diff --git a/Source/Core/VideoBackends/D3D/TextureCache.h b/Source/Core/VideoBackends/D3D/TextureCache.h index 85cc641812..9fc5d0876c 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.h +++ b/Source/Core/VideoBackends/D3D/TextureCache.h @@ -58,7 +58,7 @@ private: u32 memory_stride, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf) override; - void CompileShaders() override {} + bool CompileShaders() override { return true; } void DeleteShaders() override {} ID3D11Buffer* palette_buf; ID3D11ShaderResourceView* palette_buf_srv; diff --git a/Source/Core/VideoBackends/D3D12/TextureCache.h b/Source/Core/VideoBackends/D3D12/TextureCache.h index 4cce8a75b0..d8b20a4911 100644 --- a/Source/Core/VideoBackends/D3D12/TextureCache.h +++ b/Source/Core/VideoBackends/D3D12/TextureCache.h @@ -65,7 +65,7 @@ private: u32 memory_stride, PEControl::PixelFormat src_format, const EFBRectangle& src_rect, bool is_intensity, bool scale_by_half) override; - void CompileShaders() override {} + bool CompileShaders() override { return true; } void DeleteShaders() override {} std::unique_ptr m_palette_stream_buffer; diff --git a/Source/Core/VideoBackends/Null/TextureCache.h b/Source/Core/VideoBackends/Null/TextureCache.h index d6ee5b3b7c..7c51133c6a 100644 --- a/Source/Core/VideoBackends/Null/TextureCache.h +++ b/Source/Core/VideoBackends/Null/TextureCache.h @@ -13,7 +13,7 @@ class TextureCache : public TextureCacheBase public: TextureCache() {} ~TextureCache() {} - void CompileShaders() override {} + bool CompileShaders() override { return true; } void DeleteShaders() override {} void ConvertTexture(TCacheEntryBase* entry, TCacheEntryBase* unconverted, void* palette, TlutFormat format) override diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index 6643e6b9cd..dc9d290f3e 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -314,7 +314,7 @@ void TextureCache::SetStage() glActiveTexture(GL_TEXTURE0 + s_ActiveTexture); } -void TextureCache::CompileShaders() +bool TextureCache::CompileShaders() { constexpr const char* color_copy_program = "SAMPLER_BINDING(9) uniform sampler2DArray samp9;\n" "in vec3 f_uv0;\n" @@ -398,15 +398,18 @@ void TextureCache::CompileShaders() const char* prefix = geo_program.empty() ? "f" : "v"; const char* depth_layer = g_ActiveConfig.bStereoEFBMonoDepth ? "0.0" : "f_uv0.z"; - ProgramShaderCache::CompileShader(s_ColorCopyProgram, - StringFromFormat(vertex_program, prefix, prefix), - color_copy_program, geo_program); - ProgramShaderCache::CompileShader(s_ColorMatrixProgram, - StringFromFormat(vertex_program, prefix, prefix), - color_matrix_program, geo_program); - ProgramShaderCache::CompileShader( - s_DepthMatrixProgram, StringFromFormat(vertex_program, prefix, prefix), - StringFromFormat(depth_matrix_program, depth_layer), geo_program); + if (!ProgramShaderCache::CompileShader(s_ColorCopyProgram, + StringFromFormat(vertex_program, prefix, prefix), + color_copy_program, geo_program) || + !ProgramShaderCache::CompileShader(s_ColorMatrixProgram, + StringFromFormat(vertex_program, prefix, prefix), + color_matrix_program, geo_program) || + !ProgramShaderCache::CompileShader( + s_DepthMatrixProgram, StringFromFormat(vertex_program, prefix, prefix), + StringFromFormat(depth_matrix_program, depth_layer), geo_program)) + { + return false; + } s_ColorMatrixUniform = glGetUniformLocation(s_ColorMatrixProgram.glprogid, "colmat"); s_DepthMatrixUniform = glGetUniformLocation(s_DepthMatrixProgram.glprogid, "colmat"); @@ -500,9 +503,12 @@ void TextureCache::CompileShaders() if (g_ActiveConfig.backend_info.bSupportsPaletteConversion) { - ProgramShaderCache::CompileShader( - s_palette_pixel_shader[GX_TL_IA8], StringFromFormat(vertex_program, prefix, prefix), - "#define DECODE DecodePixel_IA8" + palette_shader, geo_program); + if (!ProgramShaderCache::CompileShader( + s_palette_pixel_shader[GX_TL_IA8], StringFromFormat(vertex_program, prefix, prefix), + "#define DECODE DecodePixel_IA8" + palette_shader, geo_program)) + { + return false; + } s_palette_buffer_offset_uniform[GX_TL_IA8] = glGetUniformLocation(s_palette_pixel_shader[GX_TL_IA8].glprogid, "texture_buffer_offset"); s_palette_multiplier_uniform[GX_TL_IA8] = @@ -510,9 +516,12 @@ void TextureCache::CompileShaders() s_palette_copy_position_uniform[GX_TL_IA8] = glGetUniformLocation(s_palette_pixel_shader[GX_TL_IA8].glprogid, "copy_position"); - ProgramShaderCache::CompileShader( - s_palette_pixel_shader[GX_TL_RGB565], StringFromFormat(vertex_program, prefix, prefix), - "#define DECODE DecodePixel_RGB565" + palette_shader, geo_program); + if (!ProgramShaderCache::CompileShader( + s_palette_pixel_shader[GX_TL_RGB565], StringFromFormat(vertex_program, prefix, prefix), + "#define DECODE DecodePixel_RGB565" + palette_shader, geo_program)) + { + return false; + } s_palette_buffer_offset_uniform[GX_TL_RGB565] = glGetUniformLocation( s_palette_pixel_shader[GX_TL_RGB565].glprogid, "texture_buffer_offset"); s_palette_multiplier_uniform[GX_TL_RGB565] = @@ -520,9 +529,12 @@ void TextureCache::CompileShaders() s_palette_copy_position_uniform[GX_TL_RGB565] = glGetUniformLocation(s_palette_pixel_shader[GX_TL_RGB565].glprogid, "copy_position"); - ProgramShaderCache::CompileShader( - s_palette_pixel_shader[GX_TL_RGB5A3], StringFromFormat(vertex_program, prefix, prefix), - "#define DECODE DecodePixel_RGB5A3" + palette_shader, geo_program); + if (!ProgramShaderCache::CompileShader( + s_palette_pixel_shader[GX_TL_RGB5A3], StringFromFormat(vertex_program, prefix, prefix), + "#define DECODE DecodePixel_RGB5A3" + palette_shader, geo_program)) + { + return false; + } s_palette_buffer_offset_uniform[GX_TL_RGB5A3] = glGetUniformLocation( s_palette_pixel_shader[GX_TL_RGB5A3].glprogid, "texture_buffer_offset"); s_palette_multiplier_uniform[GX_TL_RGB5A3] = @@ -530,6 +542,8 @@ void TextureCache::CompileShaders() s_palette_copy_position_uniform[GX_TL_RGB5A3] = glGetUniformLocation(s_palette_pixel_shader[GX_TL_RGB5A3].glprogid, "copy_position"); } + + return true; } void TextureCache::DeleteShaders() diff --git a/Source/Core/VideoBackends/OGL/TextureCache.h b/Source/Core/VideoBackends/OGL/TextureCache.h index ecd9056127..0007cf1deb 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.h +++ b/Source/Core/VideoBackends/OGL/TextureCache.h @@ -57,7 +57,7 @@ private: u32 memory_stride, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf) override; - void CompileShaders() override; + bool CompileShaders() override; void DeleteShaders() override; }; diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index 47bfa694bf..ebac32de3a 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -47,10 +47,12 @@ public: class TextureCache : public TextureCacheBase { public: - void CompileShaders() override{}; - void DeleteShaders() override{}; + bool CompileShaders() override { return true; } + void DeleteShaders() override {} void ConvertTexture(TCacheEntryBase* entry, TCacheEntryBase* unconverted, void* palette, - TlutFormat format) override{}; + TlutFormat format) override + { + } void CopyEFB(u8* dst, u32 format, u32 native_width, u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf) override diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index ab260aedd7..39af7f155c 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -133,7 +133,8 @@ void TextureCacheBase::OnConfigChanged(VideoConfig& config) config.bStereoEFBMonoDepth != backup_config.s_efb_mono_depth) { g_texture_cache->DeleteShaders(); - g_texture_cache->CompileShaders(); + if (!g_texture_cache->CompileShaders()) + PanicAlert("Failed to recompile one or more texture conversion shaders."); } } diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index b3bde3bb0d..e10a0439f1 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -160,8 +160,8 @@ public: u32 memory_stride, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf) = 0; - virtual void CompileShaders() = 0; // currently only implemented by OGL - virtual void DeleteShaders() = 0; // currently only implemented by OGL + virtual bool CompileShaders() = 0; + virtual void DeleteShaders() = 0; static TCacheEntryBase* Load(const u32 stage); static void UnbindTextures();