Jump to content
  • Advertisement
Sign in to follow this  

[SlimDX] EffectPool

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

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,
                                   out errors);

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

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

// -- Create Constant Buffers -- //

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

m_effect = SlimDX.Direct3D10.Effect.FromFile(m_Device,
                    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_ . . #endif

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!