From 2d8f9558515df4f5fccee9be9e659e40b710e164 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Mon, 17 Nov 2025 18:32:47 -0600 Subject: VideoCommon: enhance 'CustomResourceManager' for post processing This expands the interface of 'CustomResourceManager' to get a Material for post processing a frame buffer (currently EFB). The flow is similar to the normal draw material but distinguishes itself by not needing a UID. The full shader is much simpler than the draw shader and is currently put inline with the shader resource. --- .../Resources/CustomResourceManager.cpp | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'Source/Core/VideoCommon/Resources/CustomResourceManager.cpp') diff --git a/Source/Core/VideoCommon/Resources/CustomResourceManager.cpp b/Source/Core/VideoCommon/Resources/CustomResourceManager.cpp index ffb16b055a..29e215b8ea 100644 --- a/Source/Core/VideoCommon/Resources/CustomResourceManager.cpp +++ b/Source/Core/VideoCommon/Resources/CustomResourceManager.cpp @@ -43,7 +43,8 @@ void CustomResourceManager::Shutdown() void CustomResourceManager::Reset() { - m_material_resources.clear(); + m_draw_material_resources.clear(); + m_postprocessing_material_resources.clear(); m_shader_resources.clear(); m_texture_data_resources.clear(); m_texture_sampler_resources.clear(); @@ -102,11 +103,11 @@ TextureDataResource* CustomResourceManager::GetTextureDataFromAsset( return resource.get(); } -MaterialResource* CustomResourceManager::GetMaterialFromAsset( +MaterialResource* CustomResourceManager::GetDrawMaterialFromAsset( const CustomAssetLibrary::AssetID& asset_id, const GXPipelineUid& pipeline_uid, std::shared_ptr library) { - auto& resource = m_material_resources[asset_id][PipelineToHash(pipeline_uid)]; + auto& resource = m_draw_material_resources[asset_id][PipelineToHash(pipeline_uid)]; if (resource == nullptr) { resource = std::make_unique( @@ -116,11 +117,24 @@ MaterialResource* CustomResourceManager::GetMaterialFromAsset( return resource.get(); } -ShaderResource* -CustomResourceManager::GetShaderFromAsset(const CustomAssetLibrary::AssetID& asset_id, - std::size_t shader_key, const GXPipelineUid& pipeline_uid, - const std::string& preprocessor_settings, - std::shared_ptr library) +MaterialResource* CustomResourceManager::GetPostProcessingMaterialFromAsset( + const CustomAssetLibrary::AssetID& asset_id, + std::shared_ptr library) +{ + auto& resource = m_postprocessing_material_resources[asset_id]; + if (resource == nullptr) + { + resource = + std::make_unique(CreateResourceContext(asset_id, std::move(library))); + } + resource->Process(); + return resource.get(); +} + +ShaderResource* CustomResourceManager::GetShaderFromAsset( + const CustomAssetLibrary::AssetID& asset_id, std::size_t shader_key, + const std::optional& pipeline_uid, const std::string& preprocessor_settings, + std::shared_ptr library) { auto& resource = m_shader_resources[asset_id][shader_key]; if (resource == nullptr) -- cgit v1.2.3