Sign in to follow this  
jdub

Updating constant buffers?

Recommended Posts

Can I create a constant buffer (ID3D11Buffer) using D3D11_USAGE_DYNAMIC, pass it to the pipeline once using VSSetConstantBuffers() and then update the constant buffer by calling Map and then writing the desired value on the ID3D11Buffer object I created?

Is this possible or do I have to call VSSetConstantBuffers() every time I want to update constant buffers within my shader?

Share this post


Link to post
Share on other sites

Not quite true : http://msdn.microsoft.com/en-us/library/windows/desktop/ff476457(v=vs.85).aspx

 

Return value

Type: HRESULT

This method returns one of the Direct3D 11 Return Codes.

This method also returns DXGI_ERROR_WAS_STILL_DRAWING if MapFlags specifiesD3D11_MAP_FLAG_DO_NOT_WAIT and the GPU is not yet finished with the resource.

 

You cant just update an already binded constant buffer, that may cause unexpected behavior

Edited by imoogiBG

Share this post


Link to post
Share on other sites

Well that is untill you bind another shader off course or another buffer on the same slot.

lol funny i was actually thinking about that when i posted my answer. Then i realized i was sort of implicitly rebinding shader resources every time i bind a new shader in my engine.

 

 

Not quite true : http://msdn.microsoft.com/en-us/library/windows/desktop/ff476457(v=vs.85).aspx

 

Return value

Type: HRESULT

This method returns one of the Direct3D 11 Return Codes.

This method also returns DXGI_ERROR_WAS_STILL_DRAWING if MapFlags specifiesD3D11_MAP_FLAG_DO_NOT_WAIT and the GPU is not yet finished with the resource.

 

You cant just update an already binded constant buffer, that may cause unexpected behavior

Are there any reason or practical usage to create the buffer with the D3D11_MAP_FLAG_DO_NOT_WAIT flag?

Edited by BrentChua

Share this post


Link to post
Share on other sites

Not quite true : http://msdn.microsoft.com/en-us/library/windows/desktop/ff476457(v=vs.85).aspx

 

Return value

Type: HRESULT

This method returns one of the Direct3D 11 Return Codes.

This method also returns DXGI_ERROR_WAS_STILL_DRAWING if MapFlags specifiesD3D11_MAP_FLAG_DO_NOT_WAIT and the GPU is not yet finished with the resource.

 

You cant just update an already binded constant buffer, that may cause unexpected behavior

This doesn't apply to to DYNAMIC buffers that you map with DISCARD, since that causes the driver to use renaming to avoid having to wait for the GPU to be finished with the resource.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this