#include "radeon_lock.h"
#include "mm.h"
+/* Checkpoint.. for convenience */
+#define CPT { fprintf(stderr, "%s:%s line %d\n", __FILE__, __FUNCTION__, __LINE__); }
+/* From http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
+ I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble
+ with other compilers ... GLUE!
+*/
+#define WARN_ONCE(a, ...) { \
+ static int warn##__LINE__=1; \
+ if(warn##__LINE__){ \
+ fprintf(stderr, "*********************************WARN_ONCE*********************************\n"); \
+ fprintf(stderr, "File %s function %s line %d\n", \
+ __FILE__, __FUNCTION__, __LINE__); \
+ fprintf(stderr, a, ## __VA_ARGS__);\
+ fprintf(stderr, "***************************************************************************\n"); \
+ warn##__LINE__=0;\
+ } \
+ }
typedef GLuint uint32_t;
typedef GLubyte uint8_t;
- /* We should probably change types within vertex_shader
+ /* We should probably change types within vertex_shader
and pixel_shader structure later on */
#define CARD32 GLuint
#include "vertex_shader.h"
/* Texture related */
-#define TEX_0 0x1
-#define TEX_1 0x2
-#define TEX_2 0x4
-#define TEX_3 0x8
-#define TEX_4 0x10
-#define TEX_5 0x20
-#define TEX_6 0x40
-#define TEX_7 0x80
-#define TEX_ALL 0xff
-
typedef struct r300_tex_obj r300TexObj, *r300TexObjPtr;
/* Texture object in locally shared texture space.
/* hardware register values */
/* Note that R200 has 8 registers per texture and R300 only 7 */
- GLuint filter;
+ GLuint filter;
GLuint pitch; /* one of the unknown registers.. unknown 1 ?*/
GLuint size; /* npot only */
GLuint format;
GLuint offset; /* Image location in texmem.
All cube faces follow. */
GLuint unknown4;
- GLuint unknown5;
+ GLuint unknown5;
/* end hardware registers */
-
- /* registers computed by r200 code - keep them here to
+
+ /* registers computed by r200 code - keep them here to
compare against what is actually written.
-
+
to be removed later.. */
GLuint pp_border_color;
GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
GLuint format_x;
-
-
+
+
GLboolean border_fallback;
};
#define R300_PS_POINTSIZE 1
#define R300_PS_CMDSIZE 2
+#define R300_ZBS_CMD_0 0
+#define R300_ZBS_T_FACTOR 1
+#define R300_ZBS_T_CONSTANT 2
+#define R300_ZBS_W_FACTOR 3
+#define R300_ZBS_W_CONSTANT 4
+#define R300_ZBS_CMDSIZE 5
+
#define R300_CUL_CMD_0 0
#define R300_CUL_CULL 1
#define R300_CUL_CMDSIZE 2
#define R300_AT_CMD_0 0
#define R300_AT_ALPHA_TEST 1
-#define R300_AT_CMDSIZE 2
+#define R300_AT_UNKNOWN 2
+#define R300_AT_CMDSIZE 3
#define R300_BLD_CMD_0 0
#define R300_BLD_CBLEND 1
/* the layout is common for all fields inside tex */
#define R300_TEX_CMD_0 0
#define R300_TEX_VALUE_0 1
-/* We don't really use this, instead specify mtu+1 dynamically
+/* We don't really use this, instead specify mtu+1 dynamically
#define R300_TEX_CMDSIZE (MAX_TEXTURE_UNITS+1)
*/
struct r300_state_atom unk4214; /* (4214) */
struct r300_state_atom ps; /* pointsize (421C) */
struct r300_state_atom unk4230; /* (4230) */
+ struct r300_state_atom lcntl; /* line control */
+#ifdef EXP_C
+ struct r300_state_atom lsf; /* line stipple factor */
+#endif
+ struct r300_state_atom dummy[4];
struct r300_state_atom unk4260; /* (4260) */
struct r300_state_atom unk4274; /* (4274) */
struct r300_state_atom unk4288; /* (4288) */
- struct r300_state_atom unk42A0; /* (42A0) */
+ struct r300_state_atom unk42A0; /* (42A0) */
+ struct r300_state_atom zbs; /* zbias (42A4) */
struct r300_state_atom unk42B4; /* (42B4) */
struct r300_state_atom cul; /* cull cntl (42B8) */
struct r300_state_atom unk42C0; /* (42C0) */
struct r300_state_atom ri; /* rs interpolators (4310) */
struct r300_state_atom rr; /* rs route (4330) */
struct r300_state_atom unk43A4; /* (43A4) */
+#ifdef EXP_C
+ struct r300_state_atom lsp; /* line stipple pattern */
+#endif
struct r300_state_atom unk43E8; /* (43E8) */
struct r300_state_atom fp; /* fragment program cntl + nodes (4600) */
struct r300_state_atom fpt; /* texi - (4620) */
struct r300_state_atom vps; /* vertex point size (?) */
/* 8 texture units */
- /* the state is grouped by function and not by
+ /* the state is grouped by function and not by
texture unit. This makes single unit updates
- really awkward - we are much better off
+ really awkward - we are much better off
updating the whole thing at once */
struct {
struct r300_state_atom filter;
struct r300_state_atom format;
struct r300_state_atom offset;
struct r300_state_atom unknown4;
- struct r300_state_atom unknown5;
struct r300_state_atom border_color;
} tex;
struct r300_state_atom txe; /* tex enable (4104) */
/**
* State cache
*/
-
+
struct r300_depthbuffer_state {
GLfloat scale;
};
struct r300_vap_reg_state {
/* input register assigments */
int i_coords;
+ int i_normal;
int i_color[2];
+ int i_fog;
int i_tex[R300_MAX_TEXTURE_UNITS];
+ int i_index;
+ int i_pointsize;
};
/* Vertex shader state */
struct r300_vertex_shader_fragment {
int length;
union {
- GLuint d[VSF_MAX_FRAGMENT_LENGTH];
+ GLuint d[VSF_MAX_FRAGMENT_LENGTH];
float f[VSF_MAX_FRAGMENT_LENGTH];
VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH/4];
} body;
but easier to program */
struct r300_vertex_shader_fragment matrix[3];
struct r300_vertex_shader_fragment vector[2];
-
+
struct r300_vertex_shader_fragment unknown1;
struct r300_vertex_shader_fragment unknown2;
-
+
int program_start;
int unknown_ptr1; /* pointer within program space */
int program_end;
-
+
int param_offset;
int param_count;
-
+
int unknown_ptr2; /* pointer within program space */
int unknown_ptr3; /* pointer within program space */
};
+
+/* r300_vertex_shader_state and r300_vertex_program should probably be merged together someday.
+ * Keeping them them seperate for now should ensure fixed pipeline keeps functioning properly.
+ */
+struct r300_vertex_program {
+ struct vertex_program mesa_program; /* Must be first */
+ int translated;
+
+ struct r300_vertex_shader_fragment program;
+ struct r300_vertex_shader_fragment params;
+
+ int t2rs;
+ unsigned long num_temporaries; /* Number of temp vars used by program */
+ int inputs[VERT_ATTRIB_MAX];
+};
/* 64 appears to be the maximum */
#define PSF_MAX_PROGRAM_LENGTH 64
int length;
GLuint inst[PSF_MAX_PROGRAM_LENGTH];
} tex;
-
+
/* ALU intructions (logic and integer) */
struct {
int length;
GLuint inst3;
} inst[PSF_MAX_PROGRAM_LENGTH];
} alu;
-
+
/* node information */
/* nodes are used to synchronize ALU and TEX streams */
/* There could be up to 4 nodes each consisting of
/* the last node of a program should always be node3 */
struct {
int tex_offset;
- int tex_end;
+ int tex_end;
int alu_offset;
int alu_end;
} node[4];
-
+
int active_nodes; /* must be between 1 and 4, inclusive */
int first_node_has_tex; /* other nodes always have it */
-
+
int temp_register_count; /* magic value goes into PFS_CNTL_1 */
-
+
/* entire program */
int tex_offset;
int tex_end;
int alu_offset;
int alu_end;
-
+
};
-
- #define MAX_PIXEL_SHADER_PARAMS 32
+
+#define MAX_PIXEL_SHADER_PARAMS 32
struct r300_pixel_shader_state {
struct r300_pixel_shader_program program;
-
- /* parameters */
+
+ /* parameters */
int param_length; /* to limit the number of unnecessary writes */
struct {
float x;
float w;
} param[MAX_PIXEL_SHADER_PARAMS];
};
-
+
/* 8 is somewhat bogus... it is probably something like 24 */
#define R300_MAX_AOS_ARRAYS 8
+#define AOS_FORMAT_FLOAT 1
+#define AOS_FORMAT_UBYTE 2
+#define AOS_FORMAT_FLOAT_COLOR 3
+
+#define REG_COORDS 0
+#define REG_COLOR0 1
+#define REG_TEX0 2
+
struct r300_aos_rec {
GLuint offset;
int element_size; /* in dwords */
int stride; /* distance between elements, in dwords */
-
- #define AOS_FORMAT_FLOAT 1
- #define AOS_FORMAT_UBYTE 2
- #define AOS_FORMAT_FLOAT_COLOR 3
- int format;
-
+
+ int format;
+
int ncomponents; /* number of components - between 1 and 4, inclusive */
- /* just guesses */
- #define REG_COORDS 0
- #define REG_COLOR0 1
- #define REG_TEX0 2
int reg; /* which register they are assigned to. */
-
+
};
struct r300_state {
struct r300_pixel_shader_state pixel_shader;
struct r300_aos_rec aos[R300_MAX_AOS_ARRAYS];
int aos_count;
-
+ GLuint render_inputs; /* actual render inputs that R300 was configured for.
+ They are the same as tnl->render_inputs for fixed pipeline */
+
int hw_stencil;
};
struct r300_hw_state hw;
struct r300_cmdbuf cmdbuf;
struct r300_state state;
-
- /* Vertex buffers */
- int elt_count; /* size of the buffer for vertices */
- int attrib_count; /* size of the buffer for vertex attributes.. Somehow it can be different ? */
-
/* Vertex buffers
*/
- #if 0 /* we'll need it later, but not now */
- struct r300_ioctl ioctl;
- #endif
struct r300_dma dma;
GLboolean save_on_next_unlock;
GLuint TexGenInputs;
GLuint TexGenCompSel;
GLmatrix tmpmat;
+
+ struct r300_vertex_program *current_vp;
};
#define R300_CONTEXT(ctx) ((r300ContextPtr)(ctx->DriverCtx))
__DRIcontextPrivate * driContextPriv,
void *sharedContextPrivate);
+extern void r300InitVertexProgFuncs(struct dd_function_table *functions);
+extern void r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program *vp);
+
#endif /* __R300_CONTEXT_H__ */