Sign in to follow this  
Headkaze

Simple shader invalid call

Recommended Posts

Headkaze    607
I have a pretty simple shader that binds a couple of textures for transition effects.
float Progress;

texture Input1;
sampler Input1Sampler = sampler_state
{
	Texture = <Input1>;
};
texture Input2;
sampler Input2Sampler = sampler_state
{
	Texture = <Input2>;
};


float4 Blinds(float2 uv)
{
	if (frac(uv.y * 5.0f) < Progress)
	{
		return (tex2D(Input2Sampler, uv));
	}
	else
	{
		return (tex2D(Input1Sampler, uv));
	}
}

//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 main(float2 uv : TEXCOORD) : COLOR
{
	return (Blinds(uv));
}


technique BlindsTransition
{
	pass BlindsTransition
	{
		VertexShader = null;
		PixelShader = compile ps_2_0 main();
	}
}
Here is my implementation in SlimDX (DirectX 9)
m_effect.Technique = "BlindsTransition";
m_effect.SetValue<float>("Progress", 1.0f);
m_effect.SetTexture("Input1", m_screenTexture1.DXTexture);
m_effect.SetTexture("Input2", m_screenTexture2.DXTexture);
m_effect.CommitChanges();

m_effect.Begin();
m_effect.BeginPass(0);

m_bottomQuad.Render(device);

m_effect.EndPass();
m_effect.End();
I get a "D3DERR_INVALIDCALL: Invalid call (-2005530516)" at the line "m_effect.SetValue<float>("Progress", 1.0f);" with the following stack trace.
SlimDX.Direct3D9.Direct3D9Exception occurred
  Message="D3DERR_INVALIDCALL: Invalid call (-2005530516)"
  Source="SlimDX"
  StackTrace:
       at SlimDX.Result.Throw[T](Object dataKey, Object dataValue)
       at SlimDX.Result.Record[T](Int32 hr, Boolean failed, Object dataKey, Object dataValue)
       at SlimDX.Direct3D9.Effect.set_Technique(EffectHandle value)
       at DXSplitScreen.Render(Device device) in ...Engine\DXSplitScreen.cs:line 252
       at DXRenderer.RenderMiddle() in ...Rendering\DXRenderer.cs:line 451
       at DXRenderer.Render() in ...Rendering\DXRenderer.cs:line 186
  InnerException: 
Edited by Headkaze

Share this post


Link to post
Share on other sites
Headkaze    607

The strange thing is if I remove the line

 

m_effect.Technique = "BlindsTransition";

 

then I can get the two textures fading into each other by setting the "Progress" variable. Adding that line back in and it fails. Why?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this