renderer_vulkan: Flush scheduler on renderpass end

* Follows the Mali guide recommendation and fixes performance regression introduced by async shaders commit
This commit is contained in:
GPUCode
2023-01-18 18:07:23 +02:00
parent cbd9a6ffe3
commit d6cab3ab40
4 changed files with 20 additions and 5 deletions

View File

@ -118,6 +118,8 @@ void Config::ReadValues() {
static_cast<Settings::GraphicsAPI>(sdl2_config->GetInteger("Renderer", "graphics_api", 2));
Settings::values.async_command_recording =
sdl2_config->GetBoolean("Renderer", "async_command_recording", true);
Settings::values.async_shader_compilation =
sdl2_config->GetBoolean("Renderer", "async_shader_compilation", true);
Settings::values.spirv_shader_gen =
sdl2_config->GetBoolean("Renderer", "spirv_shader_gen", true);
Settings::values.renderer_debug = sdl2_config->GetBoolean("Renderer", "renderer_debug", false);

View File

@ -207,6 +207,11 @@ public:
return min_vertex_stride_alignment;
}
/// Returns true if the physical device is a Mali gpu
bool IsMaliGpu() const {
return driver_id == vk::DriverIdKHR::eArmProprietary;
}
private:
/// Returns the optimal supported usage for the requested format
[[nodiscard]] FormatTraits DetermineTraits(VideoCore::PixelFormat pixel_format,

View File

@ -84,15 +84,15 @@ RenderpassCache::~RenderpassCache() {
void RenderpassCache::EnterRenderpass(const RenderpassState& state) {
const bool is_dirty = scheduler.IsStateDirty(StateFlags::Renderpass);
if (current_state == state && !is_dirty) {
cmd_count++;
return;
}
scheduler.Record(
[should_end = bool(current_state.renderpass), state](vk::CommandBuffer cmdbuf) {
if (should_end) {
cmdbuf.endRenderPass();
}
if (current_state.renderpass) {
ExitRenderpass();
}
scheduler.Record([state](vk::CommandBuffer cmdbuf) {
const vk::RenderPassBeginInfo renderpass_begin_info = {
.renderPass = state.renderpass,
.framebuffer = state.framebuffer,
@ -118,6 +118,13 @@ void RenderpassCache::ExitRenderpass() {
scheduler.Record([](vk::CommandBuffer cmdbuf) { cmdbuf.endRenderPass(); });
current_state = {};
// The Mali guide recommends flushing at the end of each major renderpass
// Testing has shown this has a significant effect on rendering performance
if (cmd_count > 20 && instance.IsMaliGpu()) {
scheduler.Flush();
cmd_count = 0;
}
}
void RenderpassCache::CreatePresentRenderpass(vk::Format format) {

View File

@ -62,6 +62,7 @@ private:
RenderpassState current_state{};
vk::RenderPass present_renderpass{};
vk::RenderPass cached_renderpasses[MAX_COLOR_FORMATS + 1][MAX_DEPTH_FORMATS + 1][2];
u32 cmd_count{};
};
} // namespace Vulkan