[Mesa-dev] [RFC PATCH 4/5] glsl: add interpolateAtCentroid builtin

Chris Forbes chrisf at ijw.co.nz
Sun Nov 10 00:51:10 PST 2013


Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/glsl/builtin_functions.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 8cb75e5..3ea3a3f 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -564,6 +564,7 @@ private:
    B1(uaddCarry)
    B1(usubBorrow)
    B1(mulExtended)
+   B1(interpolateAtCentroid)
 
    ir_function_signature *_atomic_intrinsic(builtin_available_predicate avail);
    ir_function_signature *_atomic_op(const char *intrinsic,
@@ -2092,6 +2093,12 @@ builtin_builder::create_builtins()
                 _mulExtended(glsl_type::uvec3_type),
                 _mulExtended(glsl_type::uvec4_type),
                 NULL);
+   add_function("interpolateAtCentroid",
+                _interpolateAtCentroid(glsl_type::float_type),
+                _interpolateAtCentroid(glsl_type::vec2_type),
+                _interpolateAtCentroid(glsl_type::vec3_type),
+                _interpolateAtCentroid(glsl_type::vec4_type),
+                NULL);
 
    add_function("atomicCounter",
                 _atomic_op("__intrinsic_atomic_read",
@@ -3970,6 +3977,17 @@ builtin_builder::_mulExtended(const glsl_type *type)
 }
 
 ir_function_signature *
+builtin_builder::_interpolateAtCentroid(const glsl_type *type)
+{
+   ir_variable *interpolant = new(mem_ctx) ir_variable(type, "interpolant", ir_var_shader_in);
+   MAKE_SIG(type, gpu_shader5, 1, interpolant);
+
+   body.emit(ret(interpolate_at_centroid(interpolant)));
+
+   return sig;
+}
+
+ir_function_signature *
 builtin_builder::_atomic_intrinsic(builtin_available_predicate avail)
 {
    ir_variable *counter = in_var(glsl_type::atomic_uint_type, "counter");
-- 
1.8.4.2



More information about the mesa-dev mailing list