Mesa (master): radeonsi: make fix_fetch 64-bit

Marek Olšák mareko at kemper.freedesktop.org
Mon Jan 16 17:09:14 UTC 2017


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Jan  6 00:07:21 2017 +0100

radeonsi: make fix_fetch 64-bit

v2: add u_bit_consecutive64

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/gallium/drivers/radeonsi/si_shader.c        | 4 ++--
 src/gallium/drivers/radeonsi/si_shader.h        | 4 ++--
 src/gallium/drivers/radeonsi/si_state.c         | 6 +++---
 src/gallium/drivers/radeonsi/si_state.h         | 2 +-
 src/gallium/drivers/radeonsi/si_state_shaders.c | 2 +-
 src/util/bitscan.h                              | 9 +++++++++
 6 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index d45c0e8..ddb6ca1 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -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:
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index 1b5dec2..89f9628 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -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 */
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 6e7d8da..fa78a56 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -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);
 			}
 		}
 
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index a17dbc7..edc5b93 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -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];
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 9967837..d2f04bc 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -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;
diff --git a/src/util/bitscan.h b/src/util/bitscan.h
index a5dfa1f..32e0271 100644
--- a/src/util/bitscan.h
+++ b/src/util/bitscan.h
@@ -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
 }




More information about the mesa-commit mailing list