Geometry shader stream out bug.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 Nov 17, 2012 at 13:13

heres my debug output…

D3D11: ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Geometry Shader linkage error: Stages are incompatible with each other. Semantic ‘TEXCOORD’ is always read by the downstream shader, but never written by the upstream shader (even though the semantic is present in its output signature). [ EXECUTION ERROR #347: DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS ]

what could this mean? I was thinking it would have to be system side cause my shaders are compiling fine.

6 Replies

Please log in or register to post a reply.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 Nov 17, 2012 at 13:32

some initialization code…

D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ “POSITION”, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ “TEXCOORD”, 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ “DIFFUSE”, 0, DXGI_FORMAT_R32G32B32_FLOAT, 18, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ “NORMAL”, 0, DXGI_FORMAT_R32G32B32_FLOAT, 24, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};

UINT ls=ARRAYSIZE(layout);

D3D11_SO_DECLARATION_ENTRY layout3[] =
{
{0, “POSITION”, 0, 0, 3, 0},
{0, “TEXCOORD”, 0, 0, 2, 0},
{0, “DIFFUSE”, 0, 0, 3, 0},
{0, “NORMAL”, 0, 0, 3, 0},
};

UINT ls3=ARRAYSIZE(layout3);

vs_epl=create_vs(L”shader1.fx”,”VS_EPL”,”vs_5_0”, vl_epl, layout, ls);
gs_epl=create_gs_so(L”shader1.fx”,”GS_EPL”,”gs_5_0”, layout3, ls3);

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Nov 17, 2012 at 17:25

The error message says the geometry shader is expecting a TEXCOORD value that the vertex shader doesn’t deliver. You have to pass the texcoord value through the vertex shader even if you’re not changing it. Can you post your shader code?

And yeah, since you’re compiling the two shaders separately, they could both compile fine and it wouldn’t notice the problem until you tried to use the two together. As the error says, it is a problem with mismatched inputs/outputs between the two shaders.

46407cc1bdfbd2db4f6e8876d74f990a
0
Kenneth_Gorking 101 Nov 17, 2012 at 17:25

Sounds like you are reading from a variable that you don’t write to.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 Nov 18, 2012 at 05:00

I Still cant see whats wrong with it….

struct VS_EPL_INPUT
{
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};

struct GS_EPL_INPUT
{
float4 pos : POSITION;
float3 nor : NORMAL;
float2 uv : TEXCOORD0;
uint adj : TEXCOORD1;
};

struct PS_EPL_INPUT
{
float4 pos : POSITION;
float3 nor : NORMAL;
uint adj : TEXCOORD1;
};

GS_EPL_INPUT VS_EPL(VS_EPL_INPUT Input)
{
GS_EPL_INPUT Output;

unsigned int a=(unsigned int)(Input.uv.x*4096)+(unsigned int)(Input.uv.y*4096)*4096;

int tx,ty,tz;

ty=a%256;
tx=(a/256)%256;
tz=a/(256*256);

float4 thiscol=txDiffuse.SampleLevel(samLinear,Input.uv,0).rgba;
float4 thisnor=colour.SampleLevel(samLinear,Input.uv,0).rgba;

Output.pos = float4(float3(tx,ty,tz),1);
Output.nor= thisnor.rgb;
Output.uv= Input.uv;
Output.adj=0;

return Output;
}

[maxvertexcount(1)]
void GS_EPL( point GS_EPL_INPUT In[1], inout PointStream<PS_EPL_INPUT> PStream )
{
PS_EPL_INPUT Out;

int tx,ty,tz;

tx=In[0].pos.x;
ty=In[0].pos.y;
tz=In[0].pos.z;

float2 auv=In[0].uv;

//thats it, if its valid, output the point.
float4 thiscol=txDiffuse.SampleLevel(samLinear,auv,0).rgba;
bool valid=false;
bool top=false;
bool bottom=false;
bool side=false;

//check if its a solid voxel

float4 col[6]={float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0)};
float2 buv;
int b;

b=(ty+1)+(tx)*256+(tz)*256*256;
buv=float2((b%4096)/4096.0f,(b/4096)/4096.0f);
col[0]=txDiffuse.SampleLevel(samLinear,buv,0).rgba;
b=(ty-1)+(tx)*256+(tz)*256*256;
buv=float2((b%4096)/4096.0f,(b/4096)/4096.0f);
col[1]=txDiffuse.SampleLevel(samLinear,buv,0).rgba;
b=(ty)+(tx+1)*256+(tz)*256*256;
buv=float2((b%4096)/4096.0f,(b/4096)/4096.0f);
col[2]=txDiffuse.SampleLevel(samLinear,buv,0).rgba;
b=(ty)+(tx-1)*256+(tz)*256*256;
buv=float2((b%4096)/4096.0f,(b/4096)/4096.0f);
col[3]=txDiffuse.SampleLevel(samLinear,buv,0).rgba;
b=(ty)+(tx)*256+(tz+1)*256*256;
buv=float2((b%4096)/4096.0f,(b/4096)/4096.0f);
col[4]=txDiffuse.SampleLevel(samLinear,buv,0).rgba;
b=(ty)+(tx)*256+(tz-1)*256*256;
buv=float2((b%4096)/4096.0f,(b/4096)/4096.0f);
col[5]=txDiffuse.SampleLevel(samLinear,buv,0).rgba;

if(thiscol.a>0 && (col[0].a>0
|| col[1].a>0
|| col[2].a>0
|| col[3].a>0
|| col[4].a>0
|| col[5].a>0))
{
if(col[0].a==0) top=true;
if(col[1].a==0) bottom=true;
if(col[2].a==0) side=true;
if(col[3].a==0) side=true;
if(col[4].a==0) side=true;
if(col[5].a==0) side=true;
valid=true;
}

if(valid)
{
Out.pos = float4(float3(tx,ty,tz),1);
Out.nor = In[0].nor;
Out.adj=0;
Out.adj=4;
if(top && bottom) Out.adj=2;
else if(top) Out.adj=0;
else if(bottom) Out.adj=1;
PStream.Append(Out);
}
}

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Nov 18, 2012 at 07:51

I don’t see an issue with either TEXCOORD parameter here, but the NORMAL one is suspicious: you’re reading from it in the geometry shader, but not writing to it in the vertex shader. Any inputs to the geometry shader need to be provided by the vertex shader as outputs. Even if they are in the vertex buffer, they need to be explicitly passed through the vertex shader for the geometry shader to use them.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 Nov 18, 2012 at 07:52

Actually guys dont worry about it - i just worked out the geometry shader is running after all - its just returning an unimportant error. thanks reedbeta and ken g, i should be right.

Implicit functions are now convertable to voxels. :) give me a couple of days and ill have a new demo to show you guys, implicit voxel environment :)

shot1i.png