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

r300g: eliminate unused constants in VS

parent 62eb9eda
...@@ -254,6 +254,8 @@ struct r300_ztop_state { ...@@ -254,6 +254,8 @@ struct r300_ztop_state {
struct r300_constant_buffer { struct r300_constant_buffer {
/* Buffer of constants */ /* Buffer of constants */
uint32_t *ptr; uint32_t *ptr;
/* Remapping table. */
unsigned *remap_table;
}; };
/* Query object. /* Query object.
......
...@@ -961,6 +961,7 @@ void r300_emit_vs_constants(struct r300_context* r300, ...@@ -961,6 +961,7 @@ void r300_emit_vs_constants(struct r300_context* r300,
unsigned count = unsigned count =
((struct r300_vertex_shader*)r300->vs_state.state)->externals_count; ((struct r300_vertex_shader*)r300->vs_state.state)->externals_count;
struct r300_constant_buffer *buf = (struct r300_constant_buffer*)state; struct r300_constant_buffer *buf = (struct r300_constant_buffer*)state;
unsigned i;
CS_LOCALS(r300); CS_LOCALS(r300);
if (!count) if (!count)
...@@ -971,7 +972,14 @@ void r300_emit_vs_constants(struct r300_context* r300, ...@@ -971,7 +972,14 @@ void r300_emit_vs_constants(struct r300_context* r300,
(r300->screen->caps.is_r500 ? (r300->screen->caps.is_r500 ?
R500_PVS_CONST_START : R300_PVS_CONST_START)); R500_PVS_CONST_START : R300_PVS_CONST_START));
OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, count * 4); OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, count * 4);
OUT_CS_TABLE(buf->ptr, count * 4); if (buf->remap_table){
for (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;
} }
......
...@@ -431,9 +431,8 @@ static void r300_translate_fragment_shader( ...@@ -431,9 +431,8 @@ static void r300_translate_fragment_shader(
} }
if (compiler.Base.Error) { if (compiler.Base.Error) {
DBG(r300, DBG_FP, "r300 FP: Compiler Error:\n%sUsing a dummy shader" fprintf(stderr, "r300 FP: Compiler Error:\n%sUsing a dummy shader"
" instead.\nIf there's an 'unknown opcode' message, please" " instead.\n", compiler.Base.ErrorMsg);
" file a bug report and attach this log.\n", compiler.Base.ErrorMsg);
if (shader->dummy) { if (shader->dummy) {
fprintf(stderr, "r300 FP: Cannot compile the dummy shader! " fprintf(stderr, "r300 FP: Cannot compile the dummy shader! "
......
...@@ -1765,6 +1765,9 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) ...@@ -1765,6 +1765,9 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
r300->vs_constants.size = 0; r300->vs_constants.size = 0;
} }
((struct r300_constant_buffer*)r300->vs_constants.state)->remap_table =
vs->code.constants_remap_table;
r300->pvs_flush.dirty = TRUE; r300->pvs_flush.dirty = TRUE;
} else { } else {
draw_bind_vertex_shader(r300->draw, draw_bind_vertex_shader(r300->draw,
...@@ -1779,6 +1782,8 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader) ...@@ -1779,6 +1782,8 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
if (r300->screen->caps.has_tcl) { if (r300->screen->caps.has_tcl) {
rc_constants_destroy(&vs->code.constants); rc_constants_destroy(&vs->code.constants);
if (vs->code.constants_remap_table)
FREE(vs->code.constants_remap_table);
} else { } else {
draw_delete_vertex_shader(r300->draw, draw_delete_vertex_shader(r300->draw,
(struct draw_vertex_shader*)vs->draw_vs); (struct draw_vertex_shader*)vs->draw_vs);
......
...@@ -196,6 +196,7 @@ void r300_translate_vertex_shader(struct r300_context *r300, ...@@ -196,6 +196,7 @@ void r300_translate_vertex_shader(struct r300_context *r300,
{ {
struct r300_vertex_program_compiler compiler; struct r300_vertex_program_compiler compiler;
struct tgsi_to_rc ttr; struct tgsi_to_rc ttr;
unsigned i;
/* Setup the compiler */ /* Setup the compiler */
rc_init(&compiler.Base); rc_init(&compiler.Base);
...@@ -205,6 +206,7 @@ void r300_translate_vertex_shader(struct r300_context *r300, ...@@ -205,6 +206,7 @@ void r300_translate_vertex_shader(struct r300_context *r300,
compiler.UserData = vs; compiler.UserData = vs;
compiler.Base.is_r500 = r300->screen->caps.is_r500; compiler.Base.is_r500 = r300->screen->caps.is_r500;
compiler.Base.max_temp_regs = 32; compiler.Base.max_temp_regs = 32;
compiler.Base.remove_unused_constants = TRUE;
if (compiler.Base.Debug) { if (compiler.Base.Debug) {
DBG(r300, DBG_VP, "r300: Initial vertex program\n"); DBG(r300, DBG_VP, "r300: Initial vertex program\n");
...@@ -227,9 +229,8 @@ void r300_translate_vertex_shader(struct r300_context *r300, ...@@ -227,9 +229,8 @@ void r300_translate_vertex_shader(struct r300_context *r300,
/* Invoke the compiler */ /* Invoke the compiler */
r3xx_compile_vertex_program(&compiler); r3xx_compile_vertex_program(&compiler);
if (compiler.Base.Error) { if (compiler.Base.Error) {
DBG(r300, DBG_VP, "r300 VP: Compiler error:\n%sUsing a dummy shader" fprintf(stderr, "r300 VP: Compiler error:\n%sUsing a dummy shader"
" instead.\nIf there's an 'unknown opcode' message, please" " instead.\n", compiler.Base.ErrorMsg);
" file a bug report and attach this log.\n", compiler.Base.ErrorMsg);
if (vs->dummy) { if (vs->dummy) {
fprintf(stderr, "r300 VP: Cannot compile the dummy shader! " fprintf(stderr, "r300 VP: Cannot compile the dummy shader! "
...@@ -243,7 +244,15 @@ void r300_translate_vertex_shader(struct r300_context *r300, ...@@ -243,7 +244,15 @@ void r300_translate_vertex_shader(struct r300_context *r300,
} }
/* Initialize numbers of constants for each type. */ /* Initialize numbers of constants for each type. */
vs->externals_count = ttr.immediate_offset; vs->externals_count = 0;
for (i = 0;
i < vs->code.constants.Count &&
vs->code.constants.Constants[i].Type == RC_CONSTANT_EXTERNAL; i++) {
vs->externals_count = i+1;
}
for (; i < vs->code.constants.Count; i++) {
assert(vs->code.constants.Constants[i].Type == RC_CONSTANT_IMMEDIATE);
}
vs->immediates_count = vs->code.constants.Count - vs->externals_count; vs->immediates_count = vs->code.constants.Count - vs->externals_count;
/* And, finally... */ /* And, finally... */
......
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