[Mesa-dev] [PATCH 01/13] gallium: add PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE and corresponding cap

Roland Scheidegger sroland at vmware.com
Fri Jul 28 14:33:55 UTC 2017


Am 28.07.2017 um 07:16 schrieb Nicolai Hähnle:
> On 27.07.2017 23:17, Roland Scheidegger wrote:
>> Am 27.07.2017 um 21:14 schrieb Nicolai Hähnle:
>>> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>>>
>>> ---
>>>   src/gallium/auxiliary/util/u_dump_defines.c      | 1 +
>>>   src/gallium/auxiliary/util/u_inlines.h           | 1 +
>>>   src/gallium/docs/source/context.rst              | 9 +++++++--
>>>   src/gallium/docs/source/screen.rst               | 2 ++
>>>   src/gallium/drivers/etnaviv/etnaviv_screen.c     | 1 +
>>>   src/gallium/drivers/freedreno/freedreno_screen.c | 1 +
>>>   src/gallium/drivers/i915/i915_screen.c           | 1 +
>>>   src/gallium/drivers/llvmpipe/lp_screen.c         | 1 +
>>>   src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 1 +
>>>   src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 1 +
>>>   src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 1 +
>>>   src/gallium/drivers/r300/r300_screen.c           | 1 +
>>>   src/gallium/drivers/r600/r600_pipe.c             | 1 +
>>>   src/gallium/drivers/radeonsi/si_pipe.c           | 1 +
>>>   src/gallium/drivers/softpipe/sp_screen.c         | 1 +
>>>   src/gallium/drivers/svga/svga_screen.c           | 1 +
>>>   src/gallium/drivers/swr/swr_screen.cpp           | 1 +
>>>   src/gallium/drivers/trace/tr_dump_state.c        | 1 +
>>>   src/gallium/drivers/vc4/vc4_screen.c             | 1 +
>>>   src/gallium/drivers/virgl/virgl_screen.c         | 1 +
>>>   src/gallium/include/pipe/p_defines.h             | 3 +++
>>>   21 files changed, 30 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/gallium/auxiliary/util/u_dump_defines.c
>>> b/src/gallium/auxiliary/util/u_dump_defines.c
>>> index 9d831ef..9126feb 100644
>>> --- a/src/gallium/auxiliary/util/u_dump_defines.c
>>> +++ b/src/gallium/auxiliary/util/u_dump_defines.c
>>> @@ -372,6 +372,7 @@ util_dump_query_type_names[] = {
>>>      "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 d57f61e..e0ed594 100644
>>> --- a/src/gallium/auxiliary/util/u_inlines.h
>>> +++ b/src/gallium/auxiliary/util/u_inlines.h
>>> @@ -537,6 +537,7 @@ util_query_clear_result(union pipe_query_result
>>> *result, unsigned type)
>>>      switch (type) {
>>>      case PIPE_QUERY_OCCLUSION_PREDICATE:
>>>      case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
>>> +   case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
>>>      case PIPE_QUERY_GPU_FINISHED:
>>>         result->b = FALSE;
>>>         break;
>>> diff --git a/src/gallium/docs/source/context.rst
>>> b/src/gallium/docs/source/context.rst
>>> index a46131c..2747c29 100644
>>> --- a/src/gallium/docs/source/context.rst
>>> +++ b/src/gallium/docs/source/context.rst
>>> @@ -428,9 +428,14 @@ XXX the 2nd value is equivalent to
>>> ``PIPE_QUERY_PRIMITIVES_GENERATED`` but it is
>>>   unclear if it should be increased if stream output is not active.
>>>     ``PIPE_QUERY_SO_OVERFLOW_PREDICATE`` returns a boolean value
>>> indicating
>>> -whether the stream output targets have overflowed as a result of the
>>> +whether a stream output target has overflowed as a result of the
>>>   commands issued between ``begin_query`` and ``end_query``.
>>> -This query can be used with ``render_condition``.
>>> +This query can be used with ``render_condition``. It is indexed by the
>>> +stream number.
>>> +
>>> +``PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE`` behaves like
>>> +``PIPE_QUERY_SO_OVERFLOW_PREDICATE``, except it returns a boolean value
>>> +indicating whether any of the streams have overflowed.
>>>     ``PIPE_QUERY_GPU_FINISHED`` returns a boolean value indicating
>>> whether
>>>   all commands issued before ``end_query`` have completed. However, this
>>> diff --git a/src/gallium/docs/source/screen.rst
>>> b/src/gallium/docs/source/screen.rst
>>> index 32da228..4b88f59 100644
>>> --- a/src/gallium/docs/source/screen.rst
>>> +++ b/src/gallium/docs/source/screen.rst
>>> @@ -396,6 +396,8 @@ The integer capabilities:
>>>     ``TGSI_PROPERTY_FS_POST_DEPTH_COVERAGE`` is supported.
>>>   * ``PIPE_CAP_BINDLESS_TEXTURE``: Whether bindless texture
>>> operations are
>>>     supported.
>>> +* ``PIPE_CAP_QUERY_SO_OVERFLOW_ANY``: Whether the
>>> +  ``PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE`` query is supported.
>> Shouldn't the cap actually be for both types of so overflow queries? The
>> other one doesn't have a cap bit, and it's the same GL extension.
>> (Some drivers, like llvmpipe, don't support multiple streams but
>> implement (a non-indexed really) PIPE_QUERY_SO_OVERFLOW_PREDICATE - they
>> could easily support the ANY query too since there's not really any
>> difference if there's just one stream.)
>> Albeit I'm actually wondering if the existing query shouldn't really be
>> the non-indexed one, and the new one should have STREAM in the name. I
>> think that would be less confusing. Also, the
>> ARB_transform_feedback_overflow_query spec says only the
>> TRANSFORM_FEEDBACK_OVERFLOW_ARB query is valid if
>> arb_transform_feedback3 is available. (It is, though, perfectly valid to
>> support arb_transform_feedback3 with just 1 vertex stream...)
>> So, imho the cap bit should just indicate if so_overflow queries are
>> supported, and if so without
>> STREAM_OUTPUT_INTERLEAVE_BUFFERINTERLEAVE_BUFFER (which governs arb_tf3)
>> only PIPE_QUERY_SO_OVERFLOW_PREDICATE needs to be supported, otherwise
>> PIPE_QUERY_SO_OVERFLOW_STREAM_PREDICATE too.
>> (drivers which only support one stream should be easily able to
>> implement the per-stream query trivially as it should be the same as the
>> all-stream query.)
> 
> I think this all got a bit confused by the fact that there are already
> half-baked implementations of PIPE_QUERY_SO_OVERFLOW_PREDICATE all over
> the code, and I was guided by making minimal changes.
> 
> But looking at it again, I think you're right. The existing
> PIPE_QUERY_SO_OVERFLOW_PREDICATE seems to have never been used, and so
> we get a chance to cleanup the design.
> 
> How about this:

This looks good to me.
FWIW it's not quite true it is fully unused, we do need it with some
internal code (non-mesa state tracker and llvmpipe).
This gallium query type is MUCH older than the gl extension. D3d10 had
it much earlier. And d3d10 only has one stream, hence why there was just
this one SO overflow query in gallium. (d3d11 retrofitted this query to
be the one for any stream overflowing and added new per stream ones, and
the gl extension follows this.)

(There's also a corresponding PIPE_QUERY_SO_STATISTICS - this ought to
work exactly the same wrt affected streams - it should count from all
streams, d3d11 has additional per-stream queries. GL instead has two
different queries for querying emitted and generated primitives, which
are also directly supported by gallium, PIPE_QUERY_PRIMITIVES_GENERATED
and PIPE_QUERY_PRIMITIVES_EMITTED, these are per stream, but no way to
count primitives from all streams directly. So this is pretty
inconsistent in gallium regardless the names for overflow queries you're
going to use.)

Roland

> 
>> diff --git a/src/gallium/docs/source/context.rst
>> b/src/gallium/docs/source/context.rst
>> index a46131c..04c0c67 100644
>> --- a/src/gallium/docs/source/context.rst
>> +++ b/src/gallium/docs/source/context.rst
>> @@ -428,10 +428,16 @@ XXX the 2nd value is equivalent to
>> ``PIPE_QUERY_PRIMITIVES_GENERATED`` but it is
>>  unclear if it should be increased if stream output is not active.
>>  
>>  ``PIPE_QUERY_SO_OVERFLOW_PREDICATE`` returns a boolean value indicating
>> -whether the stream output targets have overflowed as a result of the
>> +whether any of the stream output targets have overflowed as a result
>> of the
>>  commands issued between ``begin_query`` and ``end_query``.
>>  This query can be used with ``render_condition``.
>>  
>> +``PIPE_QUERY_SO_OVERFLOW_STREAM_PREDICATE`` returns a boolean value
>> indicating
>> +whether an output stream has overflowed as a result of the commands
>> issued
>> +between ``begin_query`` and ``end_query``. The stream is selected by the
>> +``index`` parameter of ``create_query``. This query can be used with
>> +``render_condition``.
>> +
>>  ``PIPE_QUERY_GPU_FINISHED`` returns a boolean value indicating whether
>>  all commands issued before ``end_query`` have completed. However, this
>>  does not imply serialization.
>> diff --git a/src/gallium/docs/source/screen.rst
>> b/src/gallium/docs/source/screen.rst
>> index 32da228..8b06bfe 100644
>> --- a/src/gallium/docs/source/screen.rst
>> +++ b/src/gallium/docs/source/screen.rst
>> @@ -396,6 +396,10 @@ The integer capabilities:
>>    ``TGSI_PROPERTY_FS_POST_DEPTH_COVERAGE`` is supported.
>>  * ``PIPE_CAP_BINDLESS_TEXTURE``: Whether bindless texture operations are
>>    supported.
>> +* ``PIPE_CAP_QUERY_SO_OVERFLOW``: Whether the
>> +  ``PIPE_QUERY_SO_OVERFLOW_PREDICATE`` query type is supported. If
>> both this
>> +  cap and ``PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS`` are
>> supported, then
>> +  ``PIPE_QUERY_SO_OVERFLOW_STREAM_PREDICATE`` is also supported.
>>  
>>  
>>  .. _pipe_capf:
> 
> 
> Cheers,
> Nicolai
> 
> 
> 



More information about the mesa-dev mailing list