[Mesa-dev] [PATCH 2/6] texture_builtins.py: Add support for textureSize (txs).

Ian Romanick idr at freedesktop.org
Mon Aug 22 16:32:55 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/22/2011 04:26 PM, Kenneth Graunke wrote:
> ---
>  src/glsl/builtins/tools/texture_builtins.py |   50 +++++++++++++++++++-------
>  1 files changed, 36 insertions(+), 14 deletions(-)
> 
> diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py
> index a4054ca..7e569bf 100755
> --- a/src/glsl/builtins/tools/texture_builtins.py
> +++ b/src/glsl/builtins/tools/texture_builtins.py
> @@ -44,6 +44,11 @@ def get_extra_dim(sampler_type, use_proj, unused_fields):
>          extra_dim += 1
>      return extra_dim
>  
> +def get_txs_dim(sampler_type):
> +    if sampler_type.startswith("Cube"):
> +        return 2
> +    return get_coord_dim(sampler_type)
> +
>  def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
>      coord_dim = get_coord_dim(sampler_type)
>      extra_dim = get_extra_dim(sampler_type, variant & Proj, unused_fields)
> @@ -51,17 +56,20 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
>  
>      if variant & Single:
>          return_type = "float"
> +    elif tex_inst == "txs":
> +        return_type = vec_type("i", get_txs_dim(sampler_type))
>      else:
>          return_type = g + "vec4"
>  
>      # Print parameters
>      print "   (signature", return_type
>      print "     (parameters"
> -    print "       (declare (in) " + g + "sampler" + sampler_type + " sampler)"
> -    print "       (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)",
> +    print "       (declare (in) " + g + "sampler" + sampler_type + " sampler)",

Is the comma at the end of that line spurious?

> +    if tex_inst != "txs":
> +        print "\n       (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)",
>      if tex_inst == "txl":
>          print "\n       (declare (in) float lod)",
> -    elif tex_inst == "txf":
> +    elif tex_inst == "txf" or tex_inst == "txs":
>          print "\n       (declare (in) int lod)",
>      elif tex_inst == "txd":
>          grad_type = vec_type("", coord_dim)
> @@ -75,18 +83,19 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
>  
>      print ")\n     ((return (" + tex_inst, return_type, "(var_ref sampler)",
>  
> -    # Coordinate
> -    if extra_dim > 0:
> -        print "(swiz " + "xyzw"[:coord_dim] + " (var_ref P))",
> -    else:
> -        print "(var_ref P)",
> +    if tex_inst != "txs":
> +        # Coordinate
> +        if extra_dim > 0:
> +            print "(swiz " + "xyzw"[:coord_dim] + " (var_ref P))",
> +        else:
> +            print "(var_ref P)",
>  
> -    if variant & Offset:
> -        print "(var_ref offset)",
> -    else:
> -        print "0",
> +        if variant & Offset:
> +            print "(var_ref offset)",
> +        else:
> +            print "0",
>  
> -    if tex_inst != "txf":
> +    if tex_inst != "txf" and tex_inst != "txs":
>          # Projective divisor
>          if variant & Proj:
>              print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))",
> @@ -104,7 +113,7 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
>      # Bias/explicit LOD/gradient:
>      if tex_inst == "txb":
>          print "(var_ref bias)",
> -    elif tex_inst == "txl" or tex_inst == "txf":
> +    elif tex_inst == "txl" or tex_inst == "txf" or tex_inst == "txs":
>          print "(var_ref lod)",
>      elif tex_inst == "txd":
>          print "((var_ref dPdx) (var_ref dPdy))",
> @@ -130,6 +139,19 @@ def end_function(fs, name):
>  #
>  # Takes a dictionary as an argument.
>  def generate_texture_functions(fs):
> +    start_function("textureSize")
> +    generate_fiu_sigs("txs", "1D")
> +    generate_fiu_sigs("txs", "2D")
> +    generate_fiu_sigs("txs", "3D")
> +    generate_fiu_sigs("txs", "Cube")
> +    generate_fiu_sigs("txs", "1DArray")
> +    generate_fiu_sigs("txs", "2DArray")
> +    generate_sigs("", "txs", "1DShadow")
> +    generate_sigs("", "txs", "2DShadow")
> +    generate_sigs("", "txs", "1DArrayShadow")
> +    generate_sigs("", "txs", "2DArrayShadow")
> +    end_function(fs, "textureSize")
> +
>      start_function("texture")
>      generate_fiu_sigs("tex", "1D")
>      generate_fiu_sigs("tex", "2D")

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk5S5ycACgkQX1gOwKyEAw8oOgCeIh0c9UpRLVS/QnYG0MOAyUjl
Q94AnjPBwF0m4hVofLHExkoTL45f0zqf
=klce
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list