summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2009-05-18 17:06:42 -0700
committerCorbin Simpson <MostAwesomeDude@gmail.com>2009-07-08 11:39:34 -0700
commit746140e215b86ec6eb9f10be45babe700f8e2e62 (patch)
treeaf672f6d24ed5a1c76b7c054fd222777279e00e2
parent1aa38b2c2d80b67fe2eefe468f90aeb44bc20259 (diff)
r300-gallium: Unify sampler and texture emit.
They have to cross into each other's registers.
-rw-r--r--src/gallium/drivers/r300/r300_emit.c50
-rw-r--r--src/gallium/drivers/r300/r300_emit.h7
-rw-r--r--src/gallium/drivers/r300/r300_surface.c8
3 files changed, 26 insertions, 39 deletions
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 45f9ec090d..7ba56cdc1d 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -289,18 +289,6 @@ void r300_emit_rs_block_state(struct r300_context* r300,
END_CS;
}
-void r300_emit_sampler(struct r300_context* r300,
- struct r300_sampler_state* sampler, unsigned offset)
-{
- CS_LOCALS(r300);
-
- BEGIN_CS(6);
- OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->filter0);
- OUT_CS_REG(R300_TX_FILTER1_0 + (offset * 4), sampler->filter1);
- OUT_CS_REG(R300_TX_BORDER_COLOR_0 + (offset * 4), sampler->border_color);
- END_CS;
-}
-
void r300_emit_scissor_state(struct r300_context* r300,
struct r300_scissor_state* scissor)
{
@@ -314,11 +302,17 @@ void r300_emit_scissor_state(struct r300_context* r300,
}
void r300_emit_texture(struct r300_context* r300,
- struct r300_texture* tex, unsigned offset)
+ struct r300_sampler_state* sampler,
+ struct r300_texture* tex,
+ unsigned offset)
{
CS_LOCALS(r300);
- BEGIN_CS(10);
+ BEGIN_CS(16);
+ OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->filter0);
+ OUT_CS_REG(R300_TX_FILTER1_0 + (offset * 4), sampler->filter1);
+ OUT_CS_REG(R300_TX_BORDER_COLOR_0 + (offset * 4), sampler->border_color);
+
OUT_CS_REG(R300_TX_FORMAT0_0 + (offset * 4), tex->state.format0);
OUT_CS_REG(R300_TX_FORMAT1_0 + (offset * 4), tex->state.format1);
OUT_CS_REG(R300_TX_FORMAT2_0 + (offset * 4), tex->state.format2);
@@ -593,29 +587,27 @@ validate:
r300->dirty_state &= ~R300_NEW_RS_BLOCK;
}
- if (r300->dirty_state & R300_ANY_NEW_SAMPLERS) {
- for (i = 0; i < r300->sampler_count; i++) {
- if (r300->dirty_state & (R300_NEW_SAMPLER << i)) {
- r300_emit_sampler(r300, r300->sampler_states[i], i);
- dirty_tex++;
- }
- }
- r300->dirty_state &= ~R300_ANY_NEW_SAMPLERS;
- }
-
if (r300->dirty_state & R300_NEW_SCISSOR) {
r300_emit_scissor_state(r300, r300->scissor_state);
r300->dirty_state &= ~R300_NEW_SCISSOR;
}
- if (r300->dirty_state & R300_ANY_NEW_TEXTURES) {
- for (i = 0; i < r300->texture_count; i++) {
- if (r300->dirty_state & (R300_NEW_TEXTURE << i)) {
- r300_emit_texture(r300, r300->textures[i], i);
+ /* Samplers and textures are tracked separately but emitted together. */
+ if (r300->dirty_state &
+ (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) {
+ for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) {
+ if (r300->dirty_state &
+ ((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) {
+ r300_emit_texture(r300,
+ r300->sampler_states[i],
+ r300->textures[i],
+ i);
+ r300->dirty_state &=
+ ~((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i));
dirty_tex++;
}
}
- r300->dirty_state &= ~R300_ANY_NEW_TEXTURES;
+ r300->dirty_state &= ~(R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES);
}
if (r300->dirty_state & R300_NEW_VIEWPORT) {
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
index 196b6c58d3..fda26f3948 100644
--- a/src/gallium/drivers/r300/r300_emit.h
+++ b/src/gallium/drivers/r300/r300_emit.h
@@ -56,14 +56,13 @@ void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs);
void r300_emit_rs_block_state(struct r300_context* r300,
struct r300_rs_block* rs);
-void r300_emit_sampler(struct r300_context* r300,
- struct r300_sampler_state* sampler, unsigned offset);
-
void r300_emit_scissor_state(struct r300_context* r300,
struct r300_scissor_state* scissor);
void r300_emit_texture(struct r300_context* r300,
- struct r300_texture* tex, unsigned offset);
+ struct r300_sampler_state* sampler,
+ struct r300_texture* tex,
+ unsigned offset);
void r300_emit_vertex_buffer(struct r300_context* r300);
diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c
index 96b9a83383..fdabe4d9cf 100644
--- a/src/gallium/drivers/r300/r300_surface.c
+++ b/src/gallium/drivers/r300/r300_surface.c
@@ -268,14 +268,10 @@ validate:
r300_surface_setup(r300, desttex, destx, desty, w, h);
/* Setup the texture. */
- r300_emit_sampler(r300, &r300_sampler_copy_state, 0);
- r300_emit_texture(r300, srctex, 0);
+ r300_emit_texture(r300, &r300_sampler_copy_state, srctex, 0);
/* Flush and enable. */
- BEGIN_CS(4);
- OUT_CS_REG(R300_TX_INVALTAGS, 0);
- OUT_CS_REG(R300_TX_ENABLE, 0x1);
- END_CS;
+ r300_flush_textures(r300);
/* Vertex shader setup */
if (caps->has_tcl) {