From 5cdc55591bdd66c87e41fec7d181456200b93d37 Mon Sep 17 00:00:00 2001 From: plagman Date: Sun, 28 Jun 2009 21:16:11 +0000 Subject: [PATCH] Adds r_pr_ati_nodepthoffset and the proper detection code to winlayer and sdlayer to make polymer run properly on R520-class Radeon chips. A bug needs to be filed to AMD. git-svn-id: https://svn.eduke32.com/eduke32@1446 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/polymer.h | 1 + polymer/eduke32/build/src/polymer.c | 5 +++-- polymer/eduke32/build/src/polymost.c | 1 + polymer/eduke32/build/src/sdlayer.c | 9 ++++++++- polymer/eduke32/build/src/winlayer.c | 10 ++++++++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/polymer/eduke32/build/include/polymer.h b/polymer/eduke32/build/include/polymer.h index 416e22aaf..ee1a31212 100644 --- a/polymer/eduke32/build/include/polymer.h +++ b/polymer/eduke32/build/include/polymer.h @@ -52,6 +52,7 @@ extern int32_t pr_overridespecular; extern float pr_specularpower; extern float pr_specularfactor; extern int32_t pr_ati_fboworkaround; +extern int32_t pr_ati_nodepthoffset; extern int32_t r_pr_maxlightpasses; diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 583d38d36..9f149b32b 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -28,6 +28,7 @@ int32_t pr_overridespecular = 0; float pr_specularpower = 15.0f; float pr_specularfactor = 1.0f; int32_t pr_ati_fboworkaround = 0; +int32_t pr_ati_nodepthoffset = 0; int32_t r_pr_maxlightpasses = 5; // value of the cvar (not live value), used to detect changes @@ -1105,12 +1106,12 @@ void polymer_drawsprite(int32_t snum) if ((tspr->cstat & 64) && ((tspr->cstat>>4) & 3)) bglEnable(GL_CULL_FACE); - if (!depth || mirrors[depth-1].plane) + if (!pr_ati_nodepthoffset && (!depth || mirrors[depth-1].plane)) bglEnable(GL_POLYGON_OFFSET_FILL); polymer_drawplane(&spriteplane); - if (!depth || mirrors[depth-1].plane) + if (!pr_ati_nodepthoffset && (!depth || mirrors[depth-1].plane)) bglDisable(GL_POLYGON_OFFSET_FILL); if ((tspr->cstat & 64) && ((tspr->cstat>>4) & 3)) diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 6f9f0cd52..29076815c 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -5998,6 +5998,7 @@ void polymost_initosdfuncs(void) { "r_pr_specularpower", "r_pr_specularpower: overriden specular material power", (void*)&pr_specularpower, CVAR_FLOAT | CVAR_NOSAVE, 0, -10, 1000 }, { "r_pr_specularfactor", "r_pr_specularfactor: overriden specular material factor", (void*)&pr_specularfactor, CVAR_FLOAT | CVAR_NOSAVE, 0, -10, 1000 }, { "r_pr_ati_fboworkaround", "r_pr_ati_fboworkaround: enable this to workaround an ATI driver bug that causes sprite shadows to be square - you need to restart the renderer for it to take effect", (void*)&pr_ati_fboworkaround, CVAR_BOOL | CVAR_NOSAVE, 0, 0, 1 }, + { "r_pr_ati_nodepthoffset", "r_pr_ati_nodepthoffset: enable this to workaround an ATI driver bug that causes sprite drawing to freeze the game on Radeon X1x00 hardware - you need to restart the renderer for it to take effect", (void*)&pr_ati_nodepthoffset, CVAR_BOOL | CVAR_NOSAVE, 0, 0, 1 }, #endif { "r_models","r_models: enable/disable model rendering",(void *)&usemodels, CVAR_BOOL, 0, 0, 1 }, diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 063d17e4e..55d320695 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -1118,7 +1118,14 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs) if (!Bstrcmp(glinfo.vendor,"ATI Technologies Inc.")) { pr_ati_fboworkaround = 1; initprintf("Enabling ATI FBO color attachment workaround.\n"); - } else pr_ati_fboworkaround = 0; + + if (!Bstrncmp(glinfo.renderer,"Radeon X1", 9)) { + pr_ati_nodepthoffset = 1; + initprintf("Enabling ATI R520 polygon offset workaround.\n"); + } else + pr_ati_nodepthoffset = 0; + } else + pr_ati_fboworkaround = 0; #endif diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index bbc745c26..b8e85ece5 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -3389,8 +3389,14 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp) if (!Bstrcmp(glinfo.vendor,"ATI Technologies Inc.")) { pr_ati_fboworkaround = 1; initprintf("Enabling ATI FBO color attachment workaround.\n"); - } - else pr_ati_fboworkaround = 0; + + if (!Bstrncmp(glinfo.renderer,"Radeon X1", 9)) { + pr_ati_nodepthoffset = 1; + initprintf("Enabling ATI R520 polygon offset workaround.\n"); + } else + pr_ati_nodepthoffset = 0; + } else + pr_ati_fboworkaround = 0; } #endif if (!forcegl && err)