Jump to content
  • Advertisement
Sign in to follow this  
GuyWithBeard

[SlimDX] Problems creating effect

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

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
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?

Share this post


Link to post
Share on other sites
Are you using a binary release (if so, which one?) or are build from SVN (if so, which revision number)?

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
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?

Share this post


Link to post
Share on other sites
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?

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
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!