Jump to content
  • Advertisement
Sign in to follow this  
KuroKage

Problem with CreateVertexShader in DX9

This topic is 4524 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, When I call CreateVertexShader it always returns a D3DERR_INVALIDCALL. Please help. Here's the source.

// g_pVertexShader is a LPDIRECT3DVERTEXSHADER9
// g_pDevice is a valid LPDIRECT3DDEVICE9

HRESULT hresult;

const char basicShader[] = 
	"vs.2.0		       \n"
	"dp4 oPos.x, v0, c0    \n"
	"dp4 oPos.y, v0, c1    \n"
	"dp4 oPos.z, v0, c2    \n"
	"dp4 oPos.w, v0, c3    \n"
	"mov oD0,  v5          \n";

// Assemble shader
LPD3DXBUFFER	pShaderTokens = NULL;
LPD3DXBUFFER	pShaderErrors = NULL;
DWORD		dwAssembleFlags =   D3DXSHADER_SKIPVALIDATION;
						
hresult = D3DXAssembleShader(basicShader, 
			     sizeof(basicShader) - 1, 
		             NULL, 
	                     NULL, 
		             dwAssembleFlags,
			     &pShaderTokens, 
	                     &pShaderErrors);


if(hresult == D3DERR_INVALIDCALL)
   return(FALSE);
else if(hresult == D3DXERR_INVALIDDATA)
   return(FALSE);
else if(hresult == E_OUTOFMEMORY)
   return(FALSE);

// Create vertex shader
hresult = g_pDevice->CreateVertexShader(
             (DWORD*)pShaderTokens->GetBufferPointer(),
	      &g_pVertexShader);

if(hresult == D3DERR_INVALIDCALL)
   return(FALSE);
else if(hresult == D3DERR_OUTOFVIDEOMEMORY)
   return(FALSE);

pShaderTokens->Release();


I'm not sure if it's the cast to (DWORD*) in pShaderTokens->GetBufferPointer that I'm having a problem with or in the D3DXAssembleShader function (but it doesn't return an error). Please Help! Thank You

Share this post


Link to post
Share on other sites
Advertisement
It's most likely that you've got some compile/parse errors...

Does that shader, when in a text file, compile using the command-line fxc.exe compiler?

What, if any, are the compilation errors - cast pShaderErrors to a char* and print it to debug-out and see.

I've not done much direct-from-asm shader work, but the "vs.2.0" looks suspect - I'm sure that should be vs_2_0. Could be wrong though [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!