[Mesa-dev] [PATCH] gallium: add PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE

Nicolai Hähnle nhaehnle at gmail.com
Mon Sep 18 15:40:36 UTC 2017


On 18.09.2017 17:22, Jan Vesely wrote:
> On Wed, 2017-09-13 at 18:53 +0200, Nicolai Hähnle wrote:
>> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>>
>> To be able to properly distinguish between GL_ANY_SAMPLES_PASSED
>> and GL_ANY_SAMPLES_PASSED_CONSERVATIVE.
>>
>> This patch goes through all drivers, having them treat the two
>> query types identically, except:
>>
>> 1. radeon incorrectly enabled conservative mode on
>>     PIPE_QUERY_OCCLUSION_PREDICATE. We now do it correctly, only
>>     on PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE.
>> 2. st/mesa uses the new query type.
>>
>> Fixes dEQP-GLES31.functional.fbo.no_attachments.*
>> ---
>>   src/gallium/auxiliary/util/u_dump_defines.c      |  1 +
>>   src/gallium/auxiliary/util/u_inlines.h           |  1 +
>>   src/gallium/docs/source/context.rst              |  6 ++++++
>>   src/gallium/drivers/freedreno/a3xx/fd3_query.c   |  8 ++++++++
>>   src/gallium/drivers/freedreno/a4xx/fd4_query.c   |  8 ++++++++
>>   src/gallium/drivers/freedreno/a5xx/fd5_query.c   | 10 ++++++++++
>>   src/gallium/drivers/freedreno/freedreno_query.h  |  1 +
>>   src/gallium/drivers/llvmpipe/lp_query.c          |  3 +++
>>   src/gallium/drivers/llvmpipe/lp_rast.c           |  2 ++
>>   src/gallium/drivers/llvmpipe/lp_setup.c          |  3 +++
>>   src/gallium/drivers/nouveau/nv30/nv30_query.c    |  4 +++-
>>   src/gallium/drivers/nouveau/nv50/nv50_query.c    |  1 +
>>   src/gallium/drivers/nouveau/nv50/nv50_query_hw.c |  4 ++++
>>   src/gallium/drivers/nouveau/nvc0/nvc0_query.c    |  1 +
>>   src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c |  7 ++++++-
>>   src/gallium/drivers/r300/r300_query.c            |  7 +++++--
>>   src/gallium/drivers/radeon/r600_pipe_common.c    |  3 ++-
>>   src/gallium/drivers/radeon/r600_query.c          | 19 ++++++++++++++-----
>>   src/gallium/drivers/softpipe/sp_query.c          |  4 ++++
>>   src/gallium/drivers/svga/svga_pipe_query.c       |  7 ++++++-
>>   src/gallium/drivers/swr/swr_query.cpp            |  1 +
>>   src/gallium/drivers/trace/tr_dump_state.c        |  1 +
>>   src/gallium/include/pipe/p_defines.h             |  2 ++
>>   src/mesa/state_tracker/st_cb_queryobj.c          |  5 ++++-
>>   24 files changed, 97 insertions(+), 12 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/util/u_dump_defines.c b/src/gallium/auxiliary/util/u_dump_defines.c
>> index 5032974a880..e87e5301600 100644
>> --- a/src/gallium/auxiliary/util/u_dump_defines.c
>> +++ b/src/gallium/auxiliary/util/u_dump_defines.c
>> @@ -358,20 +358,21 @@ util_tex_filter_short_names[] = {
>>      "linear"
>>   };
>>   
>>   DEFINE_UTIL_STR_CONTINUOUS(tex_filter)
>>   
>>   
>>   static const char *
>>   util_query_type_names[] = {
>>      "PIPE_QUERY_OCCLUSION_COUNTER",
>>      "PIPE_QUERY_OCCLUSION_PREDICATE",
>> +   "PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE",
>>      "PIPE_QUERY_TIMESTAMP",
>>      "PIPE_QUERY_TIMESTAMP_DISJOINT",
>>      "PIPE_QUERY_TIME_ELAPSED",
>>      "PIPE_QUERY_PRIMITIVES_GENERATED",
>>      "PIPE_QUERY_PRIMITIVES_EMITTED",
>>      "PIPE_QUERY_SO_STATISTICS",
>>      "PIPE_QUERY_SO_OVERFLOW_PREDICATE",
>>      "PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE",
>>      "PIPE_QUERY_GPU_FINISHED",
>>      "PIPE_QUERY_PIPELINE_STATISTICS",
>> diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
>> index e0ed594c9fe..79f62c32266 100644
>> --- a/src/gallium/auxiliary/util/u_inlines.h
>> +++ b/src/gallium/auxiliary/util/u_inlines.h
>> @@ -529,20 +529,21 @@ util_get_min_point_size(const struct pipe_rasterizer_state *state)
>>      return !state->point_quad_rasterization &&
>>             !state->point_smooth &&
>>             !state->multisample ? 1.0f : 0.0f;
>>   }
>>   
>>   static inline void
>>   util_query_clear_result(union pipe_query_result *result, unsigned type)
>>   {
>>      switch (type) {
>>      case PIPE_QUERY_OCCLUSION_PREDICATE:
>> +   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
>>      case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
>>      case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
>>      case PIPE_QUERY_GPU_FINISHED:
>>         result->b = FALSE;
>>         break;
>>      case PIPE_QUERY_OCCLUSION_COUNTER:
>>      case PIPE_QUERY_TIMESTAMP:
>>      case PIPE_QUERY_TIME_ELAPSED:
>>      case PIPE_QUERY_PRIMITIVES_GENERATED:
>>      case PIPE_QUERY_PRIMITIVES_EMITTED:
>> diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
>> index 6ac45819a66..ba7fef8301d 100644
>> --- a/src/gallium/docs/source/context.rst
>> +++ b/src/gallium/docs/source/context.rst
>> @@ -387,20 +387,26 @@ are written to the framebuffer without being culled by
>>   The result is an unsigned 64-bit integer.
>>   This query can be used with ``render_condition``.
>>   
>>   In cases where a boolean result of an occlusion query is enough,
>>   ``PIPE_QUERY_OCCLUSION_PREDICATE`` should be used. It is just like
>>   ``PIPE_QUERY_OCCLUSION_COUNTER`` except that the result is a boolean
>>   value of FALSE for cases where COUNTER would result in 0 and TRUE
>>   for all other cases.
>>   This query can be used with ``render_condition``.
>>   
>> +In cases where a conservative approximation of an occlusion query is enough,
>> +``PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE`` should be used. It behaves
>> +like ``PIPE_QUERY_OCCLUSION_PREDICATE``, except that it may return TRUE in
>> +additional, implementation-dependent cases.
>> +This query can be used with ``render_condition``.
>> +
>>   ``PIPE_QUERY_TIME_ELAPSED`` returns the amount of time, in nanoseconds,
>>   the context takes to perform operations.
>>   The result is an unsigned 64-bit integer.
>>   
>>   ``PIPE_QUERY_TIMESTAMP`` returns a device/driver internal timestamp,
>>   scaled to nanoseconds, recorded after all commands issued prior to
>>   ``end_query`` have been processed.
>>   This query does not require a call to ``begin_query``.
>>   The result is an unsigned 64-bit integer.
>>   
>> diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_query.c b/src/gallium/drivers/freedreno/a3xx/fd3_query.c
>> index cde42c37313..97a95b21546 100644
>> --- a/src/gallium/drivers/freedreno/a3xx/fd3_query.c
>> +++ b/src/gallium/drivers/freedreno/a3xx/fd3_query.c
>> @@ -124,22 +124,30 @@ static const struct fd_hw_sample_provider occlusion_counter = {
>>   		.accumulate_result = occlusion_counter_accumulate_result,
>>   };
>>   
>>   static const struct fd_hw_sample_provider occlusion_predicate = {
>>   		.query_type = PIPE_QUERY_OCCLUSION_PREDICATE,
>>   		.active = FD_STAGE_DRAW,
>>   		.get_sample = occlusion_get_sample,
>>   		.accumulate_result = occlusion_predicate_accumulate_result,
>>   };
>>   
>> +static const struct fd_hw_sample_provider occlusion_predicate_conservative = {
>> +		.query_type = PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE,
>> +		.active = FD_STAGE_DRAW,
>> +		.get_sample = occlusion_get_sample,
>> +		.accumulate_result = occlusion_predicate_accumulate_result,
>> +};
>> +
>>   void fd3_query_context_init(struct pipe_context *pctx)
>>   {
>>   	struct fd_context *ctx = fd_context(pctx);
>>   
>>   	ctx->create_query = fd_hw_create_query;
>>   	ctx->query_prepare = fd_hw_query_prepare;
>>   	ctx->query_prepare_tile = fd_hw_query_prepare_tile;
>>   	ctx->query_set_stage = fd_hw_query_set_stage;
>>   
>>   	fd_hw_query_register_provider(pctx, &occlusion_counter);
>>   	fd_hw_query_register_provider(pctx, &occlusion_predicate);
>> +	fd_hw_query_register_provider(pctx, &occlusion_predicate_conservative);
>>   }
>> diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_query.c b/src/gallium/drivers/freedreno/a4xx/fd4_query.c
>> index f7b385d552d..809e7570b48 100644
>> --- a/src/gallium/drivers/freedreno/a4xx/fd4_query.c
>> +++ b/src/gallium/drivers/freedreno/a4xx/fd4_query.c
>> @@ -244,20 +244,27 @@ static const struct fd_hw_sample_provider occlusion_counter = {
>>   		.accumulate_result = occlusion_counter_accumulate_result,
>>   };
>>   
>>   static const struct fd_hw_sample_provider occlusion_predicate = {
>>   		.query_type = PIPE_QUERY_OCCLUSION_PREDICATE,
>>   		.active = FD_STAGE_DRAW,
>>   		.get_sample = occlusion_get_sample,
>>   		.accumulate_result = occlusion_predicate_accumulate_result,
>>   };
>>   
>> +static const struct fd_hw_sample_provider occlusion_predicate = {
> 
> Guess this should have been 'fd_hw_sample_provider occlusion_predicate_conservative' ?
> Otherwise it is the same struct name as above and breaks build.

Right, thanks for spotting this. I've pushed a one-line fix.

Cheers,
Nicolai


> Jan

-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list