Mesa (main): st/mesa: remove the sampler min_lod/max_lod value swap

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jun 27 13:07:33 UTC 2021


Module: Mesa
Branch: main
Commit: 9de9e83735c9553828e4a2ed259ac2b1d8771280
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9de9e83735c9553828e4a2ed259ac2b1d8771280

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Mon Jun  7 06:55:12 2021 -0400

st/mesa: remove the sampler min_lod/max_lod value swap

It might not be needed at all.

v2: fix v3d assertion failure

Acked-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11428>

---

 src/gallium/drivers/v3d/v3dx_emit.c      | 3 ++-
 src/gallium/drivers/v3d/v3dx_state.c     | 3 ++-
 src/mesa/state_tracker/st_atom_sampler.c | 9 ---------
 3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/v3d/v3dx_emit.c b/src/gallium/drivers/v3d/v3dx_emit.c
index 32f3010c71c..04eb27618e7 100644
--- a/src/gallium/drivers/v3d/v3dx_emit.c
+++ b/src/gallium/drivers/v3d/v3dx_emit.c
@@ -177,7 +177,8 @@ emit_one_texture(struct v3d_context *v3d, struct v3d_texture_stateobj *stage_tex
                                             MAX2(psampler->min_lod, 0),
                                             psview->u.tex.last_level),
                 .max_level_of_detail = MIN2(psview->u.tex.first_level +
-                                            psampler->max_lod,
+                                            MAX2(psampler->max_lod,
+                                                 psampler->min_lod),
                                             psview->u.tex.last_level),
 
                 .texture_base_pointer = cl_address(rsc->bo,
diff --git a/src/gallium/drivers/v3d/v3dx_state.c b/src/gallium/drivers/v3d/v3dx_state.c
index e9033d250d7..4c553988b8b 100644
--- a/src/gallium/drivers/v3d/v3dx_state.c
+++ b/src/gallium/drivers/v3d/v3dx_state.c
@@ -550,7 +550,8 @@ v3d_upload_sampler_state_variant(void *map,
 
                 sampler.min_level_of_detail = MIN2(MAX2(0, cso->min_lod),
                                                    15);
-                sampler.max_level_of_detail = MIN2(cso->max_lod, 15);
+                sampler.max_level_of_detail = MIN2(MAX2(cso->max_lod,
+                                                        cso->min_lod), 15);
 
                 /* If we're not doing inter-miplevel filtering, we need to
                  * clamp the LOD so that we only sample from baselevel.
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 5a49b06bc1a..9f1b2fd72f6 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -169,15 +169,6 @@ st_convert_sampler(const struct st_context *st,
 
    sampler->min_lod = MAX2(msamp->Attrib.MinLod, 0.0f);
    sampler->max_lod = msamp->Attrib.MaxLod;
-   if (sampler->max_lod < sampler->min_lod) {
-      /* The GL spec doesn't seem to specify what to do in this case.
-       * Swap the values.
-       */
-      float tmp = sampler->max_lod;
-      sampler->max_lod = sampler->min_lod;
-      sampler->min_lod = tmp;
-      assert(sampler->min_lod <= sampler->max_lod);
-   }
 
    /* Check that only wrap modes using the border color have the first bit
     * set.



More information about the mesa-commit mailing list