diff --git a/src/d3d11/d3d11_buffer.cpp b/src/d3d11/d3d11_buffer.cpp index cd1c8c3e3..63b898ecb 100644 --- a/src/d3d11/d3d11_buffer.cpp +++ b/src/d3d11/d3d11_buffer.cpp @@ -60,4 +60,9 @@ namespace dxvk { *pDesc = m_desc; } + + Rc<DxvkBuffer> D3D11Buffer::GetDXVKBuffer() { + return m_resource->GetDXVKBuffer(); + } + } diff --git a/src/d3d11/d3d11_buffer.h b/src/d3d11/d3d11_buffer.h index c4563fe46..9a8c69176 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<DxvkBuffer> GetDXVKBuffer(); + private: D3D11Device* const m_device; diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 4ea4500aa..dc7ed5113 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<D3D11Buffer*>(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> 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 df2b20c43..41dcac51c 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -61,9 +61,26 @@ namespace dxvk { }; + struct D3D11VertexBufferBinding { + Com<D3D11Buffer> buffer = nullptr; + UINT offset = 0; + UINT stride = 0; + }; + + + struct D3D11IndexBufferBinding { + Com<D3D11Buffer> buffer = nullptr; + UINT offset = 0; + DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; + }; + + struct D3D11ContextStateIA { Com<D3D11InputLayout> inputLayout; D3D11_PRIMITIVE_TOPOLOGY primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; + + std::array<D3D11VertexBufferBinding, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> vertexBuffers; + D3D11IndexBufferBinding indexBuffer; };