Sign in to follow this  
GuyWithBeard

[SlimDX] Problems creating effect

Recommended Posts

In SlimDX I try to create a new DX9 effect using: m_Effect = Effect.FromFile(m_Core.Renderer.Device, "temp.fx", null, null, ShaderFlags.Debug | ShaderFlags.PartialPrecision, null); The effect object gets created correctly but I cannot pass values into it or call its methods because the internal EffectPointer and InternalPointer, that apparently should hold the actual DX effect have values of 0. Why does this happen? Thanks for your help! //chinc [Edited by - chinc on February 20, 2008 6:43:46 AM]

Share this post


Link to post
Share on other sites
I did some research. Let's say I want to set the technique using:

m_Effect.Technique = "PPL";

The framework throws an null reference exception in the technique setter:

void Effect::Technique::set( EffectHandle^ value )
{
D3DXHANDLE handle = value != nullptr ? value->InternalHandle : NULL;
HRESULT hr = EffectPointer->SetTechnique( handle );
Result::Record( hr );
}

The second line won't execute since EffectPointer has a value of 0x00000000. It seems the effect pointers loose their values at some point. Any ideas?

Share this post


Link to post
Share on other sites
I am using the latest SVN revision (346). I have tracked down the error to the macro in ComObject.h:

#define COMOBJECT(type) internal: static property System::Guid NativeInterface { System::Guid get() { return Utilities::ConvertNativeGuid( IID_ ## type ); } } property type* InternalPointer { type* get() { type* result = 0; UnknownPointer->QueryInterface( IID_ ## type, reinterpret_cast<void**>( &result ) ); return result; } } private:

The InternalPointer returns an empty object even though UnknownPointer contains the correct memory address. Maybe QueryInterface fails?

Other info:

I am using Vista x64 with C++/C# 2008 Express (both SlimDX and program compiled for .NET 2.0). My video card is a 8800 GTS and the shader is a fairly simple 2.0 lighting shader.

Share this post


Link to post
Share on other sites
It doesn't look like Effect is using COMOBJECT correctly (by that I mean, it's not using it at all). Can you send me your project as a reproduction case (you can PM me the link)? Otherwise I'll knock together a test program in a bit and make sure that's actually the problem.

Share this post


Link to post
Share on other sites
Okay, I am neither very good at C++ or native DirectX but this is what I think is wrong:

Effect inherits BaseEffect and the InternalPointer accessible through EffectPointer returns an object of type ID3DXEffect. To set values on the shader we would need a ID3DXBaseEffect but this never gets created, since Effect overrides the creation of the internal object with its own ID3DXEffect.

EDIT: I terribly misphrased that first sentence :)

[Edited by - chinc on February 20, 2008 12:35:13 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by chinc
I just find it wierd that this bug was not discovered before. Do you all use DX10 or do you use DX9 without the effect framework?
The SVN has been a bit of a mess lately, honestly. Some internal architectural changes have caused chaos that is still being cleaned up. We haven't quite finished getting it fully stable again. Just bear with us, it'll all be stable again soon.

Share this post


Link to post
Share on other sites
Quote:

Effect inherits BaseEffect and the InternalPointer accessible through EffectPointer returns an object of type ID3DXEffect. To set values on the shader we would need a ID3DXBaseEffect but this never gets created, since Effect overrides the creation of the internal object with its own ID3DXEffect.

An ID3DXEffect is an ID3DXBaseEffect, and so the QueryInterface on an IUnknown that supports ID3DXEffect should support ID3DXBaseEffect. Give me a few minutes.

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