summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r300
diff options
context:
space:
mode:
authorAlex Deucher <[email protected]>2009-07-15 14:17:07 -0400
committerAlex Deucher <[email protected]>2009-07-15 14:17:07 -0400
commitc5c19919ce627b98d8aab4284da1694573bcccd4 (patch)
tree2e29b313b79b6a392e020fd5723e3cc00c800fd2 /src/gallium/drivers/r300
parenta0d4a12614fce072fa1eb5516e626909171c95e1 (diff)
parent3a3b83e5112b725e22f05b32a273a2351b820944 (diff)
Merge branch 'master' of git+ssh://[email protected]/git/mesa/mesa into r6xx-rewrite
This builds, but I get an assertion in radeonGetLock() due to the drawable being null.
Diffstat (limited to 'src/gallium/drivers/r300')
-rw-r--r--src/gallium/drivers/r300/Makefile6
-rw-r--r--src/gallium/drivers/r300/SConscript6
-rw-r--r--src/gallium/drivers/r300/r300_context.h17
-rw-r--r--src/gallium/drivers/r300/r300_debug.c54
-rw-r--r--src/gallium/drivers/r300/r300_debug.h17
-rw-r--r--src/gallium/drivers/r300/r300_emit.c62
-rw-r--r--src/gallium/drivers/r300/r300_emit.h11
-rw-r--r--src/gallium/drivers/r300/r300_flush.c6
-rw-r--r--src/gallium/drivers/r300/r300_flush.h2
-rw-r--r--src/gallium/drivers/r300/r300_fs.c109
-rw-r--r--src/gallium/drivers/r300/r300_fs.h36
-rw-r--r--src/gallium/drivers/r300/r300_fs_inlines.h158
-rw-r--r--src/gallium/drivers/r300/r300_query.h2
-rw-r--r--src/gallium/drivers/r300/r300_reg.h54
-rw-r--r--src/gallium/drivers/r300/r300_screen.c56
-rw-r--r--src/gallium/drivers/r300/r300_screen.h2
-rw-r--r--src/gallium/drivers/r300/r300_shader_inlines.h47
-rw-r--r--src/gallium/drivers/r300/r300_state.c29
-rw-r--r--src/gallium/drivers/r300/r300_state_invariant.c18
-rw-r--r--src/gallium/drivers/r300/r300_surface.c59
-rw-r--r--src/gallium/drivers/r300/r300_surface.h12
-rw-r--r--src/gallium/drivers/r300/r300_texture.c41
-rw-r--r--src/gallium/drivers/r300/r300_texture.h46
-rw-r--r--src/gallium/drivers/r300/r300_vs.c (renamed from src/gallium/drivers/r300/r300_state_tcl.c)4
-rw-r--r--src/gallium/drivers/r300/r300_vs.h (renamed from src/gallium/drivers/r300/r300_state_tcl.h)17
-rw-r--r--src/gallium/drivers/r300/r3xx_fs.c96
-rw-r--r--src/gallium/drivers/r300/r3xx_fs.h76
-rw-r--r--src/gallium/drivers/r300/r5xx_fs.c (renamed from src/gallium/drivers/r300/r300_state_shader.c)361
-rw-r--r--src/gallium/drivers/r300/r5xx_fs.h (renamed from src/gallium/drivers/r300/r300_state_shader.h)116
29 files changed, 901 insertions, 619 deletions
diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile
index e44f9b9dfc5..faceec9842f 100644
--- a/src/gallium/drivers/r300/Makefile
+++ b/src/gallium/drivers/r300/Makefile
@@ -4,20 +4,22 @@ include $(TOP)/configs/current
LIBNAME = r300
C_SOURCES = \
+ r3xx_fs.c \
+ r5xx_fs.c \
r300_chipset.c \
r300_clear.c \
r300_context.c \
r300_debug.c \
r300_emit.c \
r300_flush.c \
+ r300_fs.c \
r300_query.c \
r300_render.c \
r300_screen.c \
r300_state.c \
r300_state_derived.c \
r300_state_invariant.c \
- r300_state_shader.c \
- r300_state_tcl.c \
+ r300_vs.c \
r300_surface.c \
r300_texture.c
diff --git a/src/gallium/drivers/r300/SConscript b/src/gallium/drivers/r300/SConscript
index 182ed2d459a..493d7b28bc3 100644
--- a/src/gallium/drivers/r300/SConscript
+++ b/src/gallium/drivers/r300/SConscript
@@ -5,20 +5,22 @@ env = env.Clone()
r300 = env.ConvenienceLibrary(
target = 'r300',
source = [
+ 'r3xx_fs.c',
+ 'r5xx_fs.c',
'r300_chipset.c',
'r300_clear.c',
'r300_context.c',
'r300_debug.c',
'r300_emit.c',
'r300_flush.c',
+ 'r300_fs.c',
'r300_query.c',
'r300_render.c',
'r300_screen.c',
'r300_state.c',
'r300_state_derived.c',
'r300_state_invariant.c',
- 'r300_state_shader.c',
- 'r300_state_tcl.c',
+ 'r300_vs.c',
'r300_surface.c',
'r300_texture.c',
])
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 27bc7fd1a93..d891fd6265f 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -149,7 +149,7 @@ struct r300_constant_buffer {
unsigned count;
};
-struct r3xx_fragment_shader {
+struct r300_fragment_shader {
/* Parent class */
struct pipe_shader_state state;
struct tgsi_shader_info info;
@@ -165,9 +165,9 @@ struct r3xx_fragment_shader {
boolean uses_imms;
};
-struct r300_fragment_shader {
+struct r3xx_fragment_shader {
/* Parent class */
- struct r3xx_fragment_shader shader;
+ struct r300_fragment_shader shader;
/* Number of ALU instructions */
int alu_instruction_count;
@@ -190,9 +190,9 @@ struct r300_fragment_shader {
} instructions[64]; /* XXX magic num */
};
-struct r500_fragment_shader {
+struct r5xx_fragment_shader {
/* Parent class */
- struct r3xx_fragment_shader shader;
+ struct r300_fragment_shader shader;
/* Number of used instructions */
int instruction_count;
@@ -217,7 +217,7 @@ struct r300_texture {
/* Stride (pitch?) of this texture in bytes */
unsigned stride;
-
+
/* Total size of this texture, in bytes. */
unsigned size;
@@ -300,7 +300,7 @@ struct r300_context {
/* Depth, stencil, and alpha state. */
struct r300_dsa_state* dsa_state;
/* Fragment shader. */
- struct r3xx_fragment_shader* fs;
+ struct r300_fragment_shader* fs;
/* Framebuffer state. We currently don't need our own version of this. */
struct pipe_framebuffer_state framebuffer_state;
/* Rasterizer state. */
@@ -331,7 +331,8 @@ struct r300_context {
};
/* Convenience cast wrapper. */
-static struct r300_context* r300_context(struct pipe_context* context) {
+static INLINE struct r300_context* r300_context(struct pipe_context* context)
+{
return (struct r300_context*)context;
}
diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c
index 678cd2b8121..c83e8526cf7 100644
--- a/src/gallium/drivers/r300/r300_debug.c
+++ b/src/gallium/drivers/r300/r300_debug.c
@@ -22,7 +22,7 @@
#include "r300_debug.h"
-static void r300_dump_fs(struct r300_fragment_shader* fs)
+void r3xx_dump_fs(struct r3xx_fragment_shader* fs)
{
int i;
@@ -30,7 +30,7 @@ static void r300_dump_fs(struct r300_fragment_shader* fs)
}
}
-void r500_fs_dump(struct r500_fragment_shader* fs)
+void r5xx_fs_dump(struct r5xx_fragment_shader* fs)
{
int i;
uint32_t inst;
@@ -58,8 +58,8 @@ void r500_fs_dump(struct r500_fragment_shader* fs)
inst & R500_INST_NOP ? "NOP" : "",
inst & R500_INST_ALU_WAIT ? "ALU_WAIT" : "");
debug_printf("wmask: %s omask: %s\n",
- r500_fs_mask[(inst >> 11) & 0xf],
- r500_fs_mask[(inst >> 15) & 0xf]);
+ r5xx_fs_mask[(inst >> 11) & 0xf],
+ r5xx_fs_mask[(inst >> 15) & 0xf]);
switch (inst & 0x3) {
case R500_INST_TYPE_ALU:
case R500_INST_TYPE_OUT:
@@ -85,36 +85,36 @@ void r500_fs_dump(struct r500_fragment_shader* fs)
debug_printf(" 3: RGB_INST 0x%08x:", inst);
debug_printf("rgb_A_src:%d %s/%s/%s %d "
"rgb_B_src:%d %s/%s/%s %d\n",
- inst & 0x3, r500_fs_swiz[(inst >> 2) & 0x7],
- r500_fs_swiz[(inst >> 5) & 0x7],
- r500_fs_swiz[(inst >> 8) & 0x7],
+ inst & 0x3, r5xx_fs_swiz[(inst >> 2) & 0x7],
+ r5xx_fs_swiz[(inst >> 5) & 0x7],
+ r5xx_fs_swiz[(inst >> 8) & 0x7],
(inst >> 11) & 0x3, (inst >> 13) & 0x3,
- r500_fs_swiz[(inst >> 15) & 0x7],
- r500_fs_swiz[(inst >> 18) & 0x7],
- r500_fs_swiz[(inst >> 21) & 0x7],
+ r5xx_fs_swiz[(inst >> 15) & 0x7],
+ r5xx_fs_swiz[(inst >> 18) & 0x7],
+ r5xx_fs_swiz[(inst >> 21) & 0x7],
(inst >> 24) & 0x3);
inst = fs->instructions[i].inst4;
debug_printf(" 4: ALPHA_INST 0x%08x:", inst);
debug_printf("%s dest:%d%s alp_A_src:%d %s %d "
"alp_B_src:%d %s %d w:%d\n",
- r500_fs_op_alpha[inst & 0xf], (inst >> 4) & 0x7f,
+ r5xx_fs_op_alpha[inst & 0xf], (inst >> 4) & 0x7f,
inst & (1<<11) ? "(rel)":"", (inst >> 12) & 0x3,
- r500_fs_swiz[(inst >> 14) & 0x7], (inst >> 17) & 0x3,
- (inst >> 19) & 0x3, r500_fs_swiz[(inst >> 21) & 0x7],
+ r5xx_fs_swiz[(inst >> 14) & 0x7], (inst >> 17) & 0x3,
+ (inst >> 19) & 0x3, r5xx_fs_swiz[(inst >> 21) & 0x7],
(inst >> 24) & 0x3, (inst >> 31) & 0x1);
inst = fs->instructions[i].inst5;
debug_printf(" 5: RGBA_INST 0x%08x:", inst);
debug_printf("%s dest:%d%s rgb_C_src:%d %s/%s/%s %d "
"alp_C_src:%d %s %d\n",
- r500_fs_op_rgb[inst & 0xf], (inst >> 4) & 0x7f,
+ r5xx_fs_op_rgb[inst & 0xf], (inst >> 4) & 0x7f,
inst & (1 << 11) ? "(rel)":"", (inst >> 12) & 0x3,
- r500_fs_swiz[(inst >> 14) & 0x7],
- r500_fs_swiz[(inst >> 17) & 0x7],
- r500_fs_swiz[(inst >> 20) & 0x7],
+ r5xx_fs_swiz[(inst >> 14) & 0x7],
+ r5xx_fs_swiz[(inst >> 17) & 0x7],
+ r5xx_fs_swiz[(inst >> 20) & 0x7],
(inst >> 23) & 0x3, (inst >> 25) & 0x3,
- r500_fs_swiz[(inst >> 27) & 0x7], (inst >> 30) & 0x3);
+ r5xx_fs_swiz[(inst >> 27) & 0x7], (inst >> 30) & 0x3);
break;
case R500_INST_TYPE_FC:
/* XXX don't even bother yet */
@@ -124,7 +124,7 @@ void r500_fs_dump(struct r500_fragment_shader* fs)
debug_printf(" 1: TEX_INST 0x%08x: id: %d "
"op:%s, %s, %s %s\n",
inst, (inst >> 16) & 0xf,
- r500_fs_tex[(inst >> 22) & 0x7],
+ r5xx_fs_tex[(inst >> 22) & 0x7],
(inst & (1 << 25)) ? "ACQ" : "",
(inst & (1 << 26)) ? "IGNUNC" : "",
(inst & (1 << 27)) ? "UNSCALED" : "SCALED");
@@ -133,15 +133,15 @@ void r500_fs_dump(struct r500_fragment_shader* fs)
debug_printf(" 2: TEX_ADDR 0x%08x: "
"src: %d%s %s/%s/%s/%s dst: %d%s %s/%s/%s/%s\n",
inst, inst & 0x7f, inst & (1 << 7) ? "(rel)" : "",
- r500_fs_swiz[(inst >> 8) & 0x3],
- r500_fs_swiz[(inst >> 10) & 0x3],
- r500_fs_swiz[(inst >> 12) & 0x3],
- r500_fs_swiz[(inst >> 14) & 0x3],
+ r5xx_fs_swiz[(inst >> 8) & 0x3],
+ r5xx_fs_swiz[(inst >> 10) & 0x3],
+ r5xx_fs_swiz[(inst >> 12) & 0x3],
+ r5xx_fs_swiz[(inst >> 14) & 0x3],
(inst >> 16) & 0x7f, inst & (1 << 23) ? "(rel)" : "",
- r500_fs_swiz[(inst >> 24) & 0x3],
- r500_fs_swiz[(inst >> 26) & 0x3],
- r500_fs_swiz[(inst >> 28) & 0x3],
- r500_fs_swiz[(inst >> 30) & 0x3]);
+ r5xx_fs_swiz[(inst >> 24) & 0x3],
+ r5xx_fs_swiz[(inst >> 26) & 0x3],
+ r5xx_fs_swiz[(inst >> 28) & 0x3],
+ r5xx_fs_swiz[(inst >> 30) & 0x3]);
inst = fs->instructions[i].inst3;
debug_printf(" 3: TEX_DXDY 0x%08x\n", inst);
diff --git a/src/gallium/drivers/r300/r300_debug.h b/src/gallium/drivers/r300/r300_debug.h
index c86410ec0a9..6b58c1e2501 100644
--- a/src/gallium/drivers/r300/r300_debug.h
+++ b/src/gallium/drivers/r300/r300_debug.h
@@ -24,10 +24,10 @@
#define R300_DEBUG_H
#include "r300_reg.h"
-#include "r300_state_shader.h"
-#include "r300_state_tcl.h"
+#include "r300_fs.h"
+#include "r300_vs.h"
-static char* r500_fs_swiz[] = {
+static char* r5xx_fs_swiz[] = {
" R",
" G",
" B",
@@ -38,7 +38,7 @@ static char* r500_fs_swiz[] = {
" U",
};
-static char* r500_fs_op_rgb[] = {
+static char* r5xx_fs_op_rgb[] = {
"MAD",
"DP3",
"DP4",
@@ -54,7 +54,7 @@ static char* r500_fs_op_rgb[] = {
"MDV",
};
-static char* r500_fs_op_alpha[] = {
+static char* r5xx_fs_op_alpha[] = {
"MAD",
" DP",
"MIN",
@@ -73,7 +73,7 @@ static char* r500_fs_op_alpha[] = {
"MDV",
};
-static char* r500_fs_mask[] = {
+static char* r5xx_fs_mask[] = {
"NONE",
"R ",
" G ",
@@ -92,7 +92,7 @@ static char* r500_fs_mask[] = {
"RGBA",
};
-static char* r500_fs_tex[] = {
+static char* r5xx_fs_tex[] = {
" NOP",
" LD",
"TEXKILL",
@@ -203,7 +203,8 @@ static char* r300_vs_swiz_debug[] = {
"U",
};
-void r500_fs_dump(struct r500_fragment_shader* fs);
+void r5xx_fs_dump(struct r5xx_fragment_shader* fs);
+void r3xx_dump_fs(struct r3xx_fragment_shader* fs);
void r300_vs_dump(struct r300_vertex_shader* vs);
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 93cf6909a33..7ba56cdc1d2 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -110,7 +110,7 @@ void r300_emit_dsa_state(struct r300_context* r300,
}
void r300_emit_fragment_shader(struct r300_context* r300,
- struct r300_fragment_shader* fs)
+ struct r3xx_fragment_shader* fs)
{
int i;
CS_LOCALS(r300);
@@ -142,7 +142,7 @@ void r300_emit_fragment_shader(struct r300_context* r300,
}
void r500_emit_fragment_shader(struct r300_context* r300,
- struct r500_fragment_shader* fs)
+ struct r5xx_fragment_shader* fs)
{
int i;
struct r300_constant_buffer* constants =
@@ -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);
@@ -570,10 +564,10 @@ validate:
if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER) {
if (r300screen->caps->is_r500) {
r500_emit_fragment_shader(r300,
- (struct r500_fragment_shader*)r300->fs);
+ (struct r5xx_fragment_shader*)r300->fs);
} else {
r300_emit_fragment_shader(r300,
- (struct r300_fragment_shader*)r300->fs);
+ (struct r3xx_fragment_shader*)r300->fs);
}
r300->dirty_state &= ~R300_NEW_FRAGMENT_SHADER;
}
@@ -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);
- r300->dirty_state &= ~(R300_NEW_SAMPLER << i);
- dirty_tex++;
- }
- }
- }
-
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);
- r300->dirty_state &= ~(R300_NEW_TEXTURE << 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_SAMPLERS | R300_ANY_NEW_TEXTURES);
}
if (r300->dirty_state & R300_NEW_VIEWPORT) {
@@ -637,6 +629,10 @@ validate:
r300->dirty_state &= ~R300_NEW_VERTEX_SHADER;
}
+ /* XXX
+ assert(r300->dirty_state == 0);
+ */
+
/* Finally, emit the VBO. */
r300_emit_vertex_buffer(r300);
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
index 946f625bd89..fda26f39481 100644
--- a/src/gallium/drivers/r300/r300_emit.h
+++ b/src/gallium/drivers/r300/r300_emit.h
@@ -43,10 +43,10 @@ void r300_emit_dsa_state(struct r300_context* r300,
struct r300_dsa_state* dsa);
void r300_emit_fragment_shader(struct r300_context* r300,
- struct r300_fragment_shader* fs);
+ struct r3xx_fragment_shader* fs);
void r500_emit_fragment_shader(struct r300_context* r300,
- struct r500_fragment_shader* fs);
+ struct r5xx_fragment_shader* fs);
void r300_emit_fb_state(struct r300_context* r300,
struct pipe_framebuffer_state* fb);
@@ -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_flush.c b/src/gallium/drivers/r300/r300_flush.c
index 89a5f2b20cf..0dff1c6f4fb 100644
--- a/src/gallium/drivers/r300/r300_flush.c
+++ b/src/gallium/drivers/r300/r300_flush.c
@@ -29,7 +29,11 @@ static void r300_flush(struct pipe_context* pipe,
struct r300_context* r300 = r300_context(pipe);
CS_LOCALS(r300);
- draw_flush(r300->draw);
+ /* We probably need to flush Draw, but we may have been called from
+ * within Draw. This feels kludgy, but it might be the best thing. */
+ if (!r300->draw->flushing) {
+ draw_flush(r300->draw);
+ }
if (r300->dirty_hw) {
FLUSH_CS;
diff --git a/src/gallium/drivers/r300/r300_flush.h b/src/gallium/drivers/r300/r300_flush.h
index a1b224b39ce..9a83d89daab 100644
--- a/src/gallium/drivers/r300/r300_flush.h
+++ b/src/gallium/drivers/r300/r300_flush.h
@@ -23,6 +23,8 @@
#ifndef R300_FLUSH_H
#define R300_FLUSH_H
+#include "draw/draw_private.h"
+
#include "pipe/p_context.h"
#include "r300_context.h"
diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c
new file mode 100644
index 00000000000..4b304306d0f
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_fs.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2008 Corbin Simpson <[email protected]>
+ * Joakim Sindholt <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#include "r300_fs.h"
+
+void r300_translate_fragment_shader(struct r300_context* r300,
+ struct r300_fragment_shader* fs)
+{
+ struct tgsi_parse_context parser;
+ int i;
+ boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500;
+ struct r300_constant_buffer* consts =
+ &r300->shader_constants[PIPE_SHADER_FRAGMENT];
+
+ struct r300_fs_asm* assembler = CALLOC_STRUCT(r300_fs_asm);
+ if (assembler == NULL) {
+ return;
+ }
+ /* Setup starting offset for immediates. */
+ assembler->imm_offset = consts->user_count;
+ /* Enable depth writes, if needed. */
+ assembler->writes_depth = fs->info.writes_z;
+
+ /* Make sure we start at the beginning of the shader. */
+ if (is_r500) {
+ ((struct r5xx_fragment_shader*)fs)->instruction_count = 0;
+ }
+
+ tgsi_parse_init(&parser, fs->state.tokens);
+
+ while (!tgsi_parse_end_of_tokens(&parser)) {
+ tgsi_parse_token(&parser);
+
+ /* This is seriously the lamest way to create fragment programs ever.
+ * I blame TGSI. */
+ switch (parser.FullToken.Token.Type) {
+ case TGSI_TOKEN_TYPE_DECLARATION:
+ /* Allocated registers sitting at the beginning
+ * of the program. */
+ r300_fs_declare(assembler, &parser.FullToken.FullDeclaration);
+ break;
+ case TGSI_TOKEN_TYPE_IMMEDIATE:
+ debug_printf("r300: Emitting immediate to constant buffer, "
+ "position %d\n",
+ assembler->imm_offset + assembler->imm_count);
+ /* I am not amused by the length of these. */
+ for (i = 0; i < 4; i++) {
+ consts->constants[assembler->imm_offset +
+ assembler->imm_count][i] =
+ parser.FullToken.FullImmediate.u.ImmediateFloat32[i]
+ .Float;
+ }
+ assembler->imm_count++;
+ break;
+ case TGSI_TOKEN_TYPE_INSTRUCTION:
+ if (is_r500) {
+ r5xx_fs_instruction((struct r5xx_fragment_shader*)fs,
+ assembler, &parser.FullToken.FullInstruction);
+ } else {
+ r3xx_fs_instruction((struct r3xx_fragment_shader*)fs,
+ assembler, &parser.FullToken.FullInstruction);
+ }
+ break;
+ }
+ }
+
+ debug_printf("r300: fs: %d texs and %d colors, first free reg is %d\n",
+ assembler->tex_count, assembler->color_count,
+ assembler->tex_count + assembler->color_count);
+
+ consts->count = consts->user_count + assembler->imm_count;
+ fs->uses_imms = assembler->imm_count;
+ debug_printf("r300: fs: %d total constants, "
+ "%d from user and %d from immediates\n", consts->count,
+ consts->user_count, assembler->imm_count);
+ r3xx_fs_finalize(fs, assembler);
+ if (is_r500) {
+ r5xx_fs_finalize((struct r5xx_fragment_shader*)fs, assembler);
+ }
+
+ tgsi_dump(fs->state.tokens, 0);
+ /* XXX finish r300 dumper too */
+ if (is_r500) {
+ r5xx_fs_dump((struct r5xx_fragment_shader*)fs);
+ }
+
+ tgsi_parse_free(&parser);
+ FREE(assembler);
+}
diff --git a/src/gallium/drivers/r300/r300_fs.h b/src/gallium/drivers/r300/r300_fs.h
new file mode 100644
index 00000000000..18deb7a05e4
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_fs.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Corbin Simpson <[email protected]>
+ * Joakim Sindholt <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_FS_H
+#define R300_FS_H
+
+#include "tgsi/tgsi_dump.h"
+
+#include "r300_context.h"
+#include "r3xx_fs.h"
+#include "r5xx_fs.h"
+
+void r300_translate_fragment_shader(struct r300_context* r300,
+ struct r300_fragment_shader* fs);
+
+ #endif /* R300_FS_H */
diff --git a/src/gallium/drivers/r300/r300_fs_inlines.h b/src/gallium/drivers/r300/r300_fs_inlines.h
new file mode 100644
index 00000000000..be4be9465e6
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_fs_inlines.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2008 Corbin Simpson <[email protected]>
+ * Joakim Sindholt <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_FS_INLINES_H
+#define R300_FS_INLINES_H
+
+#include "tgsi/tgsi_parse.h"
+
+#include "r300_context.h"
+#include "r300_debug.h"
+#include "r300_reg.h"
+#include "r300_screen.h"
+#include "r300_shader_inlines.h"
+
+/* Temporary struct used to hold assembly state while putting together
+ * fragment programs. */
+struct r300_fs_asm {
+ /* Pipe context. */
+ struct r300_context* r300;
+ /* Number of colors. */
+ unsigned color_count;
+ /* Number of texcoords. */
+ unsigned tex_count;
+ /* Offset for temporary registers. Inputs and temporaries have no
+ * distinguishing markings, so inputs start at 0 and the first usable
+ * temporary register is after all inputs. */
+ unsigned temp_offset;
+ /* Number of requested temporary registers. */
+ unsigned temp_count;
+ /* Offset for immediate constants. Neither R300 nor R500 can do four
+ * inline constants per source, so instead we copy immediates into the
+ * constant buffer. */
+ unsigned imm_offset;
+ /* Number of immediate constants. */
+ unsigned imm_count;
+ /* Are depth writes enabled? */
+ boolean writes_depth;
+ /* Depth write offset. This is the TGSI output that corresponds to
+ * depth writes. */
+ unsigned depth_output;
+};
+
+static INLINE void r300_fs_declare(struct r300_fs_asm* assembler,
+ struct tgsi_full_declaration* decl)
+{
+ switch (decl->Declaration.File) {
+ case TGSI_FILE_INPUT:
+ switch (decl->Semantic.SemanticName) {
+ case TGSI_SEMANTIC_COLOR:
+ assembler->color_count++;
+ break;
+ case TGSI_SEMANTIC_FOG:
+ case TGSI_SEMANTIC_GENERIC:
+ assembler->tex_count++;
+ break;
+ default:
+ debug_printf("r300: fs: Bad semantic declaration %d\n",
+ decl->Semantic.SemanticName);
+ break;
+ }
+ break;
+ case TGSI_FILE_OUTPUT:
+ /* Depth write. Mark the position of the output so we can
+ * identify it later. */
+ if (decl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION) {
+ assembler->depth_output = decl->DeclarationRange.First;
+ }
+ break;
+ case TGSI_FILE_CONSTANT:
+ break;
+ case TGSI_FILE_TEMPORARY:
+ assembler->temp_count++;
+ break;
+ default:
+ debug_printf("r300: fs: Bad file %d\n", decl->Declaration.File);
+ break;
+ }
+
+ assembler->temp_offset = assembler->color_count + assembler->tex_count;
+}
+
+static INLINE unsigned r300_fs_src(struct r300_fs_asm* assembler,
+ struct tgsi_src_register* src)
+{
+ switch (src->File) {
+ case TGSI_FILE_NULL:
+ return 0;
+ case TGSI_FILE_INPUT:
+ /* XXX may be wrong */
+ return src->Index;
+ break;
+ case TGSI_FILE_TEMPORARY:
+ return src->Index + assembler->temp_offset;
+ break;
+ case TGSI_FILE_IMMEDIATE:
+ return (src->Index + assembler->imm_offset) | (1 << 8);
+ break;
+ case TGSI_FILE_CONSTANT:
+ /* XXX magic */
+ return src->Index | (1 << 8);
+ break;
+ default:
+ debug_printf("r300: fs: Unimplemented src %d\n", src->File);
+ break;
+ }
+ return 0;
+}
+
+static INLINE unsigned r300_fs_dst(struct r300_fs_asm* assembler,
+ struct tgsi_dst_register* dst)
+{
+ switch (dst->File) {
+ case TGSI_FILE_NULL:
+ /* This happens during KIL instructions. */
+ return 0;
+ break;
+ case TGSI_FILE_OUTPUT:
+ return 0;
+ break;
+ case TGSI_FILE_TEMPORARY:
+ return dst->Index + assembler->temp_offset;
+ break;
+ default:
+ debug_printf("r300: fs: Unimplemented dst %d\n", dst->File);
+ break;
+ }
+ return 0;
+}
+
+static INLINE boolean r300_fs_is_depr(struct r300_fs_asm* assembler,
+ struct tgsi_dst_register* dst)
+{
+ return (assembler->writes_depth &&
+ (dst->File == TGSI_FILE_OUTPUT) &&
+ (dst->Index == assembler->depth_output));
+}
+
+#endif /* R300_FS_INLINES_H */
diff --git a/src/gallium/drivers/r300/r300_query.h b/src/gallium/drivers/r300/r300_query.h
index 4f447ea45b8..6a7646087a7 100644
--- a/src/gallium/drivers/r300/r300_query.h
+++ b/src/gallium/drivers/r300/r300_query.h
@@ -27,6 +27,8 @@
#include "r300_cs.h"
#include "r300_reg.h"
+struct r300_context;
+
struct r300_query {
/* The kind of query. Currently only OQ is supported. */
unsigned type;
diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h
index 3bb9bc47b50..6825d998700 100644
--- a/src/gallium/drivers/r300/r300_reg.h
+++ b/src/gallium/drivers/r300/r300_reg.h
@@ -1064,8 +1064,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
R300_GA_COLOR_CONTROL_RGB2_SHADING_FLAT | \
R300_GA_COLOR_CONTROL_ALPHA2_SHADING_FLAT | \
R300_GA_COLOR_CONTROL_RGB3_SHADING_FLAT | \
- R300_GA_COLOR_CONTROL_ALPHA3_SHADING_FLAT | \
- R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
+ R300_GA_COLOR_CONTROL_ALPHA3_SHADING_FLAT )
# define R300_SHADE_MODEL_SMOOTH ( \
R300_GA_COLOR_CONTROL_RGB0_SHADING_GOURAUD | \
@@ -1075,8 +1074,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
R300_GA_COLOR_CONTROL_RGB2_SHADING_GOURAUD | \
R300_GA_COLOR_CONTROL_ALPHA2_SHADING_GOURAUD | \
R300_GA_COLOR_CONTROL_RGB3_SHADING_GOURAUD | \
- R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
- R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
+ R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD )
/* Specifies red & green components of fill color -- S312 format -- Backwards comp. */
#define R300_GA_SOLID_RG 0x427c
@@ -1480,6 +1478,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_TX_PITCH_EN (1 << 31)
# define R300_TX_WIDTH(x) ((x) << 0)
# define R300_TX_HEIGHT(x) ((x) << 11)
+# define R300_TX_NUM_LEVELS(x) ((x) << 26)
#define R300_TX_FORMAT1_0 0x44C0
/* The interpretation of the format word by Wladimir van der Laan */
@@ -1487,9 +1486,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
They are given meanings as R, G, B and Alpha by the swizzle
specification */
# define R300_TX_FORMAT_X8 0x0
-# define R500_TX_FORMAT_X1 0x0 // bit set in format 2
# define R300_TX_FORMAT_X16 0x1
-# define R500_TX_FORMAT_X1_REV 0x0 // bit set in format 2
# define R300_TX_FORMAT_Y4X4 0x2
# define R300_TX_FORMAT_Y8X8 0x3
# define R300_TX_FORMAT_Y16X16 0x4
@@ -1506,31 +1503,29 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_TX_FORMAT_DXT1 0xF
# define R300_TX_FORMAT_DXT3 0x10
# define R300_TX_FORMAT_DXT5 0x11
-# define R300_TX_FORMAT_D3DMFT_CxV8U8 0x12 /* no swizzle */
-# define R300_TX_FORMAT_A8R8G8B8 0x13 /* no swizzle */
-# define R300_TX_FORMAT_B8G8_B8G8 0x14 /* no swizzle */
-# define R300_TX_FORMAT_G8R8_G8B8 0x15 /* no swizzle */
-
- /* These two values are wrong, but they're the only values that
- * produce any even vaguely correct results. Can r300 only do 16-bit
- * depth textures?
- */
-# define R300_TX_FORMAT_X24_Y8 0x1e
-# define R300_TX_FORMAT_X32 0x1e
-
- /* 0x16 - some 16 bit green format.. ?? */
+# define R300_TX_FORMAT_Y8 0x12
+# define R300_TX_FORMAT_AVYU444 0x13
+# define R300_TX_FORMAT_VYUY422 0x14
+# define R300_TX_FORMAT_YVYU422 0x15
+# define R300_TX_FORMAT_16_MPEG 0x16
+# define R300_TX_FORMAT_16_16_MPEG 0x17
+# define R300_TX_FORMAT_16F 0x18
+# define R300_TX_FORMAT_16F_16F 0x19
+# define R300_TX_FORMAT_16F_16F_16F_16F 0x1A
+# define R300_TX_FORMAT_32F 0x1B
+# define R300_TX_FORMAT_32F_32F 0x1C
+# define R300_TX_FORMAT_32F_32F_32F_32F 0x1D
+# define R300_TX_FORMAT_W24_FP 0x1E
+
+# define R300_TX_FORMAT_SIGNED_W (1 << 5)
+# define R300_TX_FORMAT_SIGNED_Z (1 << 6)
+# define R300_TX_FORMAT_SIGNED_Y (1 << 7)
+# define R300_TX_FORMAT_SIGNED_X (1 << 8)
+# define R300_TX_FORMAT_SIGNED (0xf << 5)
+
# define R300_TX_FORMAT_3D (1 << 25)
# define R300_TX_FORMAT_CUBIC_MAP (2 << 25)
- /* gap */
- /* Floating point formats */
- /* Note - hardware supports both 16 and 32 bit floating point */
-# define R300_TX_FORMAT_FL_I16 0x18
-# define R300_TX_FORMAT_FL_I16A16 0x19
-# define R300_TX_FORMAT_FL_R16G16B16A16 0x1A
-# define R300_TX_FORMAT_FL_I32 0x1B
-# define R300_TX_FORMAT_FL_I32A32 0x1C
-# define R300_TX_FORMAT_FL_R32G32B32A32 0x1D
/* alpha modes, convenience mostly */
/* if you have alpha, pick constant appropriate to the
number of channels (1 for I8, 2 for I8A8, 4 for R8G8B8A8, etc */
@@ -1571,7 +1566,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_TX_FORMAT_CONST_Z (4<<5)
# define R300_TX_FORMAT_CONST_W (8<<5)
-# define R300_TX_FORMAT_YUV_MODE 0x00800000
+# define R300_TX_FORMAT_GAMMA (1 << 21)
+# define R300_TX_FORMAT_YUV_TO_RGB (1 << 22)
#define R300_TX_FORMAT2_0 0x4500 /* obvious missing in gap */
# define R300_TX_PITCHMASK_SHIFT 0
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index a6f1efe3563..da1d5ffe2fd 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -94,8 +94,7 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
return 0;
}
case PIPE_CAP_S3TC:
- /* IN THEORY */
- return 0;
+ return 1;
case PIPE_CAP_ANISOTROPIC_FILTER:
return 1;
case PIPE_CAP_POINT_SPRITE:
@@ -145,6 +144,9 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
/* XXX guessing (what a terrible guess) */
return 2;
+ case PIPE_CAP_TGSI_CONT_SUPPORTED:
+ /* XXX */
+ return 0;
default:
debug_printf("r300: Implementation error: Bad param %d\n",
param);
@@ -179,21 +181,58 @@ static float r300_get_paramf(struct pipe_screen* pscreen, int param)
}
}
-static boolean check_tex_2d_format(enum pipe_format format, boolean is_r500)
+static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage,
+ boolean is_r500)
{
switch (format) {
+ /* Supported formats. */
/* Colorbuffer */
case PIPE_FORMAT_A4R4G4B4_UNORM:
case PIPE_FORMAT_R5G6B5_UNORM:
case PIPE_FORMAT_A1R5G5B5_UNORM:
- case PIPE_FORMAT_A8R8G8B8_UNORM:
+ return usage &
+ (PIPE_TEXTURE_USAGE_RENDER_TARGET |
+ PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+ PIPE_TEXTURE_USAGE_PRIMARY);
+
+ /* Texture */
+ case PIPE_FORMAT_A8R8G8B8_SRGB:
+ case PIPE_FORMAT_R8G8B8A8_SRGB:
+ case PIPE_FORMAT_DXT1_RGB:
+ case PIPE_FORMAT_DXT1_RGBA:
+ case PIPE_FORMAT_DXT3_RGBA:
+ case PIPE_FORMAT_DXT5_RGBA:
+ case PIPE_FORMAT_YCBCR:
+ return usage & PIPE_TEXTURE_USAGE_SAMPLER;
+
/* Colorbuffer or texture */
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
case PIPE_FORMAT_I8_UNORM:
+ return usage &
+ (PIPE_TEXTURE_USAGE_RENDER_TARGET |
+ PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+ PIPE_TEXTURE_USAGE_PRIMARY |
+ PIPE_TEXTURE_USAGE_SAMPLER);
+
/* Z buffer */
case PIPE_FORMAT_Z16_UNORM:
- /* Z buffer with stencil */
+ return usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+
+ /* Z buffer with stencil or texture */
case PIPE_FORMAT_Z24S8_UNORM:
- return TRUE;
+ return usage &
+ (PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
+ PIPE_TEXTURE_USAGE_SAMPLER);
+
+ /* Definitely unsupported formats. */
+ /* Non-usable Z buffer/stencil formats. */
+ case PIPE_FORMAT_Z24X8_UNORM:
+ case PIPE_FORMAT_S8Z24_UNORM:
+ case PIPE_FORMAT_X8Z24_UNORM:
+ debug_printf("r300: Note: Got unsupported format: %s in %s\n",
+ pf_name(format), __FUNCTION__);
+ return FALSE;
/* XXX These don't even exist
case PIPE_FORMAT_A32R32G32B32:
@@ -216,7 +255,8 @@ static boolean check_tex_2d_format(enum pipe_format format, boolean is_r500)
return FALSE; */
default:
- debug_printf("r300: Warning: Got unsupported format: %s in %s\n",
+ /* Unknown format... */
+ debug_printf("r300: Warning: Got unknown format: %s in %s\n",
pf_name(format), __FUNCTION__);
break;
}
@@ -233,7 +273,7 @@ static boolean r300_is_format_supported(struct pipe_screen* pscreen,
{
switch (target) {
case PIPE_TEXTURE_2D:
- return check_tex_2d_format(format,
+ return check_tex_2d_format(format, tex_usage,
r300_screen(pscreen)->caps->is_r500);
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_3D:
diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
index 3f52dbc3bea..2a0e41fbc3b 100644
--- a/src/gallium/drivers/r300/r300_screen.h
+++ b/src/gallium/drivers/r300/r300_screen.h
@@ -49,7 +49,7 @@ struct r300_transfer {
};
/* Convenience cast wrapper. */
-static struct r300_screen* r300_screen(struct pipe_screen* screen) {
+static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) {
return (struct r300_screen*)screen;
}
diff --git a/src/gallium/drivers/r300/r300_shader_inlines.h b/src/gallium/drivers/r300/r300_shader_inlines.h
new file mode 100644
index 00000000000..a04f45b03e2
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_shader_inlines.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2009 Corbin Simpson <[email protected]>
+ * Joakim Sindholt <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R300_SHADER_INLINES_H
+#define R300_SHADER_INLINES_H
+
+/* TGSI constants. TGSI is like XML: If it can't solve your problems, you're
+ * not using enough of it. */
+static const struct tgsi_full_src_register r300_constant_zero = {
+ .SrcRegister.Extended = TRUE,
+ .SrcRegister.File = TGSI_FILE_NULL,
+ .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ZERO,
+ .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ZERO,
+ .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ZERO,
+ .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ZERO,
+};
+
+static const struct tgsi_full_src_register r300_constant_one = {
+ .SrcRegister.Extended = TRUE,
+ .SrcRegister.File = TGSI_FILE_NULL,
+ .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ONE,
+ .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ONE,
+ .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ONE,
+ .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ONE,
+};
+
+#endif /* R300_SHADER_INLINES_H */
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 01e2b511534..68da0aa4cbb 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -24,12 +24,14 @@
#include "util/u_pack_color.h"
#include "util/u_debug.h"
+
+#include "pipe/p_config.h"
#include "pipe/internal/p_winsys_screen.h"
#include "r300_context.h"
#include "r300_reg.h"
#include "r300_state_inlines.h"
-#include "r300_state_shader.h"
+#include "r300_fs.h"
/* r300_state: Functions used to intialize state context by translating
* Gallium state objects into semi-native r300 state objects. */
@@ -283,14 +285,12 @@ static void* r300_create_fs_state(struct pipe_context* pipe,
const struct pipe_shader_state* shader)
{
struct r300_context* r300 = r300_context(pipe);
- struct r3xx_fragment_shader* fs = NULL;
+ struct r300_fragment_shader* fs = NULL;
if (r300_screen(r300->context.screen)->caps->is_r500) {
- fs =
- (struct r3xx_fragment_shader*)CALLOC_STRUCT(r500_fragment_shader);
+ fs = (struct r300_fragment_shader*)CALLOC_STRUCT(r5xx_fragment_shader);
} else {
- fs =
- (struct r3xx_fragment_shader*)CALLOC_STRUCT(r300_fragment_shader);
+ fs = (struct r300_fragment_shader*)CALLOC_STRUCT(r3xx_fragment_shader);
}
/* Copy state directly into shader. */
@@ -306,7 +306,7 @@ static void* r300_create_fs_state(struct pipe_context* pipe,
static void r300_bind_fs_state(struct pipe_context* pipe, void* shader)
{
struct r300_context* r300 = r300_context(pipe);
- struct r3xx_fragment_shader* fs = (struct r3xx_fragment_shader*)shader;
+ struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader;
if (fs == NULL) {
r300->fs = NULL;
@@ -324,7 +324,7 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader)
/* Delete fragment shader state. */
static void r300_delete_fs_state(struct pipe_context* pipe, void* shader)
{
- struct r3xx_fragment_shader* fs = (struct r3xx_fragment_shader*)shader;
+ struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader;
FREE(fs->state.tokens);
FREE(shader);
}
@@ -352,14 +352,19 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
rs->enable_vte = !state->bypass_vs_clip_and_viewport;
+#ifdef PIPE_ARCH_LITTLE_ENDIAN
+ rs->vap_control_status = R300_VC_NO_SWAP;
+#else
+ rs->vap_control_status = R300_VC_32BIT_SWAP;
+#endif
+
/* If bypassing TCL, or if no TCL engine is present, turn off the HW TCL.
* Else, enable HW TCL and force Draw's TCL off. */
if (state->bypass_vs_clip_and_viewport ||
!r300_screen(pipe->screen)->caps->has_tcl) {
- rs->vap_control_status = R300_VAP_TCL_BYPASS;
+ rs->vap_control_status |= R300_VAP_TCL_BYPASS;
} else {
rs->rs.bypass_vs_clip_and_viewport = TRUE;
- rs->vap_control_status = 0;
}
rs->point_size = pack_float_16_6x(state->point_size) |
@@ -423,6 +428,10 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
rs->color_control = R300_SHADE_MODEL_SMOOTH;
}
+ if (!state->flatshade_first) {
+ rs->color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST;
+ }
+
return (void*)rs;
}
diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c
index e438114010c..9f534b8ce3c 100644
--- a/src/gallium/drivers/r300/r300_state_invariant.c
+++ b/src/gallium/drivers/r300/r300_state_invariant.c
@@ -34,14 +34,17 @@ void r300_emit_invariant_state(struct r300_context* r300)
struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;
CS_LOCALS(r300);
- BEGIN_CS(26 + (caps->has_tcl ? 2: 0));
+ BEGIN_CS(22 + (caps->has_tcl ? 2: 0));
/*** Graphics Backend (GB) ***/
/* Various GB enables */
OUT_CS_REG(R300_GB_ENABLE, 0x0);
- /* Subpixel multisampling for AA */
- OUT_CS_REG(R300_GB_MSPOS0, 0x66666666);
- OUT_CS_REG(R300_GB_MSPOS1, 0x6666666);
+ /* Subpixel multisampling for AA
+ * These are commented out because glisse's CS checker doesn't like them.
+ * I presume these will be re-enabled later.
+ * OUT_CS_REG(R300_GB_MSPOS0, 0x66666666);
+ * OUT_CS_REG(R300_GB_MSPOS1, 0x6666666);
+ */
/* Source of fog depth */
OUT_CS_REG(R300_GB_SELECT, R300_GB_FOG_SELECT_1_1_W);
/* AA enable */
@@ -69,7 +72,7 @@ void r300_emit_invariant_state(struct r300_context* r300)
END_CS;
/* XXX unsorted stuff from surface_fill */
- BEGIN_CS(77 + (caps->has_tcl ? 5 : 0));
+ BEGIN_CS(75 + (caps->has_tcl ? 5 : 0));
/* Flush PVS. */
OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
@@ -77,17 +80,12 @@ void r300_emit_invariant_state(struct r300_context* r300)
R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
R300_VPORT_Z_OFFSET_ENA | R300_VTX_W0_FMT);
- /* XXX endian */
if (caps->has_tcl) {
- OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VC_NO_SWAP);
OUT_CS_REG_SEQ(R300_VAP_GB_VERT_CLIP_ADJ, 4);
OUT_CS_32F(1.0);
OUT_CS_32F(1.0);
OUT_CS_32F(1.0);
OUT_CS_32F(1.0);
- } else {
- OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VC_NO_SWAP |
- R300_VAP_TCL_BYPASS);
}
/* XXX point tex stuffing */
OUT_CS_REG_SEQ(R300_GA_POINT_S0, 1);
diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c
index c9e2dff14ed..fdabe4d9cfe 100644
--- a/src/gallium/drivers/r300/r300_surface.c
+++ b/src/gallium/drivers/r300/r300_surface.c
@@ -151,11 +151,11 @@ validate:
/* Fragment shader setup */
if (caps->is_r500) {
- r500_emit_fragment_shader(r300, &r500_passthrough_fragment_shader);
- r300_emit_rs_block_state(r300, &r500_rs_block_clear_state);
+ r500_emit_fragment_shader(r300, &r5xx_passthrough_fragment_shader);
+ r300_emit_rs_block_state(r300, &r5xx_rs_block_clear_state);
} else {
- r300_emit_fragment_shader(r300, &r300_passthrough_fragment_shader);
- r300_emit_rs_block_state(r300, &r300_rs_block_clear_state);
+ r300_emit_fragment_shader(r300, &r3xx_passthrough_fragment_shader);
+ r300_emit_rs_block_state(r300, &r3xx_rs_block_clear_state);
}
BEGIN_CS(26);
@@ -228,13 +228,14 @@ static void r300_surface_copy(struct pipe_context* pipe,
struct r300_texture* desttex = (struct r300_texture*)dest->texture;
unsigned pixpitch = srctex->stride / srctex->tex.block.size;
boolean invalid = FALSE;
+ float fsrcx = srcx, fsrcy = srcy, fdestx = destx, fdesty = desty;
CS_LOCALS(r300);
debug_printf("r300: Copying surface %p at (%d,%d) to %p at (%d, %d),"
" dimensions %dx%d (pixel pitch %d)\n",
src, srcx, srcy, dest, destx, desty, w, h, pixpitch);
- if ((srctex == desttex) &&
+ if ((srctex->buffer == desttex->buffer) &&
((destx < srcx + w) || (srcx < destx + w)) &&
((desty < srcy + h) || (srcy < desty + h))) {
fallback:
@@ -267,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) {
@@ -291,11 +288,11 @@ validate:
/* Fragment shader setup */
if (caps->is_r500) {
- r500_emit_fragment_shader(r300, &r500_texture_fragment_shader);
- r300_emit_rs_block_state(r300, &r500_rs_block_copy_state);
+ r500_emit_fragment_shader(r300, &r5xx_texture_fragment_shader);
+ r300_emit_rs_block_state(r300, &r5xx_rs_block_copy_state);
} else {
- r300_emit_fragment_shader(r300, &r300_texture_fragment_shader);
- r300_emit_rs_block_state(r300, &r300_rs_block_copy_state);
+ r300_emit_fragment_shader(r300, &r3xx_texture_fragment_shader);
+ r300_emit_rs_block_state(r300, &r3xx_rs_block_copy_state);
}
BEGIN_CS(30);
@@ -329,25 +326,25 @@ validate:
OUT_CS(R300_PRIM_TYPE_QUADS | R300_PRIM_WALK_RING |
(4 << R300_PRIM_NUM_VERTICES_SHIFT));
/* (x , y ) */
- OUT_CS_32F((float)(destx / dest->width));
- OUT_CS_32F((float)(desty / dest->height));
- OUT_CS_32F((float)(srcx / dest->width));
- OUT_CS_32F((float)(srcy / dest->height));
+ OUT_CS_32F(fdestx / dest->width);
+ OUT_CS_32F(fdesty / dest->height);
+ OUT_CS_32F(fsrcx / src->width);
+ OUT_CS_32F(fsrcy / src->height);
/* (x , y + h) */
- OUT_CS_32F((float)(destx / dest->width));
- OUT_CS_32F((float)((desty + h) / dest->height));
- OUT_CS_32F((float)(srcx / dest->width));
- OUT_CS_32F((float)((srcy + h) / dest->height));
+ OUT_CS_32F(fdestx / dest->width);
+ OUT_CS_32F((fdesty + h) / dest->height);
+ OUT_CS_32F(fsrcx / src->width);
+ OUT_CS_32F((fsrcy + h) / src->height);
/* (x + w, y + h) */
- OUT_CS_32F((float)((destx + w) / dest->width));
- OUT_CS_32F((float)((desty + h) / dest->height));
- OUT_CS_32F((float)((srcx + w) / dest->width));
- OUT_CS_32F((float)((srcy + h) / dest->height));
+ OUT_CS_32F((fdestx + w) / dest->width);
+ OUT_CS_32F((fdesty + h) / dest->height);
+ OUT_CS_32F((fsrcx + w) / src->width);
+ OUT_CS_32F((fsrcy + h) / src->height);
/* (x + w, y ) */
- OUT_CS_32F((float)((destx + w) / dest->width));
- OUT_CS_32F((float)(desty / dest->height));
- OUT_CS_32F((float)((srcx + w) / dest->width));
- OUT_CS_32F((float)(srcy / dest->height));
+ OUT_CS_32F((fdestx + w) / dest->width);
+ OUT_CS_32F(fdesty / dest->height);
+ OUT_CS_32F((fsrcx + w) / src->width);
+ OUT_CS_32F(fsrcy / src->height);
OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA);
diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h
index 9a4c39f58bd..d01f0b143f5 100644
--- a/src/gallium/drivers/r300/r300_surface.h
+++ b/src/gallium/drivers/r300/r300_surface.h
@@ -31,8 +31,8 @@
#include "r300_context.h"
#include "r300_cs.h"
#include "r300_emit.h"
-#include "r300_state_shader.h"
-#include "r300_state_tcl.h"
+#include "r300_fs.h"
+#include "r300_vs.h"
#include "r300_state_inlines.h"
static struct r300_blend_state blend_clear_state = {
@@ -72,7 +72,7 @@ static struct r300_rs_state rs_clear_state = {
.color_control = R300_SHADE_MODEL_FLAT,
};
-static struct r300_rs_block r300_rs_block_clear_state = {
+static struct r300_rs_block r3xx_rs_block_clear_state = {
.ip[0] = R500_RS_SEL_S(R300_RS_SEL_K0) |
R500_RS_SEL_T(R300_RS_SEL_K0) |
R500_RS_SEL_R(R300_RS_SEL_K0) |
@@ -82,7 +82,7 @@ static struct r300_rs_block r300_rs_block_clear_state = {
.inst_count = 0,
};
-static struct r300_rs_block r500_rs_block_clear_state = {
+static struct r300_rs_block r5xx_rs_block_clear_state = {
.ip[0] = R500_RS_SEL_S(R500_RS_IP_PTR_K0) |
R500_RS_SEL_T(R500_RS_IP_PTR_K0) |
R500_RS_SEL_R(R500_RS_IP_PTR_K0) |
@@ -94,7 +94,7 @@ static struct r300_rs_block r500_rs_block_clear_state = {
/* The following state is used for surface_copy only. */
-static struct r300_rs_block r300_rs_block_copy_state = {
+static struct r300_rs_block r3xx_rs_block_copy_state = {
.ip[0] = R500_RS_SEL_S(R300_RS_SEL_K0) |
R500_RS_SEL_T(R300_RS_SEL_K0) |
R500_RS_SEL_R(R300_RS_SEL_K0) |
@@ -104,7 +104,7 @@ static struct r300_rs_block r300_rs_block_copy_state = {
.inst_count = R300_RS_TX_OFFSET(0),
};
-static struct r300_rs_block r500_rs_block_copy_state = {
+static struct r300_rs_block r5xx_rs_block_copy_state = {
.ip[0] = R500_RS_SEL_S(0) |
R500_RS_SEL_T(1) |
R500_RS_SEL_R(R500_RS_IP_PTR_K0) |
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 5ea9f56247b..11c7858d422 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -22,6 +22,8 @@
#include "r300_texture.h"
+/* XXX maths need to go to util */
+
static int minify(int i)
{
return MAX2(1, i >> 1);
@@ -30,25 +32,29 @@ static int minify(int i)
static void r300_setup_texture_state(struct r300_texture* tex,
unsigned width,
unsigned height,
- unsigned pitch)
+ unsigned pitch,
+ unsigned levels)
{
struct r300_texture_state* state = &tex->state;
state->format0 = R300_TX_WIDTH((width - 1) & 0x7ff) |
- R300_TX_HEIGHT((height - 1) & 0x7ff) | R300_TX_PITCH_EN;
+ R300_TX_HEIGHT((height - 1) & 0x7ff) |
+ R300_TX_NUM_LEVELS(levels) |
+ R300_TX_PITCH_EN;
/* XXX */
- state->format1 = R300_TX_FORMAT_A8R8G8B8;
+ state->format1 = r300_translate_texformat(tex->tex.format);
state->format2 = pitch - 1;
- /* XXX
+ /* Assume (somewhat foolishly) that oversized textures will
+ * not be permitted by the state tracker. */
if (width > 2048) {
- state->pitch |= R300_TXWIDTH_11;
+ state->format2 |= R500_TXWIDTH_BIT11;
}
if (height > 2048) {
- state->pitch |= R300_TXHEIGHT_11;
- } */
+ state->format2 |= R500_TXHEIGHT_BIT11;
+ }
}
static void r300_setup_miptree(struct r300_texture* tex)
@@ -67,14 +73,18 @@ static void r300_setup_miptree(struct r300_texture* tex)
base->nblocksx[i] = pf_get_nblocksx(&base->block, base->width[i]);
base->nblocksy[i] = pf_get_nblocksy(&base->block, base->width[i]);
- /* Radeons enjoy things in multiples of 32. */
- /* XXX this can be 32 when POT */
- stride = (base->nblocksx[i] * base->block.size + 63) & ~63;
+ /* Radeons enjoy things in multiples of 64.
+ *
+ * XXX
+ * POT, uncompressed, unmippmapped textures can be aligned to 32,
+ * instead of 64. */
+ stride = align(base->nblocksx[i] * base->block.size, 64);
size = stride * base->nblocksy[i] * base->depth[i];
- tex->offset[i] = (tex->size + 63) & ~63;
+ tex->offset[i] = align(tex->size, 64);
tex->size = tex->offset[i] + size;
+ /* Save stride of first level to the texture. */
if (i == 0) {
tex->stride = stride;
}
@@ -98,9 +108,8 @@ static struct pipe_texture*
r300_setup_miptree(tex);
- /* XXX */
- r300_setup_texture_state(tex, tex->tex.width[0], tex->tex.height[0],
- tex->tex.width[0]);
+ r300_setup_texture_state(tex, template->width[0], template->height[0],
+ template->width[0], template->last_level);
tex->buffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_PIXEL,
@@ -164,6 +173,7 @@ static struct pipe_texture*
{
struct r300_texture* tex;
+ /* XXX we should start doing mips now... */
if (base->target != PIPE_TEXTURE_2D ||
base->last_level != 0 ||
base->depth[0] != 1) {
@@ -181,8 +191,9 @@ static struct pipe_texture*
tex->stride = *stride;
+ /* XXX */
r300_setup_texture_state(tex, tex->tex.width[0], tex->tex.height[0],
- tex->stride);
+ tex->stride, 0);
pipe_buffer_reference(&tex->buffer, buffer);
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 98fb5c9a08f..3b56f0307c0 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -32,6 +32,52 @@
void r300_init_screen_texture_functions(struct pipe_screen* screen);
+/* Note the signature of R300_EASY_TX_FORMAT(A, R, G, B, FORMAT)... */
+static INLINE uint32_t r300_translate_texformat(enum pipe_format format)
+{
+ switch (format) {
+ /* X8 */
+ case PIPE_FORMAT_I8_UNORM:
+ return R300_EASY_TX_FORMAT(X, X, X, X, X8);
+ /* W8Z8Y8X8 */
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ return R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
+ return R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8);
+ case PIPE_FORMAT_A8R8G8B8_SRGB:
+ return R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8) |
+ R300_TX_FORMAT_GAMMA;
+ case PIPE_FORMAT_R8G8B8A8_SRGB:
+ return R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8) |
+ R300_TX_FORMAT_GAMMA;
+ /* DXT1 */
+ case PIPE_FORMAT_DXT1_RGB:
+ return R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1);
+ case PIPE_FORMAT_DXT1_RGBA:
+ return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1);
+ /* DXT3 */
+ case PIPE_FORMAT_DXT3_RGBA:
+ return R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3);
+ /* DXT5 */
+ case PIPE_FORMAT_DXT5_RGBA:
+ return R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5);
+ /* YVYU422 */
+ case PIPE_FORMAT_YCBCR:
+ return R300_EASY_TX_FORMAT(X, Y, Z, ONE, YVYU422) |
+ R300_TX_FORMAT_YUV_TO_RGB;
+ /* W24_FP */
+ case PIPE_FORMAT_Z24S8_UNORM:
+ return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP);
+ default:
+ debug_printf("r300: Implementation error: "
+ "Got unsupported texture format %s in %s\n",
+ pf_name(format), __FUNCTION__);
+ assert(0);
+ break;
+ }
+ return 0;
+}
+
#ifndef R300_WINSYS_H
boolean r300_get_texture_buffer(struct pipe_texture* texture,
diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_vs.c
index 8cf8250425e..f87435f9f07 100644
--- a/src/gallium/drivers/r300/r300_state_tcl.c
+++ b/src/gallium/drivers/r300/r300_vs.c
@@ -20,7 +20,7 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#include "r300_state_tcl.h"
+#include "r300_vs.h"
static void r300_vs_declare(struct r300_vs_asm* assembler,
struct tgsi_full_declaration* decl)
@@ -403,7 +403,7 @@ void r300_translate_vertex_shader(struct r300_context* r300,
debug_printf("r300: vs: tab: %d %d %d %d\n", assembler->tab[0],
assembler->tab[1], assembler->tab[2], assembler->tab[3]);
- tgsi_dump(vs->state.tokens);
+ tgsi_dump(vs->state.tokens, 0);
/* XXX finish r300 vertex shader dumper */
r300_vs_dump(vs);
diff --git a/src/gallium/drivers/r300/r300_state_tcl.h b/src/gallium/drivers/r300/r300_vs.h
index 2c8b586c2f5..165d7178122 100644
--- a/src/gallium/drivers/r300/r300_state_tcl.h
+++ b/src/gallium/drivers/r300/r300_vs.h
@@ -20,15 +20,17 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#ifndef R300_STATE_TCL_H
-#define R300_STATE_TCL_H
+#ifndef R300_VS_H
+#define R300_VS_H
#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_dump.h"
#include "r300_context.h"
#include "r300_debug.h"
#include "r300_reg.h"
#include "r300_screen.h"
+#include "r300_shader_inlines.h"
/* XXX get these to r300_reg */
#define R300_PVS_DST_OPCODE(x) ((x) << 0)
@@ -84,15 +86,6 @@
(R300_PVS_MODIFIER_X | R300_PVS_MODIFIER_Y | \
R300_PVS_MODIFIER_Z | R300_PVS_MODIFIER_W)
-static const struct tgsi_full_src_register r300_constant_zero = {
- .SrcRegister.Extended = TRUE,
- .SrcRegister.File = TGSI_FILE_NULL,
- .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ZERO,
- .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ZERO,
- .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ZERO,
- .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ZERO,
-};
-
/* Temporary struct used to hold assembly state while putting together
* fragment programs. */
struct r300_vs_asm {
@@ -161,4 +154,4 @@ static struct r300_vertex_shader r300_texture_vertex_shader = {
void r300_translate_vertex_shader(struct r300_context* r300,
struct r300_vertex_shader* vs);
-#endif /* R300_STATE_TCL_H */
+#endif /* R300_VS_H */
diff --git a/src/gallium/drivers/r300/r3xx_fs.c b/src/gallium/drivers/r300/r3xx_fs.c
new file mode 100644
index 00000000000..6e05d769773
--- /dev/null
+++ b/src/gallium/drivers/r300/r3xx_fs.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2008 Corbin Simpson <[email protected]>
+ * Joakim Sindholt <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#include "r3xx_fs.h"
+
+static INLINE uint32_t r3xx_rgb_op(unsigned op)
+{
+ switch (op) {
+ case TGSI_OPCODE_MOV:
+ return R300_ALU_OUTC_CMP;
+ default:
+ return 0;
+ }
+}
+
+static INLINE uint32_t r3xx_alpha_op(unsigned op)
+{
+ switch (op) {
+ case TGSI_OPCODE_MOV:
+ return R300_ALU_OUTA_CMP;
+ default:
+ return 0;
+ }
+}
+
+static INLINE void r3xx_emit_maths(struct r3xx_fragment_shader* fs,
+ struct r300_fs_asm* assembler,
+ struct tgsi_full_src_register* src,
+ struct tgsi_full_dst_register* dst,
+ unsigned op,
+ unsigned count)
+{
+ int i = fs->alu_instruction_count;
+
+ fs->instructions[i].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
+ R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
+ R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
+ r3xx_rgb_op(op);
+ fs->instructions[i].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
+ R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ;
+ fs->instructions[i].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
+ R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
+ R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
+ r3xx_alpha_op(op);
+ fs->instructions[i].alu_alpha_addr = R300_ALPHA_ADDR0(0) |
+ R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT;
+
+ fs->alu_instruction_count++;
+}
+
+void r3xx_fs_finalize(struct r300_fragment_shader* fs,
+ struct r300_fs_asm* assembler)
+{
+ fs->stack_size = assembler->temp_count + assembler->temp_offset + 1;
+}
+
+void r3xx_fs_instruction(struct r3xx_fragment_shader* fs,
+ struct r300_fs_asm* assembler,
+ struct tgsi_full_instruction* inst)
+{
+ switch (inst->Instruction.Opcode) {
+ case TGSI_OPCODE_MOV:
+ /* src0 -> src1 and src2 forced to zero */
+ inst->FullSrcRegisters[1] = inst->FullSrcRegisters[0];
+ inst->FullSrcRegisters[2] = r300_constant_zero;
+ r3xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
+ break;
+ case TGSI_OPCODE_END:
+ break;
+ default:
+ debug_printf("r300: fs: Bad opcode %d\n",
+ inst->Instruction.Opcode);
+ break;
+ }
+}
diff --git a/src/gallium/drivers/r300/r3xx_fs.h b/src/gallium/drivers/r300/r3xx_fs.h
new file mode 100644
index 00000000000..3da39ec2526
--- /dev/null
+++ b/src/gallium/drivers/r300/r3xx_fs.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2008 Corbin Simpson <[email protected]>
+ * Joakim Sindholt <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef R3XX_FS_H
+#define R3XX_FS_H
+
+#include "r300_fs_inlines.h"
+
+static struct r3xx_fragment_shader r3xx_passthrough_fragment_shader = {
+ .alu_instruction_count = 1,
+ .tex_instruction_count = 0,
+ .indirections = 0,
+ .shader.stack_size = 1,
+
+ .instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
+ R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
+ R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
+ R300_ALU_OUTC_CMP,
+ .instructions[0].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
+ R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ,
+ .instructions[0].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
+ R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
+ R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
+ R300_ALU_OUTA_CMP,
+ .instructions[0].alu_alpha_addr = R300_ALPHA_ADDR0(0) |
+ R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT,
+};
+
+static struct r3xx_fragment_shader r3xx_texture_fragment_shader = {
+ .alu_instruction_count = 1,
+ .tex_instruction_count = 0,
+ .indirections = 0,
+ .shader.stack_size = 1,
+
+ .instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
+ R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
+ R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
+ R300_ALU_OUTC_CMP,
+ .instructions[0].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
+ R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ,
+ .instructions[0].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
+ R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
+ R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
+ R300_ALU_OUTA_CMP,
+ .instructions[0].alu_alpha_addr = R300_ALPHA_ADDR0(0) |
+ R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT,
+};
+
+void r3xx_fs_finalize(struct r300_fragment_shader* fs,
+ struct r300_fs_asm* assembler);
+
+void r3xx_fs_instruction(struct r3xx_fragment_shader* fs,
+ struct r300_fs_asm* assembler,
+ struct tgsi_full_instruction* inst);
+
+#endif /* R3XX_FS_H */
diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r5xx_fs.c
index cc7f6a7c4b0..99d826278ce 100644
--- a/src/gallium/drivers/r300/r300_state_shader.c
+++ b/src/gallium/drivers/r300/r5xx_fs.c
@@ -1,5 +1,6 @@
/*
* Copyright 2008 Corbin Simpson <[email protected]>
+ * Joakim Sindholt <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -20,104 +21,9 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#include "r300_state_shader.h"
+#include "r5xx_fs.h"
-static void r300_fs_declare(struct r300_fs_asm* assembler,
- struct tgsi_full_declaration* decl)
-{
- switch (decl->Declaration.File) {
- case TGSI_FILE_INPUT:
- switch (decl->Semantic.SemanticName) {
- case TGSI_SEMANTIC_COLOR:
- assembler->color_count++;
- break;
- case TGSI_SEMANTIC_FOG:
- case TGSI_SEMANTIC_GENERIC:
- assembler->tex_count++;
- break;
- default:
- debug_printf("r300: fs: Bad semantic declaration %d\n",
- decl->Semantic.SemanticName);
- break;
- }
- break;
- case TGSI_FILE_OUTPUT:
- /* Depth write. Mark the position of the output so we can
- * identify it later. */
- if (decl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION) {
- assembler->depth_output = decl->DeclarationRange.First;
- }
- break;
- case TGSI_FILE_CONSTANT:
- break;
- case TGSI_FILE_TEMPORARY:
- assembler->temp_count++;
- break;
- default:
- debug_printf("r300: fs: Bad file %d\n", decl->Declaration.File);
- break;
- }
-
- assembler->temp_offset = assembler->color_count + assembler->tex_count;
-}
-
-static INLINE unsigned r300_fs_src(struct r300_fs_asm* assembler,
- struct tgsi_src_register* src)
-{
- switch (src->File) {
- case TGSI_FILE_NULL:
- return 0;
- case TGSI_FILE_INPUT:
- /* XXX may be wrong */
- return src->Index;
- break;
- case TGSI_FILE_TEMPORARY:
- return src->Index + assembler->temp_offset;
- break;
- case TGSI_FILE_IMMEDIATE:
- return (src->Index + assembler->imm_offset) | (1 << 8);
- break;
- case TGSI_FILE_CONSTANT:
- /* XXX magic */
- return src->Index | (1 << 8);
- break;
- default:
- debug_printf("r300: fs: Unimplemented src %d\n", src->File);
- break;
- }
- return 0;
-}
-
-static INLINE unsigned r300_fs_dst(struct r300_fs_asm* assembler,
- struct tgsi_dst_register* dst)
-{
- switch (dst->File) {
- case TGSI_FILE_NULL:
- /* This happens during KIL instructions. */
- return 0;
- break;
- case TGSI_FILE_OUTPUT:
- return 0;
- break;
- case TGSI_FILE_TEMPORARY:
- return dst->Index + assembler->temp_offset;
- break;
- default:
- debug_printf("r300: fs: Unimplemented dst %d\n", dst->File);
- break;
- }
- return 0;
-}
-
-static INLINE boolean r300_fs_is_depr(struct r300_fs_asm* assembler,
- struct tgsi_dst_register* dst)
-{
- return (assembler->writes_depth &&
- (dst->File == TGSI_FILE_OUTPUT) &&
- (dst->Index == assembler->depth_output));
-}
-
-static INLINE unsigned r500_fix_swiz(unsigned s)
+static INLINE unsigned r5xx_fix_swiz(unsigned s)
{
/* For historical reasons, the swizzle values x, y, z, w, and 0 are
* equivalent to the actual machine code, but 1 is not. Thus, we just
@@ -129,13 +35,13 @@ static INLINE unsigned r500_fix_swiz(unsigned s)
}
}
-static uint32_t r500_rgba_swiz(struct tgsi_full_src_register* reg)
+static uint32_t r5xx_rgba_swiz(struct tgsi_full_src_register* reg)
{
if (reg->SrcRegister.Extended) {
- return r500_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleX) |
- (r500_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleY) << 3) |
- (r500_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleZ) << 6) |
- (r500_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleW) << 9);
+ return r5xx_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleX) |
+ (r5xx_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleY) << 3) |
+ (r5xx_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleZ) << 6) |
+ (r5xx_fix_swiz(reg->SrcRegisterExtSwz.ExtSwizzleW) << 9);
} else {
return reg->SrcRegister.SwizzleX |
(reg->SrcRegister.SwizzleY << 3) |
@@ -144,7 +50,7 @@ static uint32_t r500_rgba_swiz(struct tgsi_full_src_register* reg)
}
}
-static uint32_t r500_strq_swiz(struct tgsi_full_src_register* reg)
+static uint32_t r5xx_strq_swiz(struct tgsi_full_src_register* reg)
{
return reg->SrcRegister.SwizzleX |
(reg->SrcRegister.SwizzleY << 2) |
@@ -152,43 +58,23 @@ static uint32_t r500_strq_swiz(struct tgsi_full_src_register* reg)
(reg->SrcRegister.SwizzleW << 6);
}
-static INLINE uint32_t r500_rgb_swiz(struct tgsi_full_src_register* reg)
+static INLINE uint32_t r5xx_rgb_swiz(struct tgsi_full_src_register* reg)
{
/* Only the first 9 bits... */
- return (r500_rgba_swiz(reg) & 0x1ff) |
+ return (r5xx_rgba_swiz(reg) & 0x1ff) |
(reg->SrcRegister.Negate ? (1 << 9) : 0) |
(reg->SrcRegisterExtMod.Absolute ? (1 << 10) : 0);
}
-static INLINE uint32_t r500_alpha_swiz(struct tgsi_full_src_register* reg)
+static INLINE uint32_t r5xx_alpha_swiz(struct tgsi_full_src_register* reg)
{
/* Only the last 3 bits... */
- return (r500_rgba_swiz(reg) >> 9) |
+ return (r5xx_rgba_swiz(reg) >> 9) |
(reg->SrcRegister.Negate ? (1 << 9) : 0) |
(reg->SrcRegisterExtMod.Absolute ? (1 << 10) : 0);
}
-static INLINE uint32_t r300_rgb_op(unsigned op)
-{
- switch (op) {
- case TGSI_OPCODE_MOV:
- return R300_ALU_OUTC_CMP;
- default:
- return 0;
- }
-}
-
-static INLINE uint32_t r300_alpha_op(unsigned op)
-{
- switch (op) {
- case TGSI_OPCODE_MOV:
- return R300_ALU_OUTA_CMP;
- default:
- return 0;
- }
-}
-
-static INLINE uint32_t r500_rgba_op(unsigned op)
+static INLINE uint32_t r5xx_rgba_op(unsigned op)
{
switch (op) {
case TGSI_OPCODE_COS:
@@ -224,7 +110,7 @@ static INLINE uint32_t r500_rgba_op(unsigned op)
}
}
-static INLINE uint32_t r500_alpha_op(unsigned op)
+static INLINE uint32_t r5xx_alpha_op(unsigned op)
{
switch (op) {
case TGSI_OPCODE_COS:
@@ -264,7 +150,7 @@ static INLINE uint32_t r500_alpha_op(unsigned op)
}
}
-static INLINE uint32_t r500_tex_op(unsigned op)
+static INLINE uint32_t r5xx_tex_op(unsigned op)
{
switch (op) {
case TGSI_OPCODE_KIL:
@@ -280,33 +166,8 @@ static INLINE uint32_t r500_tex_op(unsigned op)
}
}
-static INLINE void r300_emit_maths(struct r300_fragment_shader* fs,
- struct r300_fs_asm* assembler,
- struct tgsi_full_src_register* src,
- struct tgsi_full_dst_register* dst,
- unsigned op,
- unsigned count)
-{
- int i = fs->alu_instruction_count;
-
- fs->instructions[i].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
- r300_rgb_op(op);
- fs->instructions[i].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
- R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ;
- fs->instructions[i].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
- r300_alpha_op(op);
- fs->instructions[i].alu_alpha_addr = R300_ALPHA_ADDR0(0) |
- R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT;
-
- fs->alu_instruction_count++;
-}
-
/* Setup an ALU operation. */
-static INLINE void r500_emit_maths(struct r500_fragment_shader* fs,
+static INLINE void r5xx_emit_maths(struct r5xx_fragment_shader* fs,
struct r300_fs_asm* assembler,
struct tgsi_full_src_register* src,
struct tgsi_full_dst_register* dst,
@@ -343,9 +204,9 @@ static INLINE void r500_emit_maths(struct r500_fragment_shader* fs,
R500_ALPHA_ADDR2(r300_fs_src(assembler, &src[2].SrcRegister));
fs->instructions[i].inst5 |=
R500_ALU_RGBA_SEL_C_SRC2 |
- R500_SWIZ_RGBA_C(r500_rgb_swiz(&src[2])) |
+ R500_SWIZ_RGBA_C(r5xx_rgb_swiz(&src[2])) |
R500_ALU_RGBA_ALPHA_SEL_C_SRC2 |
- R500_SWIZ_ALPHA_C(r500_alpha_swiz(&src[2]));
+ R500_SWIZ_ALPHA_C(r5xx_alpha_swiz(&src[2]));
case 2:
fs->instructions[i].inst1 |=
R500_RGB_ADDR1(r300_fs_src(assembler, &src[1].SrcRegister));
@@ -353,10 +214,10 @@ static INLINE void r500_emit_maths(struct r500_fragment_shader* fs,
R500_ALPHA_ADDR1(r300_fs_src(assembler, &src[1].SrcRegister));
fs->instructions[i].inst3 =
R500_ALU_RGB_SEL_B_SRC1 |
- R500_SWIZ_RGB_B(r500_rgb_swiz(&src[1]));
+ R500_SWIZ_RGB_B(r5xx_rgb_swiz(&src[1]));
fs->instructions[i].inst4 |=
R500_ALPHA_SEL_B_SRC1 |
- R500_SWIZ_ALPHA_B(r500_alpha_swiz(&src[1]));
+ R500_SWIZ_ALPHA_B(r5xx_alpha_swiz(&src[1]));
case 1:
case 0:
default:
@@ -366,20 +227,20 @@ static INLINE void r500_emit_maths(struct r500_fragment_shader* fs,
R500_ALPHA_ADDR0(r300_fs_src(assembler, &src[0].SrcRegister));
fs->instructions[i].inst3 |=
R500_ALU_RGB_SEL_A_SRC0 |
- R500_SWIZ_RGB_A(r500_rgb_swiz(&src[0]));
+ R500_SWIZ_RGB_A(r5xx_rgb_swiz(&src[0]));
fs->instructions[i].inst4 |=
R500_ALPHA_SEL_A_SRC0 |
- R500_SWIZ_ALPHA_A(r500_alpha_swiz(&src[0]));
+ R500_SWIZ_ALPHA_A(r5xx_alpha_swiz(&src[0]));
break;
}
- fs->instructions[i].inst4 |= r500_alpha_op(op);
- fs->instructions[i].inst5 |= r500_rgba_op(op);
+ fs->instructions[i].inst4 |= r5xx_alpha_op(op);
+ fs->instructions[i].inst5 |= r5xx_rgba_op(op);
fs->instruction_count++;
}
-static INLINE void r500_emit_tex(struct r500_fragment_shader* fs,
+static INLINE void r5xx_emit_tex(struct r5xx_fragment_shader* fs,
struct r300_fs_asm* assembler,
struct tgsi_full_src_register* src,
struct tgsi_full_dst_register* dst,
@@ -392,10 +253,10 @@ static INLINE void r500_emit_tex(struct r500_fragment_shader* fs,
R500_INST_TEX_SEM_WAIT;
fs->instructions[i].inst1 = R500_TEX_ID(0) |
R500_TEX_SEM_ACQUIRE | //R500_TEX_IGNORE_UNCOVERED |
- r500_tex_op(op);
+ r5xx_tex_op(op);
fs->instructions[i].inst2 =
R500_TEX_SRC_ADDR(r300_fs_src(assembler, &src->SrcRegister)) |
- R500_SWIZ_TEX_STRQ(r500_strq_swiz(src)) |
+ R500_SWIZ_TEX_STRQ(r5xx_strq_swiz(src)) |
R500_TEX_DST_ADDR(r300_fs_dst(assembler, &dst->DstRegister)) |
R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G |
R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A;
@@ -412,37 +273,24 @@ static INLINE void r500_emit_tex(struct r500_fragment_shader* fs,
src[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
src[1] = src[0];
- src[2] = r500_constant_zero;
- r500_emit_maths(fs, assembler, src, dst, TGSI_OPCODE_MOV, 3);
+ src[2] = r300_constant_zero;
+ r5xx_emit_maths(fs, assembler, src, dst, TGSI_OPCODE_MOV, 3);
} else {
fs->instruction_count++;
}
}
-static void r300_fs_instruction(struct r300_fragment_shader* fs,
- struct r300_fs_asm* assembler,
- struct tgsi_full_instruction* inst)
+void r5xx_fs_finalize(struct r5xx_fragment_shader* fs,
+ struct r300_fs_asm* assembler)
{
- switch (inst->Instruction.Opcode) {
- case TGSI_OPCODE_MOV:
- /* src0 -> src1 and src2 forced to zero */
- inst->FullSrcRegisters[1] = inst->FullSrcRegisters[0];
- inst->FullSrcRegisters[2] = r500_constant_zero;
- r300_emit_maths(fs, assembler, inst->FullSrcRegisters,
- &inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
- break;
- case TGSI_OPCODE_END:
- break;
- default:
- debug_printf("r300: fs: Bad opcode %d\n",
- inst->Instruction.Opcode);
- break;
- }
+ /* XXX should this just go with OPCODE_END? */
+ fs->instructions[fs->instruction_count - 1].inst0 |=
+ R500_INST_LAST;
}
-static void r500_fs_instruction(struct r500_fragment_shader* fs,
- struct r300_fs_asm* assembler,
- struct tgsi_full_instruction* inst)
+void r5xx_fs_instruction(struct r5xx_fragment_shader* fs,
+ struct r300_fs_asm* assembler,
+ struct tgsi_full_instruction* inst)
{
/* Switch between opcodes. When possible, prefer using the official
* AMD/ATI names for opcodes, please, as it facilitates using the
@@ -465,7 +313,7 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
case TGSI_OPCODE_DDX:
case TGSI_OPCODE_DDY:
case TGSI_OPCODE_FRC:
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], inst->Instruction.Opcode, 1);
break;
@@ -486,7 +334,7 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
/* Fall through */
case TGSI_OPCODE_DP3:
case TGSI_OPCODE_DP4:
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], inst->Instruction.Opcode, 2);
break;
@@ -496,7 +344,7 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
inst->FullSrcRegisters[3] = inst->FullSrcRegisters[2];
inst->FullSrcRegisters[2] = inst->FullSrcRegisters[0];
inst->FullSrcRegisters[0] = inst->FullSrcRegisters[3];
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
break;
@@ -510,18 +358,18 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
/* Force src0 to one, move all registers over */
inst->FullSrcRegisters[2] = inst->FullSrcRegisters[1];
inst->FullSrcRegisters[1] = inst->FullSrcRegisters[0];
- inst->FullSrcRegisters[0] = r500_constant_one;
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ inst->FullSrcRegisters[0] = r300_constant_one;
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
break;
case TGSI_OPCODE_MUL:
/* Force our src2 to zero */
- inst->FullSrcRegisters[2] = r500_constant_zero;
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ inst->FullSrcRegisters[2] = r300_constant_zero;
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
break;
case TGSI_OPCODE_MAD:
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
break;
@@ -534,8 +382,8 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
case TGSI_OPCODE_SWZ:
/* src0 -> src1 and src2 forced to zero */
inst->FullSrcRegisters[1] = inst->FullSrcRegisters[0];
- inst->FullSrcRegisters[2] = r500_constant_zero;
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ inst->FullSrcRegisters[2] = r300_constant_zero;
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], inst->Instruction.Opcode, 3);
break;
@@ -550,7 +398,7 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
inst->FullDstRegisters[0].DstRegister.Index =
assembler->temp_count;
inst->FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], TGSI_OPCODE_MAD, 3);
inst->FullSrcRegisters[2].SrcRegister.Index =
assembler->temp_count;
@@ -563,7 +411,7 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
inst->FullSrcRegisters[0].SrcRegister.Negate =
!(inst->FullSrcRegisters[0].SrcRegister.Negate);
inst->FullDstRegisters[0] = inst->FullDstRegisters[1];
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], TGSI_OPCODE_MAD, 3);
break;
case TGSI_OPCODE_POW:
@@ -576,7 +424,7 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
inst->FullDstRegisters[0].DstRegister.Index =
assembler->temp_count;
inst->FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], TGSI_OPCODE_LG2, 1);
inst->FullSrcRegisters[0].SrcRegister.Index =
assembler->temp_count;
@@ -585,11 +433,11 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
inst->FullSrcRegisters[0].SrcRegister.SwizzleY = TGSI_SWIZZLE_Y;
inst->FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_Z;
inst->FullSrcRegisters[0].SrcRegister.SwizzleW = TGSI_SWIZZLE_W;
- inst->FullSrcRegisters[2] = r500_constant_zero;
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ inst->FullSrcRegisters[2] = r300_constant_zero;
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], TGSI_OPCODE_MUL, 3);
inst->FullDstRegisters[0] = inst->FullDstRegisters[1];
- r500_emit_maths(fs, assembler, inst->FullSrcRegisters,
+ r5xx_emit_maths(fs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], TGSI_OPCODE_EX2, 1);
break;
@@ -598,7 +446,7 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
case TGSI_OPCODE_TEX:
case TGSI_OPCODE_TXB:
case TGSI_OPCODE_TXP:
- r500_emit_tex(fs, assembler, &inst->FullSrcRegisters[0],
+ r5xx_emit_tex(fs, assembler, &inst->FullSrcRegisters[0],
&inst->FullDstRegisters[0], inst->Instruction.Opcode);
break;
@@ -617,102 +465,3 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,
R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP;
}
}
-
-static void r300_fs_finalize(struct r3xx_fragment_shader* fs,
- struct r300_fs_asm* assembler)
-{
- fs->stack_size = assembler->temp_count + assembler->temp_offset + 1;
-}
-
-static void r500_fs_finalize(struct r500_fragment_shader* fs,
- struct r300_fs_asm* assembler)
-{
- /* XXX should this just go with OPCODE_END? */
- fs->instructions[fs->instruction_count - 1].inst0 |=
- R500_INST_LAST;
-}
-
-void r300_translate_fragment_shader(struct r300_context* r300,
- struct r3xx_fragment_shader* fs)
-{
- struct tgsi_parse_context parser;
- int i;
- boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500;
- struct r300_constant_buffer* consts =
- &r300->shader_constants[PIPE_SHADER_FRAGMENT];
-
- struct r300_fs_asm* assembler = CALLOC_STRUCT(r300_fs_asm);
- if (assembler == NULL) {
- return;
- }
- /* Setup starting offset for immediates. */
- assembler->imm_offset = consts->user_count;
- /* Enable depth writes, if needed. */
- assembler->writes_depth = fs->info.writes_z;
-
- /* Make sure we start at the beginning of the shader. */
- if (is_r500) {
- ((struct r500_fragment_shader*)fs)->instruction_count = 0;
- }
-
- tgsi_parse_init(&parser, fs->state.tokens);
-
- while (!tgsi_parse_end_of_tokens(&parser)) {
- tgsi_parse_token(&parser);
-
- /* This is seriously the lamest way to create fragment programs ever.
- * I blame TGSI. */
- switch (parser.FullToken.Token.Type) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- /* Allocated registers sitting at the beginning
- * of the program. */
- r300_fs_declare(assembler, &parser.FullToken.FullDeclaration);
- break;
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- debug_printf("r300: Emitting immediate to constant buffer, "
- "position %d\n",
- assembler->imm_offset + assembler->imm_count);
- /* I am not amused by the length of these. */
- for (i = 0; i < 4; i++) {
- consts->constants[assembler->imm_offset +
- assembler->imm_count][i] =
- parser.FullToken.FullImmediate.u.ImmediateFloat32[i]
- .Float;
- }
- assembler->imm_count++;
- break;
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- if (is_r500) {
- r500_fs_instruction((struct r500_fragment_shader*)fs,
- assembler, &parser.FullToken.FullInstruction);
- } else {
- r300_fs_instruction((struct r300_fragment_shader*)fs,
- assembler, &parser.FullToken.FullInstruction);
- }
- break;
- }
- }
-
- debug_printf("r300: fs: %d texs and %d colors, first free reg is %d\n",
- assembler->tex_count, assembler->color_count,
- assembler->tex_count + assembler->color_count);
-
- consts->count = consts->user_count + assembler->imm_count;
- fs->uses_imms = assembler->imm_count;
- debug_printf("r300: fs: %d total constants, "
- "%d from user and %d from immediates\n", consts->count,
- consts->user_count, assembler->imm_count);
- r300_fs_finalize(fs, assembler);
- if (is_r500) {
- r500_fs_finalize((struct r500_fragment_shader*)fs, assembler);
- }
-
- tgsi_dump(fs->state.tokens);
- /* XXX finish r300 dumper too */
- if (is_r500) {
- r500_fs_dump((struct r500_fragment_shader*)fs);
- }
-
- tgsi_parse_free(&parser);
- FREE(assembler);
-}
diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r5xx_fs.h
index b6087404cef..629e587be4d 100644
--- a/src/gallium/drivers/r300/r300_state_shader.h
+++ b/src/gallium/drivers/r300/r5xx_fs.h
@@ -1,5 +1,6 @@
/*
* Copyright 2008 Corbin Simpson <[email protected]>
+ * Joakim Sindholt <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -20,15 +21,10 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
-#ifndef R300_STATE_SHADER_H
-#define R300_STATE_SHADER_H
+#ifndef R5XX_FS_H
+#define R5XX_FS_H
-#include "tgsi/tgsi_parse.h"
-
-#include "r300_context.h"
-#include "r300_debug.h"
-#include "r300_reg.h"
-#include "r300_screen.h"
+#include "r300_fs_inlines.h"
/* XXX this all should find its way back to r300_reg */
/* Swizzle tools */
@@ -59,78 +55,7 @@
#define R500_ALU_OMASK(x) ((x) << 15)
#define R500_W_OMASK (1 << 31)
-/* TGSI constants. TGSI is like XML: If it can't solve your problems, you're
- * not using enough of it. */
-static const struct tgsi_full_src_register r500_constant_zero = {
- .SrcRegister.Extended = TRUE,
- .SrcRegister.File = TGSI_FILE_NULL,
- .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ZERO,
- .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ZERO,
- .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ZERO,
- .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ZERO,
-};
-
-static const struct tgsi_full_src_register r500_constant_one = {
- .SrcRegister.Extended = TRUE,
- .SrcRegister.File = TGSI_FILE_NULL,
- .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ONE,
- .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ONE,
- .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ONE,
- .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ONE,
-};
-
-/* Temporary struct used to hold assembly state while putting together
- * fragment programs. */
-struct r300_fs_asm {
- /* Pipe context. */
- struct r300_context* r300;
- /* Number of colors. */
- unsigned color_count;
- /* Number of texcoords. */
- unsigned tex_count;
- /* Offset for temporary registers. Inputs and temporaries have no
- * distinguishing markings, so inputs start at 0 and the first usable
- * temporary register is after all inputs. */
- unsigned temp_offset;
- /* Number of requested temporary registers. */
- unsigned temp_count;
- /* Offset for immediate constants. Neither R300 nor R500 can do four
- * inline constants per source, so instead we copy immediates into the
- * constant buffer. */
- unsigned imm_offset;
- /* Number of immediate constants. */
- unsigned imm_count;
- /* Are depth writes enabled? */
- boolean writes_depth;
- /* Depth write offset. This is the TGSI output that corresponds to
- * depth writes. */
- unsigned depth_output;
-};
-
-void r300_translate_fragment_shader(struct r300_context* r300,
- struct r3xx_fragment_shader* fs);
-
-static struct r300_fragment_shader r300_passthrough_fragment_shader = {
- .alu_instruction_count = 1,
- .tex_instruction_count = 0,
- .indirections = 0,
- .shader.stack_size = 1,
-
- .instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
- R300_ALU_OUTC_CMP,
- .instructions[0].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
- R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ,
- .instructions[0].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
- R300_ALU_OUTA_CMP,
- .instructions[0].alu_alpha_addr = R300_ALPHA_ADDR0(0) |
- R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT,
-};
-
-static struct r500_fragment_shader r500_passthrough_fragment_shader = {
+static struct r5xx_fragment_shader r5xx_passthrough_fragment_shader = {
.shader.stack_size = 0,
.instruction_count = 1,
.instructions[0].inst0 = R500_INST_TYPE_OUT |
@@ -156,27 +81,7 @@ static struct r500_fragment_shader r500_passthrough_fragment_shader = {
R500_ALU_RGBA_A_SWIZ_0,
};
-static struct r300_fragment_shader r300_texture_fragment_shader = {
- .alu_instruction_count = 1,
- .tex_instruction_count = 0,
- .indirections = 0,
- .shader.stack_size = 1,
-
- .instructions[0].alu_rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) |
- R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) |
- R300_ALU_OUTC_CMP,
- .instructions[0].alu_rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) |
- R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ,
- .instructions[0].alu_alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) |
- R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) |
- R300_ALU_OUTA_CMP,
- .instructions[0].alu_alpha_addr = R300_ALPHA_ADDR0(0) |
- R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT,
-};
-
-static struct r500_fragment_shader r500_texture_fragment_shader = {
+static struct r5xx_fragment_shader r5xx_texture_fragment_shader = {
.shader.stack_size = 1,
.instruction_count = 2,
.instructions[0].inst0 = R500_INST_TYPE_TEX |
@@ -217,4 +122,11 @@ static struct r500_fragment_shader r500_texture_fragment_shader = {
R500_ALU_RGBA_A_SWIZ_0,
};
-#endif /* R300_STATE_SHADER_H */
+void r5xx_fs_finalize(struct r5xx_fragment_shader* fs,
+ struct r300_fs_asm* assembler);
+
+void r5xx_fs_instruction(struct r5xx_fragment_shader* fs,
+ struct r300_fs_asm* assembler,
+ struct tgsi_full_instruction* inst);
+
+#endif /* R5XX_FS_H */