mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Add WebGLSampler support
Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.13
This commit is contained in:
parent
78438113d4
commit
26df1962c3
16 changed files with 394 additions and 88 deletions
|
@ -1637,6 +1637,30 @@ impl WebGLImpl {
|
|||
let value = ctx.gl().get_query_object_uiv(query_id.get(), pname);
|
||||
sender.send(value).unwrap()
|
||||
},
|
||||
WebGLCommand::GenerateSampler(ref sender) => {
|
||||
let id = ctx.gl().gen_samplers(1)[0];
|
||||
sender.send(unsafe { WebGLSamplerId::new(id) }).unwrap()
|
||||
},
|
||||
WebGLCommand::DeleteSampler(sampler_id) => {
|
||||
ctx.gl().delete_samplers(&[sampler_id.get()]);
|
||||
},
|
||||
WebGLCommand::BindSampler(unit, sampler_id) => {
|
||||
ctx.gl().bind_sampler(unit, sampler_id.get());
|
||||
},
|
||||
WebGLCommand::SetSamplerParameterInt(sampler_id, pname, value) => {
|
||||
ctx.gl().sampler_parameter_i(sampler_id.get(), pname, value);
|
||||
},
|
||||
WebGLCommand::SetSamplerParameterFloat(sampler_id, pname, value) => {
|
||||
ctx.gl().sampler_parameter_f(sampler_id.get(), pname, value);
|
||||
},
|
||||
WebGLCommand::GetSamplerParameterInt(sampler_id, pname, ref sender) => {
|
||||
let value = ctx.gl().get_sampler_parameter_iv(sampler_id.get(), pname)[0];
|
||||
sender.send(value).unwrap();
|
||||
},
|
||||
WebGLCommand::GetSamplerParameterFloat(sampler_id, pname, ref sender) => {
|
||||
let value = ctx.gl().get_sampler_parameter_fv(sampler_id.get(), pname)[0];
|
||||
sender.send(value).unwrap();
|
||||
},
|
||||
}
|
||||
|
||||
// TODO: update test expectations in order to enable debug assertions
|
||||
|
|
|
@ -438,6 +438,13 @@ pub enum WebGLCommand {
|
|||
EndQuery(u32),
|
||||
GenerateQuery(WebGLSender<WebGLQueryId>),
|
||||
GetQueryState(WebGLSender<u32>, WebGLQueryId, u32),
|
||||
GenerateSampler(WebGLSender<WebGLSamplerId>),
|
||||
DeleteSampler(WebGLSamplerId),
|
||||
BindSampler(u32, WebGLSamplerId),
|
||||
SetSamplerParameterFloat(WebGLSamplerId, u32, f32),
|
||||
SetSamplerParameterInt(WebGLSamplerId, u32, i32),
|
||||
GetSamplerParameterFloat(WebGLSamplerId, u32, WebGLSender<f32>),
|
||||
GetSamplerParameterInt(WebGLSamplerId, u32, WebGLSender<i32>),
|
||||
}
|
||||
|
||||
macro_rules! nonzero_type {
|
||||
|
@ -519,6 +526,7 @@ define_resource_id!(WebGLRenderbufferId, u32);
|
|||
define_resource_id!(WebGLTextureId, u32);
|
||||
define_resource_id!(WebGLProgramId, u32);
|
||||
define_resource_id!(WebGLQueryId, u32);
|
||||
define_resource_id!(WebGLSamplerId, u32);
|
||||
define_resource_id!(WebGLShaderId, u32);
|
||||
define_resource_id!(WebGLSyncId, u64);
|
||||
define_resource_id!(WebGLVertexArrayId, u32);
|
||||
|
|
|
@ -47,7 +47,7 @@ use canvas_traits::canvas::{
|
|||
use canvas_traits::canvas::{CompositionOrBlending, LineCapStyle, LineJoinStyle, RepetitionStyle};
|
||||
use canvas_traits::webgl::WebGLVertexArrayId;
|
||||
use canvas_traits::webgl::{ActiveAttribInfo, ActiveUniformInfo, GlType, TexDataType, TexFormat};
|
||||
use canvas_traits::webgl::{GLFormats, GLLimits, WebGLQueryId};
|
||||
use canvas_traits::webgl::{GLFormats, GLLimits, WebGLQueryId, WebGLSamplerId};
|
||||
use canvas_traits::webgl::{WebGLBufferId, WebGLChan, WebGLContextShareMode, WebGLError};
|
||||
use canvas_traits::webgl::{WebGLFramebufferId, WebGLMsgSender, WebGLPipeline, WebGLProgramId};
|
||||
use canvas_traits::webgl::{WebGLReceiver, WebGLRenderbufferId, WebGLSLVersion, WebGLSender};
|
||||
|
@ -480,6 +480,7 @@ unsafe_no_jsmanaged_fields!(WebGLPipeline);
|
|||
unsafe_no_jsmanaged_fields!(WebGLProgramId);
|
||||
unsafe_no_jsmanaged_fields!(WebGLQueryId);
|
||||
unsafe_no_jsmanaged_fields!(WebGLRenderbufferId);
|
||||
unsafe_no_jsmanaged_fields!(WebGLSamplerId);
|
||||
unsafe_no_jsmanaged_fields!(WebGLShaderId);
|
||||
unsafe_no_jsmanaged_fields!(WebGLSyncId);
|
||||
unsafe_no_jsmanaged_fields!(WebGLTextureId);
|
||||
|
|
|
@ -660,3 +660,14 @@ macro_rules! impl_rare_data (
|
|||
}
|
||||
);
|
||||
);
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! optional_root_object_to_js_or_null {
|
||||
($cx: expr, $binding:expr) => {{
|
||||
rooted!(in($cx) let mut rval = NullValue());
|
||||
if let Some(object) = $binding {
|
||||
object.to_jsval($cx, rval.handle_mut());
|
||||
}
|
||||
rval.get()
|
||||
}};
|
||||
}
|
||||
|
|
|
@ -525,6 +525,7 @@ pub mod webglprogram;
|
|||
pub mod webglquery;
|
||||
pub mod webglrenderbuffer;
|
||||
pub mod webglrenderingcontext;
|
||||
pub mod webglsampler;
|
||||
pub mod webglshader;
|
||||
pub mod webglshaderprecisionformat;
|
||||
pub mod webglsync;
|
||||
|
|
|
@ -11,6 +11,7 @@ use crate::dom::bindings::codegen::UnionTypes::ArrayBufferViewOrArrayBuffer;
|
|||
use crate::dom::bindings::codegen::UnionTypes::Float32ArrayOrUnrestrictedFloatSequence;
|
||||
use crate::dom::bindings::codegen::UnionTypes::ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement;
|
||||
use crate::dom::bindings::codegen::UnionTypes::Int32ArrayOrLongSequence;
|
||||
use crate::dom::bindings::conversions::ToJSValConvertible;
|
||||
use crate::dom::bindings::error::{ErrorResult, Fallible};
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom};
|
||||
|
@ -26,6 +27,7 @@ use crate::dom::webglrenderbuffer::WebGLRenderbuffer;
|
|||
use crate::dom::webglrenderingcontext::{
|
||||
LayoutCanvasWebGLRenderingContextHelpers, WebGLRenderingContext,
|
||||
};
|
||||
use crate::dom::webglsampler::{WebGLSampler, WebGLSamplerValue};
|
||||
use crate::dom::webglshader::WebGLShader;
|
||||
use crate::dom::webglshaderprecisionformat::WebGLShaderPrecisionFormat;
|
||||
use crate::dom::webglsync::WebGLSync;
|
||||
|
@ -39,7 +41,7 @@ use canvas_traits::webgl::{webgl_channel, GLContextAttributes, WebGLCommand, Web
|
|||
use dom_struct::dom_struct;
|
||||
use euclid::default::Size2D;
|
||||
use js::jsapi::JSObject;
|
||||
use js::jsval::{BooleanValue, Int32Value, JSVal, NullValue, UInt32Value};
|
||||
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UInt32Value};
|
||||
use js::rust::CustomAutoRooterGuard;
|
||||
use js::typedarray::ArrayBufferView;
|
||||
use script_layout_interface::HTMLCanvasDataSource;
|
||||
|
@ -51,6 +53,7 @@ pub struct WebGL2RenderingContext {
|
|||
base: Dom<WebGLRenderingContext>,
|
||||
occlusion_query: MutNullableDom<WebGLQuery>,
|
||||
primitives_query: MutNullableDom<WebGLQuery>,
|
||||
samplers: Box<[MutNullableDom<WebGLSampler>]>,
|
||||
}
|
||||
|
||||
impl WebGL2RenderingContext {
|
||||
|
@ -61,11 +64,18 @@ impl WebGL2RenderingContext {
|
|||
attrs: GLContextAttributes,
|
||||
) -> Option<WebGL2RenderingContext> {
|
||||
let base = WebGLRenderingContext::new(window, canvas, WebGLVersion::WebGL2, size, attrs)?;
|
||||
|
||||
let samplers = (0..base.limits().max_combined_texture_image_units)
|
||||
.map(|_| Default::default())
|
||||
.collect::<Vec<_>>()
|
||||
.into();
|
||||
|
||||
Some(WebGL2RenderingContext {
|
||||
reflector_: Reflector::new(),
|
||||
base: Dom::from_ref(&*base),
|
||||
occlusion_query: MutNullableDom::new(None),
|
||||
primitives_query: MutNullableDom::new(None),
|
||||
samplers: samplers,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -130,6 +140,12 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
constants::MAX_CLIENT_WAIT_TIMEOUT_WEBGL => {
|
||||
Int32Value(self.base.limits().max_client_wait_timeout_webgl.as_nanos() as i32)
|
||||
},
|
||||
constants::SAMPLER_BINDING => unsafe {
|
||||
let idx = (self.base.textures().active_unit_enum() - constants::TEXTURE0) as usize;
|
||||
assert!(idx < self.samplers.len());
|
||||
let sampler = self.samplers[idx].get();
|
||||
optional_root_object_to_js_or_null!(*cx, sampler)
|
||||
},
|
||||
_ => self.base.GetParameter(cx, parameter),
|
||||
}
|
||||
}
|
||||
|
@ -1099,6 +1115,32 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.13
|
||||
fn CreateSampler(&self) -> Option<DomRoot<WebGLSampler>> {
|
||||
Some(WebGLSampler::new(&self.base))
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.13
|
||||
fn DeleteSampler(&self, sampler: Option<&WebGLSampler>) {
|
||||
if let Some(sampler) = sampler {
|
||||
handle_potential_webgl_error!(self.base, self.base.validate_ownership(sampler), return);
|
||||
for slot in self.samplers.iter() {
|
||||
if slot.get().map_or(false, |s| sampler == &*s) {
|
||||
slot.set(None);
|
||||
}
|
||||
}
|
||||
sampler.delete(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.13
|
||||
fn IsSampler(&self, sampler: Option<&WebGLSampler>) -> bool {
|
||||
match sampler {
|
||||
Some(sampler) => self.base.validate_ownership(sampler).is_ok() && sampler.is_valid(),
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12
|
||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
fn BeginQuery(&self, target: u32, query: &WebGLQuery) {
|
||||
|
@ -1321,6 +1363,63 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
sync.delete(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.13
|
||||
fn BindSampler(&self, unit: u32, sampler: Option<&WebGLSampler>) {
|
||||
if let Some(sampler) = sampler {
|
||||
handle_potential_webgl_error!(self.base, self.base.validate_ownership(sampler), return);
|
||||
|
||||
if unit as usize >= self.samplers.len() {
|
||||
self.base.webgl_error(InvalidValue);
|
||||
return;
|
||||
}
|
||||
|
||||
let result = sampler.bind(&self.base, unit);
|
||||
match result {
|
||||
Ok(_) => self.samplers[unit as usize].set(Some(sampler)),
|
||||
Err(error) => self.base.webgl_error(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.13
|
||||
fn SamplerParameteri(&self, sampler: &WebGLSampler, pname: u32, param: i32) {
|
||||
handle_potential_webgl_error!(self.base, self.base.validate_ownership(sampler), return);
|
||||
let param = WebGLSamplerValue::GLenum(param as u32);
|
||||
let result = sampler.set_parameter(&self.base, pname, param);
|
||||
if let Err(error) = result {
|
||||
self.base.webgl_error(error);
|
||||
}
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.13
|
||||
fn SamplerParameterf(&self, sampler: &WebGLSampler, pname: u32, param: f32) {
|
||||
handle_potential_webgl_error!(self.base, self.base.validate_ownership(sampler), return);
|
||||
let param = WebGLSamplerValue::Float(param);
|
||||
let result = sampler.set_parameter(&self.base, pname, param);
|
||||
if let Err(error) = result {
|
||||
self.base.webgl_error(error);
|
||||
}
|
||||
}
|
||||
|
||||
/// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.13
|
||||
fn GetSamplerParameter(&self, _cx: JSContext, sampler: &WebGLSampler, pname: u32) -> JSVal {
|
||||
handle_potential_webgl_error!(
|
||||
self.base,
|
||||
self.base.validate_ownership(sampler),
|
||||
return NullValue()
|
||||
);
|
||||
match sampler.get_parameter(&self.base, pname) {
|
||||
Ok(value) => match value {
|
||||
WebGLSamplerValue::GLenum(value) => UInt32Value(value),
|
||||
WebGLSamplerValue::Float(value) => DoubleValue(value as f64),
|
||||
},
|
||||
Err(error) => {
|
||||
self.base.webgl_error(error);
|
||||
NullValue()
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGL2RenderingContext> {
|
||||
|
|
|
@ -103,16 +103,6 @@ macro_rules! handle_object_deletion {
|
|||
};
|
||||
}
|
||||
|
||||
macro_rules! optional_root_object_to_js_or_null {
|
||||
($cx: expr, $binding:expr) => {{
|
||||
rooted!(in($cx) let mut rval = NullValue());
|
||||
if let Some(object) = $binding {
|
||||
object.to_jsval($cx, rval.handle_mut());
|
||||
}
|
||||
rval.get()
|
||||
}};
|
||||
}
|
||||
|
||||
fn has_invalid_blend_constants(arg1: u32, arg2: u32) -> bool {
|
||||
match (arg1, arg2) {
|
||||
(constants::CONSTANT_COLOR, constants::CONSTANT_ALPHA) => true,
|
||||
|
@ -4259,7 +4249,7 @@ impl Textures {
|
|||
}
|
||||
}
|
||||
|
||||
fn active_unit_enum(&self) -> u32 {
|
||||
pub fn active_unit_enum(&self) -> u32 {
|
||||
self.active_unit.get() + constants::TEXTURE0
|
||||
}
|
||||
|
||||
|
|
187
components/script/dom/webglsampler.rs
Normal file
187
components/script/dom/webglsampler.rs
Normal file
|
@ -0,0 +1,187 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGLSamplerBinding;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::webglobject::WebGLObject;
|
||||
use crate::dom::webglrenderingcontext::WebGLRenderingContext;
|
||||
use canvas_traits::webgl::WebGLError::*;
|
||||
use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLSamplerId};
|
||||
use dom_struct::dom_struct;
|
||||
use std::cell::Cell;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct WebGLSampler {
|
||||
webgl_object: WebGLObject,
|
||||
gl_id: WebGLSamplerId,
|
||||
marked_for_deletion: Cell<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum WebGLSamplerValue {
|
||||
Float(f32),
|
||||
GLenum(u32),
|
||||
}
|
||||
|
||||
fn validate_params(pname: u32, value: WebGLSamplerValue) -> bool {
|
||||
match value {
|
||||
WebGLSamplerValue::GLenum(value) => {
|
||||
let allowed_values = match pname {
|
||||
constants::TEXTURE_MIN_FILTER => &[
|
||||
constants::NEAREST,
|
||||
constants::LINEAR,
|
||||
constants::NEAREST_MIPMAP_NEAREST,
|
||||
constants::LINEAR_MIPMAP_NEAREST,
|
||||
constants::NEAREST_MIPMAP_LINEAR,
|
||||
constants::LINEAR_MIPMAP_LINEAR,
|
||||
][..],
|
||||
constants::TEXTURE_MAG_FILTER => &[constants::NEAREST, constants::LINEAR][..],
|
||||
constants::TEXTURE_WRAP_R |
|
||||
constants::TEXTURE_WRAP_S |
|
||||
constants::TEXTURE_WRAP_T => &[
|
||||
constants::CLAMP_TO_EDGE,
|
||||
constants::MIRRORED_REPEAT,
|
||||
constants::REPEAT,
|
||||
][..],
|
||||
constants::TEXTURE_COMPARE_MODE => {
|
||||
&[constants::NONE, constants::COMPARE_REF_TO_TEXTURE][..]
|
||||
},
|
||||
constants::TEXTURE_COMPARE_FUNC => &[
|
||||
constants::LEQUAL,
|
||||
constants::GEQUAL,
|
||||
constants::LESS,
|
||||
constants::GREATER,
|
||||
constants::EQUAL,
|
||||
constants::NOTEQUAL,
|
||||
constants::ALWAYS,
|
||||
constants::NEVER,
|
||||
][..],
|
||||
_ => &[][..],
|
||||
};
|
||||
allowed_values.contains(&value)
|
||||
},
|
||||
WebGLSamplerValue::Float(_) => match pname {
|
||||
constants::TEXTURE_MIN_LOD | constants::TEXTURE_MAX_LOD => true,
|
||||
_ => false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
impl WebGLSampler {
|
||||
fn new_inherited(context: &WebGLRenderingContext, id: WebGLSamplerId) -> Self {
|
||||
Self {
|
||||
webgl_object: WebGLObject::new_inherited(context),
|
||||
gl_id: id,
|
||||
marked_for_deletion: Cell::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(context: &WebGLRenderingContext) -> DomRoot<Self> {
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
context.send_command(WebGLCommand::GenerateSampler(sender));
|
||||
let id = receiver.recv().unwrap();
|
||||
|
||||
reflect_dom_object(
|
||||
Box::new(Self::new_inherited(context, id)),
|
||||
&*context.global(),
|
||||
WebGLSamplerBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn delete(&self, fallible: bool) {
|
||||
if !self.marked_for_deletion.get() {
|
||||
self.marked_for_deletion.set(true);
|
||||
|
||||
let command = WebGLCommand::DeleteSampler(self.gl_id);
|
||||
let context = self.upcast::<WebGLObject>().context();
|
||||
if fallible {
|
||||
context.send_command_ignored(command);
|
||||
} else {
|
||||
context.send_command(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_valid(&self) -> bool {
|
||||
!self.marked_for_deletion.get()
|
||||
}
|
||||
|
||||
pub fn bind(
|
||||
&self,
|
||||
context: &WebGLRenderingContext,
|
||||
unit: u32,
|
||||
) -> Result<(), canvas_traits::webgl::WebGLError> {
|
||||
if !self.is_valid() {
|
||||
return Err(InvalidOperation);
|
||||
}
|
||||
context.send_command(WebGLCommand::BindSampler(unit, self.gl_id));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_parameter(
|
||||
&self,
|
||||
context: &WebGLRenderingContext,
|
||||
pname: u32,
|
||||
value: WebGLSamplerValue,
|
||||
) -> Result<(), canvas_traits::webgl::WebGLError> {
|
||||
if !self.is_valid() {
|
||||
return Err(InvalidOperation);
|
||||
}
|
||||
if !validate_params(pname, value) {
|
||||
return Err(InvalidEnum);
|
||||
}
|
||||
let command = match value {
|
||||
WebGLSamplerValue::GLenum(value) => {
|
||||
WebGLCommand::SetSamplerParameterInt(self.gl_id, pname, value as i32)
|
||||
},
|
||||
WebGLSamplerValue::Float(value) => {
|
||||
WebGLCommand::SetSamplerParameterFloat(self.gl_id, pname, value)
|
||||
},
|
||||
};
|
||||
context.send_command(command);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_parameter(
|
||||
&self,
|
||||
context: &WebGLRenderingContext,
|
||||
pname: u32,
|
||||
) -> Result<WebGLSamplerValue, canvas_traits::webgl::WebGLError> {
|
||||
if !self.is_valid() {
|
||||
return Err(InvalidOperation);
|
||||
}
|
||||
match pname {
|
||||
constants::TEXTURE_MIN_FILTER |
|
||||
constants::TEXTURE_MAG_FILTER |
|
||||
constants::TEXTURE_WRAP_R |
|
||||
constants::TEXTURE_WRAP_S |
|
||||
constants::TEXTURE_WRAP_T |
|
||||
constants::TEXTURE_COMPARE_FUNC |
|
||||
constants::TEXTURE_COMPARE_MODE => {
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
context.send_command(WebGLCommand::GetSamplerParameterInt(
|
||||
self.gl_id, pname, sender,
|
||||
));
|
||||
Ok(WebGLSamplerValue::GLenum(receiver.recv().unwrap() as u32))
|
||||
},
|
||||
constants::TEXTURE_MIN_LOD | constants::TEXTURE_MAX_LOD => {
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
context.send_command(WebGLCommand::GetSamplerParameterFloat(
|
||||
self.gl_id, pname, sender,
|
||||
));
|
||||
Ok(WebGLSamplerValue::Float(receiver.recv().unwrap()))
|
||||
},
|
||||
_ => Err(InvalidEnum),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for WebGLSampler {
|
||||
fn drop(&mut self) {
|
||||
self.delete(true);
|
||||
}
|
||||
}
|
|
@ -530,13 +530,13 @@ interface mixin WebGL2RenderingContextBase
|
|||
any getQueryParameter(WebGLQuery query, GLenum pname);
|
||||
|
||||
/* Sampler Objects */
|
||||
/*WebGLSampler? createSampler();
|
||||
WebGLSampler? createSampler();
|
||||
void deleteSampler(WebGLSampler? sampler);
|
||||
[WebGLHandlesContextLoss] GLboolean isSampler(WebGLSampler? sampler);
|
||||
void bindSampler(GLuint unit, WebGLSampler? sampler);
|
||||
void samplerParameteri(WebGLSampler sampler, GLenum pname, GLint param);
|
||||
void samplerParameterf(WebGLSampler sampler, GLenum pname, GLfloat param);
|
||||
any getSamplerParameter(WebGLSampler sampler, GLenum pname);*/
|
||||
any getSamplerParameter(WebGLSampler sampler, GLenum pname);
|
||||
|
||||
/* Sync objects */
|
||||
WebGLSync? fenceSync(GLenum condition, GLbitfield flags);
|
||||
|
|
11
components/script/dom/webidls/WebGLSampler.webidl
Normal file
11
components/script/dom/webidls/WebGLSampler.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 https://mozilla.org/MPL/2.0/. */
|
||||
//
|
||||
// WebGL IDL definitions scraped from the Khronos specification:
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.8
|
||||
//
|
||||
|
||||
[Exposed=Window, Pref="dom.webgl2.enabled"]
|
||||
interface WebGLSampler : WebGLObject {
|
||||
};
|
|
@ -1,16 +1,16 @@
|
|||
[methods-2.html]
|
||||
[WebGL test #46: Property either does not exist or is not a function: bindTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #25: Property either does not exist or is not a function: uniform4uiv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #72: Property either does not exist or is not a function: bindVertexArray]
|
||||
[WebGL test #48: Property either does not exist or is not a function: endTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #28: Property either does not exist or is not a function: uniformMatrix2x4fv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #48: Property either does not exist or is not a function: samplerParameterf]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #1: Property either does not exist or is not a function: getBufferSubData]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -23,16 +23,7 @@
|
|||
[WebGL test #27: Property either does not exist or is not a function: uniformMatrix3x2fv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #60: Property either does not exist or is not a function: bindBufferBase]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #63: Property either does not exist or is not a function: getUniformIndices]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #57: Property either does not exist or is not a function: getTransformFeedbackVarying]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #64: Property either does not exist or is not a function: getActiveUniforms]
|
||||
[WebGL test #53: Property either does not exist or is not a function: bindBufferBase]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #3: Property either does not exist or is not a function: blitFramebuffer]
|
||||
|
@ -41,13 +32,13 @@
|
|||
[WebGL test #33: Property either does not exist or is not a function: vertexAttribI4iv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #58: Property either does not exist or is not a function: pauseTransformFeedback]
|
||||
[WebGL test #44: Property either does not exist or is not a function: deleteTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #62: Property either does not exist or is not a function: getIndexedParameter]
|
||||
[WebGL test #51: Property either does not exist or is not a function: pauseTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #56: Property either does not exist or is not a function: transformFeedbackVaryings]
|
||||
[WebGL test #49: Property either does not exist or is not a function: transformFeedbackVaryings]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #2: Property either does not exist or is not a function: copyBufferSubData]
|
||||
|
@ -56,15 +47,15 @@
|
|||
[WebGL test #23: Property either does not exist or is not a function: uniform2uiv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #55: Property either does not exist or is not a function: getIndexedParameter]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #31: Property either does not exist or is not a function: uniformMatrix4x3fv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #36: Property either does not exist or is not a function: vertexAttribIPointer]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #54: Property either does not exist or is not a function: beginTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #8: Property either does not exist or is not a function: readBuffer]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -74,22 +65,19 @@
|
|||
[WebGL test #5: Property either does not exist or is not a function: getInternalformatParameter]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #47: Property either does not exist or is not a function: samplerParameteri]
|
||||
[WebGL test #60: Property either does not exist or is not a function: getActiveUniformBlockName]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #47: Property either does not exist or is not a function: beginTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #32: Property either does not exist or is not a function: vertexAttribI4i]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #68: Property either does not exist or is not a function: uniformBlockBinding]
|
||||
[WebGL test #43: Property either does not exist or is not a function: createTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #55: Property either does not exist or is not a function: endTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #69: Property either does not exist or is not a function: createVertexArray]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #70: Property either does not exist or is not a function: deleteVertexArray]
|
||||
[WebGL test #59: Property either does not exist or is not a function: getActiveUniformBlockParameter]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #41: Property either does not exist or is not a function: clearBufferfv]
|
||||
|
@ -101,19 +89,16 @@
|
|||
[WebGL test #15: Property either does not exist or is not a function: compressedTexImage3D]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #43: Property either does not exist or is not a function: createSampler]
|
||||
[WebGL test #65: Property either does not exist or is not a function: bindVertexArray]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #34: Property either does not exist or is not a function: vertexAttribI4ui]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #51: Property either does not exist or is not a function: deleteTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #6: Property either does not exist or is not a function: invalidateFramebuffer]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #61: Property either does not exist or is not a function: bindBufferRange]
|
||||
[WebGL test #62: Property either does not exist or is not a function: createVertexArray]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #42: Property either does not exist or is not a function: clearBufferfi]
|
||||
|
@ -128,13 +113,10 @@
|
|||
[WebGL test #39: Property either does not exist or is not a function: clearBufferiv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #71: Property either does not exist or is not a function: isVertexArray]
|
||||
[WebGL test #58: Property either does not exist or is not a function: getUniformBlockIndex]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #52: Property either does not exist or is not a function: isTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #46: Property either does not exist or is not a function: bindSampler]
|
||||
[WebGL test #56: Property either does not exist or is not a function: getUniformIndices]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #16: Property either does not exist or is not a function: compressedTexSubImage3D]
|
||||
|
@ -143,12 +125,18 @@
|
|||
[WebGL test #38: Property either does not exist or is not a function: drawBuffers]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #54: Property either does not exist or is not a function: bindBufferRange]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #0: Property either does not exist or is not a function: isContextLost]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #9: Property either does not exist or is not a function: renderbufferStorageMultisample]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #45: Property either does not exist or is not a function: isTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #18: Property either does not exist or is not a function: uniform1ui]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -158,40 +146,28 @@
|
|||
[WebGL test #40: Property either does not exist or is not a function: clearBufferuiv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #66: Property either does not exist or is not a function: getActiveUniformBlockParameter]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #53: Property either does not exist or is not a function: bindTransformFeedback]
|
||||
[WebGL test #64: Property either does not exist or is not a function: isVertexArray]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #21: Property either does not exist or is not a function: uniform4ui]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #50: Property either does not exist or is not a function: createTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #11: Property either does not exist or is not a function: texStorage2D]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #59: Property either does not exist or is not a function: resumeTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #19: Property either does not exist or is not a function: uniform2ui]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #26: Property either does not exist or is not a function: uniformMatrix2x3fv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #67: Property either does not exist or is not a function: getActiveUniformBlockName]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #49: Property either does not exist or is not a function: getSamplerParameter]
|
||||
[WebGL test #52: Property either does not exist or is not a function: resumeTransformFeedback]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #29: Property either does not exist or is not a function: uniformMatrix4x2fv]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #65: Property either does not exist or is not a function: getUniformBlockIndex]
|
||||
[WebGL test #57: Property either does not exist or is not a function: getActiveUniforms]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #20: Property either does not exist or is not a function: uniform3ui]
|
||||
|
@ -203,16 +179,19 @@
|
|||
[WebGL test #4: Property either does not exist or is not a function: framebufferTextureLayer]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #44: Property either does not exist or is not a function: deleteSampler]
|
||||
[WebGL test #61: Property either does not exist or is not a function: uniformBlockBinding]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #50: Property either does not exist or is not a function: getTransformFeedbackVarying]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #12: Property either does not exist or is not a function: texStorage3D]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #10: Property either does not exist or is not a function: texImage3D]
|
||||
[WebGL test #63: Property either does not exist or is not a function: deleteVertexArray]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #45: Property either does not exist or is not a function: isSampler]
|
||||
[WebGL test #10: Property either does not exist or is not a function: texImage3D]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #13: Property either does not exist or is not a function: texSubImage3D]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[expando-loss-2.html]
|
||||
expected: ERROR
|
||||
[WebGL test #0: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||
[WebGL test #5: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -51,3 +51,9 @@
|
|||
[WebGL test #32: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #33: getError expected: NO_ERROR. Was INVALID_ENUM : after evaluating: gl.bindSampler(0, sampler)]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #40: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
[multi-context-sampler-test.html]
|
||||
expected: ERROR
|
||||
[WebGL test #1: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||
[WebGL test #2: should be green\nat (0, 0) expected: 0,255,0,255 was 0,0,0,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #3: getError expected: NO_ERROR. Was INVALID_ENUM : there should be no errors]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[sampler-drawing-test.html]
|
||||
expected: ERROR
|
||||
[WebGL test #1: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||
expected: FAIL
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
[samplers.html]
|
||||
expected: ERROR
|
||||
[WebGL test #3: getError expected: NO_ERROR. Was INVALID_ENUM : SAMPLER_BINDING query should succeed]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #4: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||
expected: FAIL
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue