[Mesa-dev] [PATCH v2 2/4] gallium: add a texture target to sampler view and a CAP to use it

Roland Scheidegger sroland at vmware.com
Thu Aug 21 11:29:09 PDT 2014


Am 21.08.2014 19:39, schrieb Ilia Mirkin:
> On Thu, Aug 21, 2014 at 1:35 PM, Roland Scheidegger <sroland at vmware.com> wrote:
>> Am 21.08.2014 04:42, schrieb Ilia Mirkin:
>>> This allows a sampler view to have a different texture target than the
>>> underlying resource. This will be used to implement the type casting
>>> between 2d arrays and cube maps as specified in ARB_texture_view.
>>>
>>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>>> ---
>>>  src/gallium/auxiliary/util/u_sampler.c           | 1 +
>>>  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/drivers/vc4/vc4_screen.c             | 1 +
>>>  src/gallium/include/pipe/p_defines.h             | 1 +
>>>  src/gallium/include/pipe/p_state.h               | 1 +
>>>  17 files changed, 19 insertions(+)
>>>
>>> diff --git a/src/gallium/auxiliary/util/u_sampler.c b/src/gallium/auxiliary/util/u_sampler.c
>>> index 227641b..86799fd 100644
>>> --- a/src/gallium/auxiliary/util/u_sampler.c
>>> +++ b/src/gallium/auxiliary/util/u_sampler.c
>>> @@ -45,6 +45,7 @@ default_template(struct pipe_sampler_view *view,
>>>     /* XXX: Check if format is compatible with texture->format.
>>>      */
>>>
>>> +   view->target = texture->target;
>>>     view->format = format;
>>>     view->u.tex.first_level = 0;
>>>     view->u.tex.last_level = texture->last_level;
>>> diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
>>> index eee254e..8feeb56 100644
>>> --- a/src/gallium/docs/source/screen.rst
>>> +++ b/src/gallium/docs/source/screen.rst
>>> @@ -225,6 +225,9 @@ The integer capabilities:
>>>    memory and GART.
>>>  * ``PIPE_CAP_CONDITIONAL_RENDER_INVERTED``: Whether the driver supports inverted
>>>    condition for conditional rendering.
>>> +* ``PIPE_CAP_SAMPLER_VIEW_TARGET``: Whether the sampler view's target can be
>>> +  different than the underlying resource's. This can happen when casting
>>> +  between 2d array and cube map (array) textures.
>> I'd like to see some more precise language, because even if the difference
>> between array and non-array textures may seem trivial and not matter
>> much usually,
>> it can happen too. Just a minor nitpick, though.
> 
> Happy to provide any language you deem appropriate. Perhaps only some
> differences need to be handled? I guess even nouveau wouldn't be
> particularly happy if you tried to cast a 3d texture to a cube map
> because of how levels work.
Well maybe just say something like for casting targets need to be
compatible as defined by ARB_texture_view (for instance 2d array <-> cube).
Clearly noone allows casting along the dimension axis.

Roland


> 
>>
>>>
>>>  .. _pipe_capf:
>>> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
>>> index ab1a740..165ec8d 100644
>>> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
>>> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
>>> @@ -218,6 +218,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>>       case PIPE_CAP_DRAW_INDIRECT:
>>>       case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>>       case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>> +     case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>               return 0;
>>>
>>>       /* Stream output. */
>>> diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
>>> index 40976b3..4b70abe 100644
>>> --- a/src/gallium/drivers/i915/i915_screen.c
>>> +++ b/src/gallium/drivers/i915/i915_screen.c
>>> @@ -234,6 +234,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
>>>     case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
>>>     case PIPE_CAP_DRAW_INDIRECT:
>>>     case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>> +   case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>        return 0;
>>>
>>>     case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
>>> diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c
>>> index 15658da..9200f55 100644
>>> --- a/src/gallium/drivers/ilo/ilo_screen.c
>>> +++ b/src/gallium/drivers/ilo/ilo_screen.c
>>> @@ -436,6 +436,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>>     case PIPE_CAP_DRAW_INDIRECT:
>>>     case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>>     case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>> +   case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>        return 0;
>>>
>>>     case PIPE_CAP_VENDOR_ID:
>>> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
>>> index 2a6e673..b10ddfb 100644
>>> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
>>> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
>>> @@ -250,6 +250,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>>     case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>>>     case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
>>>     case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>> +   case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>        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 80d6943..947140a 100644
>>> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>>> @@ -153,6 +153,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>>     case PIPE_CAP_DRAW_INDIRECT:
>>>     case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>>     case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>> +   case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>        return 0;
>>>
>>>     case PIPE_CAP_VENDOR_ID:
>>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>>> index 99dcdc5..bf777a3 100644
>>> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>>> @@ -201,6 +201,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>>     case PIPE_CAP_COMPUTE:
>>>     case PIPE_CAP_DRAW_INDIRECT:
>>>     case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>> +   case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>        return 0;
>>>
>>>     case PIPE_CAP_VENDOR_ID:
>>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>>> index 84025ef..50c82d2 100644
>>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>>> @@ -185,6 +185,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>>     case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT:
>>>     case PIPE_CAP_FAKE_SW_MSAA:
>>>     case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
>>> +   case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>        return 0;
>>>
>>>     case PIPE_CAP_VENDOR_ID:
>>> diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
>>> index a64f5f5..aaae496 100644
>>> --- a/src/gallium/drivers/r300/r300_screen.c
>>> +++ b/src/gallium/drivers/r300/r300_screen.c
>>> @@ -180,6 +180,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>>          case PIPE_CAP_DRAW_INDIRECT:
>>>          case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>>          case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>> +        case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>              return 0;
>>>
>>>          /* SWTCL-only features. */
>>> diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
>>> index e02c053..cc18c26 100644
>>> --- a/src/gallium/drivers/r600/r600_pipe.c
>>> +++ b/src/gallium/drivers/r600/r600_pipe.c
>>> @@ -320,6 +320,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>>       case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>>>       case PIPE_CAP_DRAW_INDIRECT:
>>>       case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>> +     case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>               return 0;
>>>
>>>       /* Stream output. */
>>> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
>>> index ae1d043..8abcca0 100644
>>> --- a/src/gallium/drivers/radeonsi/si_pipe.c
>>> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
>>> @@ -256,6 +256,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>>       case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
>>>       case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>>       case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>> +     case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>               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 d54112c..14ed38e 100644
>>> --- a/src/gallium/drivers/softpipe/sp_screen.c
>>> +++ b/src/gallium/drivers/softpipe/sp_screen.c
>>> @@ -196,6 +196,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>>     case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>>>     case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
>>>     case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>> +   case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>        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 544d929..0d0626f 100644
>>> --- a/src/gallium/drivers/svga/svga_screen.c
>>> +++ b/src/gallium/drivers/svga/svga_screen.c
>>> @@ -280,6 +280,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>>     case PIPE_CAP_DRAW_INDIRECT:
>>>     case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>>     case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>> +   case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>        return 0;
>>>     case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
>>>        return 64;
>>> diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
>>> index 4a86e21..7469afc 100644
>>> --- a/src/gallium/drivers/vc4/vc4_screen.c
>>> +++ b/src/gallium/drivers/vc4/vc4_screen.c
>>> @@ -160,6 +160,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>>          case PIPE_CAP_DRAW_INDIRECT:
>>>          case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>>          case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
>>> +        case PIPE_CAP_SAMPLER_VIEW_TARGET:
>>>                  return 0;
>>>
>>>                  /* Stream output. */
>>> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
>>> index 04e4798..09ec179 100644
>>> --- a/src/gallium/include/pipe/p_defines.h
>>> +++ b/src/gallium/include/pipe/p_defines.h
>>> @@ -569,6 +569,7 @@ enum pipe_cap {
>>>     PIPE_CAP_VIDEO_MEMORY = 106,
>>>     PIPE_CAP_UMA = 107,
>>>     PIPE_CAP_CONDITIONAL_RENDER_INVERTED = 108,
>>> +   PIPE_CAP_SAMPLER_VIEW_TARGET = 109,
>>>  };
>>>
>>>  #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 a82686b..36d253c 100644
>>> --- a/src/gallium/include/pipe/p_state.h
>>> +++ b/src/gallium/include/pipe/p_state.h
>>> @@ -361,6 +361,7 @@ struct pipe_surface
>>>  struct pipe_sampler_view
>>>  {
>>>     struct pipe_reference reference;
>>> +   enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
>>>     enum pipe_format format;      /**< typed PIPE_FORMAT_x */
>>>     struct pipe_resource *texture; /**< texture into which this is a view  */
>>>     struct pipe_context *context; /**< context this view belongs to */
>>>
>>
>> It would be good though to get some other feedback, personally I think
>> this solution is ok.
>>
>> 1/4, 2/4 are
>> Reviewed-by: Roland Scheidegger <sroland at vmware.com>
> 
> Thanks for your feedback so far. I'll wait for some more R-b's (still
> need 3/4 anyways)
> 
>   -ilia
> 



More information about the mesa-dev mailing list