diff options
author | Ilia Mirkin <[email protected]> | 2020-04-06 01:56:48 -0400 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2020-04-12 12:01:46 -0400 |
commit | ff168b297d94f656899a904ac147a9ce5add65c9 (patch) | |
tree | 96712a9315b7dedafb2181b9a91dcc76a8a02e80 /src | |
parent | 4137a79c2a7edb5f0caf0964ab748da7c279b61c (diff) |
mesa: add GL_NV_viewport_swizzle support
Signed-off-by: Ilia Mirkin <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4519>
Diffstat (limited to 'src')
-rw-r--r-- | src/mapi/glapi/gen/NV_viewport_swizzle.xml | 34 | ||||
-rw-r--r-- | src/mapi/glapi/gen/gl_API.xml | 2 | ||||
-rw-r--r-- | src/mapi/glapi/gen/meson.build | 1 | ||||
-rw-r--r-- | src/mapi/glapi/gen/static_data.py | 1 | ||||
-rw-r--r-- | src/mesa/main/extensions_table.h | 1 | ||||
-rw-r--r-- | src/mesa/main/get.c | 44 | ||||
-rw-r--r-- | src/mesa/main/get_hash_params.py | 6 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 4 | ||||
-rw-r--r-- | src/mesa/main/tests/dispatch_sanity.cpp | 6 | ||||
-rw-r--r-- | src/mesa/main/viewport.c | 97 | ||||
-rw-r--r-- | src/mesa/main/viewport.h | 10 |
11 files changed, 206 insertions, 0 deletions
diff --git a/src/mapi/glapi/gen/NV_viewport_swizzle.xml b/src/mapi/glapi/gen/NV_viewport_swizzle.xml new file mode 100644 index 00000000000..3b653bc66b7 --- /dev/null +++ b/src/mapi/glapi/gen/NV_viewport_swizzle.xml @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd"> + +<!-- Note: no GLX protocol info yet. --> + +<OpenGLAPI> + +<category name="GL_NV_viewport_swizzle" number="483"> + + <function name="ViewportSwizzleNV" no_error="true" es2="3.1"> + <param name="index" type="GLuint"/> + <param name="swizzlex" type="GLenum"/> + <param name="swizzley" type="GLenum"/> + <param name="swizzlez" type="GLenum"/> + <param name="swizzlew" type="GLenum"/> + </function> + + <enum name="VIEWPORT_SWIZZLE_POSITIVE_X_NV" value="0x9350"/> + <enum name="VIEWPORT_SWIZZLE_NEGATIVE_X_NV" value="0x9351"/> + <enum name="VIEWPORT_SWIZZLE_POSITIVE_Y_NV" value="0x9352"/> + <enum name="VIEWPORT_SWIZZLE_NEGATIVE_Y_NV" value="0x9353"/> + <enum name="VIEWPORT_SWIZZLE_POSITIVE_Z_NV" value="0x9354"/> + <enum name="VIEWPORT_SWIZZLE_NEGATIVE_Z_NV" value="0x9355"/> + <enum name="VIEWPORT_SWIZZLE_POSITIVE_W_NV" value="0x9358"/> + <enum name="VIEWPORT_SWIZZLE_NEGATIVE_W_NV" value="0x9357"/> + + <enum name="VIEWPORT_SWIZZLE_X_NV" value="0x9358"/> + <enum name="VIEWPORT_SWIZZLE_Y_NV" value="0x9359"/> + <enum name="VIEWPORT_SWIZZLE_Z_NV" value="0x935A"/> + <enum name="VIEWPORT_SWIZZLE_W_NV" value="0x935B"/> + +</category> + +</OpenGLAPI> diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 8c64eed6dae..4188bbf1986 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -13305,6 +13305,8 @@ <xi:include href="EXT_external_objects.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="EXT_external_objects_fd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> +<xi:include href="NV_viewport_swizzle.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> + <xi:include href="GL4x.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> </OpenGLAPI> diff --git a/src/mapi/glapi/gen/meson.build b/src/mapi/glapi/gen/meson.build index d04ccf19ae4..8f9a08f5294 100644 --- a/src/mapi/glapi/gen/meson.build +++ b/src/mapi/glapi/gen/meson.build @@ -138,6 +138,7 @@ api_xml_files = files( 'NV_primitive_restart.xml', 'NV_texture_barrier.xml', 'NV_vdpau_interop.xml', + 'NV_viewport_swizzle.xml', 'OES_EGL_image.xml', 'OES_fixed_point.xml', 'OES_single_precision.xml', diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py index 367b51338b9..99be40aac6e 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py @@ -1641,6 +1641,7 @@ offsets = { "EGLImageTargetTexStorageEXT" : 1605, "EGLImageTargetTextureStorageEXT" : 1606, "CopyImageSubDataNV": 1607, + "ViewportSwizzleNV": 1608, } functions = [ diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 9a678e247b8..5239a230cfd 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -402,6 +402,7 @@ EXT(NV_texture_barrier , NV_texture_barrier EXT(NV_texture_env_combine4 , NV_texture_env_combine4 , GLL, x , x , x , 1999) EXT(NV_texture_rectangle , NV_texture_rectangle , GLL, x , x , x , 2000) EXT(NV_vdpau_interop , NV_vdpau_interop , GLL, GLC, x , x , 2010) +EXT(NV_viewport_swizzle , NV_viewport_swizzle , GLL, GLC, x , 31, 2015) EXT(OES_EGL_image , OES_EGL_image , GLL, GLC, ES1, ES2, 2006) /* FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */ EXT(OES_EGL_image_external , OES_EGL_image_external , x , x , ES1, ES2, 2010) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 08315517167..7e9767d95e1 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -561,6 +561,7 @@ EXTRA_EXT(NV_conservative_raster_pre_snap_triangles); EXTRA_EXT(ARB_sample_locations); EXTRA_EXT(AMD_framebuffer_multisample_advanced); EXTRA_EXT(ARB_spirv_extensions); +EXTRA_EXT(NV_viewport_swizzle); static const int extra_ARB_color_buffer_float_or_glcore[] = { @@ -1326,6 +1327,20 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu memcpy(v->value_int_n.ints, ctx->Const.SupportedMultisampleModes, v->value_int_n.n * sizeof(GLint)); break; + + /* GL_NV_viewport_swizzle */ + case GL_VIEWPORT_SWIZZLE_X_NV: + v->value_enum = ctx->ViewportArray[0].SwizzleX; + break; + case GL_VIEWPORT_SWIZZLE_Y_NV: + v->value_enum = ctx->ViewportArray[0].SwizzleY; + break; + case GL_VIEWPORT_SWIZZLE_Z_NV: + v->value_enum = ctx->ViewportArray[0].SwizzleZ; + break; + case GL_VIEWPORT_SWIZZLE_W_NV: + v->value_enum = ctx->ViewportArray[0].SwizzleW; + break; } } @@ -2825,6 +2840,35 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v) goto invalid_enum; v->value_matrix = ctx->TextureMatrixStack[index].Top; return TYPE_MATRIX_T; + /* GL_NV_viewport_swizzle */ + case GL_VIEWPORT_SWIZZLE_X_NV: + if (!ctx->Extensions.NV_viewport_swizzle) + goto invalid_enum; + if (index >= ctx->Const.MaxViewports) + goto invalid_value; + v->value_int = ctx->ViewportArray[index].SwizzleX; + return TYPE_INT; + case GL_VIEWPORT_SWIZZLE_Y_NV: + if (!ctx->Extensions.NV_viewport_swizzle) + goto invalid_enum; + if (index >= ctx->Const.MaxViewports) + goto invalid_value; + v->value_int = ctx->ViewportArray[index].SwizzleY; + return TYPE_INT; + case GL_VIEWPORT_SWIZZLE_Z_NV: + if (!ctx->Extensions.NV_viewport_swizzle) + goto invalid_enum; + if (index >= ctx->Const.MaxViewports) + goto invalid_value; + v->value_int = ctx->ViewportArray[index].SwizzleZ; + return TYPE_INT; + case GL_VIEWPORT_SWIZZLE_W_NV: + if (!ctx->Extensions.NV_viewport_swizzle) + goto invalid_enum; + if (index >= ctx->Const.MaxViewports) + goto invalid_value; + v->value_int = ctx->ViewportArray[index].SwizzleW; + return TYPE_INT; } invalid_enum: diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index bd56b4e6c00..31563679593 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -668,6 +668,12 @@ descriptor=[ # INTEL_conservative_rasterization [ "CONSERVATIVE_RASTERIZATION_INTEL", "CONTEXT_BOOL(IntelConservativeRasterization), extra_INTEL_conservative_rasterization" ], + +# GL_NV_viewport_swizzle + [ "VIEWPORT_SWIZZLE_X_NV", "LOC_CUSTOM, TYPE_ENUM, 0, extra_NV_viewport_swizzle" ], + [ "VIEWPORT_SWIZZLE_Y_NV", "LOC_CUSTOM, TYPE_ENUM, 0, extra_NV_viewport_swizzle" ], + [ "VIEWPORT_SWIZZLE_Z_NV", "LOC_CUSTOM, TYPE_ENUM, 0, extra_NV_viewport_swizzle" ], + [ "VIEWPORT_SWIZZLE_W_NV", "LOC_CUSTOM, TYPE_ENUM, 0, extra_NV_viewport_swizzle" ], ]}, # Enums in OpenGL and ES 3.2 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 86b1a7035b8..7560a828b32 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1312,6 +1312,9 @@ struct gl_viewport_attrib GLfloat X, Y; /**< position */ GLfloat Width, Height; /**< size */ GLfloat Near, Far; /**< Depth buffer range */ + + /**< GL_NV_viewport_swizzle */ + GLenum16 SwizzleX, SwizzleY, SwizzleZ, SwizzleW; }; @@ -4438,6 +4441,7 @@ struct gl_extensions GLboolean NV_conservative_raster_dilate; GLboolean NV_conservative_raster_pre_snap_triangles; GLboolean NV_conservative_raster_pre_snap; + GLboolean NV_viewport_swizzle; GLboolean NVX_gpu_memory_info; GLboolean TDFX_texture_compression_FXT1; GLboolean OES_EGL_image; diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index f03317a2d5f..69dd56598e2 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -1435,6 +1435,9 @@ const struct function common_desktop_functions_possible[] = { { "glProgramUniform3ui64vARB", 40, -1 }, { "glProgramUniform4ui64vARB", 40, -1 }, + /* GL_NV_viewport_swizzle */ + { "glViewportSwizzleNV", 11, -1 }, + { NULL, 0, -1 } }; @@ -2770,5 +2773,8 @@ const struct function gles31_functions_possible[] = { { "glNamedFramebufferSampleLocationsfvARB", 31, -1 }, { "glEvaluateDepthValuesARB", 31, -1 }, + /* GL_NV_viewport_swizzle */ + { "glViewportSwizzleNV", 31, -1 }, + { NULL, 0, -1 }, }; diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index f4dc74ae41a..a501e245626 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -488,6 +488,10 @@ void _mesa_init_viewport(struct gl_context *ctx) ctx->ViewportArray[i].Height = 0; ctx->ViewportArray[i].Near = 0.0; ctx->ViewportArray[i].Far = 1.0; + ctx->ViewportArray[i].SwizzleX = GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV; + ctx->ViewportArray[i].SwizzleY = GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV; + ctx->ViewportArray[i].SwizzleZ = GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV; + ctx->ViewportArray[i].SwizzleW = GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV; } ctx->SubpixelPrecisionBias[0] = 0; @@ -658,3 +662,96 @@ _mesa_SubpixelPrecisionBiasNV(GLuint xbits, GLuint ybits) subpixel_precision_bias(ctx, xbits, ybits); } + +static void +set_viewport_swizzle(struct gl_context *ctx, GLuint index, + GLenum swizzlex, GLenum swizzley, + GLenum swizzlez, GLenum swizzlew) +{ + struct gl_viewport_attrib *viewport = &ctx->ViewportArray[index]; + if (viewport->SwizzleX == swizzlex && + viewport->SwizzleY == swizzley && + viewport->SwizzleZ == swizzlez && + viewport->SwizzleW == swizzlew) + return; + + FLUSH_VERTICES(ctx, _NEW_VIEWPORT); + ctx->NewDriverState |= ctx->DriverFlags.NewViewport; + + viewport->SwizzleX = swizzlex; + viewport->SwizzleY = swizzley; + viewport->SwizzleZ = swizzlez; + viewport->SwizzleW = swizzlew; +} + +void GLAPIENTRY +_mesa_ViewportSwizzleNV_no_error(GLuint index, + GLenum swizzlex, GLenum swizzley, + GLenum swizzlez, GLenum swizzlew) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glViewportSwizzleNV(%x, %x, %x, %x)\n", + swizzlex, swizzley, swizzlez, swizzlew); + + set_viewport_swizzle(ctx, index, swizzlex, swizzley, swizzlez, swizzlew); +} + +static bool +verify_viewport_swizzle(GLenum swizzle) +{ + return swizzle >= GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV && + swizzle <= GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV; +} + +void GLAPIENTRY +_mesa_ViewportSwizzleNV(GLuint index, + GLenum swizzlex, GLenum swizzley, + GLenum swizzlez, GLenum swizzlew) +{ + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glViewportSwizzleNV(%x, %x, %x, %x)\n", + swizzlex, swizzley, swizzlez, swizzlew); + + if (!ctx->Extensions.NV_viewport_swizzle) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glViewportSwizzleNV not supported"); + return; + } + + if (index >= ctx->Const.MaxViewports) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glViewportSwizzleNV: index (%d) >= MaxViewports (%d)", + index, ctx->Const.MaxViewports); + return; + } + + if (!verify_viewport_swizzle(swizzlex)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glViewportSwizzleNV(swizzlex=%x)", swizzlex); + return; + } + + if (!verify_viewport_swizzle(swizzley)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glViewportSwizzleNV(swizzley=%x)", swizzley); + return; + } + + if (!verify_viewport_swizzle(swizzlez)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glViewportSwizzleNV(swizzlez=%x)", swizzlez); + return; + } + + if (!verify_viewport_swizzle(swizzlew)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glViewportSwizzleNV(swizzlew=%x)", swizzlew); + return; + } + + set_viewport_swizzle(ctx, index, swizzlex, swizzley, swizzlez, swizzlew); +} diff --git a/src/mesa/main/viewport.h b/src/mesa/main/viewport.h index aca62965b06..655873d4774 100644 --- a/src/mesa/main/viewport.h +++ b/src/mesa/main/viewport.h @@ -110,4 +110,14 @@ _mesa_SubpixelPrecisionBiasNV_no_error(GLuint xbits, GLuint ybits); extern void GLAPIENTRY _mesa_SubpixelPrecisionBiasNV(GLuint xbits, GLuint ybits); +extern void GLAPIENTRY +_mesa_ViewportSwizzleNV_no_error(GLuint index, + GLenum swizzlex, GLenum swizzley, + GLenum swizzlez, GLenum swizzlew); + +extern void GLAPIENTRY +_mesa_ViewportSwizzleNV(GLuint index, + GLenum swizzlex, GLenum swizzley, + GLenum swizzlez, GLenum swizzlew); + #endif |