diff options
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 22 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.c | 33 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_reg.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state_derived.c | 48 |
4 files changed, 97 insertions, 8 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index aaab1dd2bcb..5247901be5b 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -75,6 +75,13 @@ struct r300_rs_state { uint32_t line_stipple_value; /* R300_GA_LINE_STIPPLE_VALUE: 0x4260 */ }; +struct r300_rs_block { + uint32_t ip[8]; /* R300_RS_IP_[0-7], R500_RS_IP_[0-7] */ + uint32_t count; /* R300_RS_COUNT */ + uint32_t inst_count; /* R300_RS_INST_COUNT */ + uint32_t inst[8]; /* R300_RS_INST_[0-7] */ +}; + struct r300_sampler_state { uint32_t filter0; /* R300_TX_FILTER0: 0x4400 */ uint32_t filter1; /* R300_TX_FILTER1: 0x4440 */ @@ -96,12 +103,13 @@ struct r300_texture_state { #define R300_NEW_FRAMEBUFFERS 0x0000010 #define R300_NEW_FRAGMENT_SHADER 0x0000020 #define R300_NEW_RASTERIZER 0x0000040 -#define R300_NEW_SAMPLER 0x0000080 -#define R300_NEW_SCISSOR 0x0008000 -#define R300_NEW_TEXTURE 0x0010000 -#define R300_NEW_VERTEX_FORMAT 0x1000000 -#define R300_NEW_VERTEX_SHADER 0x2000000 -#define R300_NEW_KITCHEN_SINK 0x3ffffff +#define R300_NEW_RS_BLOCK 0x0000080 +#define R300_NEW_SAMPLER 0x0000100 +#define R300_NEW_SCISSOR 0x0010000 +#define R300_NEW_TEXTURE 0x0020000 +#define R300_NEW_VERTEX_FORMAT 0x2000000 +#define R300_NEW_VERTEX_SHADER 0x4000000 +#define R300_NEW_KITCHEN_SINK 0x7ffffff /* The next several objects are not pure Radeon state; they inherit from * various Gallium classes. */ @@ -224,6 +232,8 @@ struct r300_context { struct pipe_framebuffer_state framebuffer_state; /* Rasterizer state. */ struct r300_rs_state* rs_state; + /* RS block state. */ + struct r300_rs_block* rs_block; /* Sampler states. */ struct r300_sampler_state* sampler_states[8]; int sampler_count; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 960f45f651f..86fa46df42c 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -208,6 +208,39 @@ void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs) END_CS; } +void r300_emit_rs_block_state(struct r300_context* r300, + struct r300_rs_block* rs) +{ + struct r300_screen* r300screen = + (struct r300_screen*)r300->context.screen; + CS_LOCALS(r300); + int i; + + BEGIN_CS(0); + if (r300screen->caps->is_r500) { + OUT_CS_REG_SEQ(R500_RS_IP_0, 8); + } else { + OUT_CS_REG_SEQ(R300_RS_IP_0, 8); + } + for (i = 0; i < 8; i++) { + OUT_CS(rs->ip[i]); + } + + OUT_CS_REG_SEQ(R300_RS_COUNT, 2); + OUT_CS(rs->count); + OUT_CS(rs->inst_count); + + if (r300screen->caps->is_r500) { + OUT_CS_REG_SEQ(R500_RS_INST_0, 8); + } else { + OUT_CS_REG_SEQ(R300_RS_INST_0, 8); + } + for (i = 0; i < 8; i++) { + OUT_CS(rs->inst[i]); + } + END_CS; +} + void r300_emit_scissor_state(struct r300_context* r300, struct r300_scissor_state* scissor) { diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index 8888b39a2f9..8f31bd5d6e0 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -1240,9 +1240,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define R300_RS_INST_7 0x434C # define R300_RS_INST_TEX_ID(x) ((x) << 0) # define R300_RS_INST_TEX_CN_WRITE (1 << 3) +# define R300_RS_INST_TEX_ADDR(x) ((x) << 6) # define R300_RS_INST_TEX_ADDR_SHIFT 6 # define R300_RS_INST_COL_ID(x) ((x) << 11) # define R300_RS_INST_COL_CN_WRITE (1 << 14) +# define R300_RS_INST_COL_ADDR(x) ((x) << 17) # define R300_RS_INST_COL_ADDR_SHIFT 17 # define R300_RS_INST_TEX_ADJ (1 << 22) # define R300_RS_COL_BIAS_UNUSED_SHIFT 23 diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 4284a955abf..c4f56627c3d 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -139,7 +139,7 @@ static void r300_update_vertex_layout(struct r300_context* r300) } for (i = 0; i < texs; i++) { - draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR, + draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i)); vinfo.hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i); vinfo.hwfmt[3] |= (4 << (3 * i)); @@ -159,7 +159,9 @@ static void r300_update_vertex_layout(struct r300_context* r300) for (i = 0; i < vinfo.num_attribs; i++) { /* Make sure we have a proper destination for our attribute */ - //assert(tab[i] != -1); + if (tab[i] != -1) { + assert(0); + } temp = translate_vertex_data_type(vinfo.attrib[i].emit) | (tab[i] << R300_DST_VEC_LOC_SHIFT) | R300_SIGNED; @@ -189,6 +191,48 @@ static void r300_update_vertex_layout(struct r300_context* r300) * chipset that locks up if any part of it is even slightly wrong. */ static void r300_update_rs_block(struct r300_context* r300) { + struct r300_rs_block* rs = r300->rs_block; + struct vertex_info* vinfo = &r300->vertex_info.vinfo; + int col_count = 0, fp_offset = 0, i, tex_count = 0; + + memset(rs, 0, sizeof(struct r300_rs_block)); + + for (i = 0; i < vinfo->num_attribs; i++) { + switch (vinfo->attrib[i].interp_mode) { + case INTERP_LINEAR: + rs->ip[col_count] |= + R300_RS_COL_PTR(vinfo->attrib[i].src_index) | + R300_RS_COL_FMT(R300_RS_COL_FMT_RGBA); + col_count++; + break; + case INTERP_PERSPECTIVE: + rs->ip[tex_count] |= + R300_RS_TEX_PTR(vinfo->attrib[i].src_index) | + R300_RS_SEL_S(R300_RS_SEL_C0) | + R300_RS_SEL_T(R300_RS_SEL_C1) | + R300_RS_SEL_R(R300_RS_SEL_C2) | + R300_RS_SEL_Q(R300_RS_SEL_C3); + tex_count += 4; + break; + } + } + + for (i = 0; i < tex_count; i++) { + rs->inst[i] |= R300_RS_INST_TEX_ID(i) | R300_RS_INST_TEX_CN_WRITE | + R300_RS_INST_TEX_ADDR(fp_offset); + fp_offset++; + } + + for (i = 0; i < col_count; i++) { + rs->inst[i] |= R300_RS_INST_COL_ID(i) | R300_RS_INST_COL_CN_WRITE | + R300_RS_INST_COL_ADDR(fp_offset); + fp_offset++; + } + + rs->count = (tex_count * 4) | (col_count << R300_IC_COUNT_SHIFT) | + R300_HIRES_EN; + + rs->inst_count = MAX2(col_count, tex_count); } void r300_update_derived_state(struct r300_context* r300) |