PostProcessing/FX: Fix loading of resource textures

This commit is contained in:
Stenzek 2023-11-05 13:52:56 +10:00
parent edae13d9e4
commit 4ef465cea4
No known key found for this signature in database
1 changed files with 12 additions and 5 deletions

View File

@ -6,6 +6,7 @@
#include "shadergen.h"
// TODO: Remove me
#include "core/host.h"
#include "core/settings.h"
#include "common/assert.h"
@ -775,14 +776,20 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
return false;
}
const std::string image_path =
Path::Combine(EmuFolders::Shaders, Path::Combine("reshade" FS_OSPATH_SEPARATOR_STR "Textures", source));
Common::RGBA8Image image;
if (!image.LoadFromFile(image_path.c_str()))
if (const std::string image_path =
Path::Combine(EmuFolders::Shaders, Path::Combine("reshade" FS_OSPATH_SEPARATOR_STR "Textures", source));
!image.LoadFromFile(image_path.c_str()))
{
// Might be a base file/resource instead.
const std::string resource_name = Path::Combine("shaders/reshade/Textures", source);
if (std::optional<std::vector<u8>> resdata = Host::ReadResourceFile(resource_name.c_str());
!resdata.has_value() || !image.LoadFromBuffer(resource_name.c_str(), resdata->data(), resdata->size()))
{
Error::SetString(error, fmt::format("Failed to load image '{}' (from '{}')", source, image_path).c_str());
return false;
}
}
tex.rt_scale = 0.0f;
tex.texture = g_gpu_device->CreateTexture(image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Type::Texture,