microsoft / microsoft/DirectXShaderCompiler

Missing DXR PAQ indication in RDAT to determine whether MaxPayloadSizeInBytes needs validation

Open
#5,849 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

validation
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

TL;DR
Set payload size in RDAT to zero when PAQs are used on SM 6.7+, and -disable-payload-qualifiers is not used.

Details
The Payload Access Qualifiers (PAQ) feature specifies:

With payload access qualifiers (PAQs), the MaxPayloadSizeInBytes property of D3D12_RAYTRACING_SHADER_CONFIG is no longer needed. The field is ignored by drivers if PAQs are enabled (the default per above) in SM 6.7 or higher.

and:

For SM 6.7 and higher but with PAQs disabled, MaxPayloadSizeInBytes is still used.

and:

With SM 6.7 and higher, PAQs are enabled by default. The user may opt-out of the feature by using the -disable-payload-qualifiers command line flag in DXC.

However, the runtime still enforces that MaxPayloadSizeInBytes is as large as the largest used payload without respect to PAQ usage. The runtime should ignore MaxPayloadSizeInBytes when PAQs are used on SM 6.7 and higher, but the compiler doesn't place any indication of PAQ usage in the runtime data (RDAT), so the runtime doesn't have the information necessary to do so.

There are three solutions I can think of for now, with pros/cons:

  1. Add the flag and set it in SM 6.8 and above. Revise the spec to indicate that MaxPayloadSizeInBytes is ignored when using PAQs only on SM 6.8 and above.
    • Pro: spec going forward is clear, and behavior of runtime has clear dividing line.
    • Con: cannot target SM 6.7 and take advantage of this.
  2. Add the flag in the optional feature flag area (D3D11_OPTIONAL_FEATURE_FLAGS mask is 0x7FFFFF0000000000), then set the flag on SM 6.7 and above.
    • Pro: May be able to target SM 6.7 and not set MaxPayloadSizeInBytes, if you can guarantee a new enough D3D runtime.
    • Con: Lack of clarity: SM 6.7 DXR libs will still need to properly set MaxPayloadSizeInBytes if they hope to be run on the previous version of the D3D12 runtime, but if you can guarantee they only run on a newer runtime, they don't.
  3. Set the reported payload size in RDAT to zero for each DXR entry point that uses PAQs on the payload. This will cause the MaxPayloadSizeInBytes validation in the current runtime to pass.
    • Pro: Can target SM 6.7 and not set MaxPayloadSizeInBytes, regardless of the D3D runtime used, as long as the compiler is new enough.
    • Pro: The D3D runtime doesn't need to be updated to look for a new flag and skip the check, since the check will always pass when the payload size is zero.
    • Cons: I can't think of any.

So far, (3) zeroing the payload size looks like the best option.

Just make sure to respect the -disable-payload-qualifiers option as well.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the RDAT payload-size reporting path and the handling of Shader Model 6.7 payload access qualifiers; the issue names no source file or test. Done means the reported payload size is zero when PAQs are used, while preserving the existing size when -disable-payload-qualifiers is supplied.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.