From 4cce3699f35ac4472fa6abcf085cb76ec64f4c67 Mon Sep 17 00:00:00 2001 From: Samuliak Date: Thu, 12 Sep 2024 08:05:27 +0200 Subject: [PATCH] put query object into a separate file --- src/Cafe/CMakeLists.txt | 2 + .../HW/Latte/Renderer/Metal/MetalQuery.cpp | 17 +++++++ src/Cafe/HW/Latte/Renderer/Metal/MetalQuery.h | 19 ++++++++ .../HW/Latte/Renderer/Metal/MetalRenderer.cpp | 19 ++++++++ .../HW/Latte/Renderer/Metal/MetalRenderer.h | 47 ++----------------- 5 files changed, 61 insertions(+), 43 deletions(-) create mode 100644 src/Cafe/HW/Latte/Renderer/Metal/MetalQuery.cpp create mode 100644 src/Cafe/HW/Latte/Renderer/Metal/MetalQuery.h diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 634014b7..10c85270 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -567,6 +567,8 @@ if(ENABLE_METAL) HW/Latte/Renderer/Metal/MetalSamplerCache.h HW/Latte/Renderer/Metal/MetalHybridComputePipeline.cpp HW/Latte/Renderer/Metal/MetalHybridComputePipeline.h + HW/Latte/Renderer/Metal/MetalQuery.cpp + HW/Latte/Renderer/Metal/MetalQuery.h HW/Latte/Renderer/Metal/MetalPerformanceMonitor.h HW/Latte/Renderer/Metal/UtilityShaderSource.h ) diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalQuery.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalQuery.cpp new file mode 100644 index 00000000..40c73fd4 --- /dev/null +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalQuery.cpp @@ -0,0 +1,17 @@ +#include "Cafe/HW/Latte/Renderer/Metal/MetalQuery.h" + +bool LatteQueryObjectMtl::getResult(uint64& numSamplesPassed) +{ + cemuLog_log(LogType::MetalLogging, "LatteQueryObjectMtl::getResult: occlusion queries are not yet supported on Metal"); + return true; +} + +void LatteQueryObjectMtl::begin() +{ + cemuLog_log(LogType::MetalLogging, "LatteQueryObjectMtl::begin: occlusion queries are not yet supported on Metal"); +} + +void LatteQueryObjectMtl::end() +{ + cemuLog_log(LogType::MetalLogging, "LatteQueryObjectMtl::end: occlusion queries are not yet supported on Metal"); +} diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalQuery.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalQuery.h new file mode 100644 index 00000000..ea2be227 --- /dev/null +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalQuery.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Cafe/HW/Latte/Core/LatteQueryObject.h" + +#include "Cafe/HW/Latte/Renderer/Metal/MetalCommon.h" + +// HACK: Dummy occlusion query object +class LatteQueryObjectMtl : public LatteQueryObject +{ +public: + LatteQueryObjectMtl(class MetalRenderer* mtlRenderer) : m_mtlr{mtlRenderer} {} + + bool getResult(uint64& numSamplesPassed) override; + void begin() override; + void end() override; + +private: + class MetalRenderer* m_mtlr; +}; diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp index 4ff1a3b0..ffb8fb72 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.cpp @@ -9,6 +9,7 @@ #include "Cafe/HW/Latte/Renderer/Metal/MetalSamplerCache.h" #include "Cafe/HW/Latte/Renderer/Metal/LatteTextureReadbackMtl.h" #include "Cafe/HW/Latte/Renderer/Metal/MetalHybridComputePipeline.h" +#include "Cafe/HW/Latte/Renderer/Metal/MetalQuery.h" #include "Cafe/HW/Latte/Renderer/Metal/LatteToMtl.h" #include "Cafe/HW/Latte/Renderer/Metal/UtilityShaderSource.h" @@ -1282,6 +1283,24 @@ void MetalRenderer::indexData_uploadIndexMemory(uint32 bufferIndex, uint32 offse */ } +LatteQueryObject* MetalRenderer::occlusionQuery_create() { + cemuLog_log(LogType::MetalLogging, "MetalRenderer::occlusionQuery_create: Occlusion queries are not yet supported on Metal"); + + return new LatteQueryObjectMtl(this); +} + +void MetalRenderer::occlusionQuery_destroy(LatteQueryObject* queryObj) { + cemuLog_log(LogType::MetalLogging, "MetalRenderer::occlusionQuery_destroy: occlusion queries are not yet supported on Metal"); +} + +void MetalRenderer::occlusionQuery_flush() { + cemuLog_log(LogType::MetalLogging, "MetalRenderer::occlusionQuery_flush: occlusion queries are not yet supported on Metal"); +} + +void MetalRenderer::occlusionQuery_updateState() { + cemuLog_log(LogType::MetalLogging, "MetalRenderer::occlusionQuery_updateState: occlusion queries are not yet supported on Metal"); +} + void MetalRenderer::SetBuffer(MTL::RenderCommandEncoder* renderCommandEncoder, MetalShaderType shaderType, MTL::Buffer* buffer, size_t offset, uint32 index) { auto& boundBuffer = m_state.m_encoderState.m_buffers[shaderType][index]; diff --git a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h index 25051a97..f00f814c 100644 --- a/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Metal/MetalRenderer.h @@ -155,32 +155,6 @@ enum class MetalEncoderType Blit, }; -// HACK: Dummy occlusion query object for Metal -class LatteQueryObjectMtl : public LatteQueryObject -{ -public: - LatteQueryObjectMtl(class MetalRenderer* mtlRenderer) : m_mtlr{mtlRenderer} {} - - bool getResult(uint64& numSamplesPassed) override - { - cemuLog_log(LogType::MetalLogging, "LatteQueryObjectMtl::getResult: occlusion queries are not yet supported on Metal"); - return true; - } - - void begin() override - { - cemuLog_log(LogType::MetalLogging, "LatteQueryObjectMtl::begin: occlusion queries are not yet supported on Metal"); - } - - void end() override - { - cemuLog_log(LogType::MetalLogging, "LatteQueryObjectMtl::end: occlusion queries are not yet supported on Metal"); - } - -private: - class MetalRenderer* m_mtlr; -}; - class MetalRenderer : public Renderer { public: @@ -296,23 +270,10 @@ public: void indexData_uploadIndexMemory(uint32 bufferIndex, uint32 offset, uint32 size) override; // occlusion queries - LatteQueryObject* occlusionQuery_create() override { - cemuLog_log(LogType::MetalLogging, "MetalRenderer::occlusionQuery_create: Occlusion queries are not yet supported on Metal"); - - return new LatteQueryObjectMtl(this); - } - - void occlusionQuery_destroy(LatteQueryObject* queryObj) override { - cemuLog_log(LogType::MetalLogging, "MetalRenderer::occlusionQuery_destroy: occlusion queries are not yet supported on Metal"); - } - - void occlusionQuery_flush() override { - cemuLog_log(LogType::MetalLogging, "MetalRenderer::occlusionQuery_flush: occlusion queries are not yet supported on Metal"); - } - - void occlusionQuery_updateState() override { - cemuLog_log(LogType::MetalLogging, "MetalRenderer::occlusionQuery_updateState: occlusion queries are not yet supported on Metal"); - } + LatteQueryObject* occlusionQuery_create() override; + void occlusionQuery_destroy(LatteQueryObject* queryObj) override; + void occlusionQuery_flush() override; + void occlusionQuery_updateState() override; // Helpers MetalPerformanceMonitor& GetPerformanceMonitor() { return m_performanceMonitor; }