summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300/r300_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/r300/r300_context.h')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h323
1 files changed, 183 insertions, 140 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index be6909724a..d2017f8afe 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -73,12 +73,12 @@ typedef struct r300_context *r300ContextPtr;
}
#include "r300_vertprog.h"
-#include "r300_fragprog.h"
+#include "r500_fragprog.h"
/**
* This function takes a float and packs it into a uint32_t
*/
-static inline uint32_t r300PackFloat32(float fl)
+static INLINE uint32_t r300PackFloat32(float fl)
{
union {
float fl;
@@ -95,7 +95,7 @@ static inline uint32_t r300PackFloat32(float fl)
* But it works for most things. I'll fix it later if someone
* else with a better clue doesn't
*/
-static inline uint32_t r300PackFloat24(float f)
+static INLINE uint32_t r300PackFloat24(float f)
{
float mantissa;
int exponent;
@@ -178,13 +178,6 @@ struct r300_tex_obj {
GLuint bufAddr; /* Offset to start of locally
shared texture block */
- GLuint dirty_state; /* Flags (1 per texunit) for
- whether or not this texobj
- has dirty hardware state
- (pp_*) that needs to be
- brought into the
- texunit. */
-
drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
/* Six, for the cube faces */
@@ -330,15 +323,17 @@ struct r300_state_atom {
#define R300_RI_INTERP_7 8
#define R300_RI_CMDSIZE 9
+#define R500_RI_CMDSIZE 17
+
#define R300_RR_CMD_0 0 /* rr is variable size (at least 1) */
-#define R300_RR_ROUTE_0 1
-#define R300_RR_ROUTE_1 2
-#define R300_RR_ROUTE_2 3
-#define R300_RR_ROUTE_3 4
-#define R300_RR_ROUTE_4 5
-#define R300_RR_ROUTE_5 6
-#define R300_RR_ROUTE_6 7
-#define R300_RR_ROUTE_7 8
+#define R300_RR_INST_0 1
+#define R300_RR_INST_1 2
+#define R300_RR_INST_2 3
+#define R300_RR_INST_3 4
+#define R300_RR_INST_4 5
+#define R300_RR_INST_5 6
+#define R300_RR_INST_6 7
+#define R300_RR_INST_7 8
#define R300_RR_CMDSIZE 9
#define R300_FP_CMD_0 0
@@ -352,6 +347,17 @@ struct r300_state_atom {
#define R300_FP_NODE3 8
#define R300_FP_CMDSIZE 9
+#define R500_FP_CMD_0 0
+#define R500_FP_CNTL 1
+#define R500_FP_PIXSIZE 2
+#define R500_FP_CMD_1 3
+#define R500_FP_CODE_ADDR 4
+#define R500_FP_CODE_RANGE 5
+#define R500_FP_CODE_OFFSET 6
+#define R500_FP_CMD_2 7
+#define R500_FP_FC_CNTL 8
+#define R500_FP_CMDSIZE 9
+
#define R300_FPT_CMD_0 0
#define R300_FPT_INSTR_0 1
#define R300_FPT_CMDSIZE 65
@@ -359,10 +365,14 @@ struct r300_state_atom {
#define R300_FPI_CMD_0 0
#define R300_FPI_INSTR_0 1
#define R300_FPI_CMDSIZE 65
+/* R500 has space for 512 instructions - 6 dwords per instruction */
+#define R500_FPI_CMDSIZE (512*6+1)
#define R300_FPP_CMD_0 0
#define R300_FPP_PARAM_0 1
#define R300_FPP_CMDSIZE (32*4+1)
+/* R500 has spcae for 256 constants - 4 dwords per constant */
+#define R500_FPP_CMDSIZE (256*4+1)
#define R300_FOGS_CMD_0 0
#define R300_FOGS_STATE 1
@@ -410,6 +420,12 @@ struct r300_state_atom {
#define R300_ZB_PITCH 2
#define R300_ZB_CMDSIZE 3
+#define R300_VAP_CNTL_FLUSH 0
+#define R300_VAP_CNTL_FLUSH_1 1
+#define R300_VAP_CNTL_CMD 2
+#define R300_VAP_CNTL_INSTR 3
+#define R300_VAP_CNTL_SIZE 4
+
#define R300_VPI_CMD_0 0
#define R300_VPI_INSTR_0 1
#define R300_VPI_CMDSIZE 1025 /* 256 16 byte instructions */
@@ -418,6 +434,13 @@ struct r300_state_atom {
#define R300_VPP_PARAM_0 1
#define R300_VPP_CMDSIZE 1025 /* 256 4-component parameters */
+#define R300_VPUCP_CMD_0 0
+#define R300_VPUCP_X 1
+#define R300_VPUCP_Y 2
+#define R300_VPUCP_Z 3
+#define R300_VPUCP_W 4
+#define R300_VPUCP_CMDSIZE 5 /* 256 4-component parameters */
+
#define R300_VPS_CMD_0 0
#define R300_VPS_ZERO_0 1
#define R300_VPS_ZERO_1 2
@@ -444,67 +467,72 @@ struct r300_hw_state {
struct r300_state_atom vpt; /* viewport (1D98) */
struct r300_state_atom vap_cntl;
+ struct r300_state_atom vap_index_offset; /* 0x208c r5xx only */
struct r300_state_atom vof; /* VAP output format register 0x2090 */
struct r300_state_atom vte; /* (20B0) */
- struct r300_state_atom unk2134; /* (2134) */
+ struct r300_state_atom vap_vf_max_vtx_indx; /* Maximum Vertex Indx Clamp (2134) */
struct r300_state_atom vap_cntl_status;
struct r300_state_atom vir[2]; /* vap input route (2150/21E0) */
struct r300_state_atom vic; /* vap input control (2180) */
- struct r300_state_atom unk21DC; /* (21DC) */
- struct r300_state_atom unk221C; /* (221C) */
+ struct r300_state_atom vap_psc_sgn_norm_cntl; /* Programmable Stream Control Signed Normalize Control (21DC) */
+ struct r300_state_atom vap_clip_cntl;
struct r300_state_atom vap_clip;
- struct r300_state_atom unk2288; /* (2288) */
+ struct r300_state_atom vap_pvs_vtx_timeout_reg; /* Vertex timeout register (2288) */
struct r300_state_atom pvs; /* pvs_cntl (22D0) */
struct r300_state_atom gb_enable; /* (4008) */
struct r300_state_atom gb_misc; /* Multisampling position shifts ? (4010) */
- struct r300_state_atom unk4200; /* (4200) */
- struct r300_state_atom unk4214; /* (4214) */
+ struct r300_state_atom ga_point_s0; /* S Texture Coordinate of Vertex 0 for Point texture stuffing (LLC) (4200) */
+ struct r300_state_atom ga_triangle_stipple; /* (4214) */
struct r300_state_atom ps; /* pointsize (421C) */
- struct r300_state_atom unk4230; /* (4230) */
+ struct r300_state_atom ga_point_minmax; /* (4230) */
struct r300_state_atom lcntl; /* line control */
- struct r300_state_atom unk4260; /* (4260) */
+ struct r300_state_atom ga_line_stipple; /* (4260) */
struct r300_state_atom shade;
struct r300_state_atom polygon_mode;
struct r300_state_atom fogp; /* fog parameters (4294) */
- struct r300_state_atom unk429C; /* (429C) */
+ struct r300_state_atom ga_soft_reset; /* (429C) */
struct r300_state_atom zbias_cntl;
struct r300_state_atom zbs; /* zbias (42A4) */
struct r300_state_atom occlusion_cntl;
struct r300_state_atom cul; /* cull cntl (42B8) */
- struct r300_state_atom unk42C0; /* (42C0) */
+ struct r300_state_atom su_depth_scale; /* (42C0) */
struct r300_state_atom rc; /* rs control (4300) */
struct r300_state_atom ri; /* rs interpolators (4310) */
struct r300_state_atom rr; /* rs route (4330) */
- struct r300_state_atom unk43A4; /* (43A4) */
- struct r300_state_atom unk43E8; /* (43E8) */
+ struct r300_state_atom sc_hyperz; /* (43A4) */
+ struct r300_state_atom sc_screendoor; /* (43E8) */
struct r300_state_atom fp; /* fragment program cntl + nodes (4600) */
struct r300_state_atom fpt; /* texi - (4620) */
- struct r300_state_atom unk46A4; /* (46A4) */
+ struct r300_state_atom us_out_fmt; /* (46A4) */
+ struct r300_state_atom r500fp; /* r500 fp instructions */
+ struct r300_state_atom r500fp_const; /* r500 fp constants */
struct r300_state_atom fpi[4]; /* fp instructions (46C0/47C0/48C0/49C0) */
struct r300_state_atom fogs; /* fog state (4BC0) */
struct r300_state_atom fogc; /* fog color (4BC8) */
struct r300_state_atom at; /* alpha test (4BD4) */
- struct r300_state_atom unk4BD8; /* (4BD8) */
+ struct r300_state_atom fg_depth_src; /* (4BD8) */
struct r300_state_atom fpp; /* 0x4C00 and following */
- struct r300_state_atom unk4E00; /* (4E00) */
+ struct r300_state_atom rb3d_cctl; /* (4E00) */
struct r300_state_atom bld; /* blending (4E04) */
struct r300_state_atom cmk; /* colormask (4E0C) */
struct r300_state_atom blend_color; /* constant blend color */
+ struct r300_state_atom rop; /* ropcntl */
struct r300_state_atom cb; /* colorbuffer (4E28) */
- struct r300_state_atom unk4E50; /* (4E50) */
- struct r300_state_atom unk4E88; /* (4E88) */
- struct r300_state_atom unk4EA0; /* (4E88) I saw it only written on RV350 hardware.. */
+ struct r300_state_atom rb3d_dither_ctl; /* (4E50) */
+ struct r300_state_atom rb3d_aaresolve_ctl; /* (4E88) */
+ struct r300_state_atom rb3d_discard_src_pixel_lte_threshold; /* (4E88) I saw it only written on RV350 hardware.. */
struct r300_state_atom zs; /* zstencil control (4F00) */
struct r300_state_atom zstencil_format;
struct r300_state_atom zb; /* z buffer (4F20) */
- struct r300_state_atom unk4F28; /* (4F28) */
+ struct r300_state_atom zb_depthclearvalue; /* (4F28) */
struct r300_state_atom unk4F30; /* (4F30) */
- struct r300_state_atom unk4F44; /* (4F44) */
- struct r300_state_atom unk4F54; /* (4F54) */
+ struct r300_state_atom zb_hiz_offset; /* (4F44) */
+ struct r300_state_atom zb_hiz_pitch; /* (4F54) */
struct r300_state_atom vpi; /* vp instructions */
struct r300_state_atom vpp; /* vp parameters */
struct r300_state_atom vps; /* vertex point size (?) */
+ struct r300_state_atom vpucp[6]; /* vp user clip plane - 6 */
/* 8 texture units */
/* the state is grouped by function and not by
texture unit. This makes single unit updates
@@ -546,9 +574,7 @@ struct r300_depthbuffer_state {
};
struct r300_stencilbuffer_state {
- GLuint clear;
GLboolean hw_stencil;
-
};
/* Vertex shader state */
@@ -596,6 +622,7 @@ extern int hw_tcl_on;
struct r300_vertex_program_key {
GLuint InputsRead;
GLuint OutputsWritten;
+ GLuint OutputsAdded;
};
struct r300_vertex_program {
@@ -627,82 +654,75 @@ struct r300_vertex_program_cont {
#define PFS_NUM_TEMP_REGS 32
#define PFS_NUM_CONST_REGS 16
-/* Mapping Mesa registers to R300 temporaries */
-struct reg_acc {
- int reg; /* Assigned hw temp */
- unsigned int refcount; /* Number of uses by mesa program */
-};
+struct r300_pfs_compile_state;
+
/**
- * Describe the current lifetime information for an R300 temporary
+ * Stores state that influences the compilation of a fragment program.
*/
-struct reg_lifetime {
- /* Index of the first slot where this register is free in the sense
- that it can be used as a new destination register.
- This is -1 if the register has been assigned to a Mesa register
- and the last access to the register has not yet been emitted */
- int free;
-
- /* Index of the first slot where this register is currently reserved.
- This is used to stop e.g. a scalar operation from being moved
- before the allocation time of a register that was first allocated
- for a vector operation. */
- int reserved;
-
- /* Index of the first slot in which the register can be used as a
- source without losing the value that is written by the last
- emitted instruction that writes to the register */
- int vector_valid;
- int scalar_valid;
-
- /* Index to the slot where the register was last read.
- This is also the first slot in which the register may be written again */
- int vector_lastread;
- int scalar_lastread;
+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.
+ */
+ GLuint depth_texture_mode : 2;
+
+ /**
+ * If the sampler is used as a shadow sampler,
+ * this field is (texture_compare_func - GL_NEVER).
+ * [e.g. if compare function is GL_LEQUAL, this field is 3]
+ *
+ * Otherwise, this field is 0.
+ */
+ GLuint texture_compare_func : 3;
+ } unit[16];
};
-/**
- * Store usage information about an ALU instruction slot during the
- * compilation of a fragment program.
- */
-#define SLOT_SRC_VECTOR (1<<0)
-#define SLOT_SRC_SCALAR (1<<3)
-#define SLOT_SRC_BOTH (SLOT_SRC_VECTOR | SLOT_SRC_SCALAR)
-#define SLOT_OP_VECTOR (1<<16)
-#define SLOT_OP_SCALAR (1<<17)
-#define SLOT_OP_BOTH (SLOT_OP_VECTOR | SLOT_OP_SCALAR)
-
-struct r300_pfs_compile_slot {
- /* Bitmask indicating which parts of the slot are used, using SLOT_ constants
- defined above */
- unsigned int used;
-
- /* Selected sources */
- int vsrc[3];
- int ssrc[3];
+
+struct r300_fragment_program_node {
+ int tex_offset; /**< first tex instruction */
+ int tex_end; /**< last tex instruction, relative to tex_offset */
+ int alu_offset; /**< first ALU instruction */
+ int alu_end; /**< last ALU instruction, relative to alu_offset */
+ int flags;
};
/**
- * Store information during compilation of fragment programs.
+ * Stores an R300 fragment program in its compiled-to-hardware form.
*/
-struct r300_pfs_compile_state {
- int nrslots; /* number of ALU slots used so far */
+struct r300_fragment_program_code {
+ struct {
+ int length; /**< total # of texture instructions used */
+ GLuint inst[PFS_MAX_TEX_INST];
+ } tex;
- /* Track which (parts of) slots are already filled with instructions */
- struct r300_pfs_compile_slot slot[PFS_MAX_ALU_INST];
+ struct {
+ int length; /**< total # of ALU instructions used */
+ struct {
+ GLuint inst0;
+ GLuint inst1;
+ GLuint inst2;
+ GLuint inst3;
+ } inst[PFS_MAX_ALU_INST];
+ } alu;
- /* Track the validity of R300 temporaries */
- struct reg_lifetime hwtemps[PFS_NUM_TEMP_REGS];
+ struct r300_fragment_program_node node[4];
+ int cur_node;
+ int first_node_has_tex;
- /* Used to map Mesa's inputs/temps onto hardware temps */
- int temp_in_use;
- struct reg_acc temps[PFS_NUM_TEMP_REGS];
- struct reg_acc inputs[32]; /* don't actually need 32... */
+ /**
+ * Remember which program register a given hardware constant
+ * belongs to.
+ */
+ struct prog_src_register constant[PFS_NUM_CONST_REGS];
+ int const_nr;
- /* Track usage of hardware temps, for register allocation,
- * indirection detection, etc. */
- GLuint used_in_node;
- GLuint dest_in_node;
+ int max_temp_idx;
};
/**
@@ -712,51 +732,75 @@ struct r300_pfs_compile_state {
struct r300_fragment_program {
struct gl_fragment_program mesa_program;
- GLcontext *ctx;
GLboolean translated;
GLboolean error;
- struct r300_pfs_compile_state *cs;
- struct {
- int length;
- GLuint inst[PFS_MAX_TEX_INST];
- } tex;
+ struct r300_fragment_program_external_state state;
+ struct r300_fragment_program_code code;
- struct {
- struct {
- GLuint inst0;
- GLuint inst1;
- GLuint inst2;
- GLuint inst3;
- } inst[PFS_MAX_ALU_INST];
- } alu;
+ GLboolean WritesDepth;
+ GLuint optimization;
+};
+
+struct r500_pfs_compile_state;
+struct r500_fragment_program_external_state {
struct {
- int tex_offset;
- int tex_end;
- int alu_offset;
- int alu_end;
- int flags;
- } node[4];
- int cur_node;
- int first_node_has_tex;
+ /**
+ * 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.
+ */
+ GLuint depth_texture_mode : 2;
+
+ /**
+ * If the sampler is used as a shadow sampler,
+ * this field is (texture_compare_func - GL_NEVER).
+ * [e.g. if compare function is GL_LEQUAL, this field is 3]
+ *
+ * Otherwise, this field is 0.
+ */
+ GLuint texture_compare_func : 3;
+ } unit[16];
+};
- int alu_offset;
- int alu_end;
- int tex_offset;
- int tex_end;
-
- /* Hardware constants.
- * Contains a pointer to the value. The destination of the pointer
- * is supposed to be updated when GL state changes.
- * Typically, this is either a pointer into
- * gl_program_parameter_list::ParameterValues, or a pointer to a
- * global constant (e.g. for sin/cos-approximation)
+struct r500_fragment_program_code {
+ struct {
+ GLuint inst0;
+ GLuint inst1;
+ GLuint inst2;
+ GLuint inst3;
+ GLuint inst4;
+ GLuint inst5;
+ } inst[512];
+
+ int inst_offset;
+ int inst_end;
+
+ /**
+ * Remember which program register a given hardware constant
+ * belongs to.
*/
- const GLfloat *constant[PFS_NUM_CONST_REGS];
+ struct prog_src_register constant[PFS_NUM_CONST_REGS];
int const_nr;
int max_temp_idx;
+};
+
+struct r500_fragment_program {
+ struct gl_fragment_program mesa_program;
+
+ GLcontext *ctx;
+ GLboolean translated;
+ GLboolean error;
+
+ struct r500_fragment_program_external_state state;
+ struct r500_fragment_program_code code;
+
+ GLboolean writes_depth;
GLuint optimization;
};
@@ -772,7 +816,6 @@ struct r300_state {
struct r300_texture_state texture;
int sw_tcl_inputs[VERT_ATTRIB_MAX];
struct r300_vertex_shader_state vertex_shader;
- struct r300_pfs_compile_state pfs_compile;
struct r300_dma_region aos[R300_MAX_AOS_ARRAYS];
int aos_count;
@@ -795,7 +838,7 @@ struct r300_state {
*/
struct r300_swtcl_info {
GLuint RenderIndex;
-
+
/**
* Size of a hardware vertex. This is calculated when \c ::vertex_attrs is
* installed in the Mesa state vector.