Home | History | Annotate | Download | only in tgsi

Lines Matching refs:ureg

210 static void set_bad( struct ureg_program *ureg )
212 tokens_error(&ureg->domain[0]);
217 static union tgsi_any_token *get_tokens( struct ureg_program *ureg,
221 struct ureg_tokens *tokens = &ureg->domain[domain];
233 static union tgsi_any_token *retrieve_token( struct ureg_program *ureg,
237 if (ureg->domain[domain].tokens == error_tokens)
240 return &ureg->domain[domain].tokens[nr];
270 ureg_property_gs_input_prim(struct ureg_program *ureg,
273 ureg->property_gs_input_prim = input_prim;
277 ureg_property_gs_output_prim(struct ureg_program *ureg,
280 ureg->property_gs_output_prim = output_prim;
284 ureg_property_gs_max_vertices(struct ureg_program *ureg,
287 ureg->property_gs_max_vertices = max_vertices;
291 ureg_property_fs_coord_origin(struct ureg_program *ureg,
294 ureg->property_fs_coord_origin = fs_coord_origin;
298 ureg_property_fs_coord_pixel_center(struct ureg_program *ureg,
301 ureg->property_fs_coord_pixel_center = fs_coord_pixel_center;
305 ureg_property_fs_color0_writes_all_cbufs(struct ureg_program *ureg,
308 ureg->property_fs_color0_writes_all_cbufs = fs_color0_writes_all_cbufs;
312 ureg_property_fs_depth_layout(struct ureg_program *ureg,
315 ureg->property_fs_depth_layout = fs_depth_layout;
319 ureg_DECL_fs_input_cyl_centroid(struct ureg_program *ureg,
328 for (i = 0; i < ureg->nr_fs_inputs; i++) {
329 if (ureg->fs_input[i].semantic_name == semantic_name &&
330 ureg->fs_input[i].semantic_index == semantic_index) {
335 if (ureg->nr_fs_inputs < UREG_MAX_INPUT) {
336 ureg->fs_input[i].semantic_name = semantic_name;
337 ureg->fs_input[i].semantic_index = semantic_index;
338 ureg->fs_input[i].interp = interp_mode;
339 ureg->fs_input[i].cylindrical_wrap = cylindrical_wrap;
340 ureg->fs_input[i].centroid = centroid;
341 ureg->nr_fs_inputs++;
343 set_bad(ureg);
352 ureg_DECL_vs_input( struct ureg_program *ureg,
355 assert(ureg->processor == TGSI_PROCESSOR_VERTEX);
357 ureg->vs_inputs[index/32] |= 1 << (index % 32);
363 ureg_DECL_gs_input(struct ureg_program *ureg,
368 if (ureg->nr_gs_inputs < UREG_MAX_INPUT) {
369 ureg->gs_input[ureg->nr_gs_inputs].index = index;
370 ureg->gs_input[ureg->nr_gs_inputs].semantic_name = semantic_name;
371 ureg->gs_input[ureg->nr_gs_inputs].semantic_index = semantic_index;
372 ureg->nr_gs_inputs++;
374 set_bad(ureg);
383 ureg_DECL_system_value(struct ureg_program *ureg,
388 if (ureg->nr_system_values < UREG_MAX_SYSTEM_VALUE) {
389 ureg->system_value[ureg->nr_system_values].index = index;
390 ureg->system_value[ureg->nr_system_values].semantic_name = semantic_name;
391 ureg->system_value[ureg->nr_system_values].semantic_index = semantic_index;
392 ureg->nr_system_values++;
394 set_bad(ureg);
402 ureg_DECL_output_masked( struct ureg_program *ureg,
411 for (i = 0; i < ureg->nr_outputs; i++) {
412 if (ureg->output[i].semantic_name == name &&
413 ureg->output[i].semantic_index == index) {
414 ureg->output[i].usage_mask |= usage_mask;
419 if (ureg->nr_outputs < UREG_MAX_OUTPUT) {
420 ureg->output[i].semantic_name = name;
421 ureg->output[i].semantic_index = index;
422 ureg->output[i].usage_mask = usage_mask;
423 ureg->nr_outputs++;
426 set_bad( ureg );
435 ureg_DECL_output( struct ureg_program *ureg,
439 return ureg_DECL_output_masked(ureg, name, index, TGSI_WRITEMASK_XYZW);
454 ureg_DECL_constant2D(struct ureg_program *ureg,
459 struct const_decl *decl = &ureg->const_decls2D[index2D];
478 ureg_DECL_constant(struct ureg_program *ureg,
481 struct const_decl *decl = &ureg->const_decls;
534 static struct ureg_dst alloc_temporary( struct ureg_program *ureg,
541 for (i = util_bitmask_get_first_index(ureg->free_temps);
543 i = util_bitmask_get_next_index(ureg->free_temps, i + 1)) {
544 if (util_bitmask_get(ureg->local_temps, i) == local)
551 i = ureg->nr_temps++;
553 util_bitmask_clear(ureg->free_temps, i);
556 util_bitmask_set(ureg->local_temps, i);
561 struct ureg_dst ureg_DECL_temporary( struct ureg_program *ureg )
563 return alloc_temporary(ureg, FALSE);
566 struct ureg_dst ureg_DECL_local_temporary( struct ureg_program *ureg )
568 return alloc_temporary(ureg, TRUE);
571 void ureg_release_temporary( struct ureg_program *ureg,
575 util_bitmask_set(ureg->free_temps, tmp.Index);
581 struct ureg_dst ureg_DECL_address( struct ureg_program *ureg )
583 if (ureg->nr_addrs < UREG_MAX_ADDR)
584 return ureg_dst_register( TGSI_FILE_ADDRESS, ureg->nr_addrs++ );
593 ureg_DECL_predicate(struct ureg_program *ureg)
595 if (ureg->nr_preds < UREG_MAX_PRED) {
596 ureg->nr_preds++);
605 struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg,
610 for (i = 0; i < ureg->nr_samplers; i++)
611 if (ureg->sampler[i].Index == nr)
612 return ureg->sampler[i];
615 ureg->sampler[i] = ureg_src_register( TGSI_FILE_SAMPLER, nr );
616 ureg->nr_samplers++;
617 return ureg->sampler[i];
621 return ureg->sampler[0];
628 ureg_DECL_sampler_view(struct ureg_program *ureg,
639 for (i = 0; i < ureg->nr_sampler_views; i++) {
640 if (ureg->sampler_view[i].index == index) {
646 ureg->sampler_view[i].index = index;
647 ureg->sampler_view[i].target = target;
648 ureg->sampler_view[i].return_type_x = return_type_x;
649 ureg->sampler_view[i].return_type_y = return_type_y;
650 ureg->sampler_view[i].return_type_z = return_type_z;
651 ureg->sampler_view[i].return_type_w = return_type_w;
652 ureg->nr_sampler_views++;
701 decl_immediate( struct ureg_program *ureg,
713 for (i = 0; i < ureg->nr_immediates; i++) {
714 if (ureg->immediate[i].type != type) {
719 ureg->immediate[i].value.u,
720 &ureg->immediate[i].nr,
726 if (ureg->nr_immediates < UREG_MAX_IMMEDIATE) {
727 i = ureg->nr_immediates++;
728 ureg->immediate[i].type = type;
731 ureg->immediate[i].value.u,
732 &ureg->immediate[i].nr,
738 set_bad(ureg);
757 ureg_DECL_immediate( struct ureg_program *ureg,
771 return decl_immediate(ureg, fu.u, nr, TGSI_IMM_FLOAT32);
776 ureg_DECL_immediate_uint( struct ureg_program *ureg,
780 return decl_immediate(ureg, v, nr, TGSI_IMM_UINT32);
785 ureg_DECL_immediate_block_uint( struct ureg_program *ureg,
792 if (ureg->nr_immediates + (nr + 3) / 4 > UREG_MAX_IMMEDIATE) {
793 set_bad(ureg);
797 index = ureg->nr_immediates;
798 ureg->nr_immediates += (nr + 3) / 4;
800 for (i = index; i < ureg->nr_immediates; i++) {
801 ureg->immediate[i].type = TGSI_IMM_UINT32;
802 ureg->immediate[i].nr = nr > 4 ? 4 : nr;
803 memcpy(ureg->immediate[i].value.u,
805 ureg->immediate[i].nr * sizeof(uint));
814 ureg_DECL_immediate_int( struct ureg_program *ureg,
818 return decl_immediate(ureg, (const unsigned *)v, nr, TGSI_IMM_INT32);
823 ureg_emit_src( struct ureg_program *ureg,
829 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
888 ureg_emit_dst( struct ureg_program *ureg,
894 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
942 ureg_emit_insn(struct ureg_program *ureg,
960 out = get_tokens( ureg, DOMAIN_INSN, count );
967 result.insn_token = ureg->domain[DOMAIN_INSN].count - count;
980 ureg->nr_instructions++;
987 ureg_emit_label(struct ureg_program *ureg,
996 out = get_tokens( ureg, DOMAIN_INSN, 1 );
999 insn = retrieve_token( ureg, DOMAIN_INSN, extended_token );
1002 *label_token = ureg->domain[DOMAIN_INSN].count - 1;
1009 ureg_get_instruction_number( struct ureg_program *ureg )
1011 return ureg->nr_instructions;
1018 ureg_fixup_label(struct ureg_program *ureg,
1022 union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_INSN, label_token );
1029 ureg_emit_texture(struct ureg_program *ureg,
1035 out = get_tokens( ureg, DOMAIN_INSN, 1 );
1036 insn = retrieve_token( ureg, DOMAIN_INSN, extended_token );
1046 ureg_emit_texture_offset(struct ureg_program *ureg,
1051 out = get_tokens( ureg, DOMAIN_INSN, 1);
1060 ureg_fixup_insn_size(struct ureg_program *ureg,
1063 union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_INSN, insn );
1066 out->insn.NrTokens = ureg->domain[DOMAIN_INSN].count - insn - 1;
1071 ureg_insn(struct ureg_program *ureg,
1095 insn = ureg_emit_insn(ureg,
1108 ureg_emit_dst( ureg, dst[i] );
1111 ureg_emit_src( ureg, src[i] );
1113 ureg_fixup_insn_size( ureg, insn.insn_token );
1117 ureg_tex_insn(struct ureg_program *ureg,
1144 insn = ureg_emit_insn(ureg,
1156 ureg_emit_texture( ureg, insn.extended_token, target, nr_offset );
1159 ureg_emit_texture_offset( ureg, &texoffsets[i]);
1162 ureg_emit_dst( ureg, dst[i] );
1165 ureg_emit_src( ureg, src[i] );
1167 ureg_fixup_insn_size( ureg, insn.insn_token );
1172 ureg_label_insn(struct ureg_program *ureg,
1181 insn = ureg_emit_insn(ureg,
1193 ureg_emit_label( ureg, insn.extended_token, label_token );
1196 ureg_emit_src( ureg, src[i] );
1198 ureg_fixup_insn_size( ureg, insn.insn_token );
1203 emit_decl_semantic(struct ureg_program *ureg,
1210 union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3);
1230 emit_decl_fs(struct ureg_program *ureg,
1239 union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 4);
1264 static void emit_decl( struct ureg_program *ureg,
1269 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 );
1283 static void emit_decl_range( struct ureg_program *ureg,
1288 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 );
1303 emit_decl_range2D(struct ureg_program *ureg,
1309 union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3);
1327 emit_decl_sampler_view(struct ureg_program *ureg,
1335 union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3);
1356 emit_immediate( struct ureg_program *ureg,
1360 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 5 );
1375 emit_property(struct ureg_program *ureg,
1379 union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 2);
1390 static void emit_decls( struct ureg_program *ureg )
1394 if (ureg->property_gs_input_prim != ~0) {
1395 assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY);
1397 emit_property(ureg,
1399 ureg->property_gs_input_prim);
1402 if (ureg->property_gs_output_prim != ~0) {
1403 assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY);
1405 emit_property(ureg,
1407 ureg->property_gs_output_prim);
1410 if (ureg->property_gs_max_vertices != ~0) {
1411 assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY);
1413 emit_property(ureg,
1415 ureg->property_gs_max_vertices);
1418 if (ureg->property_fs_coord_origin) {
1419 assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT);
1421 emit_property(ureg,
1423 ureg->property_fs_coord_origin);
1426 if (ureg->property_fs_coord_pixel_center) {
1427 assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT);
1429 emit_property(ureg,
1431 ureg->property_fs_coord_pixel_center);
1434 if (ureg->property_fs_color0_writes_all_cbufs) {
1435 assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT);
1437 emit_property(ureg,
1439 ureg->property_fs_color0_writes_all_cbufs);
1442 if (ureg->property_fs_depth_layout) {
1443 assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT);
1445 emit_property(ureg,
1447 ureg->property_fs_depth_layout);
1450 if (ureg->processor == TGSI_PROCESSOR_VERTEX) {
1452 if (ureg->vs_inputs[i/32] & (1 << (i%32))) {
1453 emit_decl_range( ureg, TGSI_FILE_INPUT, i, 1 );
1456 } else if (ureg->processor == TGSI_PROCESSOR_FRAGMENT) {
1457 for (i = 0; i < ureg->nr_fs_inputs; i++) {
1458 emit_decl_fs(ureg,
1461 ureg->fs_input[i].semantic_name,
1462 ureg->fs_input[i].semantic_index,
1463 ureg->fs_input[i].interp,
1464 ureg->fs_input[i].cylindrical_wrap,
1465 ureg->fs_input[i].centroid);
1468 for (i = 0; i < ureg->nr_gs_inputs; i++) {
1469 emit_decl_semantic(ureg,
1471 ureg->gs_input[i].index,
1472 ureg->gs_input[i].semantic_name,
1473 ureg->gs_input[i].semantic_index,
1478 for (i = 0; i < ureg->nr_system_values; i++) {
1479 emit_decl_semantic(ureg,
1481 ureg->system_value[i].index,
1482 ureg->system_value[i].semantic_name,
1483 ureg->system_value[i].semantic_index,
1487 for (i = 0; i < ureg->nr_outputs; i++) {
1488 emit_decl_semantic(ureg,
1491 ureg->output[i].semantic_name,
1492 ureg->output[i].semantic_index,
1493 ureg->output[i].usage_mask);
1496 for (i = 0; i < ureg->nr_samplers; i++) {
1497 emit_decl_range( ureg,
1499 ureg->sampler[i].Index, 1 );
1502 for (i = 0; i < ureg->nr_sampler_views; i++) {
1503 emit_decl_sampler_view(ureg,
1504 ureg->sampler_view[i].index,
1505 ureg->sampler_view[i].target,
1506 ureg->sampler_view[i].return_type_x,
1507 ureg->sampler_view[i].return_type_y,
1508 ureg->sampler_view[i].return_type_z,
1509 ureg->sampler_view[i].return_type_w);
1512 if (ureg->const_decls.nr_constant_ranges) {
1513 for (i = 0; i < ureg->const_decls.nr_constant_ranges; i++) {
1514 emit_decl_range(ureg,
1516 ureg->const_decls.constant_range[i].first,
1517 ureg->const_decls.constant_range[i].last - ureg->const_decls.constant_range[i].first + 1);
1522 struct const_decl *decl = &ureg->const_decls2D[i];
1528 emit_decl_range2D(ureg,
1537 if (ureg->nr_temps) {
1538 if (util_bitmask_get_first_index(ureg->local_temps) == UTIL_BITMASK_INVALID_INDEX) {
1539 emit_decl_range( ureg,
1541 0, ureg->nr_temps );
1544 for (i = 0; i < ureg->nr_temps; i++) {
1545 emit_decl( ureg, TGSI_FILE_TEMPORARY, i,
1546 util_bitmask_get(ureg->local_temps, i) );
1551 if (ureg->nr_addrs) {
1552 emit_decl_range( ureg,
1554 0, ureg->nr_addrs );
1557 if (ureg->nr_preds) {
1558 emit_decl_range(ureg,
1561 ureg->nr_preds);
1564 for (i = 0; i < ureg->nr_immediates; i++) {
1565 emit_immediate( ureg,
1566 ureg->immediate[i].value.u,
1567 ureg->immediate[i].type );
1574 static void copy_instructions( struct ureg_program *ureg )
1576 unsigned nr_tokens = ureg->domain[DOMAIN_INSN].count;
1577 union tgsi_any_token *out = get_tokens( ureg,
1582 ureg->domain[DOMAIN_INSN].tokens,
1588 fixup_header_size(struct ureg_program *ureg)
1590 union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_DECL, 0 );
1592 out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 2;
1597 emit_header( struct ureg_program *ureg )
1599 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 );
1604 out[1].processor.Processor = ureg->processor;
1609 const struct tgsi_token *ureg_finalize( struct ureg_program *ureg )
1613 emit_header( ureg );
1614 emit_decls( ureg );
1615 copy_instructions( ureg );
1616 fixup_header_size( ureg );
1618 if (ureg->domain[0].tokens == error_tokens ||
1619 ureg->domain[1].tokens == error_tokens) {
1625 tokens = &ureg->domain[DOMAIN_DECL].tokens[0].token;
1629 ureg->domain[DOMAIN_DECL].count);
1646 void *ureg_create_shader( struct ureg_program *ureg,
1652 state.tokens = ureg_finalize(ureg);
1661 if (ureg->processor == TGSI_PROCESSOR_VERTEX)
1668 const struct tgsi_token *ureg_get_tokens( struct ureg_program *ureg,
1673 ureg_finalize(ureg);
1675 tokens = &ureg->domain[DOMAIN_DECL].tokens[0].token;
1678 *nr_tokens = ureg->domain[DOMAIN_DECL].size;
1680 ureg->domain[DOMAIN_DECL].tokens = 0;
1681 ureg->domain[DOMAIN_DECL].size = 0;
1682 ureg->domain[DOMAIN_DECL].order = 0;
1683 ureg->domain[DOMAIN_DECL].count = 0;
1697 struct ureg_program *ureg = CALLOC_STRUCT( ureg_program );
1698 if (ureg == NULL)
1701 ureg->processor = processor;
1702 ureg->property_gs_input_prim = ~0;
1703 ureg->property_gs_output_prim = ~0;
1704 ureg->property_gs_max_vertices = ~0;
1706 ureg->free_temps = util_bitmask_create();
1707 if (ureg->free_temps == NULL)
1710 ureg->local_temps = util_bitmask_create();
1711 if (ureg->local_temps == NULL)
1714 return ureg;
1717 util_bitmask_destroy(ureg->free_temps);
1719 FREE(ureg);
1725 void ureg_destroy( struct ureg_program *ureg )
1729 for (i = 0; i < Elements(ureg->domain); i++) {
1730 if (ureg->domain[i].tokens &&
1731 ureg->domain[i].tokens != error_tokens)
1732 FREE(ureg->domain[i].tokens);
1735 util_bitmask_destroy(ureg->free_temps);
1736 util_bitmask_destroy(ureg->local_temps);
1738 FREE(ureg);