Followers 0

# DX11 DX11 VSSetConstantBuffers - Send more than one array

## 2 posts in this topic

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?

So how can i do this?

Thank You

0

##### Share on other sites

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.

1

##### Share on other sites

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.
0

## Create an account

Register a new account

Followers 0

• ### Similar Content

• Hi Guys,
I am just wondering if it is possible to acquire the address of the backbuffer if an API (based on DX11) only exposes the 'device' and 'context' pointers?
Any advice would be greatly appreciated

• bool InitDirect3D::Init() { if (!D3DApp::Init()) { return false; } //Additional Initialization //Disable Alt+Enter Fullscreen Toggle shortkey IDXGIFactory* factory; CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&factory)); factory->MakeWindowAssociation(mhWindow, DXGI_MWA_NO_WINDOW_CHANGES); factory->Release(); return true; }
As stated on the title and displayed on the code above, regardless of it Alt+Enter still takes effect...
I recall something from the book during the swapChain creation, where in order to create it one has to use the same factory used to create the ID3D11Device, therefore I tested and indeed using that same factory indeed it work.
How is that one particular factory related to my window and how come the MakeWindowAssociation won't take effect with a newly created factory?
Also what's even the point of being able to create this Factories if they won't work,?(except from that one associated with the ID3D11Device)
• By ProfL
Can anyone recommend a wrapper for Direct3D 11 that is similarly simple to use as SFML? I don't need all the image formats etc. BUT I want a simple way to open a window, allocate a texture, buffer, shader.

• Q1:
Since there is no more fixed pipeline rendering in DX11, for every part of rendering in DX11, do I need to create a brand-new vertex shader and pixel shader... or at least I have to find one relevant online. If you work on skinned meshes and other effects originally worked in DX9 fixed pipeline, do I have to rework everything by now?

Q2:
For assimp, if it originally was designed for DX9, like it is coupled to a DX9 device for creating meshes and materials etc. Do I have to add in the DX11 device in the assimp, or can I just leave the assimp to remain in DX9 and after the meshes are loaded, I just convert the vertex buffers and index buffers into DX11 buffers?
Thanks
Jack

• This header is mentioned in the book I'm reading but there is no documentation on msdn... Is it like an... outdated and abandoned header?
If so, what's the current default/recomended library for handling errors with directX?

• 11
• 18
• 18
• 15
• 13