1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 19:54:19 +01:00

[dxvk] Implemented physical buffer view

This commit is contained in:
Philip Rebohle 2018-03-07 13:32:17 +01:00
parent b494bb2ac1
commit ad017c2556
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 71 additions and 0 deletions

View File

@ -39,4 +39,29 @@ namespace dxvk {
m_vkd->vkDestroyBuffer(m_vkd->device(), m_handle, nullptr);
}
DxvkPhysicalBufferView::DxvkPhysicalBufferView(
const Rc<vk::DeviceFn>& vkd,
const DxvkPhysicalBufferSlice& slice,
const DxvkBufferViewCreateInfo& info)
: m_vkd(vkd), m_slice(slice.subSlice(info.rangeOffset, info.rangeLength)) {
VkBufferViewCreateInfo viewInfo;
viewInfo.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
viewInfo.pNext = nullptr;
viewInfo.flags = 0;
viewInfo.buffer = m_slice.handle();
viewInfo.format = info.format;
viewInfo.offset = m_slice.offset();
viewInfo.range = m_slice.length();
if (m_vkd->vkCreateBufferView(m_vkd->device(), &viewInfo, nullptr, &m_view) != VK_SUCCESS)
throw DxvkError("DxvkBufferView::DxvkBufferView: Failed to create buffer view");
}
DxvkPhysicalBufferView::~DxvkPhysicalBufferView() {
m_vkd->vkDestroyBufferView(
m_vkd->device(), m_view, nullptr);
}
}

View File

@ -203,4 +203,50 @@ namespace dxvk {
return DxvkPhysicalBufferSlice(this, offset, length);
}
/**
* \brief Physical buffer view
*
* Manages a texel buffer view for a physical
* buffer slice, which is used as the backing
* resource of a \c DxvkBufferView.
*/
class DxvkPhysicalBufferView : public DxvkResource {
public:
DxvkPhysicalBufferView(
const Rc<vk::DeviceFn>& vkd,
const DxvkPhysicalBufferSlice& slice,
const DxvkBufferViewCreateInfo& info);
~DxvkPhysicalBufferView();
/**
* \brief Vulkan buffer view handle
* \returns Vulkan buffer view handle
*/
VkBufferView handle() const {
return m_view;
}
/**
* \brief Physical buffer slice
*
* The slice backing this buffer view.
* \returns Physical buffer slice
*/
DxvkPhysicalBufferSlice slice() const {
return m_slice;
}
private:
Rc<vk::DeviceFn> m_vkd;
DxvkPhysicalBufferSlice m_slice;
VkBufferView m_view = VK_NULL_HANDLE;
};
}