From bf912d0a5f04c0ea5edd82363b6b564b899c5ccf Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 30 Jul 2018 20:24:53 +0200 Subject: [PATCH] [d3d11] Create shader constant buffer if necessary --- src/d3d11/d3d11_shader.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/d3d11/d3d11_shader.cpp b/src/d3d11/d3d11_shader.cpp index c33695748..f5177182e 100644 --- a/src/d3d11/d3d11_shader.cpp +++ b/src/d3d11/d3d11_shader.cpp @@ -85,6 +85,28 @@ namespace dxvk { if (readStream) m_shader->read(readStream); } + + // Create shader constant buffer if necessary + if (m_shader->shaderConstants().data() != nullptr) { + DxvkBufferCreateInfo info; + info.size = m_shader->shaderConstants().sizeInBytes(); + info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; + info.stages = util::pipelineStages(m_shader->stage()) + | VK_PIPELINE_STAGE_HOST_BIT; + info.access = VK_ACCESS_UNIFORM_READ_BIT + | VK_ACCESS_HOST_WRITE_BIT; + + VkMemoryPropertyFlags memFlags + = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT + | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT + | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + + m_buffer = pDevice->GetDXVKDevice()->createBuffer(info, memFlags); + + std::memcpy(m_buffer->mapPtr(0), + m_shader->shaderConstants().data(), + m_shader->shaderConstants().sizeInBytes()); + } }