TextureCache: Recompile EFB2Tex shaders when stereo 3D is toggled.

This commit is contained in:
Jules Blok 2014-11-04 00:53:14 +01:00
parent 4d075c2efb
commit ee76c03160
5 changed files with 44 additions and 17 deletions

View File

@ -43,6 +43,9 @@ private:
TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h) override;
u64 EncodeToRamFromTexture(u32 address, void* source_texture, u32 SourceW, u32 SourceH, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source) {return 0;};
void CompileShaders() override { }
void DeleteShaders() override { }
};
}

View File

@ -318,6 +318,32 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
}
TextureCache::TextureCache()
{
CompileShaders();
s_ActiveTexture = -1;
for (auto& gtex : s_Textures)
gtex = -1;
}
TextureCache::~TextureCache()
{
DeleteShaders();
}
void TextureCache::DisableStage(unsigned int stage)
{
}
void TextureCache::SetStage()
{
// -1 is the initial value as we don't know which texture should be bound
if (s_ActiveTexture != (u32)-1)
glActiveTexture(GL_TEXTURE0 + s_ActiveTexture);
}
void TextureCache::CompileShaders()
{
const char *pColorMatrixProg =
"SAMPLER_BINDING(9) uniform sampler2DArray samp9;\n"
@ -414,28 +440,12 @@ TextureCache::TextureCache()
s_ColorCopyPositionUniform = glGetUniformLocation(s_ColorMatrixProgram.glprogid, "copy_position");
s_DepthCopyPositionUniform = glGetUniformLocation(s_DepthMatrixProgram.glprogid, "copy_position");
s_ActiveTexture = -1;
for (auto& gtex : s_Textures)
gtex = -1;
}
TextureCache::~TextureCache()
void TextureCache::DeleteShaders()
{
s_ColorMatrixProgram.Destroy();
s_DepthMatrixProgram.Destroy();
}
void TextureCache::DisableStage(unsigned int stage)
{
}
void TextureCache::SetStage ()
{
// -1 is the initial value as we don't know which texture should be bound
if (s_ActiveTexture != (u32)-1)
glActiveTexture(GL_TEXTURE0 + s_ActiveTexture);
}
}

View File

@ -57,6 +57,9 @@ private:
unsigned int expanded_width, unsigned int tex_levels, PC_TexFormat pcfmt) override;
TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h) override;
void CompileShaders() override;
void DeleteShaders() override;
};
bool SaveTexture(const std::string& filename, u32 textarget, u32 tex, int virtual_width, int virtual_height, unsigned int level);

View File

@ -115,6 +115,12 @@ void TextureCache::OnConfigChanged(VideoConfig& config)
{
g_texture_cache->ClearRenderTargets();
}
if ((config.iStereoMode > 0) != backup_config.s_stereo_3d)
{
g_texture_cache->DeleteShaders();
g_texture_cache->CompileShaders();
}
}
backup_config.s_colorsamples = config.iSafeTextureCache_ColorSamples;
@ -126,6 +132,7 @@ void TextureCache::OnConfigChanged(VideoConfig& config)
backup_config.s_texfmt_overlay_center = config.bTexFmtOverlayCenter;
backup_config.s_hires_textures = config.bHiresTextures;
backup_config.s_copy_cache_enable = config.bEFBCopyCacheEnable;
backup_config.s_stereo_3d = config.iStereoMode > 0;
}
void TextureCache::Cleanup()

View File

@ -102,6 +102,9 @@ public:
unsigned int expanded_width, unsigned int tex_levels, PC_TexFormat pcfmt) = 0;
virtual TCacheEntryBase* CreateRenderTargetTexture(unsigned int scaled_tex_w, unsigned int scaled_tex_h) = 0;
virtual void CompileShaders() = 0; // currently only implemented by OGL
virtual void DeleteShaders() = 0; // currently only implemented by OGL
static TCacheEntryBase* Load(unsigned int stage, u32 address, unsigned int width, unsigned int height,
int format, unsigned int tlutaddr, int tlutfmt, bool use_mipmaps, unsigned int maxlevel, bool from_tmem);
static void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat,
@ -141,6 +144,7 @@ private:
bool s_texfmt_overlay_center;
bool s_hires_textures;
bool s_copy_cache_enable;
bool s_stereo_3d;
} backup_config;
};