Jump to content
  • Advertisement
Sign in to follow this  

[SlimDX] Constant Buffers with Matrices

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

Hello folks, I got an issue with constant buffers with some matrices defined as element(s). The problem seems that when update a cbuffer the matrices don't get set or get set properly. Here is are a few snippets that explain how I am trying to do it. This is the HLSL code of my shader. Please note the unbuffered Projection matrix in the top aswell.
float4x4 Projection;

// Constant buffer definition
cbuffer Screen
	float4x4	Projection2;	
	float4x4	InverseProjection;

// Vertex Shader
void VS_Geometry
	in	IA_VS_Geometry	input,
	out	VS_PS_Geometry	output
	output.Position	= mul(float4(input.Position, 1), mul(World, View));
	output.Depth	= output.Position.z;
	output.Position	= mul(output.Position, Projection);
	//output.Position	= mul(output.Position, Projection2);
	output.Normal	= mul(input.Normal, World);
	output.Binormal	= mul(input.Binormal, World);
	output.Tangent	= mul(input.Tangent, World);
	output.Texture	= input.Texture;

This code explains how I instantiate the variables used in my code below.
// Screen (c-buffer) variable of type EffectConstantBuffer (SlimDX)
ScreenVariable = Effect.GetConstantBufferByName("Screen");

// Screen (c-buffer) buffer of type Buffer (SlimDX)
ScreenBuffer = new SlimDX.Direct3D10.Buffer(
	Marshal.SizeOf(typeof(Matrix)) * 2,

This code explains how I update my c-buffers.
using (DataStream stream = ScreenBuffer.Map(MapMode.WriteDiscard, MapFlags.None))
	stream.Position = 0;

// Update the buffer

// Update the unbuffered 

The issue is, when I use the vertex shader as it now is, with the same lines uncommented, every thing works fine. My problem is when I uncomment the line where Projection2 is used instead of Projection, I get to see a blank screen. Has anyone had similar issues and can tell me what I am doing wrong? Kind regards, Xeile

Share this post

Link to post
Share on other sites
No one got an idea? I haven't tried this without SlimDX framework of course, that would mean I have to rewrite a lot first, but I doubt the problem lies there.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!