From ba932782817b1961aac89f741bf05a2c32c1bf15 Mon Sep 17 00:00:00 2001 From: Hajime-san <41257923+Hajime-san@users.noreply.github.com> Date: Fri, 2 Aug 2024 03:19:25 +0900 Subject: fix(ext/webgpu): assign missing `constants` property of shader about `GPUDevice.createRenderPipeline[Async]` (#24803) fixes https://github.com/denoland/deno/issues/24287 --- ext/webgpu/01_webgpu.js | 4 ++++ tests/testdata/webgpu/hellotriangle_shader.wgsl | 9 +++++++++ tests/unit/webgpu_test.ts | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/ext/webgpu/01_webgpu.js b/ext/webgpu/01_webgpu.js index e12e8699d..15b82a8e3 100644 --- a/ext/webgpu/01_webgpu.js +++ b/ext/webgpu/01_webgpu.js @@ -1490,6 +1490,7 @@ class GPUDevice extends EventTarget { fragment = { module, entryPoint: descriptor.fragment.entryPoint, + constants: descriptor.fragment.constants, targets: descriptor.fragment.targets, }; } @@ -1501,6 +1502,7 @@ class GPUDevice extends EventTarget { vertex: { module, entryPoint: descriptor.vertex.entryPoint, + constants: descriptor.vertex.constants, buffers: descriptor.vertex.buffers, }, primitive: descriptor.primitive, @@ -1638,6 +1640,7 @@ class GPUDevice extends EventTarget { fragment = { module, entryPoint: descriptor.fragment.entryPoint, + constants: descriptor.fragment.constants, targets: descriptor.fragment.targets, }; } @@ -1649,6 +1652,7 @@ class GPUDevice extends EventTarget { vertex: { module, entryPoint: descriptor.vertex.entryPoint, + constants: descriptor.vertex.constants, buffers: descriptor.vertex.buffers, }, primitive: descriptor.primitive, diff --git a/tests/testdata/webgpu/hellotriangle_shader.wgsl b/tests/testdata/webgpu/hellotriangle_shader.wgsl index f84ccfe94..9359c11ad 100644 --- a/tests/testdata/webgpu/hellotriangle_shader.wgsl +++ b/tests/testdata/webgpu/hellotriangle_shader.wgsl @@ -1,5 +1,11 @@ +// only test purpose +override value: f32; + @vertex fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4 { + // only test purpose + _ = value; + let x = f32(i32(in_vertex_index) - 1); let y = f32(i32(in_vertex_index & 1u) * 2 - 1); return vec4(x, y, 0.0, 1.0); @@ -7,5 +13,8 @@ fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) ve @fragment fn fs_main() -> @location(0) vec4 { + // only test purpose + _ = value; + return vec4(1.0, 0.0, 0.0, 1.0); } diff --git a/tests/unit/webgpu_test.ts b/tests/unit/webgpu_test.ts index 9947ea32b..43b24e41a 100644 --- a/tests/unit/webgpu_test.ts +++ b/tests/unit/webgpu_test.ts @@ -129,10 +129,18 @@ Deno.test({ vertex: { module: shaderModule, entryPoint: "vs_main", + // only test purpose + constants: { + value: 0.5, + }, }, fragment: { module: shaderModule, entryPoint: "fs_main", + // only test purpose + constants: { + value: 0.5, + }, targets: [ { format: "rgba8unorm-srgb", -- cgit v1.2.3