* that they neatly hide away, and don't have the cost of function setup, so
* we're going to use them. */
+#ifdef DEBUG
+#define CB_DEBUG(x) x
+#else
+#define CB_DEBUG(x)
+#endif
+
/**
* Command buffer setup.
*/
#define CB_LOCALS \
- int cs_count = 0; \
+ CB_DEBUG(int cs_count = 0;) \
uint32_t *cs_ptr = NULL; \
- (void) cs_count; (void) cs_ptr;
+ CB_DEBUG((void) cs_count;) (void) cs_ptr;
#define NEW_CB(ptr, size) do { \
assert(sizeof(*ptr) == sizeof(uint32_t)); \
cs_ptr = (ptr) = (uint32_t*)malloc((size) * sizeof(uint32_t)); \
- cs_count = size; \
+ CB_DEBUG(cs_count = size;) \
} while (0)
#define BEGIN_CB(ptr, size) do { \
assert(sizeof(*ptr) == sizeof(uint32_t)); \
cs_ptr = ptr; \
- cs_count = size; \
+ CB_DEBUG(cs_count = size;) \
} while (0)
#define END_CB do { \
- if (cs_count != 0) \
+ CB_DEBUG(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, __FUNCTION__, __FILE__, __LINE__);) \
} while (0)
#define OUT_CB(value) do { \
*cs_ptr = (value); \
cs_ptr++; \
- cs_count--; \
+ CB_DEBUG(cs_count--;) \
} while (0)
#define OUT_CB_TABLE(values, count) do { \
memcpy(cs_ptr, values, count * sizeof(uint32_t)); \
cs_ptr += count; \
- cs_count -= count; \
+ CB_DEBUG(cs_count -= count;) \
} while (0)
#define OUT_CB_32F(value) \
* 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_context* const cs_context_copy = (context); \
struct r300_winsys_screen *cs_winsys = cs_context_copy->rws; \
- int cs_count = 0; (void) cs_count;
+ CS_DEBUG(int cs_count = 0; (void) cs_count;)
#define BEGIN_CS(size) do { \
assert(r300_check_cs(cs_context_copy, (size))); \
cs_winsys->begin_cs(cs_winsys, (size), \
__FILE__, __FUNCTION__, __LINE__); \
- cs_count = size; \
+ CS_DEBUG(cs_count = size;) \
} while (0)
#define END_CS do { \
- if (cs_count != 0) \
- debug_printf("r300: Warning: cs_count off by %d\n", cs_count); \
+ CS_DEBUG(if (cs_count != 0) \
+ debug_printf("r300: Warning: cs_count off by %d\n", cs_count);) \
cs_winsys->end_cs(cs_winsys, __FILE__, __FUNCTION__, __LINE__); \
- cs_count = 0; \
+ CS_DEBUG(cs_count = 0;) \
} while (0)
#define OUT_CS(value) do { \
cs_winsys->write_cs_dword(cs_winsys, (value)); \
- cs_count--; \
+ CS_DEBUG(cs_count--;) \
} while (0)
#define OUT_CS_32F(value) do { \
cs_winsys->write_cs_dword(cs_winsys, fui(value)); \
- cs_count--; \
+ CS_DEBUG(cs_count--;) \
} while (0)
#define OUT_CS_REG(register, value) do { \
assert(register); \
cs_winsys->write_cs_dword(cs_winsys, CP_PACKET0(register, 0)); \
cs_winsys->write_cs_dword(cs_winsys, value); \
- cs_count -= 2; \
+ CS_DEBUG(cs_count -= 2;) \
} while (0)
/* Note: This expects count to be the number of registers,
#define OUT_CS_REG_SEQ(register, count) do { \
assert(register); \
cs_winsys->write_cs_dword(cs_winsys, CP_PACKET0((register), ((count) - 1))); \
- cs_count--; \
+ CS_DEBUG(cs_count--;) \
} while (0)
#define OUT_CS_TABLE(values, count) do { \
cs_winsys->write_cs_table(cs_winsys, values, count); \
- cs_count -= count; \
+ CS_DEBUG(cs_count -= count;) \
} while (0)
#define OUT_CS_ONE_REG(register, count) do { \
assert(register); \
cs_winsys->write_cs_dword(cs_winsys, CP_PACKET0((register), ((count) - 1)) | RADEON_ONE_REG_WR); \
- cs_count--; \
+ CS_DEBUG(cs_count--;) \
} while (0)
#define OUT_CS_PKT3(op, count) do { \
cs_winsys->write_cs_dword(cs_winsys, CP_PACKET3(op, count)); \
- cs_count--; \
+ CS_DEBUG(cs_count--;) \
} while (0)
assert(bo); \
cs_winsys->write_cs_dword(cs_winsys, offset); \
r300_buffer_write_reloc(cs_winsys, r300_buffer(bo), rd, wd, flags); \
- cs_count -= 3; \
+ CS_DEBUG(cs_count -= 3;) \
} while (0)
#define OUT_CS_TEX_RELOC(tex, offset, rd, wd, flags) do { \
assert(tex); \
cs_winsys->write_cs_dword(cs_winsys, offset); \
r300_texture_write_reloc(cs_winsys, tex, rd, wd, flags); \
- cs_count -= 3; \
+ CS_DEBUG(cs_count -= 3;) \
} while (0)
#define OUT_CS_BUF_RELOC_NO_OFFSET(bo, rd, wd, flags) do { \
assert(bo); \
r300_buffer_write_reloc(cs_winsys, r300_buffer(bo), rd, wd, flags); \
- cs_count -= 2; \
+ CS_DEBUG(cs_count -= 2;) \
} while (0)
#define OUT_CS_INDEX_RELOC(bo, offset, count, rd, wd, flags) do { \
cs_winsys->write_cs_dword(cs_winsys, offset); \
cs_winsys->write_cs_dword(cs_winsys, count); \
cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \
- cs_count -= 4; \
+ CS_DEBUG(cs_count -= 4;) \
} while (0)
/* It's recommended not to call begin_cs/end_cs before/after this macro. */
#define WRITE_CS_TABLE(values, count) do { \
- assert(cs_count == 0); \
+ CS_DEBUG(assert(cs_count == 0);) \
cs_winsys->write_cs_table(cs_winsys, values, count); \
} while (0)