VideoBackends: Make TextureCache::CompileShaders return a bool

This commit is contained in:
Stenzek 2016-08-13 22:56:01 +10:00
parent 6a99cbd9fc
commit 828aac7890
8 changed files with 46 additions and 29 deletions

View File

@ -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;

View File

@ -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<D3DStreamBuffer> m_palette_stream_buffer;

View File

@ -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

View File

@ -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,
if (!ProgramShaderCache::CompileShader(s_ColorCopyProgram,
StringFromFormat(vertex_program, prefix, prefix),
color_copy_program, geo_program);
ProgramShaderCache::CompileShader(s_ColorMatrixProgram,
color_copy_program, geo_program) ||
!ProgramShaderCache::CompileShader(s_ColorMatrixProgram,
StringFromFormat(vertex_program, prefix, prefix),
color_matrix_program, geo_program);
ProgramShaderCache::CompileShader(
color_matrix_program, geo_program) ||
!ProgramShaderCache::CompileShader(
s_DepthMatrixProgram, StringFromFormat(vertex_program, prefix, prefix),
StringFromFormat(depth_matrix_program, depth_layer), geo_program);
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(
if (!ProgramShaderCache::CompileShader(
s_palette_pixel_shader[GX_TL_IA8], StringFromFormat(vertex_program, prefix, prefix),
"#define DECODE DecodePixel_IA8" + palette_shader, geo_program);
"#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(
if (!ProgramShaderCache::CompileShader(
s_palette_pixel_shader[GX_TL_RGB565], StringFromFormat(vertex_program, prefix, prefix),
"#define DECODE DecodePixel_RGB565" + palette_shader, geo_program);
"#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(
if (!ProgramShaderCache::CompileShader(
s_palette_pixel_shader[GX_TL_RGB5A3], StringFromFormat(vertex_program, prefix, prefix),
"#define DECODE DecodePixel_RGB5A3" + palette_shader, geo_program);
"#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()

View File

@ -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;
};

View File

@ -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

View File

@ -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.");
}
}

View File

@ -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();