Forum

StreamOutGS, but nothing coming out GS

Heya!

I’m trying some basic StreamOut stuff for the first time:

Lines shader:

struct vsOutput
{
	float4 PosO: POSITION;
	float2 UV: TEXCOORD0;
};

vsOutput VS(
	float4 PosO: POSITION,
	float2 UV: TEXCOORD0,
	uint InstanceID: SV_VertexID)
{
	vsOutput Out;
	
	Out.PosO = PosO;
	Out.UV = UV;
	
    return Out;
}

struct gsOutput
{
    float4 PosO: SV_POSITION;
    float2 TexCd : TEXCOORD0;
};

[maxvertexcount(2)](maxvertexcount(2))
void GS(point vsOutput input[1](1), inout LineStream<gsOutput> lines)
{
    gsOutput output;
	
	output.PosO = input[0](0).PosO;
	output.TexCd = float2(0,0);
	lines.Append(output);
	
	output.PosO = input[0](0).PosO + float4(1, 1, 0, 0);
	lines.Append(output);
	
	lines.RestartStrip();
}

GeometryShader StreamOutGS = ConstructGSWithSO( CompileShader( gs_4_0, GS() ), "POSITION.xyzw;TEXCOORD0.xy", NULL,NULL,NULL,-1 );

technique11 MakeLines
{
    pass PP2
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( StreamOutGS );
    }  
}

As you can see Technique Valid is coming out false.
TTY Renderer reports “Invalid layout detected for slices:0”.
I presume there’s an issue with my gsOutput ?

Ah. Now getting Technique Valid

Changed

struct gsOutput
{
    float4 PosO: SV_POSITION;
    float2 TexCd : TEXCOORD0;
};

to

struct gsOutput
{
    float4 PosO: POSITION;
    float2 TexCd : TEXCOORD0;
};

Still not getting the expected result (seems like Lines is just passing through the geometry coming into it)

Also had to add the Topology node (thought the output topology was defined at:)

void GS(point vsOutput input[1](1), inout LineStream<gsOutput> lines)

Now works

i usually have no problem with gsfx’s however i recommend using custom layouts instead of auto.

Thanks for the tip
I tried that also, but it didn’t affect my result so put it back to auto. Will watch out in future.

Quick question :
What is the ‘As Auto’ toggle for?

that’s a good question i didn’t dig into that, i just experienced it is better to leave it on, if you use manual layouts obviously turn of auto layout because that will try to guess your desired layout from shader code afaik (so if you use SV_POSITION it will create that semantic instead of POSITION)