Skip to content

Commit

Permalink
Remove superfluous || 1 after devicePixelRatio
Browse files Browse the repository at this point in the history
There are no browsers that run WebGPU that don't support
devicePixelRatio
  • Loading branch information
greggman committed Oct 27, 2023
1 parent 529047e commit 302bfef
Show file tree
Hide file tree
Showing 25 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/sample/a-buffer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
};

const configure = () => {
let devicePixelRatio = window.devicePixelRatio || 1;
let devicePixelRatio = window.devicePixelRatio;

// The default maximum storage buffer binding size is 128Mib. The amount
// of memory we need to store transparent fragments depends on the size
Expand Down
2 changes: 1 addition & 1 deletion src/sample/animometer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {

const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/bitonicSort/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const SampleInitFactoryWebGPU = async (
const device = await adapter.requestDevice();
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;
const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/cameras/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
const device = await adapter.requestDevice();
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/computeBoids/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {

if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;
const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/cornell/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
gui.add(params, 'renderer', ['rasterizer', 'raytracer']);
gui.add(params, 'rotateCamera', true);

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;

Expand Down
2 changes: 1 addition & 1 deletion src/sample/cubemap/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/deferredRendering/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const aspect = canvas.width / canvas.height;
Expand Down
2 changes: 1 addition & 1 deletion src/sample/fractalCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/gameOfLife/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
const device = await adapter.requestDevice();
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;
const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/helloTriangle/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/helloTriangleMSAA/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/imageBlur/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/instancedCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/particles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/renderBundles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const init: SampleInit = async ({ canvas, pageState, gui, stats }) => {

const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/resizeCanvas/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {

const presentationFormat = navigator.gpu.getPreferredCanvasFormat();

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;

Expand Down
2 changes: 1 addition & 1 deletion src/sample/reversedZ/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {

const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/rotatingCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/shadowMapping/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {

const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const aspect = canvas.width / canvas.height;
Expand Down
2 changes: 1 addition & 1 deletion src/sample/texturedCube/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/twoCubes/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
if (!pageState.active) return;
const context = canvas.getContext('webgpu') as GPUCanvasContext;

const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/videoUploading/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
if (!pageState.active) return;

const context = canvas.getContext('webgpu') as GPUCanvasContext;
const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/videoUploadingWebCodecs/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
if (!pageState.active) return;

const context = canvas.getContext('webgpu') as GPUCanvasContext;
const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
canvas.width = canvas.clientWidth * devicePixelRatio;
canvas.height = canvas.clientHeight * devicePixelRatio;
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
Expand Down
2 changes: 1 addition & 1 deletion src/sample/worker/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const init: SampleInit = async ({ canvas, pageState }) => {
// Anything drawn to the OffscreenCanvas that call returns will automatically be displayed on
// the source canvas on the page.
const offscreenCanvas = canvas.transferControlToOffscreen();
const devicePixelRatio = window.devicePixelRatio || 1;
const devicePixelRatio = window.devicePixelRatio;
offscreenCanvas.width = canvas.clientWidth * devicePixelRatio;
offscreenCanvas.height = canvas.clientHeight * devicePixelRatio;

Expand Down

0 comments on commit 302bfef

Please sign in to comment.