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

Type mismatch on location error when compiling HLSL geometry shader #1737

Closed
DiligentGraphics opened this issue Mar 23, 2019 · 6 comments
Closed

Comments

@DiligentGraphics
Copy link

Hello!
I am seeing the following Vulkan validation layer error when creating PSO with geometry shader compiled from HLSL:

Diligent Engine: ERROR: Vulkan debug message (validation): UNASSIGNED-CoreValidation-Shader-InterfaceTypeMismatch
                 Type mismatch on location 0.0: 'ptr to output vec3 of float32' vs 'ptr to input arr[1] of struct of (vec3 of float32)'
                 Object[0] (shader module): Handle 0x2b19, Name: '000002B2212936F0'

Vertex shader:

struct VSIn
{
	uint uiVertexId : SV_VertexID;
};

struct VSOutput
{
	float4 f4Position : SV_Position;
	float3 f3Color	: COLOR;
};

void main(VSIn In,
          out VSOutput Out)
{
    float4 Positions[2];
    Positions[0] = float4(-0.4,0.3,0.0,1.0);
    Positions[1] = float4(-0.35,0.25,0.0,1.0);
    float3 Color[2];
    Color[0] = float3(1.0,0.0,0.0);
    Color[1] = float3(0.0,1.0,0.0);
	Out.f4Position = Positions[In.uiVertexId];
    Out.f3Color = Color[In.uiVertexId];
}

Geometry shader:

struct VSOutput
{
	float4 f4Position : SV_Position;
	float3 f3Color	: COLOR;
};

struct GSOut
{
    VSOutput VSOut;
};


[maxvertexcount(6)]
void main(point VSOutput In[1], 
          inout TriangleStream<GSOut> triStream )
{
    float2 Offsets[3];
    Offsets[0] = float2(-0.05, -0.05);
    Offsets[1] = float2(+0.05, -0.05);
    Offsets[2] = float2( 0.0, 0.0);
    for(int i=0; i<3; i++)
    {
        GSOut Out;
        Out.VSOut = In[0];
        Out.VSOut.f4Position.xy += Offsets[i];
        triStream.Append( Out );
    }
    triStream.RestartStrip();
    for(int j=0; j<3; j++)
    {
        GSOut Out;
        Out.VSOut = In[0];
        Out.VSOut.f4Position.xy += Offsets[j]*float2(1.0, -1.0);
        triStream.Append( Out );
    }
}

Pixel shader:

struct VSOutput
{
	float4 f4Position : SV_Position;
	float3 f3Color	: COLOR;
};

struct GSOut
{
    VSOutput VSOut;
};

void main(GSOut In,
          out float4 Color : SV_Target)
{
	Color = float4(In.VSOut.f3Color,1.0);
}

Despite the error, shaders seem to work as expected. They also work properly in D3D11 and D3D12 back-ends.
glslang version: 5efb004
SPIRV-Tools version: KhronosGroup/SPIRV-Tools@2d52cbe

@olegviz
Copy link

olegviz commented Apr 14, 2019

some news on this issue ?
Im also waiting for solution for our project

@anomalous42
Copy link

anomalous42 commented Jan 29, 2020

I'm seeing a similar problem, with a slightly different error message:

Type mismatch on location 0.0: 'ptr to output vec4 of float32' vs 'ptr to input arr[3] of struct of (struct of (vec4 of float32, vec4 of float32, vec4 of float32, vec4 of float32, vec2 of float32), vec4 of uint32)'

It looks like it's expanding the struct into individual elements when compiling the vertex shader, but not doing so for the tessellation control shader.

This is again coming from HLSL shaders, and despite the scary looking error from the validation layers it also seems to be rendering correctly.

Maybe this is related to #1197

@DiligentGraphics
Copy link
Author

DiligentGraphics commented Jan 29, 2020

Yes, on Windows it still works fine, but may fail on other platforms (will certainly fail on Mac).

@dmaluev
Copy link

dmaluev commented May 11, 2020

Having the same problem with geometry and hull shaders.
This is quite critical. I need geometry shader at least for point sprites.

@danginsburg
Copy link
Contributor

Please check to see if this is fixed with #2217

@TheMostDiligent
Copy link
Contributor

I confirm the change fixes the original problem - thank you! You can close the issue (I created it under different account and can't close it).

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

6 participants