[Mesa-dev] [RFC PATCH 6/5] mesa: add statevar for sample position palette

2013-11-10 Thread Chris Forbes
Signed-off-by: Chris Forbes DrawBuffer->Visual.samples;
   return;
+   case STATE_SAMPLE_POSITIONS:
+  {
+ int i;
+ for (i = 0; i < ctx->DrawBuffer->Visual.samples; i++) {
+ctx->Driver.GetSamplePosition(ctx, ctx->DrawBuffer, i, &value[2 * 
i]);
+ }
+  }
+  return;
case STATE_DEPTH_RANGE:
   value[0] = ctx->Viewport.Near; /* near   */
   value[1] = ctx->Viewport.Far;  /* far*/
@@ -669,6 +677,7 @@ _mesa_program_state_flags(const gl_state_index 
state[STATE_LENGTH])
   return _NEW_TRACK_MATRIX;
 
case STATE_NUM_SAMPLES:
+   case STATE_SAMPLE_POSITIONS:
   return _NEW_BUFFERS;
 
case STATE_DEPTH_RANGE:
@@ -861,6 +870,9 @@ append_token(char *dst, gl_state_index k)
case STATE_NUM_SAMPLES:
   append(dst, "numsamples");
   break;
+   case STATE_SAMPLE_POSITIONS:
+  append(dst, "samplepositions");
+  break;
case STATE_DEPTH_RANGE:
   append(dst, "depth.range");
   break;
@@ -1038,6 +1050,8 @@ _mesa_program_state_string(const gl_state_index 
state[STATE_LENGTH])
   break;
case STATE_NUM_SAMPLES:
   break;
+   case STATE_SAMPLE_POSITIONS:
+  break;
case STATE_DEPTH_RANGE:
   break;
case STATE_FRAGMENT_PROGRAM:
diff --git a/src/mesa/program/prog_statevars.h 
b/src/mesa/program/prog_statevars.h
index 23a9f48..87dece4 100644
--- a/src/mesa/program/prog_statevars.h
+++ b/src/mesa/program/prog_statevars.h
@@ -104,6 +104,7 @@ typedef enum gl_state_index_ {
STATE_TEXENV_COLOR,
 
STATE_NUM_SAMPLES,/* An integer, not a float like the other state vars 
*/
+   STATE_SAMPLE_POSITIONS,
 
STATE_DEPTH_RANGE,
 
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [RFC PATCH 7/5] glsl: add builtin uniform for sample positions palette

2013-11-10 Thread Chris Forbes
Signed-off-by: Chris Forbes 
---
 src/glsl/builtin_variables.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 4d44104..796e18e 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -34,6 +34,10 @@ static struct gl_builtin_uniform_element 
gl_NumSamples_elements[] = {
{NULL, {STATE_NUM_SAMPLES, 0, 0}, SWIZZLE_}
 };
 
+static struct gl_builtin_uniform_element gl_SamplePositionsMESA_elements[] = {
+   {NULL, {STATE_SAMPLE_POSITIONS, 0, 0}, SWIZZLE_XYZW},
+};
+
 static struct gl_builtin_uniform_element gl_DepthRange_elements[] = {
{"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_},
{"far", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_},
@@ -240,6 +244,7 @@ static struct gl_builtin_uniform_element 
gl_NormalMatrix_elements[] = {
 
 static const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = {
STATEVAR(gl_NumSamples),
+   STATEVAR(gl_SamplePositionsMESA),
STATEVAR(gl_DepthRange),
STATEVAR(gl_ClipPlane),
STATEVAR(gl_Point),
@@ -667,6 +672,7 @@ void
 builtin_variable_generator::generate_uniforms()
 {
add_uniform(int_t, "gl_NumSamples");
+   add_uniform(array(vec2_t, state->ctx->Const.MaxSamples), 
"gl_SamplePositionsMESA");
add_uniform(type("gl_DepthRangeParameters"), "gl_DepthRange");
add_uniform(array(vec4_t, VERT_ATTRIB_MAX), "gl_CurrentAttribVertMESA");
add_uniform(array(vec4_t, VARYING_SLOT_MAX), "gl_CurrentAttribFragMESA");
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] meta: rebind the array object to prevent corruption of current one in setup_glsl_blit_framebuffer

2013-11-10 Thread Petr Sebor
Without the rebind, the function enables generic vertex attributes 0 and 1 of 
the
array object it does not own. This was causing crashes in Euro Truck Simulator 
2,
since the enabled generic attribute 0 got precedence before vertex position 
attribute
at later time, leading to NULL pointer dereference.

Signed-off-by: Petr Sebor 
---
 src/mesa/drivers/common/meta.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index aa50dde..06e3e3c 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1516,6 +1516,11 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx,
   _mesa_VertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,
sizeof(struct vertex), OFFSET(s));
}
+   else {
+  /* Rebind the existing ArrayObj so that _mesa_EnableVertexAttribArray */
+  /* calls do not corrupt the current one. */
+  _mesa_BindVertexArray(blit->ArrayObj);
+   }
 
/* Generate a relevant fragment shader program for the texture target */
if ((target == GL_TEXTURE_2D && blit->ShaderProg != 0) ||
-- 
1.8.3.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glx: Fix scons build.

2013-11-10 Thread Jose Fonseca


- Original Message -
> On Fri, Nov 8, 2013 at 9:55 AM,   wrote:
> > From: José Fonseca 
> >
> > By disabling DRI3 support for the time being.
> >
> > I'll add DRI3 support to scons build when the DRI3 dependencies become
> > more widely available (as now there is no convenient way of testing it
> > except building dependencies from source).
> > ---
> >  src/glx/SConscript | 6 ++
> >  src/glx/glxext.c   | 2 ++
> >  2 files changed, 8 insertions(+)
> >
> > diff --git a/src/glx/SConscript b/src/glx/SConscript
> > index ef372d0..f581c12 100644
> > --- a/src/glx/SConscript
> > +++ b/src/glx/SConscript
> > @@ -40,6 +40,9 @@ if env['HAVE_XF86VIDMODE']:
> >  if False: # XXX: SHARED_GLAPI
> >  env.Append(CPPDEFINES = ['GLX_SHARED_GLAPI'])
> >
> > +# XXX: Disable DRI3 for now
> > +env.Append(CPPDEFINES = ['GLX_NO_DRI3'])
> > +
> >  sources = [
> >  'clientattrib.c',
> >  'clientinfo.c',
> > @@ -63,6 +66,7 @@ sources = [
> >  'indirect_vertex_program.c',
> >  'pixel.c',
> >  'pixelstore.c',
> > +'query_renderer.c',
> >  'render2.c',
> >  'renderpix.c',
> >  'single2.c',
> > @@ -79,6 +83,8 @@ sources = [
> >  'dri2_glx.c',
> >  'dri2.c',
> >  'dri2_query_renderer.c',
> > +#'dri3_glx.c',
> > +#'dri3_common.c',
> >  'applegl_glx.c',
> >  ]
> >
> > diff --git a/src/glx/glxext.c b/src/glx/glxext.c
> > index c6e4d9f..d3c92574 100644
> > --- a/src/glx/glxext.c
> > +++ b/src/glx/glxext.c
> > @@ -865,8 +865,10 @@ __glXInitialize(Display * dpy)
> >  ** (e.g., those called in AllocAndFetchScreenConfigs).
> >  */
> > if (glx_direct && glx_accel) {
> > +#if !defined(GLX_NO_DRI3)
> 
> Please name this HAVE_DRI3 instead. That's what the associated
> autotools patch calls it and I kind of dislike thinking about the
> meaning of double negatives.

I agree in principle, but there was no autotools patch when I posted this, and 
unless I used a negative flag I'd need to modify autotools to set it, which was 
more trouble than I thought it worth, as I knew soon or later somebody would 
fix the autotools to be optional too.

Anyway, with the autotools patch now in most of this patch is now irrelevant -- 
as long as scons doesn't defines HAVE_DRI3 there won't be any problem.

Jose
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC PATCH 0/5] ARB_gpu_shader5 interpolateAt* GLSL plumbing

2013-11-10 Thread Paul Berry
On 10 November 2013 00:51, Chris Forbes  wrote:

> Here is the driver-independent part of ARB_gpu_shader5's
> interpolateAtCentroid, interpolateAtOffset builtins.
>
> Before I go further with this approach, I'd like feedback on the following:
>
> 1) I've (ab)used ir_var_shader_in variable mode in function signatures to
> enforce the strange restrictions interpolateAt* have. Is this crazy/awful?
>

I'd rather not go this route if we can avoid it.  Before commit 42a29d8, we
had a similar situation where the same set of ir_variable_mode enums were
used to reperesent shader ins/outs as function ins/outs, and it caused a
lot of confusion and risk of mistakes in optimization and lowering passes.
I'm glad we moved away from that and I'd like to avoid drifting back in
that direction.

I'd suggest instead adding a new field to the ir_variable class to
represent this restriction (e.g. ir_variable::requires_shader_input).  We
would be set to true in the builtin_builder::_interpolateAt...() functions,
and then in patch 1/5, instead of checking the restriction when
formal->mode == ir_var_shader_in, we check it when
formal->requires_shader_input is true.


>
> 2) I intend to implement interpolateAtSample() by:
>
> - Adding a new builtin uniform (perhaps "gl_SamplePositionsMESA"); which
>will be an array of vec2, containing the full palette of current sample
>positions. This could be formally exposed by another extension at a
> later
>point.
>
> - Compiling interpolateAtSample(x, sample_num) as if the shader author
> wrote:
>interpolateAtOffset(x, gl_SamplePositionsMESA[sample_num] - vec2(0.5))
>
> Is this sensible?
>

> Does it match what other hardware will need to do? (it makes sense for
> i965,
> where the fragment shader payload otherwise does not have access to a full
> palette of sample positions.)
>

I suspect that this won't make sense for a lot of hardware, because either:

(a) the hardware may have a fast mechanism for doing interpolateAtSample()
which is better than interpolateAtOffset(x,
gl_SamplePositionsMESA[sample_num] - vec2(0.5)).  In fact, even i965 has
such a mechanism (the eval_sindex message), but it only works if the
sample_num is uniform or constant, and it's easiest to use if it's
constant.  I suspect a lot of uses of interpolateAtSample are going to use
a sample_num that's constant (after loop unrolling) so it seems worth using
this fast mechanism when we can.

(b) if the hardware supports variable sample locations, then this technique
won't work at all because the values in gl_SamplePositionsMESA[sample_num]
will need to vary from pixel to pixel.

I'd be ok with an initial implementation of interpolateAtSample() based on
interpolateAtOffset(), but I'd recommend doing it in the i965-specific
fs_visitor (rather than in src/glsl) so that it doesn't get in the way of
other hardware.  Later when we want to add the fast mechanism that requires
sample_num to be uniform or constant, it will be easy to add that to the
fs_visitor implementation with a few "if" statements.


Other than those two concerns I had a quick glance at the rest of the
series and your approach seems reasonable to me.  Consider it:

Acked-by: Paul Berry 

for now, and let me know if you'd like me to do a more thorough review.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [RFC PATCH 2/5] glsl: add ir_unop_interpolate_at_centroid

2013-11-10 Thread Chris Forbes
Will be used to implement interpolateAtCentroid() from ARB_gpu_shader5.

Signed-off-by: Chris Forbes 
---
 src/glsl/ir.cpp| 2 ++
 src/glsl/ir.h  | 9 -
 src/glsl/ir_builder.cpp| 6 ++
 src/glsl/ir_builder.h  | 2 ++
 src/glsl/ir_validate.cpp   | 5 +
 src/mesa/program/ir_to_mesa.cpp| 1 +
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 +
 7 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 1b49736..74d59db 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -251,6 +251,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
case ir_unop_dFdx:
case ir_unop_dFdy:
case ir_unop_bitfield_reverse:
+   case ir_unop_interpolate_at_centroid:
   this->type = op0->type;
   break;
 
@@ -527,6 +528,7 @@ static const char *const operator_strs[] = {
"find_msb",
"find_lsb",
"noise",
+   "interpolate_at_centroid",
"+",
"-",
"*",
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 2f06fb9..7e41008 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -1193,9 +1193,16 @@ enum ir_expression_operation {
ir_unop_noise,
 
/**
+* Interpolate fs input at centroid
+*
+* operand0 is the fs input.
+*/
+   ir_unop_interpolate_at_centroid,
+
+   /**
 * A sentinel marking the last of the unary operations.
 */
-   ir_last_unop = ir_unop_noise,
+   ir_last_unop = ir_unop_interpolate_at_centroid,
 
ir_binop_add,
ir_binop_sub,
diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
index 6c49734..c532aea 100644
--- a/src/glsl/ir_builder.cpp
+++ b/src/glsl/ir_builder.cpp
@@ -496,6 +496,12 @@ b2f(operand a)
 }
 
 ir_expression *
+interpolate_at_centroid(operand a)
+{
+   return expr(ir_unop_interpolate_at_centroid, a);
+}
+
+ir_expression *
 fma(operand a, operand b, operand c)
 {
return expr(ir_triop_fma, a, b, c);
diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
index 1f07788..410e8ab 100644
--- a/src/glsl/ir_builder.h
+++ b/src/glsl/ir_builder.h
@@ -184,6 +184,8 @@ ir_expression *i2b(operand a);
 ir_expression *f2b(operand a);
 ir_expression *b2f(operand a);
 
+ir_expression *interpolate_at_centroid(operand a);
+
 ir_expression *fma(operand a, operand b, operand c);
 ir_expression *lrp(operand x, operand y, operand a);
 ir_expression *csel(operand a, operand b, operand c);
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 13e41a0..69dd18f 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -410,6 +410,11 @@ ir_validate::visit_leave(ir_expression *ir)
   /* XXX what can we assert here? */
   break;
 
+   case ir_unop_interpolate_at_centroid:
+  assert(ir->operands[0]->type == ir->type);
+  assert(ir->operands[0]->type->is_float());
+  break;
+
case ir_binop_add:
case ir_binop_sub:
case ir_binop_mul:
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index c833a12..f75c296 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1501,6 +1501,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
case ir_binop_carry:
case ir_binop_borrow:
case ir_binop_imul_high:
+   case ir_unop_interpolate_at_centroid:
   assert(!"not supported");
   break;
 
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 0eaf746..418f27d 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2007,6 +2007,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
case ir_binop_carry:
case ir_binop_borrow:
case ir_binop_imul_high:
+   case ir_unop_interpolate_at_centroid:
   /* This operation is not supported, or should have already been handled.
*/
   assert(!"Invalid ir opcode in glsl_to_tgsi_visitor::visit()");
-- 
1.8.4.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2013-11-10 Thread Chris Forbes
Signed-off-by: Chris Forbes 
---
 src/glsl/builtin_functions.cpp | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 3ea3a3f..c55115c 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -565,6 +565,7 @@ private:
B1(usubBorrow)
B1(mulExtended)
B1(interpolateAtCentroid)
+   B1(interpolateAtOffset)
 
ir_function_signature *_atomic_intrinsic(builtin_available_predicate avail);
ir_function_signature *_atomic_op(const char *intrinsic,
@@ -2099,6 +2100,12 @@ builtin_builder::create_builtins()
 _interpolateAtCentroid(glsl_type::vec3_type),
 _interpolateAtCentroid(glsl_type::vec4_type),
 NULL);
+   add_function("interpolateAtOffset",
+_interpolateAtOffset(glsl_type::float_type),
+_interpolateAtOffset(glsl_type::vec2_type),
+_interpolateAtOffset(glsl_type::vec3_type),
+_interpolateAtOffset(glsl_type::vec4_type),
+NULL);
 
add_function("atomicCounter",
 _atomic_op("__intrinsic_atomic_read",
@@ -3988,6 +3995,18 @@ builtin_builder::_interpolateAtCentroid(const glsl_type 
*type)
 }
 
 ir_function_signature *
+builtin_builder::_interpolateAtOffset(const glsl_type *type)
+{
+   ir_variable *interpolant = new(mem_ctx) ir_variable(type, "interpolant", 
ir_var_shader_in);
+   ir_variable *offset = in_var(glsl_type::vec2_type, "offset");
+   MAKE_SIG(type, gpu_shader5, 2, interpolant, offset);
+
+   body.emit(ret(interpolate_at_offset(interpolant, offset)));
+
+   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

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [RFC PATCH 3/5] glsl: add ir_binop_interpolate_at_offset

2013-11-10 Thread Chris Forbes
Will be used to implement interpolateAtOffset() and
interpolateAtSample() from ARB_gpu_shader5.

Signed-off-by: Chris Forbes 
---
 src/glsl/ir.cpp|  2 ++
 src/glsl/ir.h  | 10 +-
 src/glsl/ir_builder.cpp|  6 ++
 src/glsl/ir_builder.h  |  1 +
 src/glsl/ir_constant_expression.cpp|  1 +
 src/glsl/ir_validate.cpp   |  7 +++
 src/mesa/program/ir_to_mesa.cpp|  1 +
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  1 +
 8 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 74d59db..dcfece9 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -406,6 +406,7 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, 
ir_rvalue *op1)
case ir_binop_rshift:
case ir_binop_bfm:
case ir_binop_ldexp:
+   case ir_binop_interpolate_at_offset:
   this->type = op0->type;
   break;
 
@@ -562,6 +563,7 @@ static const char *const operator_strs[] = {
"ubo_load",
"ldexp",
"vector_extract",
+   "interpolate_at_offset",
"fma",
"lrp",
"csel",
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 7e41008..5e9103f 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -1321,9 +1321,17 @@ enum ir_expression_operation {
ir_binop_vector_extract,
 
/**
+* Interpolate fs input at offset
+*
+* operand0 is the fs input
+* operand1 is the offset from the pixel center
+*/
+   ir_binop_interpolate_at_offset,
+
+   /**
 * A sentinel marking the last of the binary operations.
 */
-   ir_last_binop = ir_binop_vector_extract,
+   ir_last_binop = ir_binop_interpolate_at_offset,
 
/**
 * \name Fused floating-point multiply-add, part of ARB_gpu_shader5.
diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
index c532aea..09a32a3 100644
--- a/src/glsl/ir_builder.cpp
+++ b/src/glsl/ir_builder.cpp
@@ -502,6 +502,12 @@ interpolate_at_centroid(operand a)
 }
 
 ir_expression *
+interpolate_at_offset(operand a, operand b)
+{
+   return expr(ir_binop_interpolate_at_offset, a, b);
+}
+
+ir_expression *
 fma(operand a, operand b, operand c)
 {
return expr(ir_triop_fma, a, b, c);
diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
index 410e8ab..c049010 100644
--- a/src/glsl/ir_builder.h
+++ b/src/glsl/ir_builder.h
@@ -185,6 +185,7 @@ ir_expression *f2b(operand a);
 ir_expression *b2f(operand a);
 
 ir_expression *interpolate_at_centroid(operand a);
+ir_expression *interpolate_at_offset(operand a, operand b);
 
 ir_expression *fma(operand a, operand b, operand c);
 ir_expression *lrp(operand x, operand y, operand a);
diff --git a/src/glsl/ir_constant_expression.cpp 
b/src/glsl/ir_constant_expression.cpp
index 0efd1d5..dfffa1d 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -415,6 +415,7 @@ ir_expression::constant_expression_value(struct hash_table 
*variable_context)
   case ir_binop_lshift:
   case ir_binop_rshift:
   case ir_binop_ldexp:
+  case ir_binop_interpolate_at_offset:
   case ir_binop_vector_extract:
   case ir_triop_csel:
   case ir_triop_bitfield_extract:
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 69dd18f..9e39afe 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -551,6 +551,13 @@ ir_validate::visit_leave(ir_expression *ir)
  && ir->operands[1]->type->is_integer());
   break;
 
+   case ir_binop_interpolate_at_offset:
+  assert(ir->operands[0]->type == ir->type);
+  assert(ir->operands[0]->type->is_float());
+  assert(ir->operands[1]->type->components() == 2);
+  assert(ir->operands[1]->type->is_float());
+  break;
+
case ir_triop_fma:
   assert(ir->type->base_type == GLSL_TYPE_FLOAT);
   assert(ir->type == ir->operands[0]->type);
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index f75c296..6fd9fb6 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1502,6 +1502,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
case ir_binop_borrow:
case ir_binop_imul_high:
case ir_unop_interpolate_at_centroid:
+   case ir_binop_interpolate_at_offset:
   assert(!"not supported");
   break;
 
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 418f27d..65e2925 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2008,6 +2008,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
case ir_binop_borrow:
case ir_binop_imul_high:
case ir_unop_interpolate_at_centroid:
+   case ir_binop_interpolate_at_offset:
   /* This operation is not supported, or should have already been handled.
*/
   assert(!"Invalid ir opcode in glsl_to_tgsi_visitor::visit()");
-- 
1.8.4.2


[Mesa-dev] [RFC PATCH 0/5] ARB_gpu_shader5 interpolateAt* GLSL plumbing

2013-11-10 Thread Chris Forbes
Here is the driver-independent part of ARB_gpu_shader5's
interpolateAtCentroid, interpolateAtOffset builtins.

Before I go further with this approach, I'd like feedback on the following:

1) I've (ab)used ir_var_shader_in variable mode in function signatures to
enforce the strange restrictions interpolateAt* have. Is this crazy/awful?

2) I intend to implement interpolateAtSample() by:

- Adding a new builtin uniform (perhaps "gl_SamplePositionsMESA"); which
   will be an array of vec2, containing the full palette of current sample
   positions. This could be formally exposed by another extension at a later
   point.

- Compiling interpolateAtSample(x, sample_num) as if the shader author wrote:
   interpolateAtOffset(x, gl_SamplePositionsMESA[sample_num] - vec2(0.5))

Is this sensible?

Does it match what other hardware will need to do? (it makes sense for i965,
where the fragment shader payload otherwise does not have access to a full
palette of sample positions.)

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2013-11-10 Thread Chris Forbes
Signed-off-by: Chris Forbes 
---
 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

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev