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

Add "sledgehammer" option for buffer packing/unpacking for bound shader data #3726

Open
jeremyong-az opened this issue Aug 30, 2021 · 1 comment
Labels
feature/graphics This item is related to the Atom renderer or graphics. priority/minor Lowest priority. Work that may be scheduled sig/graphics-audio Categorizes an issue or PR as relevant to SIG graphics-audio.

Comments

@jeremyong-az
Copy link
Contributor

jeremyong-az commented Aug 30, 2021

Is your feature request related to a problem? Please describe.
Resource binding rules are confusing. When all else fails and we don't want to bother ensuring consistent packing between CPU and GPU memory, we can use raw buffer views, accessed as ByteAddressBuffers in HLSL code.

Describe the solution you'd like
Accessing memory in this way requires the SRV to be created with the appropriate flag (D3D12_BUFFER_SRV_FLAG_RAW). After which, the bound slot is denoted as a ByteAddressBuffer (see https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-byteaddressbuffer).

The ByteAddressBuffer lets us load/store arbitrary data at dword-aligned offsets, meaning we can control the packing ourselves up to word granularity. Leveraging this, we can define a consistent packing rule across all APIs/platforms that support BAB semantics. Having this degree of packing control means we can guarantee all RHI backends that have the same support for the load/store code gen.

Additional context
Note that we technically have ByteAddressBuffer::Load and RWByteAddressBuffer::Store from here: microsoft/DirectXShaderCompiler#2176

However, on some GPUs, there may be unfortunate codegen using the templated loads/stores here: microsoft/hlsl-specs#258

@jeremyong-az jeremyong-az added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/graphics-audio Categorizes an issue or PR as relevant to SIG graphics-audio. feature/graphics This item is related to the Atom renderer or graphics. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 30, 2021
@moudgils
Copy link
Contributor

Relevant blog - http://www.joshbarczak.com/blog/?p=1260

@superkitcath superkitcath removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 29, 2021
@superkitcath superkitcath added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Nov 10, 2021
@wintermute-motherbrain wintermute-motherbrain added priority/minor Lowest priority. Work that may be scheduled and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/graphics This item is related to the Atom renderer or graphics. priority/minor Lowest priority. Work that may be scheduled sig/graphics-audio Categorizes an issue or PR as relevant to SIG graphics-audio.
Projects
None yet
Development

No branches or pull requests

4 participants