summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2010-04-14 02:21:06 +0200
committerMarek Olšák <[email protected]>2010-04-14 04:48:19 +0200
commitabc2f29dd2baa9c8aa672f07a1500e579364ab29 (patch)
tree6c96dc9ecc804b517dda331c010dc11b22220b51 /src/gallium
parent6793506faa13c259b1f36fb4cbe21841f851e248 (diff)
r300g: emit VS immediates along with VS code
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/r300/r300_emit.c32
-rw-r--r--src/gallium/drivers/r300/r300_state.c4
-rw-r--r--src/gallium/drivers/r300/r300_vs.c4
-rw-r--r--src/gallium/drivers/r300/r300_vs.h4
4 files changed, 37 insertions, 7 deletions
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index ce5023c2141..b337cd96036 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -977,6 +977,10 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state)
vtx_mem_size / output_count, 10);
unsigned pvs_num_controllers = MIN2(vtx_mem_size / temp_count, 6);
+ unsigned imm_first = vs->externals_count;
+ unsigned imm_end = vs->code.constants.Count;
+ unsigned imm_count = vs->immediates_count;
+
CS_LOCALS(r300);
BEGIN_CS(size);
@@ -1002,6 +1006,22 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state)
R300_PVS_NUM_FPUS(r300screen->caps.num_vert_fpus) |
R300_PVS_VF_MAX_VTX_NUM(12) |
(r300screen->caps.is_r500 ? R500_TCL_STATE_OPTIMIZATION : 0));
+
+ /* Emit immediates. */
+ if (imm_count) {
+ OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
+ (r300->screen->caps.is_r500 ?
+ R500_PVS_CONST_START : R300_PVS_CONST_START) +
+ imm_first);
+ OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, imm_count * 4);
+ for (i = imm_first; i < imm_end; i++) {
+ const float *data = vs->code.constants.Constants[i].u.Immediate;
+ OUT_CS_32F(data[0]);
+ OUT_CS_32F(data[1]);
+ OUT_CS_32F(data[2]);
+ OUT_CS_32F(data[3]);
+ }
+ }
END_CS;
}
@@ -1009,17 +1029,17 @@ void r300_emit_vs_constant_buffer(struct r300_context* r300,
struct rc_constant_list* constants)
{
unsigned i;
+ unsigned count = ((struct r300_vertex_shader*)r300->vs_state.state)->externals_count;
CS_LOCALS(r300);
- BEGIN_CS(constants->Count * 4 + 3);
+ BEGIN_CS(count * 4 + 3);
OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
(r300->screen->caps.is_r500 ?
R500_PVS_CONST_START : R300_PVS_CONST_START));
- OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, constants->Count * 4);
- for (i = 0; i < constants->Count; i++) {
- const float *data = get_shader_constant(r300,
- &constants->Constants[i],
- &r300->shader_constants[PIPE_SHADER_VERTEX]);
+ OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, count * 4);
+ for (i = 0; i < count; i++) {
+ const float *data =
+ r300->shader_constants[PIPE_SHADER_VERTEX].constants[i];
OUT_CS_32F(data[0]);
OUT_CS_32F(data[1]);
OUT_CS_32F(data[2]);
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 0cb102359df..a732ef3a104 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -1379,7 +1379,9 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
if (r300->screen->caps.has_tcl) {
r300->vs_state.dirty = TRUE;
- r300->vs_state.size = vs->code.length + 9;
+ r300->vs_state.size =
+ vs->code.length + 9 +
+ (vs->immediates_count ? vs->immediates_count * 4 + 3 : 0);
r300->pvs_flush.dirty = TRUE;
diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c
index 2f9ee76bd89..8137972f018 100644
--- a/src/gallium/drivers/r300/r300_vs.c
+++ b/src/gallium/drivers/r300/r300_vs.c
@@ -333,6 +333,10 @@ void r300_translate_vertex_shader(struct r300_context* r300,
r300_dummy_vertex_shader(r300, vs);
}
+ /* Initialize numbers of constants for each type. */
+ vs->externals_count = ttr.immediate_offset;
+ vs->immediates_count = vs->code.constants.Count - vs->externals_count;
+
/* And, finally... */
rc_destroy(&compiler.Base);
}
diff --git a/src/gallium/drivers/r300/r300_vs.h b/src/gallium/drivers/r300/r300_vs.h
index 261c31ee2f5..56bcc3b70b8 100644
--- a/src/gallium/drivers/r300/r300_vs.h
+++ b/src/gallium/drivers/r300/r300_vs.h
@@ -45,6 +45,10 @@ struct r300_vertex_shader {
* compilation failure. */
boolean dummy;
+ /* Numbers of constants for each type. */
+ unsigned externals_count;
+ unsigned immediates_count;
+
/* Stream locations for SWTCL or if TCL is bypassed. */
int stream_loc_notcl[16];