Textures still not working. RS block shenanigans expected.
r300->shader_constants[PIPE_SHADER_VERTEX].user_count *
(sizeof(float) * 4));
- /* Abandon all hope, ye who enter here. */
draw_arrays(r300->draw, mode, start, count);
for (i = 0; i < r300->vertex_buffer_count; i++) {
struct r500_fragment_shader* fs)
{
CS_LOCALS(r300);
+ struct r300_constant_buffer* constants =
+ &r300->shader_constants[PIPE_SHADER_FRAGMENT];
int i;
- BEGIN_CS(9 + (fs->instruction_count * 6));
+ BEGIN_CS(9 + (fs->instruction_count * 6) + (constants->count ? 3 : 0) +
+ (constants->count * 4));
OUT_CS_REG(R500_US_CONFIG, R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO);
OUT_CS_REG(R500_US_PIXSIZE, fs->shader.stack_size);
OUT_CS_REG(R500_US_CODE_ADDR, R500_US_CODE_START_ADDR(0) |
- R500_US_CODE_END_ADDR(fs->instruction_count));
+ R500_US_CODE_END_ADDR(fs->instruction_count));
OUT_CS_REG(R500_GA_US_VECTOR_INDEX, R500_GA_US_VECTOR_INDEX_TYPE_INSTR);
- OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA,
- fs->instruction_count * 6);
+ OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, fs->instruction_count * 6);
for (i = 0; i < fs->instruction_count; i++) {
OUT_CS(fs->instructions[i].inst0);
OUT_CS(fs->instructions[i].inst1);
OUT_CS(fs->instructions[i].inst4);
OUT_CS(fs->instructions[i].inst5);
}
+
+ if (constants->count) {
+ OUT_CS_REG(R500_GA_US_VECTOR_INDEX,
+ R500_GA_US_VECTOR_INDEX_TYPE_CONST);
+ OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, constants->count * 4);
+ for (i = 0; i < constants->count; i++) {
+ OUT_CS(constants->constants[i][0]);
+ OUT_CS(constants->constants[i][1]);
+ OUT_CS(constants->constants[i][2]);
+ OUT_CS(constants->constants[i][3]);
+ }
+ }
+
END_CS;
}
}
for (i = 0; i < 8; i++) {
OUT_CS(rs->ip[i]);
+ //debug_printf("ip %d: 0x%08x\n", i, rs->ip[i]);
}
OUT_CS_REG_SEQ(R300_RS_COUNT, 2);
}
for (i = 0; i < 8; i++) {
OUT_CS(rs->inst[i]);
+ //debug_printf("inst %d: 0x%08x\n", i, rs->inst[i]);
}
+ /* debug_printf("count: 0x%08x inst_count: 0x%08x\n", rs->count,
+ rs->inst_count); */
+
END_CS;
}
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;
void r500_translate_fragment_shader(struct r300_context* r300,
struct r500_fragment_shader* fs)
{
+ struct tgsi_parse_context parser;
+ int i, imm_const_offset;
+
struct r300_fs_asm* assembler = CALLOC_STRUCT(r300_fs_asm);
if (assembler == NULL) {
return;
}
- struct tgsi_parse_context parser;
tgsi_parse_init(&parser, fs->shader.state.tokens);
* of the program. */
r300_fs_declare(assembler, &parser.FullToken.FullDeclaration);
break;
+ case TGSI_TOKEN_TYPE_IMMEDIATE:
+ assembler->imm_offset++;
+ imm_const_offset = assembler->imm_offset +
+ r300->shader_constants[PIPE_SHADER_FRAGMENT].user_count;
+ /* I am not amused by the length of these. */
+ for (i = 0; i < 4; i++) {
+ r300->shader_constants[PIPE_SHADER_FRAGMENT].constants
+ [imm_const_offset][i] =
+ parser.FullToken.FullImmediate.u.ImmediateFloat32[i]
+ .Float;
+ }
+ r300->shader_constants[PIPE_SHADER_FRAGMENT].count =
+ imm_const_offset;
+ break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
r500_fs_instruction(fs, assembler,
&parser.FullToken.FullInstruction);
+ break;
}
}
/* 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 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;
};
void r300_translate_fragment_shader(struct r300_context* r300,
struct r300_capabilities* caps = r300_screen(pipe->screen)->caps;
struct r300_texture* tex = (struct r300_texture*)dest->texture;
int i;
-
- float r, g, b, a;
+ float r, g, b, a, depth;
unsigned pixpitch = tex->stride / tex->tex.block.size;
+
r = (float)((color >> 16) & 0xff) / 255.0f;
g = (float)((color >> 8) & 0xff) / 255.0f;
b = (float)((color >> 0) & 0xff) / 255.0f;