Jump to content

  • Log In with Google      Sign In   
  • Create Account


Valid effects handle returning invalid technique handles


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Rectangle   Members   -  Reputation: 150

Like
0Likes
Like

Posted 31 August 2012 - 08:25 AM

Please review the comments in the code below:
[source lang="cpp"]// The following code succesfully returns a valid effect handle without failureID3DXBuffer* piBuffer = NULL;if(FAILED( D3DXCreateEffectFromFileA(m_d3dDev, m_szDefaultShaderFile, NULL, NULL, D3DXSHADER_DEBUG, NULL, &m_piDefaultEffect, &piBuffer) )){ if( piBuffer ) { MessageBoxA(NULL, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK); piBuffer->Release(); } return false;}if( piBuffer){ piBuffer->Release(); piBuffer = NULL;}// The following code succesfully returns the correct description data (6 params, 4 techs, 0 funcs)D3DXEFFECT_DESC fxd;m_piDefaultEffect->GetDesc(&fxd);// The following code returns <Bad Ptr&gt, and any following use of this handle results in errorsD3DXHANDLE tech = m_piDefaultEffect->GetTechnique(1); // FAILStech = m_piDefaultEffect->GetCurrentTechnique(); // FAILSm_piDefaultEffect->FindNextValidTechnique(NULL, &tech); // FAILS[/source]
Any idea why this could be happening? How can I fix this?

Edited by Rectangle, 31 August 2012 - 08:48 PM.


Sponsor:

#2 Asesh   Members   -  Reputation: 268

Like
0Likes
Like

Posted 31 August 2012 - 09:58 AM

How many techniques are there in that effect file? Seems like there's only one and if that's true then you should pass 0 as an argument to GetTechnique to retrieve the first technique

#3 Rectangle   Members   -  Reputation: 150

Like
0Likes
Like

Posted 31 August 2012 - 08:37 PM

How many techniques are there in that effect file? Seems like there's only one and if that's true then you should pass 0 as an argument to GetTechnique to retrieve the first technique


As stated in the comments of my previous post, GetDesc() returns 6 parameters, 4 techniques, and 0 functions.
No, GetTechnique(0) fails all the same as GetNextValidTechnique(NULL, NULL).
Here's the shader:
[source lang="cpp"]float4x4 WorldViewProjection : WORLDVIEWPROJECTION;float4x4 World : WORLD;float4x3 WorldInverseTranspose : WORLDINVERSETRANSPOSE;float3 afLightColor[5];float3 afLightDir[5];float3 vCameraPos : CAMERAPOSITION;struct VS_INPUT{ float3 Position : POSITION; float3 Normal : NORMAL;};struct VS_OUTPUT{ float4 Position : POSITION; float3 ViewDir : TEXCOORD0; float3 Normal : TEXCOORD1;};VS_OUTPUT DefaultVShader(VS_INPUT IN){ VS_OUTPUT Out; float3 objPos = IN.Position; Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection); float3 WorldPos = mul( float4( objPos, 1.0f), World); Out.ViewDir = vCameraPos - WorldPos; Out.Normal = mul(IN.Normal, WorldInverseTranspose); return Out;}float4 DefaultPShaderSpecular_D1(VS_OUTPUT IN) : COLOR0{ float4 OUT = float4(0.0f, 0.0f, 0.0f, 1.0f); float3 Normal = normalize(IN.Normal); float3 ViewDir = normalize(IN.ViewDir); { float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f; float3 Reflect = reflect (Normal, afLightDir[0]); float fHalfLambert = L1 * L1; OUT.rgb += afLightColor[0] * (fHalfLambert + saturate(fHalfLambert * 4.0f) * pow(dot(Reflect, ViewDir), 9)); } return OUT;}float4 DefaultPShaderSpecular_D2(VS_OUTPUT IN) : COLOR0{ float4 OUT = float4(0.0f, 0.0f, 0.0f, 1.0f); float3 Normal = normalize(IN.Normal); float3 ViewDir = normalize(IN.ViewDir); { float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f; float3 Reflect = reflect (ViewDir, Normal); float fHalfLambert = L1 * L1; OUT.rgb += afLightColor[0] * (fHalfLambert + saturate(fHalfLambert * 4.0f) * pow(dot(Reflect, afLightDir[0]), 9)); } { float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f; float3 Reflect = reflect (ViewDir,Normal); float fHalfLambert = L1 * L1; OUT.rgb += afLightColor[1] * (fHalfLambert + saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,afLightDir[1]),9)); } return OUT;}float4 DefaultPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR0{ float4 OUT = float4(0.0f, 0.0f, 0.0f, 1.0f); float3 Normal = normalize(IN.Normal); float3 ViewDir = normalize(IN.ViewDir); { float L1 = dot(Normal,afLightDir[0]); float3 Reflect = reflect (Normal,afLightDir[0]); OUT.rgb += afLightColor[0] * ((L1) + pow(dot(Reflect,ViewDir),9)); } return OUT;}float4 DefaultPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR0{ float4 OUT = float4(0.0f, 0.0f, 0.0f, 1.0f); float3 Normal = normalize(IN.Normal); float3 ViewDir = normalize(IN.ViewDir); { float L1 = dot(Normal,afLightDir[0]); float3 Reflect = reflect (Normal,afLightDir[0]); OUT.rgb += afLightColor[0] * ((L1) + pow(dot(Reflect,ViewDir),9)); } { float L1 = dot(Normal,afLightDir[1]); float3 Reflect = reflect (Normal,afLightDir[1]); OUT.rgb += afLightColor[1] * ((L1) + pow(dot(Reflect,ViewDir),9)); } return OUT;}technique DefaultFXSpecular_D1{ pass p0 { CullMode=none; PixelShader = compile ps_3_0 DefaultPShaderSpecular_D1(); VertexShader = compile vs_3_0 DefaultVShader(); }};technique DefaultFXSpecular_D2{ pass p0 { CullMode=none; PixelShader = compile ps_3_0 DefaultPShaderSpecular_D2(); VertexShader = compile vs_3_0 DefaultVShader(); }};technique DefaultFXSpecular_PS20_D1{ pass p0 { CullMode=none; PixelShader = compile ps_2_0 DefaultPShaderSpecular_PS20_D1(); VertexShader = compile vs_2_0 DefaultVShader(); }};technique DefaultFXSpecular_PS20_D2{ pass p0 { CullMode=none; PixelShader = compile ps_2_0 DefaultPShaderSpecular_PS20_D2(); VertexShader = compile vs_2_0 DefaultVShader(); }};[/source]

#4 Rectangle   Members   -  Reputation: 150

Like
0Likes
Like

Posted 31 August 2012 - 11:06 PM

Well after a lot of searching, I came across this post: http://www.gamedev.net/topic/400760-efffects-and-bad-ptr/

Turns out, it's supposed to be a <bad ptr>? Either way, passing the handle into SetTechnique() seems to return S_OK, so I can assume that all is well afterall.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS