Skip to content

Commit

Permalink
fix(ext/webgpu): assign missing constants property of shader about …
Browse files Browse the repository at this point in the history
…`GPUDevice.createRenderPipeline[Async]` (#24803)

fixes #24287
  • Loading branch information
Hajime-san authored Aug 1, 2024
1 parent 6db5f1b commit ba93278
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/webgpu/01_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,7 @@ class GPUDevice extends EventTarget {
fragment = {
module,
entryPoint: descriptor.fragment.entryPoint,
constants: descriptor.fragment.constants,
targets: descriptor.fragment.targets,
};
}
Expand All @@ -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,
Expand Down Expand Up @@ -1638,6 +1640,7 @@ class GPUDevice extends EventTarget {
fragment = {
module,
entryPoint: descriptor.fragment.entryPoint,
constants: descriptor.fragment.constants,
targets: descriptor.fragment.targets,
};
}
Expand All @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions tests/testdata/webgpu/hellotriangle_shader.wgsl
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
// only test purpose
override value: f32;

@vertex
fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4<f32> {
// only test purpose
_ = value;

let x = f32(i32(in_vertex_index) - 1);
let y = f32(i32(in_vertex_index & 1u) * 2 - 1);
return vec4<f32>(x, y, 0.0, 1.0);
}

@fragment
fn fs_main() -> @location(0) vec4<f32> {
// only test purpose
_ = value;

return vec4<f32>(1.0, 0.0, 0.0, 1.0);
}
8 changes: 8 additions & 0 deletions tests/unit/webgpu_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ba93278

Please # to comment.