Mesa (main): mesa/dd/st: direct wire queries/timestamp/condrender.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Dec 7 13:47:27 UTC 2021
Module: Mesa
Branch: main
Commit: bd9adf39198c122993ffb600aab0ca26d4ee046e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd9adf39198c122993ffb600aab0ca26d4ee046e
Author: Dave Airlie <airlied at redhat.com>
Date: Mon Dec 6 16:31:59 2021 +1000
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 at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14073>
---
src/mesa/main/condrender.c | 16 +++++++--------
src/mesa/main/dd.h | 33 +------------------------------
src/mesa/main/get.c | 9 +++------
src/mesa/main/queryobj.c | 28 ++++++++++++++------------
src/mesa/state_tracker/st_cb_condrender.c | 19 ++----------------
src/mesa/state_tracker/st_cb_condrender.h | 8 +++-----
src/mesa/state_tracker/st_cb_queryobj.c | 28 ++++++++------------------
src/mesa/state_tracker/st_cb_queryobj.h | 21 +++++++++++++++++---
src/mesa/state_tracker/st_context.c | 2 --
9 files changed, 58 insertions(+), 106 deletions(-)
diff --git a/src/mesa/main/condrender.c b/src/mesa/main/condrender.c
index 1ceb1f60569..2671a2d340a 100644
--- a/src/mesa/main/condrender.c
+++ b/src/mesa/main/condrender.c
@@ -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 "
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 3e99acc16c6..0763042c334 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -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
*/
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 2d8c0fcf02c..91620c7a53c 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -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:
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index c2bb9a396a0..6766063782e 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -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);
}
diff --git a/src/mesa/state_tracker/st_cb_condrender.c b/src/mesa/state_tracker/st_cb_condrender.c
index 4fd5ccb51f3..6769d8bf89a 100644
--- a/src/mesa/state_tracker/st_cb_condrender.c
+++ b/src/mesa/state_tracker/st_cb_condrender.c
@@ -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;
-}
diff --git a/src/mesa/state_tracker/st_cb_condrender.h b/src/mesa/state_tracker/st_cb_condrender.h
index 79d0db8d08a..2a4e8e8355f 100644
--- a/src/mesa/state_tracker/st_cb_condrender.h
+++ b/src/mesa/state_tracker/st_cb_condrender.h
@@ -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
diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c
index 3ef17636923..29372950d28 100644
--- a/src/mesa/state_tracker/st_cb_queryobj.c
+++ b/src/mesa/state_tracker/st_cb_queryobj.c
@@ -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;
-}
diff --git a/src/mesa/state_tracker/st_cb_queryobj.h b/src/mesa/state_tracker/st_cb_queryobj.h
index 24063211b7e..e0ef14d9826 100644
--- a/src/mesa/state_tracker/st_cb_queryobj.h
+++ b/src/mesa/state_tracker/st_cb_queryobj.h
@@ -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
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index de76577b3a0..b14c9fda536 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -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);
More information about the mesa-commit
mailing list