mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 08:13:05 +00:00
Refactor graphics #1
This commit is contained in:
1 parent
7905f2d12f
commit
cbc11d2eaf
71 files changed
+2051
-3399
No files matched your search
@@ -1,22 +1,16 @@
|
||||
#include "graphics/host_gpu/renderer/pipelineCache.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/emulatorConfig.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/profiler.h"
|
||||
#include "common/stringUtils.h"
|
||||
#include "graphics/guest_gpu/graphicsRun.h"
|
||||
#include "graphics/guest_gpu/hardwareContext.h"
|
||||
#include "graphics/host_gpu/renderer/colorRenderTarget.h"
|
||||
#include "graphics/host_gpu/renderer/debug.h"
|
||||
#include "graphics/host_gpu/renderer/depthRenderTarget.h"
|
||||
#include "graphics/host_gpu/renderer/framebufferCache.h"
|
||||
#include "graphics/host_gpu/renderer/renderContext.h"
|
||||
#include "graphics/host_gpu/utils.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <fmt/format.h>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
|
||||
@@ -44,26 +38,6 @@ bool PipelineStaticParameters::operator==(const PipelineStaticParameters& other)
|
||||
return std::memcmp(this, &other, sizeof(*this)) == 0;
|
||||
}
|
||||
|
||||
void PipelineCache::DeletePipelineInternal(Pipeline* p) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(p == nullptr);
|
||||
EXIT_IF(p->pipeline == nullptr);
|
||||
EXIT_IF(p->pipeline_layout == nullptr);
|
||||
|
||||
DumpPipeline("delete", *p);
|
||||
|
||||
auto* gctx = g_render_ctx->GetGraphicCtx();
|
||||
|
||||
EXIT_IF(gctx == nullptr);
|
||||
|
||||
VulkanDeviceWaitIdle(gctx);
|
||||
gctx->device.destroyPipeline(p->pipeline, nullptr);
|
||||
gctx->device.destroyPipelineLayout(p->pipeline_layout, nullptr);
|
||||
|
||||
p->pipeline = nullptr;
|
||||
p->pipeline_layout = nullptr;
|
||||
}
|
||||
|
||||
PipelineCache::GraphicsPipeline* PipelineCache::CreateGraphicsPipeline(
|
||||
VulkanFramebuffer* framebuffer, RenderColorInfo* colors, uint32_t color_count,
|
||||
RenderDepthInfo* depth, ShaderVertexInputInfo* vs_input_info, HW::Context* ctx,
|
||||
@@ -188,7 +162,6 @@ PipelineCache::GraphicsPipeline* PipelineCache::CreateGraphicsPipeline(
|
||||
|
||||
auto [iter, inserted] = m_graphics_pipelines.emplace(std::move(key), std::move(cached));
|
||||
EXIT_IF(!inserted);
|
||||
DumpPipeline("create", *iter->second);
|
||||
|
||||
return iter->second.get();
|
||||
}
|
||||
@@ -231,69 +204,4 @@ PipelineCache::CreateComputePipeline(ShaderComputeInputInfo* input_info,
|
||||
|
||||
return iter->second.get();
|
||||
}
|
||||
|
||||
void PipelineCache::DeletePipeline(Pipeline* pipeline) {
|
||||
Common::LockGuard lock(m_mutex);
|
||||
|
||||
EXIT_IF(pipeline == nullptr);
|
||||
|
||||
for (auto iter = m_graphics_pipelines.begin(); iter != m_graphics_pipelines.end(); iter++) {
|
||||
if (iter->second.get() == pipeline) {
|
||||
DeletePipelineInternal(iter->second.get());
|
||||
m_graphics_pipelines.erase(iter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto iter = m_compute_pipelines.begin(); iter != m_compute_pipelines.end(); iter++) {
|
||||
if (iter->second.get() == pipeline) {
|
||||
DeletePipelineInternal(iter->second.get());
|
||||
m_compute_pipelines.erase(iter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
EXIT_IF(true);
|
||||
}
|
||||
|
||||
void PipelineCache::DeleteAllPipelines() {
|
||||
Common::LockGuard lock(m_mutex);
|
||||
|
||||
for (auto& item: m_graphics_pipelines) {
|
||||
DeletePipelineInternal(item.second.get());
|
||||
}
|
||||
m_graphics_pipelines.clear();
|
||||
|
||||
for (auto& item: m_compute_pipelines) {
|
||||
DeletePipelineInternal(item.second.get());
|
||||
}
|
||||
m_compute_pipelines.clear();
|
||||
}
|
||||
|
||||
void PipelineCache::DumpToFile(Common::File* f, const Pipeline& p) {}
|
||||
|
||||
void PipelineCache::DumpPipeline(const char* action, const Pipeline& p) {
|
||||
EXIT_IF(action == nullptr);
|
||||
|
||||
static std::atomic_int dump_id = 0;
|
||||
|
||||
if (!Config::PipelineDumpEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Common::File f;
|
||||
const auto file_name =
|
||||
Config::GetPipelineDumpFolder() /
|
||||
fmt::format("{:04d}_{:04d}_pipeline_{}.log", GraphicsRunGetFrameNum(), dump_id++, action);
|
||||
Common::File::CreateDirectories(file_name.parent_path());
|
||||
f.Create(file_name);
|
||||
if (f.IsInvalid()) {
|
||||
auto file_name_text = Common::PathToString(file_name);
|
||||
LOGF_COLOR(Log::Color::BrightRed, "Can't create file: %s\n", file_name_text.c_str());
|
||||
return;
|
||||
}
|
||||
DumpToFile(&f, p);
|
||||
f.Close();
|
||||
}
|
||||
|
||||
} // namespace Libs::Graphics
|
||||
Reference in new issue
Block a user