Jump to content
  • Advertisement
Sign in to follow this  
Stormtrooper

[SlimDX] D3DERR_INVALIDCALL

This topic is 3724 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

(Hope its not a problem me asking all these questions, hopefully this one isn't quite as simple as the last one) Ok I'm trying to set up shaders for the first time. I'm getting a D3DERR_INVALIDCALL at this line: _spriteEffect.SetValue("g_samSrcColor", _testSprite); And this shader:
sampler2D g_samSrcColor;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0
{
    float4 Color;
    
    Color = tex2D( g_samSrcColor, Tex.xy)*10;
    return Color;
}


technique TestShader
{
    pass p1
    {
        VertexShader = null;
        PixelShader = compile ps_2_0 MyShader();
    }

}
When I comment out that line, everything works fine and the texture gets rendered but without the shader. What could be wrong? _testSprite is a Texture.

Share this post


Link to post
Share on other sites
Advertisement
I checked that out and tried using "texture" and "Texture2D" and they both crash at

_spriteEffect = Effect.FromFile(_device, "shader.fx", ShaderFlags.None);

with an E_FAIL: Undetermined error occurred.

Share this post


Link to post
Share on other sites
Quote:

I checked that out and tried using "texture" and "Texture2D" and they both crash at

_spriteEffect = Effect.FromFile(_device, "shader.fx", ShaderFlags.None);

with an E_FAIL: Undetermined error occurred.


texture g_samSrcColor;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;

Color = tex2D( g_samSrcColor, Tex.xy)*10;
return Color;
}


technique TestShader
{
pass p1
{
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}

}

This (your original shader with the sampler replaced by texture) is what you tried, yes? This is an invalid shader:
Quote:

> fxc.exe /Tfx_2_0 test.fx
Microsoft (R) D3D10 Shader Compiler 9.23.949.2378
Copyright (C) Microsoft Corporation 2002-2007. All rights reserved.

test.fx(7,13): error X3017: 'tex2D': cannot implicitly convert from 'const texture' t o 'const sampler2D'

compilation failed; no code produced


You need a texture to set from the CPU and a sampler to bind. You might want to look at how some of the shaders that use textures in the DirectX samples are written.

Share this post


Link to post
Share on other sites
Ok sweet, this worked and didn't return any errors, but the effect doesn't get rendered.


texture myTexture;

sampler2D texSampler0 : TEXUNIT0 = sampler_state
{
Texture = (myTexture);
MIPFILTER = LINEAR;
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
};

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;

Color = tex2D( texSampler0, Tex.xy)*10;
return Color;
}


technique TestShader
{
pass p1
{
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}

}






// Putting draw sprite here just for testing
public void BeginScene()
{
_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
_device.BeginScene();
_sprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.DoNotSaveState);
_spriteEffect.Begin(FX.None);
_spriteEffect.BeginPass(0);
drawSprite(_testSprite, new Rectangle(32, 0, 32, 32), new Point(32, 32), Color.White);

}


/// <summary>
/// Ends the scene
/// </summary>
public void EndScene()
{
_spriteEffect.EndPass();
_spriteEffect.End();
_sprite.End();
_device.EndScene();
}


Got the shader code from here

Share this post


Link to post
Share on other sites
Ok I did that and used Debug View and I get quite a bit of errors, unfortunately I don't know what to do about it. It says that "Total of 4 objects still alive" after I close the program. So I assume there are objects that need to be freed or cleaned up upon closing? Right now, my renderer has a Dispose method that calls _device.Dispose()


[2788] Direct3D9: (INFO) :======================= Hal SWVP device selected
[2788]
[2788] Direct3D9: (INFO) :Using P4 PSGP
[2788]
[2788] D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.44115e+017f. This is ok.
[2788] Total of 4 objects still alive.
[2788] Direct3D9: (ERROR) : [0] : Address 0483E4CB
[2788]
[2788] Direct3D9: (ERROR) : [1] : Address 0483E59B
[2788]
[2788] Direct3D9: (ERROR) : [2] : Address 0483E440
[2788]
[2788] Direct3D9: (ERROR) : [3] : Address 04832DB4
[2788]
[2788] Direct3D9: (ERROR) : [4] : Address 4FDFAF2E
[2788]
[2788] Direct3D9: (ERROR) : [5] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [6] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [7] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [8] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [9] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [10] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [11] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [12] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [13] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [14] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [15] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [0] : Address 048350D4
[2788]
[2788] Direct3D9: (ERROR) : [1] : Address 04835EBF
[2788]
[2788] Direct3D9: (ERROR) : [2] : Address 048365F8
[2788]
[2788] Direct3D9: (ERROR) : [3] : Address 04832DD5
[2788]
[2788] Direct3D9: (ERROR) : [4] : Address 4FDFAF2E
[2788]
[2788] Direct3D9: (ERROR) : [5] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [6] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [7] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [8] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [9] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [10] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [11] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [12] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [13] : Address 00000000
[2788]
[2788] Direct3D9: (ERROR) : [14] : Address 00000000
...keeps going with the Direct3D9 ERROR



Share this post


Link to post
Share on other sites
Ok, I fixed the errors by disposing the effet, the sprite, the texture, and the device. No more DX errors, but still no shader effect. Do I need to compile the shader or something?

EDIT: I also compiled my shader with the fxc.exe and it compiles fine.

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!