OpenGL Renderer: Do some minor tune-ups.
- Remove some methods in OpenGLRenderer_2_0 and OpenGLRenderer_2_1 that have negligible contribution to either performance or code simplicity. - OpenGLRenderer_1_2, OpenGLRenderer_2_0, and OpenGLRenderer_2_1 are now instantiated with their specific variant IDs. - Calls to malloc_alignedCacheLine() have been replaced with the more appropriate malloc_alignedPage(). - Do some misc. code cleanup.
This commit is contained in:
parent
c75c1ce2c3
commit
ea648f7110
|
@ -1290,7 +1290,7 @@ OpenGLRenderer::OpenGLRenderer()
|
||||||
memset(ref, 0, sizeof(OGLRenderRef));
|
memset(ref, 0, sizeof(OGLRenderRef));
|
||||||
|
|
||||||
_mappedFramebuffer = NULL;
|
_mappedFramebuffer = NULL;
|
||||||
_workingTextureUnpackBuffer = (Color4u8 *)malloc_alignedCacheLine(1024 * 1024 * sizeof(Color4u8));
|
_workingTextureUnpackBuffer = (Color4u8 *)malloc_alignedPage(1024 * 1024 * sizeof(Color4u8));
|
||||||
_pixelReadNeedsFinish = false;
|
_pixelReadNeedsFinish = false;
|
||||||
_needsZeroDstAlphaPass = true;
|
_needsZeroDstAlphaPass = true;
|
||||||
_currentPolyIndex = 0;
|
_currentPolyIndex = 0;
|
||||||
|
@ -2292,6 +2292,8 @@ Render3DError OpenGLRenderer::ApplyRenderingSettings(const GFX3D_State &renderSt
|
||||||
|
|
||||||
OpenGLRenderer_1_2::OpenGLRenderer_1_2()
|
OpenGLRenderer_1_2::OpenGLRenderer_1_2()
|
||||||
{
|
{
|
||||||
|
_variantID = OpenGLVariantID_Legacy_1_2;
|
||||||
|
|
||||||
_geometryDrawBuffersEnum = GeometryDrawBuffersEnumStandard;
|
_geometryDrawBuffersEnum = GeometryDrawBuffersEnumStandard;
|
||||||
_geometryAttachmentWorkingBuffer = GeometryAttachmentWorkingBufferStandard;
|
_geometryAttachmentWorkingBuffer = GeometryAttachmentWorkingBufferStandard;
|
||||||
_geometryAttachmentPolyID = GeometryAttachmentPolyIDStandard;
|
_geometryAttachmentPolyID = GeometryAttachmentPolyIDStandard;
|
||||||
|
@ -5394,7 +5396,7 @@ Render3DError OpenGLRenderer_1_2::SetFramebufferSize(size_t w, size_t h)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Color4u8 *oldFramebufferColor = this->_framebufferColor;
|
Color4u8 *oldFramebufferColor = this->_framebufferColor;
|
||||||
Color4u8 *newFramebufferColor = (Color4u8 *)malloc_alignedCacheLine(newFramebufferColorSizeBytes);
|
Color4u8 *newFramebufferColor = (Color4u8 *)malloc_alignedPage(newFramebufferColorSizeBytes);
|
||||||
this->_framebufferColor = newFramebufferColor;
|
this->_framebufferColor = newFramebufferColor;
|
||||||
free_aligned(oldFramebufferColor);
|
free_aligned(oldFramebufferColor);
|
||||||
}
|
}
|
||||||
|
@ -5442,6 +5444,11 @@ Render3DError OpenGLRenderer_1_2::SetFramebufferSize(size_t w, size_t h)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenGLRenderer_2_0::OpenGLRenderer_2_0()
|
||||||
|
{
|
||||||
|
_variantID = OpenGLVariantID_Legacy_2_0;
|
||||||
|
}
|
||||||
|
|
||||||
Render3DError OpenGLRenderer_2_0::InitFinalRenderStates(const std::set<std::string> *oglExtensionSet)
|
Render3DError OpenGLRenderer_2_0::InitFinalRenderStates(const std::set<std::string> *oglExtensionSet)
|
||||||
{
|
{
|
||||||
OGLRenderRef &OGLRef = *this->ref;
|
OGLRenderRef &OGLRef = *this->ref;
|
||||||
|
@ -5674,86 +5681,9 @@ Render3DError OpenGLRenderer_2_0::BeginRender(const GFX3D_State &renderState, co
|
||||||
return OGLERROR_NOERR;
|
return OGLERROR_NOERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, size_t polyRenderIndex)
|
OpenGLRenderer_2_1::OpenGLRenderer_2_1()
|
||||||
{
|
{
|
||||||
OpenGLTexture *theTexture = (OpenGLTexture *)this->_textureList[polyRenderIndex];
|
_variantID = OpenGLVariantID_Legacy_2_1;
|
||||||
const NDSTextureFormat packFormat = theTexture->GetPackFormat();
|
|
||||||
const OGLRenderRef &OGLRef = *this->ref;
|
|
||||||
|
|
||||||
glUniform2f(OGLRef.uniformPolyTexScale[this->_geometryProgramFlags.value], theTexture->GetInvWidth(), theTexture->GetInvHeight());
|
|
||||||
|
|
||||||
// Check if we need to use textures
|
|
||||||
if (!theTexture->IsSamplingEnabled())
|
|
||||||
{
|
|
||||||
glUniform1i(OGLRef.uniformPolyEnableTexture[this->_geometryProgramFlags.value], GL_FALSE);
|
|
||||||
glUniform1i(OGLRef.uniformTexSingleBitAlpha[this->_geometryProgramFlags.value], GL_FALSE);
|
|
||||||
return OGLERROR_NOERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
glUniform1i(OGLRef.uniformPolyEnableTexture[this->_geometryProgramFlags.value], GL_TRUE);
|
|
||||||
glUniform1i(OGLRef.uniformTexSingleBitAlpha[this->_geometryProgramFlags.value], (packFormat != TEXMODE_A3I5 && packFormat != TEXMODE_A5I3) ? GL_TRUE : GL_FALSE);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, theTexture->GetID());
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, ((thePoly.texParam.RepeatS_Enable) ? ((thePoly.texParam.MirroredRepeatS_Enable) ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, ((thePoly.texParam.RepeatT_Enable) ? ((thePoly.texParam.MirroredRepeatT_Enable) ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));
|
|
||||||
|
|
||||||
if (this->_enableTextureSmoothing)
|
|
||||||
{
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (this->_textureScalingFactor > 1) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->_deviceInfo.maxAnisotropy);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
theTexture->ResetCacheAge();
|
|
||||||
theTexture->IncreaseCacheUsageCount(1);
|
|
||||||
|
|
||||||
return OGLERROR_NOERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
Render3DError OpenGLRenderer_2_1::RenderFinish()
|
|
||||||
{
|
|
||||||
if (!this->_renderNeedsFinish)
|
|
||||||
{
|
|
||||||
return OGLERROR_NOERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->_pixelReadNeedsFinish)
|
|
||||||
{
|
|
||||||
this->_pixelReadNeedsFinish = false;
|
|
||||||
|
|
||||||
if(!BEGINGL())
|
|
||||||
{
|
|
||||||
return OGLERROR_BEGINGL_FAILED;
|
|
||||||
}
|
|
||||||
this->_mappedFramebuffer = (Color4u8 *__restrict)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
|
||||||
ENDGL();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->_renderNeedsFlushMain = true;
|
|
||||||
this->_renderNeedsFlush16 = true;
|
|
||||||
|
|
||||||
return OGLERROR_NOERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
Render3DError OpenGLRenderer_2_1::RenderFlush(bool willFlushBuffer32, bool willFlushBuffer16)
|
|
||||||
{
|
|
||||||
if (!this->_isPoweredOn)
|
|
||||||
{
|
|
||||||
return RENDER3DERROR_NOERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color4u8 *framebufferMain = (willFlushBuffer32) ? GPU->GetEngineMain()->Get3DFramebufferMain() : NULL;
|
|
||||||
u16 *framebuffer16 = (willFlushBuffer16) ? GPU->GetEngineMain()->Get3DFramebuffer16() : NULL;
|
|
||||||
|
|
||||||
this->FlushFramebuffer(this->_mappedFramebuffer, framebufferMain, framebuffer16);
|
|
||||||
|
|
||||||
return RENDER3DERROR_NOERR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template size_t OpenGLRenderer::DrawPolygonsForIndexRange<OGLPolyDrawMode_DrawOpaquePolys>(const POLY *rawPolyList, const CPoly *clippedPolyList, const size_t clippedPolyCount, size_t firstIndex, size_t lastIndex, size_t &indexOffset, POLYGON_ATTR &lastPolyAttr);
|
template size_t OpenGLRenderer::DrawPolygonsForIndexRange<OGLPolyDrawMode_DrawOpaquePolys>(const POLY *rawPolyList, const CPoly *clippedPolyList, const size_t clippedPolyCount, size_t firstIndex, size_t lastIndex, size_t &indexOffset, POLYGON_ATTR &lastPolyAttr);
|
||||||
|
|
|
@ -1077,6 +1077,9 @@ public:
|
||||||
|
|
||||||
class OpenGLRenderer_2_0 : public OpenGLRenderer_1_2
|
class OpenGLRenderer_2_0 : public OpenGLRenderer_1_2
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
OpenGLRenderer_2_0();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual Render3DError InitFinalRenderStates(const std::set<std::string> *oglExtensionSet);
|
virtual Render3DError InitFinalRenderStates(const std::set<std::string> *oglExtensionSet);
|
||||||
|
|
||||||
|
@ -1084,15 +1087,12 @@ protected:
|
||||||
virtual Render3DError DisableVertexAttributes();
|
virtual Render3DError DisableVertexAttributes();
|
||||||
|
|
||||||
virtual Render3DError BeginRender(const GFX3D_State &renderState, const GFX3D_GeometryList &renderGList);
|
virtual Render3DError BeginRender(const GFX3D_State &renderState, const GFX3D_GeometryList &renderGList);
|
||||||
|
|
||||||
virtual Render3DError SetupTexture(const POLY &thePoly, size_t polyRenderIndex);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpenGLRenderer_2_1 : public OpenGLRenderer_2_0
|
class OpenGLRenderer_2_1 : public OpenGLRenderer_2_0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual Render3DError RenderFinish();
|
OpenGLRenderer_2_1();
|
||||||
virtual Render3DError RenderFlush(bool willFlushBuffer32, bool willFlushBuffer16);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OGLRENDER_H
|
#endif // OGLRENDER_H
|
||||||
|
|
Loading…
Reference in New Issue