DirectX10: SV_PrimtiveID always 0, POINT_LIST
Hi,
currenty I'm implementing GPGPU stuff with DX10/C++ under Vista. I organized my algorithms in that way, that I access specific primtive data by using primitive id. For that I wanted to use the new hancy fancy SV_ semantics, especially SV_PrimitiveId. The Problem is, that it is always default 0. My algorithms implement code with scatter operations, so I have to implement it in the vertex shader or geometry shader.
My input geometry is a point list of size n. I write my shaders by using NVidias FXComposer to avoid syntax errors and all that typo stuff. I'm using PIX to debug my DX10 code.
The first thing I tried was a uint field in the input structure of my geometry shader. The field was taged by SV_PrimitiveId. So first error, FXComposer told me that SV_PrimtiveId can't be in an input structure of a geometry shader. It has to be a single input parameter of the shader. Next I tried this... (in uint id: SV_PRIMITIVEID) no syntax errors so far, but always default 0.
My thoughts are... point list is a list of geometric point primitives, so that SV_PrimtiveID has to have the current primitve id. Second the March 2008 DX10 SDK documentation states:
Name: SV_PrimitiveID
Desc.: Per-primitive identifier
Stages: Geometry Shader, Pixel Shader
Type: uint
Stages: Geometry Shader, seems to be completly nonsene. So does anybody have a tip for this problem.
Cheers
Maik
As i know, the uint that indicates primitive number it's generated only when you are using geometry instancing.
So you have to call DrawInstanced or DrawIndexedInstanced to use it
So you have to call DrawInstanced or DrawIndexedInstanced to use it
Quote:Original post by XVincentXI think you're getting confused with SV_InstanceID [smile]
As i know, the uint that indicates primitive number it's generated only when you are using geometry instancing.
To the OP, have you considered using SV_VertexID from the VS (passed through if necessary)? For point lists this should be the same value, and maybe (long shot - I can't find anything to confirm or deny) it doesn't set up SV_PrimitiveID for a point list..?
hth
Jack
Hi,
@XVincentX
SV_InstanceID indeed delivers the id of the current instance. This was my first trick. I created a stub point element... a point list with one element. This was then rendered n times with DrawInstanced(1, n, 0, 0). Worked great... but PIX isn't able to debug a pixel which contains a DrawInstanced call.
So to debug my code I had to look for an efficient replacement for this...
@jollyjeffers
I gave SV_VertexID a shot and it didn't worked out. DX10 handles each point with its own Draw internally, according to PIX debug information. Each draw is indexed by an primtive id 1 of n ... n of n. VertexId is always 0 per draw call. For me its clear, a point is a primitive on its own. A vertex id of 0 per point is correct.
Furthermore I don't think that SV_PrimitiveId isn't set for a POINT_LIST =).
Cheers
Maik
@XVincentX
SV_InstanceID indeed delivers the id of the current instance. This was my first trick. I created a stub point element... a point list with one element. This was then rendered n times with DrawInstanced(1, n, 0, 0). Worked great... but PIX isn't able to debug a pixel which contains a DrawInstanced call.
So to debug my code I had to look for an efficient replacement for this...
@jollyjeffers
I gave SV_VertexID a shot and it didn't worked out. DX10 handles each point with its own Draw internally, according to PIX debug information. Each draw is indexed by an primtive id 1 of n ... n of n. VertexId is always 0 per draw call. For me its clear, a point is a primitive on its own. A vertex id of 0 per point is correct.
Furthermore I don't think that SV_PrimitiveId isn't set for a POINT_LIST =).
Cheers
Maik
I'm sure you've seen this info from the docs:
"For example, SV_PrimitiveID cannot be interpreted by the vertex-shader stage since a vertex can be a member of multiple primitives. As a result, SV_PrimitiveID is only available to the geometry-shader stage, or the pixel-shader stage if the geometry-shader stage is inactive."
I know that you can get the SV_PrimitiveId to work in the pixel shader. If you open up the D3D10 Tutoria03 and modify two things, you can see it working for yourself with point lists.
Tutorial03.fx: Change the pixel shader to what I have below.
Tutorial03.cpp: Change line 255 to what I have below.
It would be easy to add a simple geometry shader to this sample and see that the primitive id works there too. Hopefully this will help you spot the issue in your code.
-Dieter
"For example, SV_PrimitiveID cannot be interpreted by the vertex-shader stage since a vertex can be a member of multiple primitives. As a result, SV_PrimitiveID is only available to the geometry-shader stage, or the pixel-shader stage if the geometry-shader stage is inactive."
I know that you can get the SV_PrimitiveId to work in the pixel shader. If you open up the D3D10 Tutoria03 and modify two things, you can see it working for yourself with point lists.
Tutorial03.fx: Change the pixel shader to what I have below.
float4 colors[3] = { float4( 1.0f, 0.0f, 0.0f, 1.0f ), float4( 0.0f, 1.0f, 0.0f, 1.0f ), float4( 1.0f, 1.0f, 0.0f, 1.0f )};//// Pixel Shader//float4 PS( float4 Pos : SV_POSITION, uint PrimitiveId : SV_PRIMITIVEID ) : SV_Target{ return colors[PrimitiveId];}
Tutorial03.cpp: Change line 255 to what I have below.
g_pd3dDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_POINTLIST );
It would be easy to add a simple geometry shader to this sample and see that the primitive id works there too. Hopefully this will help you spot the issue in your code.
-Dieter
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement