You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimize GL emulation prepareClientAttributes. Fix issues where the slow path was not able to handle unaligned source data. Annotate some unsupported cases. Remove liveClientAttributes, which does not seem to be a win in profiles.
Copy file name to clipboardexpand all lines: src/library_gl.js
+98-76
Original file line number
Diff line number
Diff line change
@@ -3367,7 +3367,6 @@ var LibraryGL = {
3367
3367
totalEnabledClientAttributes: 0,
3368
3368
enabledClientAttributes: [0,0],
3369
3369
clientAttributes: [],// raw data, including possible unneeded ones
3370
-
liveClientAttributes: [],// the ones actually alive in the current computation, sorted
3371
3370
currentRenderer: null,// Caches the currently active FFP emulation renderer, so that it does not have to be re-looked up unless relevant state changes.
3372
3371
modifiedClientAttributes: false,
3373
3372
clientActiveTexture: 0,
@@ -3430,17 +3429,17 @@ var LibraryGL = {
3430
3429
if(GLImmediate.currentRenderer){
3431
3430
returnGLImmediate.currentRenderer;
3432
3431
}
3433
-
// return a renderer object given the liveClientAttributes
3434
3432
// we maintain a cache of renderers, optimized to not generate garbage
3435
-
varattributes=GLImmediate.liveClientAttributes;
3436
3433
varcacheMap=GLImmediate.rendererCache;
3437
3434
vartemp;
3438
3435
varkeyView=cacheMap.getStaticKeyView().reset();
3439
3436
3440
3437
// By attrib state:
3441
3438
varenabledAttributesKey=0;
3442
-
for(vari=0;i<attributes.length;i++){
3443
-
enabledAttributesKey|=1<<attributes[i].name;
3439
+
for(vari=0;i<GLImmediate.MAX_TEXTURES+3;i++){
3440
+
if(GLImmediate.enabledClientAttributes[i]){
3441
+
enabledAttributesKey|=1<<i;
3442
+
}
3444
3443
}
3445
3444
keyView.next(enabledAttributesKey);
3446
3445
@@ -3471,7 +3470,13 @@ var LibraryGL = {
3471
3470
varrenderer=keyView.get();
3472
3471
if(!renderer){
3473
3472
#if GL_DEBUG
3474
-
Module.printErr('generating renderer for '+JSON.stringify(attributes));
3473
+
varliveClientAttributes=[];
3474
+
for(vari=0;i<GLImmediate.MAX_TEXTURES+3;i++){
3475
+
if(GLImmediate.enabledClientAttributes[i]){
3476
+
liveClientAttributes.push(clientAttributes[i]);
3477
+
}
3478
+
}
3479
+
Module.printErr('generating renderer for '+JSON.stringify(liveClientAttributes));
3475
3480
#endif
3476
3481
renderer=GLImmediate.createRenderer();
3477
3482
GLImmediate.currentRenderer=renderer;
@@ -4077,96 +4082,113 @@ var LibraryGL = {
4077
4082
// does not work for glBegin/End, where we generate renderer components dynamically and then
4078
4083
// disable them ourselves, but it does help with glDrawElements/Arrays.
4079
4084
if(!GLImmediate.modifiedClientAttributes){
4085
+
#if GL_ASSERTIONS
4086
+
if((GLImmediate.stride&3)!=0){
4087
+
Runtime.warnOnce('Warning: Rendering from client side vertex arrays where stride ('+GLImmediate.stride+') is not a multiple of four! This is not currently supported!');
// We are in cases (1) or (3): slow path, shuffle the data around into a single interleaved vertex buffer.
4127
+
// The immediate-mode glBegin()/glEnd() vertex submission gets automatically generated in appropriate layout,
4128
+
// so never need to come down this path if that was used.
4129
+
#if GL_ASSERTIONS
4130
+
Runtime.warnOnce('Rendering from planar client-side vertex arrays. This is a very slow emulation path! Use interleaved vertex arrays for best performance.');
// case (2): fast path, all data is interleaved to a single vertex array so we can get away with a single VBO upload.
4172
+
if(GL.currArrayBuffer){
4173
+
GLImmediate.vertexPointer=0;
4174
+
}else{
4175
+
GLImmediate.vertexPointer=clientStartPointer;
4154
4176
}
4155
-
#if ASSERTIONS
4156
-
assert(beginEnd||bytes<=stride);// if not begin-end, explicit stride should make sense with total byte size
4157
-
#endif
4158
-
if(bytes<stride){// ensure the size is that of the stride
4159
-
bytes=stride;
4177
+
for(vari=0;i<3+GLImmediate.MAX_TEXTURES;i++){
4178
+
if(GLImmediate.enabledClientAttributes[i]){
4179
+
varattr=GLImmediate.clientAttributes[i];
4180
+
attr.offset=attr.pointer-clientStartPointer;// Compute what will be the offset of this attribute in the VBO after we upload.
4181
+
}
4160
4182
}
4183
+
GLImmediate.stride=Math.max(maxStride,bytes);
4161
4184
}
4162
-
GLImmediate.stride=bytes;
4163
-
4164
4185
if(!beginEnd){
4165
-
bytes*=count;
4166
-
if(!GL.currArrayBuffer){
4167
-
GLImmediate.vertexPointer=start;
4186
+
#if GL_ASSERTIONS
4187
+
if((GLImmediate.stride&3)!=0){
4188
+
Runtime.warnOnce('Warning: Rendering from client side vertex arrays where stride ('+GLImmediate.stride+') is not a multiple of four! This is not currently supported!');
0 commit comments