From: Charmaine Lee Date: Tue, 1 Sep 2015 22:29:17 +0000 (-0600) Subject: tgsi: add some more helper functions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=17756876378137003443f9eebb51002564b2ac2a;p=mesa.git tgsi: add some more helper functions This patch adds some more helper functions such as . tgsi_transform_temps_decl . tgsi_transform_output_decl . tgsi_transform_dst_reg . tgsi_transform_src_reg Reviewed-by: Brian Paul --- diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.h b/src/gallium/auxiliary/tgsi/tgsi_transform.h index 9b68f6a5feb..3bd512b6f3e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_transform.h +++ b/src/gallium/auxiliary/tgsi/tgsi_transform.h @@ -95,19 +95,38 @@ struct tgsi_transform_context * Helper for emitting temporary register declarations. */ static inline void -tgsi_transform_temp_decl(struct tgsi_transform_context *ctx, - unsigned index) +tgsi_transform_temps_decl(struct tgsi_transform_context *ctx, + unsigned firstIdx, unsigned lastIdx) { struct tgsi_full_declaration decl; decl = tgsi_default_full_declaration(); decl.Declaration.File = TGSI_FILE_TEMPORARY; - decl.Range.First = - decl.Range.Last = index; + decl.Range.First = firstIdx; + decl.Range.Last = lastIdx; ctx->emit_declaration(ctx, &decl); } +static inline void +tgsi_transform_temp_decl(struct tgsi_transform_context *ctx, + unsigned index) +{ + tgsi_transform_temps_decl(ctx, index, index); +} +static inline void +tgsi_transform_const_decl(struct tgsi_transform_context *ctx, + unsigned firstIdx, unsigned lastIdx) +{ + struct tgsi_full_declaration decl; + + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_CONSTANT; + decl.Range.First = firstIdx; + decl.Range.Last = lastIdx; + ctx->emit_declaration(ctx, &decl); +} + static inline void tgsi_transform_input_decl(struct tgsi_transform_context *ctx, unsigned index, @@ -129,6 +148,26 @@ tgsi_transform_input_decl(struct tgsi_transform_context *ctx, ctx->emit_declaration(ctx, &decl); } +static inline void +tgsi_transform_output_decl(struct tgsi_transform_context *ctx, + unsigned index, + unsigned sem_name, unsigned sem_index, + unsigned interp) +{ + struct tgsi_full_declaration decl; + + decl = tgsi_default_full_declaration(); + decl.Declaration.File = TGSI_FILE_OUTPUT; + decl.Declaration.Interpolate = 1; + decl.Declaration.Semantic = 1; + decl.Semantic.Name = sem_name; + decl.Semantic.Index = sem_index; + decl.Range.First = + decl.Range.Last = index; + decl.Interp.Interpolate = interp; + + ctx->emit_declaration(ctx, &decl); +} static inline void tgsi_transform_sampler_decl(struct tgsi_transform_context *ctx, @@ -182,6 +221,28 @@ tgsi_transform_immediate_decl(struct tgsi_transform_context *ctx, ctx->emit_immediate(ctx, &immed); } +static inline void +tgsi_transform_dst_reg(struct tgsi_full_dst_register *reg, + unsigned file, unsigned index, unsigned writemask) +{ + reg->Register.File = file; + reg->Register.Index = index; + reg->Register.WriteMask = writemask; +} + +static inline void +tgsi_transform_src_reg(struct tgsi_full_src_register *reg, + unsigned file, unsigned index, + unsigned swizzleX, unsigned swizzleY, + unsigned swizzleZ, unsigned swizzleW) +{ + reg->Register.File = file; + reg->Register.Index = index; + reg->Register.SwizzleX = swizzleX; + reg->Register.SwizzleY = swizzleY; + reg->Register.SwizzleZ = swizzleZ; + reg->Register.SwizzleW = swizzleW; +} /** * Helper for emitting 1-operand instructions.