From 05ef218326ca69e2b62c6106d6a4a2671fdd907b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 7 Dec 2017 14:03:15 +0100 Subject: [PATCH] [d3d11] Implemented vertex buffer binding --- src/d3d11/d3d11_buffer.cpp | 5 +++++ src/d3d11/d3d11_buffer.h | 2 ++ src/d3d11/d3d11_context.cpp | 24 +++++++++++++++++++++++- src/d3d11/d3d11_context_state.h | 17 +++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/d3d11/d3d11_buffer.cpp b/src/d3d11/d3d11_buffer.cpp index cd1c8c3e..63b898ec 100644 --- a/src/d3d11/d3d11_buffer.cpp +++ b/src/d3d11/d3d11_buffer.cpp @@ -60,4 +60,9 @@ namespace dxvk { *pDesc = m_desc; } + + Rc D3D11Buffer::GetDXVKBuffer() { + return m_resource->GetDXVKBuffer(); + } + } diff --git a/src/d3d11/d3d11_buffer.h b/src/d3d11/d3d11_buffer.h index c4563fe4..9a8c6917 100644 --- a/src/d3d11/d3d11_buffer.h +++ b/src/d3d11/d3d11_buffer.h @@ -37,6 +37,8 @@ namespace dxvk { void GetDesc( D3D11_BUFFER_DESC *pDesc) final; + Rc GetDXVKBuffer(); + private: D3D11Device* const m_device; diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 4ea4500a..dc7ed511 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -517,7 +517,29 @@ namespace dxvk { ID3D11Buffer* const* ppVertexBuffers, const UINT* pStrides, const UINT* pOffsets) { - Logger::err("D3D11DeviceContext::IASetVertexBuffers: Not implemented"); + // TODO check if any of these buffers + // are bound as UAVs or stream outputs + for (uint32_t i = 0; i < NumBuffers; i++) { + D3D11VertexBufferBinding binding; + binding.buffer = static_cast(ppVertexBuffers[i]); + binding.offset = pOffsets[i]; + binding.stride = pStrides[i]; + m_state.ia.vertexBuffers.at(StartSlot + i) = binding; + + DxvkBufferBinding dxvkBinding; + + if (binding.buffer != nullptr) { + Rc dxvkBuffer = binding.buffer->GetDXVKBuffer(); + + dxvkBinding = DxvkBufferBinding( + dxvkBuffer, binding.offset, + dxvkBuffer->info().size - binding.offset); + } + + m_context->bindVertexBuffer( + StartSlot + i, dxvkBinding, + binding.stride); + } } diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index df2b20c4..41dcac51 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -61,9 +61,26 @@ namespace dxvk { }; + struct D3D11VertexBufferBinding { + Com buffer = nullptr; + UINT offset = 0; + UINT stride = 0; + }; + + + struct D3D11IndexBufferBinding { + Com buffer = nullptr; + UINT offset = 0; + DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; + }; + + struct D3D11ContextStateIA { Com inputLayout; D3D11_PRIMITIVE_TOPOLOGY primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; + + std::array vertexBuffers; + D3D11IndexBufferBinding indexBuffer; };