Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

DX11 VSSetConstantBuffers - Send more than one array


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

#1 Migi0027   Members   -  Reputation: 260

Like
0Likes
Like

Posted 27 January 2013 - 01:13 PM

Hi guys,

 

right now I'm having a small problem, in the command from the device context called VSSetConstantBuffers, the parameters are as following:

 

void VSSetConstantBuffers(
  [in]  UINT StartSlot,
  [in]  UINT NumBuffers,
  [in]  ID3D11Buffer *const *ppConstantBuffers
);

 

Now the number of buffers is easy when you have two arrays of constant buffers, but the ID3D11Buffer *const *ppConstantBuffers isn't so easy. My first approach was to combine the two arrays of ID3D11Buffer*(s), but that could become quite slow as this is called quite frequent. So is there a quick way to send two arrays of buffers, maybe call the function twice and change the startslot?huh.png

 

So how can i do this? 

Thank You


My Blog - Cuboid Zone , a graphical framework.


Sponsor:

#2 Jason Z   GDNet+   -  Reputation: 2398

Like
1Likes
Like

Posted 27 January 2013 - 09:12 PM

I think you already stated the best way to do the call - just make two calls to the function with a different start slot to put everything where you need them.  However, it would probably be best to try it out both ways to see what is more expensive.  Essentially you are trading a memcpy for an API call, and there are lots of variables that could help or hurt either method.  Most likely the difference between the two calls is not going to be noticeable, since the heavy costs are likely to be elsewhere in your frame.

 

You should also ensure that you are doing all of the optimizations you can, such as ensuring that any buffers that can be reused between calls are allowed to remain there, and to make sure you are using as few of buffers as you can.  I would be curious to hear if you detect any significant difference between the two methods.


Jason Zink :: DirectX MVP
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article

#3 e.s.   Members   -  Reputation: 110

Like
0Likes
Like

Posted 27 January 2013 - 10:26 PM

Here is some code that I used to bind multiple buffers at once...  Granted, your situation is a bit different with the constant buffer, but the syntax should be close. 

 

TBH, I prefer to push one buffer at a time, (I set the constant buffer in one activity, then set the static vertexbuffer data, then set instance buffer data every frame or so).

 

HTH

 

 

 

/******************************************************************/
 void ModelRenderer::BindInitialBuffer()
 {

 


  unsigned int offsets[2] = {0,0};
  unsigned int strides[2];

  ID3D11Buffer* bufferPointers[2];

  strides[0] = sizeof(NS::Vertex);
  strides[1] = sizeof(Position);

  bufferPointers[0] = ModelRenderer::StaticBuffer.Get(); 
  bufferPointers[1] = ModelRenderer::InstanceBuffer.Get();

  DeviceManager::DeviceContext->IASetVertexBuffers(
   0,                                 // First Input Slot for Binding
   2,                                 // Number of Buffers
   bufferPointers,                    // Buffer Pointer(s)
   strides,                           // Stride(s)
   offsets                            // Offset(s)
   );

  DeviceManager::DeviceContext->IASetInputLayout(ModelRenderer::InitialLayout.Get());
  DeviceManager::DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

 }

 


Edited by e.s., 27 January 2013 - 10:29 PM.





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