#include "util/ralloc.h"
#include "api_exec_decl.h"
+#include "pipe/p_context.h"
+
#include "state_tracker/st_cb_perfquery.h"
#include "state_tracker/st_cb_flush.h"
*/
m->Active = false;
m->Used = false;
- st_DeletePerfQuery(ctx, m);
+ ctx->pipe->delete_intel_perf_query(ctx->pipe, (struct pipe_query *)m);
}
void
static GLuint
init_performance_query_info(struct gl_context *ctx)
{
- return st_InitPerfQueryInfo(ctx);
+ return ctx->pipe->init_intel_perf_query_info(ctx->pipe);
}
/* For INTEL_performance_query, query id 0 is reserved to be invalid. */
const GLchar *name;
GLuint ignore;
- st_GetPerfQueryInfo(ctx, i, &name, &ignore, &ignore, &ignore);
+ ctx->pipe->get_intel_perf_query_info(ctx->pipe, i, &name,
+ &ignore, &ignore, &ignore);
if (strcmp(name, queryName) == 0) {
*queryId = index_to_queryid(i);
return;
}
- st_GetPerfQueryInfo(ctx, queryIndex,
- &queryName,
- &queryDataSize,
- &queryNumCounters,
- &queryNumActive);
+ ctx->pipe->get_intel_perf_query_info(ctx->pipe, queryIndex, &queryName,
+ &queryDataSize, &queryNumCounters,
+ &queryNumActive);
output_clipped_string(name, nameLength, queryName);
*capsMask = GL_PERFQUERY_SINGLE_CONTEXT_INTEL;
}
+static uint32_t
+pipe_counter_type_enum_to_gl_type(enum pipe_perf_counter_type type)
+{
+ switch (type) {
+ case PIPE_PERF_COUNTER_TYPE_EVENT: return GL_PERFQUERY_COUNTER_EVENT_INTEL;
+ case PIPE_PERF_COUNTER_TYPE_DURATION_NORM: return GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL;
+ case PIPE_PERF_COUNTER_TYPE_DURATION_RAW: return GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL;
+ case PIPE_PERF_COUNTER_TYPE_THROUGHPUT: return GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL;
+ case PIPE_PERF_COUNTER_TYPE_RAW: return GL_PERFQUERY_COUNTER_RAW_INTEL;
+ case PIPE_PERF_COUNTER_TYPE_TIMESTAMP: return GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL;
+ default:
+ unreachable("Unknown counter type");
+ }
+}
+
+static uint32_t
+pipe_counter_data_type_to_gl_type(enum pipe_perf_counter_data_type type)
+{
+ switch (type) {
+ case PIPE_PERF_COUNTER_DATA_TYPE_BOOL32: return GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL;
+ case PIPE_PERF_COUNTER_DATA_TYPE_UINT32: return GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL;
+ case PIPE_PERF_COUNTER_DATA_TYPE_UINT64: return GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL;
+ case PIPE_PERF_COUNTER_DATA_TYPE_FLOAT: return GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL;
+ case PIPE_PERF_COUNTER_DATA_TYPE_DOUBLE: return GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL;
+ default:
+ unreachable("Unknown counter data type");
+ }
+}
+
+static void
+get_perf_counter_info(struct gl_context *ctx,
+ unsigned query_index,
+ unsigned counter_index,
+ const char **name,
+ const char **desc,
+ GLuint *offset,
+ GLuint *data_size,
+ GLuint *type_enum,
+ GLuint *data_type_enum,
+ GLuint64 *raw_max)
+{
+ struct pipe_context *pipe = ctx->pipe;
+ uint32_t pipe_type_enum;
+ uint32_t pipe_data_type_enum;
+
+ pipe->get_intel_perf_query_counter_info(pipe, query_index, counter_index,
+ name, desc, offset, data_size,
+ &pipe_type_enum, &pipe_data_type_enum, raw_max);
+ *type_enum = pipe_counter_type_enum_to_gl_type(pipe_type_enum);
+ *data_type_enum = pipe_counter_data_type_to_gl_type(pipe_data_type_enum);
+}
+
extern void GLAPIENTRY
_mesa_GetPerfCounterInfoINTEL(GLuint queryId, GLuint counterId,
GLuint nameLength, GLchar *name,
return;
}
- st_GetPerfQueryInfo(ctx, queryIndex,
- &queryName,
- &queryDataSize,
- &queryNumCounters,
- &queryNumActive);
+ ctx->pipe->get_intel_perf_query_info(ctx->pipe, queryIndex, &queryName,
+ &queryDataSize, &queryNumCounters,
+ &queryNumActive);
counterIndex = counterid_to_index(counterId);
return;
}
- st_GetPerfCounterInfo(ctx, queryIndex, counterIndex,
+ get_perf_counter_info(ctx, queryIndex, counterIndex,
&counterName,
&counterDesc,
&counterOffset,
return;
}
- obj = st_NewPerfQueryObject(ctx, queryid_to_index(queryId));
+ obj = (struct gl_perf_query_object *)ctx->pipe->new_intel_perf_query_obj(ctx->pipe,
+ queryid_to_index(queryId));
if (obj == NULL) {
_mesa_error_no_memory(__func__);
return;
_mesa_EndPerfQueryINTEL(queryHandle);
if (obj->Used && !obj->Ready) {
- st_WaitPerfQuery(ctx, obj);
+ ctx->pipe->wait_intel_perf_query(ctx->pipe, (struct pipe_query *)obj);
obj->Ready = true;
}
_mesa_HashRemove(ctx->PerfQuery.Objects, queryHandle);
- st_DeletePerfQuery(ctx, obj);
+ ctx->pipe->delete_intel_perf_query(ctx->pipe, (struct pipe_query *)obj);
}
extern void GLAPIENTRY
* waiting for data on that object.
*/
if (obj->Used && !obj->Ready) {
- st_WaitPerfQuery(ctx, obj);
+ ctx->pipe->wait_intel_perf_query(ctx->pipe, (struct pipe_query *)obj);
obj->Ready = true;
}
- if (st_BeginPerfQuery(ctx, obj)) {
+ if (ctx->pipe->begin_intel_perf_query(ctx->pipe, (struct pipe_query *)obj)) {
obj->Used = true;
obj->Active = true;
obj->Ready = false;
return;
}
- st_EndPerfQuery(ctx, obj);
+ ctx->pipe->end_intel_perf_query(ctx->pipe, (struct pipe_query *)obj);
obj->Active = false;
obj->Ready = false;
return;
}
- obj->Ready = st_IsPerfQueryReady(ctx, obj);
+ if (!obj->Ready)
+ obj->Ready = ctx->pipe->is_intel_perf_query_ready(ctx->pipe,
+ (struct pipe_query *)obj);
if (!obj->Ready) {
if (flags == GL_PERFQUERY_FLUSH_INTEL) {
st_glFlush(ctx, 0);
} else if (flags == GL_PERFQUERY_WAIT_INTEL) {
- st_WaitPerfQuery(ctx, obj);
+ ctx->pipe->wait_intel_perf_query(ctx->pipe, (struct pipe_query *)obj);
obj->Ready = true;
}
}
if (obj->Ready) {
- if (!st_GetPerfQueryData(ctx, obj, dataSize, data, bytesWritten)) {
+ if (!ctx->pipe->get_intel_perf_query_data(ctx->pipe, (struct pipe_query *)obj,
+ dataSize, data, bytesWritten)) {
memset(data, 0, dataSize);
*bytesWritten = 0;
pipe->wait_intel_perf_query && pipe->is_intel_perf_query_ready &&
pipe->get_intel_perf_query_data;
}
-
-unsigned
-st_InitPerfQueryInfo(struct gl_context *ctx)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
-
- return pipe->init_intel_perf_query_info(pipe);
-}
-
-void
-st_GetPerfQueryInfo(struct gl_context *ctx,
- unsigned query_index,
- const char **name,
- GLuint *data_size,
- GLuint *n_counters,
- GLuint *n_active)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
-
- pipe->get_intel_perf_query_info(pipe, query_index, name, data_size,
- n_counters, n_active);
-}
-
-static uint32_t
-pipe_counter_type_enum_to_gl_type(enum pipe_perf_counter_type type)
-{
- switch (type) {
- case PIPE_PERF_COUNTER_TYPE_EVENT: return GL_PERFQUERY_COUNTER_EVENT_INTEL;
- case PIPE_PERF_COUNTER_TYPE_DURATION_NORM: return GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL;
- case PIPE_PERF_COUNTER_TYPE_DURATION_RAW: return GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL;
- case PIPE_PERF_COUNTER_TYPE_THROUGHPUT: return GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL;
- case PIPE_PERF_COUNTER_TYPE_RAW: return GL_PERFQUERY_COUNTER_RAW_INTEL;
- case PIPE_PERF_COUNTER_TYPE_TIMESTAMP: return GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL;
- default:
- unreachable("Unknown counter type");
- }
-}
-
-static uint32_t
-pipe_counter_data_type_to_gl_type(enum pipe_perf_counter_data_type type)
-{
- switch (type) {
- case PIPE_PERF_COUNTER_DATA_TYPE_BOOL32: return GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL;
- case PIPE_PERF_COUNTER_DATA_TYPE_UINT32: return GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL;
- case PIPE_PERF_COUNTER_DATA_TYPE_UINT64: return GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL;
- case PIPE_PERF_COUNTER_DATA_TYPE_FLOAT: return GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL;
- case PIPE_PERF_COUNTER_DATA_TYPE_DOUBLE: return GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL;
- default:
- unreachable("Unknown counter data type");
- }
-}
-
-void
-st_GetPerfCounterInfo(struct gl_context *ctx,
- unsigned query_index,
- unsigned counter_index,
- const char **name,
- const char **desc,
- GLuint *offset,
- GLuint *data_size,
- GLuint *type_enum,
- GLuint *data_type_enum,
- GLuint64 *raw_max)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- uint32_t pipe_type_enum;
- uint32_t pipe_data_type_enum;
-
- pipe->get_intel_perf_query_counter_info(pipe, query_index, counter_index,
- name, desc, offset, data_size,
- &pipe_type_enum, &pipe_data_type_enum, raw_max);
- *type_enum = pipe_counter_type_enum_to_gl_type(pipe_type_enum);
- *data_type_enum = pipe_counter_data_type_to_gl_type(pipe_data_type_enum);
-}
-
-void
-st_DeletePerfQuery(struct gl_context *ctx, struct gl_perf_query_object *o)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
-
- /* We can assume that the frontend waits for a query to complete
- * before ever calling into here, so we don't have to worry about
- * deleting an in-flight query object.
- */
- assert(!o->Active);
- assert(!o->Used || o->Ready);
-
- pipe->delete_intel_perf_query(pipe, (struct pipe_query *)o);
-}
-
-bool
-st_BeginPerfQuery(struct gl_context *ctx, struct gl_perf_query_object *o)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
-
- /* We can assume the frontend hides mistaken attempts to Begin a
- * query object multiple times before its End. Similarly if an
- * application reuses a query object before results have arrived
- * the frontend will wait for prior results so we don't need
- * to support abandoning in-flight results.
- */
- assert(!o->Active);
- assert(!o->Used || o->Ready); /* no in-flight query to worry about */
-
- return pipe->begin_intel_perf_query(pipe, (struct pipe_query *)o);
-}
-
-void
-st_EndPerfQuery(struct gl_context *ctx, struct gl_perf_query_object *o)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
-
- pipe->end_intel_perf_query(pipe, (struct pipe_query *)o);
-}
-
-void
-st_WaitPerfQuery(struct gl_context *ctx, struct gl_perf_query_object *o)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
-
- assert(!o->Ready);
-
- pipe->wait_intel_perf_query(pipe, (struct pipe_query *)o);
-}
-
-bool
-st_IsPerfQueryReady(struct gl_context *ctx, struct gl_perf_query_object *o)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
-
- if (o->Ready)
- return true;
-
- return pipe->is_intel_perf_query_ready(pipe, (struct pipe_query *)o);
-}
-
-bool
-st_GetPerfQueryData(struct gl_context *ctx,
- struct gl_perf_query_object *o,
- GLsizei data_size,
- GLuint *data,
- GLuint *bytes_written)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
-
- assert(st_IsPerfQueryReady(ctx, o));
-
- /* We expect that the frontend only calls this hook when it knows
- * that results are available.
- */
- assert(o->Ready);
-
- return pipe->get_intel_perf_query_data(pipe, (struct pipe_query *)o,
- data_size, data, bytes_written);
-}
-
-struct gl_perf_query_object *
-st_NewPerfQueryObject(struct gl_context *ctx, unsigned query_index)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- struct pipe_query *q;
-
- q = pipe->new_intel_perf_query_obj(pipe, query_index);
-
- return (struct gl_perf_query_object *)q;
-}