[SlimDX] Problems creating effect

Started by
12 comments, last by GuyWithBeard 16 years, 2 months ago
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]
Advertisement
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?
Are you using a binary release (if so, which one?) or are build from SVN (if so, which revision number)?
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.
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.
Yeah, hold on...

EDIT: sent you a PM
As I thought, the query was failing because Effect wasn't using COMOBJECT. I've checked in a fix.
Thanks for a fast fix! You guys provide better support than some companies do for their commercial products ;)

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?
Well, now I have the same problem with SetValue. Only this time it is InternalPointer of BaseEffect that has the value zero. And BaseEffect seems to use COMOBJECT. Ideas?
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]

This topic is closed to new replies.

Advertisement