mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-12-06 07:12:28 +01:00
vk: Rework the unique resource id system and apply it to buffer views
This commit is contained in:
parent
2fcd542b0b
commit
5a91ed01eb
|
|
@ -590,6 +590,7 @@ if(TARGET 3rdparty_vulkan)
|
||||||
RSX/VK/vkutils/device.cpp
|
RSX/VK/vkutils/device.cpp
|
||||||
RSX/VK/vkutils/sampler.cpp
|
RSX/VK/vkutils/sampler.cpp
|
||||||
RSX/VK/vkutils/shared.cpp
|
RSX/VK/vkutils/shared.cpp
|
||||||
|
RSX/VK/vkutils/unique_resource.cpp
|
||||||
RSX/VK/VKAsyncScheduler.cpp
|
RSX/VK/VKAsyncScheduler.cpp
|
||||||
RSX/VK/VKCommandStream.cpp
|
RSX/VK/VKCommandStream.cpp
|
||||||
RSX/VK/VKCommonDecompiler.cpp
|
RSX/VK/VKCommonDecompiler.cpp
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@
|
||||||
#include "../VulkanAPI.h"
|
#include "../VulkanAPI.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "unique_resource.h"
|
||||||
|
|
||||||
namespace vk
|
namespace vk
|
||||||
{
|
{
|
||||||
struct buffer_view
|
struct buffer_view : public unique_resource
|
||||||
{
|
{
|
||||||
VkBufferView value;
|
VkBufferView value;
|
||||||
VkBufferViewCreateInfo info = {};
|
VkBufferViewCreateInfo info = {};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "ex.h"
|
#include "ex.h"
|
||||||
|
#include "buffer_object.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "sampler.h"
|
#include "sampler.h"
|
||||||
|
|
||||||
|
|
@ -6,21 +7,26 @@ namespace vk
|
||||||
{
|
{
|
||||||
VkDescriptorImageInfoEx::VkDescriptorImageInfoEx(const vk::image_view& view, const vk::sampler& sampler, VkImageLayout layout)
|
VkDescriptorImageInfoEx::VkDescriptorImageInfoEx(const vk::image_view& view, const vk::sampler& sampler, VkImageLayout layout)
|
||||||
: VkDescriptorImageInfo(sampler.value, view.value, layout)
|
: VkDescriptorImageInfo(sampler.value, view.value, layout)
|
||||||
, resourceId(view.image()->id())
|
, resourceId(view.image()->uid())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VkDescriptorImageInfoEx::VkDescriptorImageInfoEx(const vk::image_view& view, const vk::sampler& sampler)
|
VkDescriptorImageInfoEx::VkDescriptorImageInfoEx(const vk::image_view& view, const vk::sampler& sampler)
|
||||||
: VkDescriptorImageInfo(sampler.value, view.value, view.image()->current_layout)
|
: VkDescriptorImageInfo(sampler.value, view.value, view.image()->current_layout)
|
||||||
, resourceId(view.image()->id())
|
, resourceId(view.image()->uid())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VkDescriptorImageInfoEx::VkDescriptorImageInfoEx(const vk::image_view& view, VkSampler sampler)
|
VkDescriptorImageInfoEx::VkDescriptorImageInfoEx(const vk::image_view& view, VkSampler sampler)
|
||||||
: VkDescriptorImageInfo(sampler, view.value, view.image()->current_layout)
|
: VkDescriptorImageInfo(sampler, view.value, view.image()->current_layout)
|
||||||
, resourceId(view.image()->id())
|
, resourceId(view.image()->uid())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VkDescriptorImageInfoEx::VkDescriptorImageInfoEx(const vk::image_view& view)
|
VkDescriptorImageInfoEx::VkDescriptorImageInfoEx(const vk::image_view& view)
|
||||||
: VkDescriptorImageInfo(VK_NULL_HANDLE, view.value, view.image()->current_layout)
|
: VkDescriptorImageInfo(VK_NULL_HANDLE, view.value, view.image()->current_layout)
|
||||||
, resourceId(view.image()->id())
|
, resourceId(view.image()->uid())
|
||||||
|
{}
|
||||||
|
|
||||||
|
VkDescriptorBufferViewEx::VkDescriptorBufferViewEx(const vk::buffer_view& view)
|
||||||
|
: resourceId(view.uid())
|
||||||
|
, view(view.value)
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
// Custom extensions to vulkan core
|
// Custom extensions to vulkan core
|
||||||
namespace vk
|
namespace vk
|
||||||
{
|
{
|
||||||
|
struct buffer_view;
|
||||||
struct image_view;
|
struct image_view;
|
||||||
struct sampler;
|
struct sampler;
|
||||||
|
|
||||||
|
|
@ -20,8 +21,20 @@ namespace vk
|
||||||
VkDescriptorImageInfoEx(const vk::image_view& view, VkSampler sampler);
|
VkDescriptorImageInfoEx(const vk::image_view& view, VkSampler sampler);
|
||||||
VkDescriptorImageInfoEx(const vk::image_view& view);
|
VkDescriptorImageInfoEx(const vk::image_view& view);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct VkDescriptorBufferViewEx {
|
||||||
|
u64 resourceId = 0ull;
|
||||||
|
VkBufferView view = VK_NULL_HANDLE;
|
||||||
|
|
||||||
|
VkDescriptorBufferViewEx() = default;
|
||||||
|
VkDescriptorBufferViewEx(u64 uid, VkBufferView view)
|
||||||
|
: resourceId(uid), view(view)
|
||||||
|
{}
|
||||||
|
VkDescriptorBufferViewEx(const vk::buffer_view& view);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-export
|
// Re-export
|
||||||
using VkDescriptorImageInfoEx = vk::VkDescriptorImageInfoEx;
|
using VkDescriptorImageInfoEx = vk::VkDescriptorImageInfoEx;
|
||||||
|
using VkDescriptorBufferViewEx = vk::VkDescriptorBufferViewEx;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
namespace vk
|
namespace vk
|
||||||
{
|
{
|
||||||
static atomic_t<u64> s_image_uid_counter = 0;
|
|
||||||
|
|
||||||
void image::validate(const vk::render_device& dev, const VkImageCreateInfo& info) const
|
void image::validate(const vk::render_device& dev, const VkImageCreateInfo& info) const
|
||||||
{
|
{
|
||||||
const auto& gpu_limits = dev.gpu().get_limits();
|
const auto& gpu_limits = dev.gpu().get_limits();
|
||||||
|
|
@ -121,8 +119,6 @@ namespace vk
|
||||||
|
|
||||||
CHECK_RESULT(vkCreateImage(m_device, &info, nullptr, &value));
|
CHECK_RESULT(vkCreateImage(m_device, &info, nullptr, &value));
|
||||||
|
|
||||||
m_uid = s_image_uid_counter++;
|
|
||||||
|
|
||||||
VkMemoryRequirements memory_req;
|
VkMemoryRequirements memory_req;
|
||||||
vkGetImageMemoryRequirements(m_device, value, &memory_req);
|
vkGetImageMemoryRequirements(m_device, value, &memory_req);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "unique_resource.h"
|
||||||
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
|
|
@ -26,7 +27,7 @@ namespace vk
|
||||||
VK_IMAGE_CREATE_SPECIAL_FLAGS_RPCS3 = (VK_IMAGE_CREATE_ALLOW_NULL_RPCS3 | VK_IMAGE_CREATE_SHAREABLE_RPCS3)
|
VK_IMAGE_CREATE_SPECIAL_FLAGS_RPCS3 = (VK_IMAGE_CREATE_ALLOW_NULL_RPCS3 | VK_IMAGE_CREATE_SHAREABLE_RPCS3)
|
||||||
};
|
};
|
||||||
|
|
||||||
class image
|
class image : public unique_resource
|
||||||
{
|
{
|
||||||
std::stack<VkImageLayout> m_layout_stack;
|
std::stack<VkImageLayout> m_layout_stack;
|
||||||
VkImageAspectFlags m_storage_aspect = 0;
|
VkImageAspectFlags m_storage_aspect = 0;
|
||||||
|
|
@ -68,7 +69,6 @@ namespace vk
|
||||||
image(image&&) = delete;
|
image(image&&) = delete;
|
||||||
|
|
||||||
// Identifiers
|
// Identifiers
|
||||||
u64 id() const { return m_uid; }
|
|
||||||
VkImage handle() const { return value; }
|
VkImage handle() const { return value; }
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
|
|
@ -99,7 +99,6 @@ namespace vk
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
VkDevice m_device = VK_NULL_HANDLE;
|
VkDevice m_device = VK_NULL_HANDLE;
|
||||||
u64 m_uid = 0ull;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct image_view
|
struct image_view
|
||||||
|
|
|
||||||
11
rpcs3/Emu/RSX/VK/vkutils/unique_resource.cpp
Normal file
11
rpcs3/Emu/RSX/VK/vkutils/unique_resource.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "unique_resource.h"
|
||||||
|
#include <util/atomic.hpp>
|
||||||
|
|
||||||
|
namespace vk
|
||||||
|
{
|
||||||
|
static atomic_t<u64> s_resource_uid;
|
||||||
|
|
||||||
|
u64 gen_uid() {
|
||||||
|
return s_resource_uid++;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
rpcs3/Emu/RSX/VK/vkutils/unique_resource.h
Normal file
22
rpcs3/Emu/RSX/VK/vkutils/unique_resource.h
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <util/types.hpp>
|
||||||
|
|
||||||
|
namespace vk
|
||||||
|
{
|
||||||
|
u64 gen_uid();
|
||||||
|
|
||||||
|
class unique_resource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
unique_resource()
|
||||||
|
: m_uid(gen_uid())
|
||||||
|
{}
|
||||||
|
|
||||||
|
u64 uid() const { return m_uid; }
|
||||||
|
bool operator == (const unique_resource& other) const { return m_uid == other.m_uid; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
u64 m_uid = 0ull;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
<ClInclude Include="Emu\RSX\VK\vkutils\sampler.h" />
|
<ClInclude Include="Emu\RSX\VK\vkutils\sampler.h" />
|
||||||
<ClInclude Include="Emu\RSX\VK\vkutils\shared.h" />
|
<ClInclude Include="Emu\RSX\VK\vkutils\shared.h" />
|
||||||
<ClInclude Include="Emu\RSX\VK\vkutils\instance.h" />
|
<ClInclude Include="Emu\RSX\VK\vkutils\instance.h" />
|
||||||
|
<ClInclude Include="Emu\RSX\VK\vkutils\unique_resource.h" />
|
||||||
<ClInclude Include="Emu\RSX\VK\VKVertexProgram.h" />
|
<ClInclude Include="Emu\RSX\VK\VKVertexProgram.h" />
|
||||||
<ClInclude Include="Emu\RSX\VK\VulkanAPI.h" />
|
<ClInclude Include="Emu\RSX\VK\VulkanAPI.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -113,6 +114,7 @@
|
||||||
<ClCompile Include="Emu\RSX\VK\vkutils\device.cpp" />
|
<ClCompile Include="Emu\RSX\VK\vkutils\device.cpp" />
|
||||||
<ClCompile Include="Emu\RSX\VK\vkutils\sampler.cpp" />
|
<ClCompile Include="Emu\RSX\VK\vkutils\sampler.cpp" />
|
||||||
<ClCompile Include="Emu\RSX\VK\vkutils\shared.cpp" />
|
<ClCompile Include="Emu\RSX\VK\vkutils\shared.cpp" />
|
||||||
|
<ClCompile Include="Emu\RSX\VK\vkutils\unique_resource.cpp" />
|
||||||
<ClCompile Include="Emu\RSX\VK\VKVertexBuffers.cpp" />
|
<ClCompile Include="Emu\RSX\VK\VKVertexBuffers.cpp" />
|
||||||
<ClCompile Include="Emu\RSX\VK\VKVertexProgram.cpp" />
|
<ClCompile Include="Emu\RSX\VK\VKVertexProgram.cpp" />
|
||||||
<ClCompile Include="Emu\RSX\VK\VKTextureCache.cpp" />
|
<ClCompile Include="Emu\RSX\VK\VKTextureCache.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,9 @@
|
||||||
<ClCompile Include="Emu\RSX\VK\vkutils\ex.cpp">
|
<ClCompile Include="Emu\RSX\VK\vkutils\ex.cpp">
|
||||||
<Filter>vkutils</Filter>
|
<Filter>vkutils</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Emu\RSX\VK\vkutils\unique_resource.cpp">
|
||||||
|
<Filter>vkutils</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Emu\RSX\VK\VKCommonDecompiler.h" />
|
<ClInclude Include="Emu\RSX\VK\VKCommonDecompiler.h" />
|
||||||
|
|
@ -206,6 +209,9 @@
|
||||||
<ClInclude Include="Emu\RSX\VK\vkutils\ex.h">
|
<ClInclude Include="Emu\RSX\VK\vkutils\ex.h">
|
||||||
<Filter>vkutils</Filter>
|
<Filter>vkutils</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Emu\RSX\VK\vkutils\unique_resource.h">
|
||||||
|
<Filter>vkutils</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="vkutils">
|
<Filter Include="vkutils">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue