diff options
author | Jacek Antonelli | 2008-08-15 23:45:44 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:44 -0500 |
commit | acfdcf2b1deeb04698174c78e8cb22b093445bb1 (patch) | |
tree | 811293650bcf81d01ea7c54d7c2cf263110aa329 /linden/indra/llrender | |
parent | Second Life viewer sources 1.20.2 (diff) | |
download | meta-impy-acfdcf2b1deeb04698174c78e8cb22b093445bb1.zip meta-impy-acfdcf2b1deeb04698174c78e8cb22b093445bb1.tar.gz meta-impy-acfdcf2b1deeb04698174c78e8cb22b093445bb1.tar.bz2 meta-impy-acfdcf2b1deeb04698174c78e8cb22b093445bb1.tar.xz |
Second Life viewer sources 1.20.3
Diffstat (limited to 'linden/indra/llrender')
-rw-r--r-- | linden/indra/llrender/llglimmediate.cpp | 7 | ||||
-rw-r--r-- | linden/indra/llrender/llglimmediate.h | 5 | ||||
-rw-r--r-- | linden/indra/llrender/llimagegl.cpp | 79 | ||||
-rw-r--r-- | linden/indra/llrender/llimagegl.h | 2 | ||||
-rw-r--r-- | linden/indra/llrender/llrendertarget.h | 2 | ||||
-rw-r--r-- | linden/indra/llrender/llvertexbuffer.cpp | 176 | ||||
-rw-r--r-- | linden/indra/llrender/llvertexbuffer.h | 14 |
7 files changed, 246 insertions, 39 deletions
diff --git a/linden/indra/llrender/llglimmediate.cpp b/linden/indra/llrender/llglimmediate.cpp index db62f3d..da9239d 100644 --- a/linden/indra/llrender/llglimmediate.cpp +++ b/linden/indra/llrender/llglimmediate.cpp | |||
@@ -43,8 +43,7 @@ LLGLImmediate gGL; | |||
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | bool LLGLImmediate::sClever = false; | 45 | bool LLGLImmediate::sClever = false; |
46 | 46 | BOOL LLGLImmediate::sStarted = FALSE; | |
47 | static BOOL sStarted = FALSE; | ||
48 | 47 | ||
49 | LLGLImmediate::LLGLImmediate() | 48 | LLGLImmediate::LLGLImmediate() |
50 | { | 49 | { |
@@ -62,9 +61,9 @@ void LLGLImmediate::start() | |||
62 | llerrs << "Redundant start." << llendl; | 61 | llerrs << "Redundant start." << llendl; |
63 | } | 62 | } |
64 | 63 | ||
65 | sStarted = TRUE; | ||
66 | LLVertexBuffer::unbind(); | 64 | LLVertexBuffer::unbind(); |
67 | 65 | sStarted = TRUE; | |
66 | |||
68 | glEnableClientState(GL_VERTEX_ARRAY); | 67 | glEnableClientState(GL_VERTEX_ARRAY); |
69 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 68 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
70 | glEnableClientState(GL_COLOR_ARRAY); | 69 | glEnableClientState(GL_COLOR_ARRAY); |
diff --git a/linden/indra/llrender/llglimmediate.h b/linden/indra/llrender/llglimmediate.h index bf2f9ab..cf4dc4f 100644 --- a/linden/indra/llrender/llglimmediate.h +++ b/linden/indra/llrender/llglimmediate.h | |||
@@ -91,9 +91,12 @@ public: | |||
91 | GLfloat uv[2]; | 91 | GLfloat uv[2]; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | public: | ||
95 | static BOOL sStarted; | ||
96 | |||
94 | private: | 97 | private: |
95 | static bool sClever; | 98 | static bool sClever; |
96 | 99 | ||
97 | U32 mCount; | 100 | U32 mCount; |
98 | U32 mMode; | 101 | U32 mMode; |
99 | Vertex mBuffer[4096]; | 102 | Vertex mBuffer[4096]; |
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp index 76c8252..c4b90a7 100644 --- a/linden/indra/llrender/llimagegl.cpp +++ b/linden/indra/llrender/llimagegl.cpp | |||
@@ -128,10 +128,16 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat) | |||
128 | void LLImageGL::bindExternalTexture(LLGLuint gl_name, S32 stage, LLGLenum bind_target ) | 128 | void LLImageGL::bindExternalTexture(LLGLuint gl_name, S32 stage, LLGLenum bind_target ) |
129 | { | 129 | { |
130 | gGL.flush(); | 130 | gGL.flush(); |
131 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); | 131 | if (stage > 0) |
132 | glClientActiveTextureARB(GL_TEXTURE0_ARB + stage); | 132 | { |
133 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); | ||
134 | } | ||
133 | glBindTexture(bind_target, gl_name); | 135 | glBindTexture(bind_target, gl_name); |
134 | sCurrentBoundTextures[stage] = gl_name; | 136 | sCurrentBoundTextures[stage] = gl_name; |
137 | if (stage > 0) | ||
138 | { | ||
139 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
140 | } | ||
135 | } | 141 | } |
136 | 142 | ||
137 | // static | 143 | // static |
@@ -141,9 +147,16 @@ void LLImageGL::unbindTexture(S32 stage, LLGLenum bind_target) | |||
141 | if (stage >= 0) | 147 | if (stage >= 0) |
142 | { | 148 | { |
143 | gGL.flush(); | 149 | gGL.flush(); |
144 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); | 150 | if (stage > 0) |
145 | glClientActiveTextureARB(GL_TEXTURE0_ARB + stage); | 151 | { |
146 | glBindTexture(bind_target, 0); | 152 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); |
153 | glBindTexture(GL_TEXTURE_2D, 0); | ||
154 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | glBindTexture(GL_TEXTURE_2D, 0); | ||
159 | } | ||
147 | sCurrentBoundTextures[stage] = 0; | 160 | sCurrentBoundTextures[stage] = 0; |
148 | } | 161 | } |
149 | } | 162 | } |
@@ -151,15 +164,7 @@ void LLImageGL::unbindTexture(S32 stage, LLGLenum bind_target) | |||
151 | // static (duplicated for speed and to avoid GL_TEXTURE_2D default argument which requires GL header dependency) | 164 | // static (duplicated for speed and to avoid GL_TEXTURE_2D default argument which requires GL header dependency) |
152 | void LLImageGL::unbindTexture(S32 stage) | 165 | void LLImageGL::unbindTexture(S32 stage) |
153 | { | 166 | { |
154 | // LLGLSLShader can return -1 | 167 | unbindTexture(stage, GL_TEXTURE_2D); |
155 | if (stage >= 0) | ||
156 | { | ||
157 | gGL.flush(); | ||
158 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); | ||
159 | glClientActiveTextureARB(GL_TEXTURE0_ARB + stage); | ||
160 | glBindTexture(GL_TEXTURE_2D, 0); | ||
161 | sCurrentBoundTextures[stage] = 0; | ||
162 | } | ||
163 | } | 168 | } |
164 | 169 | ||
165 | // static | 170 | // static |
@@ -419,8 +424,6 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const | |||
419 | } | 424 | } |
420 | 425 | ||
421 | 426 | ||
422 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); | ||
423 | |||
424 | if (sCurrentBoundTextures[stage] && sCurrentBoundTextures[stage] == mTexName) | 427 | if (sCurrentBoundTextures[stage] && sCurrentBoundTextures[stage] == mTexName) |
425 | { | 428 | { |
426 | // already set! | 429 | // already set! |
@@ -434,10 +437,20 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const | |||
434 | #endif | 437 | #endif |
435 | 438 | ||
436 | gGL.flush(); | 439 | gGL.flush(); |
440 | if (stage > 0) | ||
441 | { | ||
442 | glActiveTextureARB(GL_TEXTURE0_ARB + stage); | ||
443 | } | ||
444 | |||
437 | glBindTexture(mBindTarget, mTexName); | 445 | glBindTexture(mBindTarget, mTexName); |
438 | sCurrentBoundTextures[stage] = mTexName; | 446 | sCurrentBoundTextures[stage] = mTexName; |
439 | sBindCount++; | 447 | sBindCount++; |
440 | 448 | ||
449 | if (stage > 0) | ||
450 | { | ||
451 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
452 | } | ||
453 | |||
441 | if (mLastBindTime != sLastFrameTime) | 454 | if (mLastBindTime != sLastFrameTime) |
442 | { | 455 | { |
443 | // we haven't accounted for this texture yet this frame | 456 | // we haven't accounted for this texture yet this frame |
@@ -451,7 +464,15 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const | |||
451 | else | 464 | else |
452 | { | 465 | { |
453 | gGL.flush(); | 466 | gGL.flush(); |
467 | if (stage > 0) | ||
468 | { | ||
469 | glActiveTextureARB(GL_TEXTURE0_ARB+stage); | ||
470 | } | ||
454 | glBindTexture(mBindTarget, 0); | 471 | glBindTexture(mBindTarget, 0); |
472 | if (stage > 0) | ||
473 | { | ||
474 | glActiveTextureARB(GL_TEXTURE0_ARB+stage); | ||
475 | } | ||
455 | sCurrentBoundTextures[stage] = 0; | 476 | sCurrentBoundTextures[stage] = 0; |
456 | return FALSE; | 477 | return FALSE; |
457 | } | 478 | } |
@@ -985,6 +1006,21 @@ BOOL LLImageGL::setDiscardLevel(S32 discard_level) | |||
985 | } | 1006 | } |
986 | } | 1007 | } |
987 | 1008 | ||
1009 | BOOL LLImageGL::isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) | ||
1010 | { | ||
1011 | assert_glerror(); | ||
1012 | S32 gl_discard = discard_level - mCurrentDiscardLevel; | ||
1013 | LLGLint glwidth = 0; | ||
1014 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_WIDTH, (GLint*)&glwidth); | ||
1015 | LLGLint glheight = 0; | ||
1016 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_HEIGHT, (GLint*)&glheight); | ||
1017 | LLGLint glcomponents = 0 ; | ||
1018 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_INTERNAL_FORMAT, (GLint*)&glcomponents); | ||
1019 | assert_glerror(); | ||
1020 | |||
1021 | return glwidth >= image_width && glheight >= image_height && (GL_RGB8 == glcomponents || GL_RGBA8 == glcomponents) ; | ||
1022 | } | ||
1023 | |||
988 | BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok) | 1024 | BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok) |
989 | { | 1025 | { |
990 | if (discard_level < 0) | 1026 | if (discard_level < 0) |
@@ -1033,12 +1069,22 @@ BOOL LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compre | |||
1033 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, (GLint*)&glbytes); | 1069 | glGetTexLevelParameteriv(mTarget, gl_discard, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, (GLint*)&glbytes); |
1034 | imageraw->allocateDataSize(width, height, ncomponents, glbytes); | 1070 | imageraw->allocateDataSize(width, height, ncomponents, glbytes); |
1035 | glGetCompressedTexImageARB(mTarget, gl_discard, (GLvoid*)(imageraw->getData())); | 1071 | glGetCompressedTexImageARB(mTarget, gl_discard, (GLvoid*)(imageraw->getData())); |
1072 | if(glGetError() != GL_NO_ERROR) | ||
1073 | { | ||
1074 | llwarns << "Error happens when reading back the compressed texture image." << llendl ; | ||
1075 | imageraw->deleteData() ; | ||
1076 | } | ||
1036 | stop_glerror(); | 1077 | stop_glerror(); |
1037 | } | 1078 | } |
1038 | else | 1079 | else |
1039 | { | 1080 | { |
1040 | imageraw->allocateDataSize(width, height, ncomponents); | 1081 | imageraw->allocateDataSize(width, height, ncomponents); |
1041 | glGetTexImage(GL_TEXTURE_2D, gl_discard, mFormatPrimary, mFormatType, (GLvoid*)(imageraw->getData())); | 1082 | glGetTexImage(GL_TEXTURE_2D, gl_discard, mFormatPrimary, mFormatType, (GLvoid*)(imageraw->getData())); |
1083 | if(glGetError() != GL_NO_ERROR) | ||
1084 | { | ||
1085 | llwarns << "Error happens when reading back the texture image." << llendl ; | ||
1086 | imageraw->deleteData() ; | ||
1087 | } | ||
1042 | stop_glerror(); | 1088 | stop_glerror(); |
1043 | } | 1089 | } |
1044 | 1090 | ||
@@ -1057,7 +1103,6 @@ void LLImageGL::destroyGLTexture() | |||
1057 | { | 1103 | { |
1058 | unbindTexture(i, GL_TEXTURE_2D); | 1104 | unbindTexture(i, GL_TEXTURE_2D); |
1059 | stop_glerror(); | 1105 | stop_glerror(); |
1060 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
1061 | } | 1106 | } |
1062 | } | 1107 | } |
1063 | 1108 | ||
diff --git a/linden/indra/llrender/llimagegl.h b/linden/indra/llrender/llimagegl.h index efe94c2..b386294 100644 --- a/linden/indra/llrender/llimagegl.h +++ b/linden/indra/llrender/llimagegl.h | |||
@@ -131,6 +131,8 @@ public: | |||
131 | BOOL getUseDiscard() const { return mUseMipMaps && !mDontDiscard; } | 131 | BOOL getUseDiscard() const { return mUseMipMaps && !mDontDiscard; } |
132 | BOOL getDontDiscard() const { return mDontDiscard; } | 132 | BOOL getDontDiscard() const { return mDontDiscard; } |
133 | 133 | ||
134 | BOOL isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) ; | ||
135 | |||
134 | protected: | 136 | protected: |
135 | void init(BOOL usemipmaps); | 137 | void init(BOOL usemipmaps); |
136 | virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors | 138 | virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors |
diff --git a/linden/indra/llrender/llrendertarget.h b/linden/indra/llrender/llrendertarget.h index 918a604..d16d986 100644 --- a/linden/indra/llrender/llrendertarget.h +++ b/linden/indra/llrender/llrendertarget.h | |||
@@ -71,7 +71,7 @@ public: | |||
71 | //allocate resources for rendering | 71 | //allocate resources for rendering |
72 | //must be called before use | 72 | //must be called before use |
73 | //multiple calls will release previously allocated resources | 73 | //multiple calls will release previously allocated resources |
74 | void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage = GL_TEXTURE_2D, BOOL use_fbo = TRUE); | 74 | void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage = GL_TEXTURE_2D, BOOL use_fbo = FALSE); |
75 | 75 | ||
76 | //allocate a depth texture | 76 | //allocate a depth texture |
77 | void allocateDepth(); | 77 | void allocateDepth(); |
diff --git a/linden/indra/llrender/llvertexbuffer.cpp b/linden/indra/llrender/llvertexbuffer.cpp index f3c6997..d165c01 100644 --- a/linden/indra/llrender/llvertexbuffer.cpp +++ b/linden/indra/llrender/llvertexbuffer.cpp | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "llglheaders.h" | 38 | #include "llglheaders.h" |
39 | #include "llmemory.h" | 39 | #include "llmemory.h" |
40 | #include "llmemtype.h" | 40 | #include "llmemtype.h" |
41 | #include "llglimmediate.h" | ||
41 | 42 | ||
42 | //============================================================================ | 43 | //============================================================================ |
43 | 44 | ||
@@ -76,6 +77,141 @@ S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] = | |||
76 | sizeof(LLVector4), // TYPE_CLOTHWEIGHT, | 77 | sizeof(LLVector4), // TYPE_CLOTHWEIGHT, |
77 | }; | 78 | }; |
78 | 79 | ||
80 | U32 LLVertexBuffer::sGLMode[LLVertexBuffer::NUM_MODES] = | ||
81 | { | ||
82 | GL_TRIANGLES, | ||
83 | GL_TRIANGLE_STRIP, | ||
84 | GL_TRIANGLE_FAN, | ||
85 | GL_POINTS, | ||
86 | GL_LINES, | ||
87 | GL_LINE_STRIP | ||
88 | }; | ||
89 | |||
90 | //static | ||
91 | void LLVertexBuffer::setupClientArrays(U32 data_mask) | ||
92 | { | ||
93 | if (LLGLImmediate::sStarted) | ||
94 | { | ||
95 | llerrs << "Cannot use LLGLImmediate and LLVertexBuffer simultaneously!" << llendl; | ||
96 | } | ||
97 | |||
98 | if (sLastMask != data_mask) | ||
99 | { | ||
100 | U32 mask[] = | ||
101 | { | ||
102 | MAP_VERTEX, | ||
103 | MAP_NORMAL, | ||
104 | MAP_TEXCOORD, | ||
105 | MAP_COLOR | ||
106 | }; | ||
107 | |||
108 | GLenum array[] = | ||
109 | { | ||
110 | GL_VERTEX_ARRAY, | ||
111 | GL_NORMAL_ARRAY, | ||
112 | GL_TEXTURE_COORD_ARRAY, | ||
113 | GL_COLOR_ARRAY | ||
114 | }; | ||
115 | |||
116 | for (U32 i = 0; i < 4; ++i) | ||
117 | { | ||
118 | if (sLastMask & mask[i]) | ||
119 | { //was enabled | ||
120 | if (!(data_mask & mask[i]) && i > 0) | ||
121 | { //needs to be disabled | ||
122 | glDisableClientState(array[i]); | ||
123 | } | ||
124 | else | ||
125 | { //needs to be enabled, make sure it was (DEBUG TEMPORARY) | ||
126 | if (i > 0 && !glIsEnabled(array[i])) | ||
127 | { | ||
128 | llerrs << "Bad client state! " << array[i] << " disabled." << llendl; | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | else | ||
133 | { //was disabled | ||
134 | if (data_mask & mask[i]) | ||
135 | { //needs to be enabled | ||
136 | glEnableClientState(array[i]); | ||
137 | } | ||
138 | else if (glIsEnabled(array[i])) | ||
139 | { //needs to be disabled, make sure it was (DEBUG TEMPORARY) | ||
140 | llerrs << "Bad client state! " << array[i] << " enabled." << llendl; | ||
141 | } | ||
142 | } | ||
143 | } | ||
144 | |||
145 | if (sLastMask & MAP_TEXCOORD2) | ||
146 | { | ||
147 | if (!(data_mask & MAP_TEXCOORD2)) | ||
148 | { | ||
149 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | ||
150 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | ||
151 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
152 | } | ||
153 | } | ||
154 | else if (data_mask & MAP_TEXCOORD2) | ||
155 | { | ||
156 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | ||
157 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | ||
158 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
159 | } | ||
160 | |||
161 | sLastMask = data_mask; | ||
162 | } | ||
163 | } | ||
164 | |||
165 | void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const | ||
166 | { | ||
167 | if (start >= (U32) mRequestedNumVerts || | ||
168 | end >= (U32) mRequestedNumVerts) | ||
169 | { | ||
170 | llerrs << "Bad vertex buffer draw range: [" << start << ", " << end << "]" << llendl; | ||
171 | } | ||
172 | |||
173 | if (indices_offset >= (U32) mRequestedNumIndices || | ||
174 | indices_offset + count > (U32) mRequestedNumIndices) | ||
175 | { | ||
176 | llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl; | ||
177 | } | ||
178 | |||
179 | if (mGLIndices != sGLRenderIndices) | ||
180 | { | ||
181 | llerrs << "Wrong index buffer bound." << llendl; | ||
182 | } | ||
183 | |||
184 | if (mGLBuffer != sGLRenderBuffer) | ||
185 | { | ||
186 | llerrs << "Wrong vertex buffer bound." << llendl; | ||
187 | } | ||
188 | |||
189 | glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, | ||
190 | ((U16*) getIndicesPointer()) + indices_offset); | ||
191 | } | ||
192 | |||
193 | void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const | ||
194 | { | ||
195 | if (indices_offset >= (U32) mRequestedNumIndices || | ||
196 | indices_offset + count > (U32) mRequestedNumIndices) | ||
197 | { | ||
198 | llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl; | ||
199 | } | ||
200 | |||
201 | if (mGLIndices != sGLRenderIndices) | ||
202 | { | ||
203 | llerrs << "Wrong index buffer bound." << llendl; | ||
204 | } | ||
205 | |||
206 | if (mGLBuffer != sGLRenderBuffer) | ||
207 | { | ||
208 | llerrs << "Wrong vertex buffer bound." << llendl; | ||
209 | } | ||
210 | |||
211 | glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, | ||
212 | ((U16*) getIndicesPointer()) + indices_offset); | ||
213 | } | ||
214 | |||
79 | //static | 215 | //static |
80 | void LLVertexBuffer::initClass(bool use_vbo) | 216 | void LLVertexBuffer::initClass(bool use_vbo) |
81 | { | 217 | { |
@@ -102,7 +238,8 @@ void LLVertexBuffer::unbind() | |||
102 | 238 | ||
103 | sGLRenderBuffer = 0; | 239 | sGLRenderBuffer = 0; |
104 | sGLRenderIndices = 0; | 240 | sGLRenderIndices = 0; |
105 | sLastMask = 0; | 241 | |
242 | setupClientArrays(0); | ||
106 | } | 243 | } |
107 | 244 | ||
108 | //static | 245 | //static |
@@ -118,22 +255,14 @@ void LLVertexBuffer::cleanupClass() | |||
118 | void LLVertexBuffer::startRender() | 255 | void LLVertexBuffer::startRender() |
119 | { | 256 | { |
120 | LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); | 257 | LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); |
121 | if (sEnableVBOs) | 258 | |
122 | { | 259 | unbind(); |
123 | glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); | ||
124 | glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); | ||
125 | sVBOActive = FALSE; | ||
126 | sIBOActive = FALSE; | ||
127 | } | ||
128 | |||
129 | sRenderActive = TRUE; | 260 | sRenderActive = TRUE; |
130 | sGLRenderBuffer = 0; | ||
131 | sGLRenderIndices = 0; | ||
132 | sLastMask = 0; | ||
133 | } | 261 | } |
134 | 262 | ||
135 | void LLVertexBuffer::stopRender() | 263 | void LLVertexBuffer::stopRender() |
136 | { | 264 | { |
265 | unbind(); | ||
137 | sRenderActive = FALSE; | 266 | sRenderActive = FALSE; |
138 | } | 267 | } |
139 | 268 | ||
@@ -615,6 +744,16 @@ U8* LLVertexBuffer::mapBuffer(S32 access) | |||
615 | llerrs << "Mapped two VBOs at the same time!" << llendl; | 744 | llerrs << "Mapped two VBOs at the same time!" << llendl; |
616 | } | 745 | } |
617 | sMapped = TRUE;*/ | 746 | sMapped = TRUE;*/ |
747 | if (!mMappedData) | ||
748 | { | ||
749 | llerrs << "glMapBuffer returned NULL (no vertex data)" << llendl; | ||
750 | } | ||
751 | |||
752 | if (!mMappedIndexData) | ||
753 | { | ||
754 | llerrs << "glMapBuffer returned NULL (no index data)" << llendl; | ||
755 | } | ||
756 | |||
618 | sMappedCount++; | 757 | sMappedCount++; |
619 | } | 758 | } |
620 | 759 | ||
@@ -666,7 +805,12 @@ template <class T,S32 type> struct VertexBufferStrider | |||
666 | strider_t& strider, | 805 | strider_t& strider, |
667 | S32 index) | 806 | S32 index) |
668 | { | 807 | { |
669 | vbo.mapBuffer(); | 808 | if (vbo.mapBuffer() == NULL) |
809 | { | ||
810 | llwarns << "mapBuffer failed!" << llendl; | ||
811 | return FALSE; | ||
812 | } | ||
813 | |||
670 | if (type == LLVertexBuffer::TYPE_INDEX) | 814 | if (type == LLVertexBuffer::TYPE_INDEX) |
671 | { | 815 | { |
672 | S32 stride = sizeof(T); | 816 | S32 stride = sizeof(T); |
@@ -828,6 +972,8 @@ void LLVertexBuffer::setBuffer(U32 data_mask) | |||
828 | sIBOActive = FALSE; | 972 | sIBOActive = FALSE; |
829 | } | 973 | } |
830 | } | 974 | } |
975 | |||
976 | setupClientArrays(data_mask); | ||
831 | 977 | ||
832 | if (mGLIndices) | 978 | if (mGLIndices) |
833 | { | 979 | { |
@@ -846,8 +992,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask) | |||
846 | sSetCount++; | 992 | sSetCount++; |
847 | } | 993 | } |
848 | } | 994 | } |
849 | |||
850 | sLastMask = data_mask; | ||
851 | } | 995 | } |
852 | 996 | ||
853 | // virtual (default) | 997 | // virtual (default) |
@@ -871,10 +1015,10 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const | |||
871 | { | 1015 | { |
872 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | 1016 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
873 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD2])); | 1017 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD2])); |
1018 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
874 | } | 1019 | } |
875 | if (data_mask & MAP_TEXCOORD) | 1020 | if (data_mask & MAP_TEXCOORD) |
876 | { | 1021 | { |
877 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
878 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD])); | 1022 | glTexCoordPointer(2,GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_TEXCOORD])); |
879 | } | 1023 | } |
880 | if (data_mask & MAP_COLOR) | 1024 | if (data_mask & MAP_COLOR) |
diff --git a/linden/indra/llrender/llvertexbuffer.h b/linden/indra/llrender/llvertexbuffer.h index 3031b2d..453f3ac 100644 --- a/linden/indra/llrender/llvertexbuffer.h +++ b/linden/indra/llrender/llvertexbuffer.h | |||
@@ -84,6 +84,7 @@ public: | |||
84 | 84 | ||
85 | static void initClass(bool use_vbo); | 85 | static void initClass(bool use_vbo); |
86 | static void cleanupClass(); | 86 | static void cleanupClass(); |
87 | static void setupClientArrays(U32 data_mask); | ||
87 | static void startRender(); //between start and stop render, no client copies will occur | 88 | static void startRender(); //between start and stop render, no client copies will occur |
88 | static void stopRender(); //any buffer not copied to GL will be rendered from client memory | 89 | static void stopRender(); //any buffer not copied to GL will be rendered from client memory |
89 | static void clientCopy(F64 max_time = 0.005); //copy data from client to GL | 90 | static void clientCopy(F64 max_time = 0.005); //copy data from client to GL |
@@ -123,6 +124,15 @@ public: | |||
123 | MAP_UNMAPPED = 0x8000 // Indicates that buffer has been logically un-mapped | 124 | MAP_UNMAPPED = 0x8000 // Indicates that buffer has been logically un-mapped |
124 | }; | 125 | }; |
125 | 126 | ||
127 | enum { | ||
128 | TRIANGLES = 0, | ||
129 | TRIANGLE_STRIP, | ||
130 | TRIANGLE_FAN, | ||
131 | POINTS, | ||
132 | LINES, | ||
133 | LINE_STRIP, | ||
134 | NUM_MODES | ||
135 | }; | ||
126 | protected: | 136 | protected: |
127 | friend class LLGLImmediate; | 137 | friend class LLGLImmediate; |
128 | 138 | ||
@@ -194,6 +204,9 @@ public: | |||
194 | 204 | ||
195 | void markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count); | 205 | void markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count); |
196 | 206 | ||
207 | void draw(U32 mode, U32 count, U32 indices_offset) const; | ||
208 | void drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const; | ||
209 | |||
197 | protected: | 210 | protected: |
198 | S32 mNumVerts; // Number of vertices allocated | 211 | S32 mNumVerts; // Number of vertices allocated |
199 | S32 mNumIndices; // Number of indices allocated | 212 | S32 mNumIndices; // Number of indices allocated |
@@ -241,6 +254,7 @@ public: | |||
241 | 254 | ||
242 | static BOOL sEnableVBOs; | 255 | static BOOL sEnableVBOs; |
243 | static S32 sTypeOffsets[TYPE_MAX]; | 256 | static S32 sTypeOffsets[TYPE_MAX]; |
257 | static U32 sGLMode[NUM_MODES]; | ||
244 | static U32 sGLRenderBuffer; | 258 | static U32 sGLRenderBuffer; |
245 | static U32 sGLRenderIndices; | 259 | static U32 sGLRenderIndices; |
246 | static BOOL sVBOActive; | 260 | static BOOL sVBOActive; |