Jump to content
  • Advertisement
Sign in to follow this  
freeworld

Access Violation with ID3DEffect::FindNextValidTechnique()

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

I'm back, trying to figure something out using the debugger, but the debugger is giving me problems with stuff I didn't think had problems. It keeps having and Access Violation (I assume a bad pointer) with this line of code.
result = effect.effect->FindNextValidTechnique(NULL, &effect.technique);

// effect.effect is a LPD3DXEFFECT
// effect.technique is a LPD3DXHANDLE

strange is when running the program normally without the debugger, the function call return D3D_OK, and I can use the D3DXHANDLE in the next function SetTechnique which also returns ok.

Share this post


Link to post
Share on other sites
Advertisement
I would think your compiler should have complained. And I wouldn't think it would be the cause of the access violation but effect.technique should be D3DXHANDLE, not LPD3DXHANDLE.

The 2nd argument to FindNextValidTechnique should be D3DXHANDLE*, not LPD3DXHANDLE*.

Also, is effect.effect the pointer to a valid ID3DXEFFECT?

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
I would think your compiler should have complained. And I wouldn't think it would be the cause of the access violation but effect.technique should be D3DXHANDLE, not LPD3DXHANDLE.

The 2nd argument to FindNextValidTechnique should be D3DXHANDLE*, not LPD3DXHANDLE*.

Also, is effect.effect the pointer to a valid ID3DXEFFECT?


sorry I meant D3DXHANDLE not LPD... Are there ways to tell if LPD3DXEFFECT actually points to a valid effect?

The create function passes D3D_OK, and effect != NULL... I'm unaware of annother way to tell if it's valid. It shouldn't be loosing scope either cause it's all in the same function outside and { } brackets that my change its scope.

Share this post


Link to post
Share on other sites
Quote:
I meant D3DXHANDLE

Good!

Re: "validity" of effect.effect - sorry, a return of S_OK and not being NULL is all you need.

I agree, it won't go out of scope. If it did, your compiler should recognize that (hopefully).

You say when you're not in debug mode, you don't get the violation? It's usually the other way 'round [smile]

In debug mode, you do get the access violation and the program is interrupted by the debugger? Correct?

Just for fun, you may want to precede you FindNextValidTechnique call with a check for effect.effect not being NULL and see what you get in debug mode.

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
Just for fun, you may want to precede you FindNextValidTechnique call with a check for effect.effect not being NULL and see what you get in debug mode.


Tried that already and nothing.


if (effect.effect == NULL)
log("Effect NULL");
else
log("Effect !NULL");



Effect wasn't null.

Share this post


Link to post
Share on other sites
Can you try a different effect file to create your effect.effect?

Perhaps you should post your code for creating the ID3DXEFFECT (one of D3DXCreateEffect, D3DXCreateEffectFromFile, or D3DXCreateEffectFromResource, right?).

Share this post


Link to post
Share on other sites
Can you try a different effect file to create your effect.effect?

Perhaps you should post your code for creating the ID3DXEFFECT (one of D3DXCreateEffect, D3DXCreateEffectFromFile, or D3DXCreateEffectFromResource, right?).

I think DirectX didn't like the way I was representing the ID3DXEFFECT object.


//I had the effect in a struct like so
struct s
{
LPD3DXEFFECT *effect;
}

// wich pointed to an effect file store in a std::vector
// to use the effect object I was derefrenceing it like so
(*effect)->something;




for some reason it was that syntax that was causing problems, I've decided to go a simple route and using id's instead of pointer to accessing the effects like so


std::<LPD3DXEFFECT> effects;
effects[id]->something;




Now my new problem, is when using more than one effect in a scene, only the last effect in the scene shows up, anything effected by previous effects comes out all white?

Photobucket

In the above image, the background uses one effect, the rest uses annother.

heres the effects, they're exactly the same, just the second one, increases the pixels, red color.

first effect

float4x4 WorldViewProjection : WORLDVIEWPROJECTION;

struct VS_OUTPUT
{
float4 Pos : POSITION;
float2 UV : TEXCOORD0;
};

struct PS_OUTPUT
{
float4 Color : COLOR0;
};

Texture Tex;
sampler coloredtexture = sampler_state
{
Texture = <Tex>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = mirror;
AddressV = mirror;
};


VS_OUTPUT VShader(float4 Pos : POSITION,
float2 UV : TEXCOORD0)
{
VS_OUTPUT Out;
Out.Pos = mul(Pos, WorldViewProjection);
Out.UV = UV;
return Out;
}

PS_OUTPUT PShader(float2 UV : TEXCOORD0)
{
PS_OUTPUT Out;
Out.Color = tex2D(coloredtexture, UV);
return Out;
}

technique RenderScreen
{
pass P0
{
vertexshader = compile vs_2_0 VShader();
pixelshader = compile ps_2_0 PShader();
}
}



the second effect that alters the red channel

float4x4 WorldViewProjection : WORLDVIEWPROJECTION;

struct VS_OUTPUT
{
float4 Pos : POSITION;
float2 UV : TEXCOORD0;
};

struct PS_OUTPUT
{
float4 Color : COLOR0;
};

Texture Tex;
sampler coloredtexture = sampler_state
{
Texture = <Tex>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = mirror;
AddressV = mirror;
};


VS_OUTPUT VShader(float4 Pos : POSITION,
float2 UV : TEXCOORD0)
{
VS_OUTPUT Out;
Out.Pos = mul(Pos, WorldViewProjection);
Out.UV = UV;
return Out;
}

PS_OUTPUT PShader(float2 UV : TEXCOORD0)
{
PS_OUTPUT Out;
Out.Color = tex2D(coloredtexture, UV);
Out.Color.r += Out.Color.r/2;
return Out;
}

technique RenderScreen
{
pass P0
{
vertexshader = compile vs_2_0 VShader();
pixelshader = compile ps_2_0 PShader();
}
}

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!