mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-10 20:25:06 +01:00
vk_render_manager: Minor cleanups and rename to RenderManager
* It is no longer just a renderpass cache * Revert variable name change from render_manager back to renderpass_cache
This commit is contained in:
parent
a06aa7981e
commit
5c91cc522f
@ -54,19 +54,13 @@ RendererVulkan::RendererVulkan(Core::System& system, Pica::PicaCore& pica_,
|
|||||||
Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window)
|
Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window)
|
||||||
: RendererBase{system, window, secondary_window}, memory{system.Memory()}, pica{pica_},
|
: RendererBase{system, window, secondary_window}, memory{system.Memory()}, pica{pica_},
|
||||||
instance{window, Settings::values.physical_device.GetValue()}, scheduler{instance},
|
instance{window, Settings::values.physical_device.GetValue()}, scheduler{instance},
|
||||||
render_manager{instance, scheduler}, main_window{window, instance, scheduler},
|
renderpass_cache{instance, scheduler}, main_window{window, instance, scheduler},
|
||||||
vertex_buffer{instance, scheduler, vk::BufferUsageFlagBits::eVertexBuffer,
|
vertex_buffer{instance, scheduler, vk::BufferUsageFlagBits::eVertexBuffer,
|
||||||
VERTEX_BUFFER_SIZE},
|
VERTEX_BUFFER_SIZE},
|
||||||
update_queue{instance}, rasterizer{memory,
|
update_queue{instance},
|
||||||
pica,
|
rasterizer{
|
||||||
system.CustomTexManager(),
|
memory, pica, system.CustomTexManager(), *this, render_window,
|
||||||
*this,
|
instance, scheduler, renderpass_cache, update_queue, main_window.ImageCount()},
|
||||||
render_window,
|
|
||||||
instance,
|
|
||||||
scheduler,
|
|
||||||
render_manager,
|
|
||||||
update_queue,
|
|
||||||
main_window.ImageCount()},
|
|
||||||
present_heap{instance, scheduler.GetMasterSemaphore(), PRESENT_BINDINGS, 32} {
|
present_heap{instance, scheduler.GetMasterSemaphore(), PRESENT_BINDINGS, 32} {
|
||||||
CompileShaders();
|
CompileShaders();
|
||||||
BuildLayouts();
|
BuildLayouts();
|
||||||
@ -132,7 +126,7 @@ void RendererVulkan::PrepareDraw(Frame* frame, const Layout::FramebufferLayout&
|
|||||||
sampler);
|
sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
render_manager.EndRendering();
|
renderpass_cache.EndRendering();
|
||||||
scheduler.Record([this, layout, frame, present_set, renderpass = main_window.Renderpass(),
|
scheduler.Record([this, layout, frame, present_set, renderpass = main_window.Renderpass(),
|
||||||
index = current_pipeline](vk::CommandBuffer cmdbuf) {
|
index = current_pipeline](vk::CommandBuffer cmdbuf) {
|
||||||
const vk::Viewport viewport = {
|
const vk::Viewport viewport = {
|
||||||
@ -467,7 +461,7 @@ void RendererVulkan::FillScreen(Common::Vec3<u8> color, const TextureInfo& textu
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
render_manager.EndRendering();
|
renderpass_cache.EndRendering();
|
||||||
scheduler.Record([image = texture.image, clear_color](vk::CommandBuffer cmdbuf) {
|
scheduler.Record([image = texture.image, clear_color](vk::CommandBuffer cmdbuf) {
|
||||||
const vk::ImageSubresourceRange range = {
|
const vk::ImageSubresourceRange range = {
|
||||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||||
@ -804,29 +798,7 @@ void RendererVulkan::DrawScreens(Frame* frame, const Layout::FramebufferLayout&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduler.Record([image = frame->image](vk::CommandBuffer cmdbuf) {
|
scheduler.Record([](vk::CommandBuffer cmdbuf) { cmdbuf.endRenderPass(); });
|
||||||
const vk::ImageMemoryBarrier render_barrier = {
|
|
||||||
.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite,
|
|
||||||
.dstAccessMask = vk::AccessFlagBits::eTransferRead,
|
|
||||||
.oldLayout = vk::ImageLayout::eTransferSrcOptimal,
|
|
||||||
.newLayout = vk::ImageLayout::eTransferSrcOptimal,
|
|
||||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
|
||||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
|
||||||
.image = image,
|
|
||||||
.subresourceRange{
|
|
||||||
.aspectMask = vk::ImageAspectFlagBits::eColor,
|
|
||||||
.baseMipLevel = 0,
|
|
||||||
.levelCount = 1,
|
|
||||||
.baseArrayLayer = 0,
|
|
||||||
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
cmdbuf.endRenderPass();
|
|
||||||
cmdbuf.pipelineBarrier(vk::PipelineStageFlagBits::eColorAttachmentOutput,
|
|
||||||
vk::PipelineStageFlagBits::eTransfer,
|
|
||||||
vk::DependencyFlagBits::eByRegion, {}, {}, render_barrier);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererVulkan::SwapBuffers() {
|
void RendererVulkan::SwapBuffers() {
|
||||||
|
@ -117,7 +117,7 @@ private:
|
|||||||
|
|
||||||
Instance instance;
|
Instance instance;
|
||||||
Scheduler scheduler;
|
Scheduler scheduler;
|
||||||
RenderManager render_manager;
|
RenderManager renderpass_cache;
|
||||||
PresentWindow main_window;
|
PresentWindow main_window;
|
||||||
StreamBuffer vertex_buffer;
|
StreamBuffer vertex_buffer;
|
||||||
DescriptorUpdateQueue update_queue;
|
DescriptorUpdateQueue update_queue;
|
||||||
|
@ -179,8 +179,8 @@ constexpr vk::PipelineShaderStageCreateInfo MakeStages(vk::ShaderModule compute_
|
|||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
BlitHelper::BlitHelper(const Instance& instance_, Scheduler& scheduler_,
|
BlitHelper::BlitHelper(const Instance& instance_, Scheduler& scheduler_,
|
||||||
RenderManager& render_manager_, DescriptorUpdateQueue& update_queue_)
|
RenderManager& renderpass_cache_, DescriptorUpdateQueue& update_queue_)
|
||||||
: instance{instance_}, scheduler{scheduler_}, render_manager{render_manager_},
|
: instance{instance_}, scheduler{scheduler_}, renderpass_cache{renderpass_cache_},
|
||||||
update_queue{update_queue_}, device{instance.GetDevice()},
|
update_queue{update_queue_}, device{instance.GetDevice()},
|
||||||
compute_provider{instance, scheduler.GetMasterSemaphore(), COMPUTE_BINDINGS},
|
compute_provider{instance, scheduler.GetMasterSemaphore(), COMPUTE_BINDINGS},
|
||||||
compute_buffer_provider{instance, scheduler.GetMasterSemaphore(), COMPUTE_BUFFER_BINDINGS},
|
compute_buffer_provider{instance, scheduler.GetMasterSemaphore(), COMPUTE_BUFFER_BINDINGS},
|
||||||
@ -294,10 +294,11 @@ bool BlitHelper::BlitDepthStencil(Surface& source, Surface& dest,
|
|||||||
|
|
||||||
const RenderPass depth_pass = {
|
const RenderPass depth_pass = {
|
||||||
.framebuffer = dest.Framebuffer(),
|
.framebuffer = dest.Framebuffer(),
|
||||||
.render_pass = render_manager.GetRenderpass(PixelFormat::Invalid, dest.pixel_format, false),
|
.render_pass =
|
||||||
|
renderpass_cache.GetRenderpass(PixelFormat::Invalid, dest.pixel_format, false),
|
||||||
.render_area = dst_render_area,
|
.render_area = dst_render_area,
|
||||||
};
|
};
|
||||||
render_manager.BeginRendering(depth_pass);
|
renderpass_cache.BeginRendering(depth_pass);
|
||||||
|
|
||||||
scheduler.Record([blit, descriptor_set, this](vk::CommandBuffer cmdbuf) {
|
scheduler.Record([blit, descriptor_set, this](vk::CommandBuffer cmdbuf) {
|
||||||
const vk::PipelineLayout layout = two_textures_pipeline_layout;
|
const vk::PipelineLayout layout = two_textures_pipeline_layout;
|
||||||
@ -320,7 +321,7 @@ bool BlitHelper::ConvertDS24S8ToRGBA8(Surface& source, Surface& dest,
|
|||||||
vk::ImageLayout::eDepthStencilReadOnlyOptimal);
|
vk::ImageLayout::eDepthStencilReadOnlyOptimal);
|
||||||
update_queue.AddStorageImage(descriptor_set, 2, dest.ImageView());
|
update_queue.AddStorageImage(descriptor_set, 2, dest.ImageView());
|
||||||
|
|
||||||
render_manager.EndRendering();
|
renderpass_cache.EndRendering();
|
||||||
scheduler.Record([this, descriptor_set, copy, src_image = source.Image(),
|
scheduler.Record([this, descriptor_set, copy, src_image = source.Image(),
|
||||||
dst_image = dest.Image()](vk::CommandBuffer cmdbuf) {
|
dst_image = dest.Image()](vk::CommandBuffer cmdbuf) {
|
||||||
const std::array pre_barriers = {
|
const std::array pre_barriers = {
|
||||||
@ -432,7 +433,7 @@ bool BlitHelper::DepthToBuffer(Surface& source, vk::Buffer buffer,
|
|||||||
update_queue.AddBuffer(descriptor_set, 2, buffer, copy.buffer_offset, copy.buffer_size,
|
update_queue.AddBuffer(descriptor_set, 2, buffer, copy.buffer_offset, copy.buffer_size,
|
||||||
vk::DescriptorType::eStorageBuffer);
|
vk::DescriptorType::eStorageBuffer);
|
||||||
|
|
||||||
render_manager.EndRendering();
|
renderpass_cache.EndRendering();
|
||||||
scheduler.Record([this, descriptor_set, copy, src_image = source.Image(),
|
scheduler.Record([this, descriptor_set, copy, src_image = source.Image(),
|
||||||
extent = source.RealExtent(false)](vk::CommandBuffer cmdbuf) {
|
extent = source.RealExtent(false)](vk::CommandBuffer cmdbuf) {
|
||||||
const vk::ImageMemoryBarrier pre_barrier = {
|
const vk::ImageMemoryBarrier pre_barrier = {
|
||||||
@ -518,7 +519,7 @@ vk::Pipeline BlitHelper::MakeDepthStencilBlitPipeline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::array stages = MakeStages(full_screen_vert, blit_depth_stencil_frag);
|
const std::array stages = MakeStages(full_screen_vert, blit_depth_stencil_frag);
|
||||||
const auto renderpass = render_manager.GetRenderpass(VideoCore::PixelFormat::Invalid,
|
const auto renderpass = renderpass_cache.GetRenderpass(VideoCore::PixelFormat::Invalid,
|
||||||
VideoCore::PixelFormat::D24S8, false);
|
VideoCore::PixelFormat::D24S8, false);
|
||||||
vk::GraphicsPipelineCreateInfo depth_stencil_info = {
|
vk::GraphicsPipelineCreateInfo depth_stencil_info = {
|
||||||
.stageCount = static_cast<u32>(stages.size()),
|
.stageCount = static_cast<u32>(stages.size()),
|
||||||
|
@ -25,7 +25,7 @@ class BlitHelper {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BlitHelper(const Instance& instance, Scheduler& scheduler,
|
explicit BlitHelper(const Instance& instance, Scheduler& scheduler,
|
||||||
RenderManager& render_manager, DescriptorUpdateQueue& update_queue);
|
RenderManager& renderpass_cache, DescriptorUpdateQueue& update_queue);
|
||||||
~BlitHelper();
|
~BlitHelper();
|
||||||
|
|
||||||
bool BlitDepthStencil(Surface& source, Surface& dest, const VideoCore::TextureBlit& blit);
|
bool BlitDepthStencil(Surface& source, Surface& dest, const VideoCore::TextureBlit& blit);
|
||||||
@ -42,7 +42,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
const Instance& instance;
|
const Instance& instance;
|
||||||
Scheduler& scheduler;
|
Scheduler& scheduler;
|
||||||
RenderManager& render_manager;
|
RenderManager& renderpass_cache;
|
||||||
DescriptorUpdateQueue& update_queue;
|
DescriptorUpdateQueue& update_queue;
|
||||||
|
|
||||||
vk::Device device;
|
vk::Device device;
|
||||||
|
@ -64,11 +64,11 @@ Shader::~Shader() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsPipeline::GraphicsPipeline(const Instance& instance_, RenderManager& render_manager_,
|
GraphicsPipeline::GraphicsPipeline(const Instance& instance_, RenderManager& renderpass_cache_,
|
||||||
const PipelineInfo& info_, vk::PipelineCache pipeline_cache_,
|
const PipelineInfo& info_, vk::PipelineCache pipeline_cache_,
|
||||||
vk::PipelineLayout layout_, std::array<Shader*, 3> stages_,
|
vk::PipelineLayout layout_, std::array<Shader*, 3> stages_,
|
||||||
Common::ThreadWorker* worker_)
|
Common::ThreadWorker* worker_)
|
||||||
: instance{instance_}, render_manager{render_manager_}, worker{worker_},
|
: instance{instance_}, renderpass_cache{renderpass_cache_}, worker{worker_},
|
||||||
pipeline_layout{layout_}, pipeline_cache{pipeline_cache_}, info{info_}, stages{stages_} {}
|
pipeline_layout{layout_}, pipeline_cache{pipeline_cache_}, info{info_}, stages{stages_} {}
|
||||||
|
|
||||||
GraphicsPipeline::~GraphicsPipeline() = default;
|
GraphicsPipeline::~GraphicsPipeline() = default;
|
||||||
@ -265,7 +265,7 @@ bool GraphicsPipeline::Build(bool fail_on_compile_required) {
|
|||||||
.pDynamicState = &dynamic_info,
|
.pDynamicState = &dynamic_info,
|
||||||
.layout = pipeline_layout,
|
.layout = pipeline_layout,
|
||||||
.renderPass =
|
.renderPass =
|
||||||
render_manager.GetRenderpass(info.attachments.color, info.attachments.depth, false),
|
renderpass_cache.GetRenderpass(info.attachments.color, info.attachments.depth, false),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fail_on_compile_required) {
|
if (fail_on_compile_required) {
|
||||||
|
@ -165,7 +165,7 @@ struct Shader : public Common::AsyncHandle {
|
|||||||
|
|
||||||
class GraphicsPipeline : public Common::AsyncHandle {
|
class GraphicsPipeline : public Common::AsyncHandle {
|
||||||
public:
|
public:
|
||||||
explicit GraphicsPipeline(const Instance& instance, RenderManager& render_manager,
|
explicit GraphicsPipeline(const Instance& instance, RenderManager& renderpass_cache,
|
||||||
const PipelineInfo& info, vk::PipelineCache pipeline_cache,
|
const PipelineInfo& info, vk::PipelineCache pipeline_cache,
|
||||||
vk::PipelineLayout layout, std::array<Shader*, 3> stages,
|
vk::PipelineLayout layout, std::array<Shader*, 3> stages,
|
||||||
Common::ThreadWorker* worker);
|
Common::ThreadWorker* worker);
|
||||||
@ -181,7 +181,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const Instance& instance;
|
const Instance& instance;
|
||||||
RenderManager& render_manager;
|
RenderManager& renderpass_cache;
|
||||||
Common::ThreadWorker* worker;
|
Common::ThreadWorker* worker;
|
||||||
|
|
||||||
vk::UniquePipeline pipeline;
|
vk::UniquePipeline pipeline;
|
||||||
|
@ -78,8 +78,8 @@ constexpr std::array<vk::DescriptorSetLayoutBinding, 2> UTILITY_BINDINGS = {{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
PipelineCache::PipelineCache(const Instance& instance_, Scheduler& scheduler_,
|
PipelineCache::PipelineCache(const Instance& instance_, Scheduler& scheduler_,
|
||||||
RenderManager& render_manager_, DescriptorUpdateQueue& update_queue_)
|
RenderManager& renderpass_cache_, DescriptorUpdateQueue& update_queue_)
|
||||||
: instance{instance_}, scheduler{scheduler_}, render_manager{render_manager_},
|
: instance{instance_}, scheduler{scheduler_}, renderpass_cache{renderpass_cache_},
|
||||||
update_queue{update_queue_},
|
update_queue{update_queue_},
|
||||||
num_worker_threads{std::max(std::thread::hardware_concurrency(), 2U) >> 1},
|
num_worker_threads{std::max(std::thread::hardware_concurrency(), 2U) >> 1},
|
||||||
workers{num_worker_threads, "Pipeline workers"},
|
workers{num_worker_threads, "Pipeline workers"},
|
||||||
@ -206,7 +206,7 @@ bool PipelineCache::BindPipeline(const PipelineInfo& info, bool wait_built) {
|
|||||||
auto [it, new_pipeline] = graphics_pipelines.try_emplace(pipeline_hash);
|
auto [it, new_pipeline] = graphics_pipelines.try_emplace(pipeline_hash);
|
||||||
if (new_pipeline) {
|
if (new_pipeline) {
|
||||||
it.value() =
|
it.value() =
|
||||||
std::make_unique<GraphicsPipeline>(instance, render_manager, info, *pipeline_cache,
|
std::make_unique<GraphicsPipeline>(instance, renderpass_cache, info, *pipeline_cache,
|
||||||
*pipeline_layout, current_shaders, &workers);
|
*pipeline_layout, current_shaders, &workers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class PipelineCache {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PipelineCache(const Instance& instance, Scheduler& scheduler,
|
explicit PipelineCache(const Instance& instance, Scheduler& scheduler,
|
||||||
RenderManager& render_manager, DescriptorUpdateQueue& update_queue);
|
RenderManager& renderpass_cache, DescriptorUpdateQueue& update_queue);
|
||||||
~PipelineCache();
|
~PipelineCache();
|
||||||
|
|
||||||
/// Acquires and binds a free descriptor set from the appropriate heap.
|
/// Acquires and binds a free descriptor set from the appropriate heap.
|
||||||
@ -98,7 +98,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
const Instance& instance;
|
const Instance& instance;
|
||||||
Scheduler& scheduler;
|
Scheduler& scheduler;
|
||||||
RenderManager& render_manager;
|
RenderManager& renderpass_cache;
|
||||||
DescriptorUpdateQueue& update_queue;
|
DescriptorUpdateQueue& update_queue;
|
||||||
|
|
||||||
Pica::Shader::Profile profile{};
|
Pica::Shader::Profile profile{};
|
||||||
|
@ -58,13 +58,13 @@ RasterizerVulkan::RasterizerVulkan(Memory::MemorySystem& memory, Pica::PicaCore&
|
|||||||
VideoCore::CustomTexManager& custom_tex_manager,
|
VideoCore::CustomTexManager& custom_tex_manager,
|
||||||
VideoCore::RendererBase& renderer,
|
VideoCore::RendererBase& renderer,
|
||||||
Frontend::EmuWindow& emu_window, const Instance& instance,
|
Frontend::EmuWindow& emu_window, const Instance& instance,
|
||||||
Scheduler& scheduler, RenderManager& render_manager,
|
Scheduler& scheduler, RenderManager& renderpass_cache,
|
||||||
DescriptorUpdateQueue& update_queue_, u32 image_count)
|
DescriptorUpdateQueue& update_queue_, u32 image_count)
|
||||||
: RasterizerAccelerated{memory, pica}, instance{instance}, scheduler{scheduler},
|
: RasterizerAccelerated{memory, pica}, instance{instance}, scheduler{scheduler},
|
||||||
render_manager{render_manager}, update_queue{update_queue_},
|
renderpass_cache{renderpass_cache}, update_queue{update_queue_},
|
||||||
pipeline_cache{instance, scheduler, render_manager, update_queue}, runtime{instance,
|
pipeline_cache{instance, scheduler, renderpass_cache, update_queue}, runtime{instance,
|
||||||
scheduler,
|
scheduler,
|
||||||
render_manager,
|
renderpass_cache,
|
||||||
update_queue,
|
update_queue,
|
||||||
image_count},
|
image_count},
|
||||||
res_cache{memory, custom_tex_manager, runtime, regs, renderer},
|
res_cache{memory, custom_tex_manager, runtime, regs, renderer},
|
||||||
@ -110,7 +110,7 @@ RasterizerVulkan::RasterizerVulkan(Memory::MemorySystem& memory, Pica::PicaCore&
|
|||||||
.range = VK_WHOLE_SIZE,
|
.range = VK_WHOLE_SIZE,
|
||||||
});
|
});
|
||||||
|
|
||||||
scheduler.RegisterOnSubmit([&render_manager] { render_manager.EndRendering(); });
|
scheduler.RegisterOnSubmit([&renderpass_cache] { renderpass_cache.EndRendering(); });
|
||||||
|
|
||||||
// Prepare the static buffer descriptor set.
|
// Prepare the static buffer descriptor set.
|
||||||
const auto buffer_set = pipeline_cache.Acquire(DescriptorHeapType::Buffer);
|
const auto buffer_set = pipeline_cache.Acquire(DescriptorHeapType::Buffer);
|
||||||
@ -519,7 +519,7 @@ bool RasterizerVulkan::Draw(bool accelerate, bool is_indexed) {
|
|||||||
|
|
||||||
// Begin rendering
|
// Begin rendering
|
||||||
const auto draw_rect = fb_helper.DrawRect();
|
const auto draw_rect = fb_helper.DrawRect();
|
||||||
render_manager.BeginRendering(framebuffer, draw_rect);
|
renderpass_cache.BeginRendering(framebuffer, draw_rect);
|
||||||
|
|
||||||
// Configure viewport and scissor
|
// Configure viewport and scissor
|
||||||
const auto viewport = fb_helper.Viewport();
|
const auto viewport = fb_helper.Viewport();
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
VideoCore::CustomTexManager& custom_tex_manager,
|
VideoCore::CustomTexManager& custom_tex_manager,
|
||||||
VideoCore::RendererBase& renderer, Frontend::EmuWindow& emu_window,
|
VideoCore::RendererBase& renderer, Frontend::EmuWindow& emu_window,
|
||||||
const Instance& instance, Scheduler& scheduler,
|
const Instance& instance, Scheduler& scheduler,
|
||||||
RenderManager& render_manager, DescriptorUpdateQueue& update_queue,
|
RenderManager& renderpass_cache, DescriptorUpdateQueue& update_queue,
|
||||||
u32 image_count);
|
u32 image_count);
|
||||||
~RasterizerVulkan() override;
|
~RasterizerVulkan() override;
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
const Instance& instance;
|
const Instance& instance;
|
||||||
Scheduler& scheduler;
|
Scheduler& scheduler;
|
||||||
RenderManager& render_manager;
|
RenderManager& renderpass_cache;
|
||||||
DescriptorUpdateQueue& update_queue;
|
DescriptorUpdateQueue& update_queue;
|
||||||
PipelineCache pipeline_cache;
|
PipelineCache pipeline_cache;
|
||||||
TextureRuntime runtime;
|
TextureRuntime runtime;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
constexpr u32 MIN_DRAWS_TO_FLUSH = 20;
|
constexpr u32 MinDrawsToFlush = 20;
|
||||||
|
|
||||||
using VideoCore::PixelFormat;
|
using VideoCore::PixelFormat;
|
||||||
using VideoCore::SurfaceType;
|
using VideoCore::SurfaceType;
|
||||||
@ -118,13 +118,13 @@ void RenderManager::EndRendering() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Reset state.
|
// Reset state.
|
||||||
pass.render_pass = vk::RenderPass{};
|
pass.render_pass = VK_NULL_HANDLE;
|
||||||
images = {};
|
images = {};
|
||||||
aspects = {};
|
aspects = {};
|
||||||
|
|
||||||
// The Mali guide recommends flushing at the end of each major renderpass
|
// The Mali guide recommends flushing at the end of each major renderpass
|
||||||
// Testing has shown this has a significant effect on rendering performance
|
// Testing has shown this has a significant effect on rendering performance
|
||||||
if (num_draws > MIN_DRAWS_TO_FLUSH && instance.ShouldFlush()) {
|
if (num_draws > MinDrawsToFlush && instance.ShouldFlush()) {
|
||||||
scheduler.Flush();
|
scheduler.Flush();
|
||||||
num_draws = 0;
|
num_draws = 0;
|
||||||
}
|
}
|
||||||
@ -135,12 +135,11 @@ vk::RenderPass RenderManager::GetRenderpass(VideoCore::PixelFormat color,
|
|||||||
std::scoped_lock lock{cache_mutex};
|
std::scoped_lock lock{cache_mutex};
|
||||||
|
|
||||||
const u32 color_index =
|
const u32 color_index =
|
||||||
color == VideoCore::PixelFormat::Invalid ? MAX_COLOR_FORMATS : static_cast<u32>(color);
|
color == VideoCore::PixelFormat::Invalid ? NumColorFormats : static_cast<u32>(color);
|
||||||
const u32 depth_index = depth == VideoCore::PixelFormat::Invalid
|
const u32 depth_index =
|
||||||
? MAX_DEPTH_FORMATS
|
depth == VideoCore::PixelFormat::Invalid ? NumDepthFormats : (static_cast<u32>(depth) - 14);
|
||||||
: (static_cast<u32>(depth) - 14);
|
|
||||||
|
|
||||||
ASSERT_MSG(color_index <= MAX_COLOR_FORMATS && depth_index <= MAX_DEPTH_FORMATS,
|
ASSERT_MSG(color_index <= NumColorFormats && depth_index <= NumDepthFormats,
|
||||||
"Invalid color index {} and/or depth_index {}", color_index, depth_index);
|
"Invalid color index {} and/or depth_index {}", color_index, depth_index);
|
||||||
|
|
||||||
vk::UniqueRenderPass& renderpass = cached_renderpasses[color_index][depth_index][is_clear];
|
vk::UniqueRenderPass& renderpass = cached_renderpasses[color_index][depth_index][is_clear];
|
||||||
|
@ -35,8 +35,8 @@ struct RenderPass {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class RenderManager {
|
class RenderManager {
|
||||||
static constexpr std::size_t MAX_COLOR_FORMATS = 13;
|
static constexpr u32 NumColorFormats = 13;
|
||||||
static constexpr std::size_t MAX_DEPTH_FORMATS = 4;
|
static constexpr u32 NumDepthFormats = 4;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RenderManager(const Instance& instance, Scheduler& scheduler);
|
explicit RenderManager(const Instance& instance, Scheduler& scheduler);
|
||||||
@ -63,7 +63,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
const Instance& instance;
|
const Instance& instance;
|
||||||
Scheduler& scheduler;
|
Scheduler& scheduler;
|
||||||
vk::UniqueRenderPass cached_renderpasses[MAX_COLOR_FORMATS + 1][MAX_DEPTH_FORMATS + 1][2];
|
vk::UniqueRenderPass cached_renderpasses[NumColorFormats + 1][NumDepthFormats + 1][2];
|
||||||
std::mutex cache_mutex;
|
std::mutex cache_mutex;
|
||||||
std::array<vk::Image, 2> images;
|
std::array<vk::Image, 2> images;
|
||||||
std::array<vk::ImageAspectFlags, 2> aspects;
|
std::array<vk::ImageAspectFlags, 2> aspects;
|
||||||
|
@ -248,10 +248,10 @@ constexpr u64 DOWNLOAD_BUFFER_SIZE = 16_MiB;
|
|||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
TextureRuntime::TextureRuntime(const Instance& instance, Scheduler& scheduler,
|
TextureRuntime::TextureRuntime(const Instance& instance, Scheduler& scheduler,
|
||||||
RenderManager& render_manager, DescriptorUpdateQueue& update_queue,
|
RenderManager& renderpass_cache, DescriptorUpdateQueue& update_queue,
|
||||||
u32 num_swapchain_images_)
|
u32 num_swapchain_images_)
|
||||||
: instance{instance}, scheduler{scheduler}, render_manager{render_manager},
|
: instance{instance}, scheduler{scheduler}, renderpass_cache{renderpass_cache},
|
||||||
blit_helper{instance, scheduler, render_manager, update_queue},
|
blit_helper{instance, scheduler, renderpass_cache, update_queue},
|
||||||
upload_buffer{instance, scheduler, vk::BufferUsageFlagBits::eTransferSrc, UPLOAD_BUFFER_SIZE,
|
upload_buffer{instance, scheduler, vk::BufferUsageFlagBits::eTransferSrc, UPLOAD_BUFFER_SIZE,
|
||||||
BufferType::Upload},
|
BufferType::Upload},
|
||||||
download_buffer{instance, scheduler,
|
download_buffer{instance, scheduler,
|
||||||
@ -304,7 +304,7 @@ bool TextureRuntime::Reinterpret(Surface& source, Surface& dest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TextureRuntime::ClearTexture(Surface& surface, const VideoCore::TextureClear& clear) {
|
bool TextureRuntime::ClearTexture(Surface& surface, const VideoCore::TextureClear& clear) {
|
||||||
render_manager.EndRendering();
|
renderpass_cache.EndRendering();
|
||||||
|
|
||||||
const RecordParams params = {
|
const RecordParams params = {
|
||||||
.aspect = surface.Aspect(),
|
.aspect = surface.Aspect(),
|
||||||
@ -376,7 +376,7 @@ void TextureRuntime::ClearTextureWithRenderpass(Surface& surface,
|
|||||||
|
|
||||||
const auto color_format = is_color ? surface.pixel_format : PixelFormat::Invalid;
|
const auto color_format = is_color ? surface.pixel_format : PixelFormat::Invalid;
|
||||||
const auto depth_format = is_color ? PixelFormat::Invalid : surface.pixel_format;
|
const auto depth_format = is_color ? PixelFormat::Invalid : surface.pixel_format;
|
||||||
const auto render_pass = render_manager.GetRenderpass(color_format, depth_format, true);
|
const auto render_pass = renderpass_cache.GetRenderpass(color_format, depth_format, true);
|
||||||
|
|
||||||
const RecordParams params = {
|
const RecordParams params = {
|
||||||
.aspect = surface.Aspect(),
|
.aspect = surface.Aspect(),
|
||||||
@ -453,7 +453,7 @@ void TextureRuntime::ClearTextureWithRenderpass(Surface& surface,
|
|||||||
|
|
||||||
bool TextureRuntime::CopyTextures(Surface& source, Surface& dest,
|
bool TextureRuntime::CopyTextures(Surface& source, Surface& dest,
|
||||||
std::span<const VideoCore::TextureCopy> copies) {
|
std::span<const VideoCore::TextureCopy> copies) {
|
||||||
render_manager.EndRendering();
|
renderpass_cache.EndRendering();
|
||||||
|
|
||||||
const RecordParams params = {
|
const RecordParams params = {
|
||||||
.aspect = source.Aspect(),
|
.aspect = source.Aspect(),
|
||||||
@ -561,7 +561,7 @@ bool TextureRuntime::BlitTextures(Surface& source, Surface& dest,
|
|||||||
return blit_helper.BlitDepthStencil(source, dest, blit);
|
return blit_helper.BlitDepthStencil(source, dest, blit);
|
||||||
}
|
}
|
||||||
|
|
||||||
render_manager.EndRendering();
|
renderpass_cache.EndRendering();
|
||||||
|
|
||||||
const RecordParams params = {
|
const RecordParams params = {
|
||||||
.aspect = source.Aspect(),
|
.aspect = source.Aspect(),
|
||||||
@ -669,7 +669,7 @@ void TextureRuntime::GenerateMipmaps(Surface& surface) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
render_manager.EndRendering();
|
renderpass_cache.EndRendering();
|
||||||
|
|
||||||
auto [width, height] = surface.RealExtent();
|
auto [width, height] = surface.RealExtent();
|
||||||
const u32 levels = surface.levels;
|
const u32 levels = surface.levels;
|
||||||
@ -732,7 +732,7 @@ Surface::Surface(TextureRuntime& runtime_, const VideoCore::SurfaceParams& param
|
|||||||
raw_images.emplace_back(handles[1].image);
|
raw_images.emplace_back(handles[1].image);
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime->render_manager.EndRendering();
|
runtime->renderpass_cache.EndRendering();
|
||||||
scheduler->Record([raw_images, aspect = traits.aspect](vk::CommandBuffer cmdbuf) {
|
scheduler->Record([raw_images, aspect = traits.aspect](vk::CommandBuffer cmdbuf) {
|
||||||
const auto barriers = MakeInitBarriers(aspect, raw_images);
|
const auto barriers = MakeInitBarriers(aspect, raw_images);
|
||||||
cmdbuf.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe,
|
cmdbuf.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe,
|
||||||
@ -776,7 +776,7 @@ Surface::Surface(TextureRuntime& runtime_, const VideoCore::SurfaceBase& surface
|
|||||||
raw_images.emplace_back(handles[2].image);
|
raw_images.emplace_back(handles[2].image);
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime->render_manager.EndRendering();
|
runtime->renderpass_cache.EndRendering();
|
||||||
scheduler->Record([raw_images, aspect = traits.aspect](vk::CommandBuffer cmdbuf) {
|
scheduler->Record([raw_images, aspect = traits.aspect](vk::CommandBuffer cmdbuf) {
|
||||||
const auto barriers = MakeInitBarriers(aspect, raw_images);
|
const auto barriers = MakeInitBarriers(aspect, raw_images);
|
||||||
cmdbuf.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe,
|
cmdbuf.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe,
|
||||||
@ -804,7 +804,7 @@ Surface::~Surface() {
|
|||||||
|
|
||||||
void Surface::Upload(const VideoCore::BufferTextureCopy& upload,
|
void Surface::Upload(const VideoCore::BufferTextureCopy& upload,
|
||||||
const VideoCore::StagingData& staging) {
|
const VideoCore::StagingData& staging) {
|
||||||
runtime->render_manager.EndRendering();
|
runtime->renderpass_cache.EndRendering();
|
||||||
|
|
||||||
const RecordParams params = {
|
const RecordParams params = {
|
||||||
.aspect = Aspect(),
|
.aspect = Aspect(),
|
||||||
@ -972,7 +972,7 @@ void Surface::Download(const VideoCore::BufferTextureCopy& download,
|
|||||||
runtime->download_buffer.Commit(staging.size);
|
runtime->download_buffer.Commit(staging.size);
|
||||||
});
|
});
|
||||||
|
|
||||||
runtime->render_manager.EndRendering();
|
runtime->renderpass_cache.EndRendering();
|
||||||
|
|
||||||
if (pixel_format == PixelFormat::D24S8) {
|
if (pixel_format == PixelFormat::D24S8) {
|
||||||
runtime->blit_helper.DepthToBuffer(*this, runtime->download_buffer.Handle(), download);
|
runtime->blit_helper.DepthToBuffer(*this, runtime->download_buffer.Handle(), download);
|
||||||
@ -1072,7 +1072,7 @@ void Surface::ScaleUp(u32 new_scale) {
|
|||||||
MakeHandle(instance, GetScaledWidth(), GetScaledHeight(), levels, texture_type,
|
MakeHandle(instance, GetScaledWidth(), GetScaledHeight(), levels, texture_type,
|
||||||
traits.native, traits.usage, flags, traits.aspect, false, DebugName(true));
|
traits.native, traits.usage, flags, traits.aspect, false, DebugName(true));
|
||||||
|
|
||||||
runtime->render_manager.EndRendering();
|
runtime->renderpass_cache.EndRendering();
|
||||||
scheduler->Record(
|
scheduler->Record(
|
||||||
[raw_images = std::array{Image()}, aspect = traits.aspect](vk::CommandBuffer cmdbuf) {
|
[raw_images = std::array{Image()}, aspect = traits.aspect](vk::CommandBuffer cmdbuf) {
|
||||||
const auto barriers = MakeInitBarriers(aspect, raw_images);
|
const auto barriers = MakeInitBarriers(aspect, raw_images);
|
||||||
@ -1150,7 +1150,7 @@ vk::ImageView Surface::CopyImageView() noexcept {
|
|||||||
copy_layout = vk::ImageLayout::eUndefined;
|
copy_layout = vk::ImageLayout::eUndefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime->render_manager.EndRendering();
|
runtime->renderpass_cache.EndRendering();
|
||||||
|
|
||||||
const RecordParams params = {
|
const RecordParams params = {
|
||||||
.aspect = Aspect(),
|
.aspect = Aspect(),
|
||||||
@ -1338,7 +1338,7 @@ vk::Framebuffer Surface::Framebuffer() noexcept {
|
|||||||
const auto color_format = is_depth ? PixelFormat::Invalid : pixel_format;
|
const auto color_format = is_depth ? PixelFormat::Invalid : pixel_format;
|
||||||
const auto depth_format = is_depth ? pixel_format : PixelFormat::Invalid;
|
const auto depth_format = is_depth ? pixel_format : PixelFormat::Invalid;
|
||||||
const auto render_pass =
|
const auto render_pass =
|
||||||
runtime->render_manager.GetRenderpass(color_format, depth_format, false);
|
runtime->renderpass_cache.GetRenderpass(color_format, depth_format, false);
|
||||||
const auto attachments = std::array{ImageView()};
|
const auto attachments = std::array{ImageView()};
|
||||||
framebuffers[index] = MakeFramebuffer(instance->GetDevice(), render_pass, GetScaledWidth(),
|
framebuffers[index] = MakeFramebuffer(instance->GetDevice(), render_pass, GetScaledWidth(),
|
||||||
GetScaledHeight(), attachments);
|
GetScaledHeight(), attachments);
|
||||||
@ -1452,7 +1452,7 @@ Framebuffer::Framebuffer(TextureRuntime& runtime, const VideoCore::FramebufferPa
|
|||||||
Surface* color, Surface* depth)
|
Surface* color, Surface* depth)
|
||||||
: VideoCore::FramebufferParams{params}, res_scale{color ? color->res_scale
|
: VideoCore::FramebufferParams{params}, res_scale{color ? color->res_scale
|
||||||
: (depth ? depth->res_scale : 1u)} {
|
: (depth ? depth->res_scale : 1u)} {
|
||||||
auto& render_manager = runtime.GetRenderpassCache();
|
auto& renderpass_cache = runtime.GetRenderpassCache();
|
||||||
if (shadow_rendering && !color) {
|
if (shadow_rendering && !color) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1486,11 +1486,11 @@ Framebuffer::Framebuffer(TextureRuntime& runtime, const VideoCore::FramebufferPa
|
|||||||
const vk::Device device = runtime.GetInstance().GetDevice();
|
const vk::Device device = runtime.GetInstance().GetDevice();
|
||||||
if (shadow_rendering) {
|
if (shadow_rendering) {
|
||||||
render_pass =
|
render_pass =
|
||||||
render_manager.GetRenderpass(PixelFormat::Invalid, PixelFormat::Invalid, false);
|
renderpass_cache.GetRenderpass(PixelFormat::Invalid, PixelFormat::Invalid, false);
|
||||||
framebuffer = MakeFramebuffer(device, render_pass, color->GetScaledWidth(),
|
framebuffer = MakeFramebuffer(device, render_pass, color->GetScaledWidth(),
|
||||||
color->GetScaledHeight(), {});
|
color->GetScaledHeight(), {});
|
||||||
} else {
|
} else {
|
||||||
render_pass = render_manager.GetRenderpass(formats[0], formats[1], false);
|
render_pass = renderpass_cache.GetRenderpass(formats[0], formats[1], false);
|
||||||
framebuffer = MakeFramebuffer(device, render_pass, width, height, attachments);
|
framebuffer = MakeFramebuffer(device, render_pass, width, height, attachments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class TextureRuntime {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TextureRuntime(const Instance& instance, Scheduler& scheduler,
|
explicit TextureRuntime(const Instance& instance, Scheduler& scheduler,
|
||||||
RenderManager& render_manager, DescriptorUpdateQueue& update_queue,
|
RenderManager& renderpass_cache, DescriptorUpdateQueue& update_queue,
|
||||||
u32 num_swapchain_images);
|
u32 num_swapchain_images);
|
||||||
~TextureRuntime();
|
~TextureRuntime();
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
RenderManager& GetRenderpassCache() {
|
RenderManager& GetRenderpassCache() {
|
||||||
return render_manager;
|
return renderpass_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the removal threshold ticks for the garbage collector
|
/// Returns the removal threshold ticks for the garbage collector
|
||||||
@ -96,7 +96,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
const Instance& instance;
|
const Instance& instance;
|
||||||
Scheduler& scheduler;
|
Scheduler& scheduler;
|
||||||
RenderManager& render_manager;
|
RenderManager& renderpass_cache;
|
||||||
BlitHelper blit_helper;
|
BlitHelper blit_helper;
|
||||||
StreamBuffer upload_buffer;
|
StreamBuffer upload_buffer;
|
||||||
StreamBuffer download_buffer;
|
StreamBuffer download_buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user