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

Incorrect behaviour when using Buffer with struct template parameter. #7109

Open
neversleeping opened this issue Jan 31, 2025 · 0 comments
Open
Assignees
Labels
bug Bug, regression, crash

Comments

@neversleeping
Copy link

Description
When using Buffer with struct template parameter (like Buffer<SomeStructName>), compilation should fail with error telling that Buffer supports only scalar, vector and matrix types as template parameter. But instead:

  1. When compiling to DXIL compilation just succeeds.
  2. When compiling to SPIRV with enabled optimizations compilation will either succeed or throw exception "Access violation reading location".
  3. When compiling to SPIRV with disabled optimizations compilation will result in flowing error:
fatal error: generated SPIR-V is invalid: Reached non-composite type while indexes still remain to be traversed.
  %21 = OpCompositeExtract %uint %20 0

Maybe, somewhat related to #7080, but not sure.

Steps to Reproduce
Compile with -E CSMain -T cs_6_6 -spirv -Od

struct Struct {
    uint member;
};

Buffer<Struct> buffer;

[numthreads(32, 1, 1)]
void CSMain()
{	
	Struct var = buffer[0];
}

https://godbolt.org/z/MGchz4K3E

This code is specifically for producing error with bug request on SPIRV compilation. It's harder to make reduced example which will lead to exception when compiling with optimizations, but this exception is caused by the same thing, because when I'm replacing Buffer with StructuredBuffer, it goes away.

Actual Behavior
Compilation in both DXIL and SPIRV should result in error that Buffer can't be used with struct template parameter.

Environment

  • DXC version: 1.8 - 1.8.0.4666 (release-1.8.2407, 8df0a9d)
  • Host Operating System: Windows 11 23H2
@neversleeping neversleeping added bug Bug, regression, crash needs-triage Awaiting triage labels Jan 31, 2025
@damyanp damyanp removed the needs-triage Awaiting triage label Feb 3, 2025
@damyanp damyanp added this to the Next+1 Release milestone Feb 3, 2025
@damyanp damyanp moved this to Triaged in HLSL Triage Feb 3, 2025
@pow2clk pow2clk moved this to Active in HLSL Support Feb 4, 2025
@pow2clk pow2clk moved this from Active to Planning in HLSL Support Feb 4, 2025
@pow2clk pow2clk moved this from Planning to Active in HLSL Support Feb 4, 2025
@damyanp damyanp moved this from Active to Needs Review in HLSL Support Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash
Projects
Status: Triaged
Development

No branches or pull requests

3 participants