[Mesa-dev] [PATCH 1/2] glsl: add subpass image type
Jason Ekstrand
jason at jlekstrand.net
Fri Sep 16 04:47:01 UTC 2016
On Thu, Sep 15, 2016 at 1:23 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> SPIR-V/Vulkan have a special image type for input attachments
> called the subpass type. It has different characteristics than
> other images types.
>
> The main one being it can only be an input image to fragment
> shaders and loads from it are relative to the frag coord.
>
> This adds support for it to the GLSL types. Unfortunately
> we've run out of space in the sampler dim in types, so we
> need to use another bit.
> ---
> src/compiler/builtin_type_macros.h | 2 ++
> src/compiler/glsl_types.cpp | 12 ++++++++++++
> src/compiler/glsl_types.h | 5 +++--
> src/compiler/nir/nir.h | 1 +
> 4 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/builtin_type_macros.h
> b/src/compiler/builtin_type_macros.h
> index da3f19e..8af0e2a 100644
> --- a/src/compiler/builtin_type_macros.h
> +++ b/src/compiler/builtin_type_macros.h
> @@ -159,6 +159,8 @@ DECL_TYPE(uimageCubeArray,
> GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY, GLSL_TYPE
> DECL_TYPE(uimage2DMS, GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE,
> GLSL_TYPE_IMAGE, GLSL_SAMPLER_DIM_MS, 0, 0, GLSL_TYPE_UINT)
> DECL_TYPE(uimage2DMSArray, GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY,
> GLSL_TYPE_IMAGE, GLSL_SAMPLER_DIM_MS, 0, 1, GLSL_TYPE_UINT)
>
> +DECL_TYPE(imageSubpass, 0,
> GLSL_TYPE_IMAGE, GLSL_SAMPLER_DIM_SUBPASS,0, 0, GLSL_TYPE_FLOAT)
>
We should probably call this subpassInput to match the GLSL Vulkan spec.
> +
> DECL_TYPE(atomic_uint, GL_UNSIGNED_INT_ATOMIC_COUNTER,
> GLSL_TYPE_ATOMIC_UINT, 1, 1)
>
> STRUCT_TYPE(gl_DepthRangeParameters)
> diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
> index 641644d..bf72419 100644
> --- a/src/compiler/glsl_types.cpp
> +++ b/src/compiler/glsl_types.cpp
> @@ -674,6 +674,8 @@ glsl_type::get_sampler_instance(enum glsl_sampler_dim
> dim,
> return error_type;
> else
> return samplerExternalOES_type;
> + case GLSL_SAMPLER_DIM_SUBPASS:
> + return error_type;
> }
> case GLSL_TYPE_INT:
> if (shadow)
> @@ -701,6 +703,8 @@ glsl_type::get_sampler_instance(enum glsl_sampler_dim
> dim,
> return (array ? isampler2DMSArray_type : isampler2DMS_type);
> case GLSL_SAMPLER_DIM_EXTERNAL:
> return error_type;
> + case GLSL_SAMPLER_DIM_SUBPASS:
> + return error_type;
> }
> case GLSL_TYPE_UINT:
> if (shadow)
> @@ -728,6 +732,8 @@ glsl_type::get_sampler_instance(enum glsl_sampler_dim
> dim,
> return (array ? usampler2DMSArray_type : usampler2DMS_type);
> case GLSL_SAMPLER_DIM_EXTERNAL:
> return error_type;
> + case GLSL_SAMPLER_DIM_SUBPASS:
> + return error_type;
> }
> default:
> return error_type;
> @@ -740,6 +746,8 @@ const glsl_type *
> glsl_type::get_image_instance(enum glsl_sampler_dim dim,
> bool array, glsl_base_type type)
> {
> + if (dim == GLSL_SAMPLER_DIM_SUBPASS)
> + return imageSubpass_type;
> switch (type) {
> case GLSL_TYPE_FLOAT:
> switch (dim) {
> @@ -764,6 +772,7 @@ glsl_type::get_image_instance(enum glsl_sampler_dim
> dim,
> case GLSL_SAMPLER_DIM_MS:
> return (array ? image2DMSArray_type : image2DMS_type);
> case GLSL_SAMPLER_DIM_EXTERNAL:
> + case GLSL_SAMPLER_DIM_SUBPASS:
> return error_type;
> }
> case GLSL_TYPE_INT:
> @@ -789,6 +798,7 @@ glsl_type::get_image_instance(enum glsl_sampler_dim
> dim,
> case GLSL_SAMPLER_DIM_MS:
> return (array ? iimage2DMSArray_type : iimage2DMS_type);
> case GLSL_SAMPLER_DIM_EXTERNAL:
> + case GLSL_SAMPLER_DIM_SUBPASS:
> return error_type;
> }
> case GLSL_TYPE_UINT:
> @@ -814,6 +824,7 @@ glsl_type::get_image_instance(enum glsl_sampler_dim
> dim,
> case GLSL_SAMPLER_DIM_MS:
> return (array ? uimage2DMSArray_type : uimage2DMS_type);
> case GLSL_SAMPLER_DIM_EXTERNAL:
> + case GLSL_SAMPLER_DIM_SUBPASS:
> return error_type;
> }
> default:
> @@ -1975,6 +1986,7 @@ glsl_type::coordinate_components() const
> case GLSL_SAMPLER_DIM_RECT:
> case GLSL_SAMPLER_DIM_MS:
> case GLSL_SAMPLER_DIM_EXTERNAL:
> + case GLSL_SAMPLER_DIM_SUBPASS:
> size = 2;
> break;
> case GLSL_SAMPLER_DIM_3D:
> diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
> index 7c4827d..b1e2f7a 100644
> --- a/src/compiler/glsl_types.h
> +++ b/src/compiler/glsl_types.h
> @@ -80,7 +80,8 @@ enum glsl_sampler_dim {
> GLSL_SAMPLER_DIM_RECT,
> GLSL_SAMPLER_DIM_BUF,
> GLSL_SAMPLER_DIM_EXTERNAL,
> - GLSL_SAMPLER_DIM_MS
> + GLSL_SAMPLER_DIM_MS,
> + GLSL_SAMPLER_DIM_SUBPASS, /* for vulkan input attachments */
> };
>
> enum glsl_interface_packing {
> @@ -127,7 +128,7 @@ struct glsl_type {
> GLenum gl_type;
> glsl_base_type base_type;
>
> - unsigned sampler_dimensionality:3; /**< \see glsl_sampler_dim */
> + unsigned sampler_dimensionality:4; /**< \see glsl_sampler_dim */
> unsigned sampler_shadow:1;
> unsigned sampler_array:1;
> unsigned sampled_type:2; /**< Type of data returned using this
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index ff7c422..95659d5 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -1198,6 +1198,7 @@ nir_tex_instr_dest_size(nir_tex_instr *instr)
> case GLSL_SAMPLER_DIM_MS:
> case GLSL_SAMPLER_DIM_RECT:
> case GLSL_SAMPLER_DIM_EXTERNAL:
> + case GLSL_SAMPLER_DIM_SUBPASS:
> ret = 2;
> break;
> case GLSL_SAMPLER_DIM_3D:
> --
> 2.5.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160915/107d6897/attachment-0001.html>
More information about the mesa-dev
mailing list