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/mesa/main | |
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/mesa/main')
-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 |
7 files changed, 168 insertions, 0 deletions
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 |