From ed7bff58c47500ce230d922970f212dad0324394 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 4 Feb 2021 10:51:46 -0700 Subject: DRTVWR-525, improve dev's quality-of-life --- indra/llrender/llvertexbuffer.h | 43 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 9867bd16d6..dbe1a3687f 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -155,9 +155,8 @@ public: //get the size of a buffer with the given typemask and vertex count //fill offsets with the offset of each vertex component array into the buffer // indexed by the following enum - static S32 calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices); + static S32 calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices); - //WARNING -- when updating these enums you MUST // 1 - update LLVertexBuffer::sTypeSize // 2 - add a strider accessor @@ -165,24 +164,28 @@ public: // 4 - modify LLVertexBuffer::setupClientArray // 5 - modify LLViewerShaderMgr::mReservedAttribs // 6 - update LLVertexBuffer::setupVertexArray - enum { - TYPE_VERTEX = 0, - TYPE_NORMAL, - TYPE_TEXCOORD0, - TYPE_TEXCOORD1, - TYPE_TEXCOORD2, - TYPE_TEXCOORD3, - TYPE_COLOR, - TYPE_EMISSIVE, - TYPE_TANGENT, - TYPE_WEIGHT, - TYPE_WEIGHT4, - TYPE_CLOTHWEIGHT, - TYPE_TEXTURE_INDEX, - TYPE_MAX, // TYPE_MAX is the size/boundary marker for attributes that go in the vertex buffer - TYPE_INDEX, // TYPE_INDEX is beyond _MAX because it lives in a separate (index) buffer - }; - enum { + + // clang-format off + enum { // Shader attribute name, set in LLShaderMgr::initAttribsAndUniforms() + TYPE_VERTEX = 0, // "position" + TYPE_NORMAL, // "normal" + TYPE_TEXCOORD0, // "texcoord0" + TYPE_TEXCOORD1, // "texcoord1" + TYPE_TEXCOORD2, // "texcoord2" + TYPE_TEXCOORD3, // "texcoord3" + TYPE_COLOR, // "diffuse_color" + TYPE_EMISSIVE, // "emissive" + TYPE_TANGENT, // "tangent" + TYPE_WEIGHT, // "weight" + TYPE_WEIGHT4, // "weight4" + TYPE_CLOTHWEIGHT, // "clothing" + TYPE_TEXTURE_INDEX, // "texture_index" + TYPE_MAX, // TYPE_MAX is the size/boundary marker for attributes that go in the vertex buffer + TYPE_INDEX, // TYPE_INDEX is beyond _MAX because it lives in a separate (index) buffer + }; + // clang-format on + + enum { MAP_VERTEX = (1< Date: Wed, 5 May 2021 13:09:16 -0600 Subject: SL-15221 add VBO dirty bit to avoid many per-frame checks --- indra/llrender/llvertexbuffer.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index dbe1a3687f..649fbb782c 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -88,6 +88,7 @@ public: typedef std::list record_list_t; std::vector mFreeList; std::vector mMissCount; + bool mMissCountDirty; // flag any changes to mFreeList or mMissCount }; -- cgit v1.2.3 From 01d03edd8512580575da515401a42021577c3c57 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 1 Sep 2022 13:38:22 -0700 Subject: SL-17967 - _ARB constant removal --- indra/llrender/llvertexbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index baf8407fc6..a7907f9cae 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -288,7 +288,7 @@ public: U8* getMappedIndices() const { return mMappedIndexData; } S32 getOffset(S32 type) const { return mOffsets[type]; } S32 getUsage() const { return mUsage; } - bool isWriteable() const { return (mMappable || mUsage == GL_STREAM_DRAW_ARB) ? true : false; } + bool isWriteable() const { return (mMappable || mUsage == GL_STREAM_DRAW) ? true : false; } void draw(U32 mode, U32 count, U32 indices_offset) const; void drawArrays(U32 mode, U32 offset, U32 count) const; -- cgit v1.2.3 From be1cdc1aaa67eca71fee8cbbc16b4c85bcbdb258 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 5 Oct 2022 09:48:18 -0700 Subject: Initial pass at adding KHR_debug support This still needs some work - I'm not super satisfied with the overall structure of the code. Will continue to iterate as I add in proper RenderDoc support. --- indra/llrender/llvertexbuffer.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index a7907f9cae..a7e5fddf8c 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -300,6 +300,9 @@ public: //for debugging, validate data in given range is valid void validateRange(U32 start, U32 end, U32 count, U32 offset) const; + #ifdef LL_PROFILER_ENABLE_TRACY_OPENGL + void setLabel(std::string label); + #endif protected: @@ -370,5 +373,11 @@ public: static U32 sSetCount; }; +#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +#define LL_LABEL_VERTEX_BUFFER(buf, name) buf->setLabel(name) +#else +#define LL_LABEL_VERTEX_BUFFER(buf, name) +#endif + #endif // LL_LLVERTEXBUFFER_H -- cgit v1.2.3 From db92f9564992b9910b21f3de57a584ccfa199e75 Mon Sep 17 00:00:00 2001 From: Geenz Linden Date: Thu, 6 Oct 2022 15:18:17 -0400 Subject: Switch away from std::string API expects const char* anyways. --- indra/llrender/llvertexbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index a7e5fddf8c..d6f681e4ca 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -301,7 +301,7 @@ public: void validateRange(U32 start, U32 end, U32 count, U32 offset) const; #ifdef LL_PROFILER_ENABLE_TRACY_OPENGL - void setLabel(std::string label); + void setLabel(const char* label); #endif -- cgit v1.2.3 From 9e7b725c15ea0bfea5246eb81dd7a100b7ac5b6b Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Mon, 31 Oct 2022 09:42:27 -0700 Subject: SL-18485: Render GLTF materials with extension KHR_texture_transform with approprate texture transforms --- indra/llrender/llvertexbuffer.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 233d7785f8..b54e99ca27 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -160,11 +160,12 @@ public: //WARNING -- when updating these enums you MUST // 1 - update LLVertexBuffer::sTypeSize - // 2 - add a strider accessor - // 3 - modify LLVertexBuffer::setupVertexBuffer - // 4 - modify LLVertexBuffer::setupClientArray - // 5 - modify LLViewerShaderMgr::mReservedAttribs - // 6 - update LLVertexBuffer::setupVertexArray + // 2 - update LLVertexBuffer::vb_type_name + // 3 - add a strider accessor + // 4 - modify LLVertexBuffer::setupVertexBuffer + // 5 - modify LLVertexBuffer::setupVertexBufferFast + // 6 - modify LLViewerShaderMgr::mReservedAttribs + // 7 - update LLVertexBuffer::setupVertexArray // clang-format off enum { // Shader attribute name, set in LLShaderMgr::initAttribsAndUniforms() @@ -181,6 +182,10 @@ public: TYPE_WEIGHT4, // "weight4" TYPE_CLOTHWEIGHT, // "clothing" TYPE_TEXTURE_INDEX, // "texture_index" + TYPE_BASECOLOR_TEXCOORD, // "basecolor_texcoord" (GLTF) + TYPE_NORMAL_TEXCOORD, // "normal_texcoord" (GLTF) + TYPE_METALLIC_ROUGHNESS_TEXCOORD, // "metallic_roughness_texcoord" (GLTF) + TYPE_EMISSIVE_TEXCOORD, // "emissive_texcoord" (GLTF) TYPE_MAX, // TYPE_MAX is the size/boundary marker for attributes that go in the vertex buffer TYPE_INDEX, // TYPE_INDEX is beyond _MAX because it lives in a separate (index) buffer }; @@ -195,12 +200,15 @@ public: MAP_TEXCOORD3 = (1<& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getWeight4Strider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getClothWeightStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); + bool getBasecolorTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); + bool getNormalTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); + bool getMetallicRoughnessTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); + bool getEmissiveTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); bool useVBOs() const; -- cgit v1.2.3 From 843a5c287e34855fb7bd4882d8d0a106e987a9f7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 14 Nov 2022 11:40:18 -0600 Subject: SL-18485 Cleanup -- remove unused GLTF specific vertex attributes from LLVertexBuffer (blows past 16-attribute limit) --- indra/llrender/llvertexbuffer.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index b54e99ca27..99b8b54d69 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -182,10 +182,6 @@ public: TYPE_WEIGHT4, // "weight4" TYPE_CLOTHWEIGHT, // "clothing" TYPE_TEXTURE_INDEX, // "texture_index" - TYPE_BASECOLOR_TEXCOORD, // "basecolor_texcoord" (GLTF) - TYPE_NORMAL_TEXCOORD, // "normal_texcoord" (GLTF) - TYPE_METALLIC_ROUGHNESS_TEXCOORD, // "metallic_roughness_texcoord" (GLTF) - TYPE_EMISSIVE_TEXCOORD, // "emissive_texcoord" (GLTF) TYPE_MAX, // TYPE_MAX is the size/boundary marker for attributes that go in the vertex buffer TYPE_INDEX, // TYPE_INDEX is beyond _MAX because it lives in a separate (index) buffer }; @@ -205,10 +201,6 @@ public: MAP_WEIGHT4 = (1< Date: Wed, 16 Nov 2022 14:49:17 -0600 Subject: SL-18154 Profile guided optimizations vs release viewer. Trim some unused abilities and remove some more fast timers. --- indra/llrender/llvertexbuffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 99b8b54d69..e846ab70e2 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -303,7 +303,7 @@ public: //for debugging, validate data in given range is valid void validateRange(U32 start, U32 end, U32 count, U32 offset) const; - #ifdef LL_PROFILER_ENABLE_TRACY_OPENGL + #ifdef LL_PROFILER_ENABLE_RENDER_DOC void setLabel(const char* label); #endif @@ -376,7 +376,7 @@ public: static U32 sSetCount; }; -#ifdef LL_PROFILER_ENABLE_TRACY_OPENGL +#ifdef LL_PROFILER_ENABLE_RENDER_DOC #define LL_LABEL_VERTEX_BUFFER(buf, name) buf->setLabel(name) #else #define LL_LABEL_VERTEX_BUFFER(buf, name) -- cgit v1.2.3 From b3fc82ff1da0c869f0b1dd841647a120a1ae56af Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 9 Jan 2023 13:05:32 -0600 Subject: SL-18869 Optimizations -- decruftify LLVertexBuffer and make an optimal "renderShadowSimple" utility function for pushing vertex buffers only. --- indra/llrender/llvertexbuffer.h | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 4d73cf07c0..bb7460fb2a 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -166,8 +166,7 @@ public: // 4 - modify LLVertexBuffer::setupVertexBuffer // 5 - modify LLVertexBuffer::setupVertexBufferFast // 6 - modify LLViewerShaderMgr::mReservedAttribs - // 7 - update LLVertexBuffer::setupVertexArray - + // clang-format off enum { // Shader attribute name, set in LLShaderMgr::initAttribsAndUniforms() TYPE_VERTEX = 0, // "position" @@ -212,15 +211,12 @@ protected: virtual void setupVertexBuffer(U32 data_mask); void setupVertexBufferFast(U32 data_mask); - void setupVertexArray(); - void genBuffer(U32 size); void genIndices(U32 size); bool bindGLBuffer(bool force_bind = false); bool bindGLBufferFast(); bool bindGLIndices(bool force_bind = false); bool bindGLIndicesFast(); - bool bindGLArray(); void releaseBuffer(); void releaseIndices(); bool createGLBuffer(U32 size); @@ -282,8 +278,8 @@ public: S32 getNumVerts() const { return mNumVerts; } S32 getNumIndices() const { return mNumIndices; } - U8* getIndicesPointer() const { return useVBOs() ? (U8*) mAlignedIndexOffset : mMappedIndexData; } - U8* getVerticesPointer() const { return useVBOs() ? (U8*) mAlignedOffset : mMappedData; } + U8* getIndicesPointer() const { return useVBOs() ? nullptr : mMappedIndexData; } + U8* getVerticesPointer() const { return useVBOs() ? nullptr : mMappedData; } U32 getTypeMask() const { return mTypeMask; } bool hasDataType(S32 type) const { return ((1 << type) & getTypeMask()); } S32 getSize() const; @@ -292,7 +288,7 @@ public: U8* getMappedIndices() const { return mMappedIndexData; } S32 getOffset(S32 type) const { return mOffsets[type]; } S32 getUsage() const { return mUsage; } - bool isWriteable() const { return (mMappable || mUsage == GL_STREAM_DRAW) ? true : false; } + bool isWriteable() const { return (mUsage == GL_STREAM_DRAW) ? true : false; } void draw(U32 mode, U32 count, U32 indices_offset) const; void drawArrays(U32 mode, U32 offset, U32 count) const; @@ -310,21 +306,19 @@ public: protected: + U32 mGLBuffer; // GL VBO handle + U32 mGLIndices; // GL IBO handle + + U32 mTypeMask; + S32 mNumVerts; // Number of vertices allocated S32 mNumIndices; // Number of indices allocated - - ptrdiff_t mAlignedOffset; - ptrdiff_t mAlignedIndexOffset; + S32 mSize; S32 mIndicesSize; - U32 mTypeMask; const S32 mUsage; // GL usage - - U32 mGLBuffer; // GL VBO handle - U32 mGLIndices; // GL IBO handle - U32 mGLArray; // GL VAO handle - + U8* mMappedData; // pointer to currently mapped data (NULL if unmapped) U8* mMappedIndexData; // pointer to currently mapped indices (NULL if unmapped) @@ -335,18 +329,11 @@ protected: U32 mFinal : 1; // if true, buffer can not be mapped again U32 mEmpty : 1; // if true, client buffer is empty (or NULL). Old values have been discarded. - mutable bool mMappable; // if true, use memory mapping to upload data (otherwise doublebuffer and use glBufferSubData) - S32 mOffsets[TYPE_MAX]; std::vector mMappedVertexRegions; std::vector mMappedIndexRegions; - mutable LLGLFence* mFence; - - void placeFence() const; - void waitFence() const; - static S32 determineUsage(S32 usage); private: -- cgit v1.2.3 From fdc0ea64f050ad09a84442f40396bb9e6497ce52 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 10 Jan 2023 17:36:05 -0600 Subject: SL-18869 Optimizations -- LLVertexBuffer overhaul and shuffle of shadow map rendering to a place where the main camera has taken a stab at object updates for this frame before shadow map rendering has at them. --- indra/llrender/llvertexbuffer.h | 69 +++-------------------------------------- 1 file changed, 5 insertions(+), 64 deletions(-) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index bb7460fb2a..74b951884d 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -50,67 +50,16 @@ // called from the main (i.e OpenGL) thread) -//============================================================================ -// gl name pools for dynamic and streaming buffers -class LLVBOPool -{ -public: - static U32 sBytesPooled; - static U32 sIndexBytesPooled; - - LLVBOPool(U32 vboUsage, U32 vboType); - - const U32 mUsage; - const U32 mType; - - //size MUST be a power of 2 - U8* allocate(U32& name, U32 size, bool for_seed = false); - - //size MUST be the size provided to allocate that returned the given name - void release(U32 name, U8* buffer, U32 size); - - //batch allocate buffers to be provided to the application on demand - void seedPool(); - - //destroy all records in mFreeList - void cleanup(); - - U32 genBuffer(); - void deleteBuffer(U32 name); - - class Record - { - public: - U32 mGLName; - U8* mClientData; - }; - - typedef std::list record_list_t; - std::vector mFreeList; - std::vector mMissCount; - bool mMissCountDirty; // flag any changes to mFreeList or mMissCount - - //used to avoid calling glGenBuffers for every VBO creation - static U32 sNamePool[1024]; - static U32 sNameIdx; -}; - - //============================================================================ // base class class LLPrivateMemoryPool; class LLVertexBuffer : public LLRefCount { public: - class MappedRegion + struct MappedRegion { - public: - S32 mType; - S32 mIndex; - S32 mCount; - S32 mEnd; - - MappedRegion(S32 type, S32 index, S32 count); + S32 mStart; + S32 mEnd; }; LLVertexBuffer(const LLVertexBuffer& rhs) @@ -125,12 +74,6 @@ public: return *this; } - static LLVBOPool sStreamVBOPool; - static LLVBOPool sDynamicVBOPool; - static LLVBOPool sDynamicCopyVBOPool; - static LLVBOPool sStreamIBOPool; - static LLVBOPool sDynamicIBOPool; - static std::list sAvailableVAOName; static U32 sCurVAOName; @@ -138,12 +81,10 @@ public: static bool sUseVAO; static bool sPreferStreamDraw; - static void seedPools(); - static U32 getVAOName(); static void releaseVAOName(U32 name); - static void initClass(bool use_vbo, bool no_vbo_mapping); + static void initClass(LLWindow* window); static void cleanupClass(); static void setupClientArrays(U32 data_mask); static void drawArrays(U32 mode, const std::vector& pos); @@ -240,7 +181,7 @@ public: virtual void setBuffer(U32 data_mask); // calls setupVertexBuffer() if data_mask is not 0 void setBufferFast(U32 data_mask); // calls setupVertexBufferFast(), assumes data_mask is not 0 among other assumptions - void flush(); //flush pending data to GL memory + void flush(bool discard = false); //flush pending data to GL memory, if discard is true, discard previous VBO // allocate buffer bool allocateBuffer(S32 nverts, S32 nindices, bool create); virtual bool resizeBuffer(S32 newnverts, S32 newnindices); -- cgit v1.2.3 From 68da705f3ba284928c7e23acd4164d56dea17af9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 10 Jan 2023 18:42:09 -0600 Subject: SL-18869 Optimizations -- Quiet command buffer -- VBO cache for UI et al and remove many unneeded VBO binds. --- indra/llrender/llvertexbuffer.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 74b951884d..926d37b052 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -212,6 +212,10 @@ public: bool getMetallicRoughnessTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getEmissiveTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); + void setPositionData(const LLVector4a* data); + void setTexCoordData(const LLVector2* data); + void setColorData(const LLColor4U* data); + bool useVBOs() const; bool isEmpty() const { return mEmpty; } -- cgit v1.2.3 From 7bd9d21e19b923096ba2b5ea3cbc8be3e13d7aa0 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 19 Jan 2023 09:13:45 -0600 Subject: Optimizations, decruft, and intel compatibility pass (#53) SL-18869, SL-18772 Overhaul VBO management, restore occlusion culling, intel compatibility pass, etc --- indra/llrender/llvertexbuffer.h | 205 ++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 125 deletions(-) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 926d37b052..571856f013 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -53,17 +53,16 @@ //============================================================================ // base class class LLPrivateMemoryPool; -class LLVertexBuffer : public LLRefCount +class LLVertexBuffer final : public LLRefCount { public: struct MappedRegion { - S32 mStart; - S32 mEnd; + U32 mStart; + U32 mEnd; }; LLVertexBuffer(const LLVertexBuffer& rhs) - : mUsage(rhs.mUsage) { *this = rhs; } @@ -74,42 +73,31 @@ public: return *this; } - static std::list sAvailableVAOName; - static U32 sCurVAOName; - - static bool sUseStreamDraw; - static bool sUseVAO; - static bool sPreferStreamDraw; - - static U32 getVAOName(); - static void releaseVAOName(U32 name); - static void initClass(LLWindow* window); static void cleanupClass(); static void setupClientArrays(U32 data_mask); static void drawArrays(U32 mode, const std::vector& pos); - static void drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, S32 num_indices, const U16* indicesp); + static void drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, U32 num_indices, const U16* indicesp); static void unbind(); //unbind any bound vertex buffer //get the size of a vertex with the given typemask - static S32 calcVertexSize(const U32& typemask); + static U32 calcVertexSize(const U32& typemask); //get the size of a buffer with the given typemask and vertex count //fill offsets with the offset of each vertex component array into the buffer // indexed by the following enum - static S32 calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices); + static U32 calcOffsets(const U32& typemask, U32* offsets, U32 num_vertices); //WARNING -- when updating these enums you MUST // 1 - update LLVertexBuffer::sTypeSize // 2 - update LLVertexBuffer::vb_type_name // 3 - add a strider accessor // 4 - modify LLVertexBuffer::setupVertexBuffer - // 5 - modify LLVertexBuffer::setupVertexBufferFast // 6 - modify LLViewerShaderMgr::mReservedAttribs // clang-format off - enum { // Shader attribute name, set in LLShaderMgr::initAttribsAndUniforms() + enum AttributeType { // Shader attribute name, set in LLShaderMgr::initAttribsAndUniforms() TYPE_VERTEX = 0, // "position" TYPE_NORMAL, // "normal" TYPE_TEXCOORD0, // "texcoord0" @@ -147,45 +135,37 @@ public: protected: friend class LLRender; - virtual ~LLVertexBuffer(); // use unref() + ~LLVertexBuffer(); // use unref() - virtual void setupVertexBuffer(U32 data_mask); - void setupVertexBufferFast(U32 data_mask); + void setupVertexBuffer(); void genBuffer(U32 size); void genIndices(U32 size); - bool bindGLBuffer(bool force_bind = false); - bool bindGLBufferFast(); - bool bindGLIndices(bool force_bind = false); - bool bindGLIndicesFast(); - void releaseBuffer(); - void releaseIndices(); bool createGLBuffer(U32 size); bool createGLIndices(U32 size); void destroyGLBuffer(); void destroyGLIndices(); - bool updateNumVerts(S32 nverts); - bool updateNumIndices(S32 nindices); - void unmapBuffer(); - + bool updateNumVerts(U32 nverts); + bool updateNumIndices(U32 nindices); + public: - LLVertexBuffer(U32 typemask, S32 usage); + LLVertexBuffer(U32 typemask); - // map for data access - U8* mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range); - U8* mapIndexBuffer(S32 index, S32 count, bool map_range); + // allocate buffer + bool allocateBuffer(U32 nverts, U32 nindices); - void bindForFeedback(U32 channel, U32 type, U32 index, U32 count); + // map for data access (see also getFooStrider below) + U8* mapVertexBuffer(AttributeType type, U32 index, S32 count = -1); + U8* mapIndexBuffer(U32 index, S32 count = -1); + void unmapBuffer(); // set for rendering - virtual void setBuffer(U32 data_mask); // calls setupVertexBuffer() if data_mask is not 0 - void setBufferFast(U32 data_mask); // calls setupVertexBufferFast(), assumes data_mask is not 0 among other assumptions - - void flush(bool discard = false); //flush pending data to GL memory, if discard is true, discard previous VBO - // allocate buffer - bool allocateBuffer(S32 nverts, S32 nindices, bool create); - virtual bool resizeBuffer(S32 newnverts, S32 newnindices); - + // assumes (and will assert on) the following: + // - this buffer has no pending unampBuffer call + // - a shader is currently bound + // - This buffer has sufficient attributes within it to satisfy the needs of the currently bound shader + void setBuffer(); + // Only call each getVertexPointer, etc, once before calling unmapBuffer() // call unmapBuffer() after calls to getXXXStrider() before any cals to setBuffer() // example: @@ -193,57 +173,49 @@ public: // vb->getNormalStrider(norms); // setVertsNorms(verts, norms); // vb->unmapBuffer(); - bool getVertexStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getVertexStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getIndexStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTexCoord0Strider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTexCoord1Strider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTexCoord2Strider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getNormalStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTangentStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getTangentStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getColorStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getEmissiveStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getWeightStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getWeight4Strider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getClothWeightStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getBasecolorTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getNormalTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getMetallicRoughnessTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); - bool getEmissiveTexcoordStrider(LLStrider& strider, S32 index=0, S32 count = -1, bool map_range = false); + bool getVertexStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getVertexStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getIndexStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTexCoord0Strider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTexCoord1Strider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTexCoord2Strider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getNormalStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTangentStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getTangentStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getColorStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getEmissiveStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getWeightStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getWeight4Strider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getClothWeightStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getBasecolorTexcoordStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getNormalTexcoordStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getMetallicRoughnessTexcoordStrider(LLStrider& strider, U32 index=0, S32 count = -1); + bool getEmissiveTexcoordStrider(LLStrider& strider, U32 index=0, S32 count = -1); void setPositionData(const LLVector4a* data); void setTexCoordData(const LLVector2* data); void setColorData(const LLColor4U* data); - bool useVBOs() const; - bool isEmpty() const { return mEmpty; } - bool isLocked() const { return mVertexLocked || mIndexLocked; } - S32 getNumVerts() const { return mNumVerts; } - S32 getNumIndices() const { return mNumIndices; } + U32 getNumVerts() const { return mNumVerts; } + U32 getNumIndices() const { return mNumIndices; } - U8* getIndicesPointer() const { return useVBOs() ? nullptr : mMappedIndexData; } - U8* getVerticesPointer() const { return useVBOs() ? nullptr : mMappedData; } U32 getTypeMask() const { return mTypeMask; } - bool hasDataType(S32 type) const { return ((1 << type) & getTypeMask()); } - S32 getSize() const; - S32 getIndicesSize() const { return mIndicesSize; } + bool hasDataType(AttributeType type) const { return ((1 << type) & getTypeMask()); } + U32 getSize() const { return mSize; } + U32 getIndicesSize() const { return mIndicesSize; } U8* getMappedData() const { return mMappedData; } U8* getMappedIndices() const { return mMappedIndexData; } - S32 getOffset(S32 type) const { return mOffsets[type]; } - S32 getUsage() const { return mUsage; } - bool isWriteable() const { return (mUsage == GL_STREAM_DRAW) ? true : false; } - + U32 getOffset(AttributeType type) const { return mOffsets[type]; } + + // these functions assume (and assert on) the current VBO being bound + // Detailed error checking can be enabled by setting gDebugGL to true void draw(U32 mode, U32 count, U32 indices_offset) const; void drawArrays(U32 mode, U32 offset, U32 count) const; - void drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const; - - //implementation for inner loops that does no safety checking - void drawRangeFast(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const; + void drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const; //for debugging, validate data in given range is valid - void validateRange(U32 start, U32 end, U32 count, U32 offset) const; + bool validateRange(U32 start, U32 end, U32 count, U32 offset) const; #ifdef LL_PROFILER_ENABLE_RENDER_DOC void setLabel(const char* label); @@ -251,62 +223,45 @@ public: protected: - U32 mGLBuffer; // GL VBO handle - U32 mGLIndices; // GL IBO handle + U32 mGLBuffer = 0; // GL VBO handle + U32 mGLIndices = 0; // GL IBO handle + U32 mNumVerts = 0; // Number of vertices allocated + U32 mNumIndices = 0; // Number of indices allocated + U32 mOffsets[TYPE_MAX]; // byte offsets into mMappedData of each attribute - U32 mTypeMask; + U8* mMappedData = nullptr; // pointer to currently mapped data (NULL if unmapped) + U8* mMappedIndexData = nullptr; // pointer to currently mapped indices (NULL if unmapped) - S32 mNumVerts; // Number of vertices allocated - S32 mNumIndices; // Number of indices allocated - - S32 mSize; - S32 mIndicesSize; - - const S32 mUsage; // GL usage - - U8* mMappedData; // pointer to currently mapped data (NULL if unmapped) - U8* mMappedIndexData; // pointer to currently mapped indices (NULL if unmapped) - - U32 mMappedDataUsingVBOs : 1; - U32 mMappedIndexDataUsingVBOs : 1; - U32 mVertexLocked : 1; // if true, vertex buffer is being or has been written to in client memory - U32 mIndexLocked : 1; // if true, index buffer is being or has been written to in client memory - U32 mFinal : 1; // if true, buffer can not be mapped again - U32 mEmpty : 1; // if true, client buffer is empty (or NULL). Old values have been discarded. + U32 mTypeMask = 0; // bitmask of present vertex attributes - S32 mOffsets[TYPE_MAX]; - - std::vector mMappedVertexRegions; - std::vector mMappedIndexRegions; + U32 mSize = 0; // size in bytes of mMappedData + U32 mIndicesSize = 0; // size in bytes of mMappedIndexData - static S32 determineUsage(S32 usage); + std::vector mMappedVertexRegions; // list of mMappedData byte ranges that must be sent to GL + std::vector mMappedIndexRegions; // list of mMappedIndexData byte ranges that must be sent to GL private: - static LLPrivateMemoryPool* sPrivatePoolp; + // DEPRECATED + // These function signatures are deprecated, but for some reason + // there are classes in an external package that depend on LLVertexBuffer + + // TODO: move these classes into viewer repository + friend class LLNavShapeVBOManager; + friend class LLNavMeshVBOManager; + + LLVertexBuffer(U32 typemask, U32 usage) + : LLVertexBuffer(typemask) + {} + + bool allocateBuffer(S32 nverts, S32 nindices, BOOL create) { return allocateBuffer(nverts, nindices); } public: - static S32 sCount; - static S32 sGLCount; - static S32 sMappedCount; - static bool sMapped; - typedef std::list buffer_list_t; - - static bool sDisableVBOMapping; //disable glMapBufferARB - static bool sEnableVBOs; - static const S32 sTypeSize[TYPE_MAX]; + static const U32 sTypeSize[TYPE_MAX]; static const U32 sGLMode[LLRender::NUM_MODES]; static U32 sGLRenderBuffer; - static U32 sGLRenderArray; static U32 sGLRenderIndices; - static bool sVBOActive; - static bool sIBOActive; static U32 sLastMask; - static U32 sAllocatedBytes; - static U32 sAllocatedIndexBytes; static U32 sVertexCount; - static U32 sIndexCount; - static U32 sBindCount; - static U32 sSetCount; }; #ifdef LL_PROFILER_ENABLE_RENDER_DOC -- cgit v1.2.3 From 25ede8638209fac8dde5b71bece4bc1dfa30ea16 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 10 Mar 2023 10:52:35 -0600 Subject: SL-19172 Texture streaming tune up. Incidental decruft. --- indra/llrender/llvertexbuffer.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llrender/llvertexbuffer.h') diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 571856f013..f2d146d4bb 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -256,6 +256,8 @@ private: bool allocateBuffer(S32 nverts, S32 nindices, BOOL create) { return allocateBuffer(nverts, nindices); } public: + + static U64 getBytesAllocated(); static const U32 sTypeSize[TYPE_MAX]; static const U32 sGLMode[LLRender::NUM_MODES]; static U32 sGLRenderBuffer; -- cgit v1.2.3