mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Implement OES_element_index_uint (fixes #20384)
This commit is contained in:
parent
8061d8c3d2
commit
838d1305ca
6 changed files with 127 additions and 5 deletions
|
@ -5,6 +5,7 @@
|
||||||
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
|
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
|
||||||
use super::{ext_constants, WebGLExtension, WebGLExtensions, WebGLExtensionSpec};
|
use super::{ext_constants, WebGLExtension, WebGLExtensions, WebGLExtensionSpec};
|
||||||
|
|
||||||
|
pub mod oeselementindexuint;
|
||||||
pub mod oesstandardderivatives;
|
pub mod oesstandardderivatives;
|
||||||
pub mod oestexturefloat;
|
pub mod oestexturefloat;
|
||||||
pub mod oestexturefloatlinear;
|
pub mod oestexturefloatlinear;
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use canvas_traits::webgl::WebGLVersion;
|
||||||
|
use dom::bindings::codegen::Bindings::OESElementIndexUintBinding;
|
||||||
|
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
|
||||||
|
use dom::bindings::root::DomRoot;
|
||||||
|
use dom::webglrenderingcontext::WebGLRenderingContext;
|
||||||
|
use dom_struct::dom_struct;
|
||||||
|
use super::{WebGLExtension, WebGLExtensions, WebGLExtensionSpec};
|
||||||
|
|
||||||
|
#[dom_struct]
|
||||||
|
pub struct OESElementIndexUint {
|
||||||
|
reflector_: Reflector,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OESElementIndexUint {
|
||||||
|
fn new_inherited() -> Self {
|
||||||
|
Self { reflector_: Reflector::new() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WebGLExtension for OESElementIndexUint {
|
||||||
|
type Extension = Self;
|
||||||
|
|
||||||
|
fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> {
|
||||||
|
reflect_dom_object(
|
||||||
|
Box::new(OESElementIndexUint::new_inherited()),
|
||||||
|
&*ctx.global(),
|
||||||
|
OESElementIndexUintBinding::Wrap,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn spec() -> WebGLExtensionSpec {
|
||||||
|
WebGLExtensionSpec::Specific(WebGLVersion::WebGL1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_supported(ext: &WebGLExtensions) -> bool {
|
||||||
|
ext.supports_gl_extension("GL_OES_element_index_uint")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn enable(ext: &WebGLExtensions) {
|
||||||
|
ext.enable_element_index_uint();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn name() -> &'static str {
|
||||||
|
"OES_element_index_uint"
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,17 +57,20 @@ struct WebGLExtensionFeatures {
|
||||||
hint_targets: FnvHashSet<GLenum>,
|
hint_targets: FnvHashSet<GLenum>,
|
||||||
/// WebGL GetParameter() names enabled by extensions.
|
/// WebGL GetParameter() names enabled by extensions.
|
||||||
disabled_get_parameter_names: FnvHashSet<GLenum>,
|
disabled_get_parameter_names: FnvHashSet<GLenum>,
|
||||||
|
/// WebGL OES_element_index_uint extension.
|
||||||
|
element_index_uint_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebGLExtensionFeatures {
|
impl WebGLExtensionFeatures {
|
||||||
fn new(webgl_version: WebGLVersion) -> Self {
|
fn new(webgl_version: WebGLVersion) -> Self {
|
||||||
let (disabled_tex_types, disabled_get_parameter_names) = match webgl_version {
|
let (disabled_tex_types, disabled_get_parameter_names, element_index_uint_enabled) = match webgl_version {
|
||||||
WebGLVersion::WebGL1 => {
|
WebGLVersion::WebGL1 => {
|
||||||
(DEFAULT_DISABLED_TEX_TYPES_WEBGL1.iter().cloned().collect(),
|
(DEFAULT_DISABLED_TEX_TYPES_WEBGL1.iter().cloned().collect(),
|
||||||
DEFAULT_DISABLED_GET_PARAMETER_NAMES_WEBGL1.iter().cloned().collect())
|
DEFAULT_DISABLED_GET_PARAMETER_NAMES_WEBGL1.iter().cloned().collect(),
|
||||||
|
false)
|
||||||
},
|
},
|
||||||
WebGLVersion::WebGL2 => {
|
WebGLVersion::WebGL2 => {
|
||||||
(Default::default(), Default::default())
|
(Default::default(), Default::default(), true)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
|
@ -78,6 +81,7 @@ impl WebGLExtensionFeatures {
|
||||||
query_parameter_handlers: Default::default(),
|
query_parameter_handlers: Default::default(),
|
||||||
hint_targets: Default::default(),
|
hint_targets: Default::default(),
|
||||||
disabled_get_parameter_names,
|
disabled_get_parameter_names,
|
||||||
|
element_index_uint_enabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +100,7 @@ impl WebGLExtensions {
|
||||||
Self {
|
Self {
|
||||||
extensions: DomRefCell::new(HashMap::new()),
|
extensions: DomRefCell::new(HashMap::new()),
|
||||||
features: DomRefCell::new(WebGLExtensionFeatures::new(webgl_version)),
|
features: DomRefCell::new(WebGLExtensionFeatures::new(webgl_version)),
|
||||||
webgl_version
|
webgl_version,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,6 +244,14 @@ impl WebGLExtensions {
|
||||||
self.register::<ext::oestexturehalffloatlinear::OESTextureHalfFloatLinear>();
|
self.register::<ext::oestexturehalffloatlinear::OESTextureHalfFloatLinear>();
|
||||||
self.register::<ext::oesvertexarrayobject::OESVertexArrayObject>();
|
self.register::<ext::oesvertexarrayobject::OESVertexArrayObject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn enable_element_index_uint(&self) {
|
||||||
|
self.features.borrow_mut().element_index_uint_enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_element_index_uint_enabled(&self) -> bool {
|
||||||
|
self.features.borrow().element_index_uint_enabled
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper structs
|
// Helper structs
|
||||||
|
|
|
@ -2163,6 +2163,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
let type_size = match type_ {
|
let type_size = match type_ {
|
||||||
constants::UNSIGNED_BYTE => 1,
|
constants::UNSIGNED_BYTE => 1,
|
||||||
constants::UNSIGNED_SHORT => 2,
|
constants::UNSIGNED_SHORT => 2,
|
||||||
|
constants::UNSIGNED_INT if self.extension_manager.is_element_index_uint_enabled() => 4,
|
||||||
_ => return self.webgl_error(InvalidEnum),
|
_ => return self.webgl_error(InvalidEnum),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
11
components/script/dom/webidls/OESElementIndexUint.webidl
Normal file
11
components/script/dom/webidls/OESElementIndexUint.webidl
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
/*
|
||||||
|
* WebGL IDL definitions from the Khronos specification:
|
||||||
|
* https://www.khronos.org/registry/webgl/extensions/OES_element_index_uint/
|
||||||
|
*/
|
||||||
|
|
||||||
|
[NoInterfaceObject]
|
||||||
|
interface OESElementIndexUint {
|
||||||
|
};
|
|
@ -1,8 +1,55 @@
|
||||||
[element-index-uint.html]
|
[element-index-uint.html]
|
||||||
expected: ERROR
|
|
||||||
[WebGL test #1: Draw 0 failed pixel test]
|
[WebGL test #1: Draw 0 failed pixel test]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #2: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
[WebGL test #2: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #11: getError expected: INVALID_OPERATION. Was NO_ERROR : ]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #14: getError expected: INVALID_OPERATION. Was NO_ERROR : ]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #20: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #21: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #23: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #24: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #33: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #34: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #49: getError expected: INVALID_OPERATION. Was NO_ERROR : ]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #52: getError expected: INVALID_OPERATION. Was NO_ERROR : ]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #58: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #59: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #61: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #62: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #71: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[WebGL test #72: getError expected: INVALID_OPERATION. Was NO_ERROR : after evaluating: gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue