DrawIndexedPrimitive failing when compiling a shader as 3.0, works otherwise

Started by
2 comments, last by Hodgman 13 years, 1 month ago
I'm playing around with a simple shader, and when I call D3DXCompileShaderFromFile with the profile as vs_2_0 or vs_1_1, everything works fine.
If I use vs_3_0, the shader compiles fine but my calls to DrawIndexedPrimitive return D3DERR_INVALIDCALL. All other calls succeed.

Shader code:

struct VS_INPUT
{
float4 Position : POSITION;
float2 Texture : TEXCOORD0;
float4 VecScale : COLOR0;
float4 TexScale : COLOR1;
};

struct VS_OUTPUT
{
float4 Position : POSITION;
float2 Texture : TEXCOORD0;
};


// Global variables
float4x4 WorldViewProj;

VS_OUTPUT main( in VS_INPUT In )
{
VS_OUTPUT Out;

float4 pos = In.Position;
pos.x = In.Position.x * In.VecScale.y + In.VecScale.x;
pos.z = In.Position.z * In.VecScale.w + In.VecScale.z;

Out.Position = mul(pos,
WorldViewProj);
Out.Texture = In.Texture;

return Out;
}


Assembly for vs_1_1:
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
// float4x4 WorldViewProj;
//
//
// Registers:
//
// Name Reg Size
// ------------- ----- ----
// WorldViewProj c0 4
//

vs_1_1
def c4, 1, 0, 0, 0
dcl_position v0
dcl_texcoord v1
dcl_color v2
mov r0, v2
mad r0.xy, v0.xzzw, r0.ywzw, r0.xzzw
mov r0.z, c4.x
dp3 oPos.x, r0, c0.xzww
dp3 oPos.y, r0, c1.xzww
dp3 oPos.z, r0, c2.xzww
dp3 oPos.w, r0, c3.xzww
mov oT0.xy, v1

// approximately 8 instruction slots used



Assembly code for vs_3_0:

//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
// float4x4 WorldViewProj;
//
//
// Registers:
//
// Name Reg Size
// ------------- ----- ----
// WorldViewProj c0 4
//

vs_3_0
def c4, 1, 0, 0, 0
dcl_position v0
dcl_texcoord v1
dcl_color v2
dcl_position o0
dcl_texcoord o1.xy
mov r0, v2
mad r0.xy, v0.xzzw, r0.ywzw, r0.xzzw
mov r0.z, c4.x
dp3 o0.x, r0, c0.xzww
dp3 o0.y, r0, c1.xzww
dp3 o0.z, r0, c2.xzww
dp3 o0.w, r0, c3.xzww
mov o1.xy, v1

// approximately 8 instruction slots used



Anyone know why it could be failing?
Advertisement
Enable the debug runtimes (in teh DirectX Control Panel) and check your debug output, it'll tell you why the call is failing.
I'm using the debug runtimes, output only said "Direct3D9: (ERROR) :DrawIndexedPrimitive failed."

After digging around for a bit and enabling a pixel shader, the call started working, so I guess you can't use a 3.0 vertex shader without a pixel shader.
After digging around for a bit and enabling a pixel shader, the call started working, so I guess you can't use a 3.0 vertex shader without a pixel shader.
Specifically, 3.0 shaders have to be paired with other 3.0 shaders. e.g. you can't use a 3.0 pixel with a 2.0 vertex.

This topic is closed to new replies.

Advertisement