mesa: remove a bunch of gl_renderbuffer fields
[mesa.git] / src / mesa / drivers / dri / r300 / r300_context.h
index 026c33c67cb209203d691e128982f55826409924..518d5cdbf4f5908a93ecc61091d9e81e411f70a0 100644 (file)
@@ -44,28 +44,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "main/mtypes.h"
 #include "shader/prog_instruction.h"
+#include "compiler/radeon_code.h"
 
 struct r300_context;
 typedef struct r300_context r300ContextRec;
 typedef struct r300_context *r300ContextPtr;
 
 
-/* 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;\
-               } \
-       }
-
 #include "r300_vertprog.h"
 
 
@@ -249,6 +234,10 @@ typedef struct r300_context *r300ContextPtr;
 #define R300_ZS_CNTL_2         3
 #define R300_ZS_CMDSIZE                4
 
+#define R300_ZSB_CMD_0         0
+#define R300_ZSB_CNTL_0                1
+#define R300_ZSB_CMDSIZE       2
+
 #define R300_ZB_CMD_0          0
 #define R300_ZB_OFFSET         1
 #define R300_ZB_PITCH          2
@@ -289,6 +278,12 @@ typedef struct r300_context *r300ContextPtr;
 #define R300_TEX_CMDSIZE       (MAX_TEXTURE_UNITS+1)
 */
 
+#define R300_QUERYOBJ_CMD_0  0
+#define R300_QUERYOBJ_DATA_0 1
+#define R300_QUERYOBJ_CMD_1  2
+#define R300_QUERYOBJ_DATA_1  3
+#define R300_QUERYOBJ_CMDSIZE  4
+
 /**
  * Cache for hardware register state.
  */
@@ -352,6 +347,7 @@ struct r300_hw_state {
        struct radeon_state_atom rb3d_aaresolve_ctl;    /* (4E88) */
        struct radeon_state_atom rb3d_discard_src_pixel_lte_threshold;  /* (4E88) I saw it only written on RV350 hardware..  */
        struct radeon_state_atom zs;    /* zstencil control (4F00) */
+       struct radeon_state_atom zsb;   /* zstencil bf */
        struct radeon_state_atom zstencil_format;
        struct radeon_state_atom zb;    /* z buffer (4F20) */
        struct radeon_state_atom zb_depthclearvalue;    /* (4F28) */
@@ -359,6 +355,7 @@ struct r300_hw_state {
        struct radeon_state_atom zb_hiz_offset; /* (4F44) */
        struct radeon_state_atom zb_hiz_pitch;  /* (4F54) */
 
+       struct radeon_state_atom vap_flush;
        struct radeon_state_atom vpi;   /* vp instructions */
        struct radeon_state_atom vpp;   /* vp parameters */
        struct radeon_state_atom vps;   /* vertex point size (?) */
@@ -379,7 +376,6 @@ struct r300_hw_state {
                struct radeon_state_atom border_color;
        } tex;
        struct radeon_state_atom txe;   /* tex enable (4104) */
-
        radeonTexObj *textures[R300_MAX_TEXTURE_UNITS];
 };
 
@@ -389,185 +385,67 @@ struct r300_hw_state {
 
 /* Vertex shader state */
 
-/* Perhaps more if we store programs in vmem? */
-/* drm_r300_cmd_header_t->vpu->count is unsigned char */
-#define VSF_MAX_FRAGMENT_LENGTH (255*4)
-
-/* Can be tested with colormat currently. */
-#define VSF_MAX_FRAGMENT_TEMPS (14)
-
-#define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
-#define STATE_R300_TEXRECT_FACTOR (STATE_INTERNAL_DRIVER+1)
-
 #define COLOR_IS_RGBA
 #define TAG(x) r300##x
 #include "tnl_dd/t_dd_vertex.h"
 #undef TAG
 
+struct r300_vertex_program_key {
+       GLbitfield FpReads;
+       GLuint FogAttr;
+       GLuint WPosAttr;
+};
+
 struct r300_vertex_program {
+       struct gl_vertex_program *Base;
        struct r300_vertex_program *next;
 
-       struct r300_vertex_program_key {
-               GLuint InputsRead;
-               GLuint OutputsWritten;
-               GLuint OutputsAdded;
-       } key;
-       
-       struct r300_vertex_shader_hw_code {
-               int length;
-               union {
-                       GLuint d[VSF_MAX_FRAGMENT_LENGTH];
-                       float f[VSF_MAX_FRAGMENT_LENGTH];
-               } body;
-       } hw_code;
-
-       GLboolean translated;
-       GLboolean error;
+       struct r300_vertex_program_key key;
+       struct r300_vertex_program_code code;
 
-       int pos_end;
-       int num_temporaries;    /* Number of temp vars used by program */
-       int wpos_idx;
-       int inputs[VERT_ATTRIB_MAX];
-       int outputs[VERT_RESULT_MAX];
+       GLboolean error;
 };
 
 struct r300_vertex_program_cont {
-       struct gl_vertex_program mesa_program;  /* Must be first */
-       struct r300_vertex_program *progs;
-};
-
-#define R300_PFS_MAX_ALU_INST  64
-#define R300_PFS_MAX_TEX_INST  32
-#define R300_PFS_MAX_TEX_INDIRECT 4
-#define R300_PFS_NUM_TEMP_REGS 32
-#define R300_PFS_NUM_CONST_REGS        32
-
-#define R500_PFS_MAX_INST 512
-#define R500_PFS_NUM_TEMP_REGS 128
-#define R500_PFS_NUM_CONST_REGS 256
-
-struct r300_pfs_compile_state;
-struct r500_pfs_compile_state;
-
-/**
- * Stores state that influences the compilation of a fragment program.
- */
-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];
-};
-
-
-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;
-};
-
-/**
- * Stores an R300 fragment program in its compiled-to-hardware form.
- */
-struct r300_fragment_program_code {
-       struct {
-               int length; /**< total # of texture instructions used */
-               GLuint inst[R300_PFS_MAX_TEX_INST];
-       } tex;
-
-       struct {
-               int length; /**< total # of ALU instructions used */
-               struct {
-                       GLuint inst0;
-                       GLuint inst1;
-                       GLuint inst2;
-                       GLuint inst3;
-               } inst[R300_PFS_MAX_ALU_INST];
-       } alu;
-
-       struct r300_fragment_program_node node[4];
-       int cur_node;
-       int first_node_has_tex;
-
-       /**
-        * Remember which program register a given hardware constant
-        * belongs to.
+       /* This is the unmodified vertex program mesa provided us with.
+        * We need to keep it unchanged because we may need to create another
+        * hw specific vertex program based on this.
         */
-       struct prog_src_register constant[R300_PFS_NUM_CONST_REGS];
-       int const_nr;
-
-       int max_temp_idx;
+       struct gl_vertex_program mesa_program;
+       /* This is the list of hw specific vertex programs derived from mesa_program */
+       struct r300_vertex_program *progs;
 };
 
 
-struct r500_fragment_program_code {
-       struct {
-               GLuint inst0;
-               GLuint inst1;
-               GLuint inst2;
-               GLuint inst3;
-               GLuint inst4;
-               GLuint inst5;
-       } inst[R500_PFS_MAX_INST];
-
-       int inst_offset;
-       int inst_end;
-
-       /**
-        * Remember which program register a given hardware constant
-        * belongs to.
-        */
-       struct prog_src_register constant[R500_PFS_NUM_CONST_REGS];
-       int const_nr;
-
-       int max_temp_idx;
-};
-
 /**
 * Store everything about a fragment program that is needed
 * to render with that program.
 */
 struct r300_fragment_program {
-       struct gl_fragment_program Base;
-
-       GLboolean translated;
        GLboolean error;
-
+       struct r300_fragment_program *next;
        struct r300_fragment_program_external_state state;
-       union rX00_fragment_program_code {
-               struct r300_fragment_program_code r300;
-               struct r500_fragment_program_code r500;
-       } code;
 
-       GLboolean writes_depth;
-       GLuint optimization;
+       struct rX00_fragment_program_code code;
+       GLbitfield InputsRead;
+
+       /* attribute that we are sending the WPOS in */
+       gl_frag_attrib wpos_attr;
+       /* attribute that we are sending the fog coordinate in */
+       gl_frag_attrib fog_attr;
 };
 
-struct r300_fragment_program_compiler {
-       r300ContextPtr r300;
-       struct r300_fragment_program *fp;
-       union rX00_fragment_program_code *code;
-       struct gl_program *program;
+struct r300_fragment_program_cont {
+       /* This is the unmodified fragment program mesa provided us with.
+        * We need to keep it unchanged because we may need to create another
+        * hw specific fragment program based on this.
+        */
+       struct gl_fragment_program Base;
+       /* This is the list of hw specific fragment programs derived from Base */
+       struct r300_fragment_program *progs;
 };
 
+
 #define R300_MAX_AOS_ARRAYS            16
 
 
@@ -588,8 +466,6 @@ struct r300_swtcl_info {
 struct r300_vtable {
        void (* SetupRSUnit)(GLcontext *ctx);
        void (* SetupFragmentShaderTextures)(GLcontext *ctx, int *tmu_mappings);
-       GLboolean (* BuildFragmentProgramHwCode)(struct r300_fragment_program_compiler *compiler);
-       void (* FragmentProgramDump)(union rX00_fragment_program_code *code);
        void (* SetupPixelShader)(GLcontext *ctx);
 };
 
@@ -597,11 +473,12 @@ struct r300_vertex_buffer {
        struct vertex_attribute {
                /* generic */
                GLubyte element;
-               GLvoid *data;
-               GLboolean free_needed;
                GLuint stride;
                GLuint dwords;
                GLubyte size; /* number of components */
+               GLboolean is_named_bo;
+               struct radeon_bo *bo;
+               GLint bo_offset;
 
                /* hw specific */
                uint32_t data_type:4;
@@ -616,12 +493,14 @@ struct r300_vertex_buffer {
 };
 
 struct r300_index_buffer {
-       GLvoid *ptr;
+       struct radeon_bo *bo;
+       int bo_offset;
+
        GLboolean is_32bit;
-       GLboolean free_needed;
        GLuint count;
 };
 
+
 /**
  * \brief R300 context structure.
  */
@@ -633,6 +512,7 @@ struct r300_context {
        struct r300_hw_state hw;
 
        struct r300_vertex_program *selected_vp;
+       struct r300_fragment_program *selected_fp;
 
        /* Vertex buffers
         */
@@ -646,11 +526,10 @@ struct r300_context {
                uint32_t s3tc_force_disabled:1;
                uint32_t stencil_two_side_disabled:1;
        } options;
-       
+
        struct r300_swtcl_info swtcl;
        struct r300_vertex_buffer vbuf;
        struct r300_index_buffer ind_buf;
-       GLboolean vap_flush_needed;
 
        uint32_t fallback;
 
@@ -664,11 +543,7 @@ extern GLboolean r300CreateContext(const __GLcontextModes * glVisual,
                                   __DRIcontextPrivate * driContextPriv,
                                   void *sharedContextPrivate);
 
-extern void r300SelectVertexShader(r300ContextPtr r300);
 extern void r300InitShaderFuncs(struct dd_function_table *functions);
-extern int r300VertexProgUpdateParams(GLcontext * ctx,
-                                     struct r300_vertex_program_cont *vp,
-                                     float *dst);
 
 extern void r300InitShaderFunctions(r300ContextPtr r300);