Skip to content
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

Fix D3D12 WriteToSubresource size calculation #1699

Merged

Conversation

dgraves
Copy link
Contributor

@dgraves dgraves commented Aug 30, 2024

The current WriteToSubresource size calculation may not work correctly when either the DstSubresource parameter is greater than 0 or the subresource is a texture with a block compressed format.

The size calculation was updated to handle these cases using texture utility code that was originally added for D3D11, where it is used for the D3D11 UpdateSubresource and WriteToSubresource size calculations.

This fixes some crashes in ID3D12Resource::WriteToSubresource observed when capturing on devices with integrated GPUs.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 246515.

case D3D12_RESOURCE_DIMENSION_TEXTURE1D:
data_size = GetOneRowSizeByDXGIFormat(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GetOneRowSizeByDXGIFromat functions are no longer used. Would you like me to remove them as part of this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that can be a separate PR. Thanks!

return size;
}

uint64_t GetPixelByteSize(DXGI_FORMAT format)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing GetSubresourcePixelByteSize function was specifically documented as not supporting compressed texture formats, so I added a separate function to retrieve the block size for BC formats and then added this function to combine them. These could all be merged into a single function if you don't think that would produce any unexpected side effects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are fine separated.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4735 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4735 passed.

The current WriteToSubresource size calculation may not work correctly
when either the DstSubresource parameter is greater than 0 or the
subresource is a texture with a block compressed format.

The size calculation was updated to handle these cases using texture
utility code that was originally added for D3D11, where it is used for
the D3D11 UpdateSubresource and WriteToSubresource size calculations.
@dgraves dgraves force-pushed the fix-d3d12-writetosubresource-size-calc branch from 2d58500 to 795569c Compare September 5, 2024 22:44
@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 250573.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4784 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 4784 passed.

@bradgrantham-lunarg bradgrantham-lunarg merged commit 9c295b4 into LunarG:dev Sep 6, 2024
8 checks passed
@dgraves dgraves deleted the fix-d3d12-writetosubresource-size-calc branch September 6, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants