Sign in to follow this  
clarkm2

[SlimDX] EffectPool

Recommended Posts

I recently coded and tested an "unshared" constant buffer implementation for a single DX10 Shader Effect. I am now trying to expand this feature by sharing a constant buffer across each Effect file. It nearly complete, but my Effect files are not loading and no complication (from Effect.FromFile) or DirectX error messages are reported. Let me try to summarize my implementation. My constant buffer is defined in a header file (.fxh) and meets the 16 byte alignment rule as shown below:

// -- Constants.fxh -- //

shared cbuffer ChangePerFrame
{
	row_major float4x4 mViewInv; // 64 Bytes, 0 Offset
	LIGHT_SOURCE oLight;	     // 96 Bytes, 64 Offset
	float3 vAmbientColor;	     // 12 Bytes, 160 Offset
	float fTimeMs;		     // 4 Bytes,  172 Offset
}


I first create the EffectPool by loading the header file and then creating the constant buffers, which executes successfully.

m_EffectPool = EffectPool.FromFile(m_Device,
                                   @"..\..\FX\Constants.fxh",
                                   "fx_4_0",
                                   ShaderFlags.None,
                                   EffectFlags.None,
                                   out errors);


// -- Get Effect -- //
m_PoolEffect = m_EffectPool.AsEffect();

// -- Get Constant Buffer Reference -- //
m_eUpdatePerFrame = m_PoolEffect.GetConstantBufferByName("ChangePerFrame");

// -- Create Constant Buffers -- //
CreateBuffers();


Next, I simply load each Shader and pass in the EffectPool as so

m_effect = SlimDX.Direct3D10.Effect.FromFile(m_Device,
                    FilePath,               
                    GetProfile(version),    
                    ShaderFlags.None,      
                    EffectFlags.None,
                    m_effectPool,
                    null,
                    out Errors);


When I try to load the Effect file, the call fails by exception and does not report any error messages. I thought there might be syntax errors, but when I set m_effectPool = null the file is loaded successfully. I also verified a complication error is reported when I intentionally caused a syntax error. I also tried to load a dummy Effect file instead of the header, but this caused the same results. I must be missing a step, and yes I am including the header file in each Effect File. Quick question... Should I prevent the header from being loaded more then once by using the following code? #ifndef _H_CONSTANTS_ #define _H_CONSTANTS_ . [CODE] . #endif

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