Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Constant buffer not working


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
5 replies to this topic

#1 TheResolute   Members   -  Reputation: 187

Like
0Likes
Like

Posted 08 February 2013 - 03:53 PM

I am using a constant buffer to transfer data to my pixel shader

The problem is that the buffer contains 0s in the shader during runtime for x, y, z, and w of the float4 member, regardless of what data is updated to the buffer

Structure definitions are as follows:

 

// (C++)
struct Buffer
{
    XMMATRIX mvp_;
    XMFLOAT4 rgba_;
    int usemvp_;
};


// HLSL
cbuffer Buffer : register( b0 )
{
    matrix mvp_;
    float4 rgba_;
    int usemvp_;
};
 

 

 Any help is much appreciated


Edited by TheResolute, 08 February 2013 - 03:54 PM.


Sponsor:

#2 AngryPlatypus   Members   -  Reputation: 232

Like
0Likes
Like

Posted 08 February 2013 - 08:54 PM

Do you store the XMMATRIX in an object which is dynamically allocated? This will give you alignment issues. Try to use a XMFLOAT4X4 for storing. You can convert between those types with XMStoreFloat4x4 and XMLoadFloat4x4.



#3 Polarist   Members   -  Reputation: 160

Like
0Likes
Like

Posted 09 February 2013 - 12:43 AM

Are you actually using those values?  If not, the shader compiler may be optimizing away those variables.

 

It'd be easier to diagnose if you posted your code.  The constant buffer definitions seem fine,



#4 kubera   Members   -  Reputation: 946

Like
0Likes
Like

Posted 09 February 2013 - 04:50 AM

Please consider reading that:

http://www.gamedev.net/topic/620539-constant-buffer-update/



#5 collie   Members   -  Reputation: 169

Like
0Likes
Like

Posted 09 February 2013 - 04:55 AM

I read somewhere the other day that you have to use XMMatrixTranspose() in DX11 otherwise you'll get NaN in the pixel shader.

 

http://stackoverflow.com/questions/14150922/directx-11-shader-error-pixel-shader-receiving-only-nan/14164755#14164755



#6 TheResolute   Members   -  Reputation: 187

Like
0Likes
Like

Posted 10 February 2013 - 09:24 PM

Thank you for your help, I realized that I never called PSSetConstantBuffers(), so I fixed that and now everything is fine






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