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

[SPIR-V] Fix bug using Texture2D with alias template for SpirvType #6498

Open
cassiebeckley opened this issue Apr 4, 2024 · 2 comments · May be fixed by #6951
Open

[SPIR-V] Fix bug using Texture2D with alias template for SpirvType #6498

cassiebeckley opened this issue Apr 4, 2024 · 2 comments · May be fixed by #6951
Assignees
Labels
bug Bug, regression, crash spirv Work related to SPIR-V
Milestone

Comments

@cassiebeckley
Copy link
Collaborator

Description
For the (currently unmerged) SpirvType PR, Texture2D (and presumably other built-in types) cannot be used as an argument to an alias template for SpirvType

Steps to Reproduce

Compile

template<typename SomeType, uint Length>
using Array = vk::SpirvOpaqueType</* OpTypeArray */ 28, SomeType, vk::integral_constant<uint, Length> >;

void main() {
  Array<Texture2D, 4> image;
}

With the command

dxc -T ps_6_0 -E main -spirv

Actual Behavior
Error:

foo.hlsl:2:1: error: 'Texture2D<vector<float, 4> >' is an object and cannot be used as a type parameter
using Array = vk::SpirvOpaqueType</* OpTypeArray */ 28, SomeType, vk::integral_constant<uint, Length> >;
^
foo.hlsl:5:3: note: in instantiation of template type alias 'Array' requested here
  Array<Texture2D, 4> image;
  ^

Environment

@cassiebeckley cassiebeckley added bug Bug, regression, crash spirv Work related to SPIR-V needs-triage Awaiting triage labels Apr 4, 2024
@cassiebeckley cassiebeckley self-assigned this Apr 4, 2024
@cassiebeckley cassiebeckley removed the needs-triage Awaiting triage label Apr 4, 2024
@damyanp damyanp moved this to Triaged in HLSL Triage Apr 8, 2024
@devshgraphicsprogramming

This problem isn't limited to built-in types, its also when you put one vk::SpirvType inside another: https://godbolt.org/z/sxejh1q7W

its whats blocking my "user space solution" to #5092

@s-perron s-perron added this to the HLSL 202x milestone Aug 23, 2024
cassiebeckley added a commit to cassiebeckley/DirectXShaderCompiler that referenced this issue Oct 8, 2024
There has been a validation error for passing in a built-in type to a
template since the first commit to DXC. This check exists to prevent
instances like this:

```
Texture2D<SamplerState> image;
```

When DXC was first created, users could not create their own templates,
and therefore having a generic check for this did not cause any
problems. However, now that HLSL 2021 allows users to create their own
templates, and inline SPIR-V lets users pass types in to the SpirvType
and SpirvOpaqueType templates in order to reference them, this is
causing problems.

This PR allows the SpirvType and SpirvOpaqueType templates to take
HLSL built-in types as arguments.

Fixes microsoft#6498
@devshgraphicsprogramming

another test case
https://tinyurl.com/mv3kehwp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash spirv Work related to SPIR-V
Projects
Status: New
Status: Triaged
Development

Successfully merging a pull request may close this issue.

3 participants