mesa/st: drop lots of perfquery wrappers
Just direct call into pipe driver. Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14632>
This commit is contained in:
parent
78d13fdbb2
commit
3f8e7b8735
|
@ -37,6 +37,8 @@
|
|||
#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"
|
||||
|
||||
|
@ -58,7 +60,7 @@ free_performance_query(void *data, void *user)
|
|||
*/
|
||||
m->Active = false;
|
||||
m->Used = false;
|
||||
st_DeletePerfQuery(ctx, m);
|
||||
ctx->pipe->delete_intel_perf_query(ctx->pipe, (struct pipe_query *)m);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -78,7 +80,7 @@ lookup_object(struct gl_context *ctx, GLuint id)
|
|||
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. */
|
||||
|
@ -239,7 +241,8 @@ _mesa_GetPerfQueryIdByNameINTEL(char *queryName, GLuint *queryId)
|
|||
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);
|
||||
|
@ -279,11 +282,9 @@ _mesa_GetPerfQueryInfoINTEL(GLuint queryId,
|
|||
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);
|
||||
|
||||
|
@ -310,6 +311,58 @@ _mesa_GetPerfQueryInfoINTEL(GLuint queryId,
|
|||
*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,
|
||||
|
@ -348,11 +401,9 @@ _mesa_GetPerfCounterInfoINTEL(GLuint queryId, GLuint counterId,
|
|||
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);
|
||||
|
||||
|
@ -362,7 +413,7 @@ _mesa_GetPerfCounterInfoINTEL(GLuint queryId, GLuint counterId,
|
|||
return;
|
||||
}
|
||||
|
||||
st_GetPerfCounterInfo(ctx, queryIndex, counterIndex,
|
||||
get_perf_counter_info(ctx, queryIndex, counterIndex,
|
||||
&counterName,
|
||||
&counterDesc,
|
||||
&counterOffset,
|
||||
|
@ -453,7 +504,8 @@ _mesa_CreatePerfQueryINTEL(GLuint queryId, GLuint *queryHandle)
|
|||
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;
|
||||
|
@ -494,12 +546,12 @@ _mesa_DeletePerfQueryINTEL(GLuint queryHandle)
|
|||
_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
|
||||
|
@ -541,11 +593,11 @@ _mesa_BeginPerfQueryINTEL(GLuint queryHandle)
|
|||
* 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;
|
||||
|
@ -581,7 +633,7 @@ _mesa_EndPerfQueryINTEL(GLuint queryHandle)
|
|||
return;
|
||||
}
|
||||
|
||||
st_EndPerfQuery(ctx, obj);
|
||||
ctx->pipe->end_intel_perf_query(ctx->pipe, (struct pipe_query *)obj);
|
||||
|
||||
obj->Active = false;
|
||||
obj->Ready = false;
|
||||
|
@ -638,19 +690,22 @@ _mesa_GetPerfQueryDataINTEL(GLuint queryHandle, GLuint flags,
|
|||
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;
|
||||
|
||||
|
|
|
@ -48,169 +48,3 @@ st_have_perfquery(struct st_context *st)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -26,37 +26,4 @@
|
|||
bool
|
||||
st_have_perfquery(struct st_context *st);
|
||||
|
||||
unsigned st_InitPerfQueryInfo(struct gl_context *ctx);
|
||||
|
||||
void st_GetPerfQueryInfo(struct gl_context *ctx,
|
||||
unsigned query_index,
|
||||
const char **name,
|
||||
GLuint *data_size,
|
||||
GLuint *n_counters,
|
||||
GLuint *n_active);
|
||||
|
||||
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);
|
||||
|
||||
void st_DeletePerfQuery(struct gl_context *ctx, struct gl_perf_query_object *o);
|
||||
bool st_BeginPerfQuery(struct gl_context *ctx, struct gl_perf_query_object *o);
|
||||
void st_EndPerfQuery(struct gl_context *ctx, struct gl_perf_query_object *o);
|
||||
void st_WaitPerfQuery(struct gl_context *ctx, struct gl_perf_query_object *o);
|
||||
bool st_IsPerfQueryReady(struct gl_context *ctx, struct gl_perf_query_object *o);
|
||||
bool st_GetPerfQueryData(struct gl_context *ctx,
|
||||
struct gl_perf_query_object *o,
|
||||
GLsizei data_size,
|
||||
GLuint *data,
|
||||
GLuint *bytes_written);
|
||||
|
||||
struct gl_perf_query_object *
|
||||
st_NewPerfQueryObject(struct gl_context *ctx, unsigned query_index);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue