[Mesa-dev] [PATCH 1/3] gallium: add support for sampling from stencil of depth_stencil texture

Ilia Mirkin imirkin at alum.mit.edu
Sun May 4 03:49:53 PDT 2014


Yeah, I actually sent a follow-up patch which does this in a totally
different and much simpler way.

On Sun, May 4, 2014 at 6:47 AM, Marek Olšák <maraeo at gmail.com> wrote:
> Gallium already supports stencil texturing and st/mesa has been using
> it for glDrawPixels for quite a while. The pipe_sampler_view bit is
> unnecessary. You can create a stencil sampler view by specifying one
> of these formats:
>
> PIPE_FORMAT_S8_UINT
> PIPE_FORMAT_X24S8_UINT
> PIPE_FORMAT_S8X24_UINT
> PIPE_FORMAT_X32_S8X24_UINT
>
> r600g and radeonsi already support it.
>
> I'm not sure how useful the CAP bit is, since you can just check if
> the stencil formats are supported as sampler views.
>
> Marek
>
>
> On Sat, May 3, 2014 at 4:42 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>> Adds a PIPE_CAP_STENCIL_SAMPLING to indicate support for the feature,
>> and a stencil_sampling bit in pipe_sampler_view to indicate that the
>> stencil should be sampled instead of the depth.
>>
>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>> ---
>>  src/gallium/docs/source/screen.rst               | 3 ++-
>>  src/gallium/drivers/freedreno/freedreno_screen.c | 1 +
>>  src/gallium/drivers/i915/i915_screen.c           | 1 +
>>  src/gallium/drivers/ilo/ilo_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/include/pipe/p_defines.h             | 1 +
>>  src/gallium/include/pipe/p_state.h               | 1 +
>>  15 files changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
>> index b292257..1451ad6 100644
>> --- a/src/gallium/docs/source/screen.rst
>> +++ b/src/gallium/docs/source/screen.rst
>> @@ -202,7 +202,8 @@ The integer capabilities:
>>    implemented.
>>  * ``PIPE_CAP_TEXTURE_GATHER_OFFSETS``: Whether the ``TG4`` instruction can
>>    accept 4 offsets.
>> -
>> +* ``PIPE_CAP_STENCIL_SAMPLING``: Whether sampling can be done on the stencil
>> +  component of DEPTH_STENCIL textures. Flag passed in ``pipe_sampler_view``.
>>
>>  .. _pipe_capf:
>>
>> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
>> index 4de3e3f..45390ed 100644
>> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
>> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
>> @@ -210,6 +210,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>         case PIPE_CAP_TEXTURE_QUERY_LOD:
>>         case PIPE_CAP_SAMPLE_SHADING:
>>         case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +       case PIPE_CAP_STENCIL_SAMPLING:
>>                 return 0;
>>
>>         /* Stream output. */
>> diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
>> index dfd7a2e..abc1d9b 100644
>> --- a/src/gallium/drivers/i915/i915_screen.c
>> +++ b/src/gallium/drivers/i915/i915_screen.c
>> @@ -222,6 +222,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
>>     case PIPE_CAP_TEXTURE_QUERY_LOD:
>>     case PIPE_CAP_SAMPLE_SHADING:
>>     case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +   case PIPE_CAP_STENCIL_SAMPLING:
>>        return 0;
>>
>>     case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
>> diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c
>> index 0a1c56d..8862b55 100644
>> --- a/src/gallium/drivers/ilo/ilo_screen.c
>> +++ b/src/gallium/drivers/ilo/ilo_screen.c
>> @@ -441,6 +441,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TEXTURE_QUERY_LOD:
>>     case PIPE_CAP_SAMPLE_SHADING:
>>     case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +   case PIPE_CAP_STENCIL_SAMPLING:
>>        return 0;
>>
>>     default:
>> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
>> index e236802..14bea7e 100644
>> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
>> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
>> @@ -243,6 +243,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TEXTURE_QUERY_LOD:
>>     case PIPE_CAP_SAMPLE_SHADING:
>>     case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +   case PIPE_CAP_STENCIL_SAMPLING:
>>        return 0;
>>     case PIPE_CAP_FAKE_SW_MSAA:
>>         return 1;
>> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> index 7157e0c..5734169 100644
>> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> @@ -137,6 +137,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_TEXTURE_QUERY_LOD:
>>     case PIPE_CAP_SAMPLE_SHADING:
>>     case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +   case PIPE_CAP_STENCIL_SAMPLING:
>>        return 0;
>>     case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
>>     case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> index fcac3c1..881da0e 100644
>> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> @@ -119,6 +119,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_TWO_SIDED_STENCIL:
>>     case PIPE_CAP_DEPTH_CLIP_DISABLE:
>>     case PIPE_CAP_POINT_SPRITE:
>> +   case PIPE_CAP_STENCIL_SAMPLING:
>>        return 1;
>>     case PIPE_CAP_SM3:
>>        return 1;
>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> index 2166788..e289322 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> @@ -105,6 +105,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_DEPTH_CLIP_DISABLE:
>>     case PIPE_CAP_POINT_SPRITE:
>>     case PIPE_CAP_TGSI_TEXCOORD:
>> +   case PIPE_CAP_STENCIL_SAMPLING:
>>        return 1;
>>     case PIPE_CAP_SM3:
>>        return 1;
>> diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
>> index 2c0fc49..f1e3fb8 100644
>> --- a/src/gallium/drivers/r300/r300_screen.c
>> +++ b/src/gallium/drivers/r300/r300_screen.c
>> @@ -175,6 +175,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>          case PIPE_CAP_FAKE_SW_MSAA:
>>          case PIPE_CAP_SAMPLE_SHADING:
>>          case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +        case PIPE_CAP_STENCIL_SAMPLING:
>>              return 0;
>>
>>          /* SWTCL-only features. */
>> diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
>> index 368307c..bbaaa27 100644
>> --- a/src/gallium/drivers/r600/r600_pipe.c
>> +++ b/src/gallium/drivers/r600/r600_pipe.c
>> @@ -316,6 +316,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>         case PIPE_CAP_TEXTURE_QUERY_LOD:
>>         case PIPE_CAP_SAMPLE_SHADING:
>>         case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +       case PIPE_CAP_STENCIL_SAMPLING:
>>                 return 0;
>>
>>         /* Stream output. */
>> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
>> index 027d332..e2fdbc3 100644
>> --- a/src/gallium/drivers/radeonsi/si_pipe.c
>> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
>> @@ -245,6 +245,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>         case PIPE_CAP_TEXTURE_QUERY_LOD:
>>         case PIPE_CAP_SAMPLE_SHADING:
>>         case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +       case PIPE_CAP_STENCIL_SAMPLING:
>>                 return 0;
>>
>>         case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
>> diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
>> index 316c512..97e9576 100644
>> --- a/src/gallium/drivers/softpipe/sp_screen.c
>> +++ b/src/gallium/drivers/softpipe/sp_screen.c
>> @@ -191,6 +191,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TEXTURE_QUERY_LOD:
>>     case PIPE_CAP_SAMPLE_SHADING:
>>     case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +   case PIPE_CAP_STENCIL_SAMPLING:
>>        return 0;
>>     case PIPE_CAP_FAKE_SW_MSAA:
>>        return 1;
>> diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
>> index 5281c48..41303df 100644
>> --- a/src/gallium/drivers/svga/svga_screen.c
>> +++ b/src/gallium/drivers/svga/svga_screen.c
>> @@ -275,6 +275,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TEXTURE_QUERY_LOD:
>>     case PIPE_CAP_SAMPLE_SHADING:
>>     case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>> +   case PIPE_CAP_STENCIL_SAMPLING:
>>        return 0;
>>     case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
>>        return 64;
>> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
>> index 5753bf9..0ee7232 100644
>> --- a/src/gallium/include/pipe/p_defines.h
>> +++ b/src/gallium/include/pipe/p_defines.h
>> @@ -558,6 +558,7 @@ enum pipe_cap {
>>     PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET = 96,
>>     PIPE_CAP_SAMPLE_SHADING = 97,
>>     PIPE_CAP_TEXTURE_GATHER_OFFSETS = 98,
>> +   PIPE_CAP_STENCIL_SAMPLING = 99,
>>  };
>>
>>  #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
>> diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
>> index a41c53d..57c2c80 100644
>> --- a/src/gallium/include/pipe/p_state.h
>> +++ b/src/gallium/include/pipe/p_state.h
>> @@ -379,6 +379,7 @@ struct pipe_sampler_view
>>     unsigned swizzle_g:3;         /**< PIPE_SWIZZLE_x for green component */
>>     unsigned swizzle_b:3;         /**< PIPE_SWIZZLE_x for blue component */
>>     unsigned swizzle_a:3;         /**< PIPE_SWIZZLE_x for alpha component */
>> +   unsigned stencil_sampling:1;  /**< whether to sample from stencil */
>>  };
>>
>>
>> --
>> 1.8.3.2
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list