mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
Auto merge of #19192 - MortimerGoro:webgl2_glsl, r=jdm
Set the correct Angle GLSL output when using WebGL 2 Set the correct Angle GLSL output when using WebGL 2 <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19192) <!-- Reviewable:end -->
This commit is contained in:
commit
f1cf41da00
21 changed files with 99 additions and 621 deletions
|
@ -33,8 +33,9 @@ use app_units::Au;
|
|||
use canvas_traits::canvas::{CanvasGradientStop, LinearGradientStyle, RadialGradientStyle};
|
||||
use canvas_traits::canvas::{CompositionOrBlending, LineCapStyle, LineJoinStyle, RepetitionStyle};
|
||||
use canvas_traits::webgl::{WebGLBufferId, WebGLFramebufferId, WebGLProgramId, WebGLRenderbufferId};
|
||||
use canvas_traits::webgl::{WebGLChan, WebGLContextShareMode, WebGLError, WebGLPipeline, WebGLMsgSender, WebGLVersion};
|
||||
use canvas_traits::webgl::{WebGLChan, WebGLContextShareMode, WebGLError, WebGLPipeline, WebGLMsgSender};
|
||||
use canvas_traits::webgl::{WebGLReceiver, WebGLSender, WebGLShaderId, WebGLTextureId, WebGLVertexArrayId};
|
||||
use canvas_traits::webgl::{WebGLSLVersion, WebGLVersion};
|
||||
use cssparser::RGBA;
|
||||
use devtools_traits::{CSSError, TimelineMarkerType, WorkerId};
|
||||
use dom::abstractworker::SharedRt;
|
||||
|
@ -412,6 +413,7 @@ unsafe_no_jsmanaged_fields!(WebGLShaderId);
|
|||
unsafe_no_jsmanaged_fields!(WebGLTextureId);
|
||||
unsafe_no_jsmanaged_fields!(WebGLVertexArrayId);
|
||||
unsafe_no_jsmanaged_fields!(WebGLVersion);
|
||||
unsafe_no_jsmanaged_fields!(WebGLSLVersion);
|
||||
unsafe_no_jsmanaged_fields!(MediaList);
|
||||
unsafe_no_jsmanaged_fields!(WebVRGamepadHand);
|
||||
unsafe_no_jsmanaged_fields!(ScriptToConstellationChan);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt};
|
||||
use canvas_traits::canvas::{byte_swap, multiply_u8_pixel};
|
||||
use canvas_traits::webgl::{WebGLContextShareMode, WebGLCommand, WebGLError, WebGLVersion};
|
||||
use canvas_traits::webgl::{WebGLContextShareMode, WebGLCommand, WebGLError, WebGLVersion, WebGLSLVersion};
|
||||
use canvas_traits::webgl::{WebGLFramebufferBindingRequest, WebGLMsg, WebGLMsgSender, WebGLParameter, WebVRCommand};
|
||||
use canvas_traits::webgl::DOMToTextureCommand;
|
||||
use canvas_traits::webgl::WebGLError::*;
|
||||
|
@ -187,6 +187,7 @@ pub struct WebGLRenderingContext {
|
|||
webrender_image: Cell<Option<webrender_api::ImageKey>>,
|
||||
share_mode: WebGLContextShareMode,
|
||||
webgl_version: WebGLVersion,
|
||||
glsl_version: WebGLSLVersion,
|
||||
#[ignore_malloc_size_of = "Defined in offscreen_gl_context"]
|
||||
limits: GLLimits,
|
||||
canvas: Dom<HTMLCanvasElement>,
|
||||
|
@ -236,6 +237,7 @@ impl WebGLRenderingContext {
|
|||
webrender_image: Cell::new(None),
|
||||
share_mode: ctx_data.share_mode,
|
||||
webgl_version,
|
||||
glsl_version: ctx_data.glsl_version,
|
||||
limits: ctx_data.limits,
|
||||
canvas: Dom::from_ref(canvas),
|
||||
last_error: Cell::new(None),
|
||||
|
@ -1914,7 +1916,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn CompileShader(&self, shader: Option<&WebGLShader>) {
|
||||
if let Some(shader) = shader {
|
||||
shader.compile(self.webgl_version, &self.extension_manager)
|
||||
shader.compile(self.webgl_version, self.glsl_version, &self.extension_manager)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
||||
use angle::hl::{BuiltInResources, Output, ShaderValidator};
|
||||
use canvas_traits::webgl::{WebGLSLVersion, WebGLVersion};
|
||||
use canvas_traits::webgl::{webgl_channel, WebGLCommand, WebGLMsgSender, WebGLParameter, WebGLResult, WebGLShaderId};
|
||||
use canvas_traits::webgl::WebGLVersion;
|
||||
use dom::bindings::cell::DomRefCell;
|
||||
use dom::bindings::codegen::Bindings::WebGLShaderBinding;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
|
@ -40,12 +40,6 @@ pub struct WebGLShader {
|
|||
renderer: WebGLMsgSender,
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
const SHADER_OUTPUT_FORMAT: Output = Output::Glsl;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
const SHADER_OUTPUT_FORMAT: Output = Output::Essl;
|
||||
|
||||
static GLSLANG_INITIALIZATION: Once = ONCE_INIT;
|
||||
|
||||
impl WebGLShader {
|
||||
|
@ -100,7 +94,12 @@ impl WebGLShader {
|
|||
}
|
||||
|
||||
/// glCompileShader
|
||||
pub fn compile(&self, version: WebGLVersion, ext: &WebGLExtensions) {
|
||||
pub fn compile(
|
||||
&self,
|
||||
webgl_version: WebGLVersion,
|
||||
glsl_version: WebGLSLVersion,
|
||||
ext: &WebGLExtensions
|
||||
) {
|
||||
if self.compilation_status.get() != ShaderCompilationStatus::NotCompiled {
|
||||
debug!("Compiling already compiled shader {}", self.id);
|
||||
}
|
||||
|
@ -109,15 +108,37 @@ impl WebGLShader {
|
|||
let mut params = BuiltInResources::default();
|
||||
params.FragmentPrecisionHigh = 1;
|
||||
params.OES_standard_derivatives = ext.is_enabled::<OESStandardDerivatives>() as i32;
|
||||
let validator = match version {
|
||||
let validator = match webgl_version {
|
||||
WebGLVersion::WebGL1 => {
|
||||
let output_format = if cfg!(any(target_os = "android", target_os = "ios")) {
|
||||
Output::Essl
|
||||
} else {
|
||||
Output::Glsl
|
||||
};
|
||||
ShaderValidator::for_webgl(self.gl_type,
|
||||
SHADER_OUTPUT_FORMAT,
|
||||
output_format,
|
||||
¶ms).unwrap()
|
||||
},
|
||||
WebGLVersion::WebGL2 => {
|
||||
let output_format = if cfg!(any(target_os = "android", target_os = "ios")) {
|
||||
Output::Essl
|
||||
} else {
|
||||
match (glsl_version.major, glsl_version.minor) {
|
||||
(1, 30) => Output::Glsl130,
|
||||
(1, 40) => Output::Glsl140,
|
||||
(1, 50) => Output::Glsl150Core,
|
||||
(3, 30) => Output::Glsl330Core,
|
||||
(4, 0) => Output::Glsl400Core,
|
||||
(4, 10) => Output::Glsl410Core,
|
||||
(4, 20) => Output::Glsl420Core,
|
||||
(4, 30) => Output::Glsl430Core,
|
||||
(4, 40) => Output::Glsl440Core,
|
||||
(4, _) => Output::Glsl450Core,
|
||||
_ => Output::Glsl140
|
||||
}
|
||||
};
|
||||
ShaderValidator::for_webgl2(self.gl_type,
|
||||
SHADER_OUTPUT_FORMAT,
|
||||
output_format,
|
||||
¶ms).unwrap()
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue