1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Correct palette load for shadow map.

This commit is contained in:
Sergey Lipskiy 2013-11-10 17:43:49 +07:00
parent e9b5283339
commit 5070a1aa82
4 changed files with 16 additions and 27 deletions

View File

@ -28,6 +28,7 @@ static GLuint g_shadow_map_vertex_shader_object;
static GLuint g_shadow_map_fragment_shader_object;
static GLuint g_draw_shadow_map_program;
GLuint g_tlut_tex = 0;
static u32 g_paletteCRC256 = 0;
static const GLuint ZlutImageUnit = 0;
static const GLuint TlutImageUnit = 1;
@ -126,6 +127,7 @@ void InitShadowMapShader()
if (!OGL.bImageTexture)
return;
g_paletteCRC256 = 0;
glGenTextures(1, &g_tlut_tex);
glBindTexture(GL_TEXTURE_1D, g_tlut_tex);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@ -743,16 +745,23 @@ void GLSL_RenderDepth() {
}
void GLS_SetShadowMapCombiner() {
if (!OGL.bImageTexture)
return;
_unbindImageTextures();
/*
glBindTexture(GL_TEXTURE_1D, g_tlut_tex);
u16 *pData = (u16*)&TMEM[256];
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RED, GL_UNSIGNED_SHORT, pData);
glBindTexture(GL_TEXTURE_1D, 0);
*/
if (g_paletteCRC256 != gDP.paletteCRC256) {
g_paletteCRC256 = gDP.paletteCRC256;
u16 palette[256];
u16 *src = (u16*)&TMEM[256];
for (int i = 0; i < 256; ++i)
palette[i] = swapword(src[i*4]);
glBindTexture(GL_TEXTURE_1D, g_tlut_tex);
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RED, GL_UNSIGNED_SHORT, palette);
glBindTexture(GL_TEXTURE_1D, 0);
}
glUseProgram(g_draw_shadow_map_program);
glBindImageTexture(TlutImageUnit, g_tlut_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);

View File

@ -208,6 +208,4 @@ GLenum ogl_glCheckFramebufferStatus (GLenum target);
void ogl_glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
bool checkFBO();
extern GLuint g_tlut_tex;
#endif

18
gDP.cpp
View File

@ -676,21 +676,6 @@ void gDPLoadBlock( u32 tile, u32 uls, u32 ult, u32 lrs, u32 dxt )
#endif
}
void load_palette (u32 addr)
{
if (g_tlut_tex == 0)
return;
u16 *pPal = gDP.palette;
for (u32 i = 0; i < 256; ++i) {
*(pPal++) = *(u16*)(RDRAM + (addr^2));
addr += 2;
}
glBindTexture(GL_TEXTURE_1D, g_tlut_tex);
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RED, GL_UNSIGNED_SHORT, gDP.palette);
glBindTexture(GL_TEXTURE_1D, 0);
}
void gDPLoadTLUT( u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt )
{
gDPSetTileSize( tile, uls, ult, lrs, lrt );
@ -726,9 +711,6 @@ void gDPLoadTLUT( u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt )
gDP.changed |= CHANGED_TMEM;
if (count == 256)
load_palette(gDP.textureImage.address);
#ifdef DEBUG
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED | DEBUG_TEXTURE, "gDPLoadTLUT( %i, %i, %i, %i, %i );\n",
tile, gDP.tiles[tile].uls, gDP.tiles[tile].ult, gDP.tiles[tile].lrs, gDP.tiles[tile].lrt );

2
gDP.h
View File

@ -228,7 +228,7 @@ struct gDPInfo
u32 changed;
u16 palette[256];
//u16 palette[256];
u32 paletteCRC16[16];
u32 paletteCRC256;
u32 half_1, half_2;