summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/r300/r300_state_derived.c
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2010-02-28 07:45:56 +0100
committerMarek Olšák <maraeo@gmail.com>2010-02-28 19:30:39 +0100
commit942762cd973af0df75040de21d3321cd19829e70 (patch)
treeb7700f3c2cf71e52fa671cc8b102c29825baf2bf /src/gallium/drivers/r300/r300_state_derived.c
parent79a86d312d8b3bc2e4fa28734467400e0b050301 (diff)
r300g: decouple vertex stream setup (PSC) and VS output mapping (VAP_OUT)
Formerly known as vertex_format_state. These two are completely unrelated when using HWTCL and decoupling them makes the design less SWTCL-centric. When bypass_vs_clip_and_viewport gets removed, the PSC setup will no longer be a derived state. This change shouldn't make unbreaking SWTCL harder.
Diffstat (limited to 'src/gallium/drivers/r300/r300_state_derived.c')
-rw-r--r--src/gallium/drivers/r300/r300_state_derived.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
index 86301e23d7..0574d98e07 100644
--- a/src/gallium/drivers/r300/r300_state_derived.c
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -49,9 +49,7 @@ static void r300_draw_emit_attrib(struct r300_context* r300,
output = draw_find_shader_output(r300->draw,
info->output_semantic_name[index],
info->output_semantic_index[index]);
- draw_emit_vertex_attr(
- (struct vertex_info*)r300->vertex_format_state.state,
- emit, interp, output);
+ draw_emit_vertex_attr(&r300->vertex_info, emit, interp, output);
}
static void r300_draw_emit_all_attribs(struct r300_context* r300)
@@ -106,17 +104,21 @@ static void r300_draw_emit_all_attribs(struct r300_context* r300)
}
/* Update the PSC tables. */
+/* XXX move this function into r300_state.c after TCL-bypass gets removed
+ * XXX because this one is dependent only on vertex elements. */
static void r300_vertex_psc(struct r300_context* r300)
{
struct r300_vertex_shader* vs = r300->vs_state.state;
- struct r300_vertex_info *vformat =
- (struct r300_vertex_info*)r300->vertex_format_state.state;
+ struct r300_vertex_stream_state *vformat =
+ (struct r300_vertex_stream_state*)r300->vertex_stream_state.state;
uint16_t type, swizzle;
enum pipe_format format;
unsigned i;
int identity[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
int* stream_tab;
+ memset(vformat, 0, sizeof(struct r300_vertex_stream_state));
+
/* If TCL is bypassed, map vertex streams to equivalent VS output
* locations. */
if (r300->tcl_bypass) {
@@ -157,20 +159,25 @@ static void r300_vertex_psc(struct r300_context* r300)
}
vformat->vap_prog_stream_cntl[i >> 1] |=
(R300_LAST_VEC << (i & 1 ? 16 : 0));
+
+ vformat->count = (i >> 1) + 1;
+ r300->vertex_stream_state.size = (1 + vformat->count) * 2;
}
/* Update the PSC tables for SW TCL, using Draw. */
static void r300_swtcl_vertex_psc(struct r300_context* r300)
{
struct r300_vertex_shader* vs = r300->vs_state.state;
- struct r300_vertex_info *vformat =
- (struct r300_vertex_info*)r300->vertex_format_state.state;
- struct vertex_info* vinfo = &vformat->vinfo;
+ struct r300_vertex_stream_state *vformat =
+ (struct r300_vertex_stream_state*)r300->vertex_stream_state.state;
+ struct vertex_info* vinfo = &r300->vertex_info;
uint16_t type, swizzle;
enum pipe_format format;
unsigned i, attrib_count;
int* vs_output_tab = vs->stream_loc_notcl;
+ memset(vformat, 0, sizeof(struct r300_vertex_stream_state));
+
/* For each Draw attribute, route it to the fragment shader according
* to the vs_output_tab. */
attrib_count = vinfo->num_attribs;
@@ -212,6 +219,9 @@ static void r300_swtcl_vertex_psc(struct r300_context* r300)
}
vformat->vap_prog_stream_cntl[i >> 1] |=
(R300_LAST_VEC << (i & 1 ? 16 : 0));
+
+ vformat->count = (i >> 1) + 1;
+ r300->vertex_stream_state.size = (1 + vformat->count) * 2;
}
static void r300_rs_col(struct r300_rs_block* rs, int id, int ptr,
@@ -430,13 +440,12 @@ static void r300_update_derived_shader_state(struct r300_context* r300)
{
struct r300_vertex_shader* vs = r300->vs_state.state;
struct r300_screen* r300screen = r300_screen(r300->context.screen);
- struct r300_vertex_info *vformat =
- (struct r300_vertex_info*)r300->vertex_format_state.state;
- struct vertex_info* vinfo = &vformat->vinfo;
+ struct r300_vap_output_state *vap_out =
+ (struct r300_vap_output_state*)r300->vap_output_state.state;
- /* Mmm, delicious hax */
- memset(r300->vertex_format_state.state, 0, sizeof(struct r300_vertex_info));
- memcpy(vinfo->hwfmt, vs->hwfmt, sizeof(uint)*4);
+ /* XXX Mmm, delicious hax */
+ memset(&r300->vertex_info, 0, sizeof(struct vertex_info));
+ memcpy(vap_out, vs->hwfmt, sizeof(uint)*4);
r300_update_rs_block(r300, &vs->outputs, &r300->fs->inputs);
@@ -444,8 +453,7 @@ static void r300_update_derived_shader_state(struct r300_context* r300)
r300_vertex_psc(r300);
} else {
r300_draw_emit_all_attribs(r300);
- draw_compute_vertex_size(
- (struct vertex_info*)r300->vertex_format_state.state);
+ draw_compute_vertex_size(&r300->vertex_info);
r300_swtcl_vertex_psc(r300);
}
}
@@ -523,10 +531,9 @@ static void r300_update_ztop(struct r300_context* r300)
void r300_update_derived_state(struct r300_context* r300)
{
- /* XXX */
- if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER ||
- r300->vs_state.dirty || r300->vertex_format_state.dirty ||
- r300->rs_state.dirty) {
+ if (r300->rs_block_state.dirty ||
+ r300->vertex_stream_state.dirty || /* XXX put updating this state out of this file */
+ r300->rs_state.dirty) { /* XXX and remove this one (tcl_bypass dependency) */
r300_update_derived_shader_state(r300);
}