mesa/dd/st: direct wire queries/timestamp/condrender.

These were all interrelated, avoid the indirect calls here,
and call directly between main and state tracker

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14073>
This commit is contained in:
Dave Airlie 2021-12-06 16:31:59 +10:00 committed by Marge Bot
parent 0d8610b099
commit bd9adf3919
9 changed files with 58 additions and 106 deletions

View File

@ -36,6 +36,8 @@
#include "mtypes.h"
#include "queryobj.h"
#include "state_tracker/st_cb_queryobj.h"
#include "state_tracker/st_cb_condrender.h"
static ALWAYS_INLINE void
begin_conditional_render(struct gl_context *ctx, GLuint queryId, GLenum mode,
@ -99,8 +101,7 @@ begin_conditional_render(struct gl_context *ctx, GLuint queryId, GLenum mode,
ctx->Query.CondRenderQuery = q;
ctx->Query.CondRenderMode = mode;
if (ctx->Driver.BeginConditionalRender)
ctx->Driver.BeginConditionalRender(ctx, q, mode);
st_BeginConditionalRender(ctx, q, mode);
}
@ -138,8 +139,7 @@ end_conditional_render(struct gl_context *ctx)
{
FLUSH_VERTICES(ctx, 0, 0);
if (ctx->Driver.EndConditionalRender)
ctx->Driver.EndConditionalRender(ctx, ctx->Query.CondRenderQuery);
st_EndConditionalRender(ctx, ctx->Query.CondRenderQuery);
ctx->Query.CondRenderQuery = NULL;
ctx->Query.CondRenderMode = GL_NONE;
@ -195,27 +195,27 @@ _mesa_check_conditional_render(struct gl_context *ctx)
FALLTHROUGH;
case GL_QUERY_WAIT:
if (!q->Ready) {
ctx->Driver.WaitQuery(ctx, q);
st_WaitQuery(ctx, q);
}
return q->Result > 0;
case GL_QUERY_BY_REGION_WAIT_INVERTED:
FALLTHROUGH;
case GL_QUERY_WAIT_INVERTED:
if (!q->Ready) {
ctx->Driver.WaitQuery(ctx, q);
st_WaitQuery(ctx, q);
}
return q->Result == 0;
case GL_QUERY_BY_REGION_NO_WAIT:
FALLTHROUGH;
case GL_QUERY_NO_WAIT:
if (!q->Ready)
ctx->Driver.CheckQuery(ctx, q);
st_CheckQuery(ctx, q);
return q->Ready ? (q->Result > 0) : GL_TRUE;
case GL_QUERY_BY_REGION_NO_WAIT_INVERTED:
FALLTHROUGH;
case GL_QUERY_NO_WAIT_INVERTED:
if (!q->Ready)
ctx->Driver.CheckQuery(ctx, q);
st_CheckQuery(ctx, q);
return q->Ready ? (q->Result == 0) : GL_TRUE;
default:
_mesa_problem(ctx, "Bad cond render mode %s in "

View File

@ -59,6 +59,7 @@ struct gl_shader_program;
struct gl_texture_image;
struct gl_texture_object;
struct gl_memory_info;
struct gl_query_object;
struct gl_sampler_object;
struct gl_transform_feedback_object;
struct gl_vertex_array_object;
@ -776,25 +777,6 @@ struct dd_function_table {
GLuint *bits, GLuint *width, GLuint *height);
void (*EvaluateDepthValues)(struct gl_context *ctx);
/**
* \name Query objects
*/
/*@{*/
struct gl_query_object * (*NewQueryObject)(struct gl_context *ctx, GLuint id);
void (*DeleteQuery)(struct gl_context *ctx, struct gl_query_object *q);
void (*BeginQuery)(struct gl_context *ctx, struct gl_query_object *q);
void (*EndQuery)(struct gl_context *ctx, struct gl_query_object *q);
void (*CheckQuery)(struct gl_context *ctx, struct gl_query_object *q);
void (*WaitQuery)(struct gl_context *ctx, struct gl_query_object *q);
/*
* \pname the value requested to be written (GL_QUERY_RESULT, etc)
* \ptype the type of the value requested to be written:
* GL_UNSIGNED_INT, GL_UNSIGNED_INT64_ARB,
* GL_INT, GL_INT64_ARB
*/
void (*StoreQueryResult)(struct gl_context *ctx, struct gl_query_object *q,
struct gl_buffer_object *buf, intptr_t offset,
GLenum pname, GLenum ptype);
/*@}*/
/**
@ -922,13 +904,6 @@ struct dd_function_table {
GLbitfield, GLuint64);
/*@}*/
/** GL_NV_conditional_render */
void (*BeginConditionalRender)(struct gl_context *ctx,
struct gl_query_object *q,
GLenum mode);
void (*EndConditionalRender)(struct gl_context *ctx,
struct gl_query_object *q);
/**
* \name GL_OES_draw_texture interface
*/
@ -976,12 +951,6 @@ struct dd_function_table {
*/
void (*TextureBarrier)(struct gl_context *ctx);
/**
* \name Return a timestamp in nanoseconds as defined by GL_ARB_timer_query.
* This should be equivalent to glGetInteger64v(GL_TIMESTAMP);
*/
uint64_t (*GetTimestamp)(struct gl_context *ctx);
/**
* \name GL_ARB_texture_multisample
*/

View File

@ -43,6 +43,8 @@
#include "stencil.h"
#include "version.h"
#include "state_tracker/st_cb_queryobj.h"
/* This is a table driven implemetation of the glGet*v() functions.
* The basic idea is that most getters just look up an int somewhere
* in struct gl_context and then convert it to a bool or float according to
@ -1176,12 +1178,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
break;
/* GL_ARB_timer_query */
case GL_TIMESTAMP:
if (ctx->Driver.GetTimestamp) {
v->value_int64 = ctx->Driver.GetTimestamp(ctx);
}
else {
_mesa_problem(ctx, "driver doesn't implement GetTimestamp");
}
v->value_int64 = st_GetTimestamp(ctx);
break;
/* GL_KHR_DEBUG */
case GL_DEBUG_OUTPUT:

View File

@ -33,6 +33,8 @@
#include "mtypes.h"
#include "util/u_memory.h"
#include "state_tracker/st_cb_queryobj.h"
static struct gl_query_object **
get_pipe_stats_binding_point(struct gl_context *ctx,
GLenum target)
@ -160,7 +162,7 @@ create_queries(struct gl_context *ctx, GLenum target, GLsizei n, GLuint *ids,
GLsizei i;
for (i = 0; i < n; i++) {
struct gl_query_object *q
= ctx->Driver.NewQueryObject(ctx, ids[i]);
= st_NewQueryObject(ctx, ids[i]);
if (!q) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
return;
@ -234,10 +236,10 @@ _mesa_DeleteQueries(GLsizei n, const GLuint *ids)
*bindpt = NULL;
}
q->Active = GL_FALSE;
ctx->Driver.EndQuery(ctx, q);
st_EndQuery(ctx, q);
}
_mesa_HashRemoveLocked(ctx->Query.QueryObjects, ids[i]);
ctx->Driver.DeleteQuery(ctx, q);
st_DeleteQuery(ctx, q);
}
}
}
@ -334,7 +336,7 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
return;
} else {
/* create new object */
q = ctx->Driver.NewQueryObject(ctx, id);
q = st_NewQueryObject(ctx, id);
if (!q) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQuery{Indexed}");
return;
@ -389,7 +391,7 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
/* XXX should probably refcount query objects */
*bindpt = q;
ctx->Driver.BeginQuery(ctx, q);
st_BeginQuery(ctx, q);
}
@ -435,7 +437,7 @@ _mesa_EndQueryIndexed(GLenum target, GLuint index)
}
q->Active = GL_FALSE;
ctx->Driver.EndQuery(ctx, q);
st_EndQuery(ctx, q);
}
void GLAPIENTRY
@ -476,7 +478,7 @@ _mesa_QueryCounter(GLuint id, GLenum target)
/* XXX the Core profile should throw INVALID_OPERATION here */
/* create new object */
q = ctx->Driver.NewQueryObject(ctx, id);
q = st_NewQueryObject(ctx, id);
if (!q) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glQueryCounter");
return;
@ -516,7 +518,7 @@ _mesa_QueryCounter(GLuint id, GLenum target)
/* QueryCounter is implemented using EndQuery without BeginQuery
* in drivers. This is actually Direct3D and Gallium convention.
*/
ctx->Driver.EndQuery(ctx, q);
st_EndQuery(ctx, q);
}
@ -726,7 +728,7 @@ get_query_object(struct gl_context *ctx, const char *func,
case GL_QUERY_RESULT_NO_WAIT:
case GL_QUERY_RESULT_AVAILABLE:
case GL_QUERY_TARGET:
ctx->Driver.StoreQueryResult(ctx, q, buf, offset, pname, ptype);
st_StoreQueryResult(ctx, q, buf, offset, pname, ptype);
return;
}
@ -736,20 +738,20 @@ get_query_object(struct gl_context *ctx, const char *func,
switch (pname) {
case GL_QUERY_RESULT:
if (!q->Ready)
ctx->Driver.WaitQuery(ctx, q);
st_WaitQuery(ctx, q);
value = q->Result;
break;
case GL_QUERY_RESULT_NO_WAIT:
if (!_mesa_has_ARB_query_buffer_object(ctx))
goto invalid_enum;
ctx->Driver.CheckQuery(ctx, q);
st_CheckQuery(ctx, q);
if (!q->Ready)
return;
value = q->Result;
break;
case GL_QUERY_RESULT_AVAILABLE:
if (!q->Ready)
ctx->Driver.CheckQuery(ctx, q);
st_CheckQuery(ctx, q);
value = q->Ready;
break;
case GL_QUERY_TARGET:
@ -942,7 +944,7 @@ delete_queryobj_cb(void *data, void *userData)
{
struct gl_query_object *q= (struct gl_query_object *) data;
struct gl_context *ctx = (struct gl_context *)userData;
ctx->Driver.DeleteQuery(ctx, q);
st_DeleteQuery(ctx, q);
}

View File

@ -45,10 +45,7 @@
#include "st_cb_bitmap.h"
/**
* Called via ctx->Driver.BeginConditionalRender()
*/
static void
void
st_BeginConditionalRender(struct gl_context *ctx, struct gl_query_object *q,
GLenum mode)
{
@ -97,11 +94,7 @@ st_BeginConditionalRender(struct gl_context *ctx, struct gl_query_object *q,
cso_set_render_condition(st->cso_context, stq->pq, inverted, m);
}
/**
* Called via ctx->Driver.EndConditionalRender()
*/
static void
void
st_EndConditionalRender(struct gl_context *ctx, struct gl_query_object *q)
{
struct st_context *st = st_context(ctx);
@ -111,11 +104,3 @@ st_EndConditionalRender(struct gl_context *ctx, struct gl_query_object *q)
cso_set_render_condition(st->cso_context, NULL, FALSE, 0);
}
void st_init_cond_render_functions(struct dd_function_table *functions)
{
functions->BeginConditionalRender = st_BeginConditionalRender;
functions->EndConditionalRender = st_EndConditionalRender;
}

View File

@ -28,10 +28,8 @@
#ifndef ST_CB_CONDRENDER_H
#define ST_CB_CONDRENDER_H
struct dd_function_table;
extern void st_init_cond_render_functions(struct dd_function_table *functions);
void st_BeginConditionalRender(struct gl_context *ctx, struct gl_query_object *q,
GLenum mode);
void st_EndConditionalRender(struct gl_context *ctx, struct gl_query_object *q);
#endif

View File

@ -48,7 +48,7 @@
#include "st_util.h"
static struct gl_query_object *
struct gl_query_object *
st_NewQueryObject(struct gl_context *ctx, GLuint id)
{
struct st_query_object *stq = ST_CALLOC_STRUCT(st_query_object);
@ -78,7 +78,7 @@ free_queries(struct pipe_context *pipe, struct st_query_object *stq)
}
static void
void
st_DeleteQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
@ -129,7 +129,7 @@ target_to_index(const struct st_context *st, const struct gl_query_object *q)
return 0;
}
static void
void
st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct st_context *st = st_context(ctx);
@ -227,7 +227,7 @@ st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
}
static void
void
st_EndQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct st_context *st = st_context(ctx);
@ -340,7 +340,7 @@ get_query_result(struct pipe_context *pipe,
}
static void
void
st_WaitQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
@ -359,7 +359,7 @@ st_WaitQuery(struct gl_context *ctx, struct gl_query_object *q)
}
static void
void
st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
@ -369,7 +369,7 @@ st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q)
}
static uint64_t
uint64_t
st_GetTimestamp(struct gl_context *ctx)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
@ -386,7 +386,7 @@ st_GetTimestamp(struct gl_context *ctx)
}
}
static void
void
st_StoreQueryResult(struct gl_context *ctx, struct gl_query_object *q,
struct gl_buffer_object *buf, intptr_t offset,
GLenum pname, GLenum ptype)
@ -478,15 +478,3 @@ st_StoreQueryResult(struct gl_context *ctx, struct gl_query_object *q,
pipe->get_query_result_resource(pipe, stq->pq, wait, result_type, index,
stObj->buffer, offset);
}
void st_init_query_functions(struct dd_function_table *functions)
{
functions->NewQueryObject = st_NewQueryObject;
functions->DeleteQuery = st_DeleteQuery;
functions->BeginQuery = st_BeginQuery;
functions->EndQuery = st_EndQuery;
functions->WaitQuery = st_WaitQuery;
functions->CheckQuery = st_CheckQuery;
functions->GetTimestamp = st_GetTimestamp;
functions->StoreQueryResult = st_StoreQueryResult;
}

View File

@ -56,8 +56,23 @@ st_query_object(struct gl_query_object *q)
}
extern void
st_init_query_functions(struct dd_function_table *functions);
struct gl_query_object *
st_NewQueryObject(struct gl_context *ctx, GLuint id);
void
st_DeleteQuery(struct gl_context *ctx, struct gl_query_object *q);
void
st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q);
void
st_EndQuery(struct gl_context *ctx, struct gl_query_object *q);
void
st_WaitQuery(struct gl_context *ctx, struct gl_query_object *q);
void
st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q);
void
st_StoreQueryResult(struct gl_context *ctx, struct gl_query_object *q,
struct gl_buffer_object *buf, intptr_t offset,
GLenum pname, GLenum ptype);
uint64_t
st_GetTimestamp(struct gl_context *ctx);
#endif

View File

@ -961,8 +961,6 @@ st_init_driver_functions(struct pipe_screen *screen,
st_init_perfmon_functions(functions);
st_init_perfquery_functions(functions);
st_init_program_functions(functions);
st_init_query_functions(functions);
st_init_cond_render_functions(functions);
st_init_readpixels_functions(functions);
st_init_semaphoreobject_functions(functions);
st_init_texture_functions(functions);