Skip to content

Unable to render to and then read a texture #6410

Answered by kpreid
casey asked this question in Q&A
Discussion options

You must be logged in to vote

You’re interleaving calls to wgpu::Queue with constructing a single wgpu::CommandEncoder, which doesn’t work the way you intend. Operations are executed in the order they are put on the Queue, and so all commands you encoded were enqueued at the point you submitted the command buffer to the queue, not when you encoded them. Here’s the sequence of your queue usage:

queue.write_texture(...0x00...)
queue.write_buffer({i: 0})
queue.write_buffer({i: 1})
queue.submit([encoder.finish()])

So, all of your draw calls are executed with i = 1, because all of them executed after you wrote 1 to the buffer.

To make this work as you want, you can do one of these things:

  • Encode two command buffers, so th…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@casey
Comment options

Answer selected by casey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants