[Mesa-dev] [PATCH 5/8] st/mesa: use PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY

Marek Olšák maraeo at gmail.com
Wed May 23 20:58:56 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

---
 src/mesa/state_tracker/st_extensions.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 2d56a880273..b5622b330bb 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -929,57 +929,62 @@ void st_init_extensions(struct pipe_screen *screen,
                           PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW);
    init_format_extensions(screen, extensions, texture_mapping,
                           ARRAY_SIZE(texture_mapping), PIPE_TEXTURE_2D,
                           PIPE_BIND_SAMPLER_VIEW);
    init_format_extensions(screen, extensions, vertex_mapping,
                           ARRAY_SIZE(vertex_mapping), PIPE_BUFFER,
                           PIPE_BIND_VERTEX_BUFFER);
 
    /* Figure out GLSL support and set GLSLVersion to it. */
    consts->GLSLVersion = screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL);
-   consts->GLSLVersionCompat = _min(consts->GLSLVersion, 140);
+   consts->GLSLVersionCompat =
+      screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY);
+
+   const unsigned GLSLVersion =
+      api == API_OPENGL_COMPAT ? consts->GLSLVersionCompat :
+                                 consts->GLSLVersion;
 
    _mesa_override_glsl_version(consts);
 
    if (options->force_glsl_version > 0 &&
-       options->force_glsl_version <= consts->GLSLVersion) {
+       options->force_glsl_version <= GLSLVersion) {
       consts->ForceGLSLVersion = options->force_glsl_version;
    }
 
    consts->AllowHigherCompatVersion = options->allow_higher_compat_version;
 
    consts->ForceGLSLAbsSqrt = options->force_glsl_abs_sqrt;
 
    consts->AllowGLSLBuiltinVariableRedeclaration = options->allow_glsl_builtin_variable_redeclaration;
 
    consts->dri_config_options_sha1 = options->config_options_sha1;
 
    consts->AllowGLSLCrossStageInterpolationMismatch = options->allow_glsl_cross_stage_interpolation_mismatch;
 
-   if (consts->GLSLVersion >= 400)
+   if (GLSLVersion >= 400)
       extensions->ARB_gpu_shader5 = GL_TRUE;
-   if (consts->GLSLVersion >= 410)
+   if (GLSLVersion >= 410)
       extensions->ARB_shader_precision = GL_TRUE;
 
    /* This extension needs full OpenGL 3.2, but we don't know if that's
     * supported at this point. Only check the GLSL version. */
-   if (consts->GLSLVersion >= 150 &&
+   if (GLSLVersion >= 150 &&
        screen->get_param(screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT)) {
       extensions->AMD_vertex_shader_layer = GL_TRUE;
    }
 
-   if (consts->GLSLVersion >= 140) {
+   if (GLSLVersion >= 140) {
       if (screen->get_param(screen, PIPE_CAP_TGSI_ARRAY_COMPONENTS))
          extensions->ARB_enhanced_layouts = GL_TRUE;
    }
 
-   if (consts->GLSLVersion >= 130) {
+   if (GLSLVersion >= 130) {
       consts->NativeIntegers = GL_TRUE;
       consts->MaxClipPlanes = 8;
 
       if (screen->get_param(screen, PIPE_CAP_VERTEXID_NOBASE)) {
          consts->VertexID_is_zero_based = GL_TRUE;
       }
 
       /* Extensions that either depend on GLSL 1.30 or are a subset thereof. */
       extensions->ARB_conservative_depth = GL_TRUE;
       extensions->ARB_shading_language_packing = GL_TRUE;
@@ -1017,21 +1022,21 @@ void st_init_extensions(struct pipe_screen *screen,
 
    if (screen->get_shader_param(screen, PIPE_SHADER_TESS_CTRL,
                                 PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
       extensions->ARB_tessellation_shader = GL_TRUE;
    }
 
    /* What this is really checking for is the ability to support multiple
     * invocations of a geometry shader. There is no separate cap for that, so
     * we check the GLSLVersion.
     */
-   if (consts->GLSLVersion >= 400 &&
+   if (GLSLVersion >= 400 &&
        screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY,
                                 PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
       extensions->OES_geometry_shader = GL_TRUE;
    }
 
    /* Needs PIPE_CAP_SAMPLE_SHADING + all the sample-related bits of
     * ARB_gpu_shader5. This enables all the per-sample shading ES extensions.
     */
    extensions->OES_sample_variables = extensions->ARB_sample_shading &&
       extensions->ARB_gpu_shader5;
@@ -1164,21 +1169,21 @@ void st_init_extensions(struct pipe_screen *screen,
                                 PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS) <= 8) {
       /* We can't disable varying packing if transform feedback is available,
        * because transform feedback code assumes a packed varying layout.
        */
       if (!extensions->EXT_transform_feedback)
          consts->DisableVaryingPacking = GL_TRUE;
    }
 
    consts->MaxViewports = screen->get_param(screen, PIPE_CAP_MAX_VIEWPORTS);
    if (consts->MaxViewports >= 16) {
-      if (consts->GLSLVersion >= 400) {
+      if (GLSLVersion >= 400) {
          consts->ViewportBounds.Min = -32768.0;
          consts->ViewportBounds.Max = 32767.0;
       } else {
          consts->ViewportBounds.Min = -16384.0;
          consts->ViewportBounds.Max = 16383.0;
       }
       extensions->ARB_viewport_array = GL_TRUE;
       extensions->ARB_fragment_layer_viewport = GL_TRUE;
       if (extensions->AMD_vertex_shader_layer)
          extensions->AMD_vertex_shader_viewport_index = GL_TRUE;
@@ -1194,21 +1199,21 @@ void st_init_extensions(struct pipe_screen *screen,
        ((consts->MaxSamples >= 4 && consts->MaxFramebufferLayers >= 2048) ||
         (consts->MaxFramebufferSamples >= consts->MaxSamples &&
          consts->MaxFramebufferLayers >= consts->MaxArrayTextureLayers)))
       extensions->ARB_framebuffer_no_attachments = GL_TRUE;
 
    /* GL_ARB_ES3_compatibility.
     *
     * Assume that ES3 is supported if GLSL 3.30 is supported.
     * (OpenGL 3.3 is a requirement for that extension.)
     */
-   if (consts->GLSLVersion >= 330 &&
+   if (GLSLVersion >= 330 &&
        /* Requirements for ETC2 emulation. */
        screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_UNORM,
                                    PIPE_TEXTURE_2D, 0,
                                    PIPE_BIND_SAMPLER_VIEW) &&
        screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
                                    PIPE_TEXTURE_2D, 0,
                                    PIPE_BIND_SAMPLER_VIEW) &&
        screen->is_format_supported(screen, PIPE_FORMAT_R16_UNORM,
                                    PIPE_TEXTURE_2D, 0,
                                    PIPE_BIND_SAMPLER_VIEW) &&
-- 
2.17.0



More information about the mesa-dev mailing list