webgl: Fix support for float/half-float texture formats.

This commit is contained in:
Josh Matthews 2020-04-09 17:18:35 -04:00
parent 8789a6a8d8
commit 29ab55d076
10 changed files with 88 additions and 56 deletions

View file

@ -2,7 +2,7 @@
* 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 super::{ext_constants, WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
pub mod angleinstancedarrays;

View file

@ -3,12 +3,12 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use super::{
constants as webgl, ext_constants as gl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions,
constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions,
};
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::webglrenderingcontext::WebGLRenderingContext;
use canvas_traits::webgl::WebGLVersion;
use canvas_traits::webgl::{TexFormat, WebGLVersion};
use dom_struct::dom_struct;
#[dom_struct]
@ -44,14 +44,14 @@ impl WebGLExtension for OESTextureFloat {
fn enable(ext: &WebGLExtensions) {
ext.enable_tex_type(webgl::FLOAT);
ext.add_effective_tex_internal_format(webgl::RGBA, webgl::FLOAT, gl::RGBA32F);
ext.add_effective_tex_internal_format(webgl::RGB, webgl::FLOAT, gl::RGB32F);
ext.add_effective_tex_internal_format(webgl::LUMINANCE, webgl::FLOAT, gl::LUMINANCE32F_ARB);
ext.add_effective_tex_internal_format(webgl::ALPHA, webgl::FLOAT, gl::ALPHA32F_ARB);
ext.add_effective_tex_internal_format(TexFormat::RGBA, webgl::FLOAT, TexFormat::RGBA32f);
ext.add_effective_tex_internal_format(TexFormat::RGB, webgl::FLOAT, TexFormat::RGB32f);
ext.add_effective_tex_internal_format(TexFormat::Luminance, webgl::FLOAT, TexFormat::Luminance32f);
ext.add_effective_tex_internal_format(TexFormat::Alpha, webgl::FLOAT, TexFormat::Alpha32f);
ext.add_effective_tex_internal_format(
webgl::LUMINANCE_ALPHA,
TexFormat::LuminanceAlpha,
webgl::FLOAT,
gl::LUMINANCE_ALPHA32F_ARB,
TexFormat::LuminanceAlpha32f,
);
}

View file

@ -2,14 +2,12 @@
* 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 super::{
constants as webgl, ext_constants as gl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions,
};
use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions};
use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants;
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::webglrenderingcontext::WebGLRenderingContext;
use canvas_traits::webgl::WebGLVersion;
use canvas_traits::webgl::{TexFormat, WebGLVersion};
use dom_struct::dom_struct;
#[dom_struct]
@ -50,14 +48,14 @@ impl WebGLExtension for OESTextureHalfFloat {
fn enable(ext: &WebGLExtensions) {
let hf = OESTextureHalfFloatConstants::HALF_FLOAT_OES;
ext.enable_tex_type(hf);
ext.add_effective_tex_internal_format(webgl::RGBA, hf, gl::RGBA16F);
ext.add_effective_tex_internal_format(webgl::RGB, hf, gl::RGB16F);
ext.add_effective_tex_internal_format(webgl::LUMINANCE, hf, gl::LUMINANCE16F_ARB);
ext.add_effective_tex_internal_format(webgl::ALPHA, hf, gl::ALPHA16F_ARB);
ext.add_effective_tex_internal_format(TexFormat::RGBA, hf, TexFormat::RGBA16f);
ext.add_effective_tex_internal_format(TexFormat::RGB, hf, TexFormat::RGB16f);
ext.add_effective_tex_internal_format(TexFormat::Luminance, hf, TexFormat::Luminance16f);
ext.add_effective_tex_internal_format(TexFormat::Alpha, hf, TexFormat::Alpha16f);
ext.add_effective_tex_internal_format(
webgl::LUMINANCE_ALPHA,
TexFormat::LuminanceAlpha,
hf,
gl::LUMINANCE_ALPHA16F_ARB,
TexFormat::LuminanceAlpha16f,
);
}