Skip to content

Commit 35ffe55

Browse files
csmartdaltonAngle LUCI CQ
authored and
Angle LUCI CQ
committed
Block framebuffer queries on overridden PLS state
Generate an error from glGetFramebufferAttachmentParameteriv() when querying a color attachment that has been overridden by PLS. Bug: angleproject:40096838 Change-Id: I83e68c3527f034f9a24822cf4f57789f81b9b6af Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6338390 Reviewed-by: Kenneth Russell <[email protected]> Reviewed-by: Alexey Knyazev <[email protected]> Commit-Queue: Chris Dalton <[email protected]> Reviewed-by: Shahbaz Youssefi <[email protected]>
1 parent 5b343e8 commit 35ffe55

File tree

4 files changed

+106
-1
lines changed

4 files changed

+106
-1
lines changed

extensions/ANGLE_shader_pixel_local_storage.txt

+12
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,18 @@ Additions to the OpenGL ES Specification, Version 3.0.6
558558
(MAX_COMBINED_DRAW_BUFFERS_AND_PIXEL_LOCAL_STORAGE_PLANES_ANGLE -
559559
ACTIVE_PIXEL_LOCAL_STORAGE_PLANES_ANGLE)
560560

561+
* INVALID_OPERATION is generated by calls to
562+
GetFramebufferAttachmentParameteriv() if <attachment> references a COLOR
563+
attachment and any of the following are true:
564+
565+
<attachment> >=
566+
COLOR_ATTACHMENT0 +
567+
MAX_COLOR_ATTACHMENTS_WITH_ACTIVE_PIXEL_LOCAL_STORAGE_ANGLE
568+
<attachment> >=
569+
COLOR_ATTACHMENT0 +
570+
(MAX_COMBINED_DRAW_BUFFERS_AND_PIXEL_LOCAL_STORAGE_PLANES_ANGLE -
571+
ACTIVE_PIXEL_LOCAL_STORAGE_PLANES_ANGLE)
572+
561573
* Calls to EnableiOES(BLEND, <i>) and ColorMaskiOES(<i>, ...) are ignored
562574
if any of the following are true:
563575

src/libANGLE/ErrorStrings.h

+1
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ inline constexpr const char *kPixelDataNull = "Pixel data cannot be null.";
507507
inline constexpr const char *kPixelPackBufferBoundForTransformFeedback = "It is undefined behavior to use a pixel pack buffer that is bound for transform feedback.";
508508
inline constexpr const char *kPixelUnpackBufferBoundForTransformFeedback = "It is undefined behavior to use a pixel unpack buffer that is bound for transform feedback.";
509509
inline constexpr const char *kPLSActive = "Operation not permitted while pixel local storage is active.";
510+
inline constexpr const char *kPLSColorAttachmentReserved = "Color attachment is actively reserved for pixel local storage.";
510511
inline constexpr const char *kPLSCapNotAllowed = "Cap 0x%04X cannot be enabled or disabled while pixel local storage is active.";
511512
inline constexpr const char *kPLSDefaultFramebufferBound = "Default framebuffer object name 0 does not support pixel local storage.";
512513
inline constexpr const char *kPLSDimensionsDontMatchRenderingArea = "Pixel local storage backing texture dimensions not equal to the rendering area.";

src/libANGLE/validationES.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -5763,7 +5763,6 @@ bool ValidateGetFramebufferAttachmentParameterivBase(const Context *context,
57635763
}
57645764
break;
57655765

5766-
case GL_COLOR_ATTACHMENT0:
57675766
case GL_DEPTH_ATTACHMENT:
57685767
case GL_STENCIL_ATTACHMENT:
57695768
break;
@@ -5777,6 +5776,15 @@ bool ValidateGetFramebufferAttachmentParameterivBase(const Context *context,
57775776
ANGLE_VALIDATION_ERROR(GL_INVALID_ENUM, kInvalidAttachment);
57785777
return false;
57795778
}
5779+
[[fallthrough]];
5780+
5781+
case GL_COLOR_ATTACHMENT0:
5782+
if (context->getPrivateState().isActivelyOverriddenPLSDrawBuffer(
5783+
attachment - GL_COLOR_ATTACHMENT0_EXT))
5784+
{
5785+
ANGLE_VALIDATION_ERROR(GL_INVALID_OPERATION, kPLSColorAttachmentReserved);
5786+
return false;
5787+
}
57805788
break;
57815789
}
57825790

src/tests/gl_tests/PixelLocalStorageTest.cpp

+84
Original file line numberDiff line numberDiff line change
@@ -6204,6 +6204,90 @@ TEST_P(PixelLocalStorageValidationTest, BlendFuncDuringPLS)
62046204
}
62056205
}
62066206

6207+
// Check that glGetFramebufferAttachmentParameteriv() generates errors when
6208+
// querying overridden PLS attachments.
6209+
TEST_P(PixelLocalStorageValidationTest, FramebufferQueries)
6210+
{
6211+
ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_ANGLE_shader_pixel_local_storage"));
6212+
6213+
PLSTestTexture pls0(GL_RGBA8);
6214+
PLSTestTexture pls1(GL_RGBA8);
6215+
GLFramebuffer fbo;
6216+
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
6217+
glFramebufferTexturePixelLocalStorageANGLE(0, pls0, 0, 0);
6218+
glFramebufferTexturePixelLocalStorageANGLE(1, pls1, 0, 0);
6219+
6220+
glBeginPixelLocalStorageANGLE(2, GLenumArray({GL_DONT_CARE, GL_DONT_CARE}));
6221+
EXPECT_GL_NO_ERROR();
6222+
6223+
int firstOverriddenDrawBuffer =
6224+
std::min(MAX_COLOR_ATTACHMENTS_WITH_ACTIVE_PIXEL_LOCAL_STORAGE,
6225+
MAX_COMBINED_DRAW_BUFFERS_AND_PIXEL_LOCAL_STORAGE_PLANES - 2);
6226+
GLint intValue;
6227+
6228+
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
6229+
GL_COLOR_ATTACHMENT0 + firstOverriddenDrawBuffer,
6230+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6231+
EXPECT_GL_SINGLE_ERROR(GL_INVALID_OPERATION);
6232+
EXPECT_GL_SINGLE_ERROR_MSG("Color attachment is actively reserved for pixel local storage.");
6233+
6234+
glGetFramebufferAttachmentParameteriv(
6235+
GL_FRAMEBUFFER,
6236+
GL_COLOR_ATTACHMENT0 + MAX_COMBINED_DRAW_BUFFERS_AND_PIXEL_LOCAL_STORAGE_PLANES - 2,
6237+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6238+
EXPECT_GL_SINGLE_ERROR(GL_INVALID_OPERATION);
6239+
EXPECT_GL_SINGLE_ERROR_MSG("Color attachment is actively reserved for pixel local storage.");
6240+
6241+
glGetFramebufferAttachmentParameteriv(
6242+
GL_FRAMEBUFFER,
6243+
GL_COLOR_ATTACHMENT0 + MAX_COMBINED_DRAW_BUFFERS_AND_PIXEL_LOCAL_STORAGE_PLANES - 1,
6244+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6245+
EXPECT_GL_SINGLE_ERROR(GL_INVALID_OPERATION);
6246+
EXPECT_GL_SINGLE_ERROR_MSG("Color attachment is actively reserved for pixel local storage.");
6247+
6248+
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
6249+
GL_COLOR_ATTACHMENT0 + MAX_COLOR_ATTACHMENTS - 1,
6250+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6251+
EXPECT_GL_SINGLE_ERROR(GL_INVALID_OPERATION);
6252+
EXPECT_GL_SINGLE_ERROR_MSG("Color attachment is actively reserved for pixel local storage.");
6253+
6254+
if (firstOverriddenDrawBuffer != 0)
6255+
{
6256+
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
6257+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6258+
EXPECT_GL_NO_ERROR();
6259+
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
6260+
GL_COLOR_ATTACHMENT0 + firstOverriddenDrawBuffer - 1,
6261+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6262+
EXPECT_GL_NO_ERROR();
6263+
}
6264+
6265+
glEndPixelLocalStorageANGLE(2, GLenumArray({GL_DONT_CARE, GL_DONT_CARE}));
6266+
EXPECT_GL_NO_ERROR();
6267+
6268+
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
6269+
GL_COLOR_ATTACHMENT0 + firstOverriddenDrawBuffer,
6270+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6271+
EXPECT_GL_NO_ERROR();
6272+
6273+
glGetFramebufferAttachmentParameteriv(
6274+
GL_FRAMEBUFFER,
6275+
GL_COLOR_ATTACHMENT0 + MAX_COMBINED_DRAW_BUFFERS_AND_PIXEL_LOCAL_STORAGE_PLANES - 2,
6276+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6277+
EXPECT_GL_NO_ERROR();
6278+
6279+
glGetFramebufferAttachmentParameteriv(
6280+
GL_FRAMEBUFFER,
6281+
GL_COLOR_ATTACHMENT0 + MAX_COMBINED_DRAW_BUFFERS_AND_PIXEL_LOCAL_STORAGE_PLANES - 1,
6282+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6283+
EXPECT_GL_NO_ERROR();
6284+
6285+
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
6286+
GL_COLOR_ATTACHMENT0 + MAX_COLOR_ATTACHMENTS - 1,
6287+
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &intValue);
6288+
EXPECT_GL_NO_ERROR();
6289+
}
6290+
62076291
// Check that glEnable(GL_BLEND) and glColorMask() do not generate errors, and are ignored for
62086292
// overridden draw buffers during PLS.
62096293
TEST_P(PixelLocalStorageValidationTest, BlendMaskDuringPLS)

0 commit comments

Comments
 (0)