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] Shader target stage is undefined #4294

Closed
DBouma opened this issue Feb 23, 2022 · 1 comment
Closed

[SPIR-V] Shader target stage is undefined #4294

DBouma opened this issue Feb 23, 2022 · 1 comment
Labels
spirv Work related to SPIR-V

Comments

@DBouma
Copy link

DBouma commented Feb 23, 2022

According to the wiki the __SHADER_TARGET_STAGE is predefined when compiling a shader.

The predefined macro, __SHADER_TARGET_STAGE, is set at compilation time depending on the option provided to the -T flag to one of the above values.

However this does not seem to be the case in SPIR-V, as the shader stage identifiers do not seem to be set accordingly.
For example when compiling a compute shader:

...
bool checkForComputeStage() {
#if __SHADER_TARGET_STAGE == __SHADER_STAGE_COMPUTE
    return true;
#else
    return false;
#endif
}

void main() {
    float4 result;
    if(checkForComputeStage() {
        result = float4(1,0,0,1);
    } else {
        result = float4(0,1,0,1);
    }
    
    //write result away to a texture or buffer
}

In this case checkForComputeStage() always returns false.

@jaebaek
Copy link
Collaborator

jaebaek commented Feb 23, 2022

It's weird .. I think it should work. We will take a look.

@DBouma DBouma closed this as completed Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spirv Work related to SPIR-V
Projects
None yet
Development

No branches or pull requests

2 participants