Render 3D: Handle RenderFinish() more consistently. Fixes 3D flushing issues when running single-threaded SoftRasterizer.

This commit is contained in:
rogerman 2017-11-20 10:58:27 -08:00
parent e5694abd63
commit 6680577146
2 changed files with 58 additions and 47 deletions

View File

@ -4717,28 +4717,32 @@ Render3DError OpenGLRenderer_1_2::Reset()
Render3DError OpenGLRenderer_1_2::RenderFinish()
{
if (!this->_renderNeedsFinish || !this->_pixelReadNeedsFinish)
if (!this->_renderNeedsFinish)
{
return OGLERROR_NOERR;
}
if(!BEGINGL())
if (this->_pixelReadNeedsFinish)
{
return OGLERROR_BEGINGL_FAILED;
this->_pixelReadNeedsFinish = false;
if(!BEGINGL())
{
return OGLERROR_BEGINGL_FAILED;
}
if (this->isPBOSupported)
{
this->_mappedFramebuffer = (FragmentColor *__restrict)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
}
else
{
glReadPixels(0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_BGRA, GL_UNSIGNED_BYTE, this->_framebufferColor);
}
ENDGL();
}
if (this->isPBOSupported)
{
this->_mappedFramebuffer = (FragmentColor *__restrict)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
}
else
{
glReadPixels(0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_BGRA, GL_UNSIGNED_BYTE, this->_framebufferColor);
}
ENDGL();
this->_pixelReadNeedsFinish = false;
this->_renderNeedsFlushMain = true;
this->_renderNeedsFlush16 = true;
@ -5036,21 +5040,25 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, size_t polyR
Render3DError OpenGLRenderer_2_1::RenderFinish()
{
if (!this->_renderNeedsFinish || !this->_pixelReadNeedsFinish)
if (!this->_renderNeedsFinish)
{
return OGLERROR_NOERR;
}
if(!BEGINGL())
if (this->_pixelReadNeedsFinish)
{
return OGLERROR_BEGINGL_FAILED;
this->_pixelReadNeedsFinish = false;
if(!BEGINGL())
{
return OGLERROR_BEGINGL_FAILED;
}
this->_mappedFramebuffer = (FragmentColor *__restrict)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
ENDGL();
}
this->_mappedFramebuffer = (FragmentColor *__restrict)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
ENDGL();
this->_pixelReadNeedsFinish = false;
this->_renderNeedsFlushMain = true;
this->_renderNeedsFlush16 = true;

View File

@ -2226,39 +2226,42 @@ Render3DError SoftRasterizerRenderer::EndRender(const u64 frameCount)
Render3DError SoftRasterizerRenderer::RenderFinish()
{
if (!this->_renderNeedsFinish || !this->_renderGeometryNeedsFinish)
if (!this->_renderNeedsFinish)
{
return RENDER3DERROR_NOERR;
}
// Allow for the geometry rendering to finish.
this->_renderGeometryNeedsFinish = false;
for (size_t i = 0; i < rasterizerCores; i++)
if (this->_renderGeometryNeedsFinish)
{
rasterizerUnitTask[i].finish();
}
// Now that geometry rendering is finished on all threads, check the texture cache.
texCache.Evict();
// Do multithreaded post-processing.
if (this->_enableEdgeMark || this->_enableFog)
{
for (size_t i = 0; i < rasterizerCores; i++)
{
this->postprocessParam[i].enableEdgeMarking = this->_enableEdgeMark;
this->postprocessParam[i].enableFog = this->_enableFog;
this->postprocessParam[i].fogColor = this->currentRenderState->fogColor;
this->postprocessParam[i].fogAlphaOnly = this->currentRenderState->enableFogAlphaOnly;
rasterizerUnitTask[i].execute(&SoftRasterizer_RunRenderEdgeMarkAndFog, &this->postprocessParam[i]);
}
// Allow for post-processing to finish.
// Allow for the geometry rendering to finish.
this->_renderGeometryNeedsFinish = false;
for (size_t i = 0; i < rasterizerCores; i++)
{
rasterizerUnitTask[i].finish();
}
// Now that geometry rendering is finished on all threads, check the texture cache.
texCache.Evict();
// Do multithreaded post-processing.
if (this->_enableEdgeMark || this->_enableFog)
{
for (size_t i = 0; i < rasterizerCores; i++)
{
this->postprocessParam[i].enableEdgeMarking = this->_enableEdgeMark;
this->postprocessParam[i].enableFog = this->_enableFog;
this->postprocessParam[i].fogColor = this->currentRenderState->fogColor;
this->postprocessParam[i].fogAlphaOnly = this->currentRenderState->enableFogAlphaOnly;
rasterizerUnitTask[i].execute(&SoftRasterizer_RunRenderEdgeMarkAndFog, &this->postprocessParam[i]);
}
// Allow for post-processing to finish.
for (size_t i = 0; i < rasterizerCores; i++)
{
rasterizerUnitTask[i].finish();
}
}
}
this->_renderNeedsFlushMain = true;