1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

BindImageTexture fixes

This commit is contained in:
Sergey Lipskiy 2013-12-16 00:20:12 +07:00
parent b0f17ef953
commit cc3446c4d6
5 changed files with 17 additions and 18 deletions

View File

@ -220,6 +220,8 @@ DepthBuffer *DepthBuffer_FindBuffer( u32 address )
}
*/
void DepthBuffer_ClearBuffer() {
if (!OGL.bImageTexture)
return;
DepthBuffer *current = depthBuffer.top;
if (current == NULL || current->fbo == 0)
return;
@ -227,5 +229,6 @@ void DepthBuffer_ClearBuffer() {
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
ogl_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current->fbo);
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);
}

View File

@ -387,6 +387,7 @@ void FrameBuffer_AttachDepthBuffer()
ogl_glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer.top->renderbuf);
GLuint attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT };
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());
} else if (frameBuffer.top != NULL) {
frameBuffer.top->pDepthBuffer = 0;

View File

@ -101,11 +101,15 @@ void InitZlutTexture()
512, 512, 0, GL_RED, GL_UNSIGNED_SHORT,
zLUT);
delete[] zLUT;
glBindImageTexture(ZlutImageUnit, g_zlut_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
}
static
void DestroyZlutTexture()
{
if (!OGL.bImageTexture)
return;
glBindImageTexture(ZlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
if (g_zlut_tex > 0)
glDeleteTextures(1, &g_zlut_tex);
}
@ -147,6 +151,8 @@ void DestroyShadowMapShader()
if (!OGL.bImageTexture)
return;
glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
if (g_tlut_tex > 0)
glDeleteTextures(1, &g_tlut_tex);
glDetachShader(g_draw_shadow_map_program, g_shadow_map_vertex_shader_object);
@ -561,18 +567,10 @@ void GLSLCombiner::UpdateFBInfo() {
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() {
if (!OGL.bImageTexture)
return;
unbindImageTextures();
if (frameBuffer.top == NULL || frameBuffer.top->pDepthBuffer == NULL)
return;
@ -594,8 +592,6 @@ void GLSLCombiner::UpdateDepthInfo() {
glUniform1f(depth_trans_location, gSP.viewport.vtrans[2]*32768);
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() {
@ -631,7 +627,7 @@ void GLSL_RenderDepth() {
#else
if (frameBuffer.top == NULL || frameBuffer.top->pDepthBuffer == NULL)
return;
unbindImageTextures();
glBindImageTexture(depthImageUnit, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
glPushAttrib( GL_ENABLE_BIT | GL_VIEWPORT_BIT );
glActiveTexture( GL_TEXTURE0 );
@ -683,6 +679,8 @@ void GLSL_RenderDepth() {
OGL_SwapBuffers();
#endif
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();
glPopAttrib();
@ -697,23 +695,20 @@ void GLS_SetShadowMapCombiner() {
if (!OGL.bImageTexture)
return;
unbindImageTextures();
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]);
glBindImageTexture(TlutImageUnit, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
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);
glBindImageTexture(TlutImageUnit, g_tlut_tex, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R16UI);
}
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;
}

View File

@ -803,6 +803,8 @@ void OGL_AddTriangle( SPVertex *vertices, int v0, int v1, int v2 )
void OGL_DrawTriangles()
{
if (OGL.bImageTexture)
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
glDrawArrays( GL_TRIANGLES, 0, OGL.numVertices );
OGL.numTriangles = OGL.numVertices = 0;
}

View File

@ -211,8 +211,6 @@ void RSP_ProcessDList()
GBI.cmd[RSP.cmd]( w0, w1 );
}
void unbindImageTextures();
unbindImageTextures();
if (g_bCopyToRDRAM)
FrameBuffer_CopyToRDRAM( gDP.colorImage.address, false );
if (g_bCopyDepthToRDRAM)