You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I've been working on the most recent commit as of writing(b153065) and came across a bit of a weird bug. If you change the dimension of view from 2d to 2d-array, it changes the output of a subsequent compute pass.
Normally, it has the output 0 0 0 0 250 255 255 255 0 0 0 0 255 255 255 255 65 29 0 0 0 0 0 0 2 0 0 0 192 2 227 92, when view is 2d. This is also the output I get regardless of dimension on Google's dawn.
But if you use 2d-array in your render pass, for some reason, that changes the output to 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.
Weirdly, if you omit renderPassEncoder.end(), you get the output that you expect. Not too sure if it's related to #24672
I've included the compute shader that I used, but it was a computer-generated compute shader so it's pretty unreadable. If you think it might have something to do with the shader, I could try reducing with a program reducer.
import*asfsfrom"node:fs"functionloadShader(file){try{constdata=fs.readFileSync(file,'utf8');returndata;}catch(err){console.error('Failed to load shader:',err);}}constinputArray=newUint8Array([150,70,43,68,72,93,63,3,183,151,92,60,76,35,220,145,218,41,20,253,167,52,142,101,213,48,121,26,214,81,179,223,193,2,227,92,253,187,11,222,231,31,209,196,41,242,17,90])constshader=loadShader('compute.wgsl');asyncfunctionmain(){constadapter=awaitnavigator.gpu.requestAdapter();constdevice=awaitadapter.requestDevice();constqueue=device.queue// Setup for beginning a render passconstencoder=device.createCommandEncoder();consttexture=device.createTexture({format: "bgra8unorm",label: "texture",size: {width: 12,height: 12,depthOrArrayLayers: 1},usage: GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,viewFormats: ["bgra8unorm"]});constview=texture.createView({dimension: "2d-array",// Works fine when it is "2d" })constrenderPassEncoder=encoder.beginRenderPass({colorAttachments: [{loadOp: "load",storeOp: "discard",view: view}],maxDrawCount: 10,});renderPassEncoder.end();// This also affects the output of the compute pass // Setup for compute passconstinputBuffer=device.createBuffer({size: 48,usage: GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST|GPUBufferUsage.INDEX|GPUBufferUsage.QUERY_RESOLVE});conststorageBuffer=device.createBuffer({size: 32,usage: GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.INDIRECT|GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.VERTEX|GPUBufferUsage.INDEX});constshaderModule=device.createShaderModule({code: shader});constcomputePipeline=device.createComputePipeline({compute: {entryPoint: "main",module: shaderModule},layout: "auto"});constcomputePassEncoder=encoder.beginComputePass();computePassEncoder.setPipeline(computePipeline);queue.writeBuffer(inputBuffer,0,inputArray);constGPUBindGroup3=device.createBindGroup({layout: computePipeline.getBindGroupLayout(0),entries: [{binding: 0,resource: {buffer: inputBuffer}},{binding: 1,resource: {buffer: storageBuffer}}]});computePassEncoder.setBindGroup(0,GPUBindGroup3);computePassEncoder.dispatchWorkgroups(1);computePassEncoder.end();// Copy results of storage buffer to output bufferconstoutputBuffer=device.createBuffer({size: 32,usage: GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST});encoder.copyBufferToBuffer(storageBuffer,0,outputBuffer,0,32);queue.submit([encoder.finish()]);// Print the output of the compute passawaitoutputBuffer.mapAsync(GPUMapMode.READ)constarrayBuffer=outputBuffer.getMappedRange();constcomputePassResult=arrayBuffer.slice(0)constreadableArray=newUint8Array(computePassResult)console.log("Compute pass has output:", ...readableArray);}main().catch(console.error);
Hi! I've been working on the most recent commit as of writing(b153065) and came across a bit of a weird bug. If you change the
dimension
ofview
from2d
to2d-array
, it changes the output of a subsequent compute pass.Normally, it has the output
0 0 0 0 250 255 255 255 0 0 0 0 255 255 255 255 65 29 0 0 0 0 0 0 2 0 0 0 192 2 227 92
, whenview
is2d
. This is also the output I get regardless ofdimension
on Google's dawn.But if you use
2d-array
in your render pass, for some reason, that changes the output to0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
.Weirdly, if you omit
renderPassEncoder.end()
, you get the output that you expect. Not too sure if it's related to #24672I've included the compute shader that I used, but it was a computer-generated compute shader so it's pretty unreadable. If you think it might have something to do with the shader, I could try reducing with a program reducer.
compute.wgsl.txt
The text was updated successfully, but these errors were encountered: