1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-03 04:24:11 +01:00

[dxvk] Add usage property to buffer views

And pass it to the Vulkan driver depending on maintenance5 support.
This commit is contained in:
Philip Rebohle 2024-09-13 14:16:27 +02:00
parent ab557a2eed
commit ddb59ae394
9 changed files with 33 additions and 8 deletions

View File

@ -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<DxvkBufferView> bufferView = m_device->createBufferView(buffer,
bufferViewInfo);

View File

@ -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

View File

@ -26,6 +26,7 @@ namespace dxvk {
auto buffer = static_cast<D3D11Buffer*>(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);
}

View File

@ -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);

View File

@ -240,14 +240,18 @@ namespace dxvk {
DxvkBufferView::DxvkBufferView(
const Rc<vk::DeviceFn>& vkd,
DxvkDevice* device,
const Rc<DxvkBuffer>& 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(),

View File

@ -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<vk::DeviceFn>& vkd,
DxvkDevice* device,
const Rc<DxvkBuffer>& buffer,
const DxvkBufferViewCreateInfo& info);
@ -676,6 +679,7 @@ namespace dxvk {
Rc<vk::DeviceFn> m_vkd;
DxvkBufferViewCreateInfo m_info;
Rc<DxvkBuffer> m_buffer;
VkBufferUsageFlags m_usage;
DxvkBufferSliceHandle m_bufferSlice;
VkBufferView m_bufferView;

View File

@ -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<DxvkBufferView> dstView = m_device->createBufferView(dstBuffer, viewInfo);
viewInfo.rangeOffset = srcBufferOffset;
viewInfo.rangeLength = srcBufferSlice.length;
viewInfo.usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
Rc<DxvkBufferView> 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);

View File

@ -167,7 +167,7 @@ namespace dxvk {
Rc<DxvkBufferView> DxvkDevice::createBufferView(
const Rc<DxvkBuffer>& buffer,
const DxvkBufferViewCreateInfo& createInfo) {
return new DxvkBufferView(m_vkd, buffer, createInfo);
return new DxvkBufferView(this, buffer, createInfo);
}

View File

@ -251,9 +251,10 @@ namespace dxvk::hud {
Rc<DxvkBufferView> 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);
}