--- src/gallium/drivers/svga/svga_tgsi_emit.h | 98 ++++++++++++++++------------- 1 file changed, 56 insertions(+), 42 deletions(-)
diff --git a/src/gallium/drivers/svga/svga_tgsi_emit.h b/src/gallium/drivers/svga/svga_tgsi_emit.h index 949c39d..e36a955 100644 --- a/src/gallium/drivers/svga/svga_tgsi_emit.h +++ b/src/gallium/drivers/svga/svga_tgsi_emit.h @@ -38,16 +38,18 @@ struct src_register }; -struct svga_arl_consts { +struct svga_arl_consts +{ int number; int idx; int swizzle; int arl_num; }; -/* Internal functions: - */ +/** + * This is the context/state used during TGSI->SVGA shader translation. + */ struct svga_shader_emitter { unsigned size; @@ -63,7 +65,7 @@ struct svga_shader_emitter int nr_hw_float_const; int nr_hw_int_const; int nr_hw_temp; - + int insn_offset; int internal_temp_count; @@ -129,28 +131,24 @@ struct svga_shader_emitter }; -boolean svga_shader_emit_dword( struct svga_shader_emitter *emit, - unsigned dword ); +boolean +svga_shader_emit_dword(struct svga_shader_emitter *emit, unsigned dword); -boolean svga_shader_emit_dwords( struct svga_shader_emitter *emit, - const unsigned *dwords, - unsigned nr ); +boolean +svga_shader_emit_dwords(struct svga_shader_emitter *emit, + const unsigned *dwords, unsigned nr); -boolean svga_shader_emit_opcode( struct svga_shader_emitter *emit, - unsigned opcode ); +boolean +svga_shader_emit_opcode(struct svga_shader_emitter *emit, + unsigned opcode); -boolean svga_shader_emit_instructions( struct svga_shader_emitter *emit, - const struct tgsi_token *tokens ); +boolean +svga_shader_emit_instructions(struct svga_shader_emitter *emit, + const struct tgsi_token *tokens); -boolean svga_translate_decl_sm30( struct svga_shader_emitter *emit, - const struct tgsi_full_declaration *decl ); - - -static INLINE boolean emit_instruction( struct svga_shader_emitter *emit, - SVGA3dShaderInstToken opcode ) -{ - return svga_shader_emit_opcode( emit, opcode.value ); -} +boolean +svga_translate_decl_sm30(struct svga_shader_emitter *emit, + const struct tgsi_full_declaration *decl); #define TRANSLATE_SWIZZLE(x,y,z,w) ((x) | ((y) << 2) | ((z) << 4) | ((w) << 6)) @@ -166,9 +164,18 @@ static INLINE boolean emit_instruction( struct svga_shader_emitter *emit, TRANSLATE_SWIZZLE(TGSI_SWIZZLE_W,TGSI_SWIZZLE_W,TGSI_SWIZZLE_W,TGSI_SWIZZLE_W) +/** Emit the given SVGA3dShaderInstToken opcode */ +static INLINE boolean +emit_instruction(struct svga_shader_emitter *emit, + SVGA3dShaderInstToken opcode) +{ + return svga_shader_emit_opcode(emit, opcode.value); +} + +/** Generate a SVGA3dShaderInstToken for the given SVGA3D shader opcode */ static INLINE SVGA3dShaderInstToken -inst_token( unsigned opcode ) +inst_token(unsigned opcode) { SVGA3dShaderInstToken inst; @@ -184,9 +191,8 @@ inst_token( unsigned opcode ) * Note that this function is used to create tokens for output registers, * temp registers AND constants (see emit_def_const()). */ -static INLINE SVGA3dShaderDestToken -dst_register( unsigned file, - int number ) +static INLINE SVGA3dShaderDestToken +dst_register(unsigned file, int number) { SVGA3dShaderDestToken dest; @@ -204,13 +210,17 @@ dst_register( unsigned file, dest.shfScale = 0; dest.type_lower = file & 0x7; dest.reserved0 = 1; /* is_reg */ - + return dest; } + +/** + * Apply a writemask to the given SVGA3dShaderDestToken, returning a + * new SVGA3dShaderDestToken. + */ static INLINE SVGA3dShaderDestToken -writemask( SVGA3dShaderDestToken dest, - unsigned mask ) +writemask(SVGA3dShaderDestToken dest, unsigned mask) { assert(dest.mask & mask); dest.mask &= mask; @@ -218,8 +228,9 @@ writemask( SVGA3dShaderDestToken dest, } -static INLINE SVGA3dShaderSrcToken -src_token( unsigned file, int number ) +/** Create a SVGA3dShaderSrcToken given a register file and number */ +static INLINE SVGA3dShaderSrcToken +src_token(unsigned file, int number) { SVGA3dShaderSrcToken src; @@ -241,28 +252,31 @@ src_token( unsigned file, int number ) } -static INLINE struct src_register -src_register( unsigned file, int number ) +/** Create a src_register given a register file and register number */ +static INLINE struct src_register +src_register(unsigned file, int number) { struct src_register src; - - src.base = src_token( file, number ); + + src.base = src_token(file, number); src.indirect.value = 0; return src; } -static INLINE SVGA3dShaderDestToken dst( struct src_register src ) +/** Translate src_register into SVGA3dShaderDestToken */ +static INLINE SVGA3dShaderDestToken +dst(struct src_register src) { - return dst_register( SVGA3dShaderGetRegType( src.base.value ), - src.base.num ); + return dst_register(SVGA3dShaderGetRegType(src.base.value), src.base.num); } -static INLINE struct src_register src( SVGA3dShaderDestToken dst ) + +/** Translate SVGA3dShaderDestToken to a src_register */ +static INLINE struct src_register +src(SVGA3dShaderDestToken dst) { - return src_register( SVGA3dShaderGetRegType( dst.value ), - dst.num ); + return src_register(SVGA3dShaderGetRegType(dst.value), dst.num); } - #endif -- 1.7.10.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev