DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Calling member function on raypayload causes `cast<X>() argument of incompatible type` error with PAQ

Open simco50 opened this issue 1 year ago • 2 comments

Description When compiling the provided simple shader repro with SM6.7 or above (when PAQ is enabled by default) or with SM6.6 and compiling with -enable-payload-qualifiers, the compiler fails with an "Internal Compiler error". It seems to be related to PAQ in combination with calling a member function on a raypayload that writes to a member.

Steps to Reproduce Example in Compiler Explorer: https://godbolt.org/z/qqKedsWv9 Commandlines that reproduce the issue:

  • -T lib_6_7
  • -T lib_6_8
  • -T lib_6_6 -enable-payload-qualifiers

Actual Behavior The output of the compiler:

Internal Compiler error: cast<X>() argument of incompatible type!
Compiler returned: 29

Environment

  • DXC version dxcompiler.dll: 1.8 - 1.8.2403.36 (9c2b82878); dxil.dll: 1.8(101.8.2403.21)
  • Host Operating System: Win11 - 22631.3296

simco50 avatar Mar 26 '24 19:03 simco50

A few bits of extra context. This reproduces back to DXC 1.7.2207 when targeting SM 6.7, so it is not a new regression. The call stack for the exception throw is:

An exception is being thrown from here, because a member function is being accessed but the code assumes all member accesses are field declarations.

This exposes a flaw in the implementation for payload access qualifiers. It incorrectly assumes all member expressions are accessing field declarations whereas here we're accessing a member function declaration.

llvm-beanz avatar Mar 27 '24 14:03 llvm-beanz

Slightly reduced repro: https://godbolt.org/z/bnb9feMv6 - this repro doesn't have any payload qualifiers at all, although passing -enable-payload-qualifiers does trigger it.

Looks like this would affect someone trying to migrate from lib_6_6 to lib_6_7.

damyanp avatar Mar 27 '24 16:03 damyanp