OpenGL Renderer: Ensure that all color attachments are assigned sequentially without gaps, and ensure that fragment shaders write out a value to each assigned attachment in all cases. This is being done to try and satisfy extremely picky AMD drivers that can do crazy-go-nuts things when the color attachments are not meticulously managed this way.
This commit is contained in:
parent
e4ec1d634a
commit
3e73a550e3
|
@ -84,15 +84,48 @@ CACHE_ALIGN const GLfloat divide6bitBy63_LUT[64] = {0.0, 0.015873015
|
|||
const GLfloat PostprocessVtxBuffer[16] = {-1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f};
|
||||
|
||||
const GLenum GeometryDrawBuffersList[8][4] = {
|
||||
{ GL_COLOR_ATTACHMENT0_EXT, GL_NONE, GL_NONE, GL_NONE },
|
||||
{ GL_COLOR_ATTACHMENT0_EXT, GL_NONE, GL_NONE, GL_COLOR_ATTACHMENT2_EXT },
|
||||
{ GL_COLOR_ATTACHMENT0_EXT, GL_NONE, GL_COLOR_ATTACHMENT1_EXT, GL_NONE },
|
||||
{ GL_COLOR_ATTACHMENT0_EXT, GL_NONE, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT },
|
||||
{ GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, GL_NONE, GL_NONE },
|
||||
{ GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, GL_NONE, GL_COLOR_ATTACHMENT2_EXT },
|
||||
{ GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_NONE },
|
||||
{ GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT3_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT }
|
||||
const GLenum GeometryDrawBuffersEnum[8][4] = {
|
||||
{ GL_COLOROUT_ATTACHMENT_ID, GL_NONE, GL_NONE, GL_NONE },
|
||||
{ GL_COLOROUT_ATTACHMENT_ID, GL_FOGATTRIBUTES_ATTACHMENT_ID, GL_NONE, GL_NONE },
|
||||
{ GL_COLOROUT_ATTACHMENT_ID, GL_POLYID_ATTACHMENT_ID, GL_NONE, GL_NONE },
|
||||
{ GL_COLOROUT_ATTACHMENT_ID, GL_POLYID_ATTACHMENT_ID, GL_FOGATTRIBUTES_ATTACHMENT_ID, GL_NONE },
|
||||
{ GL_COLOROUT_ATTACHMENT_ID, GL_WORKING_ATTACHMENT_ID, GL_NONE, GL_NONE },
|
||||
{ GL_COLOROUT_ATTACHMENT_ID, GL_WORKING_ATTACHMENT_ID, GL_FOGATTRIBUTES_ATTACHMENT_ID, GL_NONE },
|
||||
{ GL_COLOROUT_ATTACHMENT_ID, GL_WORKING_ATTACHMENT_ID, GL_POLYID_ATTACHMENT_ID, GL_NONE },
|
||||
{ GL_COLOROUT_ATTACHMENT_ID, GL_WORKING_ATTACHMENT_ID, GL_POLYID_ATTACHMENT_ID, GL_FOGATTRIBUTES_ATTACHMENT_ID }
|
||||
};
|
||||
|
||||
const GLint GeometryAttachmentWorkingBuffer[8] = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
const GLint GeometryAttachmentPolyID[8] = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
2
|
||||
};
|
||||
|
||||
const GLint GeometryAttachmentFogAttributes[8] = {
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
3
|
||||
};
|
||||
|
||||
bool BEGINGL()
|
||||
|
@ -416,14 +449,14 @@ void main()\n\
|
|||
\n\
|
||||
gl_FragData[0] = newFragColor;\n\
|
||||
\n\
|
||||
#if USE_DEPTH_LEQUAL_POLYGON_FACING && DRAW_MODE_OPAQUE\n\
|
||||
gl_FragData[1] = vec4(float(!gl_FrontFacing), 0.0, 0.0, 1.0);\n\
|
||||
#if DRAW_MODE_OPAQUE\n\
|
||||
gl_FragData[ATTACHMENT_WORKING_BUFFER] = vec4(float(!gl_FrontFacing), 0.0, 0.0, 1.0);\n\
|
||||
#endif\n\
|
||||
#if ENABLE_EDGE_MARK\n\
|
||||
gl_FragData[2] = newPolyID;\n\
|
||||
gl_FragData[ATTACHMENT_POLY_ID] = newPolyID;\n\
|
||||
#endif\n\
|
||||
#if ENABLE_FOG\n\
|
||||
gl_FragData[3] = newFogAttributes;\n\
|
||||
gl_FragData[ATTACHMENT_FOG_ATTRIBUTES] = newFogAttributes;\n\
|
||||
#endif\n\
|
||||
#if USE_NDS_DEPTH_CALCULATION || ENABLE_FOG\n\
|
||||
// It is tempting to perform the NDS depth calculation in the vertex shader rather than in the fragment shader.\n\
|
||||
|
@ -2944,8 +2977,8 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs()
|
|||
glGenFramebuffersEXT(1, &OGLRef.fboRenderID);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboClearImageID);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, OGLRef.texCIColorID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, OGLRef.texCIFogAttrID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOROUT_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texCIColorID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_FOGATTRIBUTES_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texCIFogAttrID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, OGLRef.texCIDepthStencilID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, OGLRef.texCIDepthStencilID, 0);
|
||||
|
||||
|
@ -2958,10 +2991,10 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs()
|
|||
}
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboRenderID);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, OGLRef.texGColorID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, OGLRef.texGPolyID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_2D, OGLRef.texGFogAttrID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT3_EXT, GL_TEXTURE_2D, OGLRef.texFinalColorID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOROUT_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texGColorID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_POLYID_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texGPolyID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_FOGATTRIBUTES_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texGFogAttrID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_WORKING_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texFinalColorID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, OGLRef.texGDepthStencilID, 0);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, OGLRef.texGDepthStencilID, 0);
|
||||
|
||||
|
@ -2973,8 +3006,8 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs()
|
|||
return OGLERROR_FBO_CREATE_ERROR;
|
||||
}
|
||||
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
|
||||
OGLRef.selectedRenderingFBO = OGLRef.fboRenderID;
|
||||
INFO("OpenGL: Successfully created FBOs.\n");
|
||||
|
@ -3033,10 +3066,10 @@ Render3DError OpenGLRenderer_1_2::CreateMultisampledFBO(GLsizei numSamples)
|
|||
// Set up multisampled rendering FBO
|
||||
glGenFramebuffersEXT(1, &OGLRef.fboMSIntermediateRenderID);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboMSIntermediateRenderID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, OGLRef.rboMSGColorID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_RENDERBUFFER_EXT, OGLRef.rboMSGPolyID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_RENDERBUFFER_EXT, OGLRef.rboMSGFogAttrID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT3_EXT, GL_RENDERBUFFER_EXT, OGLRef.rboMSGWorkingID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOROUT_ATTACHMENT_ID, GL_RENDERBUFFER_EXT, OGLRef.rboMSGColorID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_POLYID_ATTACHMENT_ID, GL_RENDERBUFFER_EXT, OGLRef.rboMSGPolyID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_FOGATTRIBUTES_ATTACHMENT_ID, GL_RENDERBUFFER_EXT, OGLRef.rboMSGFogAttrID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_WORKING_ATTACHMENT_ID, GL_RENDERBUFFER_EXT, OGLRef.rboMSGWorkingID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, OGLRef.rboMSGDepthStencilID);
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, OGLRef.rboMSGDepthStencilID);
|
||||
|
||||
|
@ -3048,8 +3081,8 @@ Render3DError OpenGLRenderer_1_2::CreateMultisampledFBO(GLsizei numSamples)
|
|||
return OGLERROR_FBO_CREATE_ERROR;
|
||||
}
|
||||
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboRenderID);
|
||||
INFO("OpenGL: Successfully created multisampled FBO.\n");
|
||||
|
@ -3147,6 +3180,10 @@ Render3DError OpenGLRenderer_1_2::CreateGeometryPrograms()
|
|||
shaderFlags << "#define ENABLE_EDGE_MARK " << ((programFlags.EnableEdgeMark) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define DRAW_MODE_OPAQUE " << ((programFlags.OpaqueDrawMode) ? 1 : 0) << "\n";
|
||||
shaderFlags << "\n";
|
||||
shaderFlags << "#define ATTACHMENT_WORKING_BUFFER " << GeometryAttachmentWorkingBuffer[programFlags.DrawBuffersMode] << "\n";
|
||||
shaderFlags << "#define ATTACHMENT_POLY_ID " << GeometryAttachmentPolyID[programFlags.DrawBuffersMode] << "\n";
|
||||
shaderFlags << "#define ATTACHMENT_FOG_ATTRIBUTES " << GeometryAttachmentFogAttributes[programFlags.DrawBuffersMode] << "\n";
|
||||
shaderFlags << "\n";
|
||||
|
||||
std::string fragShaderCode = fragShaderHeader.str() + shaderFlags.str() + std::string(GeometryFragShader_100);
|
||||
|
||||
|
@ -3998,11 +4035,11 @@ void OpenGLRenderer_1_2::_SetupGeometryShaders(const OGLGeometryFlags flags)
|
|||
|
||||
if (this->isFBOSupported)
|
||||
{
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[flags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[flags.DrawBuffersMode]);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4097,9 +4134,9 @@ Render3DError OpenGLRenderer_1_2::ZeroDstAlphaPass(const POLYLIST *polyList, con
|
|||
// Just downsample the color buffer now so that we have some texture data to sample from in the non-multisample shader.
|
||||
// This is not perfectly pixel accurate, but it's better than nothing.
|
||||
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, OGLRef.fboRenderID);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.selectedRenderingFBO);
|
||||
}
|
||||
|
||||
|
@ -4147,7 +4184,7 @@ Render3DError OpenGLRenderer_1_2::ZeroDstAlphaPass(const POLYLIST *polyList, con
|
|||
this->_geometryProgramFlags.EnableEdgeMark = 0;
|
||||
this->_geometryProgramFlags.EnableFog = 0;
|
||||
this->_SetupGeometryShaders(this->_geometryProgramFlags);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, OGLRef.vboGeometryVtxID);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OGLRef.iboGeometryIndexID);
|
||||
|
@ -4192,13 +4229,13 @@ void OpenGLRenderer_1_2::_ResolveWorkingBackFacing()
|
|||
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, OGLRef.fboMSIntermediateRenderID);
|
||||
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, OGLRef.fboRenderID);
|
||||
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glReadBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
// Reset framebuffer targets
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboMSIntermediateRenderID);
|
||||
}
|
||||
|
||||
|
@ -4218,28 +4255,26 @@ void OpenGLRenderer_1_2::_ResolveGeometry()
|
|||
{
|
||||
if (this->_enableEdgeMark)
|
||||
{
|
||||
// Blit the polygon ID buffer
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
|
||||
glReadBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
{
|
||||
// Blit the fog buffer
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT2_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT2_EXT);
|
||||
glReadBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
// Blit the color and depth buffers
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
// Reset framebuffer targets
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboRenderID);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4247,8 +4282,8 @@ void OpenGLRenderer_1_2::_ResolveGeometry()
|
|||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboRenderID);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4266,16 +4301,16 @@ Render3DError OpenGLRenderer_1_2::ReadBackPixels()
|
|||
{
|
||||
const GLuint convertProgramID = (this->_outputFormat == NDSColorFormat_BGR666_Rev) ? OGLRef.programFramebufferRGBA6665OutputID[1] : OGLRef.programFramebufferRGBA8888OutputID[1];
|
||||
glUseProgram(convertProgramID);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
this->_lastTextureDrawTarget = OGLTextureUnitID_FinalColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
const GLuint convertProgramID = (this->_outputFormat == NDSColorFormat_BGR666_Rev) ? OGLRef.programFramebufferRGBA6665OutputID[0] : OGLRef.programFramebufferRGBA8888OutputID[0];
|
||||
glUseProgram(convertProgramID);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
this->_lastTextureDrawTarget = OGLTextureUnitID_GColor;
|
||||
}
|
||||
}
|
||||
|
@ -4327,17 +4362,17 @@ Render3DError OpenGLRenderer_1_2::ReadBackPixels()
|
|||
// Further colorspace conversion will need to be done in a later step.
|
||||
if (this->_lastTextureDrawTarget == OGLTextureUnitID_GColor)
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, this->_framebufferHeight, this->_framebufferWidth, 0, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glReadBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, this->_framebufferHeight, this->_framebufferWidth, 0, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4517,10 +4552,10 @@ Render3DError OpenGLRenderer_1_2::BeginRender(const GFX3D &engine)
|
|||
|
||||
if (!this->isFBOSupported || !this->isShaderSupported)
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
@ -4693,7 +4728,7 @@ Render3DError OpenGLRenderer_1_2::RenderEdgeMarking(const u16 *colorTable, const
|
|||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
// Pass 2: Unblended edge mark colors to zero-alpha pixels
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glUseProgram(OGLRef.programEdgeMarkID);
|
||||
glUniform1i(OGLRef.uniformStateClearPolyID, this->_clearAttributes.opaquePolyID);
|
||||
glUniform1f(OGLRef.uniformStateClearDepth, (GLfloat)this->_clearAttributes.depth / (GLfloat)0x00FFFFFF);
|
||||
|
@ -4714,7 +4749,7 @@ Render3DError OpenGLRenderer_1_2::RenderEdgeMarking(const u16 *colorTable, const
|
|||
glUniform1i(OGLRef.uniformStateClearPolyID, this->_clearAttributes.opaquePolyID);
|
||||
glUniform1f(OGLRef.uniformStateClearDepth, (GLfloat)this->_clearAttributes.depth / (GLfloat)0x00FFFFFF);
|
||||
glUniform4fv(OGLRef.uniformStateEdgeColor, 8, oglColor);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
@ -4771,7 +4806,7 @@ Render3DError OpenGLRenderer_1_2::RenderFog(const u8 *densityTable, const u32 co
|
|||
divide5bitBy31_LUT[(color >> 10) & 0x0000001F],
|
||||
divide5bitBy31_LUT[(color >> 16) & 0x0000001F]};
|
||||
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glUseProgram(shaderID.program);
|
||||
glUniform1i(OGLRef.uniformStateEnableFogAlphaOnly, (alphaOnly) ? GL_TRUE : GL_FALSE);
|
||||
glUniform4f(OGLRef.uniformStateFogColor, oglColor[0], oglColor[1], oglColor[2], oglColor[3]);
|
||||
|
@ -4864,41 +4899,39 @@ Render3DError OpenGLRenderer_1_2::ClearUsingImage(const u16 *__restrict colorBuf
|
|||
{
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
{
|
||||
// Clear the polygon ID buffer
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
|
||||
glDrawBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glClearColor((GLfloat)opaquePolyID/63.0f, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
{
|
||||
// Blit the fog buffer
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT2_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT2_EXT);
|
||||
glReadBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, GPU_FRAMEBUFFER_NATIVE_HEIGHT, GPU_FRAMEBUFFER_NATIVE_WIDTH, 0, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
// Blit the color buffer. Do this last so that color attachment 0 is set to the read FBO.
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, GPU_FRAMEBUFFER_NATIVE_HEIGHT, GPU_FRAMEBUFFER_NATIVE_WIDTH, 0, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboRenderID);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBlitFramebufferEXT(0, GPU_FRAMEBUFFER_NATIVE_HEIGHT, GPU_FRAMEBUFFER_NATIVE_WIDTH, 0, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboRenderID);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
|
||||
if (this->isMultisampledFBOSupported)
|
||||
|
@ -4916,34 +4949,32 @@ Render3DError OpenGLRenderer_1_2::ClearUsingImage(const u16 *__restrict colorBuf
|
|||
{
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
{
|
||||
// Clear the polygon ID buffer
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
|
||||
glDrawBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glClearColor((GLfloat)opaquePolyID/63.0f, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
{
|
||||
// Blit the fog buffer
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT2_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT2_EXT);
|
||||
glReadBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
// Blit the color and depth buffers. Do this last so that color attachment 0 is set to the read FBO.
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.selectedRenderingFBO);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4951,8 +4982,8 @@ Render3DError OpenGLRenderer_1_2::ClearUsingImage(const u16 *__restrict colorBuf
|
|||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.selectedRenderingFBO);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4972,7 +5003,7 @@ Render3DError OpenGLRenderer_1_2::ClearUsingValues(const FragmentColor &clearCol
|
|||
|
||||
if (this->isShaderSupported && this->isFBOSupported)
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); // texGColorID
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glClearColor(divide6bitBy63_LUT[clearColor6665.r], divide6bitBy63_LUT[clearColor6665.g], divide6bitBy63_LUT[clearColor6665.b], divide5bitBy31_LUT[clearColor6665.a]);
|
||||
glClearDepth((GLclampd)clearAttributes.depth / (GLclampd)0x00FFFFFF);
|
||||
glClearStencil(clearAttributes.opaquePolyID);
|
||||
|
@ -4980,34 +5011,34 @@ Render3DError OpenGLRenderer_1_2::ClearUsingValues(const FragmentColor &clearCol
|
|||
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3_EXT);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); // texGPolyID
|
||||
glDrawBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glClearColor((GLfloat)clearAttributes.opaquePolyID/63.0f, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT2_EXT); // texGFogAttrID
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glClearColor(clearAttributes.isFogged, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
this->_needsZeroDstAlphaPass = (clearColor6665.a == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->isFBOSupported)
|
||||
{
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
|
||||
glClearColor(divide6bitBy63_LUT[clearColor6665.r], divide6bitBy63_LUT[clearColor6665.g], divide6bitBy63_LUT[clearColor6665.b], divide5bitBy31_LUT[clearColor6665.a]);
|
||||
|
@ -5424,8 +5455,8 @@ Render3DError OpenGLRenderer_1_2::RenderPowerOff()
|
|||
if (this->isFBOSupported)
|
||||
{
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, OGLRef.fboRenderID);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
@ -5765,7 +5796,7 @@ Render3DError OpenGLRenderer_2_0::BeginRender(const GFX3D &engine)
|
|||
|
||||
this->_currentAlphaTestRef = engine.renderState.alphaTestRef;
|
||||
this->_SetupGeometryShaders(this->_geometryProgramFlags);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
|
|
@ -288,6 +288,19 @@ EXTERNOGLEXT(PFNGLDELETESYNCPROC, glDeleteSync) // Core in v3.2
|
|||
|
||||
#define OGLRENDER_VERT_INDEX_BUFFER_COUNT (POLYLIST_SIZE * 6)
|
||||
|
||||
// Assign the FBO attachments for the main geometry render
|
||||
#ifdef OGLRENDER_3_2_H
|
||||
#define GL_COLOROUT_ATTACHMENT_ID GL_COLOR_ATTACHMENT0
|
||||
#define GL_WORKING_ATTACHMENT_ID GL_COLOR_ATTACHMENT3
|
||||
#define GL_POLYID_ATTACHMENT_ID GL_COLOR_ATTACHMENT1
|
||||
#define GL_FOGATTRIBUTES_ATTACHMENT_ID GL_COLOR_ATTACHMENT2
|
||||
#else
|
||||
#define GL_COLOROUT_ATTACHMENT_ID GL_COLOR_ATTACHMENT0_EXT
|
||||
#define GL_WORKING_ATTACHMENT_ID GL_COLOR_ATTACHMENT3_EXT
|
||||
#define GL_POLYID_ATTACHMENT_ID GL_COLOR_ATTACHMENT1_EXT
|
||||
#define GL_FOGATTRIBUTES_ATTACHMENT_ID GL_COLOR_ATTACHMENT2_EXT
|
||||
#endif
|
||||
|
||||
enum OGLVertexAttributeID
|
||||
{
|
||||
OGLVertexAttributeID_Position = 0,
|
||||
|
@ -586,7 +599,11 @@ extern GPU3DInterface gpu3Dgl;
|
|||
extern GPU3DInterface gpu3DglOld;
|
||||
extern GPU3DInterface gpu3Dgl_3_2;
|
||||
|
||||
extern const GLenum GeometryDrawBuffersList[8][4];
|
||||
extern const GLenum GeometryDrawBuffersEnum[8][4];
|
||||
extern const GLint GeometryAttachmentWorkingBuffer[8];
|
||||
extern const GLint GeometryAttachmentPolyID[8];
|
||||
extern const GLint GeometryAttachmentFogAttributes[8];
|
||||
|
||||
extern CACHE_ALIGN const GLfloat divide5bitBy31_LUT[32];
|
||||
extern CACHE_ALIGN const GLfloat divide6bitBy63_LUT[64];
|
||||
extern const GLfloat PostprocessVtxBuffer[16];
|
||||
|
|
|
@ -206,13 +206,11 @@ uniform bool drawModeDepthEqualsTest;\n\
|
|||
uniform bool polyDrawShadow;\n\
|
||||
uniform int polyDepthOffsetMode;\n\
|
||||
\n\
|
||||
#if USE_DEPTH_LEQUAL_POLYGON_FACING\n\
|
||||
#if DRAW_MODE_OPAQUE\n\
|
||||
out vec4 outBackFacing;\n\
|
||||
#else\n\
|
||||
#elif USE_DEPTH_LEQUAL_POLYGON_FACING\n\
|
||||
uniform sampler2D inBackFacing;\n\
|
||||
#endif\n\
|
||||
#endif\n\
|
||||
\n\
|
||||
out vec4 outFragColor;\n\
|
||||
\n\
|
||||
|
@ -229,7 +227,7 @@ layout (depth_less) out float gl_FragDepth;\n\
|
|||
void main()\n\
|
||||
{\n\
|
||||
outFragColor = vec4(0.0, 0.0, 0.0, 0.0);\n\
|
||||
#if USE_DEPTH_LEQUAL_POLYGON_FACING && DRAW_MODE_OPAQUE\n\
|
||||
#if DRAW_MODE_OPAQUE\n\
|
||||
outBackFacing = vec4(float(!gl_FrontFacing), 0.0, 0.0, 1.0);\n\
|
||||
#endif\n\
|
||||
#if ENABLE_EDGE_MARK\n\
|
||||
|
@ -1086,10 +1084,10 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs()
|
|||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.fboRenderID);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, OGLRef.texGColorID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, OGLRef.texGPolyID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, OGLRef.texGFogAttrID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, OGLRef.texFinalColorID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOROUT_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texGColorID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_POLYID_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texGPolyID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_FOGATTRIBUTES_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texGFogAttrID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_WORKING_ATTACHMENT_ID, GL_TEXTURE_2D, OGLRef.texFinalColorID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, OGLRef.texGDepthStencilID, 0);
|
||||
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
|
@ -1184,17 +1182,17 @@ Render3DError OpenGLRenderer_3_2::CreateMultisampledFBO(GLsizei numSamples)
|
|||
|
||||
if (this->willUsePerSampleZeroDstPass)
|
||||
{
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGColorID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGWorkingID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOROUT_ATTACHMENT_ID, GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGColorID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_WORKING_ATTACHMENT_ID, GL_TEXTURE_2D_MULTISAMPLE, OGLRef.texMSGWorkingID, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, OGLRef.rboMSGColorID);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_RENDERBUFFER, OGLRef.rboMSGWorkingID);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOROUT_ATTACHMENT_ID, GL_RENDERBUFFER, OGLRef.rboMSGColorID);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_WORKING_ATTACHMENT_ID, GL_RENDERBUFFER, OGLRef.rboMSGWorkingID);
|
||||
}
|
||||
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, OGLRef.rboMSGPolyID);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_RENDERBUFFER, OGLRef.rboMSGFogAttrID);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_POLYID_ATTACHMENT_ID, GL_RENDERBUFFER, OGLRef.rboMSGPolyID);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_FOGATTRIBUTES_ATTACHMENT_ID, GL_RENDERBUFFER, OGLRef.rboMSGFogAttrID);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, OGLRef.rboMSGDepthStencilID);
|
||||
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
|
@ -1450,14 +1448,19 @@ Render3DError OpenGLRenderer_3_2::CreateGeometryPrograms()
|
|||
glBindAttribLocation(OGLRef.programGeometryID[flagsValue], OGLVertexAttributeID_Color, "inColor");
|
||||
glBindFragDataLocation(OGLRef.programGeometryID[flagsValue], 0, "outFragColor");
|
||||
|
||||
if (programFlags.EnableEdgeMark)
|
||||
{
|
||||
glBindFragDataLocation(OGLRef.programGeometryID[flagsValue], 2, "outPolyID");
|
||||
}
|
||||
|
||||
if (programFlags.EnableFog)
|
||||
{
|
||||
glBindFragDataLocation(OGLRef.programGeometryID[flagsValue], 3, "outFogAttributes");
|
||||
glBindFragDataLocation(OGLRef.programGeometryID[flagsValue], GeometryAttachmentFogAttributes[programFlags.DrawBuffersMode], "outFogAttributes");
|
||||
}
|
||||
|
||||
if (programFlags.EnableEdgeMark)
|
||||
{
|
||||
glBindFragDataLocation(OGLRef.programGeometryID[flagsValue], GeometryAttachmentPolyID[programFlags.DrawBuffersMode], "outPolyID");
|
||||
}
|
||||
|
||||
if (programFlags.OpaqueDrawMode)
|
||||
{
|
||||
glBindFragDataLocation(OGLRef.programGeometryID[flagsValue], GeometryAttachmentWorkingBuffer[programFlags.DrawBuffersMode], "outBackFacing");
|
||||
}
|
||||
|
||||
glLinkProgram(OGLRef.programGeometryID[flagsValue]);
|
||||
|
@ -1494,17 +1497,10 @@ Render3DError OpenGLRenderer_3_2::CreateGeometryPrograms()
|
|||
glUniform1i(uniformTexBufferPolyStates, OGLTextureUnitID_PolyStates);
|
||||
}
|
||||
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
if (this->_emulateDepthLEqualPolygonFacing && !programFlags.OpaqueDrawMode)
|
||||
{
|
||||
if (programFlags.OpaqueDrawMode)
|
||||
{
|
||||
glBindFragDataLocation(OGLRef.programGeometryID[flagsValue], 1, "outBackFacing");
|
||||
}
|
||||
else
|
||||
{
|
||||
const GLint uniformTexBackfacing = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "inBackFacing");
|
||||
glUniform1i(uniformTexBackfacing, OGLTextureUnitID_FinalColor);
|
||||
}
|
||||
const GLint uniformTexBackfacing = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "inBackFacing");
|
||||
glUniform1i(uniformTexBackfacing, OGLTextureUnitID_FinalColor);
|
||||
}
|
||||
|
||||
OGLRef.uniformTexDrawOpaque[flagsValue] = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "texDrawOpaque");
|
||||
|
@ -1987,7 +1983,7 @@ void OpenGLRenderer_3_2::_SetupGeometryShaders(const OGLGeometryFlags flags)
|
|||
glUniform1i(OGLRef.uniformDrawModeDepthEqualsTest[flags.value], GL_FALSE);
|
||||
glUniform1i(OGLRef.uniformPolyDrawShadow[flags.value], GL_FALSE);
|
||||
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[flags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[flags.DrawBuffersMode]);
|
||||
}
|
||||
|
||||
Render3DError OpenGLRenderer_3_2::EnableVertexAttributes()
|
||||
|
@ -2020,9 +2016,9 @@ Render3DError OpenGLRenderer_3_2::ZeroDstAlphaPass(const POLYLIST *polyList, con
|
|||
// Just downsample the color buffer now so that we have some texture data to sample from in the non-multisample shader.
|
||||
// This is not perfectly pixel accurate, but it's better than nothing.
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, OGLRef.fboRenderID);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.selectedRenderingFBO);
|
||||
}
|
||||
|
||||
|
@ -2049,7 +2045,7 @@ Render3DError OpenGLRenderer_3_2::ZeroDstAlphaPass(const POLYLIST *polyList, con
|
|||
this->_geometryProgramFlags.EnableEdgeMark = 0;
|
||||
this->_geometryProgramFlags.EnableFog = 0;
|
||||
this->_SetupGeometryShaders(this->_geometryProgramFlags);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, OGLRef.vboGeometryVtxID);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, OGLRef.iboGeometryIndexID);
|
||||
|
@ -2094,13 +2090,13 @@ void OpenGLRenderer_3_2::_ResolveWorkingBackFacing()
|
|||
glBindFramebuffer(GL_READ_FRAMEBUFFER, OGLRef.fboMSIntermediateRenderID);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, OGLRef.fboRenderID);
|
||||
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT3);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3);
|
||||
glReadBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
// Reset framebuffer targets
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.fboMSIntermediateRenderID);
|
||||
}
|
||||
|
||||
|
@ -2118,28 +2114,26 @@ void OpenGLRenderer_3_2::_ResolveGeometry()
|
|||
|
||||
if (this->_enableEdgeMark)
|
||||
{
|
||||
// Blit the polygon ID buffer
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT1);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT1);
|
||||
glReadBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
{
|
||||
// Blit the fog buffer
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT2);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT2);
|
||||
glReadBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
// Blit the color and depth buffers
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
// Reset framebuffer targets
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.fboRenderID);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
}
|
||||
|
||||
Render3DError OpenGLRenderer_3_2::ReadBackPixels()
|
||||
|
@ -2154,15 +2148,15 @@ Render3DError OpenGLRenderer_3_2::ReadBackPixels()
|
|||
{
|
||||
// Use the alternate program where the output color is not at index 0.
|
||||
glUseProgram(OGLRef.programFramebufferRGBA6665OutputID[1]);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT3);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the program where the output color is from index 0.
|
||||
glUseProgram(OGLRef.programFramebufferRGBA6665OutputID[0]);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
|
||||
glViewport(0, 0, this->_framebufferWidth, this->_framebufferHeight);
|
||||
|
@ -2189,17 +2183,17 @@ Render3DError OpenGLRenderer_3_2::ReadBackPixels()
|
|||
// Just flips the framebuffer in Y to match the coordinates of OpenGL and the NDS hardware.
|
||||
if (this->_lastTextureDrawTarget == OGLTextureUnitID_GColor)
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, this->_framebufferHeight, this->_framebufferWidth, 0, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT3);
|
||||
glReadBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT3);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glReadBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, this->_framebufferHeight, this->_framebufferWidth, 0, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
}
|
||||
|
||||
// Read back the pixels in RGBA format, since an OpenGL 3.2 device should be able to read back this
|
||||
|
@ -2412,7 +2406,7 @@ Render3DError OpenGLRenderer_3_2::BeginRender(const GFX3D &engine)
|
|||
|
||||
this->_currentAlphaTestRef = engine.renderState.alphaTestRef;
|
||||
this->_SetupGeometryShaders(this->_geometryProgramFlags);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
@ -2448,7 +2442,7 @@ Render3DError OpenGLRenderer_3_2::RenderEdgeMarking(const u16 *colorTable, const
|
|||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
// Pass 2: Unblended edge mark colors to zero-alpha pixels
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glUseProgram(OGLRef.programEdgeMarkID);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
|
||||
glStencilFunc(GL_NOTEQUAL, 0x40, 0x40);
|
||||
|
@ -2463,7 +2457,7 @@ Render3DError OpenGLRenderer_3_2::RenderEdgeMarking(const u16 *colorTable, const
|
|||
else
|
||||
{
|
||||
glUseProgram(OGLRef.programEdgeMarkID);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
@ -2496,7 +2490,7 @@ Render3DError OpenGLRenderer_3_2::RenderFog(const u8 *densityTable, const u32 co
|
|||
|
||||
OGLFogShaderID shaderID = this->_fogProgramMap[fogProgramKey.key];
|
||||
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT3);
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glUseProgram(shaderID.program);
|
||||
glViewport(0, 0, this->_framebufferWidth, this->_framebufferHeight);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
@ -2540,32 +2534,32 @@ Render3DError OpenGLRenderer_3_2::ClearUsingImage(const u16 *__restrict colorBuf
|
|||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, OGLRef.fboClearImageID);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, OGLRef.fboRenderID);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
{
|
||||
const GLfloat oglBackfacing[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
glClearBufferfv(GL_COLOR, 1, oglBackfacing);
|
||||
glClearBufferfv(GL_COLOR, GeometryAttachmentWorkingBuffer[this->_geometryProgramFlags.DrawBuffersMode], oglBackfacing);
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
{
|
||||
// Clear the polygon ID buffer
|
||||
const GLfloat oglPolyID[4] = {(GLfloat)opaquePolyID/63.0f, 0.0f, 0.0f, 1.0f};
|
||||
glClearBufferfv(GL_COLOR, 2, oglPolyID);
|
||||
glClearBufferfv(GL_COLOR, GeometryAttachmentPolyID[this->_geometryProgramFlags.DrawBuffersMode], oglPolyID);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
{
|
||||
// Blit the fog buffer
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT2);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT2);
|
||||
glReadBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, GPU_FRAMEBUFFER_NATIVE_HEIGHT, GPU_FRAMEBUFFER_NATIVE_WIDTH, 0, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
// Blit the color and depth/stencil buffers. Do this last so that color attachment 0 is set to the read FBO.
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, GPU_FRAMEBUFFER_NATIVE_HEIGHT, GPU_FRAMEBUFFER_NATIVE_WIDTH, 0, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.fboRenderID);
|
||||
|
@ -2575,32 +2569,30 @@ Render3DError OpenGLRenderer_3_2::ClearUsingImage(const u16 *__restrict colorBuf
|
|||
{
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, OGLRef.fboRenderID);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, OGLRef.selectedRenderingFBO);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
{
|
||||
const GLfloat oglBackfacing[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
glClearBufferfv(GL_COLOR, 1, oglBackfacing);
|
||||
glClearBufferfv(GL_COLOR, GeometryAttachmentWorkingBuffer[this->_geometryProgramFlags.DrawBuffersMode], oglBackfacing);
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
{
|
||||
// Clear the polygon ID buffer
|
||||
const GLfloat oglPolyID[4] = {(GLfloat)opaquePolyID/63.0f, 0.0f, 0.0f, 1.0f};
|
||||
glClearBufferfv(GL_COLOR, 2, oglPolyID);
|
||||
glClearBufferfv(GL_COLOR, GeometryAttachmentPolyID[this->_geometryProgramFlags.DrawBuffersMode], oglPolyID);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
{
|
||||
// Blit the fog buffer
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT2);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT2);
|
||||
glReadBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
// Blit the color and depth/stencil buffers. Do this last so that color attachment 0 is set to the read FBO.
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glBlitFramebuffer(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.selectedRenderingFBO);
|
||||
|
@ -2614,28 +2606,28 @@ Render3DError OpenGLRenderer_3_2::ClearUsingValues(const FragmentColor &clearCol
|
|||
OGLRenderRef &OGLRef = *this->ref;
|
||||
OGLRef.selectedRenderingFBO = (this->_enableMultisampledRendering) ? OGLRef.fboMSIntermediateRenderID : OGLRef.fboRenderID;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.selectedRenderingFBO);
|
||||
glDrawBuffers(4, GeometryDrawBuffersList[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
glDrawBuffers(4, GeometryDrawBuffersEnum[this->_geometryProgramFlags.DrawBuffersMode]);
|
||||
|
||||
const GLfloat oglColor[4] = {divide6bitBy63_LUT[clearColor6665.r], divide6bitBy63_LUT[clearColor6665.g], divide6bitBy63_LUT[clearColor6665.b], divide5bitBy31_LUT[clearColor6665.a]};
|
||||
glClearBufferfv(GL_COLOR, 0, oglColor); // texGColorID
|
||||
glClearBufferfv(GL_COLOR, 0, oglColor);
|
||||
glClearBufferfi(GL_DEPTH_STENCIL, 0, (GLfloat)clearAttributes.depth / (GLfloat)0x00FFFFFF, clearAttributes.opaquePolyID);
|
||||
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
{
|
||||
const GLfloat oglBackfacing[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
glClearBufferfv(GL_COLOR, 1, oglBackfacing);
|
||||
glClearBufferfv(GL_COLOR, GeometryAttachmentWorkingBuffer[this->_geometryProgramFlags.DrawBuffersMode], oglBackfacing);
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
{
|
||||
const GLfloat oglPolyID[4] = {(GLfloat)clearAttributes.opaquePolyID/63.0f, 0.0f, 0.0f, 1.0f};
|
||||
glClearBufferfv(GL_COLOR, 2, oglPolyID); // texGPolyID
|
||||
glClearBufferfv(GL_COLOR, GeometryAttachmentPolyID[this->_geometryProgramFlags.DrawBuffersMode], oglPolyID);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
{
|
||||
const GLfloat oglFogAttr[4] = {(GLfloat)clearAttributes.isFogged, 0.0f, 0.0f, 1.0f};
|
||||
glClearBufferfv(GL_COLOR, 3, oglFogAttr);
|
||||
glClearBufferfv(GL_COLOR, GeometryAttachmentFogAttributes[this->_geometryProgramFlags.DrawBuffersMode], oglFogAttr);
|
||||
}
|
||||
|
||||
this->_needsZeroDstAlphaPass = (clearColor6665.a == 0);
|
||||
|
@ -2894,8 +2886,8 @@ Render3DError OpenGLRenderer_3_2::RenderPowerOff()
|
|||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.fboRenderID);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glClearBufferfv(GL_COLOR, 0, oglColor);
|
||||
|
||||
if (this->_mappedFramebuffer != NULL)
|
||||
|
|
Loading…
Reference in New Issue