[Mesa-dev] [PATCH 3/4] gallium: add PIPE_CAP_TGSI_DDIV capability

Roland Scheidegger sroland at vmware.com
Mon Jan 16 17:08:42 UTC 2017


Is a cap bit actually needed here or can we require drivers to
unconditionally support this (as long as they support doubles, of
course...)?
d3d11 has a requirement (if doubles are supported) that ddiv has an
accuracy of 0.5 ULP - emulating with mul + rcp clearly isn't allowed
(rcp, both the float and double variant, actually only has 1.0 ULP
requirement, but it doesn't even matter).
(Note that div, in contrast to ddiv, has explicitly allowed a*(1/b)
implementation.)

My guess is you'd actually never want this lowered. Noone uses doubles
for ordinary graphics for a reason - I suspect when someone does use
doubles he'd rather wants full accuracy...

Roland


Am 16.01.2017 um 17:20 schrieb Nicolai Hähnle:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
> 
> For drivers to indicate that they don't want double-precision divides
> to be lowered into rcp+mul.
> ---
>  src/gallium/docs/source/screen.rst               | 2 ++
>  src/gallium/drivers/freedreno/freedreno_screen.c | 3 ++-
>  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             | 3 ++-
>  src/gallium/drivers/radeonsi/si_pipe.c           | 3 ++-
>  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 +
>  17 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
> index 000551a..4d79104 100644
> --- a/src/gallium/docs/source/screen.rst
> +++ b/src/gallium/docs/source/screen.rst
> @@ -369,6 +369,8 @@ The integer capabilities:
>  * ``PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY``: Tell the GLSL compiler to use
>    the minimum amount of optimizations just to be able to do all the linking
>    and lowering.
> +* ``PIPE_CAP_TGSI_DDIV``: Indicates that the TGSI DDIV instruction for double
> +  division is supported and preferred over a DRCP+DMUL sequence.
>  
>  
>  .. _pipe_capf:
> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
> index 2ff89eb..d6fdb77 100644
> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
> @@ -295,7 +295,8 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>  	case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
>  	case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
>  	case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
> -        case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +	case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +	case PIPE_CAP_TGSI_DDIV:
>  		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 18578c0..8791105 100644
> --- a/src/gallium/drivers/i915/i915_screen.c
> +++ b/src/gallium/drivers/i915/i915_screen.c
> @@ -297,6 +297,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
>     case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>     case PIPE_CAP_NATIVE_FENCE_FD:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        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 20a0e8d..916c1c9 100644
> --- a/src/gallium/drivers/ilo/ilo_screen.c
> +++ b/src/gallium/drivers/ilo/ilo_screen.c
> @@ -520,6 +520,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>     case PIPE_CAP_NATIVE_FENCE_FD:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        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 4501df4..3248c4d 100644
> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
> @@ -341,6 +341,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>     case PIPE_CAP_NATIVE_FENCE_FD:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        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 19df068..586a85c 100644
> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> @@ -206,6 +206,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>     case PIPE_CAP_NATIVE_FENCE_FD:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        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 5637001..3cf5724 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> @@ -258,6 +258,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>     case PIPE_CAP_NATIVE_FENCE_FD:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        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 b6e4c6c..de00565 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> @@ -275,6 +275,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>     case PIPE_CAP_NATIVE_FENCE_FD:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        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 50a42ef..bfce22e 100644
> --- a/src/gallium/drivers/r300/r300_screen.c
> +++ b/src/gallium/drivers/r300/r300_screen.c
> @@ -228,6 +228,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>          case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>          case PIPE_CAP_NATIVE_FENCE_FD:
>          case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +        case PIPE_CAP_TGSI_DDIV:
>              return 0;
>  
>          /* SWTCL-only features. */
> diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
> index a0da24f..263d09c 100644
> --- a/src/gallium/drivers/r600/r600_pipe.c
> +++ b/src/gallium/drivers/r600/r600_pipe.c
> @@ -376,7 +376,8 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>  	case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
>  	case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>  	case PIPE_CAP_NATIVE_FENCE_FD:
> -        case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +	case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +	case PIPE_CAP_TGSI_DDIV:
>  		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 842eb59..fdf9bee 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.c
> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
> @@ -413,7 +413,8 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>  	case PIPE_CAP_CULL_DISTANCE:
>  	case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
>  	case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
> -        case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +	case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +	case PIPE_CAP_TGSI_DDIV:
>  		return 1;
>  
>  	case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
> diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
> index 93c7503..ab1a877 100644
> --- a/src/gallium/drivers/softpipe/sp_screen.c
> +++ b/src/gallium/drivers/softpipe/sp_screen.c
> @@ -291,6 +291,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>     case PIPE_CAP_NATIVE_FENCE_FD:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        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 3e27474..2ae4ee7 100644
> --- a/src/gallium/drivers/svga/svga_screen.c
> +++ b/src/gallium/drivers/svga/svga_screen.c
> @@ -422,6 +422,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
>     case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        return 0;
>     }
>  
> diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp
> index 5012388..bca6047 100644
> --- a/src/gallium/drivers/swr/swr_screen.cpp
> +++ b/src/gallium/drivers/swr/swr_screen.cpp
> @@ -315,6 +315,7 @@ swr_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
>     case PIPE_CAP_NATIVE_FENCE_FD:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        return 0;
>  
>     case PIPE_CAP_VENDOR_ID:
> diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
> index 3da6202..7318425 100644
> --- a/src/gallium/drivers/vc4/vc4_screen.c
> +++ b/src/gallium/drivers/vc4/vc4_screen.c
> @@ -242,6 +242,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>          case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>          case PIPE_CAP_NATIVE_FENCE_FD:
>          case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +        case PIPE_CAP_TGSI_DDIV:
>                  return 0;
>  
>                  /* Stream output. */
> diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
> index 0a18aa0..05bdd37 100644
> --- a/src/gallium/drivers/virgl/virgl_screen.c
> +++ b/src/gallium/drivers/virgl/virgl_screen.c
> @@ -252,6 +252,7 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
>     case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
> +   case PIPE_CAP_TGSI_DDIV:
>        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 7dfd7dd..28e134c 100644
> --- a/src/gallium/include/pipe/p_defines.h
> +++ b/src/gallium/include/pipe/p_defines.h
> @@ -744,6 +744,7 @@ enum pipe_cap
>     PIPE_CAP_TGSI_CAN_READ_OUTPUTS,
>     PIPE_CAP_NATIVE_FENCE_FD,
>     PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY,
> +   PIPE_CAP_TGSI_DDIV,
>  };
>  
>  #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
> 



More information about the mesa-dev mailing list