Skip to content

Commit

Permalink
Merge pull request #3108 from AnalyticalGraphicsInc/failIfMajorPerfor…
Browse files Browse the repository at this point in the history
…manceCaveat

Default failIfMajorPerformanceCaveat to false
  • Loading branch information
pjcozzi committed Oct 20, 2015
2 parents c9968bc + 2b34d0a commit 1539c38
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Change Log
* Fixed token issue in `ArcGisMapServerImageryProvider`.
* `ImageryLayerFeatureInfo` now has an `imageryLayer` property, indicating the layer that contains the feature.
* Added `BoxOutlineGeometry.fromAxisAlignedBoundingBox` and `BoxGeometry.fromAxisAlignedBoundingBox` functions.
* The WebGL setting of `failIfMajorPerformanceCaveat` now defaults to `false`, which is the official WebGL default. This improves compatibility with out-of-date drivers and remote desktop sessions. Cesium will run slower in these cases instead of simply failing to load.

### 1.14 - 2015-10-01

Expand Down
39 changes: 14 additions & 25 deletions Source/Renderer/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,6 @@ define([

// Override select WebGL defaults
webglOptions.alpha = defaultValue(webglOptions.alpha, false); // WebGL default is true
webglOptions.failIfMajorPerformanceCaveat = defaultValue(webglOptions.failIfMajorPerformanceCaveat, true); // WebGL default is false

// Firefox 35 with ANGLE has a regression that causes alpha : false to affect all framebuffers
// Since we can't detect for ANGLE without a context, we just detect for Windows.
// https://github.com/AnalyticalGraphicsInc/cesium/issues/2431
if (FeatureDetection.isFirefox() && FeatureDetection.isWindows()) {
var firefoxVersion = FeatureDetection.firefoxVersion();
if (firefoxVersion[0] === 35) {
webglOptions.alpha = true;
}
}

var defaultToWebgl2 = false;
var webgl2Supported = (typeof WebGL2RenderingContext !== 'undefined');
Expand Down Expand Up @@ -294,32 +283,32 @@ define([
var textureFilterAnisotropic = options.allowTextureFilterAnisotropic ? getExtension(gl, ['EXT_texture_filter_anisotropic', 'WEBKIT_EXT_texture_filter_anisotropic']) : undefined;
this._textureFilterAnisotropic = !!textureFilterAnisotropic;
ContextLimits._maximumTextureFilterAnisotropy = defined(textureFilterAnisotropic) ? gl.getParameter(textureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 1.0;

var glCreateVertexArray;
var glBindVertexArray;
var glDeleteVertexArray;

var glDrawElementsInstanced;
var glDrawArraysInstanced;
var glVertexAttribDivisor;

var glDrawBuffers;

var vertexArrayObject;
var instancedArrays;
var drawBuffers;

if (webgl2) {
var that = this;

glCreateVertexArray = function () { return that._gl.createVertexArray(); };
glBindVertexArray = function(vao) { that._gl.bindVertexArray(vao); };
glDeleteVertexArray = function(vao) { that._gl.deleteVertexArray(vao); };

glDrawElementsInstanced = function(mode, count, type, offset, instanceCount) { gl.drawElementsInstanced(mode, count, type, offset, instanceCount); };
glDrawArraysInstanced = function(mode, first, count, instanceCount) { gl.drawArraysInstanced(mode, first, count, instanceCount); };
glVertexAttribDivisor = function(index, divisor) { gl.vertexAttribDivisor(index, divisor); };

glDrawBuffers = function(buffers) { gl.drawBuffers(buffers); };
} else {
vertexArrayObject = getExtension(gl, ['OES_vertex_array_object']);
Expand All @@ -328,30 +317,30 @@ define([
glBindVertexArray = function(vertexArray) { vertexArrayObject.bindVertexArrayOES(vertexArray); };
glDeleteVertexArray = function(vertexArray) { vertexArrayObject.deleteVertexArrayOES(vertexArray); };
}

instancedArrays = getExtension(gl, ['ANGLE_instanced_arrays']);
if (defined(instancedArrays)) {
glDrawElementsInstanced = function(mode, count, type, offset, instanceCount) { instancedArrays.drawElementsInstancedANGLE(mode, count, type, offset, instanceCount); };
glDrawArraysInstanced = function(mode, first, count, instanceCount) { instancedArrays.drawArraysInstancedANGLE(mode, first, count, instanceCount); };
glVertexAttribDivisor = function(index, divisor) { instancedArrays.vertexAttribDivisorANGLE(index, divisor); };
}

drawBuffers = getExtension(gl, ['WEBGL_draw_buffers']);
if (defined(drawBuffers)) {
glDrawBuffers = function(buffers) { drawBuffers.drawBuffersWEBGL(buffers); };
}
}

this.glCreateVertexArray = glCreateVertexArray;
this.glBindVertexArray = glBindVertexArray;
this.glDeleteVertexArray = glDeleteVertexArray;

this.glDrawElementsInstanced = glDrawElementsInstanced;
this.glDrawArraysInstanced = glDrawArraysInstanced;
this.glVertexAttribDivisor = glVertexAttribDivisor;

this.glDrawBuffers = glDrawBuffers;

this._vertexArrayObject = !!vertexArrayObject;
this._instancedArrays = !!instancedArrays;
this._drawBuffers = !!drawBuffers;
Expand Down
7 changes: 1 addition & 6 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ define([
* antialias : true,
* premultipliedAlpha : true,
* preserveDrawingBuffer : false,
* failIfMajorPerformanceCaveat : true
* failIfMajorPerformanceCaveat : false
* },
* allowTextureFilterAnisotropic : true
* }
Expand All @@ -152,11 +152,6 @@ define([
* <code>webgl.alpha</code> to true.
* </p>
* <p>
* <code>webgl.failIfMajorPerformanceCaveat</code> defaults to true, which ensures a context is not successfully created
* if the system has a major performance issue such as only supporting software rendering. The standard WebGL default is false,
* which is not appropriate for almost any Cesium app.
* </p>
* <p>
* The other <code>webgl</code> properties match the WebGL defaults for {@link http://www.khronos.org/registry/webgl/specs/latest/#5.2|WebGLContextAttributes}.
* </p>
* <p>
Expand Down
1 change: 0 additions & 1 deletion Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ defineSuite([
options = defaultValue(options, {});
options.contextOptions = defaultValue(options.contextOptions, {});
options.contextOptions.webgl = defaultValue(options.contextOptions.webgl, {});
options.contextOptions.webgl.failIfMajorPerformanceCaveat = false;

return new CesiumWidget(container, options);
}
Expand Down
1 change: 0 additions & 1 deletion Specs/createContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ define([
options.webgl = clone(defaultValue(options.webgl, {}));
options.webgl.alpha = defaultValue(options.webgl.alpha, true);
options.webgl.antialias = defaultValue(options.webgl.antialias, false);
options.webgl.failIfMajorPerformanceCaveat = false;


var canvas = createCanvas(canvasWidth, canvasHeight);
Expand Down
1 change: 0 additions & 1 deletion Specs/createScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ define([
var contextOptions = options.contextOptions;
contextOptions.webgl = defaultValue(contextOptions.webgl, {});
contextOptions.webgl.antialias = defaultValue(contextOptions.webgl.antialias, false);
contextOptions.webgl.failIfMajorPerformanceCaveat = false;

var scene = new Scene(options);

Expand Down
1 change: 0 additions & 1 deletion Specs/createViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ define([
options = defaultValue(options, {});
options.contextOptions = defaultValue(options.contextOptions, {});
options.contextOptions.webgl = defaultValue(options.contextOptions.webgl, {});
options.contextOptions.webgl.failIfMajorPerformanceCaveat = false;

return new Viewer(container, options);
}
Expand Down

0 comments on commit 1539c38

Please sign in to comment.