# [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",
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),
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 on other sites

Oops... the child effect flag needed to be set. It's working now.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628291
• Total Posts
2981861

• 11
• 10
• 10
• 11
• 17