summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h5
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c107
2 files changed, 111 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index 37c58a0f2fd..db708cc10f3 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -59,8 +59,11 @@ typedef struct r300_context *r300ContextPtr;
#define WARN_ONCE(a) { \
static int warn##__LINE__=1; \
if(warn##__LINE__){ \
- fprintf(stderr, "%s:%s line %d ***WARN_ONCE*** " a, \
+ fprintf(stderr, "*********************************WARN_ONCE*********************************\n"); \
+ fprintf(stderr, "File %s function %s line %d\n", \
__FILE__, __FUNCTION__, __LINE__); \
+ fprintf(stderr, a);\
+ fprintf(stderr, "***************************************************************************\n"); \
warn##__LINE__=0;\
} \
}
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 5a577b2ce31..7a23eddfac7 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1432,6 +1432,112 @@ void r300SetupVertexProgram(r300ContextPtr rmesa)
#endif
}
+
+/* just a skeleton for now.. */
+void r300GenerateTexturePixelShader(r300ContextPtr r300)
+{
+ int i, mtu;
+ mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
+ GLenum envMode;
+
+ int tex_inst=0, alu_inst=0;
+
+ for(i=0;i<mtu;i++){
+ /* No need to proliferate {} */
+ if(! (r300->state.render_inputs & (_TNL_BIT_TEX0<<i)))continue;
+
+ envMode = r300->radeon.glCtx->Texture.Unit[i].EnvMode;
+ //fprintf(stderr, "envMode=%s\n", _mesa_lookup_enum_by_nr(envMode));
+
+ /* Fetch textured pixel */
+
+ r300->state.pixel_shader.program.tex.inst[tex_inst]=0x00018000;
+ tex_inst++;
+
+ switch(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->ModeRGB){
+ case GL_REPLACE:
+ WARN_ONCE("ModeA==GL_REPLACE is possibly broken.\n");
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst0=
+ EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst1=
+ EASY_PFS_INSTR1(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, NONE, ALL);
+ break;
+ case GL_MODULATE:
+ WARN_ONCE("ModeRGB==GL_MODULATE is possibly broken.\n");
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst0=
+ EASY_PFS_INSTR0(MAD, SRC0C_XYZ, SRC1C_XYZ, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst1=
+ EASY_PFS_INSTR1(0, 0, 1, 0 | PFS_FLAG_CONST, NONE, ALL);
+
+ break;
+ default:
+ fprintf(stderr, "ModeRGB=%s is not implemented yet !\n",
+ _mesa_lookup_enum_by_nr(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->ModeRGB));
+ /* PFS_NOP */
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst0=
+ EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst1=
+ EASY_PFS_INSTR1(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, NONE, ALL);
+ }
+ switch(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->ModeA){
+ case GL_REPLACE:
+ WARN_ONCE("ModeA==GL_REPLACE is possibly broken.\n");
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst2=
+ EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst3=
+ EASY_PFS_INSTR3(0, 0, 0| PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, OUTPUT);
+
+ #if 0
+ fprintf(stderr, "numArgsA=%d sourceA[0]=%s op=%d\n",
+ r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->_NumArgsA,
+ _mesa_lookup_enum_by_nr(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->SourceA[0]),
+ r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->OperandA[0]-GL_SRC_ALPHA);
+ #endif
+ break;
+ case GL_MODULATE:
+ WARN_ONCE("ModeA==GL_MODULATE is possibly broken.\n");
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst2=
+ EASY_PFS_INSTR2(MAD, SRC0A, SRC1A, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst3=
+ EASY_PFS_INSTR3(0, 0, 1, 0 | PFS_FLAG_CONST, OUTPUT);
+
+ break;
+ default:
+ fprintf(stderr, "ModeA=%s is not implemented yet !\n",
+ _mesa_lookup_enum_by_nr(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->ModeA));
+ /* PFS_NOP */
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst2=
+ EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst3=
+ EASY_PFS_INSTR3(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, OUTPUT);
+
+ }
+
+ alu_inst++;
+ }
+
+ r300->state.pixel_shader.program.tex.length=tex_inst;
+ r300->state.pixel_shader.program.tex_offset=0;
+ r300->state.pixel_shader.program.tex_end=tex_inst-1;
+
+ #if 0
+ /* saturate last instruction, like i915 driver does */
+ r300->state.pixel_shader.program.alu.inst[alu_inst-1].inst0|=R300_FPI0_OUTC_SAT;
+ r300->state.pixel_shader.program.alu.inst[alu_inst-1].inst2|=R300_FPI2_OUTA_SAT;
+ #endif
+
+ r300->state.pixel_shader.program.alu.length=alu_inst;
+ r300->state.pixel_shader.program.alu_offset=0;
+ r300->state.pixel_shader.program.alu_end=alu_inst-1;
+}
+
void r300SetupPixelShader(r300ContextPtr rmesa)
{
int i,k;
@@ -1441,6 +1547,7 @@ int i,k;
/* textures enabled ? */
if(rmesa->state.texture.tc_count>0){
rmesa->state.pixel_shader=SINGLE_TEXTURE_PIXEL_SHADER;
+ r300GenerateTexturePixelShader(rmesa);
} else {
rmesa->state.pixel_shader=FLAT_COLOR_PIXEL_SHADER;
}