radeonsi: make fix_fetch an array of uint8_t
authorMarek Olšák <marek.olsak@amd.com>
Wed, 15 Feb 2017 23:47:48 +0000 (00:47 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 18 Feb 2017 00:22:08 +0000 (01:22 +0100)
so that we can add 3-component fallbacks.

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

index cfff54a5e00c7e89abc81083047d133e20d67256..8b9fed9fb8c266e3d9221b32f410acc63dd36fa5 100644 (file)
@@ -366,7 +366,7 @@ static void declare_input_vs(
                                    ctx->param_vertex_index0 +
                                    input_index);
 
-       fix_fetch = (ctx->shader->key.mono.vs.fix_fetch >> (4 * input_index)) & 0xf;
+       fix_fetch = ctx->shader->key.mono.vs.fix_fetch[input_index];
 
        /* Do multiple loads for double formats. */
        if (fix_fetch == SI_FIX_FETCH_RGB_64_FLOAT) {
@@ -6270,7 +6270,11 @@ 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%"PRIx64"\n", key->mono.vs.fix_fetch);
+
+               fprintf(f, "  mono.vs.fix_fetch = {");
+               for (i = 0; i < SI_MAX_ATTRIBS; i++)
+                       fprintf(f, !i ? "%u" : ", %u", key->mono.vs.fix_fetch[i]);
+               fprintf(f, "}\n");
                break;
 
        case PIPE_SHADER_TESS_CTRL:
index 6398b39a0ecdbb9bb3bdb92eb0a81edba43f561e..46161907a679b0d6d71626d4b82551688ce91475 100644 (file)
@@ -250,7 +250,6 @@ enum {
        SI_FIX_FETCH_RG_64_FLOAT,
        SI_FIX_FETCH_RGB_64_FLOAT,
        SI_FIX_FETCH_RGBA_64_FLOAT,
-       SI_FIX_FETCH_RESERVED_15, /* maximum */
 };
 
 struct si_shader;
@@ -445,8 +444,8 @@ struct si_shader_key {
        /* Flags for monolithic compilation only. */
        union {
                struct {
-                       /* One nibble for every input: SI_FIX_FETCH_* enums. */
-                       uint64_t        fix_fetch;
+                       /* One byte for every input: SI_FIX_FETCH_* enums. */
+                       uint8_t         fix_fetch[SI_MAX_ATTRIBS];
                } vs;
                struct {
                        uint64_t        inputs_to_copy; /* for fixed-func TCS */
index 4ccca52d04fecce6d8503abf36f25bc3dd111b14..d9b9f83876397cbd9798a8c30a095bde01388e6c 100644 (file)
@@ -3399,36 +3399,36 @@ 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 |= (uint64_t)SI_FIX_FETCH_A2_SNORM << (4 * i);
+                               v->fix_fetch[i] = SI_FIX_FETCH_A2_SNORM;
                        } else if (num_format == V_008F0C_BUF_NUM_FORMAT_SSCALED) {
-                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_A2_SSCALED << (4 * i);
+                               v->fix_fetch[i] = SI_FIX_FETCH_A2_SSCALED;
                        } else if (num_format == V_008F0C_BUF_NUM_FORMAT_SINT) {
                                /* This isn't actually used in OpenGL. */
-                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_A2_SINT << (4 * i);
+                               v->fix_fetch[i] = SI_FIX_FETCH_A2_SINT;
                        }
                } else if (channel && channel->type == UTIL_FORMAT_TYPE_FIXED) {
                        if (desc->swizzle[3] == PIPE_SWIZZLE_1)
-                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGBX_32_FIXED << (4 * i);
+                               v->fix_fetch[i] = SI_FIX_FETCH_RGBX_32_FIXED;
                        else
-                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGBA_32_FIXED << (4 * i);
+                               v->fix_fetch[i] = SI_FIX_FETCH_RGBA_32_FIXED;
                } else if (channel && channel->size == 32 && !channel->pure_integer) {
                        if (channel->type == UTIL_FORMAT_TYPE_SIGNED) {
                                if (channel->normalized) {
                                        if (desc->swizzle[3] == PIPE_SWIZZLE_1)
-                                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGBX_32_SNORM << (4 * i);
+                                               v->fix_fetch[i] = SI_FIX_FETCH_RGBX_32_SNORM;
                                        else
-                                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGBA_32_SNORM << (4 * i);
+                                               v->fix_fetch[i] = SI_FIX_FETCH_RGBA_32_SNORM;
                                } else {
-                                       v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGBA_32_SSCALED << (4 * i);
+                                       v->fix_fetch[i] = SI_FIX_FETCH_RGBA_32_SSCALED;
                                }
                        } else if (channel->type == UTIL_FORMAT_TYPE_UNSIGNED) {
                                if (channel->normalized) {
                                        if (desc->swizzle[3] == PIPE_SWIZZLE_1)
-                                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGBX_32_UNORM << (4 * i);
+                                               v->fix_fetch[i] = SI_FIX_FETCH_RGBX_32_UNORM;
                                        else
-                                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGBA_32_UNORM << (4 * i);
+                                               v->fix_fetch[i] = SI_FIX_FETCH_RGBA_32_UNORM;
                                } else {
-                                       v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGBA_32_USCALED << (4 * i);
+                                       v->fix_fetch[i] = SI_FIX_FETCH_RGBA_32_USCALED;
                                }
                        }
                } else if (channel && channel->size == 64 &&
@@ -3436,21 +3436,21 @@ static void *si_create_vertex_elements(struct pipe_context *ctx,
                        switch (desc->nr_channels) {
                        case 1:
                        case 2:
-                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RG_64_FLOAT << (4 * i);
+                               v->fix_fetch[i] = SI_FIX_FETCH_RG_64_FLOAT;
                                swizzle[0] = PIPE_SWIZZLE_X;
                                swizzle[1] = PIPE_SWIZZLE_Y;
                                swizzle[2] = desc->nr_channels == 2 ? PIPE_SWIZZLE_Z : PIPE_SWIZZLE_0;
                                swizzle[3] = desc->nr_channels == 2 ? PIPE_SWIZZLE_W : PIPE_SWIZZLE_0;
                                break;
                        case 3:
-                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGB_64_FLOAT << (4 * i);
+                               v->fix_fetch[i] = SI_FIX_FETCH_RGB_64_FLOAT;
                                swizzle[0] = PIPE_SWIZZLE_X; /* 3 loads */
                                swizzle[1] = PIPE_SWIZZLE_Y;
                                swizzle[2] = PIPE_SWIZZLE_0;
                                swizzle[3] = PIPE_SWIZZLE_0;
                                break;
                        case 4:
-                               v->fix_fetch |= (uint64_t)SI_FIX_FETCH_RGBA_64_FLOAT << (4 * i);
+                               v->fix_fetch[i] = SI_FIX_FETCH_RGBA_64_FLOAT;
                                swizzle[0] = PIPE_SWIZZLE_X; /* 2 loads */
                                swizzle[1] = PIPE_SWIZZLE_Y;
                                swizzle[2] = PIPE_SWIZZLE_Z;
index 07b7d582752d4704e7862c6f439ba6d7e4a6a128..cd44ed1b2277d5738f9fa50bf331c075fb9d1800 100644 (file)
@@ -107,7 +107,7 @@ struct si_vertex_element
         * in bytes if the size 3-workaround must be applied.
         */
        uint32_t                        fix_size3;
-       uint64_t                        fix_fetch;
+       uint8_t                         fix_fetch[SI_MAX_ATTRIBS];
 
        uint32_t                        rsrc_word3[SI_MAX_ATTRIBS];
        uint32_t                        format_size[SI_MAX_ATTRIBS];
index bde02f520a85e4b249af779ff9d817291833a12f..9570259d8a84705f2e8b9d28d083c3ba2aaf037b 100644 (file)
@@ -975,9 +975,8 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
                                key->part.vs.prolog.instance_divisors[i] =
                                        sctx->vertex_elements->elements[i].instance_divisor;
 
-                       key->mono.vs.fix_fetch =
-                               sctx->vertex_elements->fix_fetch &
-                               u_bit_consecutive64(0, 4 * count);
+                       memcpy(key->mono.vs.fix_fetch,
+                              sctx->vertex_elements->fix_fetch, count);
                }
                if (sctx->tes_shader.cso)
                        key->as_ls = 1;