Deferred has sky and water textures now. Underwater is still borked.
Deferred fastalpha behaves a bit better. Pulled over patch for https://jira.secondlife.com/browse/STORM-336 and https://jira.secondlife.com/browse/STORM-1011 from linden repo Sky rendered using new LL method. Assuming this fixes issues on AMD cards(works on cat 11.2) Added a few things missed related to spatial-parition updating. Added 'SkipReflectOcclusionUpdates' setting that prevents occlusion updates for reflection pass. Less taxing on CPU.
This commit is contained in:
@@ -56,6 +56,7 @@ U32 LLVertexBuffer::sSetCount = 0;
|
||||
S32 LLVertexBuffer::sCount = 0;
|
||||
S32 LLVertexBuffer::sGLCount = 0;
|
||||
S32 LLVertexBuffer::sMappedCount = 0;
|
||||
BOOL LLVertexBuffer::sDisableVBOMapping = FALSE ;
|
||||
BOOL LLVertexBuffer::sEnableVBOs = TRUE;
|
||||
U32 LLVertexBuffer::sGLRenderBuffer = 0;
|
||||
U32 LLVertexBuffer::sGLRenderIndices = 0;
|
||||
@@ -287,9 +288,10 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
|
||||
}
|
||||
|
||||
//static
|
||||
void LLVertexBuffer::initClass(bool use_vbo)
|
||||
void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping)
|
||||
{
|
||||
sEnableVBOs = use_vbo;
|
||||
sDisableVBOMapping = sEnableVBOs && no_vbo_mapping ;
|
||||
LLGLNamePool::registerPool(&sDynamicVBOPool);
|
||||
LLGLNamePool::registerPool(&sDynamicIBOPool);
|
||||
LLGLNamePool::registerPool(&sStreamVBOPool);
|
||||
@@ -346,7 +348,9 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
|
||||
mGLBuffer(0),
|
||||
mGLIndices(0),
|
||||
mMappedData(NULL),
|
||||
mMappedIndexData(NULL), mLocked(FALSE),
|
||||
mMappedIndexData(NULL),
|
||||
mVertexLocked(FALSE),
|
||||
mIndexLocked(FALSE),
|
||||
mFinal(FALSE),
|
||||
mFilthy(FALSE),
|
||||
mEmpty(TRUE),
|
||||
@@ -544,6 +548,8 @@ void LLVertexBuffer::destroyGLBuffer()
|
||||
{
|
||||
if (useVBOs())
|
||||
{
|
||||
freeClientBuffer() ;
|
||||
|
||||
if (mMappedData || mMappedIndexData)
|
||||
{
|
||||
llerrs << "Vertex buffer destroyed while mapped!" << llendl;
|
||||
@@ -571,6 +577,8 @@ void LLVertexBuffer::destroyGLIndices()
|
||||
{
|
||||
if (useVBOs())
|
||||
{
|
||||
freeClientBuffer() ;
|
||||
|
||||
if (mMappedData || mMappedIndexData)
|
||||
{
|
||||
llerrs << "Vertex buffer destroyed while mapped." << llendl;
|
||||
@@ -768,6 +776,7 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
|
||||
|
||||
if (mResized && useVBOs())
|
||||
{
|
||||
freeClientBuffer() ;
|
||||
setBuffer(0);
|
||||
}
|
||||
}
|
||||
@@ -782,104 +791,228 @@ BOOL LLVertexBuffer::useVBOs() const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void LLVertexBuffer::freeClientBuffer()
|
||||
{
|
||||
if(useVBOs() && sDisableVBOMapping && (mMappedData || mMappedIndexData))
|
||||
{
|
||||
delete[] mMappedData ;
|
||||
delete[] mMappedIndexData ;
|
||||
mMappedData = NULL ;
|
||||
mMappedIndexData = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
void LLVertexBuffer::allocateClientVertexBuffer()
|
||||
{
|
||||
if(!mMappedData)
|
||||
{
|
||||
U32 size = getSize() ;
|
||||
mMappedData = new U8[size];
|
||||
memset((void*)mMappedData, 0, size);
|
||||
}
|
||||
}
|
||||
|
||||
void LLVertexBuffer::allocateClientIndexBuffer()
|
||||
{
|
||||
if(!mMappedIndexData)
|
||||
{
|
||||
U32 size = getIndicesSize();
|
||||
mMappedIndexData = new U8[size];
|
||||
memset((void*)mMappedIndexData, 0, size);
|
||||
}
|
||||
}
|
||||
|
||||
// Map for data access
|
||||
volatile U8* LLVertexBuffer::mapBuffer(S32 access)
|
||||
volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 access)
|
||||
{
|
||||
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
|
||||
if (mFinal)
|
||||
{
|
||||
llerrs << "LLVertexBuffer::mapBuffer() called on a finalized buffer." << llendl;
|
||||
llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl;
|
||||
}
|
||||
if (!useVBOs() && !mMappedData && !mMappedIndexData)
|
||||
{
|
||||
llerrs << "LLVertexBuffer::mapBuffer() called on unallocated buffer." << llendl;
|
||||
llerrs << "LLVertexBuffer::mapVertexBuffer() called on unallocated buffer." << llendl;
|
||||
}
|
||||
|
||||
if (!mLocked && useVBOs())
|
||||
if (!mVertexLocked && useVBOs())
|
||||
{
|
||||
setBuffer(0);
|
||||
mLocked = TRUE;
|
||||
stop_glerror();
|
||||
mMappedData = (U8*) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
stop_glerror();
|
||||
mMappedIndexData = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
stop_glerror();
|
||||
{
|
||||
setBuffer(0, type);
|
||||
mVertexLocked = TRUE;
|
||||
stop_glerror();
|
||||
|
||||
if(sDisableVBOMapping)
|
||||
{
|
||||
allocateClientVertexBuffer() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
mMappedData = (U8*) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
}
|
||||
stop_glerror();
|
||||
}
|
||||
|
||||
if (!mMappedData)
|
||||
{
|
||||
//--------------------
|
||||
//print out more debug info before crash
|
||||
llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl ;
|
||||
GLint size ;
|
||||
glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size) ;
|
||||
llinfos << "GL_ARRAY_BUFFER_ARB size is " << size << llendl ;
|
||||
//--------------------
|
||||
|
||||
GLint buff;
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff);
|
||||
if ((GLuint)buff != mGLBuffer)
|
||||
if(!sDisableVBOMapping)
|
||||
{
|
||||
llerrs << "Invalid GL vertex buffer bound: " << buff << llendl;
|
||||
//--------------------
|
||||
//print out more debug info before crash
|
||||
llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl ;
|
||||
GLint size ;
|
||||
glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size) ;
|
||||
llinfos << "GL_ARRAY_BUFFER_ARB size is " << size << llendl ;
|
||||
//--------------------
|
||||
|
||||
GLint buff;
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff);
|
||||
if ((GLuint)buff != mGLBuffer)
|
||||
{
|
||||
llerrs << "Invalid GL vertex buffer bound: " << buff << llendl;
|
||||
}
|
||||
|
||||
|
||||
llerrs << "glMapBuffer returned NULL (no vertex data)" << llendl;
|
||||
}
|
||||
|
||||
|
||||
llerrs << "glMapBuffer returned NULL (no vertex data)" << llendl;
|
||||
}
|
||||
|
||||
if (!mMappedIndexData)
|
||||
{
|
||||
GLint buff;
|
||||
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff);
|
||||
if ((GLuint)buff != mGLIndices)
|
||||
else
|
||||
{
|
||||
llerrs << "Invalid GL index buffer bound: " << buff << llendl;
|
||||
llerrs << "memory allocation for vertex data failed." << llendl ;
|
||||
}
|
||||
|
||||
llerrs << "glMapBuffer returned NULL (no index data)" << llendl;
|
||||
}
|
||||
|
||||
sMappedCount++;
|
||||
}
|
||||
|
||||
return mMappedData;
|
||||
}
|
||||
|
||||
void LLVertexBuffer::unmapBuffer()
|
||||
volatile U8* LLVertexBuffer::mapIndexBuffer(S32 access)
|
||||
{
|
||||
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
|
||||
if (mMappedData || mMappedIndexData)
|
||||
if (mFinal)
|
||||
{
|
||||
if (useVBOs() && mLocked)
|
||||
llerrs << "LLVertexBuffer::mapIndexBuffer() called on a finalized buffer." << llendl;
|
||||
}
|
||||
if (!useVBOs() && !mMappedData && !mMappedIndexData)
|
||||
{
|
||||
llerrs << "LLVertexBuffer::mapIndexBuffer() called on unallocated buffer." << llendl;
|
||||
}
|
||||
|
||||
if (!mIndexLocked && useVBOs())
|
||||
{
|
||||
{
|
||||
|
||||
setBuffer(0, TYPE_INDEX);
|
||||
mIndexLocked = TRUE;
|
||||
stop_glerror();
|
||||
|
||||
if(sDisableVBOMapping)
|
||||
{
|
||||
allocateClientIndexBuffer() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
mMappedIndexData = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
|
||||
}
|
||||
stop_glerror();
|
||||
}
|
||||
|
||||
if (!mMappedIndexData)
|
||||
{
|
||||
|
||||
if(!sDisableVBOMapping)
|
||||
{
|
||||
GLint buff;
|
||||
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff);
|
||||
if ((GLuint)buff != mGLIndices)
|
||||
{
|
||||
llerrs << "Invalid GL index buffer bound: " << buff << llendl;
|
||||
}
|
||||
|
||||
llerrs << "glMapBuffer returned NULL (no index data)" << llendl;
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "memory allocation for Index data failed. " << llendl ;
|
||||
}
|
||||
}
|
||||
|
||||
sMappedCount++;
|
||||
}
|
||||
|
||||
return mMappedIndexData ;
|
||||
}
|
||||
|
||||
void LLVertexBuffer::unmapBuffer(S32 type)
|
||||
{
|
||||
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
|
||||
if (!useVBOs())
|
||||
{
|
||||
return ; //nothing to unmap
|
||||
}
|
||||
|
||||
bool updated_all = false ;
|
||||
if (mMappedData && mVertexLocked && type != TYPE_INDEX)
|
||||
{
|
||||
updated_all = (mIndexLocked && type < 0) ; //both vertex and index buffers done updating
|
||||
|
||||
if(sDisableVBOMapping)
|
||||
{
|
||||
stop_glerror();
|
||||
glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, getSize(), (void*)mMappedData);
|
||||
stop_glerror();
|
||||
}
|
||||
else
|
||||
{
|
||||
stop_glerror();
|
||||
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
|
||||
stop_glerror();
|
||||
|
||||
mMappedData = NULL;
|
||||
}
|
||||
|
||||
mVertexLocked = FALSE ;
|
||||
sMappedCount--;
|
||||
}
|
||||
|
||||
if(mMappedIndexData && mIndexLocked && (type < 0 || type == TYPE_INDEX))
|
||||
{
|
||||
if(sDisableVBOMapping)
|
||||
{
|
||||
stop_glerror();
|
||||
glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, getIndicesSize(), (void*)mMappedIndexData);
|
||||
stop_glerror();
|
||||
}
|
||||
else
|
||||
{
|
||||
stop_glerror();
|
||||
glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
|
||||
stop_glerror();
|
||||
|
||||
/*if (!sMapped)
|
||||
{
|
||||
llerrs << "Redundantly unmapped VBO!" << llendl;
|
||||
}
|
||||
sMapped = FALSE;*/
|
||||
sMappedCount--;
|
||||
mMappedIndexData = NULL ;
|
||||
}
|
||||
|
||||
if (mUsage == GL_STATIC_DRAW_ARB)
|
||||
{ //static draw buffers can only be mapped a single time
|
||||
//throw out client data (we won't be using it again)
|
||||
mEmpty = TRUE;
|
||||
mFinal = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mEmpty = FALSE;
|
||||
}
|
||||
mIndexLocked = FALSE ;
|
||||
sMappedCount--;
|
||||
}
|
||||
|
||||
mMappedIndexData = NULL;
|
||||
mMappedData = NULL;
|
||||
|
||||
mLocked = FALSE;
|
||||
if(updated_all)
|
||||
{
|
||||
if(mUsage == GL_STATIC_DRAW_ARB)
|
||||
{
|
||||
//static draw buffers can only be mapped a single time
|
||||
//throw out client data (we won't be using it again)
|
||||
mEmpty = TRUE;
|
||||
mFinal = TRUE;
|
||||
|
||||
if(sDisableVBOMapping)
|
||||
{
|
||||
freeClientBuffer() ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mEmpty = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -893,15 +1026,16 @@ template <class T,S32 type> struct VertexBufferStrider
|
||||
strider_t& strider,
|
||||
S32 index)
|
||||
{
|
||||
if (vbo.mapBuffer() == NULL)
|
||||
{
|
||||
llwarns << "mapBuffer failed!" << llendl;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (type == LLVertexBuffer::TYPE_INDEX)
|
||||
{
|
||||
S32 stride = sizeof(T);
|
||||
|
||||
if (vbo.mapIndexBuffer() == NULL)
|
||||
{
|
||||
llwarns << "mapIndexBuffer failed!" << llendl;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
strider = (T*)(vbo.getMappedIndices() + index*stride);
|
||||
strider.setStride(0);
|
||||
return TRUE;
|
||||
@@ -909,6 +1043,13 @@ template <class T,S32 type> struct VertexBufferStrider
|
||||
else if (vbo.hasDataType(type))
|
||||
{
|
||||
S32 stride = vbo.getStride();
|
||||
|
||||
if (vbo.mapVertexBuffer(type) == NULL)
|
||||
{
|
||||
llwarns << "mapVertexBuffer failed!" << llendl;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
strider = (T*)(vbo.getMappedData() + vbo.getOffset(type) + index*stride);
|
||||
strider.setStride(stride);
|
||||
return TRUE;
|
||||
@@ -989,7 +1130,7 @@ void LLVertexBuffer::setStride(S32 type, S32 new_stride)
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// Set for rendering
|
||||
void LLVertexBuffer::setBuffer(U32 data_mask)
|
||||
void LLVertexBuffer::setBuffer(U32 data_mask, S32 type)
|
||||
{
|
||||
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
|
||||
//set up pointers if the data mask is different ...
|
||||
@@ -1023,6 +1164,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
|
||||
sIBOActive = TRUE;
|
||||
}
|
||||
|
||||
BOOL error = FALSE;
|
||||
if (gDebugGL)
|
||||
{
|
||||
GLint buff;
|
||||
@@ -1085,7 +1227,11 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
|
||||
}
|
||||
}
|
||||
|
||||
unmapBuffer();
|
||||
if (error)
|
||||
{
|
||||
llerrs << "LLVertexBuffer::mapBuffer failed" << llendl;
|
||||
}
|
||||
unmapBuffer(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user