tgsi_ureg.h File Reference

Include dependency graph for tgsi_ureg.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ureg_src
struct  ureg_dst

Defines

#define OP00(op)
#define OP01(op)
#define OP00_LBL(op)
#define OP01_LBL(op)
#define OP10(op)
#define OP11(op)
#define OP12(op)
#define OP12_TEX(op)
#define OP13(op)
#define OP14_TEX(op)

Functions

struct ureg_programureg_create (unsigned processor)
struct tgsi_tokenureg_finalize (struct ureg_program *)
void * ureg_create_shader (struct ureg_program *, struct pipe_context *pipe)
void ureg_destroy (struct ureg_program *)
static void * ureg_create_shader_and_destroy (struct ureg_program *p, struct pipe_context *pipe)
struct ureg_src ureg_DECL_fs_input (struct ureg_program *, unsigned semantic_name, unsigned semantic_index, unsigned interp_mode)
struct ureg_src ureg_DECL_vs_input (struct ureg_program *, unsigned semantic_name, unsigned semantic_index)
struct ureg_dst ureg_DECL_output (struct ureg_program *, unsigned semantic_name, unsigned semantic_index)
struct ureg_src ureg_DECL_immediate (struct ureg_program *, const float *v, unsigned nr)
struct ureg_src ureg_DECL_constant (struct ureg_program *)
struct ureg_dst ureg_DECL_temporary (struct ureg_program *)
void ureg_release_temporary (struct ureg_program *ureg, struct ureg_dst tmp)
struct ureg_dst ureg_DECL_address (struct ureg_program *)
struct ureg_src ureg_DECL_sampler (struct ureg_program *, unsigned index)
static struct ureg_src ureg_imm4f (struct ureg_program *ureg, float a, float b, float c, float d)
static struct ureg_src ureg_imm3f (struct ureg_program *ureg, float a, float b, float c)
static struct ureg_src ureg_imm2f (struct ureg_program *ureg, float a, float b)
static struct ureg_src ureg_imm1f (struct ureg_program *ureg, float a)
unsigned ureg_get_instruction_number (struct ureg_program *ureg)
void ureg_fixup_label (struct ureg_program *ureg, unsigned label_token, unsigned instruction_number)
void ureg_insn (struct ureg_program *ureg, unsigned opcode, const struct ureg_dst *dst, unsigned nr_dst, const struct ureg_src *src, unsigned nr_src)
unsigned ureg_emit_insn (struct ureg_program *ureg, unsigned opcode, boolean saturate, unsigned num_dst, unsigned num_src)
void ureg_emit_label (struct ureg_program *ureg, unsigned insn_token, unsigned *label_token)
void ureg_emit_texture (struct ureg_program *ureg, unsigned insn_token, unsigned target)
void ureg_emit_dst (struct ureg_program *ureg, struct ureg_dst dst)
void ureg_emit_src (struct ureg_program *ureg, struct ureg_src src)
void ureg_fixup_insn_size (struct ureg_program *ureg, unsigned insn)
static struct ureg_src ureg_negate (struct ureg_src reg)
static struct ureg_src ureg_abs (struct ureg_src reg)
static struct ureg_src ureg_swizzle (struct ureg_src reg, int x, int y, int z, int w)
static struct ureg_src ureg_scalar (struct ureg_src reg, int x)
static struct ureg_dst ureg_writemask (struct ureg_dst reg, unsigned writemask)
static struct ureg_dst ureg_saturate (struct ureg_dst reg)
static struct ureg_dst ureg_dst_indirect (struct ureg_dst reg, struct ureg_src addr)
static struct ureg_src ureg_src_indirect (struct ureg_src reg, struct ureg_src addr)
static struct ureg_dst ureg_dst (struct ureg_src src)
static struct ureg_src ureg_src (struct ureg_dst dst)
static struct ureg_dst ureg_dst_undef (void)
static struct ureg_src ureg_src_undef (void)
static boolean ureg_src_is_undef (struct ureg_src src)
static boolean ureg_dst_is_undef (struct ureg_dst dst)


Define Documentation

#define OP00 ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg )       \
{                                                               \
   unsigned opcode = TGSI_OPCODE_##op;                          \
   unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 0 ); \
   ureg_fixup_insn_size( ureg, insn );                          \
}

Definition at line 271 of file tgsi_ureg.h.

#define OP00_LBL ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg,        \
                              unsigned *label_token )           \
{                                                               \
   unsigned opcode = TGSI_OPCODE_##op;                          \
   unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 0 ); \
   ureg_emit_label( ureg, insn, label_token );                  \
   ureg_fixup_insn_size( ureg, insn );                          \
}

Definition at line 289 of file tgsi_ureg.h.

#define OP01 ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg,        \
                              struct ureg_src src )             \
{                                                               \
   unsigned opcode = TGSI_OPCODE_##op;                          \
   unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 1 ); \
   ureg_emit_src( ureg, src );                                  \
   ureg_fixup_insn_size( ureg, insn );                          \
}

Definition at line 279 of file tgsi_ureg.h.

#define OP01_LBL ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg,        \
                              struct ureg_src src,              \
                              unsigned *label_token )          \
{                                                               \
   unsigned opcode = TGSI_OPCODE_##op;                          \
   unsigned insn = ureg_emit_insn( ureg, opcode, FALSE, 0, 1 ); \
   ureg_emit_label( ureg, insn, label_token );                  \
   ureg_emit_src( ureg, src );                                  \
   ureg_fixup_insn_size( ureg, insn );                          \
}

Definition at line 299 of file tgsi_ureg.h.

#define OP10 ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg,                \
                              struct ureg_dst dst )                     \
{                                                                       \
   unsigned opcode = TGSI_OPCODE_##op;                                  \
   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 0 );  \
   ureg_emit_dst( ureg, dst );                                          \
   ureg_fixup_insn_size( ureg, insn );                                  \
}

Definition at line 311 of file tgsi_ureg.h.

#define OP11 ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg,                \
                              struct ureg_dst dst,                      \
                              struct ureg_src src )                     \
{                                                                       \
   unsigned opcode = TGSI_OPCODE_##op;                                  \
   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 1 );  \
   ureg_emit_dst( ureg, dst );                                          \
   ureg_emit_src( ureg, src );                                          \
   ureg_fixup_insn_size( ureg, insn );                                  \
}

Definition at line 322 of file tgsi_ureg.h.

#define OP12 ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg,                \
                              struct ureg_dst dst,                      \
                              struct ureg_src src0,                     \
                              struct ureg_src src1 )                    \
{                                                                       \
   unsigned opcode = TGSI_OPCODE_##op;                                  \
   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 2 );  \
   ureg_emit_dst( ureg, dst );                                          \
   ureg_emit_src( ureg, src0 );                                         \
   ureg_emit_src( ureg, src1 );                                         \
   ureg_fixup_insn_size( ureg, insn );                                  \
}

Definition at line 334 of file tgsi_ureg.h.

#define OP12_TEX ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg,                \
                              struct ureg_dst dst,                      \
                              unsigned target,                          \
                              struct ureg_src src0,                     \
                              struct ureg_src src1 )                    \
{                                                                       \
   unsigned opcode = TGSI_OPCODE_##op;                                  \
   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 2 );  \
   ureg_emit_texture( ureg, insn, target );                             \
   ureg_emit_dst( ureg, dst );                                          \
   ureg_emit_src( ureg, src0 );                                         \
   ureg_emit_src( ureg, src1 );                                         \
   ureg_fixup_insn_size( ureg, insn );                                  \
}

Definition at line 348 of file tgsi_ureg.h.

#define OP13 ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg,                \
                              struct ureg_dst dst,                      \
                              struct ureg_src src0,                     \
                              struct ureg_src src1,                     \
                              struct ureg_src src2 )                    \
{                                                                       \
   unsigned opcode = TGSI_OPCODE_##op;                                  \
   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 3 );  \
   ureg_emit_dst( ureg, dst );                                          \
   ureg_emit_src( ureg, src0 );                                         \
   ureg_emit_src( ureg, src1 );                                         \
   ureg_emit_src( ureg, src2 );                                         \
   ureg_fixup_insn_size( ureg, insn );                                  \
}

Definition at line 364 of file tgsi_ureg.h.

#define OP14_TEX ( op   ) 

Value:

static INLINE void ureg_##op( struct ureg_program *ureg,                \
                              struct ureg_dst dst,                      \
                              unsigned target,                          \
                              struct ureg_src src0,                     \
                              struct ureg_src src1,                     \
                              struct ureg_src src2,                     \
                              struct ureg_src src3 )                    \
{                                                                       \
   unsigned opcode = TGSI_OPCODE_##op;                                  \
   unsigned insn = ureg_emit_insn( ureg, opcode, dst.Saturate, 1, 4 );  \
   ureg_emit_texture( ureg, insn, target );                             \
   ureg_emit_dst( ureg, dst );                                          \
   ureg_emit_src( ureg, src0 );                                         \
   ureg_emit_src( ureg, src1 );                                         \
   ureg_emit_src( ureg, src2 );                                         \
   ureg_emit_src( ureg, src3 );                                         \
   ureg_fixup_insn_size( ureg, insn );                                  \
}

Definition at line 380 of file tgsi_ureg.h.


Function Documentation

static struct ureg_src ureg_abs ( struct ureg_src  reg  )  [static, read]

Definition at line 419 of file tgsi_ureg.h.

References assert, and TGSI_FILE_NULL.

00420 {
00421    assert(reg.File != TGSI_FILE_NULL);
00422    reg.Absolute = 1;
00423    reg.Negate = 0;
00424    return reg;
00425 }

struct ureg_program* ureg_create ( unsigned  processor  )  [read]

Definition at line 916 of file tgsi_ureg.c.

References CALLOC_STRUCT, and ureg_program::processor.

00917 {
00918    struct ureg_program *ureg = CALLOC_STRUCT( ureg_program );
00919    if (ureg == NULL)
00920       return NULL;
00921 
00922    ureg->processor = processor;
00923    return ureg;
00924 }

void* ureg_create_shader ( struct ureg_program ,
struct pipe_context pipe 
)

Definition at line 898 of file tgsi_ureg.c.

References pipe_context::create_fs_state, pipe_context::create_vs_state, ureg_program::processor, TGSI_PROCESSOR_VERTEX, pipe_shader_state::tokens, and ureg_finalize().

00900 {
00901    struct pipe_shader_state state;
00902 
00903    state.tokens = ureg_finalize(ureg);
00904    if(!state.tokens)
00905       return NULL;
00906 
00907    if (ureg->processor == TGSI_PROCESSOR_VERTEX)
00908       return pipe->create_vs_state( pipe, &state );
00909    else
00910       return pipe->create_fs_state( pipe, &state );
00911 }

static void* ureg_create_shader_and_destroy ( struct ureg_program p,
struct pipe_context pipe 
) [static]

Definition at line 98 of file tgsi_ureg.h.

References ureg_create_shader(), and ureg_destroy().

00100 {
00101    void *result = ureg_create_shader( p, pipe );
00102    ureg_destroy( p );
00103    return result;
00104 }

struct ureg_dst ureg_DECL_address ( struct ureg_program  )  [read]

Definition at line 363 of file tgsi_ureg.c.

References assert, TGSI_FILE_ADDRESS, ureg_dst_register(), and UREG_MAX_ADDR.

00364 {
00365    if (ureg->nr_addrs < UREG_MAX_ADDR)
00366       return ureg_dst_register( TGSI_FILE_ADDRESS, ureg->nr_addrs++ );
00367 
00368    assert( 0 );
00369    return ureg_dst_register( TGSI_FILE_ADDRESS, 0 );
00370 }

struct ureg_src ureg_DECL_constant ( struct ureg_program  )  [read]

Definition at line 316 of file tgsi_ureg.c.

References TGSI_FILE_CONSTANT, and ureg_src_register().

00317 {
00318    return ureg_src_register( TGSI_FILE_CONSTANT, ureg->nr_constants++ );
00319 }

struct ureg_src ureg_DECL_fs_input ( struct ureg_program ,
unsigned  semantic_name,
unsigned  semantic_index,
unsigned  interp_mode 
) [read]

Definition at line 262 of file tgsi_ureg.c.

References assert, interp(), TGSI_PROCESSOR_FRAGMENT, and ureg_DECL_input().

00266 {
00267    assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT);
00268    return ureg_DECL_input( ureg, name, index, interp );
00269 }

struct ureg_src ureg_DECL_immediate ( struct ureg_program ,
const float *  v,
unsigned  nr 
) [read]

Definition at line 432 of file tgsi_ureg.c.

References match_or_expand_immediate(), set_bad(), swizzle(), TGSI_FILE_IMMEDIATE, UREG_MAX_IMMEDIATE, ureg_src_register(), and ureg_swizzle().

00435 {
00436    unsigned i, j;
00437    unsigned swizzle;
00438 
00439    /* Could do a first pass where we examine all existing immediates
00440     * without expanding.
00441     */
00442 
00443    for (i = 0; i < ureg->nr_immediates; i++) {
00444       if (match_or_expand_immediate( v, 
00445                                      nr,
00446                                      ureg->immediate[i].v,
00447                                      &ureg->immediate[i].nr, 
00448                                      &swizzle ))
00449          goto out;
00450    }
00451 
00452    if (ureg->nr_immediates < UREG_MAX_IMMEDIATE) {
00453       i = ureg->nr_immediates++;
00454       if (match_or_expand_immediate( v,
00455                                      nr,
00456                                      ureg->immediate[i].v,
00457                                      &ureg->immediate[i].nr, 
00458                                      &swizzle ))
00459          goto out;
00460    }
00461 
00462    set_bad( ureg );
00463 
00464 out:
00465    /* Make sure that all referenced elements are from this immediate.
00466     * Has the effect of making size-one immediates into scalars.
00467     */
00468    for (j = nr; j < 4; j++)
00469       swizzle |= (swizzle & 0x3) << (j * 2);
00470 
00471    return ureg_swizzle( ureg_src_register( TGSI_FILE_IMMEDIATE, i ),
00472                         (swizzle >> 0) & 0x3,
00473                         (swizzle >> 2) & 0x3,
00474                         (swizzle >> 4) & 0x3,
00475                         (swizzle >> 6) & 0x3);
00476 }

struct ureg_dst ureg_DECL_output ( struct ureg_program ,
unsigned  semantic_name,
unsigned  semantic_index 
) [read]

Definition at line 283 of file tgsi_ureg.c.

References set_bad(), TGSI_FILE_OUTPUT, ureg_dst_register(), and UREG_MAX_OUTPUT.

00286 {
00287    unsigned i;
00288 
00289    for (i = 0; i < ureg->nr_outputs; i++) {
00290       if (ureg->output[i].semantic_name == name &&
00291           ureg->output[i].semantic_index == index) 
00292          goto out;
00293    }
00294 
00295    if (ureg->nr_outputs < UREG_MAX_OUTPUT) {
00296       ureg->output[i].semantic_name = name;
00297       ureg->output[i].semantic_index = index;
00298       ureg->nr_outputs++;
00299    }
00300    else {
00301       set_bad( ureg );
00302    }
00303 
00304 out:
00305    return ureg_dst_register( TGSI_FILE_OUTPUT, i );
00306 }

struct ureg_src ureg_DECL_sampler ( struct ureg_program ,
unsigned  index 
) [read]

Definition at line 374 of file tgsi_ureg.c.

References assert, ureg_src::Index, PIPE_MAX_SAMPLERS, TGSI_FILE_SAMPLER, and ureg_src_register().

00376 {
00377    unsigned i;
00378 
00379    for (i = 0; i < ureg->nr_samplers; i++)
00380       if (ureg->sampler[i].Index == nr)
00381          return ureg->sampler[i];
00382    
00383    if (i < PIPE_MAX_SAMPLERS) {
00384       ureg->sampler[i] = ureg_src_register( TGSI_FILE_SAMPLER, nr );
00385       ureg->nr_samplers++;
00386       return ureg->sampler[i];
00387    }
00388 
00389    assert( 0 );
00390    return ureg->sampler[0];
00391 }

struct ureg_dst ureg_DECL_temporary ( struct ureg_program  )  [read]

Definition at line 325 of file tgsi_ureg.c.

References TGSI_FILE_TEMPORARY, ureg_dst_register(), and UREG_MAX_TEMP.

00326 {
00327    unsigned i;
00328 
00329    for (i = 0; i < UREG_MAX_TEMP; i += 32) {
00330       int bit = ffs(~ureg->temps_active[i/32]);
00331       if (bit != 0) {
00332          i += bit - 1;
00333          goto out;
00334       }
00335    }
00336 
00337    /* No reusable temps, so allocate a new one:
00338     */
00339    i = ureg->nr_temps++;
00340 
00341 out:
00342    if (i < UREG_MAX_TEMP)
00343       ureg->temps_active[i/32] |= 1 << (i % 32);
00344 
00345    if (i >= ureg->nr_temps)
00346       ureg->nr_temps = i + 1;
00347 
00348    return ureg_dst_register( TGSI_FILE_TEMPORARY, i );
00349 }

struct ureg_src ureg_DECL_vs_input ( struct ureg_program ,
unsigned  semantic_name,
unsigned  semantic_index 
) [read]

Definition at line 273 of file tgsi_ureg.c.

References assert, TGSI_INTERPOLATE_CONSTANT, TGSI_PROCESSOR_VERTEX, and ureg_DECL_input().

00276 {
00277    assert(ureg->processor == TGSI_PROCESSOR_VERTEX);
00278    return ureg_DECL_input( ureg, name, index, TGSI_INTERPOLATE_CONSTANT );
00279 }

void ureg_destroy ( struct ureg_program  ) 

Definition at line 927 of file tgsi_ureg.c.

References ureg_program::domain, Elements, error_tokens, FREE, and ureg_tokens::tokens.

00928 {
00929    unsigned i;
00930 
00931    for (i = 0; i < Elements(ureg->domain); i++) {
00932       if (ureg->domain[i].tokens && 
00933           ureg->domain[i].tokens != error_tokens)
00934          FREE(ureg->domain[i].tokens);
00935    }
00936    
00937    FREE(ureg);
00938 }

static struct ureg_dst ureg_dst ( struct ureg_src  src  )  [static, read]

Definition at line 495 of file tgsi_ureg.h.

References ureg_dst::File, ureg_dst::Index, ureg_dst::Indirect, ureg_dst::IndirectIndex, ureg_dst::IndirectSwizzle, ureg_dst::Pad1, ureg_dst::Pad2, ureg_dst::Saturate, TGSI_WRITEMASK_XYZW, and ureg_dst::WriteMask.

00496 {
00497    struct ureg_dst dst;
00498 
00499    dst.File      = src.File;
00500    dst.WriteMask = TGSI_WRITEMASK_XYZW;
00501    dst.Indirect  = src.Indirect;
00502    dst.IndirectIndex = src.IndirectIndex;
00503    dst.IndirectSwizzle = src.IndirectSwizzle;
00504    dst.Saturate  = 0;
00505    dst.Index     = src.Index;
00506    dst.Pad1      = 0;
00507    dst.Pad2      = 0;
00508 
00509    return dst;
00510 }

static struct ureg_dst ureg_dst_indirect ( struct ureg_dst  reg,
struct ureg_src  addr 
) [static, read]

Definition at line 473 of file tgsi_ureg.h.

References assert, TGSI_FILE_ADDRESS, and TGSI_FILE_NULL.

00474 {
00475    assert(reg.File != TGSI_FILE_NULL);
00476    assert(addr.File == TGSI_FILE_ADDRESS);
00477    reg.Indirect = 1;
00478    reg.IndirectIndex = addr.Index;
00479    reg.IndirectSwizzle = addr.SwizzleX;
00480    return reg;
00481 }

static boolean ureg_dst_is_undef ( struct ureg_dst  dst  )  [static]

Definition at line 581 of file tgsi_ureg.h.

References ureg_dst::File, and TGSI_FILE_NULL.

00582 {
00583    return dst.File == TGSI_FILE_NULL;
00584 }

static struct ureg_dst ureg_dst_undef ( void   )  [static, read]

Definition at line 536 of file tgsi_ureg.h.

References ureg_dst::File, ureg_dst::Index, ureg_dst::Indirect, ureg_dst::IndirectIndex, ureg_dst::IndirectSwizzle, ureg_dst::Pad1, ureg_dst::Pad2, ureg_dst::Saturate, TGSI_FILE_NULL, and ureg_dst::WriteMask.

00537 {
00538    struct ureg_dst dst;
00539 
00540    dst.File      = TGSI_FILE_NULL;
00541    dst.WriteMask = 0;
00542    dst.Indirect  = 0;
00543    dst.IndirectIndex = 0;
00544    dst.IndirectSwizzle = 0;
00545    dst.Saturate  = 0;
00546    dst.Index     = 0;
00547    dst.Pad1      = 0;
00548    dst.Pad2      = 0;
00549 
00550    return dst;
00551 }

void ureg_emit_dst ( struct ureg_program ureg,
struct ureg_dst  dst 
)

Definition at line 531 of file tgsi_ureg.c.

References assert, DOMAIN_INSN, tgsi_any_token::dst, tgsi_src_register::File, tgsi_dst_register::File, ureg_dst::File, get_tokens(), tgsi_src_register::Index, ureg_dst::Index, tgsi_dst_register::Index, tgsi_dst_register::Indirect, ureg_dst::Indirect, ureg_dst::IndirectIndex, ureg_dst::IndirectSwizzle, tgsi_any_token::src, tgsi_src_register::SwizzleW, tgsi_src_register::SwizzleX, tgsi_src_register::SwizzleY, tgsi_src_register::SwizzleZ, TGSI_FILE_ADDRESS, TGSI_FILE_CONSTANT, TGSI_FILE_COUNT, TGSI_FILE_IMMEDIATE, TGSI_FILE_INPUT, TGSI_FILE_NULL, TGSI_FILE_SAMPLER, tgsi_any_token::value, ureg_dst::WriteMask, and tgsi_dst_register::WriteMask.

00533 {
00534    unsigned size = (1 + 
00535                     (dst.Indirect ? 1 : 0));
00536 
00537    union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
00538    unsigned n = 0;
00539 
00540    assert(dst.File != TGSI_FILE_NULL);
00541    assert(dst.File != TGSI_FILE_CONSTANT);
00542    assert(dst.File != TGSI_FILE_INPUT);
00543    assert(dst.File != TGSI_FILE_SAMPLER);
00544    assert(dst.File != TGSI_FILE_IMMEDIATE);
00545    assert(dst.File < TGSI_FILE_COUNT);
00546    
00547    out[n].value = 0;
00548    out[n].dst.File = dst.File;
00549    out[n].dst.WriteMask = dst.WriteMask;
00550    out[n].dst.Indirect = dst.Indirect;
00551    out[n].dst.Index = dst.Index;
00552    n++;
00553    
00554    if (dst.Indirect) {
00555       out[n].value = 0;
00556       out[n].src.File = TGSI_FILE_ADDRESS;
00557       out[n].src.SwizzleX = dst.IndirectSwizzle;
00558       out[n].src.SwizzleY = dst.IndirectSwizzle;
00559       out[n].src.SwizzleZ = dst.IndirectSwizzle;
00560       out[n].src.SwizzleW = dst.IndirectSwizzle;
00561       out[n].src.Index = dst.IndirectIndex;
00562       n++;
00563    }
00564 
00565    assert(n == size);
00566 }

unsigned ureg_emit_insn ( struct ureg_program ureg,
unsigned  opcode,
boolean  saturate,
unsigned  num_dst,
unsigned  num_src 
)

Definition at line 571 of file tgsi_ureg.c.

References ureg_tokens::count, ureg_program::domain, DOMAIN_INSN, tgsi_instruction::Extended, get_tokens(), tgsi_any_token::insn, ureg_program::nr_instructions, tgsi_instruction::NumDstRegs, tgsi_instruction::NumSrcRegs, tgsi_instruction::Opcode, tgsi_instruction::Padding, tgsi_instruction::Saturate, tgsi_instruction::Size, TGSI_TOKEN_TYPE_INSTRUCTION, tgsi_instruction::Type, and tgsi_any_token::value.

00576 {
00577    union tgsi_any_token *out;
00578 
00579    out = get_tokens( ureg, DOMAIN_INSN, 1 );
00580    out[0].value = 0;
00581    out[0].insn.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
00582    out[0].insn.Size = 0;
00583    out[0].insn.Opcode = opcode;
00584    out[0].insn.Saturate = saturate;
00585    out[0].insn.NumDstRegs = num_dst;
00586    out[0].insn.NumSrcRegs = num_src;
00587    out[0].insn.Padding = 0;
00588    out[0].insn.Extended = 0;
00589    
00590    ureg->nr_instructions++;
00591    
00592    return ureg->domain[DOMAIN_INSN].count - 1;
00593 }

void ureg_emit_label ( struct ureg_program ureg,
unsigned  insn_token,
unsigned *  label_token 
)

Definition at line 597 of file tgsi_ureg.c.

References ureg_tokens::count, ureg_program::domain, DOMAIN_INSN, tgsi_instruction::Extended, get_tokens(), tgsi_any_token::insn, tgsi_any_token::insn_ext_label, retrieve_token(), TGSI_INSTRUCTION_EXT_TYPE_LABEL, tgsi_instruction_ext_label::Type, and tgsi_any_token::value.

00600 {
00601    union tgsi_any_token *out, *insn;
00602 
00603    if(!label_token)
00604       return;
00605 
00606    out = get_tokens( ureg, DOMAIN_INSN, 1 );
00607    insn = retrieve_token( ureg, DOMAIN_INSN, insn_token );
00608 
00609    insn->insn.Extended = 1;
00610 
00611    out[0].value = 0;
00612    out[0].insn_ext_label.Type = TGSI_INSTRUCTION_EXT_TYPE_LABEL;
00613    
00614    *label_token = ureg->domain[DOMAIN_INSN].count - 1;
00615 }

void ureg_emit_src ( struct ureg_program ureg,
struct ureg_src  src 
)

Definition at line 480 of file tgsi_ureg.c.

References tgsi_src_register_ext_mod::Absolute, ureg_src::Absolute, assert, DOMAIN_INSN, tgsi_src_register::Extended, tgsi_src_register::File, ureg_src::File, get_tokens(), ureg_src::Index, tgsi_src_register::Index, tgsi_src_register::Indirect, ureg_src::Indirect, ureg_src::IndirectIndex, ureg_src::IndirectSwizzle, tgsi_src_register_ext_mod::Negate, ureg_src::Negate, tgsi_src_register::Negate, tgsi_any_token::src, tgsi_any_token::src_ext_mod, ureg_src::SwizzleW, tgsi_src_register::SwizzleW, ureg_src::SwizzleX, tgsi_src_register::SwizzleX, ureg_src::SwizzleY, tgsi_src_register::SwizzleY, ureg_src::SwizzleZ, tgsi_src_register::SwizzleZ, TGSI_FILE_ADDRESS, TGSI_FILE_COUNT, TGSI_FILE_NULL, TGSI_FILE_OUTPUT, TGSI_SRC_REGISTER_EXT_TYPE_MOD, tgsi_src_register_ext_mod::Type, and tgsi_any_token::value.

00482 {
00483    unsigned size = (1 + 
00484                     (src.Absolute ? 1 : 0) +
00485                     (src.Indirect ? 1 : 0));
00486 
00487    union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
00488    unsigned n = 0;
00489 
00490    assert(src.File != TGSI_FILE_NULL);
00491    assert(src.File != TGSI_FILE_OUTPUT);
00492    assert(src.File < TGSI_FILE_COUNT);
00493    
00494    out[n].value = 0;
00495    out[n].src.File = src.File;
00496    out[n].src.SwizzleX = src.SwizzleX;
00497    out[n].src.SwizzleY = src.SwizzleY;
00498    out[n].src.SwizzleZ = src.SwizzleZ;
00499    out[n].src.SwizzleW = src.SwizzleW;
00500    out[n].src.Index = src.Index;
00501    out[n].src.Negate = src.Negate;
00502    n++;
00503    
00504    if (src.Absolute) {
00505       out[0].src.Extended = 1;
00506       out[0].src.Negate = 0;
00507       out[n].value = 0;
00508       out[n].src_ext_mod.Type = TGSI_SRC_REGISTER_EXT_TYPE_MOD;
00509       out[n].src_ext_mod.Absolute = 1;
00510       out[n].src_ext_mod.Negate = src.Negate;
00511       n++;
00512    }
00513 
00514    if (src.Indirect) {
00515       out[0].src.Indirect = 1;
00516       out[n].value = 0;
00517       out[n].src.File = TGSI_FILE_ADDRESS;
00518       out[n].src.SwizzleX = src.IndirectSwizzle;
00519       out[n].src.SwizzleY = src.IndirectSwizzle;
00520       out[n].src.SwizzleZ = src.IndirectSwizzle;
00521       out[n].src.SwizzleW = src.IndirectSwizzle;
00522       out[n].src.Index = src.IndirectIndex;
00523       n++;
00524    }
00525 
00526    assert(n == size);
00527 }

void ureg_emit_texture ( struct ureg_program ureg,
unsigned  insn_token,
unsigned  target 
)

Definition at line 642 of file tgsi_ureg.c.

References DOMAIN_INSN, tgsi_instruction::Extended, get_tokens(), tgsi_any_token::insn, tgsi_any_token::insn_ext_texture, retrieve_token(), tgsi_instruction_ext_texture::Texture, TGSI_INSTRUCTION_EXT_TYPE_TEXTURE, tgsi_instruction_ext_texture::Type, and tgsi_any_token::value.

00645 {
00646    union tgsi_any_token *out, *insn;
00647 
00648    out = get_tokens( ureg, DOMAIN_INSN, 1 );
00649    insn = retrieve_token( ureg, DOMAIN_INSN, insn_token );
00650 
00651    insn->insn.Extended = 1;
00652 
00653    out[0].value = 0;
00654    out[0].insn_ext_texture.Type = TGSI_INSTRUCTION_EXT_TYPE_TEXTURE;
00655    out[0].insn_ext_texture.Texture = target;
00656 }

struct tgsi_token* ureg_finalize ( struct ureg_program  )  [read]

Definition at line 870 of file tgsi_ureg.c.

References assert, copy_instructions(), ureg_tokens::count, debug_printf(), ureg_program::domain, DOMAIN_DECL, emit_decls(), emit_header(), error_tokens, fixup_header_size(), tgsi_dump(), tgsi_any_token::token, and ureg_tokens::tokens.

00871 {
00872    const struct tgsi_token *tokens;
00873 
00874    emit_header( ureg );
00875    emit_decls( ureg );
00876    copy_instructions( ureg );
00877    fixup_header_size( ureg );
00878    
00879    if (ureg->domain[0].tokens == error_tokens ||
00880        ureg->domain[1].tokens == error_tokens) {
00881       debug_printf("%s: error in generated shader\n", __FUNCTION__);
00882       assert(0);
00883       return NULL;
00884    }
00885 
00886    tokens = &ureg->domain[DOMAIN_DECL].tokens[0].token;
00887 
00888    if (0) {
00889       debug_printf("%s: emitted shader %d tokens:\n", __FUNCTION__, 
00890                    ureg->domain[DOMAIN_DECL].count);
00891       tgsi_dump( tokens, 0 );
00892    }
00893    
00894    return tokens;
00895 }

void ureg_fixup_insn_size ( struct ureg_program ureg,
unsigned  insn 
)

Definition at line 660 of file tgsi_ureg.c.

References assert, ureg_tokens::count, ureg_program::domain, DOMAIN_INSN, tgsi_any_token::insn, retrieve_token(), tgsi_instruction::Size, TGSI_TOKEN_TYPE_INSTRUCTION, and tgsi_instruction::Type.

00662 {
00663    union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_INSN, insn );
00664 
00665    assert(out->insn.Type == TGSI_TOKEN_TYPE_INSTRUCTION);
00666    out->insn.Size = ureg->domain[DOMAIN_INSN].count - insn - 1;
00667 }

void ureg_fixup_label ( struct ureg_program ureg,
unsigned  label_token,
unsigned  instruction_number 
)

Definition at line 630 of file tgsi_ureg.c.

References assert, DOMAIN_INSN, tgsi_any_token::insn_ext_label, tgsi_instruction_ext_label::Label, retrieve_token(), TGSI_INSTRUCTION_EXT_TYPE_LABEL, and tgsi_instruction_ext_label::Type.

00633 {
00634    union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_INSN, label_token );
00635 
00636    assert(out->insn_ext_label.Type == TGSI_INSTRUCTION_EXT_TYPE_LABEL);
00637    out->insn_ext_label.Label = instruction_number;
00638 }

unsigned ureg_get_instruction_number ( struct ureg_program ureg  ) 

Definition at line 621 of file tgsi_ureg.c.

References ureg_program::nr_instructions.

00622 {
00623    return ureg->nr_instructions;
00624 }

static struct ureg_src ureg_imm1f ( struct ureg_program ureg,
float  a 
) [static, read]

Definition at line 192 of file tgsi_ureg.h.

References ureg_DECL_immediate().

00194 {
00195    float v[1];
00196    v[0] = a;
00197    return ureg_DECL_immediate( ureg, v, 1 );
00198 }

static struct ureg_src ureg_imm2f ( struct ureg_program ureg,
float  a,
float  b 
) [static, read]

Definition at line 182 of file tgsi_ureg.h.

References ureg_DECL_immediate().

00184 {
00185    float v[2];
00186    v[0] = a;
00187    v[1] = b;
00188    return ureg_DECL_immediate( ureg, v, 2 );
00189 }

static struct ureg_src ureg_imm3f ( struct ureg_program ureg,
float  a,
float  b,
float  c 
) [static, read]

Definition at line 170 of file tgsi_ureg.h.

References ureg_DECL_immediate().

00173 {
00174    float v[3];
00175    v[0] = a;
00176    v[1] = b;
00177    v[2] = c;
00178    return ureg_DECL_immediate( ureg, v, 3 );
00179 }

static struct ureg_src ureg_imm4f ( struct ureg_program ureg,
float  a,
float  b,
float  c,
float  d 
) [static, read]

Definition at line 157 of file tgsi_ureg.h.

References ureg_DECL_immediate().

00160 {
00161    float v[4];
00162    v[0] = a;
00163    v[1] = b;
00164    v[2] = c;
00165    v[3] = d;
00166    return ureg_DECL_immediate( ureg, v, 4 );
00167 }

void ureg_insn ( struct ureg_program ureg,
unsigned  opcode,
const struct ureg_dst dst,
unsigned  nr_dst,
const struct ureg_src src,
unsigned  nr_src 
)

Definition at line 671 of file tgsi_ureg.c.

References assert, FALSE, tgsi_any_token::insn, tgsi_opcode_info::num_dst, tgsi_opcode_info::num_src, ureg_dst::Saturate, tgsi_get_opcode_info(), ureg_emit_dst(), ureg_emit_insn(), ureg_emit_src(), and ureg_fixup_insn_size().

00677 {
00678    unsigned insn, i;
00679    boolean saturate;
00680 
00681 #ifdef DEBUG
00682    {
00683       const struct tgsi_opcode_info *info = tgsi_get_opcode_info( opcode );
00684       assert(info);
00685       if(info) {
00686          assert(nr_dst == info->num_dst);
00687          assert(nr_src == info->num_src);
00688       }
00689    }
00690 #endif
00691    
00692    saturate = nr_dst ? dst[0].Saturate : FALSE;
00693 
00694    insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src );
00695 
00696    for (i = 0; i < nr_dst; i++)
00697       ureg_emit_dst( ureg, dst[i] );
00698 
00699    for (i = 0; i < nr_src; i++)
00700       ureg_emit_src( ureg, src[i] );
00701 
00702    ureg_fixup_insn_size( ureg, insn );
00703 }

static struct ureg_src ureg_negate ( struct ureg_src  reg  )  [static, read]

Definition at line 411 of file tgsi_ureg.h.

References assert, and TGSI_FILE_NULL.

00412 {
00413    assert(reg.File != TGSI_FILE_NULL);
00414    reg.Negate ^= 1;
00415    return reg;
00416 }

void ureg_release_temporary ( struct ureg_program ureg,
struct ureg_dst  tmp 
)

Definition at line 352 of file tgsi_ureg.c.

References ureg_dst::File, ureg_dst::Index, ureg_program::temps_active, TGSI_FILE_TEMPORARY, and UREG_MAX_TEMP.

00354 {
00355    if(tmp.File == TGSI_FILE_TEMPORARY)
00356       if (tmp.Index < UREG_MAX_TEMP)
00357          ureg->temps_active[tmp.Index/32] &= ~(1 << (tmp.Index % 32));
00358 }

static struct ureg_dst ureg_saturate ( struct ureg_dst  reg  )  [static, read]

Definition at line 465 of file tgsi_ureg.h.

References assert, and TGSI_FILE_NULL.

00466 {
00467    assert(reg.File != TGSI_FILE_NULL);
00468    reg.Saturate = 1;
00469    return reg;
00470 }

static struct ureg_src ureg_scalar ( struct ureg_src  reg,
int  x 
) [static, read]

Definition at line 450 of file tgsi_ureg.h.

References ureg_swizzle().

00451 {
00452    return ureg_swizzle(reg, x, x, x, x);
00453 }

static struct ureg_src ureg_src ( struct ureg_dst  dst  )  [static, read]

Definition at line 513 of file tgsi_ureg.h.

References ureg_src::Absolute, ureg_src::File, ureg_src::Index, ureg_src::Indirect, ureg_src::IndirectIndex, ureg_src::IndirectSwizzle, ureg_src::Negate, ureg_src::Pad, ureg_src::SwizzleW, ureg_src::SwizzleX, ureg_src::SwizzleY, ureg_src::SwizzleZ, TGSI_SWIZZLE_W, TGSI_SWIZZLE_X, TGSI_SWIZZLE_Y, and TGSI_SWIZZLE_Z.

00514 {
00515    struct ureg_src src;
00516 
00517    src.File      = dst.File;
00518    src.SwizzleX  = TGSI_SWIZZLE_X;
00519    src.SwizzleY  = TGSI_SWIZZLE_Y;
00520    src.SwizzleZ  = TGSI_SWIZZLE_Z;
00521    src.SwizzleW  = TGSI_SWIZZLE_W;
00522    src.Pad       = 0;
00523    src.Indirect  = dst.Indirect;
00524    src.IndirectIndex = dst.IndirectIndex;
00525    src.IndirectSwizzle = dst.IndirectSwizzle;
00526    src.Absolute  = 0;
00527    src.Index     = dst.Index;
00528    src.Negate    = 0;
00529 
00530    return src;
00531 }

static struct ureg_src ureg_src_indirect ( struct ureg_src  reg,
struct ureg_src  addr 
) [static, read]

Definition at line 484 of file tgsi_ureg.h.

References assert, TGSI_FILE_ADDRESS, and TGSI_FILE_NULL.

00485 {
00486    assert(reg.File != TGSI_FILE_NULL);
00487    assert(addr.File == TGSI_FILE_ADDRESS);
00488    reg.Indirect = 1;
00489    reg.IndirectIndex = addr.Index;
00490    reg.IndirectSwizzle = addr.SwizzleX;
00491    return reg;
00492 }

static boolean ureg_src_is_undef ( struct ureg_src  src  )  [static]

Definition at line 575 of file tgsi_ureg.h.

References ureg_src::File, and TGSI_FILE_NULL.

00576 {
00577    return src.File == TGSI_FILE_NULL;
00578 }

static struct ureg_src ureg_src_undef ( void   )  [static, read]

Definition at line 554 of file tgsi_ureg.h.

References ureg_src::Absolute, ureg_src::File, ureg_src::Index, ureg_src::Indirect, ureg_src::IndirectIndex, ureg_src::IndirectSwizzle, ureg_src::Negate, ureg_src::Pad, ureg_src::SwizzleW, ureg_src::SwizzleX, ureg_src::SwizzleY, ureg_src::SwizzleZ, and TGSI_FILE_NULL.

00555 {
00556    struct ureg_src src;
00557 
00558    src.File      = TGSI_FILE_NULL;
00559    src.SwizzleX  = 0;
00560    src.SwizzleY  = 0;
00561    src.SwizzleZ  = 0;
00562    src.SwizzleW  = 0;
00563    src.Pad       = 0;
00564    src.Indirect  = 0;
00565    src.IndirectIndex = 0;
00566    src.IndirectSwizzle = 0;
00567    src.Absolute  = 0;
00568    src.Index     = 0;
00569    src.Negate    = 0;
00570    
00571    return src;
00572 }

static struct ureg_src ureg_swizzle ( struct ureg_src  reg,
int  x,
int  y,
int  z,
int  w 
) [static, read]

Definition at line 428 of file tgsi_ureg.h.

References assert, and TGSI_FILE_NULL.

00430 {
00431    unsigned swz = ( (reg.SwizzleX << 0) |
00432                     (reg.SwizzleY << 2) |
00433                     (reg.SwizzleZ << 4) |
00434                     (reg.SwizzleW << 6));
00435 
00436    assert(reg.File != TGSI_FILE_NULL);
00437    assert(x < 4);
00438    assert(y < 4);
00439    assert(z < 4);
00440    assert(w < 4);
00441 
00442    reg.SwizzleX = (swz >> (x*2)) & 0x3;
00443    reg.SwizzleY = (swz >> (y*2)) & 0x3;
00444    reg.SwizzleZ = (swz >> (z*2)) & 0x3;
00445    reg.SwizzleW = (swz >> (w*2)) & 0x3;
00446    return reg;
00447 }

static struct ureg_dst ureg_writemask ( struct ureg_dst  reg,
unsigned  writemask 
) [static, read]

Definition at line 456 of file tgsi_ureg.h.

References assert, and TGSI_FILE_NULL.

00458 {
00459    assert(reg.File != TGSI_FILE_NULL);
00460    reg.WriteMask &= writemask;
00461    return reg;
00462 }


Generated on Tue Sep 29 06:25:27 2009 for Gallium3D by  doxygen 1.5.4