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

Clip Distance always added as member decoration even if not used? #472

Closed
dankbaker opened this issue Aug 17, 2016 · 4 comments
Closed

Clip Distance always added as member decoration even if not used? #472

dankbaker opened this issue Aug 17, 2016 · 4 comments

Comments

@dankbaker
Copy link
Contributor

My test GLSL shader

#version 450

layout(set=0,binding=0) buffer Dynamics
{    
     layout(offset=0)  vec4 s_Color;
     layout(offset=16) vec4 s_Color2;
     layout(offset=32) vec2 Scale;
     layout(offset=40) vec2 Offset;
     layout(offset=48) float ZDepth;
} DynamicsI;

layout(set=1,binding=0) uniform samplerBuffer V_Position;
layout(set=1,binding=1) uniform samplerBuffer V_TexCoord;

out vec2 Tex;

void main() 
{
    vec4 Pos = texelFetch (V_Position, gl_VertexIndex );
    Pos.xy = Pos.xy * DynamicsI.Scale + DynamicsI.Offset;

    Tex = texelFetch (V_TexCoord, gl_VertexIndex ).xy;
    gl_Position = Pos;
}

Will fail creation, with this message:

SC (ERROR): object: 0x0 type: 0 location: 8648 msgCode: 5: SPIR-V module not valid: Operand 4 of MemberDecorate requires one of these capabilities: ClipDistance

Looking through the SPRIV, I see:

    MemberDecorate 47(gl_PerVertex) 0 BuiltIn Position
    MemberDecorate 47(gl_PerVertex) 1 BuiltIn PointSize
    MemberDecorate 47(gl_PerVertex) 2 BuiltIn ClipDistance
    MemberDecorate 47(gl_PerVertex) 3 BuiltIn CullDistance

Which appears to be because of

    // version >= 150
            stageBuiltins[EShLangVertex].append(
                "out gl_PerVertex {"
                    "vec4 gl_Position;"     // needs qualifier fixed later
                    "float gl_PointSize;"   // needs qualifier fixed later
                    "float gl_ClipDistance[];"
                    );         

code in Initialize.cpp. I guess I'm not understanding what's going on here. It looks like this feature isn't supported by the device I am trying to create on (and AMD desktop card), but I'm not actually using the decoration, SPIRV is just outputting over generalized information. Is that what's going on? What's supposed to happen for optional features like this, are there profiles?

@johnkslang
Copy link
Member

johnkslang commented Aug 17, 2016

We had a big discussion about this internally to Khronos a while back and the decision was that it is okay to decorate with ClipDistance (and similar), but it's the actual reading and writing that needs the capability. Unless you read or wrote to clip distance, you are not really using the hardware feature, and the hardware capability is not in use, so the capability does not need to be declared, and the consumer should not care. The reasons are somewhat complex, but have to do with cross-stage linking and some other things.

Should only be an error if your SPIR-V declared the capability and the target hardware doesn't have the actual feature.

@dankbaker
Copy link
Contributor Author

dankbaker commented Aug 18, 2016

That's fine, but the debug validation layer is failing me because of it which is super annoying. Is there a way to not declare it in the SPIRV or can we get the validation removed for this? e.g. the decoration doesn't fail validation just if it's used?

Even spitting out a warning message will spew so many messages as to make the debug layer useless.

@ratchetfreak
Copy link

if you want things to get moving on validation then you can add an issue to https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/ (the repo with the actual validation)

@johnkslang
Copy link
Member

This should be fixed now, via KhronosGroup/SPIRV-Tools#365.

FireBurn pushed a commit to FireBurn/mesa that referenced this issue Jul 16, 2023
Clip/cull distances are weird, the indicator that they are used
is not them being declared but the fact of reading/writing them.
(See KhronosGroup/glslang#472)

Usually if they are not written/read the got DCEd but when
XFB is used they may be forced to remain. This makes a7xx
especially grumpy.

Fixes on a7xx:
 dEQP-VK.rasterization.provoking_vertex.transform_feedback.*

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
FireBurn pushed a commit to FireBurn/mesa that referenced this issue Jul 17, 2023
Clip/cull distances are weird, the indicator that they are used
is not them being declared but the fact of reading/writing them.
(See KhronosGroup/glslang#472)

Usually if they are not written/read the got DCEd but when
XFB is used they may be forced to remain. This makes a7xx
especially grumpy.

Fixes on a7xx:
 dEQP-VK.rasterization.provoking_vertex.transform_feedback.*

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
FireBurn pushed a commit to FireBurn/mesa that referenced this issue Jul 19, 2023
Clip/cull distances are weird, the indicator that they are used
is not them being declared but the fact of reading/writing them.
(See KhronosGroup/glslang#472)

Usually if they are not written/read the got DCEd but when
XFB is used they may be forced to remain. This makes a7xx
especially grumpy.

Fixes on a7xx:
 dEQP-VK.rasterization.provoking_vertex.transform_feedback.*

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
FireBurn pushed a commit to FireBurn/mesa that referenced this issue Jul 20, 2023
Clip/cull distances are weird, the indicator that they are used
is not them being declared but the fact of reading/writing them.
(See KhronosGroup/glslang#472)

Usually if they are not written/read the got DCEd but when
XFB is used they may be forced to remain. This makes a7xx
especially grumpy.

Fixes on a7xx:
 dEQP-VK.rasterization.provoking_vertex.transform_feedback.*

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
FireBurn pushed a commit to FireBurn/mesa that referenced this issue Jul 25, 2023
Clip/cull distances are weird, the indicator that they are used
is not them being declared but the fact of reading/writing them.
(See KhronosGroup/glslang#472)

Usually if they are not written/read the got DCEd but when
XFB is used they may be forced to remain. This makes a7xx
especially grumpy.

Fixes on a7xx:
 dEQP-VK.rasterization.provoking_vertex.transform_feedback.*

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
FireBurn pushed a commit to FireBurn/mesa that referenced this issue Jul 26, 2023
Clip/cull distances are weird, the indicator that they are used
is not them being declared but the fact of reading/writing them.
(See KhronosGroup/glslang#472)

Usually if they are not written/read the got DCEd but when
XFB is used they may be forced to remain. This makes a7xx
especially grumpy.

Fixes on a7xx:
 dEQP-VK.rasterization.provoking_vertex.transform_feedback.*

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants