st/mesa: samplers only need to track whether GLSL >= 130
authorMarek Olšák <marek.olsak@amd.com>
Sun, 11 Jun 2017 23:15:59 +0000 (01:15 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_sampler_view.c
src/mesa/state_tracker/st_sampler_view.h
src/mesa/state_tracker/st_texture.c
src/mesa/state_tracker/st_texture.h

index b71b73506f82a07e0879f8e2d9e506d738d00da2..cb6b4005fa6c83443661359ef7230cf691c52251 100644 (file)
@@ -58,7 +58,7 @@
 void
 st_update_single_texture(struct st_context *st,
                          struct pipe_sampler_view **sampler_view,
-                         GLuint texUnit, unsigned glsl_version)
+                         GLuint texUnit, bool glsl130_or_later)
 {
    struct gl_context *ctx = st->ctx;
    const struct gl_sampler_object *samp;
@@ -88,12 +88,12 @@ st_update_single_texture(struct st_context *st,
    /* Check a few pieces of state outside the texture object to see if we
     * need to force revalidation.
     */
-   if (stObj->prev_glsl_version != glsl_version ||
+   if (stObj->prev_glsl130_or_later != glsl130_or_later ||
        stObj->prev_sRGBDecode != samp->sRGBDecode) {
 
       st_texture_release_all_sampler_views(st, stObj);
 
-      stObj->prev_glsl_version = glsl_version;
+      stObj->prev_glsl130_or_later = glsl130_or_later;
       stObj->prev_sRGBDecode = samp->sRGBDecode;
    }
 
@@ -102,7 +102,8 @@ st_update_single_texture(struct st_context *st,
          stObj->pt->screen->resource_changed(stObj->pt->screen, stObj->pt);
 
    *sampler_view =
-      st_get_texture_sampler_view_from_stobj(st, stObj, samp, glsl_version);
+      st_get_texture_sampler_view_from_stobj(st, stObj, samp,
+                                             glsl130_or_later);
 }
 
 
@@ -125,17 +126,18 @@ update_textures(struct st_context *st,
 
    unsigned num_textures = 0;
 
+   /* prog->sh.data is NULL if it's ARB_fragment_program */
+   bool glsl130 = (prog->sh.data ? prog->sh.data->Version : 0) >= 130;
+
    /* loop over sampler units (aka tex image units) */
    for (unit = 0; samplers_used || unit < old_max;
         unit++, samplers_used >>= 1) {
       struct pipe_sampler_view *sampler_view = NULL;
 
       if (samplers_used & 1) {
-         /* prog->sh.data is NULL if it's ARB_fragment_program */
-         unsigned glsl_version = prog->sh.data ? prog->sh.data->Version : 0;
          const GLuint texUnit = prog->SamplerUnits[unit];
 
-         st_update_single_texture(st, &sampler_view, texUnit, glsl_version);
+         st_update_single_texture(st, &sampler_view, texUnit, glsl130);
          num_textures = unit + 1;
       }
 
index e8a46a722440f6190f8b0cd0e61d66d5e879522f..7a6993e67c791b56e9387e1197922021c1ceeb09 100644 (file)
@@ -190,7 +190,7 @@ swizzle_swizzle(unsigned swizzle1, unsigned swizzle2)
 static unsigned
 compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode,
                                enum pipe_format actualFormat,
-                               unsigned glsl_version)
+                               bool glsl130_or_later)
 {
    switch (baseFormat) {
    case GL_RGBA:
@@ -257,7 +257,7 @@ compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode,
           * BTW, it's required that sampler views are updated when
           * shaders change (check_sampler_swizzle takes care of that).
           */
-         if (glsl_version && glsl_version >= 130)
+         if (glsl130_or_later)
             return SWIZZLE_XXXX;
          else
             return MAKE_SWIZZLE4(SWIZZLE_ZERO, SWIZZLE_ZERO,
@@ -279,7 +279,7 @@ compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode,
 static unsigned
 get_texture_format_swizzle(const struct st_context *st,
                            const struct st_texture_object *stObj,
-                           unsigned glsl_version)
+                           bool glsl130_or_later)
 {
    GLenum baseFormat = _mesa_base_tex_image(&stObj->base)->_BaseFormat;
    unsigned tex_swizzle;
@@ -302,7 +302,7 @@ get_texture_format_swizzle(const struct st_context *st,
    tex_swizzle = compute_texture_format_swizzle(baseFormat,
                                                 depth_mode,
                                                 stObj->pt->format,
-                                                glsl_version);
+                                                glsl130_or_later);
 
    /* Combine the texture format swizzle with user's swizzle */
    return swizzle_swizzle(stObj->base._Swizzle, tex_swizzle);
@@ -318,9 +318,10 @@ get_texture_format_swizzle(const struct st_context *st,
 MAYBE_UNUSED static boolean
 check_sampler_swizzle(const struct st_context *st,
                       const struct st_texture_object *stObj,
-                     const struct pipe_sampler_view *sv, unsigned glsl_version)
+                      const struct pipe_sampler_view *sv,
+                      bool glsl130_or_later)
 {
-   unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl_version);
+   unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl130_or_later);
 
    return ((sv->swizzle_r != GET_SWZ(swizzle, 0)) ||
            (sv->swizzle_g != GET_SWZ(swizzle, 1)) ||
@@ -393,10 +394,10 @@ static struct pipe_sampler_view *
 st_create_texture_sampler_view_from_stobj(struct st_context *st,
                                          struct st_texture_object *stObj,
                                          enum pipe_format format,
-                                          unsigned glsl_version)
+                                          bool glsl130_or_later)
 {
    struct pipe_sampler_view templ;
-   unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl_version);
+   unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl130_or_later);
 
    u_sampler_view_default_template(&templ, stObj->pt, format);
 
@@ -425,7 +426,7 @@ struct pipe_sampler_view *
 st_get_texture_sampler_view_from_stobj(struct st_context *st,
                                        struct st_texture_object *stObj,
                                        const struct gl_sampler_object *samp,
-                                       unsigned glsl_version)
+                                       bool glsl130_or_later)
 {
    struct pipe_sampler_view **sv;
 
@@ -441,7 +442,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
        */
       MAYBE_UNUSED struct pipe_sampler_view *view = *sv;
       assert(stObj->pt == view->texture);
-      assert(!check_sampler_swizzle(st, stObj, view, glsl_version));
+      assert(!check_sampler_swizzle(st, stObj, view, glsl130_or_later));
       assert(get_sampler_view_format(st, stObj, samp) == view->format);
       assert(gl_target_to_pipe(stObj->base.Target) == view->target);
       assert(stObj->base.MinLevel + stObj->base.BaseLevel ==
@@ -458,7 +459,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
       enum pipe_format format = get_sampler_view_format(st, stObj, samp);
 
       *sv = st_create_texture_sampler_view_from_stobj(st, stObj,
-                                                      format, glsl_version);
+                                                      format, glsl130_or_later);
 
    }
 
index b08ca4a70f243787b44f00d45382c4bf42fc7d9f..392206be4f71db2086a058222222d4a9d6373d89 100644 (file)
@@ -73,7 +73,7 @@ struct pipe_sampler_view *
 st_get_texture_sampler_view_from_stobj(struct st_context *st,
                                        struct st_texture_object *stObj,
                                        const struct gl_sampler_object *samp,
-                                       unsigned glsl_version);
+                                       bool glsl130_or_later);
 
 struct pipe_sampler_view *
 st_get_buffer_sampler_view_from_stobj(struct st_context *st,
index 2b43cecc521719f43abca863464b48975070fd5a..b409f286eb5fa6f7187cd5226077ca55fa87b0ed 100644 (file)
@@ -512,7 +512,7 @@ st_create_texture_handle_from_unit(struct st_context *st,
    struct pipe_sampler_view *view;
    struct pipe_sampler_state sampler = {0};
 
-   st_update_single_texture(st, &view, texUnit, prog->sh.data->Version);
+   st_update_single_texture(st, &view, texUnit, prog->sh.data->Version >= 130);
    if (!view)
       return 0;
 
index b9336544bb3bb9c5b2a08c3cc0f53d2064cf52da..a6f6ee8ebef199df2831f04d222e13448e47d84e 100644 (file)
@@ -121,7 +121,7 @@ struct st_texture_object
    uint layer_override;
 
    /** The glsl version of the shader seen during the previous validation */
-   unsigned prev_glsl_version;
+   bool prev_glsl130_or_later;
    /** The value of the sampler's sRGBDecode state at the previous validation */
    GLenum prev_sRGBDecode;
 
@@ -291,7 +291,7 @@ st_convert_sampler_from_unit(const struct st_context *st,
 void
 st_update_single_texture(struct st_context *st,
                          struct pipe_sampler_view **sampler_view,
-                         GLuint texUnit, unsigned glsl_version);
+                         GLuint texUnit, bool glsl130_or_later);
 
 void
 st_make_bound_samplers_resident(struct st_context *st,