[Mesa-dev] [PATCH v2 21/31] glsl: allow bindless samplers/images to be l-values

Nicolai Hähnle nhaehnle at gmail.com
Wed Apr 26 07:48:45 UTC 2017


On 24.04.2017 12:35, Samuel Pitoiset wrote:
> The ARB_bindless_texture spec says:
>
>    "Replace Section 4.1.7 (Samplers), p. 25"
>
>    "Samplers can be used as l-values, so can be assigned into and
>    used as "out" and "inout" function parameters."
>
>    "Replace Section 4.1.X, (Images)"
>
>    "Images can be used as l-values, so can be assigned into and
>     used as "out" and "inout" function parameters."
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/compiler/glsl/ir.cpp | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
> index b9c4452f83..2b0d3522e5 100644
> --- a/src/compiler/glsl/ir.cpp
> +++ b/src/compiler/glsl/ir.cpp
> @@ -1460,9 +1460,28 @@ ir_dereference::is_lvalue(const struct _mesa_glsl_parse_state *state) const
>  {
>     ir_variable *var = this->variable_referenced();
>
> -   /* Every l-value derference chain eventually ends in a variable.
> +   /* Every l-value dereference chain eventually ends in a variable.
>      */
> -   if ((var == NULL) || var->data.read_only)
> +   if (!var)
> +      return false;

I believe the read-only check needs to stay. Otherwise, you'll allow 
assigning sampler values to uniforms or const variables.

Cheers,
Nicolai


> +
> +   /* The ARB_bindless_texture spec says:
> +    *
> +    * "Replace Section 4.1.7 (Samplers), p. 25"
> +    *
> +    * "Samplers can be used as l-values, so can be assigned into and used as
> +    *  "out" and "inout" function parameters."
> +    *
> +    * "Replace Section 4.1.X, (Images)"
> +    *
> +    * "Images can be used as l-values, so can be assigned into and used as
> +    *  "out" and "inout" function parameters."
> +    */
> +   if (state && state->has_bindless() &&
> +       (this->type->contains_sampler() || this->type->contains_image()))
> +      return true;
> +
> +   if (var->data.read_only)
>        return false;
>
>     /* From section 4.1.7 of the GLSL 4.40 spec:
>


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list