mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-12-06 07:12:28 +01:00
vk: Improved state cache tracking
This commit is contained in:
parent
1cc0446bc1
commit
10741a97ea
|
|
@ -72,14 +72,17 @@ namespace vk
|
||||||
|
|
||||||
void command_buffer::reset()
|
void command_buffer::reset()
|
||||||
{
|
{
|
||||||
// Nuke the state cache
|
|
||||||
m_bound_pipeline = VK_NULL_HANDLE;
|
|
||||||
m_bound_descriptor_sets[0] = VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
// Do the driver reset
|
// Do the driver reset
|
||||||
CHECK_RESULT(vkResetCommandBuffer(commands, 0));
|
CHECK_RESULT(vkResetCommandBuffer(commands, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void command_buffer::clear_state_cache()
|
||||||
|
{
|
||||||
|
m_bound_pipelines[0] = VK_NULL_HANDLE;
|
||||||
|
m_bound_pipelines[1] = VK_NULL_HANDLE;
|
||||||
|
m_bound_descriptor_sets[0] = VK_NULL_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
void command_buffer::begin()
|
void command_buffer::begin()
|
||||||
{
|
{
|
||||||
if (m_submit_fence && is_pending)
|
if (m_submit_fence && is_pending)
|
||||||
|
|
@ -104,6 +107,8 @@ namespace vk
|
||||||
begin_infos.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
begin_infos.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
|
||||||
CHECK_RESULT(vkBeginCommandBuffer(commands, &begin_infos));
|
CHECK_RESULT(vkBeginCommandBuffer(commands, &begin_infos));
|
||||||
is_open = true;
|
is_open = true;
|
||||||
|
|
||||||
|
clear_state_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void command_buffer::end()
|
void command_buffer::end()
|
||||||
|
|
@ -142,12 +147,14 @@ namespace vk
|
||||||
|
|
||||||
void command_buffer::bind_pipeline(VkPipeline pipeline, VkPipelineBindPoint bind_point) const
|
void command_buffer::bind_pipeline(VkPipeline pipeline, VkPipelineBindPoint bind_point) const
|
||||||
{
|
{
|
||||||
if (m_bound_pipeline == pipeline)
|
ensure(is_open && bind_point <= VK_PIPELINE_BIND_POINT_COMPUTE);
|
||||||
|
auto& cached = m_bound_pipelines[static_cast<int>(bind_point)];
|
||||||
|
if (cached == pipeline)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bound_pipeline = pipeline;
|
cached = pipeline;
|
||||||
vkCmdBindPipeline(commands, bind_point, pipeline);
|
vkCmdBindPipeline(commands, bind_point, pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,7 +183,7 @@ namespace vk
|
||||||
VkPipelineLayout pipe_layout) const
|
VkPipelineLayout pipe_layout) const
|
||||||
{
|
{
|
||||||
const u32 num_sets = ::size32(sets);
|
const u32 num_sets = ::size32(sets);
|
||||||
ensure(num_sets <= 2);
|
ensure(is_open && num_sets <= 2);
|
||||||
|
|
||||||
if (!memcmp(sets.data(), m_bound_descriptor_sets.data(), sets.size_bytes()))
|
if (!memcmp(sets.data(), m_bound_descriptor_sets.data(), sets.size_bytes()))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,9 @@ namespace vk
|
||||||
|
|
||||||
// State cache
|
// State cache
|
||||||
mutable std::array<VkDescriptorSet, 2> m_bound_descriptor_sets {{ VK_NULL_HANDLE }};
|
mutable std::array<VkDescriptorSet, 2> m_bound_descriptor_sets {{ VK_NULL_HANDLE }};
|
||||||
mutable VkPipeline m_bound_pipeline = VK_NULL_HANDLE;
|
mutable std::array<VkPipeline, 2> m_bound_pipelines{{ VK_NULL_HANDLE }};
|
||||||
|
|
||||||
|
void clear_state_cache();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum access_type_hint
|
enum access_type_hint
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue