if (batch->malloc_buffer)
batch->map = batch->malloc_buffer;
else
- batch->map = batch->sws->bo_map(batch->buf, GL_TRUE);
+ batch->map = batch->sws->bo_map(batch->buf,
+ BRW_DATA_OTHER,
+ GL_TRUE);
batch->size = BRW_BATCH_SIZE;
batch->ptr = batch->map;
used = batch->ptr - batch->map;
if (batch->use_malloc_buffer) {
- batch->sws->bo_subdata(batch->buf, 0, used, batch->map );
+ batch->sws->bo_subdata(batch->buf,
+ BRW_DATA_OTHER,
+ 0, used,
+ batch->map );
batch->map = NULL;
}
else {
batch->sws->bo_exec(batch->buf, used );
if (1 /*BRW_DEBUG & DEBUG_BATCH*/) {
- void *ptr = batch->sws->bo_map(batch->buf, GL_FALSE);
+ void *ptr = batch->sws->bo_map(batch->buf,
+ BRW_DATA_OTHER,
+ GL_FALSE);
intel_decode(ptr,
used / 4,
* interface.
*/
debug_printf("waiting for idle\n");
- batch->sws->bo_map(batch->buf, GL_TRUE);
+ batch->sws->bo_map(batch->buf,
+ BRW_DATA_OTHER,
+ GL_TRUE);
batch->sws->bo_unmap(batch->buf);
}
#define SURF_INDEX_VERT_CONST_BUFFER 0
+/* Bit of a hack to align these with the winsys buffer_data_type enum.
+ */
enum brw_cache_id {
- BRW_CC_VP,
- BRW_CC_UNIT,
- BRW_WM_PROG,
- BRW_SAMPLER_DEFAULT_COLOR,
- BRW_SAMPLER,
- BRW_WM_UNIT,
- BRW_SF_PROG,
- BRW_SF_VP,
- BRW_SF_UNIT,
- BRW_VS_UNIT,
- BRW_VS_PROG,
- BRW_GS_UNIT,
- BRW_GS_PROG,
- BRW_CLIP_VP,
- BRW_CLIP_UNIT,
- BRW_CLIP_PROG,
- BRW_SS_SURFACE,
- BRW_SS_SURF_BIND,
+ BRW_CC_VP = BRW_DATA_GS_CC_VP,
+ BRW_CC_UNIT = BRW_DATA_GS_CC_UNIT,
+ BRW_WM_PROG = BRW_DATA_GS_WM_PROG,
+ BRW_SAMPLER_DEFAULT_COLOR = BRW_DATA_GS_SAMPLER_DEFAULT_COLOR,
+ BRW_SAMPLER = BRW_DATA_GS_SAMPLER,
+ BRW_WM_UNIT = BRW_DATA_GS_WM_UNIT,
+ BRW_SF_PROG = BRW_DATA_GS_SF_PROG,
+ BRW_SF_VP = BRW_DATA_GS_SF_VP,
+ BRW_SF_UNIT = BRW_DATA_GS_SF_UNIT,
+ BRW_VS_UNIT = BRW_DATA_GS_VS_UNIT,
+ BRW_VS_PROG = BRW_DATA_GS_VS_PROG,
+ BRW_GS_UNIT = BRW_DATA_GS_GS_UNIT,
+ BRW_GS_PROG = BRW_DATA_GS_GS_PROG,
+ BRW_CLIP_VP = BRW_DATA_GS_CLIP_VP,
+ BRW_CLIP_UNIT = BRW_DATA_GS_CLIP_UNIT,
+ BRW_CLIP_PROG = BRW_DATA_GS_CLIP_PROG,
+ BRW_SS_SURFACE = BRW_DATA_SS_SURFACE,
+ BRW_SS_SURF_BIND = BRW_DATA_SS_SURF_BIND,
BRW_MAX_CACHE
};
struct brw_cache_item **items;
GLuint size, n_items;
+ enum brw_buffer_type buffer_type;
+
GLuint key_size[BRW_MAX_CACHE]; /* for fixed-size keys */
GLuint aux_size[BRW_MAX_CACHE];
char *name[BRW_MAX_CACHE];
*/
brw->sws->bo_subdata(brw->curbe.curbe_bo,
brw->curbe.curbe_offset,
+ BRW_DATA_OTHER,
bufsz,
buf);
}
if (brw->sws->bo_is_busy(query->bo) && !wait)
return FALSE;
- map = brw->sws->bo_map(query->bo, GL_FALSE);
+ map = brw->sws->bo_map(query->bo, BRW_DATA_OTHER, GL_FALSE);
if (map == NULL)
return FALSE;
return buf->user_buffer;
return sws->bo_map( buf->bo,
+ BRW_DATA_OTHER,
(usage & PIPE_BUFFER_USAGE_CPU_WRITE) ? TRUE : FALSE );
}
struct brw_screen *bscreen = brw_screen(screen);
struct brw_winsys_screen *sws = bscreen->sws;
struct brw_buffer *buf;
- unsigned usage_type;
+ unsigned buffer_type;
buf = CALLOC_STRUCT(brw_buffer);
if (!buf)
case PIPE_BUFFER_USAGE_VERTEX:
case PIPE_BUFFER_USAGE_INDEX:
case (PIPE_BUFFER_USAGE_VERTEX|PIPE_BUFFER_USAGE_INDEX):
- usage_type = BRW_BUFFER_TYPE_VERTEX;
+ buffer_type = BRW_BUFFER_TYPE_VERTEX;
break;
case PIPE_BUFFER_USAGE_PIXEL:
- usage_type = BRW_BUFFER_TYPE_PIXEL;
+ buffer_type = BRW_BUFFER_TYPE_PIXEL;
break;
case PIPE_BUFFER_USAGE_CONSTANT:
- usage_type = BRW_BUFFER_TYPE_SHADER_CONSTANTS;
+ buffer_type = BRW_BUFFER_TYPE_SHADER_CONSTANTS;
break;
default:
- usage_type = BRW_BUFFER_TYPE_GENERIC;
+ buffer_type = BRW_BUFFER_TYPE_GENERIC;
break;
}
buf->bo = sws->bo_alloc( sws,
- usage_type,
+ buffer_type,
size,
alignment );
{
struct brw_screen *bscreen = brw_screen(screen);
struct brw_texture *tex;
+ enum brw_buffer_type buffer_type;
tex = CALLOC_STRUCT(brw_texture);
if (tex == NULL)
goto fail;
- if (templ->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
- }
- else if (templ->tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_PRIMARY)) {
- }
- else if (templ->tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
- }
- else if (templ->tex_usage & PIPE_TEXTURE_USAGE_SAMPLER) {
+ if (templ->tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+ PIPE_TEXTURE_USAGE_PRIMARY)) {
+ buffer_type = BRW_BUFFER_TYPE_SCANOUT;
}
-
- if (templ->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC) {
+ else {
+ buffer_type = BRW_BUFFER_TYPE_TEXTURE;
}
tex->bo = bscreen->sws->bo_alloc( bscreen->sws,
- BRW_USAGE_SAMPLER,
+ buffer_type,
tex->pitch * tex->total_height * tex->cpp,
64 );
* these various entities.
*/
bo = cache->sws->bo_alloc(cache->sws,
- BRW_BUFFER_TYPE_STATE_CACHE,
+ cache->buffer_type,
data_size, 1 << 6);
data_size, cache_id);
/* Copy data to the buffer */
- cache->sws->bo_subdata(bo, 0, data_size, data);
+ cache->sws->bo_subdata(bo,
+ cache_id,
+ 0, data_size, data);
update_cache_last(cache, cache_id, bo);
reloc_bufs, nr_reloc_bufs);
}
-enum pool_type {
- DW_SURFACE_STATE,
- DW_GENERAL_STATE
-};
-
static void
brw_init_cache_id(struct brw_cache *cache,
static void
-brw_init_non_surface_cache(struct brw_context *brw)
+brw_init_general_state_cache(struct brw_context *brw)
{
struct brw_cache *cache = &brw->cache;
cache->brw = brw;
cache->sws = brw->sws;
+ cache->buffer_type = BRW_BUFFER_TYPE_GENERAL_STATE;
+
cache->size = 7;
cache->n_items = 0;
cache->items = (struct brw_cache_item **)
static void
-brw_init_surface_cache(struct brw_context *brw)
+brw_init_surface_state_cache(struct brw_context *brw)
{
struct brw_cache *cache = &brw->surface_cache;
cache->brw = brw;
cache->sws = brw->sws;
+ cache->buffer_type = BRW_BUFFER_TYPE_SURFACE_STATE;
+
cache->size = 7;
cache->n_items = 0;
cache->items = (struct brw_cache_item **)
void
brw_init_caches(struct brw_context *brw)
{
- brw_init_non_surface_cache(brw);
- brw_init_surface_cache(brw);
+ brw_init_general_state_cache(brw);
+ brw_init_surface_state_cache(brw);
}
if (buffer == NULL)
return;
- data = sws->bo_map(buffer, GL_FALSE);
+ data = sws->bo_map(buffer, BRW_DATA_OTHER, GL_FALSE);
for (i = 0; i < state_size / 4; i++) {
state_out(name, data, buffer->offset[0], i,
"dword %d\n", i);
debug_printf(" WM SS%d: NULL\n", i);
continue;
}
- surf = (struct brw_surface_state *)brw->sws->bo_map(surf_bo, GL_FALSE);
+ surf = (struct brw_surface_state *)brw->sws->bo_map(surf_bo,
+ BRW_DATA_OTHER,
+ GL_FALSE);
surfoff = surf_bo->offset[0];
sprintf(name, "WM SS%d", i);
if (brw->sf.vp_bo == NULL)
return;
- vp = (struct brw_sf_viewport *)brw->sws->bo_map(brw->sf.vp_bo, GL_FALSE);
+ vp = (struct brw_sf_viewport *)brw->sws->bo_map(brw->sf.vp_bo,
+ BRW_DATA_OTHER,
+ GL_FALSE);
vp_off = brw->sf.vp_bo->offset[0];
state_out(name, vp, vp_off, 0, "m00 = %f\n", vp->viewport.m00);
if (prog == NULL)
return;
- data = (uint32_t *)sws->bo_map(prog, GL_FALSE);
+ data = (uint32_t *)sws->bo_map(prog,
+ BRW_DATA_OTHER,
+ GL_FALSE);
for (i = 0; i < prog->size / 4 / 4; i++) {
debug_printf("%8s: 0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
unsigned size;
};
-/* Describe the usage of a particular buffer in a relocation. The DRM
- * winsys will translate these back to GEM read/write domain flags.
- */
-enum brw_buffer_usage {
- BRW_USAGE_STATE, /* INSTRUCTION, 0 */
- BRW_USAGE_QUERY_RESULT, /* INSTRUCTION, INSTRUCTION */
- BRW_USAGE_RENDER_TARGET, /* RENDER, 0 */
- BRW_USAGE_DEPTH_BUFFER, /* RENDER, RENDER */
- BRW_USAGE_BLIT_SOURCE, /* RENDER, 0 */
- BRW_USAGE_BLIT_DEST, /* RENDER, RENDER */
- BRW_USAGE_SAMPLER, /* SAMPLER, 0 */
- BRW_USAGE_VERTEX, /* VERTEX, 0 */
- BRW_USAGE_SCRATCH, /* 0, 0 */
- BRW_USAGE_MAX
-};
/* Should be possible to validate usages above against buffer creation
* types, below:
BRW_BUFFER_TYPE_SHADER_CONSTANTS,
BRW_BUFFER_TYPE_SHADER_SCRATCH,
BRW_BUFFER_TYPE_BATCH,
- BRW_BUFFER_TYPE_STATE_CACHE,
+ BRW_BUFFER_TYPE_GENERAL_STATE,
+ BRW_BUFFER_TYPE_SURFACE_STATE,
BRW_BUFFER_TYPE_PIXEL, /* image uploads, pbo's, etc */
BRW_BUFFER_TYPE_GENERIC, /* unknown */
BRW_BUFFER_TYPE_MAX /* Count of possible values */
};
+
+/* Describe the usage of a particular buffer in a relocation. The DRM
+ * winsys will translate these back to GEM read/write domain flags.
+ */
+enum brw_buffer_usage {
+ BRW_USAGE_STATE, /* INSTRUCTION, 0 */
+ BRW_USAGE_QUERY_RESULT, /* INSTRUCTION, INSTRUCTION */
+ BRW_USAGE_RENDER_TARGET, /* RENDER, 0 */
+ BRW_USAGE_DEPTH_BUFFER, /* RENDER, RENDER */
+ BRW_USAGE_BLIT_SOURCE, /* RENDER, 0 */
+ BRW_USAGE_BLIT_DEST, /* RENDER, RENDER */
+ BRW_USAGE_SAMPLER, /* SAMPLER, 0 */
+ BRW_USAGE_VERTEX, /* VERTEX, 0 */
+ BRW_USAGE_SCRATCH, /* 0, 0 */
+ BRW_USAGE_MAX
+};
+
+enum brw_buffer_data_type {
+ BRW_DATA_GS_CC_VP,
+ BRW_DATA_GS_CC_UNIT,
+ BRW_DATA_GS_WM_PROG,
+ BRW_DATA_GS_SAMPLER_DEFAULT_COLOR,
+ BRW_DATA_GS_SAMPLER,
+ BRW_DATA_GS_WM_UNIT,
+ BRW_DATA_GS_SF_PROG,
+ BRW_DATA_GS_SF_VP,
+ BRW_DATA_GS_SF_UNIT,
+ BRW_DATA_GS_VS_UNIT,
+ BRW_DATA_GS_VS_PROG,
+ BRW_DATA_GS_GS_UNIT,
+ BRW_DATA_GS_GS_PROG,
+ BRW_DATA_GS_CLIP_VP,
+ BRW_DATA_GS_CLIP_UNIT,
+ BRW_DATA_GS_CLIP_PROG,
+ BRW_DATA_SS_SURFACE,
+ BRW_DATA_SS_SURF_BIND,
+ BRW_DATA_OTHER,
+ BRW_DATA_MAX
+};
+
struct brw_winsys_screen {
unsigned bytes_used );
int (*bo_subdata)(struct brw_winsys_buffer *buffer,
- size_t offset,
- size_t size,
- const void *data);
+ enum brw_buffer_data_type data_type,
+ size_t offset,
+ size_t size,
+ const void *data);
boolean (*bo_is_busy)(struct brw_winsys_buffer *buffer);
boolean (*bo_references)(struct brw_winsys_buffer *a,
* Map a buffer.
*/
void *(*bo_map)(struct brw_winsys_buffer *buffer,
+ enum brw_buffer_data_type data_type,
boolean write);
/**
void (*bo_unmap)(struct brw_winsys_buffer *buffer);
/*@}*/
-
-
-
/**
* Destroy the winsys.
*/
const char *names[BRW_BUFFER_TYPE_MAX] = {
- "texture",
- "scanout",
- "vertex",
- "curbe",
- "query",
- "shader_constants",
- "wm_scratch",
- "batch",
- "state_cache",
- "pixel",
- "generic",
+ "TEXTURE",
+ "SCANOUT",
+ "VERTEX",
+ "CURBE",
+ "QUERY",
+ "SHADER_CONSTANTS",
+ "WM_SCRATCH",
+ "BATCH",
+ "GENERAL_STATE",
+ "SURFACE_STATE",
+ "PIXEL",
+ "GENERIC",
};
const char *usages[BRW_USAGE_MAX] = {
- "state",
- "query_result",
- "render_target",
- "depth_buffer",
- "blit_source",
- "blit_dest",
- "sampler",
- "vertex",
- "scratch"
+ "STATE",
+ "QUERY_RESULT",
+ "RENDER_TARGET",
+ "DEPTH_BUFFER",
+ "BLIT_SOURCE",
+ "BLIT_DEST",
+ "SAMPLER",
+ "VERTEX",
+ "SCRATCH"
};
+
+const char *data_types[BRW_DATA_MAX] =
+{
+ "GS: CC_VP",
+ "GS: CC_UNIT",
+ "GS: WM_PROG",
+ "GS: SAMPLER_DEFAULT_COLOR",
+ "GS: SAMPLER",
+ "GS: WM_UNIT",
+ "GS: SF_PROG",
+ "GS: SF_VP",
+ "GS: SF_UNIT",
+ "GS: VS_UNIT",
+ "GS: VS_PROG",
+ "GS: GS_UNIT",
+ "GS: GS_PROG",
+ "GS: CLIP_VP",
+ "GS: CLIP_UNIT",
+ "GS: CLIP_PROG",
+ "SS: SURFACE",
+ "SS: SURF_BIND",
+ "(untyped)"
+};
+
+
static struct brw_winsys_buffer *
xlib_brw_bo_alloc( struct brw_winsys_screen *sws,
enum brw_buffer_type type,
struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
struct xlib_brw_buffer *buf;
- debug_printf("%s type %d sz %d align %d\n",
- __FUNCTION__, type, size, alignment );
+ debug_printf("%s type %s sz %d align %d\n",
+ __FUNCTION__, names[type], size, alignment );
buf = CALLOC_STRUCT(xlib_brw_buffer);
if (!buf)
static int
xlib_brw_bo_emit_reloc( struct brw_winsys_buffer *buffer,
- enum brw_buffer_usage usage,
- unsigned delta,
- unsigned offset,
- struct brw_winsys_buffer *buffer2)
+ enum brw_buffer_usage usage,
+ unsigned delta,
+ unsigned offset,
+ struct brw_winsys_buffer *buffer2)
{
struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
struct xlib_brw_buffer *buf2 = xlib_brw_buffer(buffer2);
static int
xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer,
- size_t offset,
- size_t size,
- const void *data)
+ enum brw_buffer_data_type data_type,
+ size_t offset,
+ size_t size,
+ const void *data)
{
struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
- debug_printf("%s buf %p off %d sz %d data %p\n",
+ debug_printf("%s buf %p off %d sz %d data %p %s\n",
__FUNCTION__,
- (void *)buffer, offset, size, data);
+ (void *)buffer, offset, size, data, data_types[data_type]);
memcpy(buf->virtual + offset, data, size);
return 0;
static void *
xlib_brw_bo_map(struct brw_winsys_buffer *buffer,
+ enum brw_buffer_data_type data_type,
boolean write)
{
struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
- debug_printf("%s %p %s\n", __FUNCTION__, (void *)buffer,
- write ? "read/write" : "read");
+ debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer,
+ write ? "read/write" : "read",
+ write ? data_types[data_type] : "");
buf->map_count++;
return buf->virtual;