mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Implement depth texture load for nfl quaterback 98
Fixed nfl quaterback 98: missing fb effect (whatever option used) #316
This commit is contained in:
parent
5b4ce499c4
commit
6e0d0432a7
|
@ -155,6 +155,7 @@ struct Config
|
||||||
#define hack_ModifyVertexXyInShader (1<<13) //Pass screen coordinates provided in gSPModifyVertex to vertes shader.
|
#define hack_ModifyVertexXyInShader (1<<13) //Pass screen coordinates provided in gSPModifyVertex to vertes shader.
|
||||||
#define hack_legoRacers (1<<14) //LEGO racers course map
|
#define hack_legoRacers (1<<14) //LEGO racers course map
|
||||||
#define hack_doNotResetTLUTmode (1<<15) //Don't set TLUT mode to none after dlist end. Quake 64
|
#define hack_doNotResetTLUTmode (1<<15) //Don't set TLUT mode to none after dlist end. Quake 64
|
||||||
|
#define hack_LoadDepthTextures (1<<16) //Load textures for depth buffer
|
||||||
|
|
||||||
extern Config config;
|
extern Config config;
|
||||||
|
|
||||||
|
|
|
@ -535,3 +535,7 @@ void SetMonochromeCombiner() {
|
||||||
}
|
}
|
||||||
gDP.changed |= CHANGED_COMBINE;
|
gDP.changed |= CHANGED_COMBINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SetDepthTextureCombiner() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -133,6 +133,7 @@ void DestroyShaderCombiner();
|
||||||
void SetDepthFogCombiner();
|
void SetDepthFogCombiner();
|
||||||
void SetMonochromeCombiner();
|
void SetMonochromeCombiner();
|
||||||
#endif // GL_IMAGE_TEXTURES_SUPPORT
|
#endif // GL_IMAGE_TEXTURES_SUPPORT
|
||||||
|
bool SetDepthTextureCombiner();
|
||||||
|
|
||||||
//#define USE_TOONIFY
|
//#define USE_TOONIFY
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ static GLuint g_readtex_shader_object;
|
||||||
static GLuint g_readtex_ms_shader_object;
|
static GLuint g_readtex_ms_shader_object;
|
||||||
static GLuint g_dither_shader_object;
|
static GLuint g_dither_shader_object;
|
||||||
static GLuint g_monochrome_image_program = 0;
|
static GLuint g_monochrome_image_program = 0;
|
||||||
|
static GLuint g_depth_texture_program = 0;
|
||||||
|
|
||||||
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
||||||
GLuint g_draw_shadow_map_program = 0;
|
GLuint g_draw_shadow_map_program = 0;
|
||||||
|
@ -228,6 +229,24 @@ void InitShaderCombiner()
|
||||||
glUseProgram(g_monochrome_image_program);
|
glUseProgram(g_monochrome_image_program);
|
||||||
const int texLoc = glGetUniformLocation(g_monochrome_image_program, "uColorImage");
|
const int texLoc = glGetUniformLocation(g_monochrome_image_program, "uColorImage");
|
||||||
glUniform1i(texLoc, 0);
|
glUniform1i(texLoc, 0);
|
||||||
|
|
||||||
|
if ((config.generalEmulation.hacks&hack_LoadDepthTextures) != 0) {
|
||||||
|
GLuint depth_texture_shader_object = _createShader(GL_FRAGMENT_SHADER, depth_texture_fragment_shader);
|
||||||
|
g_depth_texture_program = glCreateProgram();
|
||||||
|
glBindAttribLocation(g_depth_texture_program, SC_POSITION, "aPosition");
|
||||||
|
glBindAttribLocation(g_depth_texture_program, SC_TEXCOORD0, "aTexCoord0");
|
||||||
|
glAttachShader(g_depth_texture_program, g_vertex_shader_object);
|
||||||
|
glAttachShader(g_depth_texture_program, depth_texture_shader_object);
|
||||||
|
glLinkProgram(g_depth_texture_program);
|
||||||
|
glDeleteShader(depth_texture_shader_object);
|
||||||
|
assert(checkProgramLinkStatus(g_depth_texture_program));
|
||||||
|
glUseProgram(g_depth_texture_program);
|
||||||
|
int loc = glGetUniformLocation(g_depth_texture_program, "uTex0");
|
||||||
|
glUniform1i(loc, 0);
|
||||||
|
loc = glGetUniformLocation(g_depth_texture_program, "uRenderState");
|
||||||
|
glUniform1i(loc, OGLRender::rsTexRect);
|
||||||
|
}
|
||||||
|
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
|
|
||||||
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
||||||
|
@ -267,6 +286,8 @@ void DestroyShaderCombiner() {
|
||||||
glDeleteProgram(g_monochrome_image_program);
|
glDeleteProgram(g_monochrome_image_program);
|
||||||
g_monochrome_image_program = 0;
|
g_monochrome_image_program = 0;
|
||||||
noiseTex.destroy();
|
noiseTex.destroy();
|
||||||
|
glDeleteProgram(g_depth_texture_program);
|
||||||
|
g_depth_texture_program = 0;
|
||||||
|
|
||||||
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
||||||
DestroyZlutTexture();
|
DestroyZlutTexture();
|
||||||
|
@ -879,7 +900,18 @@ void SetDepthFogCombiner()
|
||||||
}
|
}
|
||||||
#endif // GL_IMAGE_TEXTURES_SUPPORT
|
#endif // GL_IMAGE_TEXTURES_SUPPORT
|
||||||
|
|
||||||
void SetMonochromeCombiner() {
|
void SetMonochromeCombiner()
|
||||||
|
{
|
||||||
glUseProgram(g_monochrome_image_program);
|
glUseProgram(g_monochrome_image_program);
|
||||||
gDP.changed |= CHANGED_COMBINE;
|
gDP.changed |= CHANGED_COMBINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SetDepthTextureCombiner()
|
||||||
|
{
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthFunc(GL_ALWAYS);
|
||||||
|
glDepthMask(TRUE);
|
||||||
|
glUseProgram(g_depth_texture_program);
|
||||||
|
gDP.changed |= CHANGED_COMBINE | CHANGED_RENDERMODE;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -673,3 +673,19 @@ MAIN_SHADER_VERSION
|
||||||
"} \n"
|
"} \n"
|
||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const char* depth_texture_fragment_shader =
|
||||||
|
MAIN_SHADER_VERSION
|
||||||
|
"uniform sampler2D uTex0; \n"
|
||||||
|
"in mediump vec2 vTexCoord0; \n"
|
||||||
|
"void main() \n"
|
||||||
|
"{ \n"
|
||||||
|
#ifdef GLESX
|
||||||
|
"#ifdef GL_NV_fragdepth \n"
|
||||||
|
" gl_FragDepth = texture(uTex0, vTexCoord0).r; \n"
|
||||||
|
"#endif \n"
|
||||||
|
#else
|
||||||
|
" gl_FragDepth = texture(uTex0, vTexCoord0).r; \n"
|
||||||
|
#endif
|
||||||
|
"} \n"
|
||||||
|
;
|
||||||
|
|
|
@ -988,6 +988,18 @@ bool texturedRectDepthBufferCopy(const OGLRender::TexturedRectParams & _params)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
bool texturedRectDepthBufferRender(const OGLRender::TexturedRectParams & _params)
|
||||||
|
{
|
||||||
|
if (gDP.colorImage.address == gDP.depthImageAddress) {
|
||||||
|
FrameBuffer * pCurBuf = frameBufferList().getCurrent();
|
||||||
|
if (pCurBuf == nullptr || pCurBuf->m_pDepthBuffer == nullptr)
|
||||||
|
return true;
|
||||||
|
return !SetDepthTextureCombiner();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
bool texturedRectCopyToItself(const OGLRender::TexturedRectParams & _params)
|
bool texturedRectCopyToItself(const OGLRender::TexturedRectParams & _params)
|
||||||
{
|
{
|
||||||
|
@ -1485,6 +1497,8 @@ void OGLRender::_setSpecialTexrect() const
|
||||||
texturedRectSpecial = texturedRectPaletteMod;
|
texturedRectSpecial = texturedRectPaletteMod;
|
||||||
else if (strstr(name, (const char *)"ZELDA"))
|
else if (strstr(name, (const char *)"ZELDA"))
|
||||||
texturedRectSpecial = texturedRectMonochromeBackground;
|
texturedRectSpecial = texturedRectMonochromeBackground;
|
||||||
|
else if (strstr(name, (const char *)"quarterback_club_98"))
|
||||||
|
texturedRectSpecial = texturedRectDepthBufferRender;
|
||||||
else
|
else
|
||||||
texturedRectSpecial = NULL;
|
texturedRectSpecial = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,6 +352,8 @@ void RSP_Init()
|
||||||
config.generalEmulation.hacks |= hack_ModifyVertexXyInShader;
|
config.generalEmulation.hacks |= hack_ModifyVertexXyInShader;
|
||||||
else if (strstr(RSP.romname, (const char *)"Quake") != NULL)
|
else if (strstr(RSP.romname, (const char *)"Quake") != NULL)
|
||||||
config.generalEmulation.hacks |= hack_doNotResetTLUTmode;
|
config.generalEmulation.hacks |= hack_doNotResetTLUTmode;
|
||||||
|
else if (strstr(RSP.romname, (const char *)"quarterback_club_98") != NULL)
|
||||||
|
config.generalEmulation.hacks |= hack_LoadDepthTextures;
|
||||||
|
|
||||||
api().FindPluginPath(RSP.pluginpath);
|
api().FindPluginPath(RSP.pluginpath);
|
||||||
|
|
||||||
|
|
|
@ -881,6 +881,22 @@ bool TextureCache::_loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 &
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureCache::_loadDepthTexture(CachedTexture * _pTexture, u16* _pDest)
|
||||||
|
{
|
||||||
|
#ifndef GLES2
|
||||||
|
const u32 numTexels = _pTexture->realWidth * _pTexture->realHeight;
|
||||||
|
_pTexture->textureBytes = numTexels * sizeof(GLfloat);
|
||||||
|
GLfloat * pDestF = (GLfloat*)malloc(_pTexture->textureBytes);
|
||||||
|
assert(pDestF != NULL);
|
||||||
|
|
||||||
|
for (u32 t = 0; t < numTexels; ++t)
|
||||||
|
pDestF[t] = _pDest[t] / 65535.0f;
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, _pTexture->realWidth, _pTexture->realHeight, 0, GL_RED, GL_FLOAT, pDestF);
|
||||||
|
free(pDestF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Worker function for _load
|
* Worker function for _load
|
||||||
*/
|
*/
|
||||||
|
@ -1047,6 +1063,12 @@ void TextureCache::_load(u32 _tile, CachedTexture *_pTexture)
|
||||||
while (true) {
|
while (true) {
|
||||||
_getTextureDestData(tmptex, pDest, glInternalFormat, GetTexel, &line);
|
_getTextureDestData(tmptex, pDest, glInternalFormat, GetTexel, &line);
|
||||||
|
|
||||||
|
if ((config.generalEmulation.hacks&hack_LoadDepthTextures) != 0 && gDP.colorImage.address == gDP.depthImageAddress) {
|
||||||
|
_loadDepthTexture(_pTexture, (u16*)pDest);
|
||||||
|
free(pDest);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_toggleDumpTex &&
|
if (m_toggleDumpTex &&
|
||||||
config.textureFilter.txHiresEnable != 0 &&
|
config.textureFilter.txHiresEnable != 0 &&
|
||||||
config.textureFilter.txDump != 0) {
|
config.textureFilter.txDump != 0) {
|
||||||
|
|
|
@ -77,6 +77,7 @@ private:
|
||||||
bool _loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 & _ricecrc);
|
bool _loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 & _ricecrc);
|
||||||
void _loadBackground(CachedTexture *pTexture);
|
void _loadBackground(CachedTexture *pTexture);
|
||||||
bool _loadHiresBackground(CachedTexture *_pTexture);
|
bool _loadHiresBackground(CachedTexture *_pTexture);
|
||||||
|
void _loadDepthTexture(CachedTexture * _pTexture, u16* _pDest);
|
||||||
void _updateBackground();
|
void _updateBackground();
|
||||||
void _clear();
|
void _clear();
|
||||||
void _initDummyTexture(CachedTexture * _pDummy);
|
void _initDummyTexture(CachedTexture * _pDummy);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user