-
Couldn't load subscription status.
- Fork 131
Open
Description
To reproduce:
- Create a buffer using
mapped_at_creation=Trueand the MAP_READ flag. - Use
wgpuBufferGetMappedRangeto get mapped memory and write data to it. - Unmap.
- Map the buffer with MAP_READ.
- Use
wgpuBufferGetMappedRangeto get mapped memory and read data from it. - Data is all zeros.
If I submit an empty command buffer to the queue between unmap and mapping it again, it does work. So it looks like the written data is not actually submitted yet.
Here's some Python code illustrating the same. It uses an uncommitted version of wgpu-py (I'm working on the buffer mapping API), so consider this pseudo-code to help illustrate the issue.
import wgpu.backends.rs
import wgpu.utils
device = wgpu.utils.get_default_device()
data1 = b"abcdefghijkl"
# Create buffer with data
buf = device.create_buffer(size=len(data1), usage=wgpu.BufferUsage.MAP_READ, mapped_at_creation=True)
buf.write_mapped(data1)
buf.unmap()
# Comment this out to make the problem go away
# encoder = device.create_command_encoder()
# device.queue.submit([encoder.finish()])
# Download from buffer to CPU
buf.map(wgpu.MapMode.READ)
data2 = buf.read_mapped()
buf.unmap()
print(data2.tobytes())
assert data1 == data2My questions are:
Is this expected behavior (from the POV of the WebGPU spec) or something we should fix?
If the intent is to fix it, where should this happen, here or wgpu-core?
Metadata
Metadata
Assignees
Labels
No labels