[Mesa-dev] [PATCH 1/2] gallium: add texture gather support to gallium (v2)

Dave Airlie airlied at gmail.com
Thu Feb 6 19:36:35 PST 2014


From: Dave Airlie <airlied at redhat.com>

This just adds the TG4 opcode, and a CAP for the
max texture gather components.

v2: add component selection src and a cap to say
hw can do it. (st can use to help control
GL_ARB_gpu_shader5/GLSL 4.00). Add docs.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/auxiliary/tgsi/tgsi_info.c     |  1 +
 src/gallium/docs/source/tgsi.rst           | 23 +++++++++++++++++++++++
 src/gallium/include/pipe/p_defines.h       |  4 +++-
 src/gallium/include/pipe/p_shader_tokens.h |  4 +++-
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index f993600..565f274 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -221,6 +221,7 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
    { 1, 3, 1, 0, 0, 0, OTHR, "TXL2", TGSI_OPCODE_TXL2 },
    { 1, 2, 0, 0, 0, 0, COMP, "IMUL_HI", TGSI_OPCODE_IMUL_HI },
    { 1, 2, 0, 0, 0, 0, COMP, "UMUL_HI", TGSI_OPCODE_UMUL_HI },
+   { 1, 3, 1, 0, 0, 0, OTHR, "TG4", TGSI_OPCODE_TG4 },
 };
 
 const struct tgsi_opcode_info *
diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
index 0501aca..5f54a6f 100644
--- a/src/gallium/docs/source/tgsi.rst
+++ b/src/gallium/docs/source/tgsi.rst
@@ -986,6 +986,29 @@ XXX doesn't look like most of the opcodes really belong here.
 
   dst.z = texture_depth(unit, lod)
 
+.. opcode:: TG4 - Texture Gather (as per ARB_texture_gather)
+               Gathers the four texels to be used in a bi-linear
+               filtering operation and packs them into a single register.
+               Only works with 2D, 2D array, cubemaps, and cubemaps arrays.
+               For 2D textures, only the addressing modes of the sampler and
+               the top level of any mip pyramid are used. Set W to zero.
+               It behaves like the TEX instruction, but a filtered
+               sample is not generated. The four samples that contribute
+               to filtering are placed into xyzw in clockwise order,
+               starting with the (u,v) texture coordinate delta at the
+               following locations (-, +), (+, +), (+, -), (-, -), where
+               the magnitude of the deltas are half a texel.
+
+               some can handle components - check the capability
+               PIPE_CAP_TEXTURE_GATHER_COMPONENT_SELECT
+
+.. math::
+
+   coord = src0
+
+   component = src1
+
+   dst = texture_gather4 (unit, coord, component)
 
 Integer ISA
 ^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index dbedd87..bd5e434 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -520,7 +520,9 @@ enum pipe_cap {
    PIPE_CAP_MAX_VIEWPORTS = 84,
    PIPE_CAP_ENDIANNESS = 85,
    PIPE_CAP_MIXED_FRAMEBUFFER_SIZES = 86,
-   PIPE_CAP_TGSI_VS_LAYER = 87
+   PIPE_CAP_TGSI_VS_LAYER = 87,
+   PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS = 88,
+   PIPE_CAP_TEXTURE_GATHER_COMPONENT_SELECT = 89
 };
 
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 8750bd2..8fa6a0a 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -453,7 +453,9 @@ struct tgsi_property_data {
 #define TGSI_OPCODE_IMUL_HI             180
 #define TGSI_OPCODE_UMUL_HI             181
 
-#define TGSI_OPCODE_LAST                182
+#define TGSI_OPCODE_TG4                 182
+
+#define TGSI_OPCODE_LAST                183
 
 #define TGSI_SAT_NONE            0  /* do not saturate */
 #define TGSI_SAT_ZERO_ONE        1  /* clamp to [0,1] */
-- 
1.8.3.1



More information about the mesa-dev mailing list