--- src/mesa/drivers/dri/i965/Makefile.sources | 1 + src/mesa/drivers/dri/i965/brw_nir_intrinsics.h | 80 ++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/mesa/drivers/dri/i965/brw_nir_intrinsics.h
diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index fd6d840..d07b6fe 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -82,6 +82,7 @@ i965_FILES = \ brw_multisample_state.h \ brw_nir.h \ brw_nir.c \ + brw_nir_intrinsics.h \ brw_nir_analyze_boolean_resolves.c \ brw_object_purgeable.c \ brw_packed_float.c \ diff --git a/src/mesa/drivers/dri/i965/brw_nir_intrinsics.h b/src/mesa/drivers/dri/i965/brw_nir_intrinsics.h new file mode 100644 index 0000000..65edc40 --- /dev/null +++ b/src/mesa/drivers/dri/i965/brw_nir_intrinsics.h @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright © 2014-2015 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef BRW_NIR_INTRINSICS_H +#define BRW_NIR_INTRINSICS_H + +#include "brw_ir_surface_builder.h" +#include "main/shaderimage.h" + +namespace brw { + /** + * Entry point for translating NIR atomic counter intrinsics. + */ + template<typename V, typename B> + void + emit_atomic_counter_intrinsic(V *v, const B &bld, + const nir_intrinsic_instr *instr) + { + using namespace surface_access; + typedef typename B::vector_builder::src_reg src_reg; + typename B::vector_builder vbld = bld.vector(); + + /* Get the arguments of the atomic intrinsic. */ + const src_reg offset(v->get_nir_src(instr->src[0])); + const src_reg surface(v->stage_prog_data->binding_table.abo_start + + instr->const_index[0]); + + /* Get some metadata from the atomic intrinsic. */ + const unsigned rsize = (nir_intrinsic_infos[instr->intrinsic].has_dest ? + 1 : 0); + src_reg tmp; + + /* Emit a surface read or atomic op. */ + switch (instr->intrinsic) { + case nir_intrinsic_atomic_counter_read: + tmp = emit_untyped_read(vbld, surface, offset, 1, 1); + break; + + case nir_intrinsic_atomic_counter_inc: + tmp = emit_untyped_atomic(vbld, surface, offset, src_reg(), + src_reg(), 1, rsize, BRW_AOP_INC); + break; + + case nir_intrinsic_atomic_counter_dec: + tmp = emit_untyped_atomic(vbld, surface, offset, src_reg(), + src_reg(), 1, rsize, BRW_AOP_PREDEC); + break; + + default: + unreachable("Unreachable"); + } + + /* Assign the result. */ + if (rsize) + vbld.MOV(v->get_nir_dest(instr->dest), tmp); + } +} + +#endif -- 2.3.5 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev