#include "util/u_memory.h"
#include "brw_batchbuffer.h"
-//#include "brw_decode.h"
#include "brw_reg.h"
#include "brw_winsys.h"
#include "brw_debug.h"
#include "brw_structs.h"
-#include "intel_decode.h"
-#define USE_MALLOC_BUFFER 1
#define ALWAYS_EMIT_MI_FLUSH 1
enum pipe_error
if (ret)
return ret;
- if (batch->malloc_buffer)
- batch->map = batch->malloc_buffer;
- else
- batch->map = batch->sws->bo_map(batch->buf,
- BRW_DATA_OTHER,
- GL_TRUE);
-
batch->size = BRW_BATCH_SIZE;
+
+ /* With map_range semantics, the winsys can decide whether to
+ * inject a malloc'ed bounce buffer instead of mapping directly.
+ */
+ batch->map = batch->sws->bo_map(batch->buf,
+ BRW_DATA_BATCH_BUFFER,
+ 0, batch->size,
+ GL_TRUE,
+ GL_TRUE,
+ GL_TRUE);
+
batch->ptr = batch->map;
return PIPE_OK;
}
{
struct brw_batchbuffer *batch = CALLOC_STRUCT(brw_batchbuffer);
- batch->use_malloc_buffer = USE_MALLOC_BUFFER;
- if (batch->use_malloc_buffer) {
- batch->malloc_buffer = MALLOC(BRW_BATCH_SIZE);
- }
-
batch->sws = sws;
batch->chipset = chipset;
brw_batchbuffer_reset(batch);
void
brw_batchbuffer_free(struct brw_batchbuffer *batch)
{
- if (batch->malloc_buffer) {
- FREE(batch->malloc_buffer);
- batch->map = NULL;
- }
- else if (batch->map) {
+ if (batch->map) {
batch->sws->bo_unmap(batch->buf);
batch->map = NULL;
}
file, line, used);
if (ALWAYS_EMIT_MI_FLUSH) {
- *(GLuint *) (batch->ptr) = ((MI_FLUSH << 16) | BRW_FLUSH_STATE_CACHE);
+ *(GLuint *) (batch->ptr) = MI_FLUSH | BRW_FLUSH_STATE_CACHE;
batch->ptr += 4;
used = batch->ptr - batch->map;
}
batch->ptr += 4;
used = batch->ptr - batch->map;
- if (batch->use_malloc_buffer) {
- batch->sws->bo_subdata(batch->buf,
- BRW_DATA_OTHER,
- 0, used,
- batch->map );
- batch->map = NULL;
- }
- else {
- batch->sws->bo_unmap(batch->buf);
- batch->map = NULL;
- }
-
+ batch->sws->bo_flush_range(batch->buf, 0, used);
+ batch->sws->bo_unmap(batch->buf);
+ batch->map = NULL;
batch->ptr = NULL;
batch->sws->bo_exec(batch->buf, used );
- if (1 /*BRW_DEBUG & DEBUG_BATCH*/) {
- void *ptr = batch->sws->bo_map(batch->buf,
- BRW_DATA_OTHER,
- GL_FALSE);
-
- intel_decode(ptr,
- used / 4,
- batch->buf->offset[0],
- batch->chipset.pci_id);
-
- batch->sws->bo_unmap(batch->buf);
- }
-
if (BRW_DEBUG & DEBUG_SYNC) {
/* Abuse map/unmap to achieve wait-for-fence.
*
* interface.
*/
debug_printf("waiting for idle\n");
- batch->sws->bo_map(batch->buf,
- BRW_DATA_OTHER,
- GL_TRUE);
- batch->sws->bo_unmap(batch->buf);
+ batch->sws->bo_wait_idle(batch->buf);
}
/* Reset the buffer:
enum pipe_error
brw_batchbuffer_emit_reloc(struct brw_batchbuffer *batch,
struct brw_winsys_buffer *buffer,
- uint32_t usage,
+ enum brw_buffer_usage usage,
uint32_t delta)
{
int ret;
if (batch->ptr - batch->map > batch->buf->size) {
- debug_printf("bad relocation ptr %p map %p offset %d size %d\n",
- batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size);
+ debug_printf("bad relocation ptr %p map %p offset %li size %i\n",
+ batch->ptr, batch->map, (long) (batch->ptr - batch->map), batch->buf->size);
return PIPE_ERROR_OUT_OF_MEMORY;
}
if (ret != 0)
return ret;
- /*
- * Using the old buffer offset, write in what the right data would be, in case
- * the buffer doesn't move and we can short-circuit the relocation processing
- * in the kernel
+ /* bo_emit_reloc was resposible for writing a zero into the
+ * batchbuffer if necessary. Just need to update our pointer.
*/
- brw_batchbuffer_emit_dword (batch, buffer->offset[0] + delta);
+ batch->ptr += 4;
+
return 0;
}