[Mesa-dev] [RFC PATCH 8/5] glsl: add interpolateAtSample builtin
Chris Forbes
chrisf at ijw.co.nz
Sun Nov 10 02:29:59 PST 2013
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
src/glsl/builtin_functions.cpp | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index c55115c..b1ff152 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -566,6 +566,7 @@ private:
B1(mulExtended)
B1(interpolateAtCentroid)
B1(interpolateAtOffset)
+ B1(interpolateAtSample)
ir_function_signature *_atomic_intrinsic(builtin_available_predicate avail);
ir_function_signature *_atomic_op(const char *intrinsic,
@@ -2106,6 +2107,12 @@ builtin_builder::create_builtins()
_interpolateAtOffset(glsl_type::vec3_type),
_interpolateAtOffset(glsl_type::vec4_type),
NULL);
+ add_function("interpolateAtSample",
+ _interpolateAtSample(glsl_type::float_type),
+ _interpolateAtSample(glsl_type::vec2_type),
+ _interpolateAtSample(glsl_type::vec3_type),
+ _interpolateAtSample(glsl_type::vec4_type),
+ NULL);
add_function("atomicCounter",
_atomic_op("__intrinsic_atomic_read",
@@ -4007,6 +4014,29 @@ builtin_builder::_interpolateAtOffset(const glsl_type *type)
}
ir_function_signature *
+builtin_builder::_interpolateAtSample(const glsl_type *type)
+{
+ ir_variable *interpolant = new(mem_ctx) ir_variable(type, "interpolant", ir_var_shader_in);
+ ir_variable *sample_num = in_var(glsl_type::int_type, "sample_num");
+ MAKE_SIG(type, gpu_shader5, 2, interpolant, sample_num);
+
+ ir_constant_data offset;
+ offset.f[0] = -0.5f;
+ offset.f[1] = -0.5f;
+
+ ir_rvalue *sample_pos = sub(
+ new(mem_ctx) ir_dereference_array(
+ new(mem_ctx) ir_variable(glsl_type::get_array_instance(glsl_type::vec2_type, 0),
+ "gl_SamplePositionsMESA",
+ ir_var_uniform),
+ new(mem_ctx) ir_dereference_variable(sample_num)),
+ imm(glsl_type::vec2_type, offset));
+
+ body.emit(ret(interpolate_at_offset(interpolant, sample_pos)));
+ 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