Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shader/Const buffer problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 lipsryme   Members   -  Reputation: 986

Like
0Likes
Like

Posted 17 September 2012 - 05:08 PM

I've got a const buffer struct defined in my application code, which you can see here:

struct cbDOFProperties
{
	 float _focalWidth;
	 float _focalDepth;
	 float _farClip;
	 float _padding;

	 XMFLOAT2 _filterTaps[12];
};

Now the same in my shader:
cbuffer cbDOFProperties : register(b0)
{
	 float _focalWidth;
	 float _focalDepth;
	 float _farClip;
	 float _padding;


	 float2 _filterTaps[12];
};

The problem I'm having is that I'm getting a warning telling me:
D3D11: WARNING: ID3D11DeviceContext::DrawIndexed: The size of the Constant Buffer at slot 0 of the Pixel Shader unit is too small (112 bytes provided, 208 bytes, at least, expected).

I don't get it. the size of a float2 would be 2*4 byte = 8 bytes * 12 = 96 bytes + 4x floats = 112 bytes like it tells me I've provided. Then why is it expecting 208 ???

Sponsor:

#2 MJP   Moderators   -  Reputation: 10243

Like
1Likes
Like

Posted 17 September 2012 - 05:23 PM

Arrays in constant buffers will be padded to 4 floats per element, as described here.

#3 lipsryme   Members   -  Reputation: 986

Like
0Likes
Like

Posted 17 September 2012 - 05:41 PM

Hmm might be a stupid question but how would I give "him" more data in this case ?

edit: nvm got it
Hmm or not... how do I correctly set an array to a constant buffer ?

Edited by lipsryme, 17 September 2012 - 06:03 PM.


#4 MJP   Moderators   -  Reputation: 10243

Like
0Likes
Like

Posted 17 September 2012 - 07:16 PM

Declare it as an array of XMFLOAT4 in your C++ structure, and only set the X and Y values.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS