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.
This commit is contained in:
iwubcode
2025-11-17 18:32:47 -06:00
parent 6ba2d2e081
commit 2d8f955851
6 changed files with 407 additions and 84 deletions

View File

@@ -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<VideoCommon::CustomAssetLibrary> 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<MaterialResource>(
@@ -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<VideoCommon::CustomAssetLibrary> library)
MaterialResource* CustomResourceManager::GetPostProcessingMaterialFromAsset(
const CustomAssetLibrary::AssetID& asset_id,
std::shared_ptr<VideoCommon::CustomAssetLibrary> library)
{
auto& resource = m_postprocessing_material_resources[asset_id];
if (resource == nullptr)
{
resource =
std::make_unique<MaterialResource>(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<GXPipelineUid>& pipeline_uid, const std::string& preprocessor_settings,
std::shared_ptr<VideoCommon::CustomAssetLibrary> library)
{
auto& resource = m_shader_resources[asset_id][shader_key];
if (resource == nullptr)