[Mesa-dev] [PATCH 1/8] gallium: add separate PIPE_CAP_INT64_DIVMOD

Nicolai Hähnle nhaehnle at gmail.com
Mon Feb 6 11:52:27 UTC 2017


On 05.02.2017 19:20, Ilia Mirkin wrote:
> Nouveau does not currently have logic to implement this as a library
> function. Even though such a library could be written, there's no big
> advantage to do it that way for now given that int64 is a very uncommon
> use-case. Allow a driver to expose INT64 without supporting division and
> modulo operations.

Seems reasonable. This patch is:

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>


>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  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/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_glsl_to_tgsi.cpp       | 3 +++
>  18 files changed, 21 insertions(+)
>
> diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
> index 4f5b4bb..74c8cec 100644
> --- a/src/gallium/docs/source/screen.rst
> +++ b/src/gallium/docs/source/screen.rst
> @@ -376,6 +376,8 @@ The integer capabilities:
>  * ``PIPE_CAP_DOUBLES``: Whether double precision floating-point operations
>    are supported.
>  * ``PIPE_CAP_INT64``: Whether 64-bit integer operations are supported.
> +* ``PIPE_CAP_INT64_DIVMOD``: Whether 64-bit integer division/modulo
> +  operations are supported.
>
>
>  .. _pipe_capf:
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index 8f2882f..e3090dc 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -243,6 +243,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_MUL_ZERO_WINS:
>     case PIPE_CAP_DOUBLES:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        return 0;
>
>     /* Stream output. */
> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
> index bc8a277..1122e29 100644
> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
> @@ -300,6 +300,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>  	case PIPE_CAP_TGSI_MUL_ZERO_WINS:
>  	case PIPE_CAP_DOUBLES:
>  	case PIPE_CAP_INT64:
> +	case PIPE_CAP_INT64_DIVMOD:
>  		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 76f20fc..038cca1 100644
> --- a/src/gallium/drivers/i915/i915_screen.c
> +++ b/src/gallium/drivers/i915/i915_screen.c
> @@ -300,6 +300,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
>     case PIPE_CAP_TGSI_MUL_ZERO_WINS:
>     case PIPE_CAP_DOUBLES:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        return 0;
>
>     case PIPE_CAP_MAX_VIEWPORTS:
> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
> index 0b12119..76a30a6 100644
> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
> @@ -269,6 +269,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
>     case PIPE_CAP_DOUBLES:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        return 1;
>
>     case PIPE_CAP_VENDOR_ID:
> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> index b43d852..6c58a0a 100644
> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
> @@ -210,6 +210,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_MUL_ZERO_WINS:
>     case PIPE_CAP_DOUBLES:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        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 32c3de3..aa756ed 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
> @@ -262,6 +262,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_FS_FBFETCH:
>     case PIPE_CAP_DOUBLES:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        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 b995cde..e99dc4c 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
> @@ -282,6 +282,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>     case PIPE_CAP_NATIVE_FENCE_FD:
>     case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        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 1410740..7ea6a1c 100644
> --- a/src/gallium/drivers/r300/r300_screen.c
> +++ b/src/gallium/drivers/r300/r300_screen.c
> @@ -232,6 +232,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>          case PIPE_CAP_TGSI_MUL_ZERO_WINS:
>          case PIPE_CAP_DOUBLES:
>          case PIPE_CAP_INT64:
> +        case PIPE_CAP_INT64_DIVMOD:
>              return 0;
>
>          /* SWTCL-only features. */
> diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
> index 2cc16b2..5290f40 100644
> --- a/src/gallium/drivers/r600/r600_pipe.c
> +++ b/src/gallium/drivers/r600/r600_pipe.c
> @@ -379,6 +379,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>  	case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
>  	case PIPE_CAP_TGSI_FS_FBFETCH:
>  	case PIPE_CAP_INT64:
> +	case PIPE_CAP_INT64_DIVMOD:
>  		return 0;
>
>  	case PIPE_CAP_DOUBLES:
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
> index 8ce4d50..853d850 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.c
> +++ b/src/gallium/drivers/radeonsi/si_pipe.c
> @@ -419,6 +419,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
>  	case PIPE_CAP_DOUBLES:
>  		return HAVE_LLVM >= 0x0307;
>  	case PIPE_CAP_INT64:
> +	case PIPE_CAP_INT64_DIVMOD:
>  		return HAVE_LLVM >= 0x0309;
>
>  	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 fd7ce25..02eff91 100644
> --- a/src/gallium/drivers/softpipe/sp_screen.c
> +++ b/src/gallium/drivers/softpipe/sp_screen.c
> @@ -167,6 +167,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT:
>     case PIPE_CAP_DOUBLES:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        return 1;
>     case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
>        return 16;
> diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
> index f404fb5..f9dfcd2 100644
> --- a/src/gallium/drivers/svga/svga_screen.c
> +++ b/src/gallium/drivers/svga/svga_screen.c
> @@ -426,6 +426,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_MUL_ZERO_WINS:
>     case PIPE_CAP_DOUBLES:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        return 0;
>     }
>
> diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp
> index 52c6049..f4fe1f3 100644
> --- a/src/gallium/drivers/swr/swr_screen.cpp
> +++ b/src/gallium/drivers/swr/swr_screen.cpp
> @@ -318,6 +318,7 @@ swr_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_FS_FBFETCH:
>     case PIPE_CAP_TGSI_MUL_ZERO_WINS:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        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 76f12ac..5cc0b04 100644
> --- a/src/gallium/drivers/vc4/vc4_screen.c
> +++ b/src/gallium/drivers/vc4/vc4_screen.c
> @@ -246,6 +246,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>          case PIPE_CAP_TGSI_MUL_ZERO_WINS:
>          case PIPE_CAP_DOUBLES:
>          case PIPE_CAP_INT64:
> +        case PIPE_CAP_INT64_DIVMOD:
>                  return 0;
>
>                  /* Stream output. */
> diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
> index 39df5f6..49df4f2 100644
> --- a/src/gallium/drivers/virgl/virgl_screen.c
> +++ b/src/gallium/drivers/virgl/virgl_screen.c
> @@ -255,6 +255,7 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
>     case PIPE_CAP_TGSI_FS_FBFETCH:
>     case PIPE_CAP_TGSI_MUL_ZERO_WINS:
>     case PIPE_CAP_INT64:
> +   case PIPE_CAP_INT64_DIVMOD:
>        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 9915957..1d6d264 100644
> --- a/src/gallium/include/pipe/p_defines.h
> +++ b/src/gallium/include/pipe/p_defines.h
> @@ -754,6 +754,7 @@ enum pipe_cap
>     PIPE_CAP_TGSI_MUL_ZERO_WINS,
>     PIPE_CAP_DOUBLES,
>     PIPE_CAP_INT64,
> +   PIPE_CAP_INT64_DIVMOD,
>  };
>
>  #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 77a51d5..8151bcd 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -7044,6 +7044,9 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
>                                               options->EmitNoIndirectUniform);
>        }
>
> +      if (!pscreen->get_param(pscreen, PIPE_CAP_INT64_DIVMOD))
> +         lower_64bit_integer_instructions(ir, DIV64 | MOD64);
> +
>        if (ctx->Extensions.ARB_shading_language_packing) {
>           unsigned lower_inst = LOWER_PACK_SNORM_2x16 |
>                                 LOWER_UNPACK_SNORM_2x16 |
>



More information about the mesa-dev mailing list