summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/r300')
-rw-r--r--src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c30
-rw-r--r--src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c11
-rw-r--r--src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c2
-rw-r--r--src/mesa/drivers/dri/r300/compiler/r500_fragprog.c7
-rw-r--r--src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c18
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_code.c14
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_code.h26
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c125
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_dataflow.h12
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_dataflow_deadcode.c14
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_emulate_branches.c29
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c11
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_optimize.c67
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c3
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c38
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c15
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c28
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h47
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c339
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c161
-rw-r--r--src/mesa/drivers/dri/r300/compiler/radeon_rename_regs.c5
-rw-r--r--src/mesa/drivers/dri/r300/r300_blit.c2
-rw-r--r--src/mesa/drivers/dri/r300/r300_blit.h2
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.c36
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.h2
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.c11
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h10
-rw-r--r--src/mesa/drivers/dri/r300/r300_draw.c24
-rw-r--r--src/mesa/drivers/dri/r300/r300_emit.c8
-rw-r--r--src/mesa/drivers/dri/r300/r300_emit.h8
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog_common.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog_common.h2
-rw-r--r--src/mesa/drivers/dri/r300/r300_render.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_render.h4
-rw-r--r--src/mesa/drivers/dri/r300/r300_shader.c12
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c107
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.h6
-rw-r--r--src/mesa/drivers/dri/r300/r300_swtcl.c24
-rw-r--r--src/mesa/drivers/dri/r300/r300_swtcl.h16
-rw-r--r--src/mesa/drivers/dri/r300/r300_tex.c6
-rw-r--r--src/mesa/drivers/dri/r300/r300_tex.h2
-rw-r--r--src/mesa/drivers/dri/r300/r300_texstate.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertprog.c8
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertprog.h2
-rw-r--r--src/mesa/drivers/dri/r300/radeon_context.h4
45 files changed, 757 insertions, 553 deletions
diff --git a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
index 3b2b06fc2b..8be32ea91f 100644
--- a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
+++ b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
@@ -74,7 +74,7 @@ static void use_temporary(struct r300_fragment_program_code *code, unsigned int
code->pixsize = index;
}
-static unsigned int use_source(struct r300_fragment_program_code* code, struct radeon_pair_instruction_source src)
+static unsigned int use_source(struct r300_fragment_program_code* code, struct rc_pair_instruction_source src)
{
if (src.File == RC_FILE_CONSTANT) {
return src.Index | (1 << 5);
@@ -133,6 +133,8 @@ static unsigned int translate_alpha_opcode(struct r300_fragment_program_compiler
*/
static int emit_alu(struct r300_emit_state * emit, struct rc_pair_instruction* inst)
{
+ int ip;
+ int j;
PROG_CODE;
if (code->alu.length >= c->Base.max_alu_insts) {
@@ -140,20 +142,20 @@ static int emit_alu(struct r300_emit_state * emit, struct rc_pair_instruction* i
return 0;
}
- int ip = code->alu.length++;
- int j;
+ ip = code->alu.length++;
code->alu.inst[ip].rgb_inst = translate_rgb_opcode(c, inst->RGB.Opcode);
code->alu.inst[ip].alpha_inst = translate_alpha_opcode(c, inst->Alpha.Opcode);
for(j = 0; j < 3; ++j) {
unsigned int src = use_source(code, inst->RGB.Src[j]);
+ unsigned int arg;
code->alu.inst[ip].rgb_addr |= src << (6*j);
src = use_source(code, inst->Alpha.Src[j]);
code->alu.inst[ip].alpha_addr |= src << (6*j);
- unsigned int arg = r300FPTranslateRGBSwizzle(inst->RGB.Arg[j].Source, inst->RGB.Arg[j].Swizzle);
+ arg = r300FPTranslateRGBSwizzle(inst->RGB.Arg[j].Source, inst->RGB.Arg[j].Swizzle);
arg |= inst->RGB.Arg[j].Abs << 6;
arg |= inst->RGB.Arg[j].Negate << 5;
code->alu.inst[ip].rgb_inst |= arg << (7*j);
@@ -259,6 +261,10 @@ static int finish_node(struct r300_emit_state * emit)
{
struct r300_fragment_program_compiler * c = emit->compiler;
struct r300_fragment_program_code *code = &emit->compiler->code->code.r300;
+ unsigned alu_offset;
+ unsigned alu_end;
+ unsigned tex_offset;
+ unsigned tex_end;
if (code->alu.length == emit->node_first_alu) {
/* Generate a single NOP for this node */
@@ -268,10 +274,10 @@ static int finish_node(struct r300_emit_state * emit)
return 0;
}
- unsigned alu_offset = emit->node_first_alu;
- unsigned alu_end = code->alu.length - alu_offset - 1;
- unsigned tex_offset = emit->node_first_tex;
- unsigned tex_end = code->tex.length - tex_offset - 1;
+ alu_offset = emit->node_first_alu;
+ alu_end = code->alu.length - alu_offset - 1;
+ tex_offset = emit->node_first_tex;
+ tex_end = code->tex.length - tex_offset - 1;
if (code->tex.length == emit->node_first_tex) {
if (emit->current_node > 0) {
@@ -334,6 +340,9 @@ static int begin_tex(struct r300_emit_state * emit)
static int emit_tex(struct r300_emit_state * emit, struct rc_instruction * inst)
{
+ unsigned int unit;
+ unsigned int dest;
+ unsigned int opcode;
PROG_CODE;
if (code->tex.length >= R300_PFS_MAX_TEX_INST) {
@@ -341,9 +350,8 @@ static int emit_tex(struct r300_emit_state * emit, struct rc_instruction * inst)
return 0;
}
- unsigned int unit = inst->U.I.TexSrcUnit;
- unsigned int dest = inst->U.I.DstReg.Index;
- unsigned int opcode;
+ unit = inst->U.I.TexSrcUnit;
+ dest = inst->U.I.DstReg.Index;
switch(inst->U.I.Opcode) {
case RC_OPCODE_KIL: opcode = R300_TEX_OP_KIL; break;
diff --git a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c
index caa48fe478..2d28b06539 100644
--- a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c
+++ b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c
@@ -94,6 +94,9 @@ static const struct swizzle_data* lookup_native_swizzle(unsigned int swizzle)
*/
static int r300_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
{
+ unsigned int relevant;
+ int j;
+
if (reg.Abs)
reg.Negate = RC_MASK_NONE;
@@ -101,8 +104,6 @@ static int r300_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
opcode == RC_OPCODE_TEX ||
opcode == RC_OPCODE_TXB ||
opcode == RC_OPCODE_TXP) {
- int j;
-
if (reg.Abs || reg.Negate)
return 0;
@@ -117,8 +118,7 @@ static int r300_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
return 1;
}
- unsigned int relevant = 0;
- int j;
+ relevant = 0;
for(j = 0; j < 3; ++j)
if (GET_SWZ(reg.Swizzle, j) != RC_SWIZZLE_UNUSED)
@@ -154,9 +154,10 @@ static void r300_swizzle_split(
unsigned int matchcount = 0;
unsigned int matchmask = 0;
for(comp = 0; comp < 3; ++comp) {
+ unsigned int swz;
if (!GET_BIT(mask, comp))
continue;
- unsigned int swz = GET_SWZ(src.Swizzle, comp);
+ swz = GET_SWZ(src.Swizzle, comp);
if (swz == RC_SWIZZLE_UNUSED)
continue;
if (swz == GET_SWZ(sd->hash, comp)) {
diff --git a/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c b/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c
index 08785716db..d7d49e514b 100644
--- a/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c
+++ b/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c
@@ -392,9 +392,9 @@ static void ei_if(struct r300_vertex_program_compiler * compiler,
* don't already have one. */
if (!compiler->PredicateMask) {
unsigned int writemasks[RC_REGISTER_MAX_INDEX];
- memset(writemasks, 0, sizeof(writemasks));
struct rc_instruction * inst;
unsigned int i;
+ memset(writemasks, 0, sizeof(writemasks));
for(inst = compiler->Base.Program.Instructions.Next;
inst != &compiler->Base.Program.Instructions;
inst = inst->Next) {
diff --git a/src/mesa/drivers/dri/r300/compiler/r500_fragprog.c b/src/mesa/drivers/dri/r300/compiler/r500_fragprog.c
index 627ce374ef..289bb87ae5 100644
--- a/src/mesa/drivers/dri/r300/compiler/r500_fragprog.c
+++ b/src/mesa/drivers/dri/r300/compiler/r500_fragprog.c
@@ -39,10 +39,12 @@ int r500_transform_IF(
struct rc_instruction * inst,
void* data)
{
+ struct rc_instruction * inst_mov;
+
if (inst->U.I.Opcode != RC_OPCODE_IF)
return 0;
- struct rc_instruction * inst_mov = rc_insert_new_instruction(c, inst->Prev);
+ inst_mov = rc_insert_new_instruction(c, inst->Prev);
inst_mov->U.I.Opcode = RC_OPCODE_MOV;
inst_mov->U.I.DstReg.WriteMask = 0;
inst_mov->U.I.WriteALUResult = RC_ALURESULT_W;
@@ -251,12 +253,11 @@ void r500FragmentProgramDump(struct radeon_compiler *c, void *user)
{
struct r300_fragment_program_compiler *compiler = (struct r300_fragment_program_compiler*)c;
struct r500_fragment_program_code *code = &compiler->code->code.r500;
- fprintf(stderr, "R500 Fragment Program:\n--------\n");
-
int n, i;
uint32_t inst;
uint32_t inst0;
char *str = NULL;
+ fprintf(stderr, "R500 Fragment Program:\n--------\n");
for (n = 0; n < code->inst_end+1; n++) {
inst0 = inst = code->inst[n].inst0;
diff --git a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
index 54cff9169a..6f101c68eb 100644
--- a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
+++ b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
@@ -198,7 +198,7 @@ static void use_temporary(struct r500_fragment_program_code* code, unsigned int
code->max_temp_idx = index;
}
-static unsigned int use_source(struct r500_fragment_program_code* code, struct radeon_pair_instruction_source src)
+static unsigned int use_source(struct r500_fragment_program_code* code, struct rc_pair_instruction_source src)
{
if (src.File == RC_FILE_CONSTANT) {
return src.Index | 0x100;
@@ -227,6 +227,7 @@ static void alu_nop(struct r300_fragment_program_compiler *c, int ip)
*/
static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair_instruction *inst)
{
+ int ip;
PROG_CODE;
if (code->inst_end >= c->Base.max_alu_insts-1) {
@@ -234,7 +235,7 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair
return;
}
- int ip = ++code->inst_end;
+ ip = ++code->inst_end;
/* Quirk: MDH/MDV (DDX/DDY) need a NOP on previous non-TEX instructions. */
if (inst->RGB.Opcode == RC_OPCODE_DDX || inst->Alpha.Opcode == RC_OPCODE_DDX ||
@@ -250,7 +251,7 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair
if (inst->RGB.OutputWriteMask || inst->Alpha.OutputWriteMask || inst->Alpha.DepthWriteMask) {
code->inst[ip].inst0 = R500_INST_TYPE_OUT;
if (inst->WriteALUResult) {
- error("%s: cannot write output and ALU result at the same time");
+ error("Cannot write output and ALU result at the same time");
return;
}
} else {
@@ -357,6 +358,7 @@ static unsigned int translate_strq_swizzle(unsigned int swizzle)
*/
static int emit_tex(struct r300_fragment_program_compiler *c, struct rc_sub_instruction *inst)
{
+ int ip;
PROG_CODE;
if (code->inst_end >= c->Base.max_alu_insts-1) {
@@ -364,7 +366,7 @@ static int emit_tex(struct r300_fragment_program_compiler *c, struct rc_sub_inst
return 0;
}
- int ip = ++code->inst_end;
+ ip = ++code->inst_end;
code->inst[ip].inst0 = R500_INST_TYPE_TEX
| (inst->DstReg.WriteMask << 11)
@@ -407,12 +409,14 @@ static int emit_tex(struct r300_fragment_program_compiler *c, struct rc_sub_inst
static void emit_flowcontrol(struct emit_state * s, struct rc_instruction * inst)
{
+ unsigned int newip;
+
if (s->Code->inst_end >= s->C->max_alu_insts-1) {
rc_error(s->C, "emit_tex: Too many instructions");
return;
}
- unsigned int newip = ++s->Code->inst_end;
+ newip = ++s->Code->inst_end;
/* Currently all loops use the same integer constant to intialize
* the loop variables. */
@@ -623,6 +627,8 @@ void r500BuildFragmentProgramHwCode(struct radeon_compiler *c, void *user)
if (code->inst_end == -1 ||
(code->inst[code->inst_end].inst0 & R500_INST_TYPE_MASK) != R500_INST_TYPE_OUT) {
+ int ip;
+
/* This may happen when dead-code elimination is disabled or
* when most of the fragment program logic is leading to a KIL */
if (code->inst_end >= compiler->Base.max_alu_insts-1) {
@@ -630,7 +636,7 @@ void r500BuildFragmentProgramHwCode(struct radeon_compiler *c, void *user)
return;
}
- int ip = ++code->inst_end;
+ ip = ++code->inst_end;
code->inst[ip].inst0 = R500_INST_TYPE_OUT | R500_INST_TEX_SEM_WAIT;
}
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_code.c b/src/mesa/drivers/dri/r300/compiler/radeon_code.c
index 0eab18c344..6842fb873b 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_code.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_code.c
@@ -28,6 +28,7 @@
#include "radeon_code.h"
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include "radeon_program.h"
@@ -171,3 +172,16 @@ unsigned rc_constants_add_immediate_scalar(struct rc_constant_list * c, float da
return rc_constants_add(c, &constant);
}
+
+void rc_constants_print(struct rc_constant_list * c)
+{
+ unsigned int i;
+ for(i = 0; i < c->Count; i++) {
+ if (c->Constants[i].Type == RC_CONSTANT_IMMEDIATE) {
+ float * values = c->Constants[i].u.Immediate;
+ fprintf(stderr, "CONST[%u] = "
+ "{ %10.4f %10.4f %10.4f %10.4f }\n",
+ i, values[0],values[1], values[2], values[3]);
+ }
+ }
+}
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_code.h b/src/mesa/drivers/dri/r300/compiler/radeon_code.h
index f76676fae8..cfb6df2cd7 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_code.h
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_code.h
@@ -60,6 +60,7 @@ enum {
RC_STATE_R300_WINDOW_DIMENSION,
RC_STATE_R300_TEXRECT_FACTOR,
+ RC_STATE_R300_TEXSCALE_FACTOR,
RC_STATE_R300_VIEWPORT_SCALE,
RC_STATE_R300_VIEWPORT_OFFSET
};
@@ -89,6 +90,7 @@ unsigned rc_constants_add(struct rc_constant_list * c, struct rc_constant * cons
unsigned rc_constants_add_state(struct rc_constant_list * c, unsigned state1, unsigned state2);
unsigned rc_constants_add_immediate_vec4(struct rc_constant_list * c, const float * data);
unsigned rc_constants_add_immediate_scalar(struct rc_constant_list * c, float data, unsigned * swizzle);
+void rc_constants_print(struct rc_constant_list * c);
/**
* Compare functions.
@@ -126,11 +128,7 @@ struct r300_fragment_program_external_state {
struct {
/**
* If the sampler is used as a shadow sampler,
- * this field is:
- * 0 - GL_LUMINANCE
- * 1 - GL_INTENSITY
- * 2 - GL_ALPHA
- * depending on the depth texture mode.
+ * this field contains swizzle depending on the depth texture mode.
*/
unsigned depth_texture_swizzle:12;
@@ -150,13 +148,9 @@ struct r300_fragment_program_external_state {
unsigned compare_mode_enabled : 1;
/**
- * If the sampler needs to fake NPOT, this field is set.
- */
- unsigned fake_npot : 1;
-
- /**
- * If the sampler will recieve non-normalized coords,
- * this field is set.
+ * If the sampler will receive non-normalized coords,
+ * this field is set. The scaling factor is given by
+ * RC_STATE_R300_TEXRECT_FACTOR.
*/
unsigned non_normalized_coords : 1;
@@ -166,7 +160,13 @@ struct r300_fragment_program_external_state {
* If this field is \ref RC_WRAP_NONE (aka 0), no wrapping maths
* will be performed on the coordinates.
*/
- unsigned wrap_mode : 2;
+ unsigned wrap_mode : 3;
+
+ /**
+ * The coords are scaled after applying the wrap mode emulation
+ * and right before texture fetch. The scaling factor is given by
+ * RC_STATE_R300_TEXSCALE_FACTOR. */
+ unsigned clamp_and_scale_before_fetch : 1;
} unit[16];
};
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c
index e73700f84a..a27d395587 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.c
@@ -29,49 +29,32 @@
#include "radeon_program.h"
+struct read_write_mask_data {
+ void * UserData;
+ rc_read_write_mask_fn Cb;
+};
+
static void reads_normal_callback(
- rc_read_write_chan_fn cb,
+ void * userdata,
struct rc_instruction * fullinst,
- struct rc_src_register src,
- void * userdata)
+ struct rc_src_register * src)
{
+ struct read_write_mask_data * cb_data = userdata;
unsigned int refmask = 0;
unsigned int chan;
for(chan = 0; chan < 4; chan++) {
- refmask |= 1 << GET_SWZ(src.Swizzle, chan);
+ refmask |= 1 << GET_SWZ(src->Swizzle, chan);
}
refmask &= RC_MASK_XYZW;
- if (refmask)
- cb(userdata, fullinst, src.File, src.Index, refmask);
-
- if (refmask && src.RelAddr)
- cb(userdata, fullinst, RC_FILE_ADDRESS, 0, RC_MASK_X);
-}
-
-static void reads_normal(struct rc_instruction * fullinst, rc_read_write_chan_fn cb, void * userdata)
-{
- struct rc_sub_instruction * inst = &fullinst->U.I;
- const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->Opcode);
-
- for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) {
-
- if (inst->SrcReg[src].File == RC_FILE_NONE)
- return;
+ if (refmask) {
+ cb_data->Cb(cb_data->UserData, fullinst, src->File,
+ src->Index, refmask);
+ }
- if (inst->SrcReg[src].File == RC_FILE_PRESUB) {
- unsigned int i;
- unsigned int srcp_regs = rc_presubtract_src_reg_count(
- inst->PreSub.Opcode);
- for( i = 0; i < srcp_regs; i++) {
- reads_normal_callback(cb, fullinst,
- inst->PreSub.SrcReg[i],
- userdata);
- }
- } else {
- reads_normal_callback(cb, fullinst,
- inst->SrcReg[src], userdata);
- }
+ if (refmask && src->RelAddr) {
+ cb_data->Cb(cb_data->UserData, fullinst, RC_FILE_ADDRESS, 0,
+ RC_MASK_X);
}
}
@@ -112,7 +95,7 @@ static void pair_get_src_refmasks(unsigned int * refmasks,
}
}
-static void reads_pair(struct rc_instruction * fullinst, rc_read_write_mask_fn cb, void * userdata)
+static void reads_pair(struct rc_instruction * fullinst, rc_read_write_mask_fn cb, void * userdata)
{
struct rc_pair_instruction * inst = &fullinst->U.P;
unsigned int refmasks[3] = { 0, 0, 0 };
@@ -143,6 +126,74 @@ static void reads_pair(struct rc_instruction * fullinst, rc_read_write_mask_fn
}
}
+static void pair_sub_for_all_args(
+ struct rc_instruction * fullinst,
+ struct rc_pair_sub_instruction * sub,
+ rc_pair_read_arg_fn cb,
+ void * userdata)
+{
+ int i;
+ const struct rc_opcode_info * info = rc_get_opcode_info(sub->Opcode);
+
+ for(i = 0; i < info->NumSrcRegs; i++) {
+ cb(userdata, fullinst, &sub->Arg[i]);
+ }
+}
+
+/* This function calls the callback function (cb) for each source used by
+ * the instruction.
+ * */
+void rc_for_all_reads_src(
+ struct rc_instruction * inst,
+ rc_read_src_fn cb,
+ void * userdata)
+{
+ const struct rc_opcode_info * opcode =
+ rc_get_opcode_info(inst->U.I.Opcode);
+
+ /* This function only works with normal instructions. */
+ if (inst->Type != RC_INSTRUCTION_NORMAL) {
+ assert(0);
+ return;
+ }
+
+ for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) {
+
+ if (inst->U.I.SrcReg[src].File == RC_FILE_NONE)
+ continue;
+
+ if (inst->U.I.SrcReg[src].File == RC_FILE_PRESUB) {
+ unsigned int i;
+ unsigned int srcp_regs = rc_presubtract_src_reg_count(
+ inst->U.I.PreSub.Opcode);
+ for( i = 0; i < srcp_regs; i++) {
+ cb(userdata, inst, &inst->U.I.PreSub.SrcReg[i]);
+ }
+ } else {
+ cb(userdata, inst, &inst->U.I.SrcReg[src]);
+ }
+ }
+}
+
+/**
+ * This function calls the callback function (cb) for each arg of the RGB and
+ * alpha components.
+ */
+void rc_pair_for_all_reads_arg(
+ struct rc_instruction * inst,
+ rc_pair_read_arg_fn cb,
+ void * userdata)
+{
+ /* This function only works with pair instructions. */
+ if (inst->Type != RC_INSTRUCTION_PAIR) {
+ assert(0);
+ return;
+ }
+
+ pair_sub_for_all_args(inst, &inst->U.P.RGB, cb, userdata);
+ pair_sub_for_all_args(inst, &inst->U.P.Alpha, cb, userdata);
+}
+
/**
* Calls a callback function for all register reads.
*
@@ -153,7 +204,11 @@ static void reads_pair(struct rc_instruction * fullinst, rc_read_write_mask_fn
void rc_for_all_reads_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata)
{
if (inst->Type == RC_INSTRUCTION_NORMAL) {
- reads_normal(inst, cb, userdata);
+ struct read_write_mask_data cb_data;
+ cb_data.UserData = userdata;
+ cb_data.Cb = cb;
+
+ rc_for_all_reads_src(inst, reads_normal_callback, &cb_data);
} else {
reads_pair(inst, cb, userdata);
}
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.h b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.h
index 795d9cc2b6..d10ae3c7b7 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.h
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow.h
@@ -33,6 +33,8 @@
struct radeon_compiler;
struct rc_instruction;
struct rc_swizzle_caps;
+struct rc_src_register;
+struct rc_pair_instruction_arg;
/**
@@ -49,6 +51,16 @@ typedef void (*rc_read_write_mask_fn)(void * userdata, struct rc_instruction * i
void rc_for_all_reads_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata);
void rc_for_all_writes_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata);
+typedef void (*rc_read_src_fn)(void * userdata, struct rc_instruction * inst,
+ struct rc_src_register * src);
+void rc_for_all_reads_src(struct rc_instruction * inst, rc_read_src_fn cb,
+ void * userdata);
+
+typedef void (*rc_pair_read_arg_fn)(void * userdata,
+ struct rc_instruction * inst, struct rc_pair_instruction_arg * arg);
+void rc_pair_for_all_reads_arg(struct rc_instruction * inst,
+ rc_pair_read_arg_fn cb, void * userdata);
+
typedef void (*rc_remap_register_fn)(void * userdata, struct rc_instruction * inst,
rc_register_file * pfile, unsigned int * pindex);
void rc_remap_registers(struct rc_instruction * inst, rc_remap_register_fn cb, void * userdata);
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow_deadcode.c b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow_deadcode.c
index 9d17b4772a..87906f37b1 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_dataflow_deadcode.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_dataflow_deadcode.c
@@ -106,10 +106,12 @@ static void push_loop(struct deadcode_state * s)
static void push_branch(struct deadcode_state * s)
{
+ struct branchinfo * branch;
+
memory_pool_array_reserve(&s->C->Pool, struct branchinfo, s->BranchStack,
s->BranchStackSize, s->BranchStackReserved, 1);
- struct branchinfo * branch = &s->BranchStack[s->BranchStackSize++];
+ branch = &s->BranchStack[s->BranchStackSize++];
branch->HaveElse = 0;
memcpy(&branch->StoreEndif, &s->R, sizeof(s->R));
}
@@ -152,6 +154,7 @@ static void update_instruction(struct deadcode_state * s, struct rc_instruction
const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
struct instruction_state * insts = &s->Instructions[inst->IP];
unsigned int usedmask = 0;
+ unsigned int srcmasks[3];
if (opcode->HasDstReg) {
unsigned char * pused = get_used_ptr(s, inst->U.I.DstReg.File, inst->U.I.DstReg.Index);
@@ -180,7 +183,6 @@ static void update_instruction(struct deadcode_state * s, struct rc_instruction
}
}
- unsigned int srcmasks[3];
rc_compute_sources_for_writemask(inst, usedmask, srcmasks);
for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) {
@@ -219,6 +221,7 @@ void rc_dataflow_deadcode(struct radeon_compiler * c, void *user)
unsigned int nr_instructions;
unsigned has_temp_reladdr_src = 0;
rc_dataflow_mark_outputs_fn dce = (rc_dataflow_mark_outputs_fn)user;
+ unsigned int ip;
/* Give up if there is relative addressing of destination operands. */
for(struct rc_instruction * inst = c->Program.Instructions.Next;
@@ -349,12 +352,14 @@ void rc_dataflow_deadcode(struct radeon_compiler * c, void *user)
update_instruction(&s, inst);
}
- unsigned int ip = 0;
+ ip = 0;
for(struct rc_instruction * inst = c->Program.Instructions.Next;
inst != &c->Program.Instructions;
inst = inst->Next, ++ip) {
const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
int dead = 1;
+ unsigned int srcmasks[3];
+ unsigned int usemask;
if (!opcode->HasDstReg) {
dead = 0;
@@ -376,8 +381,7 @@ void rc_dataflow_deadcode(struct radeon_compiler * c, void *user)
continue;
}
- unsigned int srcmasks[3];
- unsigned int usemask = s.Instructions[ip].WriteMask;
+ usemask = s.Instructions[ip].WriteMask;
if (inst->U.I.WriteALUResult == RC_ALURESULT_X)
usemask |= RC_MASK_X;
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_emulate_branches.c b/src/mesa/drivers/dri/r300/compiler/radeon_emulate_branches.c
index 222e5b7e02..7bede344f3 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_emulate_branches.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_emulate_branches.c
@@ -57,18 +57,21 @@ struct emulate_branch_state {
static void handle_if(struct emulate_branch_state * s, struct rc_instruction * inst)
{
+ struct branch_info * branch;
+ struct rc_instruction * inst_mov;
+
memory_pool_array_reserve(&s->C->Pool, struct branch_info,
s->Branches, s->BranchCount, s->BranchReserved, 1);
DBG("%s\n", __FUNCTION__);
- struct branch_info * branch = &s->Branches[s->BranchCount++];
+ branch = &s->Branches[s->BranchCount++];
memset(branch, 0, sizeof(struct branch_info));
branch->If = inst;
/* Make a safety copy of the decision register, because we will need
* it at ENDIF time and it might be overwritten in both branches. */
- struct rc_instruction * inst_mov = rc_insert_new_instruction(s->C, inst->Prev);
+ inst_mov = rc_insert_new_instruction(s->C, inst->Prev);
inst_mov->U.I.Opcode = RC_OPCODE_MOV;
inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
inst_mov->U.I.DstReg.Index = rc_find_free_temporary(s->C);
@@ -84,6 +87,8 @@ static void handle_if(struct emulate_branch_state * s, struct rc_instruction * i
static void handle_else(struct emulate_branch_state * s, struct rc_instruction * inst)
{
+ struct branch_info * branch;
+
if (!s->BranchCount) {
rc_error(s->C, "Encountered ELSE outside of branches");
return;
@@ -91,7 +96,7 @@ static void handle_else(struct emulate_branch_state * s, struct rc_instruction *
DBG("%s\n", __FUNCTION__);
- struct branch_info * branch = &s->Branches[s->BranchCount - 1];
+ branch = &s->Branches[s->BranchCount - 1];
branch->Else = inst;
}
@@ -191,6 +196,10 @@ static void inject_cmp(struct emulate_branch_state * s,
static void handle_endif(struct emulate_branch_state * s, struct rc_instruction * inst)
{
+ struct branch_info * branch;
+ struct register_proxies IfProxies;
+ struct register_proxies ElseProxies;
+
if (!s->BranchCount) {
rc_error(s->C, "Encountered ENDIF outside of branches");
return;
@@ -198,9 +207,7 @@ static void handle_endif(struct emulate_branch_state * s, struct rc_instruction
DBG("%s\n", __FUNCTION__);
- struct branch_info * branch = &s->Branches[s->BranchCount - 1];
- struct register_proxies IfProxies;
- struct register_proxies ElseProxies;
+ branch = &s->Branches[s->BranchCount - 1];
memset(&IfProxies, 0, sizeof(IfProxies));
memset(&ElseProxies, 0, sizeof(ElseProxies));
@@ -261,16 +268,19 @@ static void remap_output_function(void * userdata, struct rc_instruction * inst,
*/
static void fix_output_writes(struct emulate_branch_state * s, struct rc_instruction * inst)
{
+ const struct rc_opcode_info * opcode;
+
if (!s->BranchCount)
return;
- const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+ opcode = rc_get_opcode_info(inst->U.I.Opcode);
if (!opcode->HasDstReg)
return;
if (inst->U.I.DstReg.File == RC_FILE_OUTPUT) {
struct remap_output_data remap;
+ struct rc_instruction * inst_mov;
remap.Output = inst->U.I.DstReg.Index;
remap.Temporary = rc_find_free_temporary(s->C);
@@ -281,7 +291,7 @@ static void fix_output_writes(struct emulate_branch_state * s, struct rc_instruc
rc_remap_registers(inst, &remap_output_function, &remap);
}
- struct rc_instruction * inst_mov = rc_insert_new_instruction(s->C, s->C->Program.Instructions.Prev);
+ inst_mov = rc_insert_new_instruction(s->C, s->C->Program.Instructions.Prev);
inst_mov->U.I.Opcode = RC_OPCODE_MOV;
inst_mov->U.I.DstReg.File = RC_FILE_OUTPUT;
inst_mov->U.I.DstReg.Index = remap.Output;
@@ -299,12 +309,13 @@ static void fix_output_writes(struct emulate_branch_state * s, struct rc_instruc
void rc_emulate_branches(struct radeon_compiler *c, void *user)
{
struct emulate_branch_state s;
+ struct rc_instruction * ptr;
memset(&s, 0, sizeof(s));
s.C = c;
/* Untypical loop because we may remove the current instruction */
- struct rc_instruction * ptr = c->Program.Instructions.Next;
+ ptr = c->Program.Instructions.Next;
while(ptr != &c->Program.Instructions) {
struct rc_instruction * inst = ptr;
ptr = ptr->Next;
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c b/src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c
index cd4fcbabb9..205eecd112 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_emulate_loops.c
@@ -386,8 +386,6 @@ static int build_loop_info(struct radeon_compiler * c, struct loop_info * loop,
case RC_OPCODE_SNE:
break;
default:
- rc_error(c, "%s: expected conditional",
- __FUNCTION__);
return 0;
}
loop->Cond = loop->If->Prev;
@@ -431,8 +429,10 @@ static int transform_loop(struct emulate_loop_state * s,
loop = &s->Loops[s->LoopCount++];
- if (!build_loop_info(s->C, loop, inst))
+ if (!build_loop_info(s->C, loop, inst)) {
+ rc_error(s->C, "Failed to build loop info\n");
return 0;
+ }
if(try_unroll_loop(s->C, loop)){
return 1;
@@ -511,11 +511,12 @@ void rc_emulate_loops(struct radeon_compiler *c, void *user)
* loops are unrolled first.
*/
for( i = s->LoopCount - 1; i >= 0; i-- ){
+ unsigned int iterations;
+
if(!s->Loops[i].EndLoop){
continue;
}
- unsigned int iterations = loop_max_possible_iterations(
- s->C, &s->Loops[i]);
+ iterations = loop_max_possible_iterations(s->C, &s->Loops[i]);
unroll_loop(s->C, &s->Loops[i], iterations);
}
}
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
index c15a9b1c45..41769e347e 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
@@ -163,7 +163,8 @@ static void copy_propagate(struct radeon_compiler * c, struct rc_instruction * i
if (inst_mov->U.I.DstReg.File != RC_FILE_TEMPORARY ||
inst_mov->U.I.DstReg.RelAddr ||
- inst_mov->U.I.WriteALUResult)
+ inst_mov->U.I.WriteALUResult ||
+ inst_mov->U.I.SaturateMode)
return;
memset(&s, 0, sizeof(s));
@@ -410,27 +411,34 @@ static void constant_folding(struct radeon_compiler * c, struct rc_instruction *
/* Replace 0.0, 1.0 and 0.5 immediates by their explicit swizzles */
for(unsigned int src = 0; src < opcode->NumSrcRegs; ++src) {
+ struct rc_constant * constant;
+ struct rc_src_register newsrc;
+ int have_real_reference;
+
if (inst->U.I.SrcReg[src].File != RC_FILE_CONSTANT ||
inst->U.I.SrcReg[src].RelAddr ||
inst->U.I.SrcReg[src].Index >= c->Program.Constants.Count)
continue;
- struct rc_constant * constant =
+ constant =
&c->Program.Constants.Constants[inst->U.I.SrcReg[src].Index];
if (constant->Type != RC_CONSTANT_IMMEDIATE)
continue;
- struct rc_src_register newsrc = inst->U.I.SrcReg[src];
- int have_real_reference = 0;
+ newsrc = inst->U.I.SrcReg[src];
+ have_real_reference = 0;
for(unsigned int chan = 0; chan < 4; ++chan) {
unsigned int swz = GET_SWZ(newsrc.Swizzle, chan);
+ unsigned int newswz;
+ float imm;
+ float baseimm;
+
if (swz >= 4)
continue;
- unsigned int newswz;
- float imm = constant->u.Immediate[swz];
- float baseimm = imm;
+ imm = constant->u.Immediate[swz];
+ baseimm = imm;
if (imm < 0.0)
baseimm = -baseimm;
@@ -475,8 +483,8 @@ static void constant_folding(struct radeon_compiler * c, struct rc_instruction *
}
/**
- * This function returns a writemask that indicates wich components are
- * read by src and also written by dst.
+ * If src and dst use the same register, this function returns a writemask that
+ * indicates wich components are read by src. Otherwise zero is returned.
*/
static unsigned int src_reads_dst_mask(struct rc_src_register src,
struct rc_dst_register dst)
@@ -563,10 +571,18 @@ static int presub_helper(
* s->Inst->U.I.DstReg, because if it does we must not
* remove s->Inst. */
for(i = 0; i < info->NumSrcRegs; i++) {
- if(s->Inst->U.I.DstReg.WriteMask !=
- src_reads_dst_mask(inst->U.I.SrcReg[i],
- s->Inst->U.I.DstReg)) {
- continue;
+ unsigned int mask = src_reads_dst_mask(
+ inst->U.I.SrcReg[i], s->Inst->U.I.DstReg);
+ /* XXX We could be more aggressive here using
+ * presubtract. It is okay if SrcReg[i] only reads
+ * from some of the mask components. */
+ if(s->Inst->U.I.DstReg.WriteMask != mask) {
+ if (s->Inst->U.I.DstReg.WriteMask & mask) {
+ can_remove = 0;
+ break;
+ } else {
+ continue;
+ }
}
if (cant_sub || !can_use_presub) {
can_remove = 0;
@@ -626,6 +642,21 @@ static void presub_replace_add(struct peephole_state *s,
inst->U.I.SrcReg[src_index].Index = presub_opcode;
}
+static int is_presub_candidate(struct rc_instruction * inst)
+{
+ const struct rc_opcode_info * info = rc_get_opcode_info(inst->U.I.Opcode);
+ unsigned int i;
+
+ if (inst->U.I.PreSub.Opcode != RC_PRESUB_NONE || inst->U.I.SaturateMode)
+ return 0;
+
+ for(i = 0; i < info->NumSrcRegs; i++) {
+ if (src_reads_dst_mask(inst->U.I.SrcReg[i], inst->U.I.DstReg))
+ return 0;
+ }
+ return 1;
+}
+
static int peephole_add_presub_add(
struct radeon_compiler * c,
struct rc_instruction * inst_add)
@@ -635,10 +666,7 @@ static int peephole_add_presub_add(
unsigned int i;
struct peephole_state s;
- if (inst_add->U.I.PreSub.Opcode != RC_PRESUB_NONE)
- return 0;
-
- if (inst_add->U.I.SaturateMode)
+ if (!is_presub_candidate(inst_add))
return 0;
if (inst_add->U.I.SrcReg[0].Swizzle != inst_add->U.I.SrcReg[1].Swizzle)
@@ -705,10 +733,7 @@ static int peephole_add_presub_inv(
unsigned int i, swz, mask;
struct peephole_state s;
- if (inst_add->U.I.PreSub.Opcode != RC_PRESUB_NONE)
- return 0;
-
- if (inst_add->U.I.SaturateMode)
+ if (!is_presub_candidate(inst_add))
return 0;
mask = inst_add->U.I.DstReg.WriteMask;
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c
index c73845512f..91524f5ec6 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c
@@ -322,12 +322,13 @@ void rc_pair_regalloc_inputs_only(struct radeon_compiler *cc, void *user)
{
struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)cc;
struct regalloc_state s;
+ int temp_reg_offset;
compute_live_intervals(cc, &s);
c->AllocateHwInputs(c, &alloc_input, &s);
- int temp_reg_offset = 0;
+ temp_reg_offset = 0;
for (unsigned i = 0; i < RC_REGISTER_MAX_INDEX; i++) {
if (s.Input[i].Allocated && temp_reg_offset <= s.Input[i].Index)
temp_reg_offset = s.Input[i].Index + 1;
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c
index 5269d65985..bfe3553460 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c
@@ -237,11 +237,12 @@ static void commit_alu_instruction(struct schedule_state * s, struct schedule_in
static void emit_all_tex(struct schedule_state * s, struct rc_instruction * before)
{
struct schedule_instruction *readytex;
+ struct rc_instruction * inst_begin;
assert(s->ReadyTEX);
/* Node marker for R300 */
- struct rc_instruction * inst_begin = rc_insert_new_instruction(s->C, before->Prev);
+ inst_begin = rc_insert_new_instruction(s->C, before->Prev);
inst_begin->U.I.Opcode = RC_OPCODE_BEGIN_TEX;
/* Link texture instructions back in */
@@ -280,6 +281,8 @@ static int destructive_merge_instructions(
struct rc_pair_instruction * alpha)
{
const struct rc_opcode_info * opcode;
+ const struct rc_opcode_info * rgb_info;
+
assert(rgb->Alpha.Opcode == RC_OPCODE_NOP);
assert(alpha->RGB.Opcode == RC_OPCODE_NOP);
@@ -288,8 +291,7 @@ static int destructive_merge_instructions(
* src1. */
/* Merge the rgb presubtract registers. */
- const struct rc_opcode_info * rgb_info =
- rc_get_opcode_info(rgb->RGB.Opcode);
+ rgb_info = rc_get_opcode_info(rgb->RGB.Opcode);
if (alpha->RGB.Src[RC_PAIR_PRESUB_SRC].Used) {
unsigned int srcp_src;
unsigned int srcp_regs;
@@ -301,9 +303,9 @@ static int destructive_merge_instructions(
unsigned int arg;
int free_source;
unsigned int one_way = 0;
- struct radeon_pair_instruction_source srcp =
+ struct rc_pair_instruction_source srcp =
alpha->RGB.Src[srcp_src];
- struct radeon_pair_instruction_source temp;
+ struct rc_pair_instruction_source temp;
/* 2nd arg of 1 means this is an rgb source.
* 3rd arg of 0 means this is not an alpha source. */
free_source = rc_pair_alloc_source(rgb, 1, 0,
@@ -366,9 +368,9 @@ static int destructive_merge_instructions(
unsigned int arg;
int free_source;
unsigned int one_way = 0;
- struct radeon_pair_instruction_source srcp =
+ struct rc_pair_instruction_source srcp =
alpha->Alpha.Src[srcp_src];
- struct radeon_pair_instruction_source temp;
+ struct rc_pair_instruction_source temp;
/* 2nd arg of 0 means this is not an rgb source.
* 3rd arg of 1 means this is an alpha source. */
free_source = rc_pair_alloc_source(rgb, 0, 1,
@@ -424,6 +426,7 @@ static int destructive_merge_instructions(
unsigned int oldsrc = alpha->Alpha.Arg[arg].Source;
rc_register_file file = 0;
unsigned int index = 0;
+ int source;
if (alpha->Alpha.Arg[arg].Swizzle < 3) {
srcrgb = 1;
@@ -435,7 +438,7 @@ static int destructive_merge_instructions(
index = alpha->Alpha.Src[oldsrc].Index;
}
- int source = rc_pair_alloc_source(rgb, srcrgb, srcalpha, file, index);
+ source = rc_pair_alloc_source(rgb, srcrgb, srcalpha, file, index);
if (source < 0)
return 0;
@@ -475,6 +478,12 @@ static int merge_instructions(struct rc_pair_instruction * rgb, struct rc_pair_i
{
struct rc_pair_instruction backup;
+ /*Instructions can't write output registers and ALU result at the
+ * same time. */
+ if ((rgb->WriteALUResult && alpha->Alpha.OutputWriteMask)
+ || (rgb->RGB.OutputWriteMask && alpha->WriteALUResult)) {
+ return 0;
+ }
memcpy(&backup, rgb, sizeof(struct rc_pair_instruction));
if (destructive_merge_instructions(rgb, alpha))
@@ -597,6 +606,7 @@ static void scan_read(void * data, struct rc_instruction * inst,
{
struct schedule_state * s = data;
struct reg_value * v = get_reg_value(s, file, index, chan);
+ struct reg_value_reader * reader;
if (!v)
return;
@@ -610,7 +620,7 @@ static void scan_read(void * data, struct rc_instruction * inst,
DBG("%i: read %i[%i] chan %i\n", s->Current->Instruction->IP, file, index, chan);
- struct reg_value_reader * reader = memory_pool_malloc(&s->C->Pool, sizeof(*reader));
+ reader = memory_pool_malloc(&s->C->Pool, sizeof(*reader));
reader->Reader = s->Current;
reader->Next = v->Readers;
v->Readers = reader;
@@ -630,13 +640,14 @@ static void scan_write(void * data, struct rc_instruction * inst,
{
struct schedule_state * s = data;
struct reg_value ** pv = get_reg_valuep(s, file, index, chan);
+ struct reg_value * newv;
if (!pv)
return;
DBG("%i: write %i[%i] chan %i\n", s->Current->Instruction->IP, file, index, chan);
- struct reg_value * newv = memory_pool_malloc(&s->C->Pool, sizeof(*newv));
+ newv = memory_pool_malloc(&s->C->Pool, sizeof(*newv));
memset(newv, 0, sizeof(*newv));
newv->Writer = s->Current;
@@ -659,12 +670,13 @@ static void schedule_block(struct r300_fragment_program_compiler * c,
struct rc_instruction * begin, struct rc_instruction * end)
{
struct schedule_state s;
+ unsigned int ip;
memset(&s, 0, sizeof(s));
s.C = &c->Base;
/* Scan instructions for data dependencies */
- unsigned int ip = 0;
+ ip = 0;
for(struct rc_instruction * inst = begin; inst != end; inst = inst->Next) {
s.Current = memory_pool_malloc(&c->Base.Pool, sizeof(*s.Current));
memset(s.Current, 0, sizeof(struct schedule_instruction));
@@ -716,12 +728,14 @@ void rc_pair_schedule(struct radeon_compiler *cc, void *user)
struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)cc;
struct rc_instruction * inst = c->Base.Program.Instructions.Next;
while(inst != &c->Base.Program.Instructions) {
+ struct rc_instruction * first;
+
if (is_controlflow(inst)) {
inst = inst->Next;
continue;
}
- struct rc_instruction * first = inst;
+ first = inst;
while(inst != &c->Base.Program.Instructions && !is_controlflow(inst))
inst = inst->Next;
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
index ff82584466..c549be5218 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
@@ -148,9 +148,12 @@ static void set_pair_instruction(struct r300_fragment_program_compiler *c,
struct rc_pair_instruction * pair,
struct rc_sub_instruction * inst)
{
+ int needrgb, needalpha, istranscendent;
+ const struct rc_opcode_info * opcode;
+ int i;
+
memset(pair, 0, sizeof(struct rc_pair_instruction));
- int needrgb, needalpha, istranscendent;
classify_instruction(inst, &needrgb, &needalpha, &istranscendent);
if (needrgb) {
@@ -167,8 +170,7 @@ static void set_pair_instruction(struct r300_fragment_program_compiler *c,
pair->Alpha.Saturate = 1;
}
- const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->Opcode);
- int i;
+ opcode = rc_get_opcode_info(inst->Opcode);
/* Presubtract handling:
* We need to make sure that the values used by the presubtract
@@ -330,15 +332,18 @@ void rc_pair_translate(struct radeon_compiler *cc, void *user)
for(struct rc_instruction * inst = c->Base.Program.Instructions.Next;
inst != &c->Base.Program.Instructions;
inst = inst->Next) {
+ const struct rc_opcode_info * opcode;
+ struct rc_sub_instruction copy;
+
if (inst->Type != RC_INSTRUCTION_NORMAL)
continue;
- const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+ opcode = rc_get_opcode_info(inst->U.I.Opcode);
if (opcode->HasTexture || opcode->IsFlowControl || opcode->Opcode == RC_OPCODE_KIL)
continue;
- struct rc_sub_instruction copy = inst->U.I;
+ copy = inst->U.I;
check_opcode_support(c, &copy);
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c
index 4d3e26f28c..39408845d5 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_alu.c
@@ -874,13 +874,15 @@ int r300_transform_trig_simple(struct radeon_compiler* c,
struct rc_instruction* inst,
void* unused)
{
+ unsigned int constants[2];
+ unsigned int tempreg;
+
if (inst->U.I.Opcode != RC_OPCODE_COS &&
inst->U.I.Opcode != RC_OPCODE_SIN &&
inst->U.I.Opcode != RC_OPCODE_SCS)
return 0;
- unsigned int constants[2];
- unsigned int tempreg = rc_find_free_temporary(c);
+ tempreg = rc_find_free_temporary(c);
sincos_constants(c, constants);
@@ -918,6 +920,8 @@ int r300_transform_trig_simple(struct radeon_compiler* c,
swizzle_wwww(srcreg(RC_FILE_TEMPORARY, tempreg)),
constants);
} else {
+ struct rc_dst_register dst;
+
emit3(c, inst->Prev, RC_OPCODE_MAD, 0, dstregtmpmask(tempreg, RC_MASK_XY),
swizzle_xxxx(inst->U.I.SrcReg[0]),
swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[1])),
@@ -929,7 +933,7 @@ int r300_transform_trig_simple(struct radeon_compiler* c,
swizzle_wwww(srcreg(RC_FILE_CONSTANT, constants[1])),
negate(swizzle_zzzz(srcreg(RC_FILE_CONSTANT, constants[0]))));
- struct rc_dst_register dst = inst->U.I.DstReg;
+ dst = inst->U.I.DstReg;
dst.WriteMask = inst->U.I.DstReg.WriteMask & RC_MASK_X;
sin_approx(c, inst, dst,
@@ -988,16 +992,16 @@ int radeonTransformTrigScale(struct radeon_compiler* c,
struct rc_instruction* inst,
void* unused)
{
- if (inst->U.I.Opcode != RC_OPCODE_COS &&
- inst->U.I.Opcode != RC_OPCODE_SIN &&
- inst->U.I.Opcode != RC_OPCODE_SCS)
- return 0;
-
static const float RCP_2PI = 0.15915494309189535;
unsigned int temp;
unsigned int constant;
unsigned int constant_swizzle;
+ if (inst->U.I.Opcode != RC_OPCODE_COS &&
+ inst->U.I.Opcode != RC_OPCODE_SIN &&
+ inst->U.I.Opcode != RC_OPCODE_SCS)
+ return 0;
+
temp = rc_find_free_temporary(c);
constant = rc_constants_add_immediate_scalar(&c->Program.Constants, RCP_2PI, &constant_swizzle);
@@ -1020,6 +1024,10 @@ int r300_transform_trig_scale_vertex(struct radeon_compiler *c,
struct rc_instruction *inst,
void *unused)
{
+ static const float cons[4] = {0.15915494309189535, 0.5, 6.28318530717959, -3.14159265358979};
+ unsigned int temp;
+ unsigned int constant;
+
if (inst->U.I.Opcode != RC_OPCODE_COS &&
inst->U.I.Opcode != RC_OPCODE_SIN &&
inst->U.I.Opcode != RC_OPCODE_SCS)
@@ -1030,10 +1038,6 @@ int r300_transform_trig_scale_vertex(struct radeon_compiler *c,
* repeat(x) = frac(x / 2PI + 0.5) * 2PI - PI
*/
- static const float cons[4] = {0.15915494309189535, 0.5, 6.28318530717959, -3.14159265358979};
- unsigned int temp;
- unsigned int constant;
-
temp = rc_find_free_temporary(c);
constant = rc_constants_add_immediate_vec4(&c->Program.Constants, cons);
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h b/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h
index e0061e454b..01cdb15424 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h
@@ -55,52 +55,35 @@ struct radeon_compiler;
*/
#define RC_PAIR_PRESUB_SRC 3
-struct radeon_pair_instruction_source {
+struct rc_pair_instruction_source {
unsigned int Used:1;
unsigned int File:3;
unsigned int Index:RC_REGISTER_INDEX_BITS;
};
-struct radeon_pair_instruction_rgb {
- unsigned int Opcode:8;
- unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
- unsigned int WriteMask:3;
- unsigned int Target:2;
- unsigned int OutputWriteMask:3;
- unsigned int Saturate:1;
-
- struct radeon_pair_instruction_source Src[4];
-
- struct {
- unsigned int Source:2;
- unsigned int Swizzle:9;
- unsigned int Abs:1;
- unsigned int Negate:1;
- } Arg[3];
+struct rc_pair_instruction_arg {
+ unsigned int Source:2;
+ unsigned int Swizzle:9;
+ unsigned int Abs:1;
+ unsigned int Negate:1;
};
-struct radeon_pair_instruction_alpha {
+struct rc_pair_sub_instruction {
unsigned int Opcode:8;
unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
- unsigned int WriteMask:1;
- unsigned int Target:2;
- unsigned int OutputWriteMask:1;
+ unsigned int WriteMask:3;
+ unsigned int Target:2;
+ unsigned int OutputWriteMask:3;
unsigned int DepthWriteMask:1;
unsigned int Saturate:1;
- struct radeon_pair_instruction_source Src[4];
-
- struct {
- unsigned int Source:2;
- unsigned int Swizzle:3;
- unsigned int Abs:1;
- unsigned int Negate:1;
- } Arg[3];
+ struct rc_pair_instruction_source Src[4];
+ struct rc_pair_instruction_arg Arg[3];
};
struct rc_pair_instruction {
- struct radeon_pair_instruction_rgb RGB;
- struct radeon_pair_instruction_alpha Alpha;
+ struct rc_pair_sub_instruction RGB;
+ struct rc_pair_sub_instruction Alpha;
unsigned int WriteALUResult:2;
unsigned int ALUResultCompare:3;
@@ -108,7 +91,7 @@ struct rc_pair_instruction {
};
typedef void (*rc_pair_foreach_src_fn)
- (void *, struct radeon_pair_instruction_source *);
+ (void *, struct rc_pair_instruction_source *);
typedef enum {
RC_PAIR_SOURCE_NONE = 0,
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c b/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
index ddce590ee6..530afa5e08 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_program_tex.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Corbin Simpson
+ * Copyright (C) 2010 Marek Olšák <maraeo@gmail.com>
*
* All Rights Reserved.
*
@@ -46,31 +47,61 @@ static struct rc_src_register shadow_ambient(struct r300_fragment_program_compil
return reg;
}
-static void lower_texture_rect(struct r300_fragment_program_compiler *compiler,
- struct rc_instruction *inst)
+static void scale_texcoords(struct r300_fragment_program_compiler *compiler,
+ struct rc_instruction *inst,
+ unsigned state_constant)
{
- struct rc_instruction *inst_rect;
+ struct rc_instruction *inst_mov;
+
unsigned temp = rc_find_free_temporary(&compiler->Base);
- if (inst->U.I.TexSrcTarget == RC_TEXTURE_RECT ||
- compiler->state.unit[inst->U.I.TexSrcUnit].non_normalized_coords) {
- inst_rect = rc_insert_new_instruction(&compiler->Base, inst->Prev);
+ inst_mov = rc_insert_new_instruction(&compiler->Base, inst->Prev);
- inst_rect->U.I.Opcode = RC_OPCODE_MUL;
- inst_rect->U.I.DstReg.File = RC_FILE_TEMPORARY;
- inst_rect->U.I.DstReg.Index = temp;
- inst_rect->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
- inst_rect->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
- inst_rect->U.I.SrcReg[1].Index =
- rc_constants_add_state(&compiler->Base.Program.Constants,
- RC_STATE_R300_TEXRECT_FACTOR, inst->U.I.TexSrcUnit);
+ inst_mov->U.I.Opcode = RC_OPCODE_MUL;
+ inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_mov->U.I.DstReg.Index = temp;
+ inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+ inst_mov->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
+ inst_mov->U.I.SrcReg[1].Index =
+ rc_constants_add_state(&compiler->Base.Program.Constants,
+ state_constant, inst->U.I.TexSrcUnit);
- reset_srcreg(&inst->U.I.SrcReg[0]);
- inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
- inst->U.I.SrcReg[0].Index = temp;
+ reset_srcreg(&inst->U.I.SrcReg[0]);
+ inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+ inst->U.I.SrcReg[0].Index = temp;
+}
- inst->U.I.TexSrcTarget = RC_TEXTURE_2D;
- }
+static void projective_divide(struct r300_fragment_program_compiler *compiler,
+ struct rc_instruction *inst)
+{
+ struct rc_instruction *inst_mul, *inst_rcp;
+
+ unsigned temp = rc_find_free_temporary(&compiler->Base);
+
+ inst_rcp = rc_insert_new_instruction(&compiler->Base, inst->Prev);
+ inst_rcp->U.I.Opcode = RC_OPCODE_RCP;
+ inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_rcp->U.I.DstReg.Index = temp;
+ inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
+ inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+ /* Because the input can be arbitrarily swizzled,
+ * read the component mapped to W. */
+ inst_rcp->U.I.SrcReg[0].Swizzle =
+ RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 3));
+
+ inst_mul = rc_insert_new_instruction(&compiler->Base, inst->Prev);
+ inst_mul->U.I.Opcode = RC_OPCODE_MUL;
+ inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_mul->U.I.DstReg.Index = temp;
+ inst_mul->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+ inst_mul->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+ inst_mul->U.I.SrcReg[1].Index = temp;
+ inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
+
+ reset_srcreg(&inst->U.I.SrcReg[0]);
+ inst->U.I.Opcode = RC_OPCODE_TEX;
+ inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+ inst->U.I.SrcReg[0].Index = temp;
}
/**
@@ -88,6 +119,9 @@ int radeonTransformTEX(
{
struct r300_fragment_program_compiler *compiler =
(struct r300_fragment_program_compiler*)data;
+ rc_wrap_mode wrapmode = compiler->state.unit[inst->U.I.TexSrcUnit].wrap_mode;
+ int is_rect = inst->U.I.TexSrcTarget == RC_TEXTURE_RECT ||
+ compiler->state.unit[inst->U.I.TexSrcUnit].non_normalized_coords;
if (inst->U.I.Opcode != RC_OPCODE_TEX &&
inst->U.I.Opcode != RC_OPCODE_TXB &&
@@ -141,16 +175,18 @@ int radeonTransformTEX(
inst_rcp->U.I.DstReg.Index = tmp_recip_w;
inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
- inst_rcp->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW;
+ inst_rcp->U.I.SrcReg[0].Swizzle =
+ RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 3));
}
- /* Perspective-divide r by W (if it's TXP) and add the texture sample (see below). */
+ /* Perspective-divide Z by W (if it's TXP) and add the texture sample (see below). */
tmp_sum = rc_find_free_temporary(c);
inst_mad = rc_insert_new_instruction(c, inst_rcp ? inst_rcp : inst);
inst_mad->U.I.DstReg.File = RC_FILE_TEMPORARY;
inst_mad->U.I.DstReg.Index = tmp_sum;
inst_mad->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
- inst_mad->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_ZZZZ;
+ inst_mad->U.I.SrcReg[0].Swizzle =
+ RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 2));
if (inst->U.I.Opcode == RC_OPCODE_TXP) {
inst_mad->U.I.Opcode = RC_OPCODE_MAD;
inst_mad->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
@@ -206,11 +242,22 @@ int radeonTransformTEX(
}
}
- /* Texture wrap modes don't work on NPOT textures or texrects.
- *
- * The game plan is simple. We have two flags, fake_npot and
- * non_normalized_coords, as well as a tex target. The RECT tex target
- * will make the emitted code use non-scaled texcoords.
+ /* R300 cannot sample from rectangles and the wrap mode fallback needs
+ * normalized coordinates anyway. */
+ if (inst->U.I.Opcode != RC_OPCODE_KIL &&
+ is_rect && (!c->is_r500 || wrapmode != RC_WRAP_NONE)) {
+ scale_texcoords(compiler, inst, RC_STATE_R300_TEXRECT_FACTOR);
+ inst->U.I.TexSrcTarget = RC_TEXTURE_2D;
+ }
+
+ /* Divide by W if needed. */
+ if (inst->U.I.Opcode == RC_OPCODE_TXP &&
+ (wrapmode == RC_WRAP_REPEAT || wrapmode == RC_WRAP_MIRRORED_REPEAT ||
+ compiler->state.unit[inst->U.I.TexSrcUnit].clamp_and_scale_before_fetch)) {
+ projective_divide(compiler, inst);
+ }
+
+ /* Texture wrap modes don't work on NPOT textures.
*
* Non-wrapped/clamped texcoords with NPOT are free in HW. Repeat and
* mirroring are not. If we need to repeat, we do:
@@ -235,128 +282,140 @@ int radeonTransformTEX(
* ~ C & M. ;)
*/
if (inst->U.I.Opcode != RC_OPCODE_KIL &&
- (inst->U.I.TexSrcTarget == RC_TEXTURE_RECT ||
- compiler->state.unit[inst->U.I.TexSrcUnit].fake_npot ||
- compiler->state.unit[inst->U.I.TexSrcUnit].non_normalized_coords)) {
- rc_wrap_mode wrapmode = compiler->state.unit[inst->U.I.TexSrcUnit].wrap_mode;
-
- /* R300 cannot sample from rectangles. */
- if (!c->is_r500) {
- lower_texture_rect(compiler, inst);
- }
-
- if (compiler->state.unit[inst->U.I.TexSrcUnit].fake_npot &&
- wrapmode != RC_WRAP_NONE) {
+ wrapmode != RC_WRAP_NONE) {
+ struct rc_instruction *inst_mov;
+ unsigned temp = rc_find_free_temporary(c);
+
+ if (wrapmode == RC_WRAP_REPEAT) {
+ /* Both instructions will be paired up. */
+ struct rc_instruction *inst_frc = rc_insert_new_instruction(c, inst->Prev);
+
+ inst_frc->U.I.Opcode = RC_OPCODE_FRC;
+ inst_frc->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_frc->U.I.DstReg.Index = temp;
+ inst_frc->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+ inst_frc->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+ } else if (wrapmode == RC_WRAP_MIRRORED_REPEAT) {
+ /*
+ * Function:
+ * f(v) = 1 - abs(frac(v * 0.5) * 2 - 1)
+ *
+ * Code:
+ * MUL temp, src0, 0.5
+ * FRC temp, temp
+ * MAD temp, temp, 2, -1
+ * ADD temp, 1, -abs(temp)
+ */
+
+ struct rc_instruction *inst_mul, *inst_frc, *inst_mad, *inst_add;
+ unsigned two, two_swizzle;
+
+ inst_mul = rc_insert_new_instruction(c, inst->Prev);
+
+ inst_mul->U.I.Opcode = RC_OPCODE_MUL;
+ inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_mul->U.I.DstReg.Index = temp;
+ inst_mul->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+ inst_mul->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+ inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_HHHH;
+
+ inst_frc = rc_insert_new_instruction(c, inst->Prev);
+
+ inst_frc->U.I.Opcode = RC_OPCODE_FRC;
+ inst_frc->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_frc->U.I.DstReg.Index = temp;
+ inst_frc->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+ inst_frc->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+ inst_frc->U.I.SrcReg[0].Index = temp;
+ inst_frc->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZ0;
+
+ two = rc_constants_add_immediate_scalar(&c->Program.Constants, 2, &two_swizzle);
+ inst_mad = rc_insert_new_instruction(c, inst->Prev);
+
+ inst_mad->U.I.Opcode = RC_OPCODE_MAD;
+ inst_mad->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_mad->U.I.DstReg.Index = temp;
+ inst_mad->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+ inst_mad->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+ inst_mad->U.I.SrcReg[0].Index = temp;
+ inst_mad->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZ0;
+ inst_mad->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
+ inst_mad->U.I.SrcReg[1].Index = two;
+ inst_mad->U.I.SrcReg[1].Swizzle = two_swizzle;
+ inst_mad->U.I.SrcReg[2].Swizzle = RC_SWIZZLE_1111;
+ inst_mad->U.I.SrcReg[2].Negate = RC_MASK_XYZ;
+
+ inst_add = rc_insert_new_instruction(c, inst->Prev);
+
+ inst_add->U.I.Opcode = RC_OPCODE_ADD;
+ inst_add->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_add->U.I.DstReg.Index = temp;
+ inst_add->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+ inst_add->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_1111;
+ inst_add->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
+ inst_add->U.I.SrcReg[1].Index = temp;
+ inst_add->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_XYZ0;
+ inst_add->U.I.SrcReg[1].Abs = 1;
+ inst_add->U.I.SrcReg[1].Negate = RC_MASK_XYZ;
+ } else if (wrapmode == RC_WRAP_MIRRORED_CLAMP) {
+ /*
+ * Mirrored clamp modes are bloody simple, we just use abs
+ * to mirror [0, 1] into [-1, 0]. This works for
+ * all modes i.e. CLAMP, CLAMP_TO_EDGE, and CLAMP_TO_BORDER.
+ */
struct rc_instruction *inst_mov;
- unsigned temp = rc_find_free_temporary(c);
-
- /* For NPOT fallback, we need normalized coordinates anyway. */
- if (c->is_r500) {
- lower_texture_rect(compiler, inst);
- }
-
- if (wrapmode == RC_WRAP_REPEAT) {
- /* Both instructions will be paired up. */
- struct rc_instruction *inst_frc = rc_insert_new_instruction(c, inst->Prev);
-
- inst_frc->U.I.Opcode = RC_OPCODE_FRC;
- inst_frc->U.I.DstReg.File = RC_FILE_TEMPORARY;
- inst_frc->U.I.DstReg.Index = temp;
- inst_frc->U.I.DstReg.WriteMask = RC_MASK_XYZ;
- inst_frc->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
- } else if (wrapmode == RC_WRAP_MIRRORED_REPEAT) {
- /*
- * Function:
- * f(v) = 1 - abs(frac(v * 0.5) * 2 - 1)
- *
- * Code:
- * MUL temp, src0, 0.5
- * FRC temp, temp
- * MAD temp, temp, 2, -1
- * ADD temp, 1, -abs(temp)
- */
-
- struct rc_instruction *inst_mul, *inst_frc, *inst_mad, *inst_add;
- unsigned two, two_swizzle;
-
- inst_mul = rc_insert_new_instruction(c, inst->Prev);
-
- inst_mul->U.I.Opcode = RC_OPCODE_MUL;
- inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
- inst_mul->U.I.DstReg.Index = temp;
- inst_mul->U.I.DstReg.WriteMask = RC_MASK_XYZ;
- inst_mul->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
- inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_HHHH;
-
- inst_frc = rc_insert_new_instruction(c, inst->Prev);
-
- inst_frc->U.I.Opcode = RC_OPCODE_FRC;
- inst_frc->U.I.DstReg.File = RC_FILE_TEMPORARY;
- inst_frc->U.I.DstReg.Index = temp;
- inst_frc->U.I.DstReg.WriteMask = RC_MASK_XYZ;
- inst_frc->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
- inst_frc->U.I.SrcReg[0].Index = temp;
- inst_frc->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZ0;
-
- two = rc_constants_add_immediate_scalar(&c->Program.Constants, 2, &two_swizzle);
- inst_mad = rc_insert_new_instruction(c, inst->Prev);
-
- inst_mad->U.I.Opcode = RC_OPCODE_MAD;
- inst_mad->U.I.DstReg.File = RC_FILE_TEMPORARY;
- inst_mad->U.I.DstReg.Index = temp;
- inst_mad->U.I.DstReg.WriteMask = RC_MASK_XYZ;
- inst_mad->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
- inst_mad->U.I.SrcReg[0].Index = temp;
- inst_mad->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_XYZ0;
- inst_mad->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
- inst_mad->U.I.SrcReg[1].Index = two;
- inst_mad->U.I.SrcReg[1].Swizzle = two_swizzle;
- inst_mad->U.I.SrcReg[2].Swizzle = RC_SWIZZLE_1111;
- inst_mad->U.I.SrcReg[2].Negate = RC_MASK_XYZ;
-
- inst_add = rc_insert_new_instruction(c, inst->Prev);
-
- inst_add->U.I.Opcode = RC_OPCODE_ADD;
- inst_add->U.I.DstReg.File = RC_FILE_TEMPORARY;
- inst_add->U.I.DstReg.Index = temp;
- inst_add->U.I.DstReg.WriteMask = RC_MASK_XYZ;
- inst_add->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_1111;
- inst_add->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
- inst_add->U.I.SrcReg[1].Index = temp;
- inst_add->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_XYZ0;
- inst_add->U.I.SrcReg[1].Abs = 1;
- inst_add->U.I.SrcReg[1].Negate = RC_MASK_XYZ;
- } else if (wrapmode == RC_WRAP_MIRRORED_CLAMP) {
- /*
- * Mirrored clamp modes are bloody simple, we just use abs
- * to mirror [0, 1] into [-1, 0]. This works for
- * all modes i.e. CLAMP, CLAMP_TO_EDGE, and CLAMP_TO_BORDER.
- */
- struct rc_instruction *inst_mov;
-
- inst_mov = rc_insert_new_instruction(c, inst->Prev);
-
- inst_mov->U.I.Opcode = RC_OPCODE_MOV;
- inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
- inst_mov->U.I.DstReg.Index = temp;
- inst_mov->U.I.DstReg.WriteMask = RC_MASK_XYZ;
- inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
- inst_mov->U.I.SrcReg[0].Abs = 1;
- }
- /* Preserve W for TXP/TXB. */
inst_mov = rc_insert_new_instruction(c, inst->Prev);
inst_mov->U.I.Opcode = RC_OPCODE_MOV;
inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
inst_mov->U.I.DstReg.Index = temp;
- inst_mov->U.I.DstReg.WriteMask = RC_MASK_W;
+ inst_mov->U.I.DstReg.WriteMask = RC_MASK_XYZ;
inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
-
- reset_srcreg(&inst->U.I.SrcReg[0]);
- inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
- inst->U.I.SrcReg[0].Index = temp;
+ inst_mov->U.I.SrcReg[0].Abs = 1;
}
+
+ /* Preserve W for TXP/TXB. */
+ inst_mov = rc_insert_new_instruction(c, inst->Prev);
+
+ inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+ inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_mov->U.I.DstReg.Index = temp;
+ inst_mov->U.I.DstReg.WriteMask = RC_MASK_W;
+ inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+
+ reset_srcreg(&inst->U.I.SrcReg[0]);
+ inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+ inst->U.I.SrcReg[0].Index = temp;
+ }
+
+ if (inst->U.I.Opcode != RC_OPCODE_KIL &&
+ compiler->state.unit[inst->U.I.TexSrcUnit].clamp_and_scale_before_fetch) {
+ struct rc_instruction *inst_mov;
+ unsigned temp = rc_find_free_temporary(c);
+
+ /* Saturate XYZ. */
+ inst_mov = rc_insert_new_instruction(c, inst->Prev);
+ inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+ inst_mov->U.I.SaturateMode = RC_SATURATE_ZERO_ONE;
+ inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_mov->U.I.DstReg.Index = temp;
+ inst_mov->U.I.DstReg.WriteMask = RC_MASK_XYZ;
+ inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+
+ /* Copy W. */
+ inst_mov = rc_insert_new_instruction(c, inst->Prev);
+ inst_mov->U.I.Opcode = RC_OPCODE_MOV;
+ inst_mov->U.I.DstReg.File = RC_FILE_TEMPORARY;
+ inst_mov->U.I.DstReg.Index = temp;
+ inst_mov->U.I.DstReg.WriteMask = RC_MASK_W;
+ inst_mov->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
+
+ reset_srcreg(&inst->U.I.SrcReg[0]);
+ inst->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
+ inst->U.I.SrcReg[0].Index = temp;
+
+ scale_texcoords(compiler, inst, RC_STATE_R300_TEXSCALE_FACTOR);
}
/* Cannot write texture to output registers (all chips) or with masks (non-r500) */
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c b/src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c
index d111319d3d..d6c808ad81 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c
@@ -28,107 +28,105 @@
#include "radeon_remove_constants.h"
#include "radeon_dataflow.h"
+struct mark_used_data {
+ unsigned char * const_used;
+ unsigned * has_rel_addr;
+};
+
static void remap_regs(void * userdata, struct rc_instruction * inst,
rc_register_file * pfile, unsigned int * pindex)
{
- unsigned *inv_remap_table = userdata;
+ unsigned *inv_remap_table = userdata;
+
+ if (*pfile == RC_FILE_CONSTANT) {
+ *pindex = inv_remap_table[*pindex];
+ }
+}
+
+static void mark_used(void * userdata, struct rc_instruction * inst,
+ struct rc_src_register * src)
+{
+ struct mark_used_data * d = userdata;
- if (*pfile == RC_FILE_CONSTANT) {
- *pindex = inv_remap_table[*pindex];
- }
+ if (src->File == RC_FILE_CONSTANT) {
+ if (src->RelAddr) {
+ *d->has_rel_addr = 1;
+ } else {
+ d->const_used[src->Index] = 1;
+ }
+ }
}
void rc_remove_unused_constants(struct radeon_compiler *c, void *user)
{
unsigned **out_remap_table = (unsigned**)user;
- unsigned char *const_used;
- unsigned *remap_table;
- unsigned *inv_remap_table;
- unsigned has_rel_addr = 0;
- unsigned is_identity = 1;
+ unsigned char *const_used;
+ unsigned *remap_table;
+ unsigned *inv_remap_table;
+ unsigned has_rel_addr = 0;
+ unsigned is_identity = 1;
unsigned are_externals_remapped = 0;
- struct rc_constant *constants = c->Program.Constants.Constants;
+ struct rc_constant *constants = c->Program.Constants.Constants;
+ struct mark_used_data d;
+ unsigned new_count;
+
+ if (!c->Program.Constants.Count) {
+ *out_remap_table = NULL;
+ return;
+ }
- if (!c->Program.Constants.Count) {
- *out_remap_table = NULL;
- return;
- }
+ const_used = malloc(c->Program.Constants.Count);
+ memset(const_used, 0, c->Program.Constants.Count);
- const_used = malloc(c->Program.Constants.Count);
- memset(const_used, 0, c->Program.Constants.Count);
+ d.const_used = const_used;
+ d.has_rel_addr = &has_rel_addr;
/* Pass 1: Mark used constants. */
- for (struct rc_instruction *inst = c->Program.Instructions.Next;
- inst != &c->Program.Instructions; inst = inst->Next) {
- const struct rc_opcode_info *opcode = rc_get_opcode_info(inst->U.I.Opcode);
-
- /* XXX: This loop and the if statement after it should be
- * replaced by a call to one of the rc_for_all_reads_* functions.
- * The reason it does not use one of those functions now is
- * because none of them have RelAddr as an argument. */
- for (unsigned i = 0; i < opcode->NumSrcRegs; i++) {
- if (inst->U.I.SrcReg[i].File == RC_FILE_CONSTANT) {
- if (inst->U.I.SrcReg[i].RelAddr) {
- has_rel_addr = 1;
- } else {
- const_used[inst->U.I.SrcReg[i].Index] = 1;
- }
- }
- }
- if (inst->U.I.PreSub.Opcode != RC_PRESUB_NONE) {
- unsigned int i;
- unsigned int srcp_regs = rc_presubtract_src_reg_count(
- inst->U.I.PreSub.Opcode);
- for( i = 0; i < srcp_regs; i++) {
- if (inst->U.I.PreSub.SrcReg[i].File ==
- RC_FILE_CONSTANT) {
- const_used[
- inst->U.I.PreSub.SrcReg[i].Index] = 1;
- }
- }
- }
- }
+ for (struct rc_instruction *inst = c->Program.Instructions.Next;
+ inst != &c->Program.Instructions; inst = inst->Next) {
+ rc_for_all_reads_src(inst, mark_used, &d);
+ }
- /* Pass 2: If there is relative addressing, mark all externals as used. */
- if (has_rel_addr) {
- for (unsigned i = 0; i < c->Program.Constants.Count; i++)
- if (constants[i].Type == RC_CONSTANT_EXTERNAL)
- const_used[i] = 1;
- }
+ /* Pass 2: If there is relative addressing, mark all externals as used. */
+ if (has_rel_addr) {
+ for (unsigned i = 0; i < c->Program.Constants.Count; i++)
+ if (constants[i].Type == RC_CONSTANT_EXTERNAL)
+ const_used[i] = 1;
+ }
- /* Pass 3: Make the remapping table and remap constants.
+ /* Pass 3: Make the remapping table and remap constants.
* This pass removes unused constants simply by overwriting them by other constants. */
- remap_table = malloc(c->Program.Constants.Count * sizeof(unsigned));
- inv_remap_table = malloc(c->Program.Constants.Count * sizeof(unsigned));
- unsigned new_count = 0;
+ remap_table = malloc(c->Program.Constants.Count * sizeof(unsigned));
+ inv_remap_table = malloc(c->Program.Constants.Count * sizeof(unsigned));
+ new_count = 0;
- for (unsigned i = 0; i < c->Program.Constants.Count; i++) {
- if (const_used[i]) {
- remap_table[new_count] = i;
- inv_remap_table[i] = new_count;
+ for (unsigned i = 0; i < c->Program.Constants.Count; i++) {
+ if (const_used[i]) {
+ remap_table[new_count] = i;
+ inv_remap_table[i] = new_count;
- if (i != new_count) {
+ if (i != new_count) {
if (constants[i].Type == RC_CONSTANT_EXTERNAL)
are_externals_remapped = 1;
constants[new_count] = constants[i];
- is_identity = 0;
- }
- new_count++;
- }
- }
+ is_identity = 0;
+ }
+ new_count++;
+ }
+ }
/* is_identity ==> new_count == old_count
* !is_identity ==> new_count < old_count */
assert( is_identity || new_count < c->Program.Constants.Count);
assert(!(has_rel_addr && are_externals_remapped));
- /* Pass 4: Redirect reads of all constants to their new locations. */
- if (!is_identity) {
- for (struct rc_instruction *inst = c->Program.Instructions.Next;
- inst != &c->Program.Instructions; inst = inst->Next) {
- rc_remap_registers(inst, remap_regs, inv_remap_table);
- }
+ /* Pass 4: Redirect reads of all constants to their new locations. */
+ if (!is_identity) {
+ for (struct rc_instruction *inst = c->Program.Instructions.Next;
+ inst != &c->Program.Instructions; inst = inst->Next) {
+ rc_remap_registers(inst, remap_regs, inv_remap_table);
+ }
}
@@ -138,12 +136,15 @@ void rc_remove_unused_constants(struct radeon_compiler *c, void *user)
c->Program.Constants.Count = new_count;
if (are_externals_remapped) {
- *out_remap_table = remap_table;
- } else {
- *out_remap_table = NULL;
- free(remap_table);
- }
-
- free(const_used);
- free(inv_remap_table);
+ *out_remap_table = remap_table;
+ } else {
+ *out_remap_table = NULL;
+ free(remap_table);
+ }
+
+ free(const_used);
+ free(inv_remap_table);
+
+ if (c->Debug)
+ rc_constants_print(&c->Program.Constants);
}
diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_rename_regs.c b/src/mesa/drivers/dri/r300/compiler/radeon_rename_regs.c
index 31d25f9ab8..60e228be5b 100644
--- a/src/mesa/drivers/dri/r300/compiler/radeon_rename_regs.c
+++ b/src/mesa/drivers/dri/r300/compiler/radeon_rename_regs.c
@@ -104,13 +104,14 @@ void rc_rename_regs(struct radeon_compiler *c, void *user)
inst != &c->Program.Instructions;
inst = inst->Next) {
const struct rc_opcode_info * info;
+ unsigned int old_index, temp_index;
+ struct rc_dst_register * dst;
if(inst->Type != RC_INSTRUCTION_NORMAL) {
rc_error(c, "%s only works with normal instructions.",
__FUNCTION__);
return;
}
- unsigned int old_index, temp_index;
- struct rc_dst_register * dst = &inst->U.I.DstReg;
+ dst = &inst->U.I.DstReg;
info = rc_get_opcode_info(inst->U.I.Opcode);
if(!info->HasDstReg || dst->File != RC_FILE_TEMPORARY) {
continue;
diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c
index 74aef765e3..9fd8e8fde5 100644
--- a/src/mesa/drivers/dri/r300/r300_blit.c
+++ b/src/mesa/drivers/dri/r300/r300_blit.c
@@ -569,7 +569,7 @@ unsigned r300_check_blit(gl_format dst_format)
* @param[in] height region height
* @param[in] flip_y set if y coords of the source image need to be flipped
*/
-unsigned r300_blit(GLcontext *ctx,
+unsigned r300_blit(struct gl_context *ctx,
struct radeon_bo *src_bo,
intptr_t src_offset,
gl_format src_mesaformat,
diff --git a/src/mesa/drivers/dri/r300/r300_blit.h b/src/mesa/drivers/dri/r300/r300_blit.h
index 39b157a57b..286dbe1856 100644
--- a/src/mesa/drivers/dri/r300/r300_blit.h
+++ b/src/mesa/drivers/dri/r300/r300_blit.h
@@ -32,7 +32,7 @@ void r300_blit_init(struct r300_context *r300);
unsigned r300_check_blit(gl_format mesa_format);
-unsigned r300_blit(GLcontext *ctx,
+unsigned r300_blit(struct gl_context *ctx,
struct radeon_bo *src_bo,
intptr_t src_offset,
gl_format src_mesaformat,
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
index c40802aec6..8a2f5ce021 100644
--- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c
+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
@@ -69,7 +69,7 @@ static unsigned packet0_count(r300ContextPtr r300, uint32_t *pkt)
#define vpu_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
#define r500fp_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->r500fp.count)
-static int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_vpu(struct gl_context *ctx, struct radeon_state_atom *atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int cnt;
@@ -83,7 +83,7 @@ static int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom)
return cnt ? (cnt * 4) + extra : 0;
}
-static int check_vpp(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_vpp(struct gl_context *ctx, struct radeon_state_atom *atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int cnt;
@@ -114,7 +114,7 @@ void r300_emit_vpu(struct r300_context *r300,
END_BATCH();
}
-static void emit_vpu_state(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_vpu_state(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
drm_r300_cmd_header_t cmd;
@@ -126,7 +126,7 @@ static void emit_vpu_state(GLcontext *ctx, struct radeon_state_atom * atom)
r300_emit_vpu(r300, &atom->cmd[1], vpu_count(atom->cmd) * 4, addr);
}
-static void emit_vpp_state(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_vpp_state(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
drm_r300_cmd_header_t cmd;
@@ -158,7 +158,7 @@ void r500_emit_fp(struct r300_context *r300,
END_BATCH();
}
-static void emit_r500fp_atom(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_r500fp_atom(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
drm_r300_cmd_header_t cmd;
@@ -179,7 +179,7 @@ static void emit_r500fp_atom(GLcontext *ctx, struct radeon_state_atom * atom)
r500_emit_fp(r300, &atom->cmd[1], count, addr, type, clamp);
}
-static int check_tex_offsets(GLcontext *ctx, struct radeon_state_atom * atom)
+static int check_tex_offsets(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int numtmus = packet0_count(r300, r300->hw.tex.offset.cmd);
@@ -200,7 +200,7 @@ static int check_tex_offsets(GLcontext *ctx, struct radeon_state_atom * atom)
return dw;
}
-static void emit_tex_offsets(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_tex_offsets(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
BATCH_LOCALS(&r300->radeon);
@@ -249,7 +249,7 @@ static void emit_tex_offsets(GLcontext *ctx, struct radeon_state_atom * atom)
}
}
-void r300_emit_scissor(GLcontext *ctx)
+void r300_emit_scissor(struct gl_context *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
BATCH_LOCALS(&r300->radeon);
@@ -287,7 +287,7 @@ void r300_emit_scissor(GLcontext *ctx)
OUT_BATCH((x2 << R300_SCISSORS_X_SHIFT)|(y2 << R300_SCISSORS_Y_SHIFT));
END_BATCH();
}
-static int check_cb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
+static int check_cb_offset(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
uint32_t dw = 6 + 3 + 16;
@@ -411,7 +411,7 @@ void r300_emit_cb_setup(struct r300_context *r300,
END_BATCH();
}
-static void emit_cb_offset_atom(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_cb_offset_atom(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct radeon_renderbuffer *rrb;
@@ -433,7 +433,7 @@ static void emit_cb_offset_atom(GLcontext *ctx, struct radeon_state_atom * atom)
}
}
-static int check_zb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
+static int check_zb_offset(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
uint32_t dw;
@@ -443,7 +443,7 @@ static int check_zb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
return dw;
}
-static void emit_zb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_zb_offset(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
BATCH_LOCALS(&r300->radeon);
@@ -476,7 +476,7 @@ static void emit_zb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
END_BATCH();
}
-static void emit_zstencil_format(GLcontext *ctx, struct radeon_state_atom * atom)
+static void emit_zstencil_format(struct gl_context *ctx, struct radeon_state_atom * atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
BATCH_LOCALS(&r300->radeon);
@@ -504,17 +504,17 @@ static void emit_zstencil_format(GLcontext *ctx, struct radeon_state_atom * atom
END_BATCH();
}
-static int check_never(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_never(struct gl_context *ctx, struct radeon_state_atom *atom)
{
return 0;
}
-static int check_always(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_always(struct gl_context *ctx, struct radeon_state_atom *atom)
{
return atom->cmd_size;
}
-static int check_variable(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_variable(struct gl_context *ctx, struct radeon_state_atom *atom)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int cnt;
@@ -525,7 +525,7 @@ static int check_variable(GLcontext *ctx, struct radeon_state_atom *atom)
return cnt ? cnt + 1 : 0;
}
-static int check_r500fp(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_r500fp(struct gl_context *ctx, struct radeon_state_atom *atom)
{
int cnt;
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -537,7 +537,7 @@ static int check_r500fp(GLcontext *ctx, struct radeon_state_atom *atom)
return cnt ? (cnt * 6) + extra : 0;
}
-static int check_r500fp_const(GLcontext *ctx, struct radeon_state_atom *atom)
+static int check_r500fp_const(struct gl_context *ctx, struct radeon_state_atom *atom)
{
int cnt;
r300ContextPtr r300 = R300_CONTEXT(ctx);
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.h b/src/mesa/drivers/dri/r300/r300_cmdbuf.h
index 0e68da928e..7e6b8c5de6 100644
--- a/src/mesa/drivers/dri/r300/r300_cmdbuf.h
+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.h
@@ -45,7 +45,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SCISSORS_BUFSZ (3)
void r300InitCmdBuf(r300ContextPtr r300);
-void r300_emit_scissor(GLcontext *ctx);
+void r300_emit_scissor(struct gl_context *ctx);
void r300_emit_vpu(struct r300_context *ctx,
uint32_t *data,
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index 3d2f8928fa..9fbd36bfe6 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -134,7 +134,6 @@ static const struct dri_extension card_extensions[] = {
{"GL_MESAX_texture_float", NULL},
{"GL_NV_blend_square", NULL},
{"GL_NV_vertex_program", GL_NV_vertex_program_functions},
- {"GL_SGIS_generate_mipmap", NULL},
{NULL, NULL}
/* *INDENT-ON* */
};
@@ -220,7 +219,7 @@ static void r300_vtbl_pre_emit_atoms(radeonContextPtr radeon)
end_3d(radeon);
}
-static void r300_fallback(GLcontext *ctx, GLuint bit, GLboolean mode)
+static void r300_fallback(struct gl_context *ctx, GLuint bit, GLboolean mode)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
if (mode)
@@ -332,7 +331,7 @@ static void r300_init_vtbl(radeonContextPtr radeon)
}
}
-static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
+static void r300InitConstValues(struct gl_context *ctx, radeonScreenPtr screen)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -440,7 +439,7 @@ static void r300ParseOptions(r300ContextPtr r300, radeonScreenPtr screen)
r300->options = options;
}
-static void r300InitGLExtensions(GLcontext *ctx)
+static void r300InitGLExtensions(struct gl_context *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -478,7 +477,7 @@ static void r300InitIoctlFuncs(struct dd_function_table *functions)
/* Create the device specific rendering context.
*/
GLboolean r300CreateContext(gl_api api,
- const __GLcontextModes * glVisual,
+ const struct gl_config * glVisual,
__DRIcontext * driContextPriv,
void *sharedContextPrivate)
{
@@ -486,7 +485,7 @@ GLboolean r300CreateContext(gl_api api,
radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
struct dd_function_table functions;
r300ContextPtr r300;
- GLcontext *ctx;
+ struct gl_context *ctx;
assert(glVisual);
assert(driContextPriv);
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index 99540e3354..349a3d412f 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -463,9 +463,9 @@ struct r300_swtcl_info {
};
struct r300_vtable {
- void (* SetupRSUnit)(GLcontext *ctx);
- void (* SetupFragmentShaderTextures)(GLcontext *ctx, int *tmu_mappings);
- void (* SetupPixelShader)(GLcontext *ctx);
+ void (* SetupRSUnit)(struct gl_context *ctx);
+ void (* SetupFragmentShaderTextures)(struct gl_context *ctx, int *tmu_mappings);
+ void (* SetupPixelShader)(struct gl_context *ctx);
};
struct r300_vertex_buffer {
@@ -544,7 +544,7 @@ struct r300_context {
extern void r300DestroyContext(__DRIcontext * driContextPriv);
extern GLboolean r300CreateContext(gl_api api,
- const __GLcontextModes * glVisual,
+ const struct gl_config * glVisual,
__DRIcontext * driContextPriv,
void *sharedContextPrivate);
@@ -552,7 +552,7 @@ extern void r300InitShaderFuncs(struct dd_function_table *functions);
extern void r300InitShaderFunctions(r300ContextPtr r300);
-extern void r300InitDraw(GLcontext *ctx);
+extern void r300InitDraw(struct gl_context *ctx);
#define r300PackFloat32 radeonPackFloat32
#define r300PackFloat24 radeonPackFloat24
diff --git a/src/mesa/drivers/dri/r300/r300_draw.c b/src/mesa/drivers/dri/r300/r300_draw.c
index 5ae9f49840..81769e1ee5 100644
--- a/src/mesa/drivers/dri/r300/r300_draw.c
+++ b/src/mesa/drivers/dri/r300/r300_draw.c
@@ -75,7 +75,7 @@ static int getTypeSize(GLenum type)
}
}
-static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
+static void r300FixupIndexBuffer(struct gl_context *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
GLvoid *src_ptr;
@@ -143,7 +143,7 @@ static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
}
-static void r300SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
+static void r300SetupIndexBuffer(struct gl_context *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -219,7 +219,7 @@ static void r300SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
* Convert attribute data type to float
* If the attribute uses named buffer object replace the bo with newly allocated bo
*/
-static void r300ConvertAttrib(GLcontext *ctx, int count, const struct gl_client_array *input, struct vertex_attribute *attr)
+static void r300ConvertAttrib(struct gl_context *ctx, int count, const struct gl_client_array *input, struct vertex_attribute *attr)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
const GLvoid *src_ptr;
@@ -290,7 +290,7 @@ static void r300ConvertAttrib(GLcontext *ctx, int count, const struct gl_client_
}
}
-static void r300AlignDataToDword(GLcontext *ctx, const struct gl_client_array *input, int count, struct vertex_attribute *attr)
+static void r300AlignDataToDword(struct gl_context *ctx, const struct gl_client_array *input, int count, struct vertex_attribute *attr)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
const int dst_stride = (input->StrideB + 3) & ~3;
@@ -328,7 +328,7 @@ static void r300AlignDataToDword(GLcontext *ctx, const struct gl_client_array *i
attr->stride = dst_stride;
}
-static void r300TranslateAttrib(GLcontext *ctx, GLuint attr, int count, const struct gl_client_array *input)
+static void r300TranslateAttrib(struct gl_context *ctx, GLuint attr, int count, const struct gl_client_array *input)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct r300_vertex_buffer *vbuf = &r300->vbuf;
@@ -467,7 +467,7 @@ static void r300TranslateAttrib(GLcontext *ctx, GLuint attr, int count, const st
++vbuf->num_attribs;
}
-static void r300SetVertexFormat(GLcontext *ctx, const struct gl_client_array *arrays[], int count)
+static void r300SetVertexFormat(struct gl_context *ctx, const struct gl_client_array *arrays[], int count)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct r300_vertex_buffer *vbuf = &r300->vbuf;
@@ -497,7 +497,7 @@ static void r300SetVertexFormat(GLcontext *ctx, const struct gl_client_array *ar
return;
}
-static void r300AllocDmaRegions(GLcontext *ctx, const struct gl_client_array *input[], int count)
+static void r300AllocDmaRegions(struct gl_context *ctx, const struct gl_client_array *input[], int count)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct r300_vertex_buffer *vbuf = &r300->vbuf;
@@ -578,7 +578,7 @@ static void r300AllocDmaRegions(GLcontext *ctx, const struct gl_client_array *in
}
-static void r300FreeData(GLcontext *ctx)
+static void r300FreeData(struct gl_context *ctx)
{
/* Need to zero tcl.aos[n].bo and tcl.elt_dma_bo
* to prevent double unref in radeonReleaseArrays
@@ -604,7 +604,7 @@ static void r300FreeData(GLcontext *ctx)
}
}
-static GLuint r300PredictTryDrawPrimsSize(GLcontext *ctx,
+static GLuint r300PredictTryDrawPrimsSize(struct gl_context *ctx,
GLuint nr_prims, const struct _mesa_prim *prim)
{
struct r300_context *r300 = R300_CONTEXT(ctx);
@@ -641,7 +641,7 @@ static GLuint r300PredictTryDrawPrimsSize(GLcontext *ctx,
return dwords;
}
-static GLboolean r300TryDrawPrims(GLcontext *ctx,
+static GLboolean r300TryDrawPrims(struct gl_context *ctx,
const struct gl_client_array *arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
@@ -707,7 +707,7 @@ static GLboolean r300TryDrawPrims(GLcontext *ctx,
return GL_TRUE;
}
-static void r300DrawPrims(GLcontext *ctx,
+static void r300DrawPrims(struct gl_context *ctx,
const struct gl_client_array *arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
@@ -741,7 +741,7 @@ static void r300DrawPrims(GLcontext *ctx,
_tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
}
-void r300InitDraw(GLcontext *ctx)
+void r300InitDraw(struct gl_context *ctx)
{
struct vbo_context *vbo = vbo_context(ctx);
diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c
index a24d431611..f392006ced 100644
--- a/src/mesa/drivers/dri/r300/r300_emit.c
+++ b/src/mesa/drivers/dri/r300/r300_emit.c
@@ -48,14 +48,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_emit.h"
-GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead)
+GLuint r300VAPInputCntl0(struct gl_context * ctx, GLuint InputsRead)
{
/* No idea what this value means. I have seen other values written to
* this register... */
return 0x5555;
}
-GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead)
+GLuint r300VAPInputCntl1(struct gl_context * ctx, GLuint InputsRead)
{
GLuint i, vic_1 = 0;
@@ -76,7 +76,7 @@ GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead)
return vic_1;
}
-GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint vp_writes)
+GLuint r300VAPOutputCntl0(struct gl_context * ctx, GLuint vp_writes)
{
GLuint ret = 0;
@@ -100,7 +100,7 @@ GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint vp_writes)
return ret;
}
-GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint vp_writes)
+GLuint r300VAPOutputCntl1(struct gl_context * ctx, GLuint vp_writes)
{
GLuint i, ret = 0, first_free_texcoord = 0;
diff --git a/src/mesa/drivers/dri/r300/r300_emit.h b/src/mesa/drivers/dri/r300/r300_emit.h
index a456d8867c..8911ab7728 100644
--- a/src/mesa/drivers/dri/r300/r300_emit.h
+++ b/src/mesa/drivers/dri/r300/r300_emit.h
@@ -220,9 +220,9 @@ extern int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim);
extern void r300EmitCacheFlush(r300ContextPtr rmesa);
-extern GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead);
-extern GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead);
-extern GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint vp_writes);
-extern GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint vp_writes);
+extern GLuint r300VAPInputCntl0(struct gl_context * ctx, GLuint InputsRead);
+extern GLuint r300VAPInputCntl1(struct gl_context * ctx, GLuint InputsRead);
+extern GLuint r300VAPOutputCntl0(struct gl_context * ctx, GLuint vp_writes);
+extern GLuint r300VAPOutputCntl1(struct gl_context * ctx, GLuint vp_writes);
#endif
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c
index 4af91f114d..4e457b51eb 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog_common.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.c
@@ -208,7 +208,7 @@ static void allocate_hw_inputs(
}
-static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_program_cont *cont, struct r300_fragment_program *fp)
+static void translate_fragment_program(struct gl_context *ctx, struct r300_fragment_program_cont *cont, struct r300_fragment_program *fp)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct r300_fragment_program_compiler compiler;
@@ -278,7 +278,7 @@ static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_prog
rc_destroy(&compiler.Base);
}
-struct r300_fragment_program *r300SelectAndTranslateFragmentShader(GLcontext *ctx)
+struct r300_fragment_program *r300SelectAndTranslateFragmentShader(struct gl_context *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct r300_fragment_program_cont *fp_list;
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.h b/src/mesa/drivers/dri/r300/r300_fragprog_common.h
index 3d64c08cee..cfa5acf433 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog_common.h
+++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.h
@@ -32,6 +32,6 @@
#include "r300_context.h"
-struct r300_fragment_program *r300SelectAndTranslateFragmentShader(GLcontext *ctx);
+struct r300_fragment_program *r300SelectAndTranslateFragmentShader(struct gl_context *ctx);
#endif
diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c
index cf89ab7ec3..821318e7a5 100644
--- a/src/mesa/drivers/dri/r300/r300_render.c
+++ b/src/mesa/drivers/dri/r300/r300_render.c
@@ -321,7 +321,7 @@ static void r300FireAOS(r300ContextPtr rmesa, int vertex_count, int type)
END_BATCH();
}
-void r300RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim)
+void r300RunRenderPrimitive(struct gl_context * ctx, int start, int end, int prim)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
BATCH_LOCALS(&rmesa->radeon);
@@ -444,7 +444,7 @@ static const char *getFallbackString(r300ContextPtr rmesa, uint32_t bit)
}
}
-void r300SwitchFallback(GLcontext *ctx, uint32_t bit, GLboolean mode)
+void r300SwitchFallback(struct gl_context *ctx, uint32_t bit, GLboolean mode)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
diff --git a/src/mesa/drivers/dri/r300/r300_render.h b/src/mesa/drivers/dri/r300/r300_render.h
index 581e9fa0cc..5a78592c75 100644
--- a/src/mesa/drivers/dri/r300/r300_render.h
+++ b/src/mesa/drivers/dri/r300/r300_render.h
@@ -63,8 +63,8 @@
extern const struct tnl_pipeline_stage _r300_render_stage;
-extern void r300SwitchFallback(GLcontext *ctx, uint32_t bit, GLboolean mode);
+extern void r300SwitchFallback(struct gl_context *ctx, uint32_t bit, GLboolean mode);
-extern void r300RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim);
+extern void r300RunRenderPrimitive(struct gl_context * ctx, int start, int end, int prim);
#endif
diff --git a/src/mesa/drivers/dri/r300/r300_shader.c b/src/mesa/drivers/dri/r300/r300_shader.c
index a9bddf0577..f2bbac5b85 100644
--- a/src/mesa/drivers/dri/r300/r300_shader.c
+++ b/src/mesa/drivers/dri/r300/r300_shader.c
@@ -32,7 +32,7 @@
#include "r300_context.h"
#include "r300_fragprog_common.h"
-static void freeFragProgCache(GLcontext *ctx, struct r300_fragment_program_cont *cache)
+static void freeFragProgCache(struct gl_context *ctx, struct r300_fragment_program_cont *cache)
{
struct r300_fragment_program *tmp, *fp = cache->progs;
@@ -44,7 +44,7 @@ static void freeFragProgCache(GLcontext *ctx, struct r300_fragment_program_cont
}
}
-static void freeVertProgCache(GLcontext *ctx, struct r300_vertex_program_cont *cache)
+static void freeVertProgCache(struct gl_context *ctx, struct r300_vertex_program_cont *cache)
{
struct r300_vertex_program *tmp, *vp = cache->progs;
@@ -57,7 +57,7 @@ static void freeVertProgCache(GLcontext *ctx, struct r300_vertex_program_cont *c
}
}
-static struct gl_program *r300NewProgram(GLcontext * ctx, GLenum target,
+static struct gl_program *r300NewProgram(struct gl_context * ctx, GLenum target,
GLuint id)
{
struct r300_vertex_program_cont *vp;
@@ -81,7 +81,7 @@ static struct gl_program *r300NewProgram(GLcontext * ctx, GLenum target,
return NULL;
}
-static void r300DeleteProgram(GLcontext * ctx, struct gl_program *prog)
+static void r300DeleteProgram(struct gl_context * ctx, struct gl_program *prog)
{
struct r300_vertex_program_cont *vp = (struct r300_vertex_program_cont *)prog;
struct r300_fragment_program_cont *fp = (struct r300_fragment_program_cont *)prog;
@@ -99,7 +99,7 @@ static void r300DeleteProgram(GLcontext * ctx, struct gl_program *prog)
}
static GLboolean
-r300ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
+r300ProgramStringNotify(struct gl_context * ctx, GLenum target, struct gl_program *prog)
{
struct r300_vertex_program_cont *vp = (struct r300_vertex_program_cont *)prog;
struct r300_fragment_program_cont *fp = (struct r300_fragment_program_cont *)prog;
@@ -123,7 +123,7 @@ r300ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
}
static GLboolean
-r300IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
+r300IsProgramNative(struct gl_context * ctx, GLenum target, struct gl_program *prog)
{
if (target == GL_FRAGMENT_PROGRAM_ARB) {
struct r300_fragment_program *fp = r300SelectAndTranslateFragmentShader(ctx);
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 0113eecaa3..ab8c1df5f7 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -62,7 +62,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_render.h"
#include "r300_vertprog.h"
-static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
+static void r300BlendColor(struct gl_context * ctx, const GLfloat cf[4])
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -204,7 +204,7 @@ static void r300SetBlendCntl(r300ContextPtr r300, int func, int eqn,
}
}
-static void r300SetBlendState(GLcontext * ctx)
+static void r300SetBlendState(struct gl_context * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int func = (R300_BLEND_GL_ONE << R300_SRC_BLEND_SHIFT) |
@@ -302,13 +302,13 @@ static void r300SetBlendState(GLcontext * ctx)
R300_ALPHA_BLEND_ENABLE), funcA, eqnA);
}
-static void r300BlendEquationSeparate(GLcontext * ctx,
+static void r300BlendEquationSeparate(struct gl_context * ctx,
GLenum modeRGB, GLenum modeA)
{
r300SetBlendState(ctx);
}
-static void r300BlendFuncSeparate(GLcontext * ctx,
+static void r300BlendFuncSeparate(struct gl_context * ctx,
GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA)
{
@@ -331,7 +331,7 @@ static GLuint translate_logicop(GLenum logicop)
* Used internally to update the r300->hw hardware state to match the
* current OpenGL state.
*/
-static void r300SetLogicOpState(GLcontext *ctx)
+static void r300SetLogicOpState(struct gl_context *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
R300_STATECHANGE(r300, rop);
@@ -347,13 +347,13 @@ static void r300SetLogicOpState(GLcontext *ctx)
* Called by Mesa when an application program changes the LogicOp state
* via glLogicOp.
*/
-static void r300LogicOpcode(GLcontext *ctx, GLenum logicop)
+static void r300LogicOpcode(struct gl_context *ctx, GLenum logicop)
{
if (RGBA_LOGICOP_ENABLED(ctx))
r300SetLogicOpState(ctx);
}
-static void r300ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
+static void r300ClipPlane( struct gl_context *ctx, GLenum plane, const GLfloat *eq )
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
GLint p;
@@ -373,7 +373,7 @@ static void r300ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
rmesa->hw.vpucp[p].cmd[R300_VPUCP_W] = ip[3];
}
-static void r300SetClipPlaneState(GLcontext * ctx, GLenum cap, GLboolean state)
+static void r300SetClipPlaneState(struct gl_context * ctx, GLenum cap, GLboolean state)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
GLuint p;
@@ -395,7 +395,7 @@ static void r300SetClipPlaneState(GLcontext * ctx, GLenum cap, GLboolean state)
/**
* Update our tracked culling state based on Mesa's state.
*/
-static void r300UpdateCulling(GLcontext * ctx)
+static void r300UpdateCulling(struct gl_context * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
uint32_t val = 0;
@@ -435,7 +435,7 @@ static void r300UpdateCulling(GLcontext * ctx)
r300->hw.cul.cmd[R300_CUL_CULL] = val;
}
-static void r300SetPolygonOffsetState(GLcontext * ctx, GLboolean state)
+static void r300SetPolygonOffsetState(struct gl_context * ctx, GLboolean state)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -447,14 +447,14 @@ static void r300SetPolygonOffsetState(GLcontext * ctx, GLboolean state)
}
}
-static GLboolean current_fragment_program_writes_depth(GLcontext* ctx)
+static GLboolean current_fragment_program_writes_depth(struct gl_context* ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
return ctx->FragmentProgram._Current && r300->selected_fp->code.writes_depth;
}
-static void r300SetEarlyZState(GLcontext * ctx)
+static void r300SetEarlyZState(struct gl_context * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
GLuint topZ = R300_ZTOP_ENABLE;
@@ -499,7 +499,7 @@ static void r300SetEarlyZState(GLcontext * ctx)
}
}
-static void r300SetAlphaState(GLcontext * ctx)
+static void r300SetAlphaState(struct gl_context * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
GLubyte refByte;
@@ -549,7 +549,7 @@ static void r300SetAlphaState(GLcontext * ctx)
r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
}
-static void r300AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
+static void r300AlphaFunc(struct gl_context * ctx, GLenum func, GLfloat ref)
{
(void)func;
(void)ref;
@@ -579,7 +579,7 @@ static int translate_func(int func)
return 0;
}
-static void r300SetDepthState(GLcontext * ctx)
+static void r300SetDepthState(struct gl_context * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -598,7 +598,7 @@ static void r300SetDepthState(GLcontext * ctx)
}
}
-static void r300CatchStencilFallback(GLcontext *ctx)
+static void r300CatchStencilFallback(struct gl_context *ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
const unsigned back = ctx->Stencil._BackFace;
@@ -616,7 +616,7 @@ static void r300CatchStencilFallback(GLcontext *ctx)
}
}
-static void r300SetStencilState(GLcontext * ctx, GLboolean state)
+static void r300SetStencilState(struct gl_context * ctx, GLboolean state)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
GLboolean hw_stencil = GL_FALSE;
@@ -641,7 +641,7 @@ static void r300SetStencilState(GLcontext * ctx, GLboolean state)
}
}
-static void r300UpdatePolygonMode(GLcontext * ctx)
+static void r300UpdatePolygonMode(struct gl_context * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
uint32_t hw_mode = R300_GA_POLY_MODE_DISABLE;
@@ -704,7 +704,7 @@ static void r300UpdatePolygonMode(GLcontext * ctx)
*
* \note Mesa already filters redundant calls to this function.
*/
-static void r300CullFace(GLcontext * ctx, GLenum mode)
+static void r300CullFace(struct gl_context * ctx, GLenum mode)
{
(void)mode;
@@ -716,7 +716,7 @@ static void r300CullFace(GLcontext * ctx, GLenum mode)
*
* \note Mesa already filters redundant calls to this function.
*/
-static void r300FrontFace(GLcontext * ctx, GLenum mode)
+static void r300FrontFace(struct gl_context * ctx, GLenum mode)
{
(void)mode;
@@ -729,7 +729,7 @@ static void r300FrontFace(GLcontext * ctx, GLenum mode)
*
* \note Mesa already filters redundant calls to this function.
*/
-static void r300DepthFunc(GLcontext * ctx, GLenum func)
+static void r300DepthFunc(struct gl_context * ctx, GLenum func)
{
(void)func;
r300SetDepthState(ctx);
@@ -740,7 +740,7 @@ static void r300DepthFunc(GLcontext * ctx, GLenum func)
*
* \note Mesa already filters redundant calls to this function.
*/
-static void r300DepthMask(GLcontext * ctx, GLboolean mask)
+static void r300DepthMask(struct gl_context * ctx, GLboolean mask)
{
(void)mask;
r300SetDepthState(ctx);
@@ -749,7 +749,7 @@ static void r300DepthMask(GLcontext * ctx, GLboolean mask)
/**
* Handle glColorMask()
*/
-static void r300ColorMask(GLcontext * ctx,
+static void r300ColorMask(struct gl_context * ctx,
GLboolean r, GLboolean g, GLboolean b, GLboolean a)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -767,7 +767,7 @@ static void r300ColorMask(GLcontext * ctx,
/* =============================================================
* Point state
*/
-static void r300PointSize(GLcontext * ctx, GLfloat size)
+static void r300PointSize(struct gl_context * ctx, GLfloat size)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -784,7 +784,7 @@ static void r300PointSize(GLcontext * ctx, GLfloat size)
((int)(size * 6) << R300_POINTSIZE_Y_SHIFT);
}
-static void r300PointParameter(GLcontext * ctx, GLenum pname, const GLfloat * param)
+static void r300PointParameter(struct gl_context * ctx, GLenum pname, const GLfloat * param)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -814,7 +814,7 @@ static void r300PointParameter(GLcontext * ctx, GLenum pname, const GLfloat * pa
/* =============================================================
* Line state
*/
-static void r300LineWidth(GLcontext * ctx, GLfloat widthf)
+static void r300LineWidth(struct gl_context * ctx, GLfloat widthf)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -826,7 +826,7 @@ static void r300LineWidth(GLcontext * ctx, GLfloat widthf)
R300_LINE_CNT_HO | R300_LINE_CNT_VE | (int)(widthf * 6.0);
}
-static void r300PolygonMode(GLcontext * ctx, GLenum face, GLenum mode)
+static void r300PolygonMode(struct gl_context * ctx, GLenum face, GLenum mode)
{
(void)face;
(void)mode;
@@ -864,7 +864,7 @@ static int translate_stencil_op(int op)
return 0;
}
-static void r300ShadeModel(GLcontext * ctx, GLenum mode)
+static void r300ShadeModel(struct gl_context * ctx, GLenum mode)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -885,7 +885,7 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode)
rmesa->hw.shade2.cmd[3] = 0x00000000;
}
-static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face,
+static void r300StencilFuncSeparate(struct gl_context * ctx, GLenum face,
GLenum func, GLint ref, GLuint mask)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -932,7 +932,7 @@ static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face,
}
}
-static void r300StencilMaskSeparate(GLcontext * ctx, GLenum face, GLuint mask)
+static void r300StencilMaskSeparate(struct gl_context * ctx, GLenum face, GLuint mask)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
const unsigned back = ctx->Stencil._BackFace;
@@ -956,7 +956,7 @@ static void r300StencilMaskSeparate(GLcontext * ctx, GLenum face, GLuint mask)
}
}
-static void r300StencilOpSeparate(GLcontext * ctx, GLenum face,
+static void r300StencilOpSeparate(struct gl_context * ctx, GLenum face,
GLenum fail, GLenum zfail, GLenum zpass)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -992,7 +992,7 @@ static void r300StencilOpSeparate(GLcontext * ctx, GLenum face,
* Window position and viewport transformation
*/
-static void r300UpdateWindow(GLcontext * ctx)
+static void r300UpdateWindow(struct gl_context * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
__DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
@@ -1028,7 +1028,7 @@ static void r300UpdateWindow(GLcontext * ctx)
rmesa->hw.vpt.cmd[R300_VPT_ZOFFSET] = r300PackFloat32(tz);
}
-static void r300Viewport(GLcontext * ctx, GLint x, GLint y,
+static void r300Viewport(struct gl_context * ctx, GLint x, GLint y,
GLsizei width, GLsizei height)
{
/* Don't pipeline viewport changes, conflict with window offset
@@ -1040,12 +1040,12 @@ static void r300Viewport(GLcontext * ctx, GLint x, GLint y,
radeon_viewport(ctx, x, y, width, height);
}
-static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
+static void r300DepthRange(struct gl_context * ctx, GLclampd nearval, GLclampd farval)
{
r300UpdateWindow(ctx);
}
-void r300UpdateViewportOffset(GLcontext * ctx)
+void r300UpdateViewportOffset(struct gl_context * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
__DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
@@ -1074,7 +1074,7 @@ void r300UpdateViewportOffset(GLcontext * ctx)
* Update R300's own internal state parameters.
* For now just STATE_R300_WINDOW_DIMENSION
*/
-static void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state)
+static void r300UpdateStateParameters(struct gl_context * ctx, GLuint new_state)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_program_parameter_list *paramList;
@@ -1096,7 +1096,7 @@ static void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state)
/* =============================================================
* Polygon state
*/
-static void r300PolygonOffset(GLcontext * ctx, GLfloat factor, GLfloat units)
+static void r300PolygonOffset(struct gl_context * ctx, GLfloat factor, GLfloat units)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
GLfloat constant = units;
@@ -1193,7 +1193,7 @@ static unsigned long gen_fixed_filter(unsigned long f)
return f;
}
-static void r300SetupFragmentShaderTextures(GLcontext *ctx, int *tmu_mappings)
+static void r300SetupFragmentShaderTextures(struct gl_context *ctx, int *tmu_mappings)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int i;
@@ -1235,7 +1235,7 @@ static void r300SetupFragmentShaderTextures(GLcontext *ctx, int *tmu_mappings)
R300_US_TEX_INST_0, code->tex.length);
}
-static void r500SetupFragmentShaderTextures(GLcontext *ctx, int *tmu_mappings)
+static void r500SetupFragmentShaderTextures(struct gl_context *ctx, int *tmu_mappings)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
int i;
@@ -1280,7 +1280,7 @@ static GLuint translate_lod_bias(GLfloat bias)
}
-static void r300SetupTextures(GLcontext * ctx)
+static void r300SetupTextures(struct gl_context * ctx)
{
int i, mtu;
struct radeon_tex_obj *t;
@@ -1427,7 +1427,7 @@ union r300_outputs_written {
((hw_tcl_on) ? (ow).vp_outputs & (1 << (vp_result)) : \
RENDERINPUTS_TEST( (ow.index_bitset), (tnl_attrib) ))
-static void r300SetupRSUnit(GLcontext * ctx)
+static void r300SetupRSUnit(struct gl_context * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
union r300_outputs_written OutputsWritten;
@@ -1521,7 +1521,7 @@ static void r300SetupRSUnit(GLcontext * ctx)
WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n", InputsRead);
}
-static void r500SetupRSUnit(GLcontext * ctx)
+static void r500SetupRSUnit(struct gl_context * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
union r300_outputs_written OutputsWritten;
@@ -1681,7 +1681,7 @@ void r300VapCntl(r300ContextPtr rmesa, GLuint input_count,
*
* \note Mesa already filters redundant calls to this function.
*/
-static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
+static void r300Enable(struct gl_context * ctx, GLenum cap, GLboolean state)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
if (RADEON_DEBUG & RADEON_STATE)
@@ -1756,7 +1756,7 @@ static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
*/
static void r300ResetHwState(r300ContextPtr r300)
{
- GLcontext *ctx = r300->radeon.glCtx;
+ struct gl_context *ctx = r300->radeon.glCtx;
int has_tcl;
has_tcl = r300->options.hw_tcl_enabled;
@@ -1965,7 +1965,7 @@ static void r300ResetHwState(r300ContextPtr r300)
void r300UpdateShaders(r300ContextPtr rmesa)
{
- GLcontext *ctx = rmesa->radeon.glCtx;
+ struct gl_context *ctx = rmesa->radeon.glCtx;
/* should only happenen once, just after context is created */
/* TODO: shouldn't we fallback to sw here? */
@@ -1994,7 +1994,7 @@ void r300UpdateShaders(r300ContextPtr rmesa)
rmesa->radeon.NewGLState = 0;
}
-static const GLfloat *get_fragmentprogram_constant(GLcontext *ctx, GLuint index, GLfloat * buffer)
+static const GLfloat *get_fragmentprogram_constant(struct gl_context *ctx, GLuint index, GLfloat * buffer)
{
static const GLfloat dummy[4] = { 0, 0, 0, 0 };
r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -2052,7 +2052,7 @@ static const GLfloat *get_fragmentprogram_constant(GLcontext *ctx, GLuint index,
}
-static void r300SetupPixelShader(GLcontext *ctx)
+static void r300SetupPixelShader(struct gl_context *ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_fragment_program *fp = rmesa->selected_fp;
@@ -2109,7 +2109,7 @@ static void r300SetupPixelShader(GLcontext *ctx)
if(_nc>_p->r500fp.count)_p->r500fp.count=_nc;\
} while(0)
-static void r500SetupPixelShader(GLcontext *ctx)
+static void r500SetupPixelShader(struct gl_context *ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct r300_fragment_program *fp = rmesa->selected_fp;
@@ -2158,7 +2158,7 @@ static void r500SetupPixelShader(GLcontext *ctx)
bump_r500fp_const_count(rmesa->hw.r500fp_const.cmd, fp->code.constants.Count * 4);
}
-void r300SetupVAP(GLcontext *ctx, GLuint InputsRead, GLuint OutputsWritten)
+void r300SetupVAP(struct gl_context *ctx, GLuint InputsRead, GLuint OutputsWritten)
{
r300ContextPtr rmesa = R300_CONTEXT( ctx );
struct vertex_attribute *attrs = rmesa->vbuf.attribs;
@@ -2218,7 +2218,7 @@ void r300SetupVAP(GLcontext *ctx, GLuint InputsRead, GLuint OutputsWritten)
void r300UpdateShaderStates(r300ContextPtr rmesa)
{
- GLcontext *ctx;
+ struct gl_context *ctx;
ctx = rmesa->radeon.glCtx;
/* should only happenen once, just after context is created */
@@ -2241,7 +2241,7 @@ void r300UpdateShaderStates(r300ContextPtr rmesa)
#define EASY_US_OUT_FMT(comps, c0, c1, c2, c3) \
(R500_OUT_FMT_##comps | R500_C0_SEL_##c0 | R500_C1_SEL_##c1 | \
R500_C2_SEL_##c2 | R500_C3_SEL_##c3)
-static void r300SetupUsOutputFormat(GLcontext *ctx)
+static void r300SetupUsOutputFormat(struct gl_context *ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
uint32_t hw_format;
@@ -2292,6 +2292,7 @@ static void r300SetupUsOutputFormat(GLcontext *ctx)
break;
default:
assert(!"Unsupported format");
+ hw_format = 0;
break;
}
@@ -2303,7 +2304,7 @@ static void r300SetupUsOutputFormat(GLcontext *ctx)
/**
* Called by Mesa after an internal state update.
*/
-static void r300InvalidateState(GLcontext * ctx, GLuint new_state)
+static void r300InvalidateState(struct gl_context * ctx, GLuint new_state)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -2346,7 +2347,7 @@ void r300InitState(r300ContextPtr r300)
r300ResetHwState(r300);
}
-static void r300RenderMode(GLcontext * ctx, GLenum mode)
+static void r300RenderMode(struct gl_context * ctx, GLenum mode)
{
r300SwitchFallback(ctx, R300_FALLBACK_RENDER_MODE, ctx->RenderMode != GL_RENDER);
}
diff --git a/src/mesa/drivers/dri/r300/r300_state.h b/src/mesa/drivers/dri/r300/r300_state.h
index e70f84f4e4..e3b0da4cbd 100644
--- a/src/mesa/drivers/dri/r300/r300_state.h
+++ b/src/mesa/drivers/dri/r300/r300_state.h
@@ -50,13 +50,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
r300->radeon.hw.is_dirty = GL_TRUE; \
} while(0)
-void r300UpdateViewportOffset (GLcontext * ctx);
-void r300UpdateDrawBuffer (GLcontext * ctx);
+void r300UpdateViewportOffset (struct gl_context * ctx);
+void r300UpdateDrawBuffer (struct gl_context * ctx);
void r300UpdateShaders (r300ContextPtr rmesa);
void r300UpdateShaderStates (r300ContextPtr rmesa);
void r300InitState (r300ContextPtr r300);
void r300InitStateFuncs (radeonContextPtr radeon, struct dd_function_table *functions);
void r300VapCntl(r300ContextPtr rmesa, GLuint input_count, GLuint output_count, GLuint temp_count);
-void r300SetupVAP(GLcontext *ctx, GLuint InputsRead, GLuint OutputsWritten);
+void r300SetupVAP(struct gl_context *ctx, GLuint InputsRead, GLuint OutputsWritten);
#endif /* __R300_STATE_H__ */
diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c
index 4dcc7cb022..4a6762ff83 100644
--- a/src/mesa/drivers/dri/r300/r300_swtcl.c
+++ b/src/mesa/drivers/dri/r300/r300_swtcl.c
@@ -68,7 +68,7 @@ do { \
++num_attrs; \
} while (0)
-void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead, GLuint *_OutputsWritten)
+void r300ChooseSwtclVertexFormat(struct gl_context *ctx, GLuint *_InputsRead, GLuint *_OutputsWritten)
{
r300ContextPtr rmesa = R300_CONTEXT( ctx );
TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -226,7 +226,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead, GLuint *_
RENDERINPUTS_COPY(rmesa->render_inputs_bitset, tnl->render_inputs_bitset);
}
-static void r300PrepareVertices(GLcontext *ctx)
+static void r300PrepareVertices(struct gl_context *ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
GLuint InputsRead, OutputsWritten;
@@ -285,7 +285,7 @@ static GLuint reduced_prim[] = {
GL_TRIANGLES,
};
-static void r300RasterPrimitive( GLcontext *ctx, GLuint prim );
+static void r300RasterPrimitive( struct gl_context *ctx, GLuint prim );
/***********************************************************************
* Emit primitives as inline vertices *
@@ -497,7 +497,7 @@ static void init_rast_tab( void )
/**********************************************************************/
/* Choose render functions */
/**********************************************************************/
-static void r300ChooseRenderState( GLcontext *ctx )
+static void r300ChooseRenderState( struct gl_context *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -528,7 +528,7 @@ static void r300ChooseRenderState( GLcontext *ctx )
}
}
-void r300RenderStart(GLcontext *ctx)
+void r300RenderStart(struct gl_context *ctx)
{
radeon_print(RADEON_SWRENDER, RADEON_VERBOSE, "%s\n", __func__);
r300ContextPtr rmesa = R300_CONTEXT( ctx );
@@ -550,11 +550,11 @@ void r300RenderStart(GLcontext *ctx)
}
}
-void r300RenderFinish(GLcontext *ctx)
+void r300RenderFinish(struct gl_context *ctx)
{
}
-static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim )
+static void r300RasterPrimitive( struct gl_context *ctx, GLuint hwprim )
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
radeon_print(RADEON_SWRENDER, RADEON_TRACE, "%s\n", __func__);
@@ -565,7 +565,7 @@ static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim )
}
}
-void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
+void r300RenderPrimitive(struct gl_context *ctx, GLenum prim)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -578,13 +578,13 @@ void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
r300RasterPrimitive( ctx, reduced_prim[prim] );
}
-void r300ResetLineStipple(GLcontext *ctx)
+void r300ResetLineStipple(struct gl_context *ctx)
{
if (RADEON_DEBUG & RADEON_VERTS)
fprintf(stderr, "%s\n", __func__);
}
-void r300InitSwtcl(GLcontext *ctx)
+void r300InitSwtcl(struct gl_context *ctx)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -620,7 +620,7 @@ void r300InitSwtcl(GLcontext *ctx)
_tnl_need_projected_coords( ctx, GL_FALSE );
}
-void r300DestroySwtcl(GLcontext *ctx)
+void r300DestroySwtcl(struct gl_context *ctx)
{
}
@@ -656,7 +656,7 @@ static void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vert
END_BATCH();
}
-void r300_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
+void r300_swtcl_flush(struct gl_context *ctx, uint32_t current_offset)
{
radeon_print(RADEON_SWRENDER, RADEON_TRACE, "%s\n", __func__);
r300ContextPtr rmesa = R300_CONTEXT(ctx);
diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.h b/src/mesa/drivers/dri/r300/r300_swtcl.h
index c271d26546..51cfffc2af 100644
--- a/src/mesa/drivers/dri/r300/r300_swtcl.h
+++ b/src/mesa/drivers/dri/r300/r300_swtcl.h
@@ -50,16 +50,16 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SWTCL_OVM_TEX(n) ((n) + 6)
#define SWTCL_OVM_POINT_SIZE 15
-extern void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *InputsRead, GLuint *OutputsWritten);
+extern void r300ChooseSwtclVertexFormat(struct gl_context *ctx, GLuint *InputsRead, GLuint *OutputsWritten);
-extern void r300InitSwtcl( GLcontext *ctx );
-extern void r300DestroySwtcl( GLcontext *ctx );
+extern void r300InitSwtcl( struct gl_context *ctx );
+extern void r300DestroySwtcl( struct gl_context *ctx );
-extern void r300RenderStart(GLcontext *ctx);
-extern void r300RenderFinish(GLcontext *ctx);
-extern void r300RenderPrimitive(GLcontext *ctx, GLenum prim);
-extern void r300ResetLineStipple(GLcontext *ctx);
+extern void r300RenderStart(struct gl_context *ctx);
+extern void r300RenderFinish(struct gl_context *ctx);
+extern void r300RenderPrimitive(struct gl_context *ctx, GLenum prim);
+extern void r300ResetLineStipple(struct gl_context *ctx);
-extern void r300_swtcl_flush(GLcontext *ctx, uint32_t current_offset);
+extern void r300_swtcl_flush(struct gl_context *ctx, uint32_t current_offset);
#endif
diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c
index baef206bc2..a6bda0e499 100644
--- a/src/mesa/drivers/dri/r300/r300_tex.c
+++ b/src/mesa/drivers/dri/r300/r300_tex.c
@@ -185,7 +185,7 @@ static void r300SetTexBorderColor(radeonTexObjPtr t, const GLfloat color[4])
* next UpdateTextureState
*/
-static void r300TexParameter(GLcontext * ctx, GLenum target,
+static void r300TexParameter(struct gl_context * ctx, GLenum target,
struct gl_texture_object *texObj,
GLenum pname, const GLfloat * params)
{
@@ -243,7 +243,7 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
}
}
-static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
+static void r300DeleteTexture(struct gl_context * ctx, struct gl_texture_object *texObj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
radeonTexObj* t = radeon_tex_obj(texObj);
@@ -284,7 +284,7 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
* allocate the default texture objects.
* Fixup MaxAnisotropy according to user preference.
*/
-static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
+static struct gl_texture_object *r300NewTextureObject(struct gl_context * ctx,
GLuint name,
GLenum target)
{
diff --git a/src/mesa/drivers/dri/r300/r300_tex.h b/src/mesa/drivers/dri/r300/r300_tex.h
index aca44cd766..c44a39cb46 100644
--- a/src/mesa/drivers/dri/r300/r300_tex.h
+++ b/src/mesa/drivers/dri/r300/r300_tex.h
@@ -47,7 +47,7 @@ extern void r300SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth,
GLuint pitch);
-extern GLboolean r300ValidateBuffers(GLcontext * ctx);
+extern GLboolean r300ValidateBuffers(struct gl_context * ctx);
extern void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions);
diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c
index 9458869826..0116c5d2fa 100644
--- a/src/mesa/drivers/dri/r300/r300_texstate.c
+++ b/src/mesa/drivers/dri/r300/r300_texstate.c
@@ -301,7 +301,7 @@ static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t)
*
* Mostly this means populating the texture object's mipmap tree.
*/
-static GLboolean r300_validate_texture(GLcontext * ctx, struct gl_texture_object *texObj)
+static GLboolean r300_validate_texture(struct gl_context * ctx, struct gl_texture_object *texObj)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
radeonTexObj *t = radeon_tex_obj(texObj);
@@ -320,7 +320,7 @@ static GLboolean r300_validate_texture(GLcontext * ctx, struct gl_texture_object
/**
* Ensure all enabled and complete textures are uploaded along with any buffers being used.
*/
-GLboolean r300ValidateBuffers(GLcontext * ctx)
+GLboolean r300ValidateBuffers(struct gl_context * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct radeon_renderbuffer *rrb;
diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c
index a160128091..1daa305e3c 100644
--- a/src/mesa/drivers/dri/r300/r300_vertprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.c
@@ -49,7 +49,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Write parameter array for the given vertex program into dst.
* Return the total number of components written.
*/
-static int r300VertexProgUpdateParams(GLcontext * ctx, struct r300_vertex_program *vp, float *dst)
+static int r300VertexProgUpdateParams(struct gl_context * ctx, struct r300_vertex_program *vp, float *dst)
{
int i;
@@ -227,7 +227,7 @@ static void initialize_NV_registers(struct radeon_compiler * compiler)
inst->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_0000;
}
-static struct r300_vertex_program *build_program(GLcontext *ctx,
+static struct r300_vertex_program *build_program(struct gl_context *ctx,
struct r300_vertex_program_key *wanted_key,
const struct gl_vertex_program *mesa_vp)
{
@@ -307,7 +307,7 @@ static struct r300_vertex_program *build_program(GLcontext *ctx,
return vp;
}
-struct r300_vertex_program * r300SelectAndTranslateVertexShader(GLcontext *ctx)
+struct r300_vertex_program * r300SelectAndTranslateVertexShader(struct gl_context *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct r300_vertex_program_key wanted_key = { 0 };
@@ -386,7 +386,7 @@ static void r300EmitVertexProgram(r300ContextPtr r300, int dest, struct r300_ver
void r300SetupVertexProgram(r300ContextPtr rmesa)
{
- GLcontext *ctx = rmesa->radeon.glCtx;
+ struct gl_context *ctx = rmesa->radeon.glCtx;
struct r300_vertex_program *prog = rmesa->selected_vp;
int inst_count = 0;
int param_count = 0;
diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.h b/src/mesa/drivers/dri/r300/r300_vertprog.h
index ccec896be4..ce24dcb353 100644
--- a/src/mesa/drivers/dri/r300/r300_vertprog.h
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.h
@@ -6,6 +6,6 @@
void r300SetupVertexProgram(r300ContextPtr rmesa);
-struct r300_vertex_program * r300SelectAndTranslateVertexShader(GLcontext *ctx);
+struct r300_vertex_program * r300SelectAndTranslateVertexShader(struct gl_context *ctx);
#endif
diff --git a/src/mesa/drivers/dri/r300/radeon_context.h b/src/mesa/drivers/dri/r300/radeon_context.h
index da4812d323..52b7fb91e6 100644
--- a/src/mesa/drivers/dri/r300/radeon_context.h
+++ b/src/mesa/drivers/dri/r300/radeon_context.h
@@ -49,12 +49,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "drm.h"
#include "dri_util.h"
-#include "radeon_screen.h"
-
#define FALLBACK( radeon, bit, mode ) fprintf(stderr, "%s:%s\n", __LINE__, __FILE__);
/* TCL fallbacks */
-extern void radeonTclFallback(GLcontext * ctx, GLuint bit, GLboolean mode);
+extern void radeonTclFallback(struct gl_context * ctx, GLuint bit, GLboolean mode);
#define TCL_FALLBACK( ctx, bit, mode ) ;