fix some AMD issues

This is only a hack. The correct solution would be:
1. don't use GL_TEXTURE_RECT ever. GL_TEXTURE_2D should also be faster
2. use GL_TEXTURE8+ for util textures
3. both
This commit is contained in:
degasus 2013-01-03 09:45:12 +01:00
parent b38b62afc6
commit a1ca288555
4 changed files with 13 additions and 4 deletions

View File

@ -341,6 +341,7 @@ void XFBSource::Draw(const MathUtil::Rectangle<float> &sourcerc,
{ {
// Texture map xfbSource->texture onto the main buffer // Texture map xfbSource->texture onto the main buffer
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
if(!(s_cached_sourcerc == sourcerc) || !(s_cached_drawrc == drawrc)) { if(!(s_cached_sourcerc == sourcerc) || !(s_cached_drawrc == drawrc)) {
@ -374,6 +375,8 @@ void XFBSource::Draw(const MathUtil::Rectangle<float> &sourcerc,
// TODO: this after merging with graphic_update // TODO: this after merging with graphic_update
glBindVertexArray(0); glBindVertexArray(0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
} }

View File

@ -1185,6 +1185,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
GLuint read_texture = FramebufferManager::ResolveAndGetRenderTarget(rc); GLuint read_texture = FramebufferManager::ResolveAndGetRenderTarget(rc);
// Render to the real buffer now. // Render to the real buffer now.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the window backbuffer glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the window backbuffer
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
if(!( s_cached_targetRc == targetRc)) { if(!( s_cached_targetRc == targetRc)) {

View File

@ -121,7 +121,6 @@ TextureCache::TCacheEntry::TCacheEntry()
void TextureCache::TCacheEntry::Bind(unsigned int stage) void TextureCache::TCacheEntry::Bind(unsigned int stage)
{ {
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
@ -215,7 +214,6 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width,
void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height, void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,
unsigned int expanded_width, unsigned int level, bool autogen_mips) unsigned int expanded_width, unsigned int level, bool autogen_mips)
{ {
//glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
//GL_REPORT_ERRORD(); //GL_REPORT_ERRORD();
@ -307,6 +305,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_RECTANGLE_ARB); glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
glViewport(0, 0, virtual_width, virtual_height); glViewport(0, 0, virtual_width, virtual_height);
@ -370,6 +369,8 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
// TODO: this after merging with graphic_update // TODO: this after merging with graphic_update
glBindVertexArray(0); glBindVertexArray(0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
// Unbind texture from temporary framebuffer // Unbind texture from temporary framebuffer
@ -472,7 +473,6 @@ TextureCache::~TextureCache()
void TextureCache::DisableStage(unsigned int stage) void TextureCache::DisableStage(unsigned int stage)
{ {
glActiveTexture(GL_TEXTURE0 + stage); glActiveTexture(GL_TEXTURE0 + stage);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_RECTANGLE_ARB); glDisable(GL_TEXTURE_RECTANGLE_ARB);
} }

View File

@ -190,6 +190,7 @@ void Init()
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
CreateRgbToYuyvProgram(); CreateRgbToYuyvProgram();
CreateYuyvToRgbProgram(); CreateYuyvToRgbProgram();
@ -236,6 +237,7 @@ void EncodeToRamUsingShader(GLuint srcTexture, const TargetRectangle& sourceRc,
// set source texture // set source texture
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_RECTANGLE_ARB); glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, srcTexture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, srcTexture);
if (linearFilter) if (linearFilter)
@ -280,6 +282,8 @@ void EncodeToRamUsingShader(GLuint srcTexture, const TargetRectangle& sourceRc,
// TODO: this after merging with graphic_update // TODO: this after merging with graphic_update
glBindVertexArray(0); glBindVertexArray(0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
// .. and then read back the results. // .. and then read back the results.
@ -383,7 +387,6 @@ void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc, u8* des
EncodeToRamUsingShader(srcTexture, sourceRc, destAddr, dstWidth / 2, dstHeight, 0, false, false); EncodeToRamUsingShader(srcTexture, sourceRc, destAddr, dstWidth / 2, dstHeight, 0, false, false);
FramebufferManager::SetFramebuffer(0); FramebufferManager::SetFramebuffer(0);
VertexShaderManager::SetViewportChanged(); VertexShaderManager::SetViewportChanged();
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
TextureCache::DisableStage(0); TextureCache::DisableStage(0);
g_renderer->RestoreAPIState(); g_renderer->RestoreAPIState();
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
@ -407,6 +410,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
// switch to texture converter frame buffer // switch to texture converter frame buffer
// attach destTexture as color destination // attach destTexture as color destination
FramebufferManager::SetFramebuffer(s_texConvFrameBuffer); FramebufferManager::SetFramebuffer(s_texConvFrameBuffer);
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, destTexture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, destTexture);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, destTexture, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, destTexture, 0);
@ -419,6 +423,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur
// set srcAddr as data for source texture // set srcAddr as data for source texture
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_RECTANGLE_ARB); glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_srcTexture);
// TODO: make this less slow. (How?) // TODO: make this less slow. (How?)