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

vk::ext_type_def fails to compile #5181

Open
forbiddencactus opened this issue May 3, 2023 · 5 comments
Open

vk::ext_type_def fails to compile #5181

forbiddencactus opened this issue May 3, 2023 · 5 comments
Assignees
Labels
bug Bug, regression, crash spirv Work related to SPIR-V

Comments

@forbiddencactus
Copy link

forbiddencactus commented May 3, 2023

The following code, as detailed in the wiki, fails to compile:

[[vk::ext_type_def(/* Unique id for type */ 0, /* OpTypeInt */ 21)]] void createTypeInt([[vk::ext_literal]] int sizeInBits, [[vk::ext_literal]] int signedness); createTypeInt(/* sizeInBits */ 12, /* signedness */ 0); .. vk::ext_type</* Unique id for type */ 0> foo = 3;

@s-perron s-perron self-assigned this May 3, 2023
@s-perron s-perron added spirv Work related to SPIR-V bug Bug, regression, crash labels May 3, 2023
@s-perron
Copy link
Collaborator

s-perron commented May 3, 2023

At a quick glance, I believe the wiki is incorrect and misleading.

First the createTypeInt(/* sizeInBits */ 12, /* signedness */ 0) needs to be inside a function. A function call in that location does not parse. This is the misleading part.

The wrong parts are first you cannot have a 12 bit integer. If I fix this up to be able to parse, you can see the error. Try

[[vk::ext_type_def(0, 21)]]
void createTypeInt([[vk::ext_literal]] int sizeInBits,
                   [[vk::ext_literal]] int signedness);

vk::ext_type<0> foo;
float main() : SV_Target
{
    createTypeInt(12, 0);
    return 0.0;
}

I get the error:

fatal error: generated SPIR-V is invalid: Invalid number of bits (12) used for OpTypeInt.
%spirvIntrinsicType = OpTypeInt 12 0

The second error is the assigment vk::ext_type</* Unique id for type */ 0> foo = 3. The compiler cannot do anything with this because it does not know that the ext_type is an integer. As far as the compiler is concerned there is a type mismatch.

@s-perron
Copy link
Collaborator

s-perron commented May 3, 2023

@forbiddencactus Thanks for bring this up. I have recently pointed a few people to this wiki and suggested they try it. I assumed it all worked. This will need to be fixed up.

@forbiddencactus
Copy link
Author

No worries!

In general GL_EXT_spirv_intrinsics is a bit patchy, edge cases that don't work and that sort of thing. I can't remember the other issues off the top of my head but will begin reporting them as I find them again. :)

@s-perron
Copy link
Collaborator

I have opened microsoft/hlsl-specs#59 to try to clean up the spec. The documentation will be updated once we have updated the HLSL spec. I don't want to update it multiple times.

@s-perron s-perron assigned cassiebeckley and unassigned s-perron Jan 30, 2024
@s-perron
Copy link
Collaborator

Now that we have finished updating the inline spir-v, could you update the wiki that is pointed to above?

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
None yet
Development

No branches or pull requests

3 participants