On 10/14/2013 10:12 AM, Anuj Phogat wrote: > Implement the FS backend for new builtins added by the extension: > in vec2 gl_SamplePosition > in int gl_SampleID > in int gl_NumSamples > out int gl_SampleMask[] > > Signed-off-by: Anuj Phogat <anuj.pho...@gmail.com> > --- > src/mesa/drivers/dri/i965/brw_fs.cpp | 109 > +++++++++++++++++++++++++++ > src/mesa/drivers/dri/i965/brw_fs.h | 4 + > src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 23 ++++++ > src/mesa/drivers/dri/i965/brw_wm.h | 1 + > 4 files changed, 137 insertions(+) > > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp > b/src/mesa/drivers/dri/i965/brw_fs.cpp > index e5d6e4b..e4f7745 100644 > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp > @@ -1115,6 +1115,109 @@ > fs_visitor::emit_frontfacing_interpolation(ir_variable *ir) > return reg; > } > > +void > +fs_visitor::compute_sample_position(fs_reg dst, fs_reg int_sample_pos) > +{ > + int num_samples = ctx->DrawBuffer->Visual.samples; > + assert(num_samples >= 0 && num_samples <= 8); > + > + /* From arb_sample_shading specification: > + * "When rendering to a non-multisample buffer, or if multisample > + * rasterization is disabled, gl_SamplePosition will always be > + * (0.5, 0.5). > + */ > + if (!ctx->Multisample.Enabled || num_samples == 0) { > + emit(BRW_OPCODE_MOV, dst, fs_reg(0.5f)); > + } > + else { > + /* For num_samples = {4, 8} */ > + emit(BRW_OPCODE_MOV, dst, int_sample_pos); > + emit(BRW_OPCODE_MUL, dst, dst, fs_reg(1 / 16.0f)); > + } > +}
> +fs_reg * > +fs_visitor::emit_sampleid_interpolation(ir_variable *ir) > +{ > + assert(brw->gen >= 6); > + bool multisampled_fbo = ctx->DrawBuffer->Visual.samples > 1; > + > + this->current_annotation = "compute sample id"; > + fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type); > + > + if (multisampled_fbo && ctx->Multisample.Enabled) { One more thing. These two blocks have different conditions. For gl_SamplePosition, num_samples == 1 hits the MSAA case. For gl_SampleId, num_samples == 1 hits the non-MSAA case. I don't know which is right, but they should match. _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev