[Mesa-dev] [PATCH] gallium: add a cap for VIEWPORT_SUBPIXEL_BITS

Marek Olšák maraeo at gmail.com
Mon Jul 18 11:35:04 UTC 2016


On Sat, Jul 16, 2016 at 11:51 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> On Sat, Jul 16, 2016 at 7:47 AM, Józef Kucia <joseph.kucia at gmail.com> wrote:
>> This allows Gallium drivers to advertise the subpixel precision
>> for floating point viewports bounds.
>>
>> Signed-off-by: Józef Kucia <joseph.kucia at gmail.com>
>> ---
>>
>> Currently all Mesa drivers return 0 for GL_VIEWPORT_SUBPIXEL_BITS
>> regardless whether floating point viewport bounds are supported.
>>
>> From the ARB_viewport_array spec:
>>
>>   "More specifically, if VIEWPORT_SUBPIXEL_BITS is zero, then
>>   this indicates that the viewport bounds are likely implemented
>>   using integers in hardware."
>>
>>
>> I do not have commit access.
>>
>> ---
>>  src/gallium/docs/source/screen.rst               | 2 ++
>>  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/swr/swr_screen.cpp           | 1 +
>>  src/gallium/drivers/vc4/vc4_screen.c             | 1 +
>>  src/gallium/drivers/virgl/virgl_screen.c         | 1 +
>>  src/gallium/include/pipe/p_defines.h             | 1 +
>>  src/mesa/state_tracker/st_extensions.c           | 2 ++
>>  18 files changed, 20 insertions(+)
>>
>> diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
>> index 141b45a..34f2e72 100644
>> --- a/src/gallium/docs/source/screen.rst
>> +++ b/src/gallium/docs/source/screen.rst
>> @@ -345,6 +345,8 @@ The integer capabilities:
>>    supported in ``set_window_rectangles``.
>>  * ``PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED``: If true, the driver implements support
>>    for ``pipe_rasterizer_state::offset_units_unscaled``.
>> +* ``PIPE_CAP_VIEWPORT_SUBPIXEL_BITS``: Number of bits of subpixel precision for
>> +  floating point viewport bounds.
>>
>>
>>  .. _pipe_capf:
>> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
>> index 5255c10..81fb2ad 100644
>> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
>> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
>> @@ -267,6 +267,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>         case PIPE_CAP_TGSI_VOTE:
>>         case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>         case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +       case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>                 return 0;
>>
>>         case PIPE_CAP_MAX_VIEWPORTS:
>> diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
>> index 3f0ab98..6b5218b 100644
>> --- a/src/gallium/drivers/i915/i915_screen.c
>> +++ b/src/gallium/drivers/i915/i915_screen.c
>> @@ -290,6 +290,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
>>     case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
>>     case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
>>     case PIPE_CAP_SAMPLER_VIEW_TARGET:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        return 0;
>>
>>     case PIPE_CAP_MAX_VIEWPORTS:
>> diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c
>> index 2024688..448f512 100644
>> --- a/src/gallium/drivers/ilo/ilo_screen.c
>> +++ b/src/gallium/drivers/ilo/ilo_screen.c
>> @@ -505,6 +505,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TGSI_VOTE:
>>     case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>     case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        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 684c7a5..61c3fb7 100644
>> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
>> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
>> @@ -328,6 +328,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TGSI_VOTE:
>>     case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>     case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        return 0;
>>     }
>>     /* should only get here on unhandled cases */
>> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> index 68d8317..3d75021 100644
>> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
>> @@ -199,6 +199,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_TGSI_VOTE:
>>     case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>     case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        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 303ecf1..d18a768 100644
>> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
>> @@ -253,6 +253,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
>>     case PIPE_CAP_TGSI_VOTE:
>>     case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        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 f681631..ea874e6 100644
>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
>> @@ -265,6 +265,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>     case PIPE_CAP_PCI_BUS:
>>     case PIPE_CAP_PCI_DEVICE:
>>     case PIPE_CAP_PCI_FUNCTION:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        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 d47b70d..7d2ea4a 100644
>> --- a/src/gallium/drivers/r300/r300_screen.c
>> +++ b/src/gallium/drivers/r300/r300_screen.c
>> @@ -221,6 +221,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>          case PIPE_CAP_TGSI_VOTE:
>>          case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>          case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +        case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>              return 0;
>>
>>          /* SWTCL-only features. */
>> diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
>> index f23daf9..6bd027b 100644
>> --- a/src/gallium/drivers/r600/r600_pipe.c
>> +++ b/src/gallium/drivers/r600/r600_pipe.c
>> @@ -371,6 +371,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>         case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
>>         case PIPE_CAP_TGSI_VOTE:
>>         case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>> +       case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>                 return 0;
>>
>>         case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
>> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
>> index ee97bcf..768dc8c 100644
>> --- a/src/gallium/drivers/radeonsi/si_pipe.c
>> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
>> @@ -444,6 +444,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>>         case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
>>         case PIPE_CAP_TGSI_VOTE:
>>         case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>> +       case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>                 return 0;
>>
>>         case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
>> diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
>> index 93022db..e80c1aa 100644
>> --- a/src/gallium/drivers/softpipe/sp_screen.c
>> +++ b/src/gallium/drivers/softpipe/sp_screen.c
>> @@ -278,6 +278,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TGSI_VOTE:
>>     case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>     case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        return 0;
>>     case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
>>        return 4;
>> diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
>> index 5b4ac74..13253ac 100644
>> --- a/src/gallium/drivers/svga/svga_screen.c
>> +++ b/src/gallium/drivers/svga/svga_screen.c
>> @@ -412,6 +412,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TGSI_VOTE:
>>     case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>     case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        return 0;
>>     }
>>
>> diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp
>> index d478405..e0e59fa 100644
>> --- a/src/gallium/drivers/swr/swr_screen.cpp
>> +++ b/src/gallium/drivers/swr/swr_screen.cpp
>> @@ -364,6 +364,7 @@ swr_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TGSI_VOTE:
>>     case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>     case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        return 0;
>>     }
>>
>> diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
>> index 29c0f94..5c17c55 100644
>> --- a/src/gallium/drivers/vc4/vc4_screen.c
>> +++ b/src/gallium/drivers/vc4/vc4_screen.c
>> @@ -217,6 +217,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>>          case PIPE_CAP_TGSI_VOTE:
>>          case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>          case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +        case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>                  return 0;
>>
>>                  /* Stream output. */
>> diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
>> index 82e7f13..fd3d35d 100644
>> --- a/src/gallium/drivers/virgl/virgl_screen.c
>> +++ b/src/gallium/drivers/virgl/virgl_screen.c
>> @@ -246,6 +246,7 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
>>     case PIPE_CAP_TGSI_VOTE:
>>     case PIPE_CAP_MAX_WINDOW_RECTANGLES:
>>     case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
>> +   case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>>        return 0;
>>     case PIPE_CAP_VENDOR_ID:
>>        return 0x1af4;
>> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
>> index 62fa673..3ab6c2f 100644
>> --- a/src/gallium/include/pipe/p_defines.h
>> +++ b/src/gallium/include/pipe/p_defines.h
>> @@ -732,6 +732,7 @@ enum pipe_cap
>>     PIPE_CAP_TGSI_VOTE,
>>     PIPE_CAP_MAX_WINDOW_RECTANGLES,
>>     PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED,
>> +   PIPE_CAP_VIEWPORT_SUBPIXEL_BITS,
>>  };
>>
>>  #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
>> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
>> index 3d27ca3..722df5c 100644
>> --- a/src/mesa/state_tracker/st_extensions.c
>> +++ b/src/mesa/state_tracker/st_extensions.c
>> @@ -1100,6 +1100,8 @@ void st_init_extensions(struct pipe_screen *screen,
>>           consts->ViewportBounds.Min = -16384.0;
>>           consts->ViewportBounds.Max = 16383.0;
>>        }
>> +      consts->ViewportSubpixelBits =
>> +         screen->get_param(screen, PIPE_CAP_VIEWPORT_SUBPIXEL_BITS);
>
> Normally such things go into st_init_limits.
>
> Of course none of this actually changes backends to return > 0 bits...
> did you mean to follow up with further patches?

FWIW, r600 and radeonsi should return 8.

Marek


More information about the mesa-dev mailing list