gallivm: set non-existing values really to zero in size queries for d3d10
authorRoland Scheidegger <sroland@vmware.com>
Thu, 8 Aug 2013 15:18:44 +0000 (17:18 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Fri, 9 Aug 2013 18:49:19 +0000 (20:49 +0200)
My previous attempt at doing so double-failed miserably (minification of
zero still gives one, and even if it would not the value was never written
anyway).
While here also rename the confusingly named int_vec bld as we have int vecs
of different sizes, and rename need_nr_mips (as this also changes out-of-bounds
behavior) to is_sviewinfo too.

Reviewed-by: Zack Rusin <zackr@vmware.com>
src/gallium/auxiliary/draw/draw_llvm_sample.c
src/gallium/auxiliary/gallivm/lp_bld_sample.h
src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
src/gallium/drivers/llvmpipe/lp_tex_sample.c

index f10cba3279c590e30dd5c2baf3555807a3810662..97b025565c3106c209bb6fbc5e626912af0404f9 100644 (file)
@@ -271,7 +271,7 @@ draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
                                       struct lp_type type,
                                       unsigned texture_unit,
                                       unsigned target,
-                                      boolean need_nr_mips,
+                                      boolean is_sviewinfo,
                                       boolean scalar_lod,
                                       LLVMValueRef explicit_lod, /* optional */
                                       LLVMValueRef *sizes_out)
@@ -286,7 +286,7 @@ draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
                            type,
                            texture_unit,
                            target,
-                           need_nr_mips,
+                           is_sviewinfo,
                            scalar_lod,
                            explicit_lod,
                            sizes_out);
index db3ea1df59f49f7a299b2457acff5925634bfeb2..75e8c593f51ebd7b34598cbd089fd364f35326f4 100644 (file)
@@ -498,7 +498,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
                         struct lp_type int_type,
                         unsigned texture_unit,
                         unsigned target,
-                        boolean need_nr_mips,
+                        boolean is_viewinfo,
                         boolean scalar_lod,
                         LLVMValueRef explicit_lod,
                         LLVMValueRef *sizes_out);
index e403ac83c6a5c0cd186832f477da1a53a11c9cb6..65d6e7b1e4989552c4f822a0cf718bd1ba25e6fd 100644 (file)
@@ -1944,7 +1944,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
                         struct lp_type int_type,
                         unsigned texture_unit,
                         unsigned target,
-                        boolean need_nr_mips,
+                        boolean is_sviewinfo,
                         boolean scalar_lod,
                         LLVMValueRef explicit_lod,
                         LLVMValueRef *sizes_out)
@@ -1954,7 +1954,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
    int dims, i;
    boolean has_array;
    unsigned num_lods = 1;
-   struct lp_build_context bld_int_vec;
+   struct lp_build_context bld_int_vec4;
 
    /*
     * Do some sanity verification about bound texture and shader dcl target.
@@ -1997,24 +1997,19 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
 
    assert(!int_type.floating);
 
-   lp_build_context_init(&bld_int_vec, gallivm, lp_type_int_vec(32, 128));
+   lp_build_context_init(&bld_int_vec4, gallivm, lp_type_int_vec(32, 128));
 
    if (explicit_lod) {
       /* FIXME: this needs to honor per-element lod */
       lod = LLVMBuildExtractElement(gallivm->builder, explicit_lod, lp_build_const_int32(gallivm, 0), "");
       first_level = dynamic_state->first_level(dynamic_state, gallivm, texture_unit);
       level = LLVMBuildAdd(gallivm->builder, lod, first_level, "level");
-      lod = lp_build_broadcast_scalar(&bld_int_vec, level);
+      lod = lp_build_broadcast_scalar(&bld_int_vec4, level);
    } else {
-      lod = bld_int_vec.zero;
+      lod = bld_int_vec4.zero;
    }
 
-   if (need_nr_mips) {
-      size = bld_int_vec.zero;
-   }
-   else {
-      size = bld_int_vec.undef;
-   }
+   size = bld_int_vec4.undef;
 
    size = LLVMBuildInsertElement(gallivm->builder, size,
                                  dynamic_state->width(dynamic_state, gallivm, texture_unit),
@@ -2032,7 +2027,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
                                     lp_build_const_int32(gallivm, 2), "");
    }
 
-   size = lp_build_minify(&bld_int_vec, size, lod);
+   size = lp_build_minify(&bld_int_vec4, size, lod);
 
    if (has_array)
       size = LLVMBuildInsertElement(gallivm->builder, size,
@@ -2044,7 +2039,7 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
     * if level is out of bounds (note this can't cover unbound texture
     * here, which also requires returning zero).
     */
-   if (explicit_lod && need_nr_mips) {
+   if (explicit_lod && is_sviewinfo) {
       LLVMValueRef last_level, out, out1;
       struct lp_build_context leveli_bld;
 
@@ -2056,25 +2051,30 @@ lp_build_size_query_soa(struct gallivm_state *gallivm,
       out1 = lp_build_cmp(&leveli_bld, PIPE_FUNC_GREATER, level, last_level);
       out = lp_build_or(&leveli_bld, out, out1);
       if (num_lods == 1) {
-         out = lp_build_broadcast_scalar(&bld_int_vec, out);
+         out = lp_build_broadcast_scalar(&bld_int_vec4, out);
       }
       else {
          /* TODO */
          assert(0);
       }
-      size = lp_build_andnot(&bld_int_vec, size, out);
+      size = lp_build_andnot(&bld_int_vec4, size, out);
    }
    for (i = 0; i < dims + (has_array ? 1 : 0); i++) {
-      sizes_out[i] = lp_build_extract_broadcast(gallivm, bld_int_vec.type, int_type,
+      sizes_out[i] = lp_build_extract_broadcast(gallivm, bld_int_vec4.type, int_type,
                                                 size,
                                                 lp_build_const_int32(gallivm, i));
    }
+   if (is_sviewinfo) {
+      for (; i < 4; i++) {
+         sizes_out[i] = lp_build_const_vec(gallivm, int_type, 0.0);
+      }
+   }
 
    /*
     * if there's no explicit_lod (buffers, rects) queries requiring nr of
     * mips would be illegal.
     */
-   if (need_nr_mips && explicit_lod) {
+   if (is_sviewinfo && explicit_lod) {
       struct lp_build_context bld_int_scalar;
       LLVMValueRef num_levels;
       lp_build_context_init(&bld_int_scalar, gallivm, lp_type_int(32));
index 5402de407d567cfbf18bc6d93a3d2f82eef79829..68a4be932231b0b525fe7c760ed75492226d75f6 100644 (file)
@@ -281,7 +281,7 @@ lp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
                                     struct lp_type type,
                                     unsigned texture_unit,
                                     unsigned target,
-                                    boolean need_nr_mips,
+                                    boolean is_sviewinfo,
                                     boolean scalar_lod,
                                     LLVMValueRef explicit_lod, /* optional */
                                     LLVMValueRef *sizes_out)
@@ -296,7 +296,7 @@ lp_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
                            type,
                            texture_unit,
                            target,
-                           need_nr_mips,
+                           is_sviewinfo,
                            scalar_lod,
                            explicit_lod,
                            sizes_out);