Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Constant buffer not working

4: Adsense

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   

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.


#2 AngryPlatypus   Members   

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   

172
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   

1570
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   

213
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   

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.