Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com> --- src/mesa/drivers/dri/i965/brw_fs.h | 6 +++++ src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 39 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 968ae77..2b3ac34 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -514,6 +514,12 @@ public: void visit_atomic_counter_intrinsic(ir_call *ir); fs_reg fetch_resinfo(int sampler, const fs_reg& lod); + void normalize(const fs_reg& norm, + const fs_reg& unorm, + const fs_reg& range); + void denormalize(const fs_reg& unorm, + const fs_reg& norm, + const fs_reg& range); struct gl_fragment_program *fp; diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 42836ac..10afe5d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -1589,6 +1589,45 @@ fs_visitor::fetch_resinfo(int sampler, const fs_reg& lod) } void +fs_visitor::denormalize(const fs_reg& unorm, + const fs_reg& norm, + const fs_reg& range) +{ + fs_reg range_f = fs_reg(this, glsl_type::float_type); + fs_reg unorm_f = fs_reg(this, glsl_type::float_type); + + /* Make sure the math is performed using floats - range is likely to be + * unsigned. Move will do the needed conversion and optimizing passes will + * remove the copy if the range is already a float. + */ + emit(MOV(range_f, range)); + + emit(MUL(unorm_f, norm, range_f)); + + /* Such as range the unnormalized is likely to be unsigned. */ + emit(MOV(unorm, unorm_f)); +} + +void +fs_visitor::normalize(const fs_reg& norm, + const fs_reg& unorm, + const fs_reg& range) +{ + fs_reg range_inv = fs_reg(this, glsl_type::float_type); + fs_reg unorm_f = fs_reg(this, glsl_type::float_type); + + /* Make sure the math is performed using floats - range and unnormalized + * are likely to be unsigned. Move will do the needed conversion and + * optimizing passes will remove the copies if they are already floats. + */ + emit(MOV(range_inv, range)); + emit(MOV(unorm_f, unorm)); + + emit(SHADER_OPCODE_RCP, range_inv, range_inv); + emit(MUL(norm, unorm_f, range_inv)); +} + +void fs_visitor::visit(ir_texture *ir) { fs_inst *inst = NULL; -- 1.8.3.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev