Jump to content

  • Log In with Google      Sign In   
  • Create Account


cbuffers lifetime in a pipeline


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 Corefanatic   Members   -  Reputation: 129

Like
0Likes
Like

Posted 17 March 2012 - 09:34 AM

Hi there,
A quick question I have is about how long is a lifetime of a constant buffer within a frame. Let's assume all my vertex shaders have the same set of constant buffers:

cbuffer cbPerObject
{
float4x4 matWorld;
}

cbuffer cbPerFrame
{
float4x4 matView;
float4x4 matProj;
}

At the moment I naturally set the perObject cb with every object I draw, and perFrame with each new vertex shader I set to the pipeline. What I am wondering is, if my shaders have the the same layout , would the perFrame cb stay attached from one vertex shader to another?

Sponsor:

#2 iedoc   Members   -  Reputation: 522

Like
1Likes
Like

Posted 17 March 2012 - 09:49 AM

If i'm understanding the question right, constant buffers will stay attached to whichever shaders you bind them to, and will stay attached until you change them. If you have not bound a cb to specific shader, then that shader will not use it. Even if you have two identical vertex shaders, you will still have to bind a cb to each of them explicitly, not just to one if you want both of them to use the cb.
Braynzar Soft - DirectX Lessons & Game Programming Resources!

#3 mhagain   Crossbones+   -  Reputation: 6303

Like
0Likes
Like

Posted 17 March 2012 - 10:17 AM

You can bind a cbuffer at the start of a frame and have it remain valid for the entire frame, yes. I do this with a few global values and it works quite well. You may want to look to set explicit register slots in your HLSL code (like "cbuffer cbPerObject : register(b1)", for example) to make this more predictable, especially if you're using Effects.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#4 iedoc   Members   -  Reputation: 522

Like
0Likes
Like

Posted 17 March 2012 - 10:20 AM

the cb will stay bound until you change it. I use a cbPerScene buffer, that is only set once per scene at initialization time
Braynzar Soft - DirectX Lessons & Game Programming Resources!




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