Mesa (master): gallivm: fix no-op n:n lp_build_resize()

Roland Scheidegger sroland at kemper.freedesktop.org
Wed Mar 26 00:45:23 UTC 2014


Module: Mesa
Branch: master
Commit: 3b421daf32e5941801e0efb162037de4d8ca1f1d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3b421daf32e5941801e0efb162037de4d8ca1f1d

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Tue Mar 25 01:52:03 2014 +0100

gallivm: fix no-op n:n lp_build_resize()

This can get called in some circumstances if both src type and dst type
have same width (seen with float32->unorm32). While this particular case
was bogus anyway let's just fix that as it can work trivially (due to the
way it was called it actually worked anyway apart from the assert).

Reviewed-by: Zack Rusin <zackr at vmware.com>
Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

---

 src/gallium/auxiliary/gallivm/lp_bld_pack.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
index 22a4f5a8..2b0a1fb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
@@ -710,9 +710,6 @@ lp_build_resize(struct gallivm_state *gallivm,
    /* We must not loose or gain channels. Only precision */
    assert(src_type.length * num_srcs == dst_type.length * num_dsts);
 
-   /* We don't support M:N conversion, only 1:N, M:1, or 1:1 */
-   assert(num_srcs == 1 || num_dsts == 1);
-
    assert(src_type.length <= LP_MAX_VECTOR_LENGTH);
    assert(dst_type.length <= LP_MAX_VECTOR_LENGTH);
    assert(num_srcs <= LP_MAX_VECTOR_LENGTH);
@@ -723,6 +720,7 @@ lp_build_resize(struct gallivm_state *gallivm,
        * Truncate bit width.
        */
 
+      /* Conversion must be M:1 */
       assert(num_dsts == 1);
 
       if (src_type.width * src_type.length == dst_type.width * dst_type.length) {
@@ -775,6 +773,7 @@ lp_build_resize(struct gallivm_state *gallivm,
        * Expand bit width.
        */
 
+      /* Conversion must be 1:N */
       assert(num_srcs == 1);
 
       if (src_type.width * src_type.length == dst_type.width * dst_type.length) {
@@ -813,10 +812,11 @@ lp_build_resize(struct gallivm_state *gallivm,
        * No-op
        */
 
-      assert(num_srcs == 1);
-      assert(num_dsts == 1);
+      /* "Conversion" must be N:N */
+      assert(num_srcs == num_dsts);
 
-      tmp[0] = src[0];
+      for(i = 0; i < num_dsts; ++i)
+         tmp[i] = src[i];
    }
 
    for(i = 0; i < num_dsts; ++i)




More information about the mesa-commit mailing list