Commit 0a21938d authored by Marek Olšák's avatar Marek Olšák
Browse files

r300g: eliminate unused constants in FS

parent abae06ac
...@@ -180,9 +180,18 @@ void r300_emit_fs_constants(struct r300_context* r300, unsigned size, void *stat ...@@ -180,9 +180,18 @@ void r300_emit_fs_constants(struct r300_context* r300, unsigned size, void *stat
BEGIN_CS(size); BEGIN_CS(size);
OUT_CS_REG_SEQ(R300_PFS_PARAM_0_X, count * 4); OUT_CS_REG_SEQ(R300_PFS_PARAM_0_X, count * 4);
for (i = 0; i < count; i++) if (buf->remap_table){
for (j = 0; j < 4; j++) for (i = 0; i < count; i++) {
OUT_CS(pack_float24(*(float*)&buf->ptr[i*4+j])); uint32_t *data = &buf->ptr[buf->remap_table[i]*4];
for (j = 0; j < 4; j++)
OUT_CS(pack_float24(data[j]));
}
} else {
for (i = 0; i < count; i++)
for (j = 0; j < 4; j++)
OUT_CS(pack_float24(*(float*)&buf->ptr[i*4+j]));
}
END_CS; END_CS;
} }
...@@ -226,7 +235,7 @@ void r500_emit_fs_constants(struct r300_context* r300, unsigned size, void *stat ...@@ -226,7 +235,7 @@ void r500_emit_fs_constants(struct r300_context* r300, unsigned size, void *stat
{ {
struct r300_fragment_shader *fs = r300_fs(r300); struct r300_fragment_shader *fs = r300_fs(r300);
struct r300_constant_buffer *buf = (struct r300_constant_buffer*)state; struct r300_constant_buffer *buf = (struct r300_constant_buffer*)state;
unsigned count = fs->shader->externals_count * 4; unsigned count = fs->shader->externals_count;
CS_LOCALS(r300); CS_LOCALS(r300);
if (count == 0) if (count == 0)
...@@ -234,8 +243,15 @@ void r500_emit_fs_constants(struct r300_context* r300, unsigned size, void *stat ...@@ -234,8 +243,15 @@ void r500_emit_fs_constants(struct r300_context* r300, unsigned size, void *stat
BEGIN_CS(size); BEGIN_CS(size);
OUT_CS_REG(R500_GA_US_VECTOR_INDEX, R500_GA_US_VECTOR_INDEX_TYPE_CONST); OUT_CS_REG(R500_GA_US_VECTOR_INDEX, R500_GA_US_VECTOR_INDEX_TYPE_CONST);
OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, count); OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, count * 4);
OUT_CS_TABLE(buf->ptr, count); if (buf->remap_table){
for (unsigned i = 0; i < count; i++) {
uint32_t *data = &buf->ptr[buf->remap_table[i]*4];
OUT_CS_TABLE(data, 4);
}
} else {
OUT_CS_TABLE(buf->ptr, count * 4);
}
END_CS; END_CS;
} }
......
...@@ -386,6 +386,7 @@ static void r300_translate_fragment_shader( ...@@ -386,6 +386,7 @@ static void r300_translate_fragment_shader(
compiler.state = shader->compare_state; compiler.state = shader->compare_state;
compiler.Base.is_r500 = r300->screen->caps.is_r500; compiler.Base.is_r500 = r300->screen->caps.is_r500;
compiler.Base.max_temp_regs = compiler.Base.is_r500 ? 128 : 32; compiler.Base.max_temp_regs = compiler.Base.is_r500 ? 128 : 32;
compiler.Base.remove_unused_constants = TRUE;
compiler.AllocateHwInputs = &allocate_hardware_inputs; compiler.AllocateHwInputs = &allocate_hardware_inputs;
compiler.UserData = &shader->inputs; compiler.UserData = &shader->inputs;
...@@ -446,7 +447,12 @@ static void r300_translate_fragment_shader( ...@@ -446,7 +447,12 @@ static void r300_translate_fragment_shader(
} }
/* Initialize numbers of constants for each type. */ /* Initialize numbers of constants for each type. */
shader->externals_count = ttr.immediate_offset; shader->externals_count = 0;
for (i = 0;
i < shader->code.constants.Count &&
shader->code.constants.Constants[i].Type == RC_CONSTANT_EXTERNAL; i++) {
shader->externals_count = i+1;
}
shader->immediates_count = 0; shader->immediates_count = 0;
shader->rc_state_count = 0; shader->rc_state_count = 0;
......
...@@ -865,6 +865,9 @@ void r300_mark_fs_code_dirty(struct r300_context *r300) ...@@ -865,6 +865,9 @@ void r300_mark_fs_code_dirty(struct r300_context *r300)
r300->fs_rc_constant_state.size = fs->shader->rc_state_count * 5; r300->fs_rc_constant_state.size = fs->shader->rc_state_count * 5;
r300->fs_constants.size = fs->shader->externals_count * 4 + 1; r300->fs_constants.size = fs->shader->externals_count * 4 + 1;
} }
((struct r300_constant_buffer*)r300->fs_constants.state)->remap_table =
fs->shader->code.constants_remap_table;
} }
/* Bind fragment shader state. */ /* Bind fragment shader state. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment