Skip to content

Commit

Permalink
The D3D12_SUBRESOURCE_FOOTPRINT was calculated incorrectly by multipl…
Browse files Browse the repository at this point in the history
…ying the height by the block count.

DirectX automatically takes format into account because it's passed into the footprint. Only the block width is necessary to compute the pitch or linear size. This prevents a crash when using `Queue::write_texture` with a block compressed texture.
  • Loading branch information
dtzxporter committed Jan 4, 2024
1 parent 31d50af commit a15b969
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions wgpu-hal/src/dx12/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl crate::BufferTextureCopy {
&self,
format: wgt::TextureFormat,
) -> d3d12_ty::D3D12_PLACED_SUBRESOURCE_FOOTPRINT {
let (block_width, block_height) = format.block_dimensions();
let (block_width, _) = format.block_dimensions();
d3d12_ty::D3D12_PLACED_SUBRESOURCE_FOOTPRINT {
Offset: self.buffer_layout.offset,
Footprint: d3d12_ty::D3D12_SUBRESOURCE_FOOTPRINT {
Expand All @@ -30,10 +30,7 @@ impl crate::BufferTextureCopy {
)
.unwrap(),
Width: self.size.width,
Height: self
.buffer_layout
.rows_per_image
.map_or(self.size.height, |count| count * block_height),
Height: self.size.height,
Depth: self.size.depth,
RowPitch: {
let actual = self.buffer_layout.bytes_per_row.unwrap_or_else(|| {
Expand Down

0 comments on commit a15b969

Please sign in to comment.