r300g: Inline immediates where possible.
Oh look, more gears. Seems to work just fine though.
This commit is contained in:
@@ -201,6 +201,8 @@ static void transform_srcreg(
|
|||||||
struct rc_src_register * dst,
|
struct rc_src_register * dst,
|
||||||
struct tgsi_full_src_register * src)
|
struct tgsi_full_src_register * src)
|
||||||
{
|
{
|
||||||
|
unsigned i, j;
|
||||||
|
|
||||||
dst->File = translate_register_file(src->Register.File);
|
dst->File = translate_register_file(src->Register.File);
|
||||||
dst->Index = translate_register_index(ttr, src->Register.File, src->Register.Index);
|
dst->Index = translate_register_index(ttr, src->Register.File, src->Register.Index);
|
||||||
dst->RelAddr = src->Register.Indirect;
|
dst->RelAddr = src->Register.Indirect;
|
||||||
@@ -210,6 +212,21 @@ static void transform_srcreg(
|
|||||||
dst->Swizzle |= tgsi_util_get_full_src_register_swizzle(src, 3) << 9;
|
dst->Swizzle |= tgsi_util_get_full_src_register_swizzle(src, 3) << 9;
|
||||||
dst->Abs = src->Register.Absolute;
|
dst->Abs = src->Register.Absolute;
|
||||||
dst->Negate = src->Register.Negate ? RC_MASK_XYZW : 0;
|
dst->Negate = src->Register.Negate ? RC_MASK_XYZW : 0;
|
||||||
|
|
||||||
|
if (src->Register.File == TGSI_FILE_IMMEDIATE) {
|
||||||
|
for (i = 0; i < ttr->imms_to_swizzle_count; i++) {
|
||||||
|
if (ttr->imms_to_swizzle[i].index == src->Register.Index) {
|
||||||
|
dst->File = RC_FILE_TEMPORARY;
|
||||||
|
dst->Index = 0;
|
||||||
|
dst->Swizzle = 0;
|
||||||
|
for (j = 0; j < 4; j++) {
|
||||||
|
dst->Swizzle |= GET_SWZ(ttr->imms_to_swizzle[i].swizzle,
|
||||||
|
tgsi_util_get_full_src_register_swizzle(src, j)) << (j * 3);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_texture src,
|
static void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_texture src,
|
||||||
@@ -277,21 +294,48 @@ static void transform_instruction(struct tgsi_to_rc * ttr, struct tgsi_full_inst
|
|||||||
&ttr->compiler->Program.ShadowSamplers);
|
&ttr->compiler->Program.ShadowSamplers);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_immediate(struct tgsi_to_rc * ttr, struct tgsi_full_immediate * imm)
|
static void handle_immediate(struct tgsi_to_rc * ttr,
|
||||||
|
struct tgsi_full_immediate * imm,
|
||||||
|
unsigned index)
|
||||||
{
|
{
|
||||||
struct rc_constant constant;
|
struct rc_constant constant;
|
||||||
int i;
|
unsigned swizzle = 0;
|
||||||
|
boolean can_swizzle = TRUE;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
constant.Type = RC_CONSTANT_IMMEDIATE;
|
for (i = 0; i < 4; i++) {
|
||||||
constant.Size = 4;
|
if (imm->u[i].Float == 0.0f) {
|
||||||
for(i = 0; i < 4; ++i)
|
swizzle |= RC_SWIZZLE_ZERO << (i * 3);
|
||||||
constant.u.Immediate[i] = imm->u[i].Float;
|
} else if (imm->u[i].Float == 0.5f) {
|
||||||
rc_constants_add(&ttr->compiler->Program.Constants, &constant);
|
swizzle |= RC_SWIZZLE_HALF << (i * 3);
|
||||||
|
} else if (imm->u[i].Float == 1.0f) {
|
||||||
|
swizzle |= RC_SWIZZLE_ONE << (i * 3);
|
||||||
|
} else {
|
||||||
|
can_swizzle = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (can_swizzle) {
|
||||||
|
struct swizzled_imms* si =
|
||||||
|
&ttr->imms_to_swizzle[ttr->imms_to_swizzle_count];
|
||||||
|
|
||||||
|
si->index = index;
|
||||||
|
si->swizzle = swizzle;
|
||||||
|
ttr->imms_to_swizzle_count++;
|
||||||
|
} else {
|
||||||
|
constant.Type = RC_CONSTANT_IMMEDIATE;
|
||||||
|
constant.Size = 4;
|
||||||
|
for(i = 0; i < 4; ++i)
|
||||||
|
constant.u.Immediate[i] = imm->u[i].Float;
|
||||||
|
rc_constants_add(&ttr->compiler->Program.Constants, &constant);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
|
void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
|
||||||
{
|
{
|
||||||
struct tgsi_parse_context parser;
|
struct tgsi_parse_context parser;
|
||||||
|
unsigned imm_index = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Allocate constants placeholders.
|
/* Allocate constants placeholders.
|
||||||
@@ -317,7 +361,8 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
|
|||||||
case TGSI_TOKEN_TYPE_DECLARATION:
|
case TGSI_TOKEN_TYPE_DECLARATION:
|
||||||
break;
|
break;
|
||||||
case TGSI_TOKEN_TYPE_IMMEDIATE:
|
case TGSI_TOKEN_TYPE_IMMEDIATE:
|
||||||
handle_immediate(ttr, &parser.FullToken.FullImmediate);
|
handle_immediate(ttr, &parser.FullToken.FullImmediate, imm_index);
|
||||||
|
imm_index++;
|
||||||
break;
|
break;
|
||||||
case TGSI_TOKEN_TYPE_INSTRUCTION:
|
case TGSI_TOKEN_TYPE_INSTRUCTION:
|
||||||
transform_instruction(ttr, &parser.FullToken.FullInstruction);
|
transform_instruction(ttr, &parser.FullToken.FullInstruction);
|
||||||
|
|||||||
@@ -29,11 +29,18 @@ struct tgsi_full_declaration;
|
|||||||
struct tgsi_shader_info;
|
struct tgsi_shader_info;
|
||||||
struct tgsi_token;
|
struct tgsi_token;
|
||||||
|
|
||||||
|
struct swizzled_imms {
|
||||||
|
unsigned index;
|
||||||
|
unsigned swizzle;
|
||||||
|
};
|
||||||
|
|
||||||
struct tgsi_to_rc {
|
struct tgsi_to_rc {
|
||||||
struct radeon_compiler * compiler;
|
struct radeon_compiler * compiler;
|
||||||
const struct tgsi_shader_info * info;
|
const struct tgsi_shader_info * info;
|
||||||
|
|
||||||
int immediate_offset;
|
int immediate_offset;
|
||||||
|
struct swizzled_imms imms_to_swizzle[10];
|
||||||
|
unsigned imms_to_swizzle_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens);
|
void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens);
|
||||||
|
|||||||
Reference in New Issue
Block a user