diff options
author | Alan Jeffrey <ajeffrey@mozilla.com> | 2020-01-09 17:28:46 -0600 |
---|---|---|
committer | Alan Jeffrey <ajeffrey@mozilla.com> | 2020-04-17 23:44:53 -0500 |
commit | 8bb1732258c44e6850618a8f2fbb2927bc01b090 (patch) | |
tree | e4483e94fd5fbceb15fe9e35e3d5a085d3b2b814 /components/script/dom | |
parent | 9dbc6554f087ca3675104fb1bac45b0c442a0158 (diff) | |
download | servo-8bb1732258c44e6850618a8f2fbb2927bc01b090.tar.gz servo-8bb1732258c44e6850618a8f2fbb2927bc01b090.zip |
Update surfman to 0.2 and remove glutin
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/webgl_extensions/extensions.rs | 22 | ||||
-rw-r--r-- | components/script/dom/webglrenderbuffer.rs | 2 | ||||
-rw-r--r-- | components/script/dom/webglshader.rs | 45 |
3 files changed, 64 insertions, 5 deletions
diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs index 2dc3ef8f11f..04e110b7ed0 100644 --- a/components/script/dom/webgl_extensions/extensions.rs +++ b/components/script/dom/webgl_extensions/extensions.rs @@ -52,12 +52,24 @@ const DEFAULT_DISABLED_GET_PARAMETER_NAMES_WEBGL1: [GLenum; 3] = [ OESVertexArrayObjectConstants::VERTEX_ARRAY_BINDING_OES, ]; +// Param names that are implemented for glGetParameter in a WebGL 2.0 context +// but must trigger a InvalidEnum error until the related WebGL Extensions are enabled. +// Example: https://www.khronos.org/registry/webgl/extensions/EXT_texture_filter_anisotropic/ +const DEFAULT_DISABLED_GET_PARAMETER_NAMES_WEBGL2: [GLenum; 1] = + [EXTTextureFilterAnisotropicConstants::MAX_TEXTURE_MAX_ANISOTROPY_EXT]; + // Param names that are implemented for glGetTexParameter in a WebGL 1.0 context // but must trigger a InvalidEnum error until the related WebGL Extensions are enabled. // Example: https://www.khronos.org/registry/webgl/extensions/OES_standard_derivatives/ const DEFAULT_DISABLED_GET_TEX_PARAMETER_NAMES_WEBGL1: [GLenum; 1] = [EXTTextureFilterAnisotropicConstants::TEXTURE_MAX_ANISOTROPY_EXT]; +// Param names that are implemented for glGetTexParameter in a WebGL 2.0 context +// but must trigger a InvalidEnum error until the related WebGL Extensions are enabled. +// Example: https://www.khronos.org/registry/webgl/extensions/EXT_texture_filter_anisotropic/ +const DEFAULT_DISABLED_GET_TEX_PARAMETER_NAMES_WEBGL2: [GLenum; 1] = + [EXTTextureFilterAnisotropicConstants::TEXTURE_MAX_ANISOTROPY_EXT]; + // Param names that are implemented for glGetVertexAttrib in a WebGL 1.0 context // but must trigger a InvalidEnum error until the related WebGL Extensions are enabled. // Example: https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/ @@ -116,8 +128,14 @@ impl WebGLExtensionFeatures { ), WebGLVersion::WebGL2 => ( Default::default(), - Default::default(), - Default::default(), + DEFAULT_DISABLED_GET_PARAMETER_NAMES_WEBGL2 + .iter() + .cloned() + .collect(), + DEFAULT_DISABLED_GET_TEX_PARAMETER_NAMES_WEBGL2 + .iter() + .cloned() + .collect(), Default::default(), true, true, diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index 51f1bdbad4e..f1a3ba99c53 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -233,7 +233,7 @@ impl WebGLRenderbuffer { ), ); let samples = receiver.recv().unwrap(); - if sample_count < 0 || sample_count as usize > samples.len() { + if sample_count < 0 || sample_count > samples.get(0).cloned().unwrap_or(0) { return Err(WebGLError::InvalidOperation); } } diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 5302c6c78ad..9be334f6595 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -277,8 +277,49 @@ impl WebGLShader { }, }; - match validator.compile_and_translate(&[&source]) { - Ok(translated_source) => { + // Replicating + // https://searchfox.org/mozilla-central/rev/c621276fbdd9591f52009042d959b9e19b66d49f/dom/canvas/WebGLShaderValidator.cpp#32 + let options = mozangle::shaders::ffi::SH_VARIABLES | + mozangle::shaders::ffi::SH_ENFORCE_PACKING_RESTRICTIONS | + mozangle::shaders::ffi::SH_OBJECT_CODE | + mozangle::shaders::ffi::SH_INIT_GL_POSITION | + mozangle::shaders::ffi::SH_INITIALIZE_UNINITIALIZED_LOCALS | + mozangle::shaders::ffi::SH_INIT_OUTPUT_VARIABLES | + mozangle::shaders::ffi::SH_LIMIT_EXPRESSION_COMPLEXITY | + mozangle::shaders::ffi::SH_LIMIT_CALL_STACK_DEPTH | + if cfg!(target_os = "macos") { + // Work around https://bugs.webkit.org/show_bug.cgi?id=124684, + // https://chromium.googlesource.com/angle/angle/+/5e70cf9d0b1bb + mozangle::shaders::ffi::SH_UNFOLD_SHORT_CIRCUIT | + // Work around that Mac drivers handle struct scopes incorrectly. + mozangle::shaders::ffi::SH_REGENERATE_STRUCT_NAMES | + // Work around that Intel drivers on Mac OSX handle for-loop incorrectly. + mozangle::shaders::ffi::SH_ADD_AND_TRUE_TO_LOOP_CONDITION + } else { + // We want to do this everywhere, but to do this on Mac, we need + // to do it only on Mac OSX > 10.6 as this causes the shader + // compiler in 10.6 to crash + mozangle::shaders::ffi::SH_CLAMP_INDIRECT_ARRAY_BOUNDS + }; + + // Replicating + // https://github.com/servo/mozangle/blob/706a9baaf8026c1a3cb6c67ba63aa5f4734264d0/src/shaders/mod.rs#L226 + let options = options | + mozangle::shaders::ffi::SH_VALIDATE | + mozangle::shaders::ffi::SH_OBJECT_CODE | + mozangle::shaders::ffi::SH_VARIABLES | // For uniform_name_map() + mozangle::shaders::ffi::SH_EMULATE_ABS_INT_FUNCTION | // To workaround drivers + mozangle::shaders::ffi::SH_EMULATE_ISNAN_FLOAT_FUNCTION | // To workaround drivers + mozangle::shaders::ffi::SH_EMULATE_ATAN2_FLOAT_FUNCTION | // To workaround drivers + mozangle::shaders::ffi::SH_CLAMP_INDIRECT_ARRAY_BOUNDS | + mozangle::shaders::ffi::SH_INIT_GL_POSITION | + mozangle::shaders::ffi::SH_ENFORCE_PACKING_RESTRICTIONS | + mozangle::shaders::ffi::SH_LIMIT_EXPRESSION_COMPLEXITY | + mozangle::shaders::ffi::SH_LIMIT_CALL_STACK_DEPTH; + + match validator.compile(&[&source], options) { + Ok(()) => { + let translated_source = validator.object_code(); debug!("Shader translated: {}", translated_source); // NOTE: At this point we should be pretty sure that the compilation in the paint thread // will succeed. |