Jump to content

  • Log In with Google      Sign In   
  • Create Account


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   Crossbones+   -  Reputation: 1577

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


Hi! Cuboid Zone

The Rule: Be polite, be professional, but have a plan to kill everyone you meet, ohh, AND STEAL ALL ZE TRIANGLES FROM ZHEM!


Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 4901

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.



#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