mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-06-04 22:25:01 -06:00
vk: Simplify texture cache OOM tracking a bit
This commit is contained in:
parent
9aafd8c09f
commit
7f830d555d
@ -158,7 +158,6 @@ void VKGSRender::load_texture_env()
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
vk::clear_status_interrupt(vk::out_of_memory);
|
|
||||||
std::lock_guard lock(m_sampler_mutex);
|
std::lock_guard lock(m_sampler_mutex);
|
||||||
|
|
||||||
for (u32 textures_ref = current_fp_metadata.referenced_textures_mask, i = 0; textures_ref; textures_ref >>= 1, ++i)
|
for (u32 textures_ref = current_fp_metadata.referenced_textures_mask, i = 0; textures_ref; textures_ref >>= 1, ++i)
|
||||||
@ -368,8 +367,10 @@ void VKGSRender::load_texture_env()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VKGSRender::bind_texture_env()
|
bool VKGSRender::bind_texture_env()
|
||||||
{
|
{
|
||||||
|
bool out_of_memory = false;
|
||||||
|
|
||||||
for (u32 textures_ref = current_fp_metadata.referenced_textures_mask, i = 0; textures_ref; textures_ref >>= 1, ++i)
|
for (u32 textures_ref = current_fp_metadata.referenced_textures_mask, i = 0; textures_ref; textures_ref >>= 1, ++i)
|
||||||
{
|
{
|
||||||
if (!(textures_ref & 1))
|
if (!(textures_ref & 1))
|
||||||
@ -386,7 +387,7 @@ void VKGSRender::bind_texture_env()
|
|||||||
//Requires update, copy subresource
|
//Requires update, copy subresource
|
||||||
if (!(view = m_texture_cache.create_temporary_subresource(*m_current_command_buffer, sampler_state->external_subresource_desc)))
|
if (!(view = m_texture_cache.create_temporary_subresource(*m_current_command_buffer, sampler_state->external_subresource_desc)))
|
||||||
{
|
{
|
||||||
vk::raise_status_interrupt(vk::out_of_memory);
|
out_of_memory = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -516,7 +517,7 @@ void VKGSRender::bind_texture_env()
|
|||||||
{
|
{
|
||||||
if (!(image_ptr = m_texture_cache.create_temporary_subresource(*m_current_command_buffer, sampler_state->external_subresource_desc)))
|
if (!(image_ptr = m_texture_cache.create_temporary_subresource(*m_current_command_buffer, sampler_state->external_subresource_desc)))
|
||||||
{
|
{
|
||||||
vk::raise_status_interrupt(vk::out_of_memory);
|
out_of_memory = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,14 +588,16 @@ void VKGSRender::bind_texture_env()
|
|||||||
::glsl::program_domain::glsl_vertex_program,
|
::glsl::program_domain::glsl_vertex_program,
|
||||||
m_current_frame->descriptor_set);
|
m_current_frame->descriptor_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return out_of_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VKGSRender::bind_interpreter_texture_env()
|
bool VKGSRender::bind_interpreter_texture_env()
|
||||||
{
|
{
|
||||||
if (current_fp_metadata.referenced_textures_mask == 0)
|
if (current_fp_metadata.referenced_textures_mask == 0)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<VkDescriptorImageInfo, 68> texture_env;
|
std::array<VkDescriptorImageInfo, 68> texture_env;
|
||||||
@ -623,6 +626,8 @@ void VKGSRender::bind_interpreter_texture_env()
|
|||||||
std::advance(end, 16);
|
std::advance(end, 16);
|
||||||
std::fill(start, end, fallback);
|
std::fill(start, end, fallback);
|
||||||
|
|
||||||
|
bool out_of_memory = false;
|
||||||
|
|
||||||
for (u32 textures_ref = current_fp_metadata.referenced_textures_mask, i = 0; textures_ref; textures_ref >>= 1, ++i)
|
for (u32 textures_ref = current_fp_metadata.referenced_textures_mask, i = 0; textures_ref; textures_ref >>= 1, ++i)
|
||||||
{
|
{
|
||||||
if (!(textures_ref & 1))
|
if (!(textures_ref & 1))
|
||||||
@ -639,7 +644,7 @@ void VKGSRender::bind_interpreter_texture_env()
|
|||||||
//Requires update, copy subresource
|
//Requires update, copy subresource
|
||||||
if (!(view = m_texture_cache.create_temporary_subresource(*m_current_command_buffer, sampler_state->external_subresource_desc)))
|
if (!(view = m_texture_cache.create_temporary_subresource(*m_current_command_buffer, sampler_state->external_subresource_desc)))
|
||||||
{
|
{
|
||||||
vk::raise_status_interrupt(vk::out_of_memory);
|
out_of_memory = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -706,6 +711,7 @@ void VKGSRender::bind_interpreter_texture_env()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_shader_interpreter.update_fragment_textures(texture_env, m_current_frame->descriptor_set);
|
m_shader_interpreter.update_fragment_textures(texture_env, m_current_frame->descriptor_set);
|
||||||
|
return out_of_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VKGSRender::emit_geometry(u32 sub_index)
|
void VKGSRender::emit_geometry(u32 sub_index)
|
||||||
@ -985,20 +991,20 @@ void VKGSRender::end()
|
|||||||
ev->gpu_wait(*m_current_command_buffer);
|
ev->gpu_wait(*m_current_command_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int binding_attempts = 0;
|
for (int binding_attempts = 0; binding_attempts < 3; binding_attempts++)
|
||||||
while (binding_attempts++ < 3)
|
|
||||||
{
|
{
|
||||||
|
bool out_of_memory;
|
||||||
if (!m_shader_interpreter.is_interpreter(m_program)) [[likely]]
|
if (!m_shader_interpreter.is_interpreter(m_program)) [[likely]]
|
||||||
{
|
{
|
||||||
bind_texture_env();
|
out_of_memory = bind_texture_env();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bind_interpreter_texture_env();
|
out_of_memory = bind_interpreter_texture_env();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Replace OOO tracking with ref-counting to simplify the logic
|
// TODO: Replace OOM tracking with ref-counting to simplify the logic
|
||||||
if (!vk::test_status_interrupt(vk::out_of_memory))
|
if (!out_of_memory)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1014,11 +1020,6 @@ void VKGSRender::end()
|
|||||||
// Reload texture env if referenced objects were invalidated during OOO handling.
|
// Reload texture env if referenced objects were invalidated during OOO handling.
|
||||||
load_texture_env();
|
load_texture_env();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Nothing to reload, only texture cache references held. Simply attempt to bind again.
|
|
||||||
vk::clear_status_interrupt(vk::out_of_memory);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_texture_cache.release_uncached_temporary_subresources();
|
m_texture_cache.release_uncached_temporary_subresources();
|
||||||
|
|||||||
@ -543,8 +543,8 @@ private:
|
|||||||
void update_vertex_env(u32 id, const vk::vertex_upload_info& vertex_info);
|
void update_vertex_env(u32 id, const vk::vertex_upload_info& vertex_info);
|
||||||
|
|
||||||
void load_texture_env();
|
void load_texture_env();
|
||||||
void bind_texture_env();
|
bool bind_texture_env();
|
||||||
void bind_interpreter_texture_env();
|
bool bind_interpreter_texture_env();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void init_buffers(rsx::framebuffer_creation_context context, bool skip_reading = false);
|
void init_buffers(rsx::framebuffer_creation_context context, bool skip_reading = false);
|
||||||
|
|||||||
@ -38,8 +38,7 @@ namespace vk
|
|||||||
{
|
{
|
||||||
uninterruptible = 1,
|
uninterruptible = 1,
|
||||||
heap_dirty = 2,
|
heap_dirty = 2,
|
||||||
heap_changed = 3,
|
heap_changed = 3
|
||||||
out_of_memory = 4
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const vk::render_device *get_current_renderer();
|
const vk::render_device *get_current_renderer();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user