diff options
Diffstat (limited to 'indra/llrender')
-rw-r--r-- | indra/llrender/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/llrender/llcubemap.cpp | 257 | ||||
-rw-r--r-- | indra/llrender/llcubemap.h | 24 | ||||
-rw-r--r-- | indra/llrender/llcubemaparray.cpp | 157 | ||||
-rw-r--r-- | indra/llrender/llcubemaparray.h | 67 | ||||
-rw-r--r-- | indra/llrender/llgl.cpp | 73 | ||||
-rw-r--r-- | indra/llrender/llgl.h | 2 | ||||
-rw-r--r-- | indra/llrender/llglheaders.h | 22 | ||||
-rw-r--r-- | indra/llrender/llglslshader.cpp | 114 | ||||
-rw-r--r-- | indra/llrender/llglslshader.h | 8 | ||||
-rw-r--r-- | indra/llrender/llimagegl.cpp | 205 | ||||
-rw-r--r-- | indra/llrender/llimagegl.h | 27 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 10 | ||||
-rw-r--r-- | indra/llrender/llrender.h | 3 | ||||
-rw-r--r-- | indra/llrender/llrendertarget.cpp | 12 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 44 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.h | 9 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 6 |
18 files changed, 677 insertions, 365 deletions
diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt index baab09a104..a30f47f1d9 100644 --- a/indra/llrender/CMakeLists.txt +++ b/indra/llrender/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories(SYSTEM set(llrender_SOURCE_FILES llatmosphere.cpp llcubemap.cpp + llcubemaparray.cpp llfontbitmapcache.cpp llfontfreetype.cpp llfontgl.cpp @@ -58,6 +59,7 @@ set(llrender_HEADER_FILES llatmosphere.h llcubemap.h + llcubemaparray.h llfontgl.h llfontfreetype.h llfontbitmapcache.h diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp index 834084674e..473447ad72 100644 --- a/indra/llrender/llcubemap.cpp +++ b/indra/llrender/llcubemap.cpp @@ -40,8 +40,9 @@ #include "llglheaders.h" -const F32 epsilon = 1e-7f; -const U16 RESOLUTION = 64; +namespace { + const U16 RESOLUTION = 64; +} bool LLCubeMap::sUseCubeMaps = true; @@ -166,6 +167,73 @@ void LLCubeMap::init(const std::vector<LLPointer<LLImageRaw> >& rawimages) } } +void LLCubeMap::initReflectionMap(U32 resolution, U32 components) +{ + U32 texname = 0; + + LLImageGL::generateTextures(1, &texname); + + mImages[0] = new LLImageGL(resolution, resolution, components, TRUE); + mImages[0]->setTexName(texname); + mImages[0]->setTarget(mTargets[0], LLTexUnit::TT_CUBE_MAP); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, texname); + mImages[0]->setAddressMode(LLTexUnit::TAM_CLAMP); +} + +void LLCubeMap::initEnvironmentMap(const std::vector<LLPointer<LLImageRaw> >& rawimages) +{ + llassert(rawimages.size() == 6); + + U32 texname = 0; + + LLImageGL::generateTextures(1, &texname); + + U32 resolution = rawimages[0]->getWidth(); + U32 components = rawimages[0]->getComponents(); + + for (int i = 0; i < 6; i++) + { + llassert(rawimages[i]->getWidth() == resolution); + llassert(rawimages[i]->getHeight() == resolution); + llassert(rawimages[i]->getComponents() == components); + + mImages[i] = new LLImageGL(resolution, resolution, components, TRUE); + mImages[i]->setTarget(mTargets[i], LLTexUnit::TT_CUBE_MAP); + mRawImages[i] = rawimages[i]; + mImages[i]->createGLTexture(0, mRawImages[i], texname); + + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_CUBE_MAP, texname); + mImages[i]->setAddressMode(LLTexUnit::TAM_CLAMP); + stop_glerror(); + + mImages[i]->setSubImage(mRawImages[i], 0, 0, resolution, resolution); + } + enableTexture(0); + bind(); + mImages[0]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + glGenerateMipmap(GL_TEXTURE_CUBE_MAP); + gGL.getTexUnit(0)->disable(); + disable(); +} + +void LLCubeMap::generateMipMaps() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + + mImages[0]->setUseMipMaps(TRUE); + mImages[0]->setHasMipMaps(TRUE); + enableTexture(0); + bind(); + mImages[0]->setFilteringOption(LLTexUnit::TFO_BILINEAR); + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("cmgmm - glGenerateMipmap"); + glGenerateMipmap(GL_TEXTURE_CUBE_MAP); + } + gGL.getTexUnit(0)->disable(); + disable(); +} + GLuint LLCubeMap::getGLName() { return mImages[0]->getTexName(); @@ -256,191 +324,6 @@ void LLCubeMap::restoreMatrix() }*/ } -void LLCubeMap::setReflection (void) -{ - gGL.getTexUnit(mTextureStage)->bindManual(LLTexUnit::TT_CUBE_MAP, getGLName()); - mImages[0]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - mImages[0]->setAddressMode(LLTexUnit::TAM_CLAMP); -} - -LLVector3 LLCubeMap::map(U8 side, U16 v_val, U16 h_val) const -{ - LLVector3 dir; - - const U8 curr_coef = side >> 1; // 0/1 = X axis, 2/3 = Y, 4/5 = Z - const S8 side_dir = (((side & 1) << 1) - 1); // even = -1, odd = 1 - const U8 i_coef = (curr_coef + 1) % 3; - const U8 j_coef = (i_coef + 1) % 3; - - dir.mV[curr_coef] = side_dir; - - switch (side) - { - case 0: // negative X - dir.mV[i_coef] = -F32((v_val<<1) + 1) / RESOLUTION + 1; - dir.mV[j_coef] = F32((h_val<<1) + 1) / RESOLUTION - 1; - break; - case 1: // positive X - dir.mV[i_coef] = -F32((v_val<<1) + 1) / RESOLUTION + 1; - dir.mV[j_coef] = -F32((h_val<<1) + 1) / RESOLUTION + 1; - break; - case 2: // negative Y - dir.mV[i_coef] = -F32((v_val<<1) + 1) / RESOLUTION + 1; - dir.mV[j_coef] = F32((h_val<<1) + 1) / RESOLUTION - 1; - break; - case 3: // positive Y - dir.mV[i_coef] = F32((v_val<<1) + 1) / RESOLUTION - 1; - dir.mV[j_coef] = F32((h_val<<1) + 1) / RESOLUTION - 1; - break; - case 4: // negative Z - dir.mV[i_coef] = -F32((h_val<<1) + 1) / RESOLUTION + 1; - dir.mV[j_coef] = -F32((v_val<<1) + 1) / RESOLUTION + 1; - break; - case 5: // positive Z - dir.mV[i_coef] = -F32((h_val<<1) + 1) / RESOLUTION + 1; - dir.mV[j_coef] = F32((v_val<<1) + 1) / RESOLUTION - 1; - break; - default: - dir.mV[i_coef] = F32((v_val<<1) + 1) / RESOLUTION - 1; - dir.mV[j_coef] = F32((h_val<<1) + 1) / RESOLUTION - 1; - } - - dir.normVec(); - return dir; -} - - -BOOL LLCubeMap::project(F32& v_val, F32& h_val, BOOL& outside, - U8 side, const LLVector3& dir) const -{ - const U8 curr_coef = side >> 1; // 0/1 = X axis, 2/3 = Y, 4/5 = Z - const S8 side_dir = (((side & 1) << 1) - 1); // even = -1, odd = 1 - const U8 i_coef = (curr_coef + 1) % 3; - const U8 j_coef = (i_coef + 1) % 3; - - outside = TRUE; - if (side_dir * dir.mV[curr_coef] < 0) - return FALSE; - - LLVector3 ray; - - F32 norm_val = fabs(dir.mV[curr_coef]); - - if (norm_val < epsilon) - norm_val = 1e-5f; - - ray.mV[curr_coef] = side_dir; - ray.mV[i_coef] = dir.mV[i_coef] / norm_val; - ray.mV[j_coef] = dir.mV[j_coef] / norm_val; - - - const F32 i_val = (ray.mV[i_coef] + 1) * 0.5f * RESOLUTION; - const F32 j_val = (ray.mV[j_coef] + 1) * 0.5f * RESOLUTION; - - switch (side) - { - case 0: // negative X - v_val = RESOLUTION - i_val; - h_val = j_val; - break; - case 1: // positive X - v_val = RESOLUTION - i_val; - h_val = RESOLUTION - j_val; - break; - case 2: // negative Y - v_val = RESOLUTION - i_val; - h_val = j_val; - break; - case 3: // positive Y - v_val = i_val; - h_val = j_val; - break; - case 4: // negative Z - v_val = RESOLUTION - j_val; - h_val = RESOLUTION - i_val; - break; - case 5: // positive Z - v_val = RESOLUTION - j_val; - h_val = i_val; - break; - default: - v_val = i_val; - h_val = j_val; - } - - outside = ((v_val < 0) || (v_val > RESOLUTION) || - (h_val < 0) || (h_val > RESOLUTION)); - - return TRUE; -} - -BOOL LLCubeMap::project(F32& v_min, F32& v_max, F32& h_min, F32& h_max, - U8 side, LLVector3 dir[4]) const -{ - v_min = h_min = RESOLUTION; - v_max = h_max = 0; - - BOOL fully_outside = TRUE; - for (U8 vtx = 0; vtx < 4; ++vtx) - { - F32 v_val, h_val; - BOOL outside; - BOOL consider = project(v_val, h_val, outside, side, dir[vtx]); - if (!outside) - fully_outside = FALSE; - if (consider) - { - if (v_val < v_min) v_min = v_val; - if (v_val > v_max) v_max = v_val; - if (h_val < h_min) h_min = h_val; - if (h_val > h_max) h_max = h_val; - } - } - - v_min = llmax(0.0f, v_min); - v_max = llmin(RESOLUTION - epsilon, v_max); - h_min = llmax(0.0f, h_min); - h_max = llmin(RESOLUTION - epsilon, h_max); - - return !fully_outside; -} - - -void LLCubeMap::paintIn(LLVector3 dir[4], const LLColor4U& col) -{ - LL_PROFILE_ZONE_SCOPED; - F32 v_min, v_max, h_min, h_max; - LLVector3 center = dir[0] + dir[1] + dir[2] + dir[3]; - center.normVec(); - - for (U8 side = 0; side < 6; ++side) - { - if (!project(v_min, v_max, h_min, h_max, side, dir)) - continue; - - U8 *td = mRawImages[side]->getData(); - - U16 v_minu = (U16) v_min; - U16 v_maxu = (U16) (ceil(v_max) + 0.5); - U16 h_minu = (U16) h_min; - U16 h_maxu = (U16) (ceil(h_max) + 0.5); - - for (U16 v = v_minu; v < v_maxu; ++v) - for (U16 h = h_minu; h < h_maxu; ++h) - //for (U16 v = 0; v < RESOLUTION; ++v) - // for (U16 h = 0; h < RESOLUTION; ++h) - { - const LLVector3 ray = map(side, v, h); - if (ray * center > 0.999) - { - const U32 offset = (RESOLUTION * v + h) * 4; - for (U8 cc = 0; cc < 3; ++cc) - td[offset + cc] = U8((td[offset + cc] + col.mV[cc]) * 0.5); - } - } - mImages[side]->setSubImage(mRawImages[side], 0, 0, RESOLUTION, RESOLUTION); - } -} void LLCubeMap::destroyGL() { diff --git a/indra/llrender/llcubemap.h b/indra/llrender/llcubemap.h index a01636d8d4..b9e081cea3 100644 --- a/indra/llrender/llcubemap.h +++ b/indra/llrender/llcubemap.h @@ -40,6 +40,17 @@ class LLCubeMap : public LLRefCount public: LLCubeMap(bool init_as_srgb); void init(const std::vector<LLPointer<LLImageRaw> >& rawimages); + + // initialize as an undefined cubemap at the given resolution + // used for render-to-cubemap operations + // avoids usage of LLImageRaw + void initReflectionMap(U32 resolution, U32 components = 3); + + // init from environment map images + // Similar to init, but takes ownership of rawimages and makes this cubemap + // respect the resolution of rawimages + // Raw images must point to array of six square images that are all the same resolution + void initEnvironmentMap(const std::vector<LLPointer<LLImageRaw> >& rawimages); void initGL(); void initRawData(const std::vector<LLPointer<LLImageRaw> >& rawimages); void initGLData(); @@ -54,18 +65,15 @@ public: void disableTexture(void); void setMatrix(S32 stage); void restoreMatrix(); - void setReflection (void); - void finishPaint(); + U32 getResolution() { return mImages[0].notNull() ? mImages[0]->getWidth(0) : 0; } + + // generate mip maps for this Cube Map using GL + // NOTE: Cube Map MUST already be resident in VRAM + void generateMipMaps(); GLuint getGLName(); - LLVector3 map(U8 side, U16 v_val, U16 h_val) const; - BOOL project(F32& v_val, F32& h_val, BOOL& outside, - U8 side, const LLVector3& dir) const; - BOOL project(F32& v_min, F32& v_max, F32& h_min, F32& h_max, - U8 side, LLVector3 dir[4]) const; - void paintIn(LLVector3 dir[4], const LLColor4U& col); void destroyGL(); public: diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp new file mode 100644 index 0000000000..438d92cdba --- /dev/null +++ b/indra/llrender/llcubemaparray.cpp @@ -0,0 +1,157 @@ +/** + * @file llcubemaparray.cpp + * @brief LLCubeMap class implementation + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +#include "linden_common.h" + +#include "llworkerthread.h" + +#include "llcubemaparray.h" + +#include "v4coloru.h" +#include "v3math.h" +#include "v3dmath.h" +#include "m3math.h" +#include "m4math.h" + +#include "llrender.h" +#include "llglslshader.h" + +#include "llglheaders.h" + +//#pragma optimize("", off) + +// MUST match order of OpenGL face-layers +GLenum LLCubeMapArray::sTargets[6] = +{ + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB +}; + +LLVector3 LLCubeMapArray::sLookVecs[6] = +{ + LLVector3(1, 0, 0), + LLVector3(-1, 0, 0), + LLVector3(0, 1, 0), + LLVector3(0, -1, 0), + LLVector3(0, 0, 1), + LLVector3(0, 0, -1) +}; + +LLVector3 LLCubeMapArray::sUpVecs[6] = +{ + LLVector3(0, -1, 0), + LLVector3(0, -1, 0), + LLVector3(0, 0, 1), + LLVector3(0, 0, -1), + LLVector3(0, -1, 0), + LLVector3(0, -1, 0) +}; + +LLVector3 LLCubeMapArray::sClipToCubeLookVecs[6] = +{ + LLVector3(0, 0, -1), //GOOD + LLVector3(0, 0, 1), //GOOD + + LLVector3(1, 0, 0), // GOOD + LLVector3(1, 0, 0), // GOOD + + LLVector3(1, 0, 0), + LLVector3(-1, 0, 0), +}; + +LLVector3 LLCubeMapArray::sClipToCubeUpVecs[6] = +{ + LLVector3(-1, 0, 0), //GOOD + LLVector3(1, 0, 0), //GOOD + + LLVector3(0, 1, 0), // GOOD + LLVector3(0, -1, 0), // GOOD + + LLVector3(0, 0, -1), + LLVector3(0, 0, 1) +}; + +LLCubeMapArray::LLCubeMapArray() + : mTextureStage(0) +{ + +} + +LLCubeMapArray::~LLCubeMapArray() +{ +} + +void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count) +{ + U32 texname = 0; + + LLImageGL::generateTextures(1, &texname); + + mImage = new LLImageGL(resolution, resolution, components, TRUE); + mImage->setTexName(texname); + mImage->setTarget(sTargets[0], LLTexUnit::TT_CUBE_MAP_ARRAY); + + mImage->setUseMipMaps(TRUE); + mImage->setHasMipMaps(TRUE); + + bind(0); + + glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY_ARB, 0, GL_RGB, resolution, resolution, count*6, 0, + GL_RGB, GL_UNSIGNED_BYTE, nullptr); + + mImage->setAddressMode(LLTexUnit::TAM_CLAMP); + + mImage->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + + glGenerateMipmap(GL_TEXTURE_CUBE_MAP_ARRAY_ARB); + + unbind(); +} + +void LLCubeMapArray::bind(S32 stage) +{ + mTextureStage = stage; + gGL.getTexUnit(stage)->bindManual(LLTexUnit::TT_CUBE_MAP_ARRAY, getGLName(), TRUE); +} + +void LLCubeMapArray::unbind() +{ + gGL.getTexUnit(mTextureStage)->unbind(LLTexUnit::TT_CUBE_MAP_ARRAY); + mTextureStage = -1; +} + +GLuint LLCubeMapArray::getGLName() +{ + return mImage->getTexName(); +} + +void LLCubeMapArray::destroyGL() +{ + mImage = NULL; +} diff --git a/indra/llrender/llcubemaparray.h b/indra/llrender/llcubemaparray.h new file mode 100644 index 0000000000..cbc0692afb --- /dev/null +++ b/indra/llrender/llcubemaparray.h @@ -0,0 +1,67 @@ +/** + * @file llcubemaparray.h + * @brief LLCubeMap class definition + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#pragma once + +#include "llgl.h" + +#include <vector> + +class LLVector3; + +class LLCubeMapArray : public LLRefCount +{ +public: + LLCubeMapArray(); + + static GLenum sTargets[6]; + + // look and up vectors for each cube face (agent space) + static LLVector3 sLookVecs[6]; + static LLVector3 sUpVecs[6]; + + // look and up vectors for each cube face (clip space) + static LLVector3 sClipToCubeLookVecs[6]; + static LLVector3 sClipToCubeUpVecs[6]; + + // allocate a cube map array + // res - resolution of each cube face + // components - number of components per pixel + // count - number of cube maps in the array + void allocate(U32 res, U32 components, U32 count); + void bind(S32 stage); + void unbind(); + + GLuint getGLName(); + + void destroyGL(); + +protected: + friend class LLTexUnit; + ~LLCubeMapArray(); + LLPointer<LLImageGL> mImage; + S32 mTextureStage; +}; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 2b7ce155f6..8ebaf77eec 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -86,30 +86,31 @@ void APIENTRY gl_debug_callback(GLenum source, const GLchar* message, GLvoid* userParam) { - if (severity != GL_DEBUG_SEVERITY_HIGH_ARB && - severity != GL_DEBUG_SEVERITY_MEDIUM_ARB && - severity != GL_DEBUG_SEVERITY_LOW_ARB) + if (severity != GL_DEBUG_SEVERITY_HIGH_ARB // && + //severity != GL_DEBUG_SEVERITY_MEDIUM_ARB && + //severity != GL_DEBUG_SEVERITY_LOW_ARB + ) { //suppress out-of-spec messages sent by nvidia driver (mostly vertexbuffer hints) return; } - if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) - { - LL_WARNS() << "----- GL ERROR --------" << LL_ENDL; - } - else - { - LL_WARNS() << "----- GL WARNING -------" << LL_ENDL; - } - LL_WARNS() << "Type: " << std::hex << type << LL_ENDL; - LL_WARNS() << "ID: " << std::hex << id << LL_ENDL; - LL_WARNS() << "Severity: " << std::hex << severity << LL_ENDL; - LL_WARNS() << "Message: " << message << LL_ENDL; - LL_WARNS() << "-----------------------" << LL_ENDL; - if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) - { - LL_ERRS() << "Halting on GL Error" << LL_ENDL; - } + if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) + { + LL_WARNS() << "----- GL ERROR --------" << LL_ENDL; + } + else + { + LL_WARNS() << "----- GL WARNING -------" << LL_ENDL; + } + LL_WARNS() << "Type: " << std::hex << type << LL_ENDL; + LL_WARNS() << "ID: " << std::hex << id << LL_ENDL; + LL_WARNS() << "Severity: " << std::hex << severity << LL_ENDL; + LL_WARNS() << "Message: " << message << LL_ENDL; + LL_WARNS() << "-----------------------" << LL_ENDL; + if (severity == GL_DEBUG_SEVERITY_HIGH_ARB) + { + LL_ERRS() << "Halting on GL Error" << LL_ENDL; + } } #endif @@ -312,6 +313,15 @@ PFNGLGETUNIFORMIVARBPROC glGetUniformivARB = NULL; PFNGLGETSHADERSOURCEARBPROC glGetShaderSourceARB = NULL; PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL; +// GL_ARB_uniform_buffer_object +PFNGLGETUNIFORMINDICESPROC glGetUniformIndices = NULL; +PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv = NULL; +PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName = NULL; +PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex = NULL; +PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv = NULL; +PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName = NULL; +PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding = NULL; + #if LL_WINDOWS PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; #endif @@ -432,6 +442,7 @@ LLGLManager::LLGLManager() : mHasTextureRectangle(FALSE), mHasTextureMultisample(FALSE), mHasTransformFeedback(FALSE), + mHasUniformBufferObject(FALSE), mMaxSampleMaskWords(0), mMaxColorTextureSamples(0), mMaxDepthTextureSamples(0), @@ -440,6 +451,7 @@ LLGLManager::LLGLManager() : mHasAnisotropic(FALSE), mHasARBEnvCombine(FALSE), mHasCubeMap(FALSE), + mHasCubeMapArray(FALSE), mHasDebugOutput(FALSE), mIsAMD(FALSE), @@ -1053,6 +1065,8 @@ void LLGLManager::initExtensions() mHasTextureMultisample = ExtensionExists("GL_ARB_texture_multisample", gGLHExts.mSysExts); mHasDebugOutput = ExtensionExists("GL_ARB_debug_output", gGLHExts.mSysExts); mHasTransformFeedback = mGLVersion >= 4.f ? TRUE : FALSE; + mHasUniformBufferObject = ExtensionExists("GL_ARB_uniform_buffer_object", gGLHExts.mSysExts); + mHasCubeMapArray = ExtensionExists("GL_ARB_texture_cube_map_array", gGLHExts.mSysExts); #if !LL_DARWIN mHasPointParameters = ExtensionExists("GL_ARB_point_parameters", gGLHExts.mSysExts); #endif @@ -1165,6 +1179,10 @@ void LLGLManager::initExtensions() { LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_draw_buffers" << LL_ENDL; } + if (!mHasCubeMapArray) + { + LL_INFOS("RenderInit") << "Couldn't initialize GL_ARB_texture_cube_map_array" << LL_ENDL; + } // Disable certain things due to known bugs if (mIsIntel && mHasMipMapGeneration) @@ -1285,6 +1303,10 @@ void LLGLManager::initExtensions() mGLMaxVertexRange = 0; mGLMaxIndexRange = 0; } + + // same with glTexImage3D et al + glTexImage3D = (PFNGLTEXIMAGE3DPROC)GLH_EXT_GET_PROC_ADDRESS("glTexImage3D"); + glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)GLH_EXT_GET_PROC_ADDRESS("glCopyTexSubImage3D"); #endif // !LL_LINUX || LL_LINUX_NV_GL_HEADERS #if LL_LINUX_NV_GL_HEADERS // nvidia headers are critically different from mesa-esque @@ -1318,6 +1340,17 @@ void LLGLManager::initExtensions() glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glPointParameterfvARB"); } + if (mHasUniformBufferObject) + { + glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)GLH_EXT_GET_PROC_ADDRESS("glGetUniformIndices"); + glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetUniformIndices"); + glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)GLH_EXT_GET_PROC_ADDRESS("glGetActiveUniformName"); + glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)GLH_EXT_GET_PROC_ADDRESS("glGetUniformBlockIndex"); + glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetActiveUniformBlockiv"); + glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)GLH_EXT_GET_PROC_ADDRESS("glGetActiveUniformBlockName"); + glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)GLH_EXT_GET_PROC_ADDRESS("glUniformBlockBinding"); + } + // Assume shader capabilities glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteObjectARB"); glGetHandleARB = (PFNGLGETHANDLEARBPROC) GLH_EXT_GET_PROC_ADDRESS("glGetHandleARB"); diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 33cb0706c4..3c40f85654 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -105,6 +105,7 @@ public: BOOL mHasTextureRectangle; BOOL mHasTextureMultisample; BOOL mHasTransformFeedback; + BOOL mHasUniformBufferObject; S32 mMaxSampleMaskWords; S32 mMaxColorTextureSamples; S32 mMaxDepthTextureSamples; @@ -114,6 +115,7 @@ public: BOOL mHasAnisotropic; BOOL mHasARBEnvCombine; BOOL mHasCubeMap; + BOOL mHasCubeMapArray; BOOL mHasDebugOutput; BOOL mHassRGBTexture; BOOL mHassRGBFramebuffer; diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 3d93cc0762..154f1aa2bd 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -564,15 +564,26 @@ extern PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB; extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB; +// GL_ARB_uniform_buffer_object +extern PFNGLGETUNIFORMINDICESPROC glGetUniformIndices; +extern PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv; +extern PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName; +extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex; +extern PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv; +extern PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName; +extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; + #elif LL_DARWIN //---------------------------------------------------------------------------- // LL_DARWIN +#define GL_GLEXT_LEGACY #include <OpenGL/gl.h> #include <OpenGL/glu.h> #define GL_EXT_separate_specular_color 1 -#include <OpenGL/glext.h> +#define GL_GLEXT_PROTOTYPES +#include "GL/glext.h" #include "GL/glh_extensions.h" @@ -821,14 +832,7 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); #define glGetQueryiv glGetQueryivARB #define glGetQueryObjectiv glGetQueryObjectivARB #include <tracy/TracyOpenGL.hpp> - - #define LL_PROFILER_GPU_ZONEC(name,color) TracyGpuZoneC(name,color); - #define LL_PROFILER_GPU_COLLECT TracyGpuCollect - #define LL_PROFILER_GPU_CONTEXT TracyGpuContext -#else - #define LL_PROFILER_GPU_ZONEC(name,color) (void)name;(void)color; - #define LL_PROFILER_GPU_COLLECT - #define LL_PROFILER_GPU_CONTEXT #endif + #endif // LL_LLGLHEADERS_H diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 185c1450c8..67f82c9c5e 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -452,7 +452,7 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes, #ifdef GL_INTERLEAVED_ATTRIBS if (varying_count > 0 && varyings) { - glTransformFeedbackVaryings(mProgramObject, varying_count, varyings, GL_INTERLEAVED_ATTRIBS); + glTransformFeedbackVaryings((GLuint64) mProgramObject, varying_count, varyings, GL_INTERLEAVED_ATTRIBS); } #endif @@ -738,7 +738,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> * { //found it mUniform[i] = location; - mTexture[i] = mapUniformTextureChannel(location, type); + mTexture[i] = mapUniformTextureChannel(location, type, size); return; } } @@ -752,7 +752,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> * { //found it mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location; - mTexture[i+LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type); + mTexture[i+LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type, size); return; } } @@ -775,16 +775,38 @@ void LLGLSLShader::removePermutation(std::string name) mDefines[name].erase(); } -GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type) +GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type, GLint size) { LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; if ((type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB) || - type == GL_SAMPLER_2D_MULTISAMPLE) + type == GL_SAMPLER_2D_MULTISAMPLE || + type == GL_SAMPLER_CUBE_MAP_ARRAY_ARB) { //this here is a texture - glUniform1iARB(location, mActiveTextureChannels); - LL_DEBUGS("ShaderUniform") << "Assigned to texture channel " << mActiveTextureChannels << LL_ENDL; - return mActiveTextureChannels++; + GLint ret = mActiveTextureChannels; + if (size == 1) + { + glUniform1iARB(location, mActiveTextureChannels); + LL_DEBUGS("ShaderUniform") << "Assigned to texture channel " << mActiveTextureChannels << LL_ENDL; + mActiveTextureChannels++; + } + else + { + //is array of textures, make sequential after this texture + GLint channel[32]; // <=== only support up to 32 texture channels + llassert(size <= 32); + size = llmin(size, 32); + for (int i = 0; i < size; ++i) + { + channel[i] = mActiveTextureChannels++; + } + glUniform1ivARB(location, size, channel); + LL_DEBUGS("ShaderUniform") << "Assigned to texture channel " << + (mActiveTextureChannels-size) << " through " << (mActiveTextureChannels-1) << LL_ENDL; + } + + llassert(mActiveTextureChannels <= 32); // too many textures (probably) + return ret; } return -1; } @@ -832,6 +854,9 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms) As example where this situation appear see: "Deferred Material Shader 28/29/30/31" And tickets: MAINT-4165, MAINT-4839, MAINT-3568, MAINT-6437 + + --- davep TODO -- pretty sure the entire block here is superstitious and that the uniform index has nothing to do with the texture channel + texture channel should follow the uniform VALUE */ @@ -840,6 +865,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms) S32 bumpMap = glGetUniformLocationARB(mProgramObject, "bumpMap"); S32 altDiffuseMap = glGetUniformLocationARB(mProgramObject, "altDiffuseMap"); S32 environmentMap = glGetUniformLocationARB(mProgramObject, "environmentMap"); + S32 reflectionMap = glGetUniformLocationARB(mProgramObject, "reflectionMap"); std::set<S32> skip_index; @@ -882,6 +908,12 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms) continue; } + if (-1 == reflectionMap && std::string(name) == "reflectionMap") + { + reflectionMap = i; + continue; + } + if (-1 == altDiffuseMap && std::string(name) == "altDiffuseMap") { altDiffuseMap = i; @@ -892,8 +924,9 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms) bool specularDiff = specularMap < diffuseMap && -1 != specularMap; bool bumpLessDiff = bumpMap < diffuseMap && -1 != bumpMap; bool envLessDiff = environmentMap < diffuseMap && -1 != environmentMap; + bool refLessDiff = reflectionMap < diffuseMap && -1 != reflectionMap; - if (specularDiff || bumpLessDiff || envLessDiff) + if (specularDiff || bumpLessDiff || envLessDiff || refLessDiff) { mapUniform(diffuseMap, uniforms); skip_index.insert(diffuseMap); @@ -912,6 +945,11 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms) mapUniform(environmentMap, uniforms); skip_index.insert(environmentMap); } + + if (-1 != reflectionMap) { + mapUniform(reflectionMap, uniforms); + skip_index.insert(reflectionMap); + } } } @@ -1252,6 +1290,30 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) } } +void LLGLSLShader::uniform4iv(U32 index, U32 count, const GLint* v) +{ + if (mProgramObject) + { + if (mUniform.size() <= index) + { + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; + return; + } + + if (mUniform[index] >= 0) + { + const auto& iter = mValue.find(mUniform[index]); + LLVector4 vec(v[0], v[1], v[2], v[3]); + if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) + { + glUniform1ivARB(mUniform[index], count, v); + mValue[mUniform[index]] = vec; + } + } + } +} + + void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject) @@ -1489,6 +1551,40 @@ void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v) } } +void LLGLSLShader::uniform1iv(const LLStaticHashedString& uniform, U32 count, const GLint* v) +{ + GLint location = getUniformLocation(uniform); + + if (location >= 0) + { + LLVector4 vec(v[0], 0, 0, 0); + const auto& iter = mValue.find(location); + if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; + glUniform1ivARB(location, count, v); + mValue[location] = vec; + } + } +} + +void LLGLSLShader::uniform4iv(const LLStaticHashedString& uniform, U32 count, const GLint* v) +{ + GLint location = getUniformLocation(uniform); + + if (location >= 0) + { + LLVector4 vec(v[0], v[1], v[2], v[3]); + const auto& iter = mValue.find(location); + if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; + glUniform4ivARB(location, count, v); + mValue[location] = vec; + } + } +} + void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j) { GLint location = getUniformLocation(uniform); diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 85e83dbcb9..68e1a8954d 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -52,12 +52,13 @@ public: bool hasShadows; bool hasAmbientOcclusion; bool hasSrgb; - bool encodesNormal; + bool encodesNormal; // include: shaders\class1\environment\encodeNormF.glsl bool isDeferred; bool hasIndirect; S32 mIndexedTextureChannels; bool disableTextureIndex; bool hasAlphaMask; + bool hasReflectionProbes = false; bool attachNothing; // char numLights; @@ -178,6 +179,7 @@ public: void uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z); void uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void uniform1iv(U32 index, U32 count, const GLint* i); + void uniform4iv(U32 index, U32 count, const GLint* i); void uniform1fv(U32 index, U32 count, const GLfloat* v); void uniform2fv(U32 index, U32 count, const GLfloat* v); void uniform3fv(U32 index, U32 count, const GLfloat* v); @@ -188,6 +190,8 @@ public: void uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); void uniform1i(const LLStaticHashedString& uniform, GLint i); + void uniform1iv(const LLStaticHashedString& uniform, U32 count, const GLint* v); + void uniform4iv(const LLStaticHashedString& uniform, U32 count, const GLint* v); void uniform1f(const LLStaticHashedString& uniform, GLfloat v); void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y); void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z); @@ -207,7 +211,7 @@ public: GLint getUniformLocation(U32 index); GLint getAttribLocation(U32 attrib); - GLint mapUniformTextureChannel(GLint location, GLenum type); + GLint mapUniformTextureChannel(GLint location, GLenum type, GLint size); void clearPermutations(); void addPermutation(std::string name, std::string value); diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 9bd3a0a6b0..6215727de0 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -53,13 +53,75 @@ const F32 MIN_TEXTURE_LIFETIME = 10.f; //assumes i is a power of 2 > 0 U32 wpo2(U32 i); + +// texture memory accounting (for OS X) +static LLMutex sTexMemMutex; +static std::unordered_map<U32, U32> sTextureAllocs; +static U64 sTextureBytes = 0; + +// track a texture alloc on the currently bound texture. +// asserts that no currently tracked alloc exists +static void alloc_tex_image(U32 width, U32 height, U32 pixformat) +{ + U32 texUnit = gGL.getCurrentTexUnitIndex(); + U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture(); + S32 size = LLImageGL::dataFormatBytes(pixformat, width, height); + + llassert(size >= 0); + + sTexMemMutex.lock(); + llassert(sTextureAllocs.find(texName) == sTextureAllocs.end()); + + sTextureAllocs[texName] = size; + sTextureBytes += size; + + sTexMemMutex.unlock(); +} + +// track texture free on given texName +static void free_tex_image(U32 texName) +{ + sTexMemMutex.lock(); + auto iter = sTextureAllocs.find(texName); + if (iter != sTextureAllocs.end()) + { + llassert(iter->second <= sTextureBytes); // sTextureBytes MUST NOT go below zero + + sTextureBytes -= iter->second; + + sTextureAllocs.erase(iter); + } + + sTexMemMutex.unlock(); +} + +// track texture free on given texNames +static void free_tex_images(U32 count, const U32* texNames) +{ + for (int i = 0; i < count; ++i) + { + free_tex_image(texNames[i]); + } +} + +// track texture free on currently bound texture +static void free_cur_tex_image() +{ + U32 texUnit = gGL.getCurrentTexUnitIndex(); + U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture(); + free_tex_image(texName); +} + +// static +U64 LLImageGL::getTextureBytesAllocated() +{ + return sTextureBytes; +} + //statics U32 LLImageGL::sUniqueCount = 0; U32 LLImageGL::sBindCount = 0; -S32Bytes LLImageGL::sGlobalTextureMemory(0); -S32Bytes LLImageGL::sBoundTextureMemory(0); -S32Bytes LLImageGL::sCurBoundTextureMemory(0); S32 LLImageGL::sCount = 0; BOOL LLImageGL::sGlobalUseAnisotropic = FALSE; @@ -220,6 +282,7 @@ S32 LLImageGL::dataFormatBits(S32 dataformat) case GL_RGBA: return 32; case GL_SRGB_ALPHA: return 32; case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac + case GL_DEPTH_COMPONENT: return 24; default: LL_ERRS() << "LLImageGL::Unknown format: " << dataformat << LL_ENDL; return 0; @@ -282,15 +345,6 @@ void LLImageGL::updateStats(F32 current_time) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; sLastFrameTime = current_time; - sBoundTextureMemory = sCurBoundTextureMemory; - sCurBoundTextureMemory = S32Bytes(0); -} - -//static -S32 LLImageGL::updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) -{ - LLImageGL::sCurBoundTextureMemory += mem ; - return LLImageGL::sCurBoundTextureMemory.value(); } //---------------------------------------------------------------------------- @@ -623,7 +677,7 @@ void LLImageGL::forceUpdateBindStats(void) const mLastBindTime = sLastFrameTime; } -BOOL LLImageGL::updateBindStats(S32Bytes tex_mem) const +BOOL LLImageGL::updateBindStats() const { if (mTexName != 0) { @@ -635,7 +689,6 @@ BOOL LLImageGL::updateBindStats(S32Bytes tex_mem) const { // we haven't accounted for this texture yet this frame sUniqueCount++; - updateBoundTexMem(tex_mem, mComponents, mCategory); mLastBindTime = sLastFrameTime; return TRUE ; @@ -812,6 +865,7 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32 if (LLRender::sGLCoreProfile) { + LL_PROFILE_GPU_ZONE("generate mip map"); glGenerateMipmap(mTarget); } stop_glerror(); @@ -1231,6 +1285,7 @@ void LLImageGL::deleteTextures(S32 numTextures, const U32 *textures) { if (gGLManager.mInited) { + free_tex_images(numTextures, textures); glDeleteTextures(numTextures, textures); } } @@ -1353,7 +1408,10 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt stop_glerror(); { LL_PROFILE_ZONE_NAMED("glTexImage2D"); + + free_cur_tex_image(); glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, use_scratch ? scratch : pixels); + alloc_tex_image(width, height, pixformat); } stop_glerror(); @@ -1519,6 +1577,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ // Call with void data, vmem is allocated but unitialized { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + LL_PROFILE_GPU_ZONE("createGLTexture"); checkActiveThread(); bool main_thread = on_main_thread(); @@ -1599,11 +1658,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ // things will break if we don't unbind after creation gGL.getTexUnit(0)->unbind(mBindTarget); - if (old_texname != 0) - { - sGlobalTextureMemory -= mTextureMemory; - } - //if we're on the image loading thread, be sure to delete old_texname and update mTexName on the main thread if (!defer_copy) { @@ -1624,7 +1678,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ mTextureMemory = (S32Bytes)getMipBytes(mCurrentDiscardLevel); - sGlobalTextureMemory += mTextureMemory; mTexelsInGLTexture = getWidth() * getHeight(); // mark this as bound at this point, so we don't throw it out immediately @@ -1634,51 +1687,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ return TRUE; } -void LLImageGLThread::updateClass() -{ - LL_PROFILE_ZONE_SCOPED; - - // update available vram one per second - static LLFrameTimer sTimer; - - if (sTimer.getElapsedSeconds() < 1.f) - { - return; - } - - sTimer.reset(); - - auto func = []() - { - if (gGLManager.mHasATIMemInfo) - { - S32 meminfo[4]; - glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo); - LLImageGLThread::sFreeVRAMMegabytes = meminfo[0]; - - } - else if (gGLManager.mHasNVXMemInfo) - { - S32 free_memory; - glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &free_memory); - LLImageGLThread::sFreeVRAMMegabytes = free_memory / 1024; - } - }; - - - // post update to background thread if available, otherwise execute immediately - auto queue = LL::WorkQueue::getInstance("LLImageGL"); - if (sEnabled) - { - queue->post(func); - } - else - { - llassert(queue == nullptr); - func(); - } -} - void LLImageGL::syncToMainThread(LLGLuint new_tex_name) { LL_PROFILE_ZONE_SCOPED; @@ -1688,26 +1696,38 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name) LL_PROFILE_ZONE_NAMED("cglt - sync"); if (gGLManager.mHasSync) { - // post a sync to the main thread (will execute before tex name swap lambda below) - // glFlush calls here are partly superstitious and partly backed by observation - // on AMD hardware - glFlush(); - auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - glFlush(); - LL::WorkQueue::postMaybe( - mMainQueue, - [=]() - { - LL_PROFILE_ZONE_NAMED("cglt - wait sync"); - { - LL_PROFILE_ZONE_NAMED("glWaitSync"); - glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); - } + if (gGLManager.mIsNVIDIA) + { + // wait for texture upload to finish before notifying main thread + // upload is complete + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + glClientWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + glDeleteSync(sync); + } + else + { + // post a sync to the main thread (will execute before tex name swap lambda below) + // glFlush calls here are partly superstitious and partly backed by observation + // on AMD hardware + glFlush(); + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + LL::WorkQueue::postMaybe( + mMainQueue, + [=]() { - LL_PROFILE_ZONE_NAMED("glDeleteSync"); - glDeleteSync(sync); - } - }); + LL_PROFILE_ZONE_NAMED("cglt - wait sync"); + { + LL_PROFILE_ZONE_NAMED("glWaitSync"); + glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + } + { + LL_PROFILE_ZONE_NAMED("glDeleteSync"); + glDeleteSync(sync); + } + }); + } } else { @@ -1724,8 +1744,11 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name) syncTexName(new_tex_name); unref(); }); + + LL_PROFILER_GPU_COLLECT; } + void LLImageGL::syncTexName(LLGLuint texname) { if (texname != 0) @@ -1857,7 +1880,6 @@ void LLImageGL::destroyGLTexture() { if(mTextureMemory != S32Bytes(0)) { - sGlobalTextureMemory -= mTextureMemory; mTextureMemory = (S32Bytes)0; } @@ -2409,13 +2431,9 @@ void LLImageGL::checkActiveThread() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, nummips); */ -std::atomic<S32> LLImageGLThread::sFreeVRAMMegabytes(4096); //if free vram is unknown, default to 4GB - LLImageGLThread::LLImageGLThread(LLWindow* window) - // We want exactly one thread, but a very large capacity: we never want - // anyone, especially inner-loop render code, to have to block on post() - // because we're full. - : ThreadPool("LLImageGL", 1, 1024*1024) + // We want exactly one thread. + : ThreadPool("LLImageGL", 1) , mWindow(window) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -2438,8 +2456,3 @@ void LLImageGLThread::run() mWindow->destroySharedContext(mContext); } -S32 LLImageGLThread::getFreeVRAMMegabytes() -{ - return sFreeVRAMMegabytes; -} - diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 4d5b60d6bc..b4618fd35c 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -52,6 +52,13 @@ class LLImageGL : public LLRefCount { friend class LLTexUnit; public: + + // Get an estimate of how many bytes have been allocated in vram for textures. + // Does not include mipmaps. + // NOTE: multiplying this number by two gives a good estimate for total + // video memory usage based on testing in lagland against an NVIDIA GPU. + static U64 getTextureBytesAllocated(); + // These 2 functions replace glGenTextures() and glDeleteTextures() static void generateTextures(S32 numTextures, U32 *textures); static void deleteTextures(S32 numTextures, const U32 *textures); @@ -61,7 +68,7 @@ public: static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height); static S32 dataFormatComponents(S32 dataformat); - BOOL updateBindStats(S32Bytes tex_mem) const ; + BOOL updateBindStats() const ; F32 getTimePassedSinceLastBound(); void forceUpdateBindStats(void) const; @@ -73,9 +80,6 @@ public: static void restoreGL(); static void dirtyTexOptions(); - // Sometimes called externally for textures not using LLImageGL (should go away...) - static S32 updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) ; - static bool checkSize(S32 width, S32 height); //for server side use only. @@ -161,11 +165,11 @@ public: BOOL getUseMipMaps() const { return mUseMipMaps; } void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; } - + void setHasMipMaps(BOOL hasmips) { mHasMipMaps = hasmips; } void updatePickMask(S32 width, S32 height, const U8* data_in); BOOL getMask(const LLVector2 &tc); - void checkTexSize(bool forced = false) const ; + void checkTexSize(bool forced = false) const ; // Sets the addressing mode used to sample the texture // (such as wrapping, mirrored wrapping, and clamp) @@ -265,9 +269,6 @@ public: static F32 sLastFrameTime; // Global memory statistics - static S32Bytes sGlobalTextureMemory; // Tracks main memory texmem - static S32Bytes sBoundTextureMemory; // Tracks bound texmem for last completed frame - static S32Bytes sCurBoundTextureMemory; // Tracks bound texmem for current frame static U32 sBindCount; // Tracks number of texture binds for current frame static U32 sUniqueCount; // Tracks number of unique texture binds for current frame static BOOL sGlobalUseAnisotropic; @@ -327,12 +328,6 @@ public: // follows gSavedSettings "RenderGLMultiThreaded" static bool sEnabled; - // app should call this function periodically - static void updateClass(); - - // free video memory in megabytes - static std::atomic<S32> sFreeVRAMMegabytes; - LLImageGLThread(LLWindow* window); // post a function to be executed on the LLImageGL background thread @@ -344,8 +339,6 @@ public: void run() override; - static S32 getFreeVRAMMegabytes(); - private: LLWindow* mWindow; void* mContext = nullptr; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index a03a27cf94..e5bd19e91c 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -71,6 +71,7 @@ static const GLenum sGLTextureType[] = GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_CUBE_MAP_ARRAY_ARB, GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_3D }; @@ -223,7 +224,7 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind) enable(gl_tex->getTarget()); mCurrTexture = gl_tex->getTexName(); glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture); - if(gl_tex->updateBindStats(gl_tex->mTextureMemory)) + if(gl_tex->updateBindStats()) { texture->setActive() ; texture->updateBindStatsForTester() ; @@ -302,7 +303,7 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind, S32 mCurrTexture = texname; glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture); stop_glerror(); - texture->updateBindStats(texture->mTextureMemory); + texture->updateBindStats(); mHasMipMaps = texture->mHasMipMaps; if (texture->mTexOptionsDirty) { @@ -341,7 +342,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap) mCurrTexture = cubeMap->mImages[0]->getTexName(); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture); mHasMipMaps = cubeMap->mImages[0]->mHasMipMaps; - cubeMap->mImages[0]->updateBindStats(cubeMap->mImages[0]->mTextureMemory); + cubeMap->mImages[0]->updateBindStats(); if (cubeMap->mImages[0]->mTexOptionsDirty) { cubeMap->mImages[0]->mTexOptionsDirty = false; @@ -888,6 +889,9 @@ void LLRender::init() glCullFace(GL_BACK); + // necessary for reflection maps + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + if (sGLCoreProfile && !LLVertexBuffer::sUseVAO) { //bind a dummy vertex array object so we're core profile compliant #ifdef GL_ARB_vertex_array_object diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index e2489876e4..095ed400f4 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -52,7 +52,7 @@ class LLTexture ; #define LL_MATRIX_STACK_DEPTH 32 -class LLTexUnit +class LLTexUnit { friend class LLRender; public: @@ -63,6 +63,7 @@ public: TT_TEXTURE = 0, // Standard 2D Texture TT_RECT_TEXTURE, // Non power of 2 texture TT_CUBE_MAP, // 6-sided cube map texture + TT_CUBE_MAP_ARRAY, // Array of cube maps TT_MULTISAMPLE_TEXTURE, // see GL_ARB_texture_multisample TT_TEXTURE_3D, // standard 3D Texture TT_NONE, // No texture type is currently enabled diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 0408010513..fa46e0f7d0 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -119,6 +119,7 @@ void LLRenderTarget::resize(U32 resx, U32 resy) bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool stencil, LLTexUnit::eTextureType usage, bool use_fbo, S32 samples) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; resx = llmin(resx, (U32) gGLManager.mGLMaxTextureSize); resy = llmin(resy, (U32) gGLManager.mGLMaxTextureSize); @@ -219,6 +220,7 @@ void LLRenderTarget::releaseColorAttachment() bool LLRenderTarget::addColorAttachment(U32 color_fmt) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; if (color_fmt == 0) { return true; @@ -315,6 +317,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) bool LLRenderTarget::allocateDepth() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; if (mStencil) { //use render buffers where stencil buffers are in play @@ -395,6 +398,7 @@ void LLRenderTarget::shareDepthBuffer(LLRenderTarget& target) void LLRenderTarget::release() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; if (mDepth) { if (mStencil) @@ -469,6 +473,8 @@ void LLRenderTarget::release() void LLRenderTarget::bindTarget() { + llassert(mFBO); + if (mFBO) { stop_glerror(); @@ -484,13 +490,11 @@ void LLRenderTarget::bindTarget() GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3}; - LL_PROFILER_GPU_ZONEC( "gl.DrawBuffersARB", 0x4000FF ) glDrawBuffersARB(mTex.size(), drawbuffers); } if (mTex.empty()) { //no color buffer to draw to - LL_PROFILER_GPU_ZONEC( "gl.DrawBuffer", 0x0000FF ) glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); } @@ -511,6 +515,8 @@ void LLRenderTarget::bindTarget() void LLRenderTarget::clear(U32 mask_in) { + LL_PROFILE_GPU_ZONE("clear"); + llassert(mFBO); U32 mask = GL_COLOR_BUFFER_BIT; if (mUseDepth) { @@ -576,6 +582,7 @@ void LLRenderTarget::bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilt void LLRenderTarget::flush(bool fetch_depth) { gGL.flush(); + llassert(mFBO); if (!mFBO) { gGL.getTexUnit(0)->bind(this); @@ -675,6 +682,7 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0 } { + LL_PROFILE_GPU_ZONE("copyContentsToFramebuffer"); GLboolean write_depth = mask & GL_DEPTH_BUFFER_BIT ? TRUE : FALSE; LLGLDepthTest depth(write_depth, write_depth); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index c100c182dd..96fb764f75 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -218,6 +218,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } + if (features->hasReflectionProbes) + { + if (!shader->attachFragmentObject("deferred/reflectionProbeF.glsl")) + { + return FALSE; + } + } + if (features->hasAmbientOcclusion) { if (!shader->attachFragmentObject("deferred/aoUtil.glsl")) @@ -665,7 +673,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (file == NULL) { - LL_SHADER_LOADING_WARNS() << "GLSL Shader file not found: " << open_file_name << LL_ENDL; + LL_WARNS("ShaderLoading") << "GLSL Shader file not found: " << open_file_name << LL_ENDL; return 0; } @@ -712,8 +720,15 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade { if (major_version >= 4) { - //set version to 400 - shader_code_text[shader_code_count++] = strdup("#version 400\n"); + //set version to 400 or 420 + if (minor_version >= 20) + { + shader_code_text[shader_code_count++] = strdup("#version 420\n"); + } + else + { + shader_code_text[shader_code_count++] = strdup("#version 400\n"); + } } else if (major_version == 3) { @@ -772,7 +787,14 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade extra_code_text[extra_code_count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n"); } } - + + // Use alpha float to store bit flags + // See: C++: addDeferredAttachment(), shader: frag_data[2] + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS 0.0 \n"); // atmo kill + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS 0.34\n"); // bit 0 + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_PBR 0.67\n"); // bit 1 + extra_code_text[extra_code_count++] = strdup("#define GET_GBUFFER_FLAG(flag) (abs(norm.w-flag)< 0.1)\n"); + if (defines) { for (std::unordered_map<std::string,std::string>::iterator iter = defines->begin(); iter != defines->end(); ++iter) @@ -1148,13 +1170,19 @@ void LLShaderMgr::initAttribsAndUniforms() llassert(mReservedUniforms.size() == LLShaderMgr::PROJECTOR_AMBIENT_LOD+1); mReservedUniforms.push_back("color"); - + mReservedUniforms.push_back("emissiveColor"); + mReservedUniforms.push_back("metallicFactor"); + mReservedUniforms.push_back("roughnessFactor"); + mReservedUniforms.push_back("diffuseMap"); mReservedUniforms.push_back("altDiffuseMap"); mReservedUniforms.push_back("specularMap"); + mReservedUniforms.push_back("emissiveMap"); mReservedUniforms.push_back("bumpMap"); mReservedUniforms.push_back("bumpMap2"); mReservedUniforms.push_back("environmentMap"); + mReservedUniforms.push_back("reflectionProbes"); + mReservedUniforms.push_back("irradianceProbes"); mReservedUniforms.push_back("cloud_noise_texture"); mReservedUniforms.push_back("cloud_noise_texture_next"); mReservedUniforms.push_back("fullbright"); @@ -1201,6 +1229,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("minimum_alpha"); mReservedUniforms.push_back("emissive_brightness"); + // Deferred mReservedUniforms.push_back("shadow_matrix"); mReservedUniforms.push_back("env_mat"); mReservedUniforms.push_back("shadow_clip"); @@ -1225,8 +1254,9 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("depth_cutoff"); mReservedUniforms.push_back("norm_cutoff"); mReservedUniforms.push_back("shadow_target_width"); + mReservedUniforms.push_back("view_dir"); // DEFERRED_VIEW_DIR - llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH+1); + llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_VIEW_DIR+1); mReservedUniforms.push_back("tc_scale"); mReservedUniforms.push_back("rcp_screen_res"); @@ -1256,6 +1286,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("positionMap"); mReservedUniforms.push_back("diffuseRect"); mReservedUniforms.push_back("specularRect"); + mReservedUniforms.push_back("emissiveRect"); mReservedUniforms.push_back("noiseMap"); mReservedUniforms.push_back("lightFunc"); mReservedUniforms.push_back("lightMap"); @@ -1326,6 +1357,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("halo_map"); mReservedUniforms.push_back("moon_brightness"); mReservedUniforms.push_back("cloud_variance"); + mReservedUniforms.push_back("reflection_probe_ambiance"); mReservedUniforms.push_back("sh_input_r"); mReservedUniforms.push_back("sh_input_g"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 67c0d6ab10..9e8f848491 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -74,12 +74,18 @@ public: PROJECTOR_LOD, // "proj_lod" PROJECTOR_AMBIENT_LOD, // "proj_ambient_lod" DIFFUSE_COLOR, // "color" + EMISSIVE_COLOR, // "emissiveColor" + METALLIC_FACTOR, // "metallicFactor" + ROUGHNESS_FACTOR, // "roughnessFactor" DIFFUSE_MAP, // "diffuseMap" ALTERNATE_DIFFUSE_MAP, // "altDiffuseMap" SPECULAR_MAP, // "specularMap" + EMISSIVE_MAP, // "emissiveMap" BUMP_MAP, // "bumpMap" BUMP_MAP2, // "bumpMap2" ENVIRONMENT_MAP, // "environmentMap" + REFLECTION_PROBES, // "reflectionProbes" + IRRADIANCE_PROBES, // "irradianceProbes" CLOUD_NOISE_MAP, // "cloud_noise_texture" CLOUD_NOISE_MAP_NEXT, // "cloud_noise_texture_next" FULLBRIGHT, // "fullbright" @@ -142,6 +148,7 @@ public: DEFERRED_DEPTH_CUTOFF, // "depth_cutoff" DEFERRED_NORM_CUTOFF, // "norm_cutoff" DEFERRED_SHADOW_TARGET_WIDTH, // "shadow_target_width" + DEFERRED_VIEW_DIR, // "view_dir" FXAA_TC_SCALE, // "tc_scale" FXAA_RCP_SCREEN_RES, // "rcp_screen_res" @@ -168,6 +175,7 @@ public: DEFERRED_POSITION, // "positionMap" DEFERRED_DIFFUSE, // "diffuseRect" DEFERRED_SPECULAR, // "specularRect" + DEFERRED_EMISSIVE, // "emissiveRect" DEFERRED_NOISE, // "noiseMap" DEFERRED_LIGHTFUNC, // "lightFunc" DEFERRED_LIGHT, // "lightMap" @@ -242,6 +250,7 @@ public: CLOUD_VARIANCE, // "cloud_variance" + REFLECTION_PROBE_AMBIANCE, // "reflection_probe_ambiance" SH_INPUT_L1R, // "sh_input_r" SH_INPUT_L1G, // "sh_input_g" SH_INPUT_L1B, // "sh_input_b" diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 6338cab96a..b1b69f1508 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -624,7 +624,6 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi stop_glerror(); LLGLSLShader::startProfile(); - LL_PROFILER_GPU_ZONEC( "gl.DrawRangeElements", 0xFFFF00 ) glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, idx); LLGLSLShader::stopProfile(count, mode); @@ -642,7 +641,6 @@ void LLVertexBuffer::drawRangeFast(U32 mode, U32 start, U32 end, U32 count, U32 U16* idx = ((U16*)getIndicesPointer()) + indices_offset; - LL_PROFILER_GPU_ZONEC("gl.DrawRangeElements", 0xFFFF00) glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, idx); } @@ -688,8 +686,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const stop_glerror(); LLGLSLShader::startProfile(); - LL_PROFILER_GPU_ZONEC( "gl.DrawElements", 0xA0FFA0 ) - glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, + glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, ((U16*) getIndicesPointer()) + indices_offset); LLGLSLShader::stopProfile(count, mode); stop_glerror(); @@ -736,7 +733,6 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const LLGLSLShader::startProfile(); { - LL_PROFILER_GPU_ZONEC("gl.DrawArrays", 0xFF4040) glDrawArrays(sGLMode[mode], first, count); } LLGLSLShader::stopProfile(count, mode); |