diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 8107bcb8..ba3dd10a 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -532,6 +532,7 @@ namespace dxvk { bufferViewInfo.format = rawFormat; bufferViewInfo.rangeOffset = 0; bufferViewInfo.rangeLength = bufferInfo.size; + bufferViewInfo.usage = VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; Rc bufferView = m_device->createBufferView(buffer, bufferViewInfo); diff --git a/src/d3d11/d3d11_view_srv.cpp b/src/d3d11/d3d11_view_srv.cpp index 3970cb2c..4795961f 100644 --- a/src/d3d11/d3d11_view_srv.cpp +++ b/src/d3d11/d3d11_view_srv.cpp @@ -43,6 +43,7 @@ namespace dxvk { // Fill in buffer view info DxvkBufferViewCreateInfo viewInfo; + viewInfo.usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT; if (bufInfo.Flags & D3D11_BUFFEREX_SRV_FLAG_RAW) { // Raw buffer view. We'll represent this as a diff --git a/src/d3d11/d3d11_view_uav.cpp b/src/d3d11/d3d11_view_uav.cpp index 96de3df2..164a04ca 100644 --- a/src/d3d11/d3d11_view_uav.cpp +++ b/src/d3d11/d3d11_view_uav.cpp @@ -26,6 +26,7 @@ namespace dxvk { auto buffer = static_cast(pResource); DxvkBufferViewCreateInfo viewInfo; + viewInfo.usage = VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; if (pDesc->Buffer.Flags & D3D11_BUFFEREX_SRV_FLAG_RAW) { viewInfo.format = VK_FORMAT_R32_UINT; @@ -454,6 +455,7 @@ namespace dxvk { viewInfo.format = VK_FORMAT_UNDEFINED; viewInfo.rangeOffset = 0; viewInfo.rangeLength = sizeof(uint32_t); + viewInfo.usage = VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; return device->createBufferView(buffer, viewInfo); } diff --git a/src/d3d9/d3d9_format_helpers.cpp b/src/d3d9/d3d9_format_helpers.cpp index 7f284870..7d53ba2f 100644 --- a/src/d3d9/d3d9_format_helpers.cpp +++ b/src/d3d9/d3d9_format_helpers.cpp @@ -96,6 +96,7 @@ namespace dxvk { bufferViewInfo.format = bufferFormat; bufferViewInfo.rangeOffset = srcSlice.offset(); bufferViewInfo.rangeLength = srcSlice.length(); + bufferViewInfo.usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT; auto tmpBufferView = m_device->createBufferView(srcSlice.buffer(), bufferViewInfo); m_context->setSpecConstant(VK_PIPELINE_BIND_POINT_COMPUTE, 0, specConstantValue); diff --git a/src/dxvk/dxvk_buffer.cpp b/src/dxvk/dxvk_buffer.cpp index 333cf480..8e32a0af 100644 --- a/src/dxvk/dxvk_buffer.cpp +++ b/src/dxvk/dxvk_buffer.cpp @@ -240,14 +240,18 @@ namespace dxvk { DxvkBufferView::DxvkBufferView( - const Rc& vkd, + DxvkDevice* device, const Rc& buffer, const DxvkBufferViewCreateInfo& info) - : m_vkd(vkd), m_info(info), m_buffer(buffer), + : m_vkd(device->vkd()), m_info(info), m_buffer(buffer), + m_usage (info.usage), m_bufferSlice (getSliceHandle()), m_bufferView (VK_NULL_HANDLE) { if (m_info.format != VK_FORMAT_UNDEFINED) m_bufferView = createBufferView(m_bufferSlice); + + if (!device->features().khrMaintenance5.maintenance5) + m_usage = 0; } @@ -266,12 +270,18 @@ namespace dxvk { VkBufferView DxvkBufferView::createBufferView( const DxvkBufferSliceHandle& slice) { + VkBufferUsageFlags2CreateInfoKHR viewFlags = { VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR }; + viewFlags.usage = m_usage; + VkBufferViewCreateInfo viewInfo = { VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO }; viewInfo.buffer = slice.handle; viewInfo.format = m_info.format; viewInfo.offset = slice.offset; viewInfo.range = slice.length; - + + if (!m_usage) + viewInfo.pNext = &viewFlags; + VkBufferView result = VK_NULL_HANDLE; if (m_vkd->vkCreateBufferView(m_vkd->device(), diff --git a/src/dxvk/dxvk_buffer.h b/src/dxvk/dxvk_buffer.h index 4f289239..c278718e 100644 --- a/src/dxvk/dxvk_buffer.h +++ b/src/dxvk/dxvk_buffer.h @@ -52,6 +52,9 @@ namespace dxvk { /// Size of the buffer region to include in the view VkDeviceSize rangeLength; + + /// Buffer view usage flags + VkBufferUsageFlags usage; }; @@ -577,7 +580,7 @@ namespace dxvk { public: DxvkBufferView( - const Rc& vkd, + DxvkDevice* device, const Rc& buffer, const DxvkBufferViewCreateInfo& info); @@ -676,6 +679,7 @@ namespace dxvk { Rc m_vkd; DxvkBufferViewCreateInfo m_info; Rc m_buffer; + VkBufferUsageFlags m_usage; DxvkBufferSliceHandle m_bufferSlice; VkBufferView m_bufferView; diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index c63dce53..1692baee 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -873,10 +873,12 @@ namespace dxvk { viewInfo.format = format; viewInfo.rangeOffset = dstBufferOffset; viewInfo.rangeLength = dstBufferSlice.length; + viewInfo.usage = VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; Rc dstView = m_device->createBufferView(dstBuffer, viewInfo); viewInfo.rangeOffset = srcBufferOffset; viewInfo.rangeLength = srcBufferSlice.length; + viewInfo.usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT; Rc srcView; if (srcBuffer == dstBuffer @@ -1066,11 +1068,13 @@ namespace dxvk { tmpViewInfoD.format = dataFormatD; tmpViewInfoD.rangeOffset = 0; tmpViewInfoD.rangeLength = dataSizeD; + tmpViewInfoD.usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT; DxvkBufferViewCreateInfo tmpViewInfoS; tmpViewInfoS.format = dataFormatS; tmpViewInfoS.rangeOffset = dataSizeD; tmpViewInfoS.rangeLength = dataSizeS; + tmpViewInfoS.usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT; auto tmpBufferViewD = m_device->createBufferView(tmpBuffer, tmpViewInfoD); auto tmpBufferViewS = m_device->createBufferView(tmpBuffer, tmpViewInfoS); diff --git a/src/dxvk/dxvk_device.cpp b/src/dxvk/dxvk_device.cpp index 226596f0..8685f006 100644 --- a/src/dxvk/dxvk_device.cpp +++ b/src/dxvk/dxvk_device.cpp @@ -167,7 +167,7 @@ namespace dxvk { Rc DxvkDevice::createBufferView( const Rc& buffer, const DxvkBufferViewCreateInfo& createInfo) { - return new DxvkBufferView(m_vkd, buffer, createInfo); + return new DxvkBufferView(this, buffer, createInfo); } diff --git a/src/dxvk/hud/dxvk_hud_renderer.cpp b/src/dxvk/hud/dxvk_hud_renderer.cpp index 6e1dfeaf..dc96c74b 100644 --- a/src/dxvk/hud/dxvk_hud_renderer.cpp +++ b/src/dxvk/hud/dxvk_hud_renderer.cpp @@ -251,9 +251,10 @@ namespace dxvk::hud { Rc HudRenderer::createDataView() { DxvkBufferViewCreateInfo info; - info.format = VK_FORMAT_R8_UINT; - info.rangeOffset = 0; - info.rangeLength = m_dataBuffer->info().size; + info.format = VK_FORMAT_R8_UINT; + info.rangeOffset = 0; + info.rangeLength = m_dataBuffer->info().size; + info.usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT; return m_device->createBufferView(m_dataBuffer, info); } @@ -278,6 +279,7 @@ namespace dxvk::hud { info.format = VK_FORMAT_UNDEFINED; info.rangeOffset = 0; info.rangeLength = m_fontBuffer->info().size; + info.usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT; return m_device->createBufferView(m_fontBuffer, info); }