radeonsi: make fix_fetch 64-bit
authorMarek Olšák <marek.olsak@amd.com>
Thu, 5 Jan 2017 23:07:21 +0000 (00:07 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 16 Jan 2017 17:07:08 +0000 (18:07 +0100)
v2: add u_bit_consecutive64

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state.h
src/gallium/drivers/radeonsi/si_state_shaders.c
src/util/bitscan.h

index d45c0e8649c87c90f387adbf97801c5da626a010..ddb6ca1ae1752b643396401fca519cadc73a2799 100644 (file)
@@ -433,7 +433,7 @@ static void declare_input_vs(
                                                    input, llvm_chan, "");
        }
 
-       fix_fetch = (ctx->shader->key.mono.vs.fix_fetch >> (2 * input_index)) & 3;
+       fix_fetch = (ctx->shader->key.mono.vs.fix_fetch >> (4 * input_index)) & 0xf;
        if (fix_fetch) {
                /* The hardware returns an unsigned value; convert it to a
                 * signed one.
@@ -6583,7 +6583,7 @@ static void si_dump_shader_key(unsigned shader, struct si_shader_key *key,
                fprintf(f, "  part.vs.epilog.export_prim_id = %u\n", key->part.vs.epilog.export_prim_id);
                fprintf(f, "  as_es = %u\n", key->as_es);
                fprintf(f, "  as_ls = %u\n", key->as_ls);
-               fprintf(f, "  mono.vs.fix_fetch = 0x%x\n", key->mono.vs.fix_fetch);
+               fprintf(f, "  mono.vs.fix_fetch = 0x%"PRIx64"\n", key->mono.vs.fix_fetch);
                break;
 
        case PIPE_SHADER_TESS_CTRL:
index 1b5dec21e31a12c0a7ac31b61216099e639c9562..89f9628a1f6ba27f37df069675d23fc801f66cca 100644 (file)
@@ -425,8 +425,8 @@ struct si_shader_key {
        /* Flags for monolithic compilation only. */
        union {
                struct {
-                       /* One pair of bits for every input: SI_FIX_FETCH_* enums. */
-                       uint32_t        fix_fetch;
+                       /* One nibble for every input: SI_FIX_FETCH_* enums. */
+                       uint64_t        fix_fetch;
                } vs;
                struct {
                        uint64_t        inputs_to_copy; /* for fixed-func TCS */
index 6e7d8daceb03a520cbddd3ba07ecbf11a82806c5..fa78a56f73ee1573dcba3f2317179f8a6ab49e91 100644 (file)
@@ -3363,12 +3363,12 @@ static void *si_create_vertex_elements(struct pipe_context *ctx,
                 */
                if (data_format == V_008F0C_BUF_DATA_FORMAT_2_10_10_10) {
                        if (num_format == V_008F0C_BUF_NUM_FORMAT_SNORM) {
-                               v->fix_fetch |= SI_FIX_FETCH_A2_SNORM << (2 * i);
+                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_A2_SNORM << (4 * i);
                        } else if (num_format == V_008F0C_BUF_NUM_FORMAT_SSCALED) {
-                               v->fix_fetch |= SI_FIX_FETCH_A2_SSCALED << (2 * i);
+                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_A2_SSCALED << (4 * i);
                        } else if (num_format == V_008F0C_BUF_NUM_FORMAT_SINT) {
                                /* This isn't actually used in OpenGL. */
-                               v->fix_fetch |= SI_FIX_FETCH_A2_SINT << (2 * i);
+                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_A2_SINT << (4 * i);
                        }
                }
 
index a17dbc73102ab8d005c81be21342e5b32cb770e8..edc5b9337819ce9c596e32813dc4e22a175996dd 100644 (file)
@@ -99,12 +99,12 @@ struct si_stencil_ref {
 struct si_vertex_element
 {
        unsigned                        count;
-       uint32_t                        fix_fetch;
 
        /* Two bits per attribute indicating the size of each vector component
         * in bytes if the size 3-workaround must be applied.
         */
        uint32_t                        fix_size3;
+       uint64_t                        fix_fetch;
 
        uint32_t                        rsrc_word3[SI_MAX_ATTRIBS];
        uint32_t                        format_size[SI_MAX_ATTRIBS];
index 99678377c8d4e00edd1f93370a65f7be0484b3dd..d2f04bc8328929582aad7b75d1941c9572e84a7c 100644 (file)
@@ -934,7 +934,7 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
 
                        key->mono.vs.fix_fetch =
                                sctx->vertex_elements->fix_fetch &
-                               u_bit_consecutive(0, 2 * count);
+                               u_bit_consecutive64(0, 4 * count);
                }
                if (sctx->tes_shader.cso)
                        key->as_ls = 1;
index a5dfa1f9e3bf458a8dd4b4bee24b4f8bb38b7240..32e027165cc106044dad87950ecbfafdd20840ef 100644 (file)
@@ -226,6 +226,15 @@ u_bit_consecutive(unsigned start, unsigned count)
    return ((1u << count) - 1) << start;
 }
 
+static inline uint64_t
+u_bit_consecutive64(unsigned start, unsigned count)
+{
+   assert(start + count <= 64);
+   if (count == 64)
+      return ~(uint64_t)0;
+   return (((uint64_t)1 << count) - 1) << start;
+}
+
 
 #ifdef __cplusplus
 }