*/
if (brw->ctx.Extensions.ARB_query_buffer_object &&
brw_is_query_pipelined(query)) {
- brw_emit_pipe_control_write(brw,
- PIPE_CONTROL_WRITE_IMMEDIATE,
+ unsigned flags = PIPE_CONTROL_WRITE_IMMEDIATE;
+
+ if (available) {
+ /* Order available *after* the query results. */
+ flags |= PIPE_CONTROL_FLUSH_ENABLE;
+ } else {
+ /* Make it unavailable *before* any pipelined reads. */
+ flags |= PIPE_CONTROL_CS_STALL;
+ }
+
+ brw_emit_pipe_control_write(brw, flags,
query->bo, 2 * sizeof(uint64_t),
- available, 0);
+ available);
}
}
static void
write_primitives_generated(struct brw_context *brw,
- drm_bacon_bo *query_bo, int stream, int idx)
+ struct brw_bo *query_bo, int stream, int idx)
{
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
+
brw_emit_mi_flush(brw);
- if (brw->gen >= 7 && stream > 0) {
+ if (devinfo->gen >= 7 && stream > 0) {
brw_store_register_mem64(brw, query_bo,
GEN7_SO_PRIM_STORAGE_NEEDED(stream),
idx * sizeof(uint64_t));
static void
write_xfb_primitives_written(struct brw_context *brw,
- drm_bacon_bo *bo, int stream, int idx)
+ struct brw_bo *bo, int stream, int idx)
{
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
+
brw_emit_mi_flush(brw);
- if (brw->gen >= 7) {
+ if (devinfo->gen >= 7) {
brw_store_register_mem64(brw, bo, GEN7_SO_NUM_PRIMS_WRITTEN(stream),
idx * sizeof(uint64_t));
} else {
static void
write_xfb_overflow_streams(struct gl_context *ctx,
- drm_bacon_bo *bo, int stream, int count,
+ struct brw_bo *bo, int stream, int count,
int idx)
{
struct brw_context *brw = brw_context(ctx);
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
brw_emit_mi_flush(brw);
int w_idx = 4 * i + idx;
int g_idx = 4 * i + idx + 2;
- if (brw->gen >= 7) {
+ if (devinfo->gen >= 7) {
brw_store_register_mem64(brw, bo,
GEN7_SO_NUM_PRIMS_WRITTEN(stream + i),
g_idx * sizeof(uint64_t));
}
static void
-emit_pipeline_stat(struct brw_context *brw, drm_bacon_bo *bo,
+emit_pipeline_stat(struct brw_context *brw, struct brw_bo *bo,
int stream, int target, int idx)
{
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
+
/* One source of confusion is the tessellation shader statistics. The
* hardware has no statistics specific to the TE unit. Ideally we could have
* the HS primitives for TESS_CONTROL_SHADER_PATCHES_ARB, and the DS
/* Gen6 GS code counts full primitives, that is, it won't count individual
* triangles in a triangle strip. Use CL_INVOCATION_COUNT for that.
*/
- if (brw->gen == 6 && target == GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB)
+ if (devinfo->gen == 6 && target == GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB)
reg = CL_INVOCATION_COUNT;
assert(reg != 0);
struct brw_query_object *query)
{
struct brw_context *brw = brw_context(ctx);
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
if (query->bo == NULL)
return;
- brw_bo_map(brw, query->bo, false, "query object");
- uint64_t *results = query->bo->virtual;
+ uint64_t *results = brw_bo_map(brw, query->bo, MAP_READ);
switch (query->Base.Target) {
case GL_TIME_ELAPSED:
/* The query BO contains the starting and ending timestamps.
* Subtract the two and convert to nanoseconds.
*/
query->Base.Result = brw_raw_timestamp_delta(brw, results[0], results[1]);
- query->Base.Result = brw_timebase_scale(brw, query->Base.Result);
+ query->Base.Result = gen_device_info_timebase_scale(devinfo, query->Base.Result);
break;
case GL_TIMESTAMP:
/* The query BO contains a single timestamp value in results[0]. */
- query->Base.Result = brw_timebase_scale(brw, results[0]);
+ query->Base.Result = gen_device_info_timebase_scale(devinfo, results[0]);
/* Ensure the scaled timestamp overflows according to
* GL_QUERY_COUNTER_BITS
* and correctly emitted the number of pixel shader invocations, but,
* whomever forgot to undo the multiply by 4.
*/
- if (brw->gen == 8 || brw->is_haswell)
+ if (devinfo->gen == 8 || devinfo->is_haswell)
query->Base.Result /= 4;
break;
default:
unreachable("Unrecognized query target in brw_queryobj_get_results()");
}
- drm_bacon_bo_unmap(query->bo);
+ brw_bo_unmap(query->bo);
/* Now that we've processed the data stored in the query's buffer object,
* we can release it.
*/
- drm_bacon_bo_unreference(query->bo);
+ brw_bo_unreference(query->bo);
query->bo = NULL;
query->Base.Ready = true;
struct brw_query_object *query = (struct brw_query_object *)q;
/* Since we're starting a new query, we need to throw away old results. */
- drm_bacon_bo_unreference(query->bo);
- query->bo = drm_bacon_bo_alloc(brw->bufmgr, "query results", 4096, 4096);
+ brw_bo_unreference(query->bo);
+ query->bo =
+ brw_bo_alloc(brw->bufmgr, "query results", 4096, BRW_MEMZONE_OTHER);
/* For ARB_query_buffer_object: The result is not available */
set_query_availability(brw, query, false);
* (for example, due to being full). Record that it's been flushed.
*/
query->flushed = query->flushed ||
- !drm_bacon_bo_references(brw->batch.bo, query->bo);
+ !brw_batch_references(&brw->batch, query->bo);
if (!query->flushed)
intel_batchbuffer_flush(brw);
*/
flush_batch_if_needed(brw, query);
- if (!drm_bacon_bo_busy(query->bo)) {
+ if (!brw_bo_busy(query->bo)) {
gen6_queryobj_get_results(ctx, query);
}
}