r300: refactor PVS code and constants emission
[mesa.git] / src / mesa / drivers / dri / r300 / r300_cmdbuf.h
index f4cc5d3bb120d92b353ea8710fdab1ee5a73414c..0e68da928ed51122ddb81487633b3e02b375fb73 100644 (file)
@@ -37,101 +37,33 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define __R300_CMDBUF_H__
 
 #include "r300_context.h"
-#include "radeon_cs.h"
 
-extern int r300FlushCmdBufLocked(r300ContextPtr r300, const char *caller);
-extern int r300FlushCmdBuf(r300ContextPtr r300, const char *caller);
-
-extern void r300EmitState(r300ContextPtr r300);
-
-extern void r300InitCmdBuf(r300ContextPtr r300);
-extern void r300DestroyCmdBuf(r300ContextPtr r300);
-extern void r300EnsureCmdBufSpace(r300ContextPtr r300, int dwords, const char *caller);
-
-void r300BeginBatch(r300ContextPtr r300,
-                   int n,
-                   int dostate,
-                    const char *file,
-                    const char *function,
-                    int line);
-
-/**
- * Every function writing to the command buffer needs to declare this
- * to get the necessary local variables.
- */
-#define BATCH_LOCALS(r300) \
-       const r300ContextPtr b_l_r300 = r300
-
-/**
- * Prepare writing n dwords to the command buffer,
- * including producing any necessary state emits on buffer wraparound.
- */
-#define BEGIN_BATCH(n) r300BeginBatch(b_l_r300, n, 1, __FILE__, __FUNCTION__, __LINE__)
-
-/**
- * Same as BEGIN_BATCH, but do not cause automatic state emits.
- */
-#define BEGIN_BATCH_NO_AUTOSTATE(n) r300BeginBatch(b_l_r300, n, 0, __FILE__, __FUNCTION__, __LINE__)
-
-/**
- * Write one dword to the command buffer.
- */
-#define OUT_BATCH(data) \
-       do { \
-        radeon_cs_write_dword(b_l_r300->cmdbuf.cs, data);\
-       } while(0)
-
-/**
- * Write a relocated dword to the command buffer.
- */
-#define OUT_BATCH_RELOC(data, bo, offset, rd, wd, flags) \
-       do { \
-        if (offset) {\
-            fprintf(stderr, "(%s:%s:%d) offset : %d\n",\
-            __FILE__, __FUNCTION__, __LINE__, offset);\
-        }\
-        radeon_cs_write_dword(b_l_r300->cmdbuf.cs, offset);\
-        radeon_cs_write_reloc(b_l_r300->cmdbuf.cs, \
-                              bo, \
-                              rd, \
-                              wd, \
-                              flags);\
-       } while(0)
-
-/**
- * Write n dwords from ptr to the command buffer.
- */
-#define OUT_BATCH_TABLE(ptr,n) \
-       do { \
-               int _i; \
-        for (_i=0; _i < n; _i++) {\
-            radeon_cs_write_dword(b_l_r300->cmdbuf.cs, ptr[_i]);\
-        }\
-       } while(0)
-
-/**
- * Finish writing dwords to the command buffer.
- * The number of (direct or indirect) OUT_BATCH calls between the previous
- * BEGIN_BATCH and END_BATCH must match the number specified at BEGIN_BATCH time.
- */
-#define END_BATCH() \
-       do { \
-        radeon_cs_end(b_l_r300->cmdbuf.cs, __FILE__, __FUNCTION__, __LINE__);\
-       } while(0)
-
-/**
- * After the last END_BATCH() of rendering, this indicates that flushing
- * the command buffer now is okay.
- */
-#define COMMIT_BATCH() \
-       do { \
-       } while(0)
-
-void emit_vpu(GLcontext *ctx, struct radeon_state_atom * atom);
-int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom);
-
-void emit_r500fp(GLcontext *ctx, struct radeon_state_atom * atom);
-int check_r500fp(GLcontext *ctx, struct radeon_state_atom *atom);
-int check_r500fp_const(GLcontext *ctx, struct radeon_state_atom *atom);
-
-#endif                         /* __R300_CMDBUF_H__ */
+#define CACHE_FLUSH_BUFSZ      (4*2)
+#define PRE_EMIT_STATE_BUFSZ   (2+2)
+#define AOS_BUFSZ(nr)          (3+(nr >>1)*3 + (nr&1)*2 + (nr*2))
+#define FIREAOS_BUFSZ          (3)
+#define SCISSORS_BUFSZ         (3)
+
+void r300InitCmdBuf(r300ContextPtr r300);
+void r300_emit_scissor(GLcontext *ctx);
+
+void r300_emit_vpu(struct r300_context *ctx,
+                   uint32_t *data,
+                   unsigned len,
+                   uint32_t addr);
+
+void r500_emit_fp(struct r300_context *r300,
+                  uint32_t *data,
+                  unsigned len,
+                  uint32_t addr,
+                  unsigned type,
+                  unsigned clamp);
+
+void r300_emit_cb_setup(struct r300_context *r300,
+                        struct radeon_bo *bo,
+                        uint32_t offset,
+                        GLuint format,
+                        unsigned cpp,
+                        unsigned pitch);
+
+#endif /* __R300_CMDBUF_H__ */