Track glEnable states via static refs instead of map lookups.
Sync light state, bound shader, and various gl context states similarly to render matrices. Texture handles now refcounted, as multiple viewer textures could ref the same handle (cubemaps do this) Clean up gl extension loading a bit. Not necessary, but only look for ARB variants if not included in current core version. Removed unused extensions. Use core shader api if supported, else use ARB. (FN signatures are identical. Just doing some pointer substitution to ARB if not core.) Attempt at improving VBO update batching. Subdata updates better batched to gether per-frame. There's probably other stuff I forgot that is in this changeset, too. Todo: Fix lightstate assertion when toggling fullscreen with shaders off.
This commit is contained in:
@@ -195,8 +195,8 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
|
||||
return false;
|
||||
}
|
||||
|
||||
U32 tex;
|
||||
LLImageGL::generateTextures(1, &tex);
|
||||
auto texName = LLImageGL::createTextureName();
|
||||
U32 tex = texName->getTexName();
|
||||
gGL.getTexUnit(0)->bindManual(mUsage, tex);
|
||||
|
||||
stop_glerror();
|
||||
@@ -245,6 +245,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
|
||||
}
|
||||
|
||||
mTex.push_back(tex);
|
||||
mTexName.push_back(texName);
|
||||
mInternalFormat.push_back(color_fmt);
|
||||
|
||||
if (gDebugGL)
|
||||
@@ -258,6 +259,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
|
||||
|
||||
bool LLRenderTarget::allocateDepth()
|
||||
{
|
||||
mDepthName.reset();
|
||||
if (mStencil && mFBO)
|
||||
{
|
||||
//use render buffers where stencil buffers are in play
|
||||
@@ -270,7 +272,9 @@ bool LLRenderTarget::allocateDepth()
|
||||
}
|
||||
else
|
||||
{
|
||||
LLImageGL::generateTextures(1, &mDepth);
|
||||
mDepthName = LLImageGL::createTextureName();
|
||||
mDepth = mDepthName->getTexName();
|
||||
|
||||
gGL.getTexUnit(0)->bindManual(mUsage, mDepth);
|
||||
|
||||
U32 internal_type = LLTexUnit::getInternalType(mUsage);
|
||||
@@ -357,7 +361,6 @@ void LLRenderTarget::release()
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, LLTexUnit::getInternalType(mUsage), 0, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,0);
|
||||
}
|
||||
LLImageGL::deleteTextures(1, &mDepth);
|
||||
stop_glerror();
|
||||
}
|
||||
mDepth = 0;
|
||||
@@ -387,13 +390,11 @@ void LLRenderTarget::release()
|
||||
mFBO = 0;
|
||||
}
|
||||
|
||||
if (mTex.size() > 0)
|
||||
{
|
||||
sBytesAllocated -= mResX*mResY*4*mTex.size();
|
||||
LLImageGL::deleteTextures(mTex.size(), &mTex[0]);
|
||||
mTex.clear();
|
||||
mInternalFormat.clear();
|
||||
}
|
||||
sBytesAllocated -= mResX * mResY * 4 * mTex.size();
|
||||
mTex.clear();
|
||||
mInternalFormat.clear();
|
||||
mDepthName.reset();
|
||||
mTexName.clear(); // Were textures not being released at all..?
|
||||
|
||||
mResX = mResY = 0;
|
||||
|
||||
@@ -440,8 +441,7 @@ void LLRenderTarget::bindTarget()
|
||||
stop_glerror();
|
||||
}
|
||||
}
|
||||
|
||||
glViewport(0, 0, mResX, mResY);
|
||||
gGL.setViewport(0, 0, mResX, mResY);
|
||||
sBoundTarget = this;
|
||||
}
|
||||
|
||||
@@ -452,18 +452,22 @@ void LLRenderTarget::clear(U32 mask_in)
|
||||
{
|
||||
mask |= GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
|
||||
}
|
||||
|
||||
if (mFBO)
|
||||
{
|
||||
check_framebuffer_status();
|
||||
stop_glerror();
|
||||
LLGLDisable<GL_SCISSOR_TEST> scissor;
|
||||
gGL.syncContextState();
|
||||
glClear(mask & mask_in);
|
||||
stop_glerror();
|
||||
}
|
||||
else
|
||||
{
|
||||
LLGLEnable scissor(GL_SCISSOR_TEST);
|
||||
glScissor(0, 0, mResX, mResY);
|
||||
LLGLEnable<GL_SCISSOR_TEST> scissor;
|
||||
gGL.setScissor(0, 0, mResX, mResY);
|
||||
stop_glerror();
|
||||
gGL.syncContextState();
|
||||
glClear(mask & mask_in);
|
||||
}
|
||||
}
|
||||
@@ -515,7 +519,7 @@ void LLRenderTarget::flush(bool fetch_depth)
|
||||
stop_glerror();
|
||||
if(mSampleBuffer)
|
||||
{
|
||||
LLGLEnable multisample(GL_MULTISAMPLE);
|
||||
LLGLEnable<GL_MULTISAMPLE> multisample;
|
||||
stop_glerror();
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
|
||||
stop_glerror();
|
||||
@@ -575,12 +579,12 @@ void LLRenderTarget::flush(bool fetch_depth)
|
||||
|
||||
if(mPreviousFBO)
|
||||
{
|
||||
glViewport(0, 0, mPreviousFBO->mResX, mPreviousFBO->mResY);
|
||||
gGL.setViewport(0, 0, mPreviousFBO->mResX, mPreviousFBO->mResY);
|
||||
mPreviousFBO = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
glViewport(gGLViewport[0],gGLViewport[1],gGLViewport[2],gGLViewport[3]);
|
||||
gGL.setViewport(gGLViewport);
|
||||
}
|
||||
stop_glerror();
|
||||
}
|
||||
@@ -683,12 +687,9 @@ bool LLRenderTarget::isComplete() const
|
||||
return (!mTex.empty() || mDepth) ? true : false;
|
||||
}
|
||||
|
||||
void LLRenderTarget::getViewport(S32* viewport)
|
||||
void LLRenderTarget::getViewport(LLRect& viewport)
|
||||
{
|
||||
viewport[0] = 0;
|
||||
viewport[1] = 0;
|
||||
viewport[2] = mResX;
|
||||
viewport[3] = mResY;
|
||||
viewport = LLRect(0, mResY, mResX, 0);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
@@ -754,7 +755,7 @@ void LLMultisampleBuffer::bindTarget(LLRenderTarget* ref)
|
||||
|
||||
check_framebuffer_status();
|
||||
|
||||
glViewport(0, 0, mResX, mResY);
|
||||
gGL.setViewport(0, 0, mResX, mResY);
|
||||
|
||||
sBoundTarget = this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user