gallium: enable GL_AMD_depth_clamp_separate on r600, radeonsi
[mesa.git] / src / gallium / drivers / r300 / r300_cs.h
index c194d6a1b08c3ebff2c61b5e8d78efe58f2f7c8d..560b77533cf6be6540be17db5ba8888eedd0a2de 100644 (file)
 
 #include "r300_reg.h"
 #include "r300_context.h"
-#include "r300_winsys.h"
 
 /* Yes, I know macros are ugly. However, they are much prettier than the code
  * that they neatly hide away, and don't have the cost of function setup,so
  * we're going to use them. */
 
-#ifdef DEBUG
-#define CS_DEBUG(x) x
-#else
-#define CS_DEBUG(x)
-#endif
-
 /**
  * Command submission setup.
  */
 
 #define CS_LOCALS(context) \
-    struct r300_winsys_cs *cs_copy = (context)->cs; \
-    struct r300_winsys_screen *cs_winsys = (context)->rws; \
+    struct radeon_cmdbuf *cs_copy = (context)->cs; \
+    struct radeon_winsys *cs_winsys = (context)->rws; \
     int cs_count = 0; (void) cs_count; (void) cs_winsys;
 
+#ifdef DEBUG
+
 #define BEGIN_CS(size) do { \
-    assert(size <= (cs_copy->ndw - cs_copy->cdw)); \
-    CS_DEBUG(cs_count = size;) \
+    assert(size <= (cs_copy->current.max_dw - cs_copy->current.cdw)); \
+    cs_count = size; \
 } while (0)
 
-#ifdef DEBUG
 #define END_CS do { \
     if (cs_count != 0) \
         debug_printf("r300: Warning: cs_count off by %d at (%s, %s:%i)\n", \
                      cs_count, __FUNCTION__, __FILE__, __LINE__); \
     cs_count = 0; \
 } while (0)
+
+#define CS_USED_DW(x) cs_count -= (x)
+
 #else
+
+#define BEGIN_CS(size)
 #define END_CS
-#endif
+#define CS_USED_DW(x)
 
+#endif
 
 /**
  * Writing pure DWORDs.
  */
 
 #define OUT_CS(value) do { \
-    cs_copy->ptr[cs_copy->cdw++] = (value); \
-    CS_DEBUG(cs_count--;) \
+    cs_copy->current.buf[cs_copy->current.cdw++] = (value); \
+    CS_USED_DW(1); \
 } while (0)
 
 #define OUT_CS_32F(value) \
     OUT_CS(CP_PACKET3(op, count))
 
 #define OUT_CS_TABLE(values, count) do { \
-    memcpy(cs_copy->ptr + cs_copy->cdw, values, count * 4); \
-    cs_copy->cdw += count; \
-    CS_DEBUG(cs_count -= count;) \
+    memcpy(cs_copy->current.buf + cs_copy->current.cdw, (values), (count) * 4); \
+    cs_copy->current.cdw += (count); \
+    CS_USED_DW(count); \
 } while (0)
 
 
 /**
- * Writing relocations.
+ * Writing buffers.
  */
 
-#define OUT_CS_RELOC(bo, offset, rd, wd) do { \
-    assert(bo); \
-    OUT_CS(offset); \
-    cs_winsys->cs_write_reloc(cs_copy, bo, rd, wd); \
-    CS_DEBUG(cs_count -= 2;) \
-} while (0)
-
-#define OUT_CS_BUF_RELOC(bo, offset, rd, wd) do { \
-    assert(bo); \
-    OUT_CS_RELOC(r300_buffer(bo)->buf, offset, rd, wd); \
-} while (0)
-
-#define OUT_CS_TEX_RELOC(tex, offset, rd, wd) do { \
-    assert(tex); \
-    OUT_CS_RELOC(tex->buffer, offset, rd, wd); \
-} while (0)
-
-#define OUT_CS_BUF_RELOC_NO_OFFSET(bo, rd, wd) do { \
-    assert(bo); \
-    cs_winsys->cs_write_reloc(cs_copy, r300_buffer(bo)->buf, rd, wd); \
-    CS_DEBUG(cs_count -= 2;) \
+#define OUT_CS_RELOC(r) do { \
+    assert((r)); \
+    assert((r)->buf); \
+    OUT_CS(0xc0001000); /* PKT3_NOP */ \
+    OUT_CS(cs_winsys->cs_lookup_buffer(cs_copy, (r)->buf) * 4); \
 } while (0)
 
 
  */
 
 #define WRITE_CS_TABLE(values, count) do { \
-    CS_DEBUG(assert(cs_count == 0);) \
-    memcpy(cs_copy->ptr + cs_copy->cdw, (values), (count) * 4); \
-    cs_copy->cdw += (count); \
+    assert(cs_count == 0); \
+    memcpy(cs_copy->current.buf + cs_copy->current.cdw, (values), (count) * 4); \
+    cs_copy->current.cdw += (count); \
 } while (0)
 
 #endif /* R300_CS_H */