Skip to content

Commit c4ea568

Browse files
authored
[WebGPU] Fix texture GetFormat to return enum int (#19027)
* [WebGPU] Fix texture GetFormat to return enum int * [WebGPU] remove deprecated dispatch path
1 parent c3f9ac2 commit c4ea568

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/library_webgpu.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,8 @@ var LibraryWebGPU = {
20082008

20092009
wgpuTextureGetFormat: function(textureId) {
20102010
var texture = WebGPU.mgrTexture.get(textureId);
2011-
return texture.format;
2011+
// Should return the enum integer instead of string.
2012+
return WebGPU.TextureFormat.indexOf(texture.format);
20122013
},
20132014

20142015
wgpuTextureGetHeight: function(textureId) {
@@ -2101,24 +2102,14 @@ var LibraryWebGPU = {
21012102

21022103
wgpuComputePassEncoderDispatchWorkgroups: function(passId, x, y, z) {
21032104
var pass = WebGPU.mgrComputePassEncoder.get(passId);
2104-
// TODO(shrekshao): Remove deprecated dispatch path
2105-
if (pass["dispatchWorkgroups"]) {
2106-
pass["dispatchWorkgroups"](x, y, z);
2107-
} else {
2108-
pass["dispatch"](x, y, z);
2109-
}
2105+
pass["dispatchWorkgroups"](x, y, z);
21102106
},
21112107
wgpuComputePassEncoderDispatchWorkgroupsIndirect: function(passId, indirectBufferId, {{{ defineI64Param('indirectOffset') }}}) {
21122108
{{{ receiveI64ParamAsI32s('indirectOffset') }}}
21132109
var indirectBuffer = WebGPU.mgrBuffer.get(indirectBufferId);
21142110
var indirectOffset = {{{ gpu.makeI32I32ToU53('indirectOffset_low', 'indirectOffset_high') }}};
21152111
var pass = WebGPU.mgrComputePassEncoder.get(passId);
2116-
// TODO(shrekshao): Remove deprecated dispatchIndirect path
2117-
if (pass["dispatchWorkgroupsIndirect"]) {
2118-
pass["dispatchWorkgroupsIndirect"](indirectBuffer, indirectOffset);
2119-
} else {
2120-
pass["dispatchIndirect"](indirectBuffer, indirectOffset);
2121-
}
2112+
pass["dispatchWorkgroupsIndirect"](indirectBuffer, indirectOffset);
21222113
},
21232114

21242115
wgpuComputePassEncoderBeginPipelineStatisticsQuery: function(passId, querySetId, queryIndex) {

test/webgpu_basic_rendering.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ void GetDevice(void (*callback)(wgpu::Device)) {
4545
}
4646

4747
static const char shaderCode[] = R"(
48-
@stage(vertex)
48+
@vertex
4949
fn main_v(@builtin(vertex_index) idx: u32) -> @builtin(position) vec4<f32> {
5050
var pos = array<vec2<f32>, 3>(
5151
vec2<f32>(0.0, 0.5), vec2<f32>(-0.5, -0.5), vec2<f32>(0.5, -0.5));
5252
return vec4<f32>(pos[idx], 0.0, 1.0);
5353
}
5454
55-
@stage(fragment)
55+
@fragment
5656
fn main_f() -> @location(0) vec4<f32> {
5757
return vec4<f32>(0.0, 0.502, 1.0, 1.0); // 0x80/0xff ~= 0.502
5858
}
@@ -309,6 +309,12 @@ void doRenderTest() {
309309
}
310310
render(readbackTexture.CreateView(), depthTexture.CreateView());
311311

312+
{
313+
// A little texture.GetFormat test
314+
assert(wgpu::TextureFormat::BGRA8Unorm == readbackTexture.GetFormat());
315+
assert(wgpu::TextureFormat::Depth32Float == depthTexture.GetFormat());
316+
}
317+
312318
{
313319
wgpu::BufferDescriptor descriptor{};
314320
descriptor.size = 4;

0 commit comments

Comments
 (0)