Go to the source code of this file.
Data Structures | |
union | tgsi_any_token |
struct | ureg_tokens |
struct | ureg_program |
Defines | |
#define | UREG_MAX_INPUT PIPE_MAX_ATTRIBS |
#define | UREG_MAX_OUTPUT PIPE_MAX_ATTRIBS |
#define | UREG_MAX_IMMEDIATE 32 |
#define | UREG_MAX_TEMP 256 |
#define | UREG_MAX_ADDR 2 |
#define | DOMAIN_DECL 0 |
#define | DOMAIN_INSN 1 |
Functions | |
static void | tokens_error (struct ureg_tokens *tokens) |
static void | tokens_expand (struct ureg_tokens *tokens, unsigned count) |
static void | set_bad (struct ureg_program *ureg) |
static union tgsi_any_token * | get_tokens (struct ureg_program *ureg, unsigned domain, unsigned count) |
static union tgsi_any_token * | retrieve_token (struct ureg_program *ureg, unsigned domain, unsigned nr) |
static struct ureg_dst | ureg_dst_register (unsigned file, unsigned index) |
static struct ureg_src | ureg_src_register (unsigned file, unsigned index) |
static struct ureg_src | ureg_DECL_input (struct ureg_program *ureg, unsigned name, unsigned index, unsigned interp_mode) |
struct ureg_src | ureg_DECL_fs_input (struct ureg_program *ureg, unsigned name, unsigned index, unsigned interp) |
struct ureg_src | ureg_DECL_vs_input (struct ureg_program *ureg, unsigned name, unsigned index) |
struct ureg_dst | ureg_DECL_output (struct ureg_program *ureg, unsigned name, unsigned index) |
struct ureg_src | ureg_DECL_constant (struct ureg_program *ureg) |
struct ureg_dst | ureg_DECL_temporary (struct ureg_program *ureg) |
void | ureg_release_temporary (struct ureg_program *ureg, struct ureg_dst tmp) |
struct ureg_dst | ureg_DECL_address (struct ureg_program *ureg) |
struct ureg_src | ureg_DECL_sampler (struct ureg_program *ureg, unsigned nr) |
static int | match_or_expand_immediate (const float *v, unsigned nr, float *v2, unsigned *nr2, unsigned *swizzle) |
struct ureg_src | ureg_DECL_immediate (struct ureg_program *ureg, const float *v, unsigned nr) |
void | ureg_emit_src (struct ureg_program *ureg, struct ureg_src src) |
void | ureg_emit_dst (struct ureg_program *ureg, struct ureg_dst dst) |
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) |
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_emit_texture (struct ureg_program *ureg, unsigned insn_token, unsigned target) |
void | ureg_fixup_insn_size (struct ureg_program *ureg, unsigned insn) |
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) |
static void | emit_decl (struct ureg_program *ureg, unsigned file, unsigned index, unsigned semantic_name, unsigned semantic_index, unsigned interp) |
static void | emit_decl_range (struct ureg_program *ureg, unsigned file, unsigned first, unsigned count) |
static void | emit_immediate (struct ureg_program *ureg, const float *v) |
static void | emit_decls (struct ureg_program *ureg) |
static void | copy_instructions (struct ureg_program *ureg) |
static void | fixup_header_size (struct ureg_program *ureg) |
static void | emit_header (struct ureg_program *ureg) |
struct tgsi_token * | ureg_finalize (struct ureg_program *ureg) |
void * | ureg_create_shader (struct ureg_program *ureg, struct pipe_context *pipe) |
struct ureg_program * | ureg_create (unsigned processor) |
void | ureg_destroy (struct ureg_program *ureg) |
Variables | |
static union tgsi_any_token | error_tokens [32] |
#define DOMAIN_DECL 0 |
Definition at line 77 of file tgsi_ureg.c.
#define DOMAIN_INSN 1 |
Definition at line 78 of file tgsi_ureg.c.
#define UREG_MAX_ADDR 2 |
Definition at line 75 of file tgsi_ureg.c.
#define UREG_MAX_IMMEDIATE 32 |
Definition at line 73 of file tgsi_ureg.c.
#define UREG_MAX_INPUT PIPE_MAX_ATTRIBS |
Definition at line 71 of file tgsi_ureg.c.
#define UREG_MAX_OUTPUT PIPE_MAX_ATTRIBS |
Definition at line 72 of file tgsi_ureg.c.
#define UREG_MAX_TEMP 256 |
Definition at line 74 of file tgsi_ureg.c.
static void copy_instructions | ( | struct ureg_program * | ureg | ) | [static] |
Definition at line 831 of file tgsi_ureg.c.
References ureg_tokens::count, ureg_program::domain, DOMAIN_DECL, DOMAIN_INSN, get_tokens(), and ureg_tokens::tokens.
00832 { 00833 unsigned nr_tokens = ureg->domain[DOMAIN_INSN].count; 00834 union tgsi_any_token *out = get_tokens( ureg, 00835 DOMAIN_DECL, 00836 nr_tokens ); 00837 00838 memcpy(out, 00839 ureg->domain[DOMAIN_INSN].tokens, 00840 nr_tokens * sizeof out[0] ); 00841 }
static void emit_decl | ( | struct ureg_program * | ureg, | |
unsigned | file, | |||
unsigned | index, | |||
unsigned | semantic_name, | |||
unsigned | semantic_index, | |||
unsigned | interp | |||
) | [static] |
Definition at line 707 of file tgsi_ureg.c.
References tgsi_any_token::decl, tgsi_any_token::decl_range, tgsi_any_token::decl_semantic, DOMAIN_DECL, tgsi_declaration::File, tgsi_declaration_range::First, get_tokens(), tgsi_declaration::Interpolate, tgsi_declaration_range::Last, tgsi_declaration::Semantic, tgsi_declaration_semantic::SemanticIndex, tgsi_declaration_semantic::SemanticName, tgsi_declaration::Size, TGSI_TOKEN_TYPE_DECLARATION, TGSI_WRITEMASK_XYZW, tgsi_declaration::Type, tgsi_declaration::UsageMask, and tgsi_any_token::value.
00713 { 00714 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 3 ); 00715 00716 out[0].value = 0; 00717 out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; 00718 out[0].decl.Size = 3; 00719 out[0].decl.File = file; 00720 out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; /* FIXME! */ 00721 out[0].decl.Interpolate = interp; 00722 out[0].decl.Semantic = 1; 00723 00724 out[1].value = 0; 00725 out[1].decl_range.First = 00726 out[1].decl_range.Last = index; 00727 00728 out[2].value = 0; 00729 out[2].decl_semantic.SemanticName = semantic_name; 00730 out[2].decl_semantic.SemanticIndex = semantic_index; 00731 00732 }
static void emit_decl_range | ( | struct ureg_program * | ureg, | |
unsigned | file, | |||
unsigned | first, | |||
unsigned | count | |||
) | [static] |
Definition at line 735 of file tgsi_ureg.c.
References tgsi_any_token::decl, tgsi_any_token::decl_range, DOMAIN_DECL, tgsi_declaration::File, tgsi_declaration_range::First, get_tokens(), tgsi_declaration::Interpolate, tgsi_declaration_range::Last, tgsi_declaration::Semantic, tgsi_declaration::Size, TGSI_INTERPOLATE_CONSTANT, TGSI_TOKEN_TYPE_DECLARATION, tgsi_declaration::Type, tgsi_declaration::UsageMask, and tgsi_any_token::value.
00739 { 00740 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 ); 00741 00742 out[0].value = 0; 00743 out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; 00744 out[0].decl.Size = 2; 00745 out[0].decl.File = file; 00746 out[0].decl.UsageMask = 0xf; 00747 out[0].decl.Interpolate = TGSI_INTERPOLATE_CONSTANT; 00748 out[0].decl.Semantic = 0; 00749 00750 out[1].value = 0; 00751 out[1].decl_range.First = first; 00752 out[1].decl_range.Last = first + count - 1; 00753 }
static void emit_decls | ( | struct ureg_program * | ureg | ) | [static] |
Definition at line 776 of file tgsi_ureg.c.
References emit_decl(), emit_decl_range(), emit_immediate(), ureg_program::immediate, ureg_src::Index, ureg_program::input, ureg_program::interp, ureg_program::nr_addrs, ureg_program::nr_constants, ureg_program::nr_immediates, ureg_program::nr_inputs, ureg_program::nr_outputs, ureg_program::nr_samplers, ureg_program::nr_temps, ureg_program::output, ureg_program::sampler, ureg_program::semantic_index, ureg_program::semantic_name, TGSI_FILE_ADDRESS, TGSI_FILE_CONSTANT, TGSI_FILE_INPUT, TGSI_FILE_OUTPUT, TGSI_FILE_SAMPLER, TGSI_FILE_TEMPORARY, TGSI_INTERPOLATE_CONSTANT, and ureg_program::v.
00777 { 00778 unsigned i; 00779 00780 for (i = 0; i < ureg->nr_inputs; i++) { 00781 emit_decl( ureg, 00782 TGSI_FILE_INPUT, 00783 i, 00784 ureg->input[i].semantic_name, 00785 ureg->input[i].semantic_index, 00786 ureg->input[i].interp ); 00787 } 00788 00789 for (i = 0; i < ureg->nr_outputs; i++) { 00790 emit_decl( ureg, 00791 TGSI_FILE_OUTPUT, 00792 i, 00793 ureg->output[i].semantic_name, 00794 ureg->output[i].semantic_index, 00795 TGSI_INTERPOLATE_CONSTANT ); 00796 } 00797 00798 for (i = 0; i < ureg->nr_samplers; i++) { 00799 emit_decl_range( ureg, 00800 TGSI_FILE_SAMPLER, 00801 ureg->sampler[i].Index, 1 ); 00802 } 00803 00804 if (ureg->nr_constants) { 00805 emit_decl_range( ureg, 00806 TGSI_FILE_CONSTANT, 00807 0, ureg->nr_constants ); 00808 } 00809 00810 if (ureg->nr_temps) { 00811 emit_decl_range( ureg, 00812 TGSI_FILE_TEMPORARY, 00813 0, ureg->nr_temps ); 00814 } 00815 00816 if (ureg->nr_addrs) { 00817 emit_decl_range( ureg, 00818 TGSI_FILE_ADDRESS, 00819 0, ureg->nr_addrs ); 00820 } 00821 00822 for (i = 0; i < ureg->nr_immediates; i++) { 00823 emit_immediate( ureg, 00824 ureg->immediate[i].v ); 00825 } 00826 }
static void emit_header | ( | struct ureg_program * | ureg | ) | [static] |
Definition at line 854 of file tgsi_ureg.c.
References tgsi_header::BodySize, DOMAIN_DECL, get_tokens(), tgsi_any_token::header, tgsi_header::HeaderSize, tgsi_version::MajorVersion, tgsi_version::MinorVersion, tgsi_processor::Padding, tgsi_version::Padding, ureg_program::processor, tgsi_processor::Processor, tgsi_any_token::processor, and tgsi_any_token::version.
00855 { 00856 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 3 ); 00857 00858 out[0].version.MajorVersion = 1; 00859 out[0].version.MinorVersion = 1; 00860 out[0].version.Padding = 0; 00861 00862 out[1].header.HeaderSize = 2; 00863 out[1].header.BodySize = 0; 00864 00865 out[2].processor.Processor = ureg->processor; 00866 out[2].processor.Padding = 0; 00867 }
static void emit_immediate | ( | struct ureg_program * | ureg, | |
const float * | v | |||
) | [static] |
Definition at line 755 of file tgsi_ureg.c.
References tgsi_immediate::DataType, DOMAIN_DECL, tgsi_immediate::Extended, tgsi_immediate_float32::Float, get_tokens(), tgsi_any_token::imm, tgsi_any_token::imm_data, tgsi_immediate::Padding, tgsi_immediate::Size, TGSI_IMM_FLOAT32, TGSI_TOKEN_TYPE_IMMEDIATE, tgsi_immediate::Type, and tgsi_any_token::value.
00757 { 00758 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 5 ); 00759 00760 out[0].value = 0; 00761 out[0].imm.Type = TGSI_TOKEN_TYPE_IMMEDIATE; 00762 out[0].imm.Size = 5; 00763 out[0].imm.DataType = TGSI_IMM_FLOAT32; 00764 out[0].imm.Padding = 0; 00765 out[0].imm.Extended = 0; 00766 00767 out[1].imm_data.Float = v[0]; 00768 out[2].imm_data.Float = v[1]; 00769 out[3].imm_data.Float = v[2]; 00770 out[4].imm_data.Float = v[3]; 00771 }
static void fixup_header_size | ( | struct ureg_program * | ureg | ) | [static] |
Definition at line 845 of file tgsi_ureg.c.
References tgsi_header::BodySize, ureg_tokens::count, ureg_program::domain, DOMAIN_DECL, tgsi_any_token::header, and retrieve_token().
00846 { 00847 union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_DECL, 1 ); 00848 00849 out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 3; 00850 }
static union tgsi_any_token* get_tokens | ( | struct ureg_program * | ureg, | |
unsigned | domain, | |||
unsigned | count | |||
) | [static, write] |
Definition at line 159 of file tgsi_ureg.c.
References ureg_tokens::count, ureg_program::domain, ureg_tokens::size, ureg_tokens::tokens, and tokens_expand().
00162 { 00163 struct ureg_tokens *tokens = &ureg->domain[domain]; 00164 union tgsi_any_token *result; 00165 00166 if (tokens->count + count > tokens->size) 00167 tokens_expand(tokens, count); 00168 00169 result = &tokens->tokens[tokens->count]; 00170 tokens->count += count; 00171 return result; 00172 }
static int match_or_expand_immediate | ( | const float * | v, | |
unsigned | nr, | |||
float * | v2, | |||
unsigned * | nr2, | |||
unsigned * | swizzle | |||
) | [static] |
Definition at line 396 of file tgsi_ureg.c.
00401 { 00402 unsigned i, j; 00403 00404 *swizzle = 0; 00405 00406 for (i = 0; i < nr; i++) { 00407 boolean found = FALSE; 00408 00409 for (j = 0; j < *nr2 && !found; j++) { 00410 if (v[i] == v2[j]) { 00411 *swizzle |= j << (i * 2); 00412 found = TRUE; 00413 } 00414 } 00415 00416 if (!found) { 00417 if (*nr2 >= 4) 00418 return FALSE; 00419 00420 v2[*nr2] = v[i]; 00421 *swizzle |= *nr2 << (i * 2); 00422 (*nr2)++; 00423 } 00424 } 00425 00426 return TRUE; 00427 }
static union tgsi_any_token* retrieve_token | ( | struct ureg_program * | ureg, | |
unsigned | domain, | |||
unsigned | nr | |||
) | [static, write] |
Definition at line 175 of file tgsi_ureg.c.
References ureg_program::domain, error_tokens, and ureg_tokens::tokens.
00178 { 00179 if (ureg->domain[domain].tokens == error_tokens) 00180 return &error_tokens[0]; 00181 00182 return &ureg->domain[domain].tokens[nr]; 00183 }
static void set_bad | ( | struct ureg_program * | ureg | ) | [static] |
Definition at line 152 of file tgsi_ureg.c.
References ureg_program::domain, and tokens_error().
00153 { 00154 tokens_error(&ureg->domain[0]); 00155 }
static void tokens_error | ( | struct ureg_tokens * | tokens | ) | [static] |
Definition at line 120 of file tgsi_ureg.c.
References ureg_tokens::count, Elements, error_tokens, ureg_tokens::size, and ureg_tokens::tokens.
00121 { 00122 tokens->tokens = error_tokens; 00123 tokens->size = Elements(error_tokens); 00124 tokens->count = 0; 00125 }
static void tokens_expand | ( | struct ureg_tokens * | tokens, | |
unsigned | count | |||
) | [static] |
Definition at line 128 of file tgsi_ureg.c.
References ureg_tokens::count, error_tokens, ureg_tokens::order, REALLOC, ureg_tokens::size, ureg_tokens::tokens, and tokens_error().
00130 { 00131 unsigned old_size = tokens->size * sizeof(unsigned); 00132 00133 if (tokens->tokens == error_tokens) 00134 goto fail; 00135 00136 while (tokens->count + count > tokens->size) { 00137 tokens->size = (1 << ++tokens->order); 00138 } 00139 00140 tokens->tokens = REALLOC(tokens->tokens, 00141 old_size, 00142 tokens->size * sizeof(unsigned)); 00143 if (tokens->tokens == NULL) 00144 goto fail; 00145 00146 return; 00147 00148 fail: 00149 tokens_error(tokens); 00150 }
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 * | ureg, | |
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 }
struct ureg_dst ureg_DECL_address | ( | struct ureg_program * | ureg | ) | [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 * | ureg | ) | [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 * | ureg, | |
unsigned | name, | |||
unsigned | index, | |||
unsigned | interp | |||
) | [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 * | ureg, | |
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 }
static struct ureg_src ureg_DECL_input | ( | struct ureg_program * | ureg, | |
unsigned | name, | |||
unsigned | index, | |||
unsigned | interp_mode | |||
) | [static, read] |
Definition at line 232 of file tgsi_ureg.c.
References set_bad(), TGSI_FILE_INPUT, UREG_MAX_INPUT, and ureg_src_register().
00236 { 00237 unsigned i; 00238 00239 for (i = 0; i < ureg->nr_inputs; i++) { 00240 if (ureg->input[i].semantic_name == name && 00241 ureg->input[i].semantic_index == index) 00242 goto out; 00243 } 00244 00245 if (ureg->nr_inputs < UREG_MAX_INPUT) { 00246 ureg->input[i].semantic_name = name; 00247 ureg->input[i].semantic_index = index; 00248 ureg->input[i].interp = interp_mode; 00249 ureg->nr_inputs++; 00250 } 00251 else { 00252 set_bad( ureg ); 00253 } 00254 00255 out: 00256 return ureg_src_register( TGSI_FILE_INPUT, i ); 00257 }
struct ureg_dst ureg_DECL_output | ( | struct ureg_program * | ureg, | |
unsigned | name, | |||
unsigned | 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 * | ureg, | |
unsigned | nr | |||
) | [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 * | ureg | ) | [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 * | ureg, | |
unsigned | name, | |||
unsigned | 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 * | ureg | ) |
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_register | ( | unsigned | file, | |
unsigned | index | |||
) | [static, read] |
Definition at line 188 of file tgsi_ureg.c.
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.
00190 { 00191 struct ureg_dst dst; 00192 00193 dst.File = file; 00194 dst.WriteMask = TGSI_WRITEMASK_XYZW; 00195 dst.Indirect = 0; 00196 dst.IndirectIndex = 0; 00197 dst.IndirectSwizzle = 0; 00198 dst.Saturate = 0; 00199 dst.Index = index; 00200 dst.Pad1 = 0; 00201 dst.Pad2 = 0; 00202 00203 return dst; 00204 }
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 * | ureg | ) | [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 }
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 }
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_src ureg_src_register | ( | unsigned | file, | |
unsigned | index | |||
) | [static, read] |
Definition at line 207 of file tgsi_ureg.c.
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.
00209 { 00210 struct ureg_src src; 00211 00212 src.File = file; 00213 src.SwizzleX = TGSI_SWIZZLE_X; 00214 src.SwizzleY = TGSI_SWIZZLE_Y; 00215 src.SwizzleZ = TGSI_SWIZZLE_Z; 00216 src.SwizzleW = TGSI_SWIZZLE_W; 00217 src.Pad = 0; 00218 src.Indirect = 0; 00219 src.IndirectIndex = 0; 00220 src.IndirectSwizzle = 0; 00221 src.Absolute = 0; 00222 src.Index = index; 00223 src.Negate = 0; 00224 00225 return src; 00226 }
union tgsi_any_token error_tokens[32] [static] |
Definition at line 118 of file tgsi_ureg.c.