Update surfman to 0.2 and remove glutin

This commit is contained in:
Alan Jeffrey 2020-01-09 17:28:46 -06:00
parent 9dbc6554f0
commit 8bb1732258
94 changed files with 2265 additions and 1513 deletions

View file

@ -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,

View file

@ -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);
}
}

View file

@ -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.