OpenGL Renderer:
- Remove even more extraneous binds. - Do some misc. optimizations.
This commit is contained in:
parent
e527ed1e37
commit
c5350f6247
|
@ -977,8 +977,6 @@ OpenGLRenderer_1_2::~OpenGLRenderer_1_2()
|
|||
//kill the tex cache to free all the texture ids
|
||||
TexCache_Reset();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
while(!ref->freeTextureIDs.empty())
|
||||
{
|
||||
GLuint temp = ref->freeTextureIDs.front();
|
||||
|
@ -1393,13 +1391,7 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs()
|
|||
glGenTextures(1, &OGLRef.texGDepthStencilID);
|
||||
glGenTextures(1, &OGLRef.texPostprocessFogID);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGColorID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GColor);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthStencilID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -1408,6 +1400,14 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGColorID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GDepth);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -1415,6 +1415,7 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GPolyID);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGPolyID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -1422,6 +1423,7 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogAttr);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGFogAttrID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -1429,6 +1431,7 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texPostprocessFogID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -1722,12 +1725,15 @@ Render3DError OpenGLRenderer_1_2::CreateToonTable()
|
|||
// The toon table is a special 1D texture where each pixel corresponds
|
||||
// to a specific color in the toon table.
|
||||
glGenTextures(1, &OGLRef.texToonTableID);
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + OGLTextureUnitID_ToonTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texToonTableID);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 32, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, tempToonTable);
|
||||
glBindTexture(GL_TEXTURE_1D, 0);
|
||||
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
@ -1763,15 +1769,12 @@ Render3DError OpenGLRenderer_1_2::UploadClearImage(const u16 *__restrict colorBu
|
|||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, colorBuffer);
|
||||
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + OGLTextureUnitID_GDepth);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthID);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, depth);
|
||||
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + OGLTextureUnitID_GPolyID);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGPolyID);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, polyID);
|
||||
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + OGLTextureUnitID_FogAttr);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGFogAttrID);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, fogAttributes);
|
||||
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
|
@ -1856,6 +1859,8 @@ Render3DError OpenGLRenderer_1_2::EnableVertexAttributes()
|
|||
}
|
||||
}
|
||||
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
|
@ -2122,7 +2127,6 @@ Render3DError OpenGLRenderer_1_2::RenderGeometry(const GFX3D_State &renderState,
|
|||
for (size_t i = 0; i < polyCount; i++)
|
||||
{
|
||||
const POLY &thePoly = polyList->list[indexList->list[i]];
|
||||
this->SetPolygonIndex(i);
|
||||
|
||||
// Set up the polygon if it changed
|
||||
if (lastPolyAttr != thePoly.polyAttr)
|
||||
|
@ -2178,6 +2182,7 @@ Render3DError OpenGLRenderer_1_2::RenderGeometry(const GFX3D_State &renderState,
|
|||
}
|
||||
|
||||
// Render the polygons
|
||||
this->SetPolygonIndex(i);
|
||||
glDrawElements(polyPrimitive, vertIndexCount, GL_UNSIGNED_SHORT, indexBufferPtr);
|
||||
indexBufferPtr += vertIndexCount;
|
||||
vertIndexCount = 0;
|
||||
|
@ -2204,9 +2209,7 @@ Render3DError OpenGLRenderer_1_2::EndRender(const u64 frameCount)
|
|||
Render3DError OpenGLRenderer_1_2::UpdateToonTable(const u16 *toonTableBuffer)
|
||||
{
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + OGLTextureUnitID_ToonTable);
|
||||
glBindTexture(GL_TEXTURE_1D, this->ref->texToonTableID);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 32, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, toonTableBuffer);
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
@ -2347,7 +2350,6 @@ Render3DError OpenGLRenderer_1_2::SetupPolygon(const POLY &thePoly)
|
|||
// can change this too.
|
||||
if(attr.polygonMode == 3)
|
||||
{
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
if(attr.polygonID == 0)
|
||||
{
|
||||
//when the polyID is zero, we are writing the shadow mask.
|
||||
|
@ -2371,7 +2373,6 @@ Render3DError OpenGLRenderer_1_2::SetupPolygon(const POLY &thePoly)
|
|||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
if(attr.isTranslucent)
|
||||
{
|
||||
glStencilFunc(GL_NOTEQUAL, attr.polygonID, 255);
|
||||
|
@ -2583,12 +2584,32 @@ Render3DError OpenGLRenderer_1_2::RenderFinish()
|
|||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
Render3DError OpenGLRenderer_1_3::CreateToonTable()
|
||||
{
|
||||
OGLRenderRef &OGLRef = *this->ref;
|
||||
u16 tempToonTable[32];
|
||||
memset(tempToonTable, 0, sizeof(tempToonTable));
|
||||
|
||||
// The toon table is a special 1D texture where each pixel corresponds
|
||||
// to a specific color in the toon table.
|
||||
glGenTextures(1, &OGLRef.texToonTableID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_ToonTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texToonTableID);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 32, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, tempToonTable);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
Render3DError OpenGLRenderer_1_3::UpdateToonTable(const u16 *toonTableBuffer)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_ToonTable);
|
||||
glBindTexture(GL_TEXTURE_1D, this->ref->texToonTableID);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 32, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, toonTableBuffer);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
@ -2617,19 +2638,14 @@ Render3DError OpenGLRenderer_1_3::UploadClearImage(const u16 *__restrict colorBu
|
|||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, colorBuffer);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GDepth);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthID);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, depth);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GPolyID);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGPolyID);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, polyID);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogAttr);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGFogAttrID);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, fogAttributes);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
|
@ -2819,6 +2835,8 @@ Render3DError OpenGLRenderer_1_5::EnableVertexAttributes()
|
|||
}
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
|
@ -3351,6 +3369,8 @@ Render3DError OpenGLRenderer_2_0::EnableVertexAttributes()
|
|||
glVertexAttribPointer(OGLVertexAttributeID_Color, 3, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(VERT), OGLRef.vtxPtrColor);
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
|
@ -3489,11 +3509,6 @@ Render3DError OpenGLRenderer_2_0::RenderEdgeMarking(const u16 *colorTable, const
|
|||
glVertexAttribPointer(OGLVertexAttributeID_TexCoord0, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *)(sizeof(GLfloat) * 8));
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GDepth);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GPolyID);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGPolyID);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
|
||||
|
||||
if (this->isVAOSupported)
|
||||
|
@ -3561,13 +3576,6 @@ Render3DError OpenGLRenderer_2_0::RenderFog(const u8 *densityTable, const u32 co
|
|||
glVertexAttribPointer(OGLVertexAttributeID_TexCoord0, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *)(sizeof(GLfloat) * 8));
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GColor);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGColorID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GDepth);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogAttr);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGFogAttrID);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
|
||||
|
||||
if (this->isVAOSupported)
|
||||
|
@ -3613,7 +3621,6 @@ Render3DError OpenGLRenderer_2_0::SetupPolygon(const POLY &thePoly)
|
|||
// can change this too.
|
||||
if(attr.polygonMode == 3)
|
||||
{
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
if(attr.polygonID == 0)
|
||||
{
|
||||
//when the polyID is zero, we are writing the shadow mask.
|
||||
|
@ -3637,7 +3644,6 @@ Render3DError OpenGLRenderer_2_0::SetupPolygon(const POLY &thePoly)
|
|||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
if(attr.isTranslucent)
|
||||
{
|
||||
glStencilFunc(GL_NOTEQUAL, attr.polygonID, 255);
|
||||
|
|
|
@ -680,6 +680,7 @@ public:
|
|||
class OpenGLRenderer_1_3 : public OpenGLRenderer_1_2
|
||||
{
|
||||
protected:
|
||||
virtual Render3DError CreateToonTable();
|
||||
virtual Render3DError UploadClearImage(const u16 *__restrict colorBuffer, const u32 *__restrict depthBuffer, const bool *__restrict fogBuffer, const u8 *__restrict polyIDBuffer);
|
||||
|
||||
public:
|
||||
|
|
|
@ -603,13 +603,7 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs()
|
|||
glGenTextures(1, &OGLRef.texGDepthStencilID);
|
||||
glGenTextures(1, &OGLRef.texPostprocessFogID);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGColorID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GColor);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthStencilID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -618,6 +612,14 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGColorID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GDepth);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -625,6 +627,7 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GPolyID);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGPolyID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -632,6 +635,7 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogAttr);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGFogAttrID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -639,6 +643,7 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GFX3D_FRAMEBUFFER_WIDTH, GFX3D_FRAMEBUFFER_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texPostprocessFogID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -993,6 +998,7 @@ void OpenGLRenderer_3_2::GetExtensionSet(std::set<std::string> *oglExtensionSet)
|
|||
Render3DError OpenGLRenderer_3_2::EnableVertexAttributes()
|
||||
{
|
||||
glBindVertexArray(this->ref->vaoGeometryStatesID);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
|
@ -1077,59 +1083,25 @@ Render3DError OpenGLRenderer_3_2::BeginRender(const GFX3D &engine)
|
|||
}
|
||||
|
||||
const GLfloat edgeColorAlpha = (engine.renderState.enableAntialiasing) ? (16.0f/31.0f) : 1.0f;
|
||||
state->edgeColor[0].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[0] ) & 0x001F];
|
||||
state->edgeColor[0].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[0] >> 5) & 0x001F];
|
||||
state->edgeColor[0].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[0] >> 10) & 0x001F];
|
||||
state->edgeColor[0].a = edgeColorAlpha;
|
||||
|
||||
state->edgeColor[1].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[1] ) & 0x001F];
|
||||
state->edgeColor[1].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[1] >> 5) & 0x001F];
|
||||
state->edgeColor[1].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[1] >> 10) & 0x001F];
|
||||
state->edgeColor[1].a = edgeColorAlpha;
|
||||
|
||||
state->edgeColor[2].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[2] ) & 0x001F];
|
||||
state->edgeColor[2].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[2] >> 5) & 0x001F];
|
||||
state->edgeColor[2].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[2] >> 10) & 0x001F];
|
||||
state->edgeColor[2].a = edgeColorAlpha;
|
||||
|
||||
state->edgeColor[3].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[3] ) & 0x001F];
|
||||
state->edgeColor[3].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[3] >> 5) & 0x001F];
|
||||
state->edgeColor[3].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[3] >> 10) & 0x001F];
|
||||
state->edgeColor[3].a = edgeColorAlpha;
|
||||
|
||||
state->edgeColor[4].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[4] ) & 0x001F];
|
||||
state->edgeColor[4].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[4] >> 5) & 0x001F];
|
||||
state->edgeColor[4].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[4] >> 10) & 0x001F];
|
||||
state->edgeColor[4].a = edgeColorAlpha;
|
||||
|
||||
state->edgeColor[5].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[5] ) & 0x001F];
|
||||
state->edgeColor[5].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[5] >> 5) & 0x001F];
|
||||
state->edgeColor[5].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[5] >> 10) & 0x001F];
|
||||
state->edgeColor[5].a = edgeColorAlpha;
|
||||
|
||||
state->edgeColor[6].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[6] ) & 0x001F];
|
||||
state->edgeColor[6].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[6] >> 5) & 0x001F];
|
||||
state->edgeColor[6].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[6] >> 10) & 0x001F];
|
||||
state->edgeColor[6].a = edgeColorAlpha;
|
||||
|
||||
state->edgeColor[7].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[7] ) & 0x001F];
|
||||
state->edgeColor[7].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[7] >> 5) & 0x001F];
|
||||
state->edgeColor[7].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[7] >> 10) & 0x001F];
|
||||
state->edgeColor[7].a = edgeColorAlpha;
|
||||
for (size_t i = 0; i < 8; i++)
|
||||
{
|
||||
state->edgeColor[i].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[i] ) & 0x001F];
|
||||
state->edgeColor[i].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[i] >> 5) & 0x001F];
|
||||
state->edgeColor[i].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[i] >> 10) & 0x001F];
|
||||
state->edgeColor[i].a = edgeColorAlpha;
|
||||
}
|
||||
|
||||
glUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
|
||||
// Do per-poly setup
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_PolyStates);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, OGLRef.texPolyStatesID);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, OGLRef.vboGeometryVtxID);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OGLRef.iboGeometryIndexID);
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, OGLRef.tboPolyStatesID);
|
||||
|
||||
size_t vertIndexCount = 0;
|
||||
GLushort *indexPtr = (GLushort *)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, engine.polylist->count * 6 * sizeof(GLushort), GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
OGLPolyStates *polyStates = (OGLPolyStates *)glMapBufferRange(GL_TEXTURE_BUFFER, 0, engine.polylist->count * sizeof(OGLPolyStates), GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
GLushort *indexPtr = (GLushort *)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, engine.polylist->count * 6 * sizeof(GLushort), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
OGLPolyStates *polyStates = (OGLPolyStates *)glMapBufferRange(GL_TEXTURE_BUFFER, 0, engine.polylist->count * sizeof(OGLPolyStates), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
|
||||
for (size_t i = 0; i < engine.polylist->count; i++)
|
||||
{
|
||||
|
@ -1173,10 +1145,14 @@ Render3DError OpenGLRenderer_3_2::BeginRender(const GFX3D &engine)
|
|||
|
||||
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
|
||||
glUnmapBuffer(GL_TEXTURE_BUFFER);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(VERT) * engine.vertlist->count, engine.vertlist);
|
||||
|
||||
const size_t vtxBufferSize = sizeof(VERT) * engine.vertlist->count;
|
||||
VERT *vtxPtr = (VERT *)glMapBufferRange(GL_ARRAY_BUFFER, 0, vtxBufferSize, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
|
||||
memcpy(vtxPtr, engine.vertlist, vtxBufferSize);
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
|
||||
glUseProgram(OGLRef.programGeometryID);
|
||||
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
|
@ -1198,11 +1174,6 @@ Render3DError OpenGLRenderer_3_2::RenderEdgeMarking(const u16 *colorTable, const
|
|||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OGLRef.iboPostprocessIndexID);
|
||||
glBindVertexArray(OGLRef.vaoPostprocessStatesID);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GDepth);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GPolyID);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGPolyID);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
@ -1227,13 +1198,6 @@ Render3DError OpenGLRenderer_3_2::RenderFog(const u8 *densityTable, const u32 co
|
|||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OGLRef.iboPostprocessIndexID);
|
||||
glBindVertexArray(OGLRef.vaoPostprocessStatesID);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GColor);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGColorID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_GDepth);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGDepthID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogAttr);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texGFogAttrID);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
@ -1337,7 +1301,6 @@ Render3DError OpenGLRenderer_3_2::SetupPolygon(const POLY &thePoly)
|
|||
// can change this too.
|
||||
if(attr.polygonMode == 3)
|
||||
{
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
if(attr.polygonID == 0)
|
||||
{
|
||||
//when the polyID is zero, we are writing the shadow mask.
|
||||
|
@ -1361,7 +1324,6 @@ Render3DError OpenGLRenderer_3_2::SetupPolygon(const POLY &thePoly)
|
|||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
if(attr.isTranslucent)
|
||||
{
|
||||
glStencilFunc(GL_NOTEQUAL, attr.polygonID, 255);
|
||||
|
|
Loading…
Reference in New Issue