[Mesa-dev] [PATCH 6/7] gallium/radeon: formalize that create_batch_query doesn't need pipe_context
Marek Olšák
maraeo at gmail.com
Sun Mar 12 17:16:30 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/drivers/radeon/r600_perfcounter.c | 12 ++++++------
src/gallium/drivers/radeon/r600_query.c | 9 ++++-----
src/gallium/drivers/radeon/r600_query.h | 4 ++--
3 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/gallium/drivers/radeon/r600_perfcounter.c b/src/gallium/drivers/radeon/r600_perfcounter.c
index 0c2c6e9..bf24aab 100644
--- a/src/gallium/drivers/radeon/r600_perfcounter.c
+++ b/src/gallium/drivers/radeon/r600_perfcounter.c
@@ -92,34 +92,34 @@ struct r600_pc_counter {
struct r600_query_pc {
struct r600_query_hw b;
unsigned shaders;
unsigned num_counters;
struct r600_pc_counter *counters;
struct r600_pc_group *groups;
};
-static void r600_pc_query_destroy(struct r600_common_context *ctx,
+static void r600_pc_query_destroy(struct r600_common_screen *rscreen,
struct r600_query *rquery)
{
struct r600_query_pc *query = (struct r600_query_pc *)rquery;
while (query->groups) {
struct r600_pc_group *group = query->groups;
query->groups = group->next;
FREE(group);
}
FREE(query->counters);
- r600_query_hw_destroy(ctx, rquery);
+ r600_query_hw_destroy(rscreen, rquery);
}
static bool r600_pc_query_prepare_buffer(struct r600_common_screen *screen,
struct r600_query_hw *hwquery,
struct r600_resource *buffer)
{
/* no-op */
return true;
}
@@ -294,22 +294,22 @@ static struct r600_pc_group *get_group_state(struct r600_common_screen *screen,
group->next = query->groups;
query->groups = group;
return group;
}
struct pipe_query *r600_create_batch_query(struct pipe_context *ctx,
unsigned num_queries,
unsigned *query_types)
{
- struct r600_common_context *rctx = (struct r600_common_context *)ctx;
- struct r600_common_screen *screen = rctx->screen;
+ struct r600_common_screen *screen =
+ (struct r600_common_screen *)ctx->screen;
struct r600_perfcounters *pc = screen->perfcounters;
struct r600_perfcounter_block *block;
struct r600_pc_group *group;
struct r600_query_pc *query;
unsigned base_gid, sub_gid, sub_index;
unsigned i, j;
if (!pc)
return NULL;
@@ -358,21 +358,21 @@ struct pipe_query *r600_create_batch_query(struct pipe_context *ctx,
query->b.num_cs_dw_begin += pc->num_instance_cs_dwords; /* conservative */
query->b.num_cs_dw_end += pc->num_instance_cs_dwords;
i = 0;
for (group = query->groups; group; group = group->next) {
struct r600_perfcounter_block *block = group->block;
unsigned select_dw, read_dw;
unsigned instances = 1;
if ((block->flags & R600_PC_BLOCK_SE) && group->se < 0)
- instances = rctx->screen->info.max_se;
+ instances = screen->info.max_se;
if (group->instance < 0)
instances *= block->num_instances;
group->result_base = i;
query->b.result_size += sizeof(uint64_t) * instances * group->num_counters;
i += instances * group->num_counters;
pc->get_size(block, group->num_counters, group->selectors,
&select_dw, &read_dw);
query->b.num_cs_dw_begin += select_dw;
@@ -416,21 +416,21 @@ struct pipe_query *r600_create_batch_query(struct pipe_context *ctx,
if (group->instance < 0)
counter->qwords *= block->num_instances;
}
if (!r600_query_hw_init(screen, &query->b))
goto error;
return (struct pipe_query *)query;
error:
- r600_pc_query_destroy(rctx, &query->b.b);
+ r600_pc_query_destroy(screen, &query->b.b);
return NULL;
}
static bool r600_init_block_names(struct r600_common_screen *screen,
struct r600_perfcounter_block *block)
{
unsigned i, j, k;
unsigned groups_shader = 1, groups_se = 1, groups_instance = 1;
unsigned namelen;
char *groupname;
diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c
index d834261..e269c39 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -44,27 +44,26 @@ struct r600_query_sw {
uint64_t begin_result;
uint64_t end_result;
uint64_t begin_time;
uint64_t end_time;
/* Fence for GPU_FINISHED. */
struct pipe_fence_handle *fence;
};
-static void r600_query_sw_destroy(struct r600_common_context *rctx,
+static void r600_query_sw_destroy(struct r600_common_screen *rscreen,
struct r600_query *rquery)
{
- struct pipe_screen *screen = rctx->b.screen;
struct r600_query_sw *query = (struct r600_query_sw *)rquery;
- screen->fence_reference(screen, &query->fence, NULL);
+ rscreen->b.fence_reference(&rscreen->b, &query->fence, NULL);
FREE(query);
}
static enum radeon_value_id winsys_id_from_type(unsigned type)
{
switch (type) {
case R600_QUERY_REQUESTED_VRAM: return RADEON_REQUESTED_VRAM_MEMORY;
case R600_QUERY_REQUESTED_GTT: return RADEON_REQUESTED_GTT_MEMORY;
case R600_QUERY_MAPPED_VRAM: return RADEON_MAPPED_VRAM;
case R600_QUERY_MAPPED_GTT: return RADEON_MAPPED_GTT;
@@ -407,21 +406,21 @@ static struct pipe_query *r600_query_sw_create(unsigned query_type)
query = CALLOC_STRUCT(r600_query_sw);
if (!query)
return NULL;
query->b.type = query_type;
query->b.ops = &sw_query_ops;
return (struct pipe_query *)query;
}
-void r600_query_hw_destroy(struct r600_common_context *rctx,
+void r600_query_hw_destroy(struct r600_common_screen *rscreen,
struct r600_query *rquery)
{
struct r600_query_hw *query = (struct r600_query_hw *)rquery;
struct r600_query_buffer *prev = query->buffer.previous;
/* Release all query buffers. */
while (prev) {
struct r600_query_buffer *qbuf = prev;
prev = prev->previous;
r600_resource_reference(&qbuf->buf, NULL);
@@ -869,21 +868,21 @@ static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned q
return r600_query_sw_create(query_type);
return r600_query_hw_create(rscreen, query_type, index);
}
static void r600_destroy_query(struct pipe_context *ctx, struct pipe_query *query)
{
struct r600_common_context *rctx = (struct r600_common_context *)ctx;
struct r600_query *rquery = (struct r600_query *)query;
- rquery->ops->destroy(rctx, rquery);
+ rquery->ops->destroy(rctx->screen, rquery);
}
static boolean r600_begin_query(struct pipe_context *ctx,
struct pipe_query *query)
{
struct r600_common_context *rctx = (struct r600_common_context *)ctx;
struct r600_query *rquery = (struct r600_query *)query;
return rquery->ops->begin(rctx, rquery);
}
diff --git a/src/gallium/drivers/radeon/r600_query.h b/src/gallium/drivers/radeon/r600_query.h
index 052034a..d39663a 100644
--- a/src/gallium/drivers/radeon/r600_query.h
+++ b/src/gallium/drivers/radeon/r600_query.h
@@ -106,21 +106,21 @@ enum {
R600_QUERY_FIRST_PERFCOUNTER = PIPE_QUERY_DRIVER_SPECIFIC + 100,
};
enum {
R600_QUERY_GROUP_GPIN = 0,
R600_NUM_SW_QUERY_GROUPS
};
struct r600_query_ops {
- void (*destroy)(struct r600_common_context *, struct r600_query *);
+ void (*destroy)(struct r600_common_screen *, struct r600_query *);
bool (*begin)(struct r600_common_context *, struct r600_query *);
bool (*end)(struct r600_common_context *, struct r600_query *);
bool (*get_result)(struct r600_common_context *,
struct r600_query *, bool wait,
union pipe_query_result *result);
void (*get_result_resource)(struct r600_common_context *,
struct r600_query *, bool wait,
enum pipe_query_value_type result_type,
int index,
struct pipe_resource *resource,
@@ -182,21 +182,21 @@ struct r600_query_hw {
unsigned num_cs_dw_begin;
unsigned num_cs_dw_end;
/* Linked list of queries */
struct list_head list;
/* For transform feedback: which stream the query is for */
unsigned stream;
};
bool r600_query_hw_init(struct r600_common_screen *rscreen,
struct r600_query_hw *query);
-void r600_query_hw_destroy(struct r600_common_context *rctx,
+void r600_query_hw_destroy(struct r600_common_screen *rscreen,
struct r600_query *rquery);
bool r600_query_hw_begin(struct r600_common_context *rctx,
struct r600_query *rquery);
bool r600_query_hw_end(struct r600_common_context *rctx,
struct r600_query *rquery);
bool r600_query_hw_get_result(struct r600_common_context *rctx,
struct r600_query *rquery,
bool wait,
union pipe_query_result *result);
--
2.7.4
More information about the mesa-dev
mailing list