mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
BindImageTexture fixes
This commit is contained in:
parent
b0f17ef953
commit
cc3446c4d6
|
@ -220,6 +220,8 @@ DepthBuffer *DepthBuffer_FindBuffer( u32 address )
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void DepthBuffer_ClearBuffer() {
|
void DepthBuffer_ClearBuffer() {
|
||||||
|
if (!OGL.bImageTexture)
|
||||||
|
return;
|
||||||
DepthBuffer *current = depthBuffer.top;
|
DepthBuffer *current = depthBuffer.top;
|
||||||
if (current == NULL || current->fbo == 0)
|
if (current == NULL || current->fbo == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -227,5 +229,6 @@ void DepthBuffer_ClearBuffer() {
|
||||||
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||||
ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current->fbo);
|
ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current->fbo);
|
||||||
OGL_DrawRect(0,0,VI.width, VI.height, color);
|
OGL_DrawRect(0,0,VI.width, VI.height, color);
|
||||||
|
glBindImageTexture(depthImageUnit, current->depth_texture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||||
ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,6 +387,7 @@ void FrameBuffer_AttachDepthBuffer()
|
||||||
ogl_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer.top->renderbuf);
|
ogl_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer.top->renderbuf);
|
||||||
GLuint attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT };
|
GLuint attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT };
|
||||||
ogl_glDrawBuffers(2, attachments, frameBuffer.top->texture->glName);
|
ogl_glDrawBuffers(2, attachments, frameBuffer.top->texture->glName);
|
||||||
|
glBindImageTexture(depthImageUnit, depthBuffer.top->depth_texture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||||
assert(checkFBO());
|
assert(checkFBO());
|
||||||
} else if (frameBuffer.top != NULL) {
|
} else if (frameBuffer.top != NULL) {
|
||||||
frameBuffer.top->pDepthBuffer = 0;
|
frameBuffer.top->pDepthBuffer = 0;
|
||||||
|
|
|
@ -101,11 +101,15 @@ void InitZlutTexture()
|
||||||
512, 512, 0, GL_RED, GL_UNSIGNED_SHORT,
|
512, 512, 0, GL_RED, GL_UNSIGNED_SHORT,
|
||||||
zLUT);
|
zLUT);
|
||||||
delete[] zLUT;
|
delete[] zLUT;
|
||||||
|
glBindImageTexture(ZlutImageUnit, g_zlut_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void DestroyZlutTexture()
|
void DestroyZlutTexture()
|
||||||
{
|
{
|
||||||
|
if (!OGL.bImageTexture)
|
||||||
|
return;
|
||||||
|
glBindImageTexture(ZlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
|
||||||
if (g_zlut_tex > 0)
|
if (g_zlut_tex > 0)
|
||||||
glDeleteTextures(1, &g_zlut_tex);
|
glDeleteTextures(1, &g_zlut_tex);
|
||||||
}
|
}
|
||||||
|
@ -147,6 +151,8 @@ void DestroyShadowMapShader()
|
||||||
if (!OGL.bImageTexture)
|
if (!OGL.bImageTexture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
|
||||||
|
|
||||||
if (g_tlut_tex > 0)
|
if (g_tlut_tex > 0)
|
||||||
glDeleteTextures(1, &g_tlut_tex);
|
glDeleteTextures(1, &g_tlut_tex);
|
||||||
glDetachShader(g_draw_shadow_map_program, g_shadow_map_vertex_shader_object);
|
glDetachShader(g_draw_shadow_map_program, g_shadow_map_vertex_shader_object);
|
||||||
|
@ -561,18 +567,10 @@ void GLSLCombiner::UpdateFBInfo() {
|
||||||
glUniform1i(fbFixedAlpha_location, nFbFixedAlpha);
|
glUniform1i(fbFixedAlpha_location, nFbFixedAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unbindImageTextures() {
|
|
||||||
glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R16UI);
|
|
||||||
glBindImageTexture(ZlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R16UI);
|
|
||||||
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLSLCombiner::UpdateDepthInfo() {
|
void GLSLCombiner::UpdateDepthInfo() {
|
||||||
if (!OGL.bImageTexture)
|
if (!OGL.bImageTexture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unbindImageTextures();
|
|
||||||
|
|
||||||
if (frameBuffer.top == NULL || frameBuffer.top->pDepthBuffer == NULL)
|
if (frameBuffer.top == NULL || frameBuffer.top->pDepthBuffer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -594,8 +592,6 @@ void GLSLCombiner::UpdateDepthInfo() {
|
||||||
glUniform1f(depth_trans_location, gSP.viewport.vtrans[2]*32768);
|
glUniform1f(depth_trans_location, gSP.viewport.vtrans[2]*32768);
|
||||||
|
|
||||||
GLuint texture = frameBuffer.top->pDepthBuffer->depth_texture->glName;
|
GLuint texture = frameBuffer.top->pDepthBuffer->depth_texture->glName;
|
||||||
glBindImageTexture(ZlutImageUnit, g_zlut_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
|
|
||||||
glBindImageTexture(depthImageUnit, texture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLSLCombiner::UpdateAlphaTestInfo() {
|
void GLSLCombiner::UpdateAlphaTestInfo() {
|
||||||
|
@ -631,7 +627,7 @@ void GLSL_RenderDepth() {
|
||||||
#else
|
#else
|
||||||
if (frameBuffer.top == NULL || frameBuffer.top->pDepthBuffer == NULL)
|
if (frameBuffer.top == NULL || frameBuffer.top->pDepthBuffer == NULL)
|
||||||
return;
|
return;
|
||||||
unbindImageTextures();
|
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||||
glPushAttrib( GL_ENABLE_BIT | GL_VIEWPORT_BIT );
|
glPushAttrib( GL_ENABLE_BIT | GL_VIEWPORT_BIT );
|
||||||
|
|
||||||
glActiveTexture( GL_TEXTURE0 );
|
glActiveTexture( GL_TEXTURE0 );
|
||||||
|
@ -683,6 +679,8 @@ void GLSL_RenderDepth() {
|
||||||
OGL_SwapBuffers();
|
OGL_SwapBuffers();
|
||||||
#endif
|
#endif
|
||||||
ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer.top->fbo);
|
||||||
|
glBindImageTexture(depthImageUnit, frameBuffer.top->pDepthBuffer->depth_texture->glName, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
|
||||||
|
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
@ -697,23 +695,20 @@ void GLS_SetShadowMapCombiner() {
|
||||||
if (!OGL.bImageTexture)
|
if (!OGL.bImageTexture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unbindImageTextures();
|
|
||||||
|
|
||||||
if (g_paletteCRC256 != gDP.paletteCRC256) {
|
if (g_paletteCRC256 != gDP.paletteCRC256) {
|
||||||
g_paletteCRC256 = gDP.paletteCRC256;
|
g_paletteCRC256 = gDP.paletteCRC256;
|
||||||
u16 palette[256];
|
u16 palette[256];
|
||||||
u16 *src = (u16*)&TMEM[256];
|
u16 *src = (u16*)&TMEM[256];
|
||||||
for (int i = 0; i < 256; ++i)
|
for (int i = 0; i < 256; ++i)
|
||||||
palette[i] = swapword(src[i*4]);
|
palette[i] = swapword(src[i*4]);
|
||||||
|
glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
|
||||||
glBindTexture(GL_TEXTURE_1D, g_tlut_tex);
|
glBindTexture(GL_TEXTURE_1D, g_tlut_tex);
|
||||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RED, GL_UNSIGNED_SHORT, palette);
|
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RED, GL_UNSIGNED_SHORT, palette);
|
||||||
glBindTexture(GL_TEXTURE_1D, 0);
|
glBindTexture(GL_TEXTURE_1D, 0);
|
||||||
|
glBindImageTexture(TlutImageUnit, g_tlut_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
|
||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram(g_draw_shadow_map_program);
|
glUseProgram(g_draw_shadow_map_program);
|
||||||
|
|
||||||
glBindImageTexture(TlutImageUnit, g_tlut_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
|
|
||||||
GLuint texture = frameBuffer.top->pDepthBuffer->depth_texture->glName;
|
|
||||||
glBindImageTexture(depthImageUnit, texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F);
|
|
||||||
gDP.changed |= CHANGED_COMBINE;
|
gDP.changed |= CHANGED_COMBINE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -803,6 +803,8 @@ void OGL_AddTriangle( SPVertex *vertices, int v0, int v1, int v2 )
|
||||||
|
|
||||||
void OGL_DrawTriangles()
|
void OGL_DrawTriangles()
|
||||||
{
|
{
|
||||||
|
if (OGL.bImageTexture)
|
||||||
|
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||||
glDrawArrays( GL_TRIANGLES, 0, OGL.numVertices );
|
glDrawArrays( GL_TRIANGLES, 0, OGL.numVertices );
|
||||||
OGL.numTriangles = OGL.numVertices = 0;
|
OGL.numTriangles = OGL.numVertices = 0;
|
||||||
}
|
}
|
||||||
|
|
2
RSP.cpp
2
RSP.cpp
|
@ -211,8 +211,6 @@ void RSP_ProcessDList()
|
||||||
GBI.cmd[RSP.cmd]( w0, w1 );
|
GBI.cmd[RSP.cmd]( w0, w1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void unbindImageTextures();
|
|
||||||
unbindImageTextures();
|
|
||||||
if (g_bCopyToRDRAM)
|
if (g_bCopyToRDRAM)
|
||||||
FrameBuffer_CopyToRDRAM( gDP.colorImage.address, false );
|
FrameBuffer_CopyToRDRAM( gDP.colorImage.address, false );
|
||||||
if (g_bCopyDepthToRDRAM)
|
if (g_bCopyDepthToRDRAM)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user