| From 98f2bc9e65ea6e8cbc4f15e02afae1c05010be08 Mon Sep 17 00:00:00 2001 |
| From: Fritz Koenig <frkoenig@google.com> |
| Date: Tue, 30 Jul 2019 14:53:30 -0700 |
| Subject: [PATCH 3/5] mesa: Allow MESA_framebuffer_flip_y for GLES 3 |
| |
| Implement glFramebufferParameteriMESA on GLES 3 so |
| that the extension is not dependant on GLES 3.1 |
| |
| Reviewed-by: Eric Anholt <eric@anholt.net> |
| Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> |
| --- |
| docs/specs/MESA_framebuffer_flip_y.txt | 35 ++++++++++++--- |
| src/mapi/glapi/gen/apiexec.py | 4 ++ |
| src/mapi/glapi/gen/es_EXT.xml | 15 +++++++ |
| src/mapi/glapi/gen/static_data.py | 2 + |
| src/mesa/main/extensions_table.h | 2 +- |
| src/mesa/main/fbobject.c | 59 ++++++++++++++++++++----- |
| src/mesa/main/fbobject.h | 6 +++ |
| src/mesa/main/tests/dispatch_sanity.cpp | 8 ++++ |
| 8 files changed, 111 insertions(+), 20 deletions(-) |
| |
| diff --git a/docs/specs/MESA_framebuffer_flip_y.txt b/docs/specs/MESA_framebuffer_flip_y.txt |
| index 697ab4e75d6..b13e4eeb388 100644 |
| --- a/docs/specs/MESA_framebuffer_flip_y.txt |
| +++ b/docs/specs/MESA_framebuffer_flip_y.txt |
| @@ -22,7 +22,7 @@ Status |
| |
| Version |
| |
| - Version 1, June 7, 2018 |
| + Version 3, August, 2019 |
| |
| Number |
| |
| @@ -30,7 +30,7 @@ Number |
| |
| Dependencies |
| |
| - OpenGL ES 3.1 is required, for FramebufferParameteri. |
| + Requires OpenGL ES 3.0, OpenGL 4.3, or ARB_framebuffer_no_attachments. |
| |
| Overview |
| |
| @@ -57,7 +57,10 @@ Issues |
| |
| New Procedures and Functions |
| |
| - None |
| + OpenGL ES must provide the following functions: |
| + |
| + void FramebufferParameteriMESA(enum target, enum pname, int param); |
| + void GetFramebufferParameterivMESA(enum target, enum pname, int *params); |
| |
| New Types |
| |
| @@ -65,17 +68,35 @@ New Types |
| |
| New Tokens |
| |
| - Accepted by the <pname> argument of FramebufferParameteri and |
| - GetFramebufferParameteriv: |
| + Accepted by the <pname> argument of FramebufferParameteriMESA and |
| + GetFramebufferParameterivMESA: |
| |
| GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB |
| |
| +Interactions with OpenGL 4.3, OpenGL ES 3.1, ARB_framebuffer_no_attachments |
| +and any other versions and extensions that provide the entry points |
| +FramebufferParameteri and GetFramebufferParameteriv |
| + |
| + Token GL_FRAMEBUFFER_FLIP_Y_MESA is accepted as the <pname> argument of |
| + FramebufferParameteri and GetFramebufferParameteriv. |
| + |
| Errors |
| |
| - An INVALID_OPERATION error is generated by GetFramebufferParameteriv if the |
| - default framebuffer is bound to <target> and <pname> is FRAMEBUFFER_FLIP_Y_MESA. |
| + An INVALID_OPERATION error is generated by GetFramebufferParameteriv or |
| + GetFramebufferParameterivMESA if the default framebuffer is bound |
| + to <target> and <pname> is GL_FRAMEBUFFER_FLIP_Y_MESA. |
| + |
| + |
| |
| Revision History |
| |
| + Version 3, August, 2019 |
| + Allow OpenGL ES 3.0 to implement by adding functions |
| + FramebufferParameteriMESA and GetFramebufferParameterivMESA which were |
| + previously only available in OpenGL ES 3.1. |
| + |
| + Version 2, June, 2019 |
| + Enable extension for OpenGL 4.3 and beyond |
| + |
| Version 1, June, 2018 |
| Initial draft (Fritz Koenig) |
| diff --git a/src/mapi/glapi/gen/apiexec.py b/src/mapi/glapi/gen/apiexec.py |
| index 4f9229d5fcd..26adb00ae21 100644 |
| --- a/src/mapi/glapi/gen/apiexec.py |
| +++ b/src/mapi/glapi/gen/apiexec.py |
| @@ -150,6 +150,10 @@ functions = { |
| "FramebufferParameteri": exec_info(compatibility=30, core=31, es2=31), |
| "GetFramebufferParameteriv": exec_info(compatibility=30, core=31, es2=31), |
| |
| + # OpenGL 4.3 / GL_MESA_framebuffer_flip_y. |
| + "FramebufferParameteriMESA": exec_info(core=31, es2=30), |
| + "GetFramebufferParameterivMESA": exec_info(core=31, es2=30), |
| + |
| # OpenGL 4.5 / GL_ARB_direct_state_access. Mesa can expose the extension |
| # with core profile. |
| "CreateTransformFeedbacks": exec_info(compatibility=31, core=31), |
| diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml |
| index 917fed62f98..3a797a50989 100644 |
| --- a/src/mapi/glapi/gen/es_EXT.xml |
| +++ b/src/mapi/glapi/gen/es_EXT.xml |
| @@ -1475,4 +1475,19 @@ |
| </function> |
| </category> |
| |
| +<!-- 302. GL_MESA_framebuffer_flip_y --> |
| +<category name="GL_MESA_framebuffer_flip_y" number="302"> |
| + <enum name="GL_FRAMEBUFFER_FLIP_Y_MESA" value="0x8BBB"/> |
| + <function name="FramebufferParameteriMESA" es2="3.0"> |
| + <param name="target" type="GLenum"/> |
| + <param name="pname" type="GLenum"/> |
| + <param name="param" type="GLint" /> |
| + </function> |
| + <function name="GetFramebufferParameterivMESA" es2="3.0"> |
| + <param name="target" type="GLenum" /> |
| + <param name="pname" type="GLenum" /> |
| + <param name="params" type="GLint *" output="true" /> |
| + </function> |
| +</category> |
| + |
| </OpenGLAPI> |
| diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py |
| index bc49324348f..24781390d30 100644 |
| --- a/src/mapi/glapi/gen/static_data.py |
| +++ b/src/mapi/glapi/gen/static_data.py |
| @@ -1453,6 +1453,8 @@ offsets = { |
| "TexParameterxv": 1417, |
| "BlendBarrier": 1418, |
| "PrimitiveBoundingBox": 1419, |
| + "FramebufferParameteriMESA": 1420, |
| + "GetFramebufferParameterivMESA": 1421, |
| } |
| |
| functions = [ |
| diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h |
| index 05ed418d750..bca4aa063f5 100644 |
| --- a/src/mesa/main/extensions_table.h |
| +++ b/src/mesa/main/extensions_table.h |
| @@ -342,7 +342,7 @@ EXT(KHR_texture_compression_astc_hdr , KHR_texture_compression_astc_hdr |
| EXT(KHR_texture_compression_astc_ldr , KHR_texture_compression_astc_ldr , GLL, GLC, x , ES2, 2012) |
| EXT(KHR_texture_compression_astc_sliced_3d , KHR_texture_compression_astc_sliced_3d , GLL, GLC, x , ES2, 2015) |
| |
| -EXT(MESA_framebuffer_flip_y , MESA_framebuffer_flip_y , x, x, x , 31, 2018) |
| +EXT(MESA_framebuffer_flip_y , MESA_framebuffer_flip_y , 43, 43, x , 30, 2018) |
| EXT(MESA_pack_invert , MESA_pack_invert , GLL, GLC, x , x , 2002) |
| EXT(MESA_shader_integer_functions , MESA_shader_integer_functions , GLL, GLC, x , 30, 2016) |
| EXT(MESA_texture_signed_rgba , EXT_texture_snorm , GLL, GLC, x , x , 2009) |
| diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c |
| index 047ef4ee395..3010de79818 100644 |
| --- a/src/mesa/main/fbobject.c |
| +++ b/src/mesa/main/fbobject.c |
| @@ -1590,18 +1590,46 @@ invalid_pname_enum: |
| _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname); |
| } |
| |
| +static bool |
| +validate_framebuffer_parameter_extensions(GLenum pname, const char *func) |
| +{ |
| + GET_CURRENT_CONTEXT(ctx); |
| + |
| + if (!ctx->Extensions.ARB_framebuffer_no_attachments && |
| + !ctx->Extensions.ARB_sample_locations && |
| + !ctx->Extensions.MESA_framebuffer_flip_y) { |
| + _mesa_error(ctx, GL_INVALID_OPERATION, |
| + "%s not supported " |
| + "(none of ARB_framebuffer_no_attachments," |
| + " ARB_sample_locations, or" |
| + " MESA_framebuffer_flip_y extensions are available)", |
| + func); |
| + return false; |
| + } |
| + |
| + /* |
| + * If only the MESA_framebuffer_flip_y extension is enabled |
| + * pname can only be GL_FRAMEBUFFER_FLIP_Y_MESA |
| + */ |
| + if (ctx->Extensions.MESA_framebuffer_flip_y && |
| + pname != GL_FRAMEBUFFER_FLIP_Y_MESA && |
| + !(ctx->Extensions.ARB_framebuffer_no_attachments || |
| + ctx->Extensions.ARB_sample_locations)) { |
| + _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname); |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| void GLAPIENTRY |
| _mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param) |
| { |
| GET_CURRENT_CONTEXT(ctx); |
| struct gl_framebuffer *fb; |
| |
| - if (!ctx->Extensions.ARB_framebuffer_no_attachments && |
| - !ctx->Extensions.ARB_sample_locations) { |
| - _mesa_error(ctx, GL_INVALID_OPERATION, |
| - "glFramebufferParameteriv not supported " |
| - "(neither ARB_framebuffer_no_attachments nor ARB_sample_locations" |
| - " is available)"); |
| + if (!validate_framebuffer_parameter_extensions(pname, |
| + "glFramebufferParameteri")) { |
| return; |
| } |
| |
| @@ -1615,6 +1643,12 @@ _mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param) |
| framebuffer_parameteri(ctx, fb, pname, param, "glFramebufferParameteri"); |
| } |
| |
| +void GLAPIENTRY |
| +_mesa_FramebufferParameteriMESA(GLenum target, GLenum pname, GLint param) |
| +{ |
| + _mesa_FramebufferParameteri(target, pname, param); |
| +} |
| + |
| static bool |
| validate_get_framebuffer_parameteriv_pname(struct gl_context *ctx, |
| struct gl_framebuffer *fb, |
| @@ -1744,12 +1778,8 @@ _mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| GET_CURRENT_CONTEXT(ctx); |
| struct gl_framebuffer *fb; |
| |
| - if (!ctx->Extensions.ARB_framebuffer_no_attachments && |
| - !ctx->Extensions.ARB_sample_locations) { |
| - _mesa_error(ctx, GL_INVALID_OPERATION, |
| - "glGetFramebufferParameteriv not supported " |
| - "(neither ARB_framebuffer_no_attachments nor ARB_sample_locations" |
| - " is available)"); |
| + if (!validate_framebuffer_parameter_extensions(pname, |
| + "glGetFramebufferParameteriv")) { |
| return; |
| } |
| |
| @@ -1764,6 +1794,11 @@ _mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) |
| "glGetFramebufferParameteriv"); |
| } |
| |
| +void GLAPIENTRY |
| +_mesa_GetFramebufferParameterivMESA(GLenum target, GLenum pname, GLint *params) |
| +{ |
| + _mesa_GetFramebufferParameteriv(target, pname, params); |
| +} |
| |
| /** |
| * Remove the specified renderbuffer or texture from any attachment point in |
| diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h |
| index fcf9835dfa4..6796571f809 100644 |
| --- a/src/mesa/main/fbobject.h |
| +++ b/src/mesa/main/fbobject.h |
| @@ -369,9 +369,15 @@ _mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments, |
| extern void GLAPIENTRY |
| _mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param); |
| |
| +extern void GLAPIENTRY |
| +_mesa_FramebufferParameteriMESA(GLenum target, GLenum pname, GLint param); |
| + |
| extern void GLAPIENTRY |
| _mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params); |
| |
| +extern void GLAPIENTRY |
| +_mesa_GetFramebufferParameterivMESA(GLenum target, GLenum pname, GLint *params); |
| + |
| extern void GLAPIENTRY |
| _mesa_FramebufferSampleLocationsfvARB(GLenum target, GLuint start, |
| GLsizei count, const GLfloat *v); |
| diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp |
| index 672e4ce892a..57364041b6e 100644 |
| --- a/src/mesa/main/tests/dispatch_sanity.cpp |
| +++ b/src/mesa/main/tests/dispatch_sanity.cpp |
| @@ -1198,6 +1198,10 @@ const struct function common_desktop_functions_possible[] = { |
| { "glRenderbufferStorageMultisampleAdvancedAMD", 11, -1 }, |
| { "glNamedRenderbufferStorageMultisampleAdvancedAMD", 11, -1 }, |
| |
| + /* GL_MESA_framebuffer_flip_y */ |
| + { "glFramebufferParameteriMESA", 43, -1 }, |
| + { "glGetFramebufferParameterivMESA", 43, -1 }, |
| + |
| { NULL, 0, -1 } |
| }; |
| |
| @@ -2433,6 +2437,10 @@ const struct function gles3_functions_possible[] = { |
| { "glRenderbufferStorageMultisampleAdvancedAMD", 11, -1 }, |
| { "glNamedRenderbufferStorageMultisampleAdvancedAMD", 11, -1 }, |
| |
| + /* GL_MESA_framebuffer_flip_y */ |
| + { "glFramebufferParameteriMESA", 30, -1 }, |
| + { "glGetFramebufferParameterivMESA", 30, -1 }, |
| + |
| { NULL, 0, -1 } |
| }; |
| |
| -- |
| 2.23.0.581.g78d2f28ef7-goog |
| |