mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #25852 - szeged:mmatyas__webgl_fns_renderbuf_enums, r=jdm
Allow more WebGL2 FBO attachment formats Add support for most of the framebuffer attachment formats introduced in WebGL2 for textures and renderbuffers. Related format tables: - https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml - https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glRenderbufferStorage.xhtml <!-- Please describe your changes on the following line: --> cc @jdm @zakorgy --- <!-- 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 - [x] There are tests for these changes <!-- 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. -->
This commit is contained in:
commit
386759ca90
6 changed files with 137 additions and 78 deletions
|
@ -219,10 +219,10 @@ impl WebGLFramebuffer {
|
||||||
self.size.get()
|
self.size.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_attachment_constraints(
|
fn check_attachment_constraints<'a>(
|
||||||
&self,
|
&self,
|
||||||
attachment: &Option<WebGLFramebufferAttachment>,
|
attachment: &Option<WebGLFramebufferAttachment>,
|
||||||
constraints: &[u32],
|
mut constraints: impl Iterator<Item = &'a u32>,
|
||||||
fb_size: &mut Option<(i32, i32)>,
|
fb_size: &mut Option<(i32, i32)>,
|
||||||
) -> Result<(), u32> {
|
) -> Result<(), u32> {
|
||||||
// Get the size of this attachment.
|
// Get the size of this attachment.
|
||||||
|
@ -254,7 +254,7 @@ impl WebGLFramebuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(format) = format {
|
if let Some(format) = format {
|
||||||
if constraints.iter().all(|c| *c != format) {
|
if constraints.all(|c| *c != format) {
|
||||||
return Err(constants::FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
|
return Err(constants::FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,22 +269,6 @@ impl WebGLFramebuffer {
|
||||||
let has_z = z.is_some();
|
let has_z = z.is_some();
|
||||||
let has_s = s.is_some();
|
let has_s = s.is_some();
|
||||||
let has_zs = zs.is_some();
|
let has_zs = zs.is_some();
|
||||||
let attachments = [&*z, &*s, &*zs];
|
|
||||||
let attachment_constraints = [
|
|
||||||
&[
|
|
||||||
constants::DEPTH_COMPONENT16,
|
|
||||||
constants::DEPTH_COMPONENT24,
|
|
||||||
constants::DEPTH_COMPONENT32F,
|
|
||||||
constants::DEPTH24_STENCIL8,
|
|
||||||
constants::DEPTH32F_STENCIL8,
|
|
||||||
][..],
|
|
||||||
&[
|
|
||||||
constants::STENCIL_INDEX8,
|
|
||||||
constants::DEPTH24_STENCIL8,
|
|
||||||
constants::DEPTH32F_STENCIL8,
|
|
||||||
][..],
|
|
||||||
&[constants::DEPTH_STENCIL][..],
|
|
||||||
];
|
|
||||||
|
|
||||||
let is_supported = match self.webgl_version {
|
let is_supported = match self.webgl_version {
|
||||||
// From the WebGL 1.0 spec, 6.6 ("Framebuffer Object Attachments"):
|
// From the WebGL 1.0 spec, 6.6 ("Framebuffer Object Attachments"):
|
||||||
|
@ -326,7 +310,38 @@ impl WebGLFramebuffer {
|
||||||
|
|
||||||
let mut fb_size = None;
|
let mut fb_size = None;
|
||||||
|
|
||||||
for (attachment, constraints) in attachments.iter().zip(&attachment_constraints) {
|
let attachments = [&*z, &*s, &*zs];
|
||||||
|
let webgl1_attachment_constraints = &[
|
||||||
|
&[
|
||||||
|
constants::DEPTH_COMPONENT16,
|
||||||
|
constants::DEPTH_COMPONENT24,
|
||||||
|
constants::DEPTH_COMPONENT32F,
|
||||||
|
constants::DEPTH24_STENCIL8,
|
||||||
|
constants::DEPTH32F_STENCIL8,
|
||||||
|
][..],
|
||||||
|
&[
|
||||||
|
constants::STENCIL_INDEX8,
|
||||||
|
constants::DEPTH24_STENCIL8,
|
||||||
|
constants::DEPTH32F_STENCIL8,
|
||||||
|
][..],
|
||||||
|
&[constants::DEPTH_STENCIL][..],
|
||||||
|
];
|
||||||
|
let webgl2_attachment_constraints = &[
|
||||||
|
&[constants::DEPTH_STENCIL][..],
|
||||||
|
&[constants::DEPTH_STENCIL][..],
|
||||||
|
&[][..],
|
||||||
|
];
|
||||||
|
let empty_attachment_constrains = &[&[][..], &[][..], &[][..]];
|
||||||
|
let extra_attachment_constraints = match self.webgl_version {
|
||||||
|
WebGLVersion::WebGL1 => empty_attachment_constrains,
|
||||||
|
WebGLVersion::WebGL2 => webgl2_attachment_constraints,
|
||||||
|
};
|
||||||
|
let attachment_constraints = webgl1_attachment_constraints
|
||||||
|
.iter()
|
||||||
|
.zip(extra_attachment_constraints.iter())
|
||||||
|
.map(|(a, b)| a.iter().chain(b.iter()));
|
||||||
|
|
||||||
|
for (attachment, constraints) in attachments.iter().zip(attachment_constraints) {
|
||||||
if let Err(errnum) =
|
if let Err(errnum) =
|
||||||
self.check_attachment_constraints(attachment, constraints, &mut fb_size)
|
self.check_attachment_constraints(attachment, constraints, &mut fb_size)
|
||||||
{
|
{
|
||||||
|
@ -334,18 +349,79 @@ impl WebGLFramebuffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let color_constraints = &[
|
let webgl1_color_constraints = &[
|
||||||
constants::RGBA4,
|
|
||||||
constants::RGB5_A1,
|
|
||||||
constants::RGB565,
|
|
||||||
constants::RGBA,
|
|
||||||
constants::RGB,
|
constants::RGB,
|
||||||
|
constants::RGB565,
|
||||||
|
constants::RGB5_A1,
|
||||||
|
constants::RGBA,
|
||||||
|
constants::RGBA4,
|
||||||
][..];
|
][..];
|
||||||
|
let webgl2_color_constraints = &[
|
||||||
|
constants::ALPHA,
|
||||||
|
constants::LUMINANCE,
|
||||||
|
constants::LUMINANCE_ALPHA,
|
||||||
|
constants::R11F_G11F_B10F,
|
||||||
|
constants::R16F,
|
||||||
|
constants::R16I,
|
||||||
|
constants::R16UI,
|
||||||
|
constants::R32F,
|
||||||
|
constants::R32I,
|
||||||
|
constants::R32UI,
|
||||||
|
constants::R8,
|
||||||
|
constants::R8_SNORM,
|
||||||
|
constants::R8I,
|
||||||
|
constants::R8UI,
|
||||||
|
constants::RG16F,
|
||||||
|
constants::RG16I,
|
||||||
|
constants::RG16UI,
|
||||||
|
constants::RG32F,
|
||||||
|
constants::RG32I,
|
||||||
|
constants::RG32UI,
|
||||||
|
constants::RG8,
|
||||||
|
constants::RG8_SNORM,
|
||||||
|
constants::RG8I,
|
||||||
|
constants::RG8UI,
|
||||||
|
constants::RGB10_A2,
|
||||||
|
constants::RGB10_A2UI,
|
||||||
|
constants::RGB16F,
|
||||||
|
constants::RGB16I,
|
||||||
|
constants::RGB16UI,
|
||||||
|
constants::RGB32F,
|
||||||
|
constants::RGB32I,
|
||||||
|
constants::RGB32UI,
|
||||||
|
constants::RGB8,
|
||||||
|
constants::RGB8_SNORM,
|
||||||
|
constants::RGB8I,
|
||||||
|
constants::RGB8UI,
|
||||||
|
constants::RGB9_E5,
|
||||||
|
constants::RGBA16F,
|
||||||
|
constants::RGBA16I,
|
||||||
|
constants::RGBA16UI,
|
||||||
|
constants::RGBA32F,
|
||||||
|
constants::RGBA32I,
|
||||||
|
constants::RGBA32UI,
|
||||||
|
constants::RGBA8,
|
||||||
|
constants::RGBA8_SNORM,
|
||||||
|
constants::RGBA8I,
|
||||||
|
constants::RGBA8UI,
|
||||||
|
constants::SRGB8,
|
||||||
|
constants::SRGB8_ALPHA8,
|
||||||
|
][..];
|
||||||
|
let empty_color_constrains = &[][..];
|
||||||
|
let extra_color_constraints = match self.webgl_version {
|
||||||
|
WebGLVersion::WebGL1 => empty_color_constrains,
|
||||||
|
WebGLVersion::WebGL2 => webgl2_color_constraints,
|
||||||
|
};
|
||||||
|
let color_constraints = webgl1_color_constraints
|
||||||
|
.iter()
|
||||||
|
.chain(extra_color_constraints.iter());
|
||||||
|
|
||||||
let has_c = self.colors.iter().any(|att| att.borrow().is_some());
|
let has_c = self.colors.iter().any(|att| att.borrow().is_some());
|
||||||
for attachment in self.colors.iter() {
|
for attachment in self.colors.iter() {
|
||||||
let attachment = attachment.borrow();
|
let attachment = attachment.borrow();
|
||||||
|
let constraints = color_constraints.clone();
|
||||||
if let Err(errnum) =
|
if let Err(errnum) =
|
||||||
self.check_attachment_constraints(&*attachment, color_constraints, &mut fb_size)
|
self.check_attachment_constraints(&*attachment, constraints, &mut fb_size)
|
||||||
{
|
{
|
||||||
return self.status.set(errnum);
|
return self.status.set(errnum);
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,31 @@ impl WebGLRenderbuffer {
|
||||||
constants::RGBA4 | constants::DEPTH_COMPONENT16 | constants::STENCIL_INDEX8 => {
|
constants::RGBA4 | constants::DEPTH_COMPONENT16 | constants::STENCIL_INDEX8 => {
|
||||||
internal_format
|
internal_format
|
||||||
},
|
},
|
||||||
|
constants::R8 |
|
||||||
|
constants::R8UI |
|
||||||
|
constants::R8I |
|
||||||
|
constants::R16UI |
|
||||||
|
constants::R16I |
|
||||||
|
constants::R32UI |
|
||||||
|
constants::R32I |
|
||||||
|
constants::RG8 |
|
||||||
|
constants::RG8UI |
|
||||||
|
constants::RG8I |
|
||||||
|
constants::RG16UI |
|
||||||
|
constants::RG16I |
|
||||||
|
constants::RG32UI |
|
||||||
|
constants::RG32I |
|
||||||
|
constants::RGB8 |
|
||||||
|
constants::RGBA8 |
|
||||||
|
constants::SRGB8_ALPHA8 |
|
||||||
|
constants::RGB10_A2 |
|
||||||
|
constants::RGBA8UI |
|
||||||
|
constants::RGBA8I |
|
||||||
|
constants::RGB10_A2UI |
|
||||||
|
constants::RGBA16UI |
|
||||||
|
constants::RGBA16I |
|
||||||
|
constants::RGBA32I |
|
||||||
|
constants::RGBA32UI |
|
||||||
constants::DEPTH_COMPONENT24 |
|
constants::DEPTH_COMPONENT24 |
|
||||||
constants::DEPTH_COMPONENT32F |
|
constants::DEPTH_COMPONENT32F |
|
||||||
constants::DEPTH24_STENCIL8 |
|
constants::DEPTH24_STENCIL8 |
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[read-pixels-from-rgb8-into-pbo-bug.html]
|
[read-pixels-from-rgb8-into-pbo-bug.html]
|
||||||
[WebGL test #1: framebuffer with RGB8 color buffer is incomplete]
|
[WebGL test #2: getError expected: NO_ERROR. Was INVALID_OPERATION : Tests should complete without gl errors]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #2: getError expected: NO_ERROR. Was INVALID_ENUM : Tests should complete without gl errors]
|
[WebGL test #1: Expected in pixel 0: [255,0,0,255\], got: 0,0,0,0]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,7 @@
|
||||||
[framebuffer-object-attachment.html]
|
[framebuffer-object-attachment.html]
|
||||||
[WebGL test #13: gl.getParameter(gl.RED_BITS) + gl.getParameter(gl.GREEN_BITS) + gl.getParameter(gl.BLUE_BITS) + gl.getParameter(gl.ALPHA_BITS) >= 16 should be true. Was false.]
|
[WebGL test #45: getError expected: NO_ERROR. Was INVALID_ENUM : ]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #10: checkFramebufferStatus expects [FRAMEBUFFER_COMPLETE\], was FRAMEBUFFER_INCOMPLETE_ATTACHMENT]
|
[WebGL test #28: checkFramebufferStatus expects [FRAMEBUFFER_COMPLETE\], was FRAMEBUFFER_INCOMPLETE_ATTACHMENT]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #20: checkFramebufferStatus expects [FRAMEBUFFER_COMPLETE\], was FRAMEBUFFER_INCOMPLETE_ATTACHMENT]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #21: checkFramebufferStatus expects [FRAMEBUFFER_COMPLETE\], was FRAMEBUFFER_INCOMPLETE_ATTACHMENT]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #17: checkFramebufferStatus expects [FRAMEBUFFER_COMPLETE\], was FRAMEBUFFER_INCOMPLETE_ATTACHMENT]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #9: checkFramebufferStatus expects [FRAMEBUFFER_COMPLETE\], was FRAMEBUFFER_INCOMPLETE_ATTACHMENT]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #11: getError expected: NO_ERROR. Was INVALID_ENUM : ]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #19: checkFramebufferStatus expects [FRAMEBUFFER_COMPLETE\], was FRAMEBUFFER_INCOMPLETE_ATTACHMENT]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #22: checkFramebufferStatus expects [FRAMEBUFFER_COMPLETE\], was FRAMEBUFFER_INCOMPLETE_ATTACHMENT]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #18: checkFramebufferStatus expects [FRAMEBUFFER_COMPLETE\], was FRAMEBUFFER_INCOMPLETE_ATTACHMENT]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #27: getError expected: NO_ERROR. Was INVALID_ENUM : ]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,47 +1,35 @@
|
||||||
[clearbuffer-sub-source.html]
|
[clearbuffer-sub-source.html]
|
||||||
[WebGL test #14: getError expected: NO_ERROR. Was INVALID_FRAMEBUFFER_OPERATION : clearBuffer with srcOffset = 2 should succeed]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #5: clearBuffer fails to work. Expected: 1,2,3,4, got: 0,0,0,0]
|
[WebGL test #5: clearBuffer fails to work. Expected: 1,2,3,4, got: 0,0,0,0]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #2: getError expected: NO_ERROR. Was INVALID_ENUM : clearBuffer with no srcOffset should succeed]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #11: clearBuffer fails to work. Expected: 1,2,3,4, got: 0,0,0,0]
|
[WebGL test #11: clearBuffer fails to work. Expected: 1,2,3,4, got: 0,0,0,0]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #13: clearBuffer fails to work. Expected: 1,2,3,4, got: 0,0,0,0]
|
[WebGL test #13: clearBuffer fails to work. Expected: 1,2,3,4, got: 0,0,0,0]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #9: gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be 36053. Was 36054.]
|
[WebGL test #12: getError expected: NO_ERROR. Was INVALID_OPERATION : clearBuffer with srcOffset = 0 should succeed]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #10: getError expected: NO_ERROR. Was INVALID_ENUM : clearBuffer with no srcOffset should succeed]
|
[WebGL test #6: getError expected: NO_ERROR. Was INVALID_OPERATION : clearBuffer with srcOffset = 2 should succeed]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #16: getError expected: INVALID_VALUE. Was INVALID_FRAMEBUFFER_OPERATION : clearBuffer with srcOffset = 4 should fail: out of bounds]
|
[WebGL test #4: getError expected: NO_ERROR. Was INVALID_OPERATION : clearBuffer with srcOffset = 0 should succeed]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #4: getError expected: NO_ERROR. Was INVALID_FRAMEBUFFER_OPERATION : clearBuffer with srcOffset = 0 should succeed]
|
[WebGL test #14: getError expected: NO_ERROR. Was INVALID_OPERATION : clearBuffer with srcOffset = 2 should succeed]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #15: clearBuffer fails to work. Expected: 3,4,5,6, got: 0,0,0,0]
|
[WebGL test #15: clearBuffer fails to work. Expected: 3,4,5,6, got: 0,0,0,0]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #8: getError expected: INVALID_VALUE. Was INVALID_FRAMEBUFFER_OPERATION : clearBuffer with srcOffset = 4 should fail: out of bounds]
|
[WebGL test #8: getError expected: INVALID_VALUE. Was INVALID_OPERATION : clearBuffer with srcOffset = 4 should fail: out of bounds]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #6: getError expected: NO_ERROR. Was INVALID_FRAMEBUFFER_OPERATION : clearBuffer with srcOffset = 2 should succeed]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #7: clearBuffer fails to work. Expected: 3,4,5,6, got: 0,0,0,0]
|
[WebGL test #7: clearBuffer fails to work. Expected: 3,4,5,6, got: 0,0,0,0]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #12: getError expected: NO_ERROR. Was INVALID_FRAMEBUFFER_OPERATION : clearBuffer with srcOffset = 0 should succeed]
|
[WebGL test #16: getError expected: INVALID_VALUE. Was INVALID_OPERATION : clearBuffer with srcOffset = 4 should fail: out of bounds]
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[WebGL test #1: gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be 36053. Was 36054.]
|
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[WebGL test #3: clearBuffer fails to work. Expected: 1,2,3,4, got: 0,0,0,0]
|
[WebGL test #3: clearBuffer fails to work. Expected: 1,2,3,4, got: 0,0,0,0]
|
||||||
|
|
|
@ -3,6 +3,3 @@
|
||||||
[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 #1: gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be 36053. Was 36054.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue