-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make Queue::write_texture
work Correctly on DX12 + Add new test write_texture_subset_2d_mips
#3992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff, one minor nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Seems to not pass tests |
I haven't looked at the details but we are now ignoring
|
@teoxoy |
Related: https://gpuweb.github.io/gpuweb/#abstract-opdef-validating-linear-texture-data |
I doubt we can use But maybe we can use it to figure out why our calculations were wrong previously by comparing their outputs. |
@teoxoy looks like it, I'll look into it. |
9eb78c7
to
d655986
Compare
5096e23
to
013f712
Compare
… write_texture.rs
013f712
to
995aaf7
Compare
ran all tests and it's working as expected |
|
||
let total_bytes_in_copy = total_bytes_in_copy(format, bytes_per_row, rows_per_image, copy_size); | ||
|
||
test( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dimension is hardcoded to be wgpu::TextureDimension::D2
but should be 3d for this test.
mips_count, | ||
tex_size, | ||
copy_size, | ||
copy_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy_size, | |
tex_size, |
We should copy back the whole texture.
|
||
let val = (mip_level + 1) as u8; | ||
let data = vec![val; total_size_in_bytes as usize]; | ||
|
||
// Write the first two rows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is outdated.
); | ||
|
||
ctx.queue.submit(None); | ||
|
||
let read_buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { | ||
label: None, | ||
size: (size * size) as u64, | ||
size: (total_size_in_bytes) as u64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be large enough to copy back the whole texture.
tex_size, | ||
tex_size, | ||
tex_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems to now copy the whole texture instead of a subset (prev. height: 2
).
Height: self | ||
.buffer_layout | ||
.rows_per_image | ||
.map_or(self.size.height, |count| count * block_height), | ||
Height: self.size.height, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct but I'm not sure what happens if you copy a 3D texture with a non-default rows_per_image
.
We have RowPitch
but no ColPitch
.
Vulkan has bufferImageHeight
and Metal has sourceBytesPerImage
.
@cwfitzgerald any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dawn appears to issue one copy per layer, though I'm not 100% sure on this, as dawn has a lot of layers to their d3d12 copy code.
It seems like we should issue one copy if it's dense, otherwise one copy per subresource if it's not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my conclusion as well, Vulkan and Metal support specifying rows_per_image
for 3D textures but D3D12 doesn't.
So, for a non-default rows_per_image
we should set depth: 1
and issue multiple copies by advancing D3D12_PLACED_SUBRESOURCE_FOOTPRINT.Offset
by rows_per_image * depth_index
.
This is a pre-existing issue, will open an issue to track it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking as "Request changes"
Checklist
cargo clippy
.cargo clippy --target wasm32-unknown-unknown
if applicable.Connections
fixes #3072
Description
Fixes
Queue::write_texture
failing on the DX12 backend and added a new test to test writing/copying from different mipmap levels .Testing
Run tests for write_texture.rs