From 95c20be56372197a2a0d284226cb79d7398353dc Mon Sep 17 00:00:00 2001 From: M Henning Date: Sat, 19 Aug 2023 12:08:01 -0400 Subject: [PATCH] nv/codegen: Merge from_common into from_nir Reviewed-by: Karol Herbst Part-of: --- src/nouveau/codegen/meson.build | 2 - src/nouveau/codegen/nv50_ir_from_common.cpp | 56 --------------------- src/nouveau/codegen/nv50_ir_from_common.h | 40 --------------- src/nouveau/codegen/nv50_ir_from_nir.cpp | 38 ++++++++++++-- 4 files changed, 34 insertions(+), 102 deletions(-) delete mode 100644 src/nouveau/codegen/nv50_ir_from_common.cpp delete mode 100644 src/nouveau/codegen/nv50_ir_from_common.h diff --git a/src/nouveau/codegen/meson.build b/src/nouveau/codegen/meson.build index 61ce61ffc9e..89883429388 100644 --- a/src/nouveau/codegen/meson.build +++ b/src/nouveau/codegen/meson.build @@ -25,8 +25,6 @@ files_libnouveau_codegen = files( 'nv50_ir_build_util.h', 'nv50_ir_driver.h', 'nv50_ir_emit_nv50.cpp', - 'nv50_ir_from_common.cpp', - 'nv50_ir_from_common.h', 'nv50_ir_from_nir.cpp', 'nv50_ir_graph.cpp', 'nv50_ir_graph.h', diff --git a/src/nouveau/codegen/nv50_ir_from_common.cpp b/src/nouveau/codegen/nv50_ir_from_common.cpp deleted file mode 100644 index 5b22bd167c6..00000000000 --- a/src/nouveau/codegen/nv50_ir_from_common.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2011 Christoph Bumiller - * - * 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 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. - */ - -#include "nv50_ir_from_common.h" - -namespace nv50_ir { - -ConverterCommon::ConverterCommon(Program *prog, nv50_ir_prog_info *info, - nv50_ir_prog_info_out *info_out) - : BuildUtil(prog), - info(info), - info_out(info_out) {} - -uint8_t -ConverterCommon::translateInterpMode(const struct nv50_ir_varying *var, operation& op) -{ - uint8_t mode = NV50_IR_INTERP_PERSPECTIVE; - - if (var->flat) - mode = NV50_IR_INTERP_FLAT; - else - if (var->linear) - mode = NV50_IR_INTERP_LINEAR; - else - if (var->sc) - mode = NV50_IR_INTERP_SC; - - op = (mode == NV50_IR_INTERP_PERSPECTIVE || mode == NV50_IR_INTERP_SC) - ? OP_PINTERP : OP_LINTERP; - - if (var->centroid) - mode |= NV50_IR_INTERP_CENTROID; - - return mode; -} - -} // namespace nv50_ir diff --git a/src/nouveau/codegen/nv50_ir_from_common.h b/src/nouveau/codegen/nv50_ir_from_common.h deleted file mode 100644 index 422396cfc59..00000000000 --- a/src/nouveau/codegen/nv50_ir_from_common.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2011 Christoph Bumiller - * - * 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 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. - */ - -#include "nv50_ir.h" -#include "nv50_ir_build_util.h" - -namespace nv50_ir { - -class ConverterCommon : public BuildUtil -{ -public: - ConverterCommon(Program *, nv50_ir_prog_info *, nv50_ir_prog_info_out *); -protected: - uint8_t translateInterpMode(const struct nv50_ir_varying *var, operation& op); - - struct nv50_ir_prog_info *info; - struct nv50_ir_prog_info_out *info_out; - Value *outBase; // base address of vertex out patch (for TCP) -}; - -} // namespace nv50_ir diff --git a/src/nouveau/codegen/nv50_ir_from_nir.cpp b/src/nouveau/codegen/nv50_ir_from_nir.cpp index b6a36433c99..c393f7b708f 100644 --- a/src/nouveau/codegen/nv50_ir_from_nir.cpp +++ b/src/nouveau/codegen/nv50_ir_from_nir.cpp @@ -29,7 +29,6 @@ #include "util/u_prim.h" #include "nv50_ir.h" -#include "nv50_ir_from_common.h" #include "nv50_ir_lowering_helper.h" #include "nv50_ir_target.h" #include "nv50_ir_util.h" @@ -94,7 +93,7 @@ nv50_nir_lower_load_user_clip_plane(nir_shader *nir, struct nv50_ir_prog_info *i info); } -class Converter : public ConverterCommon +class Converter : public BuildUtil { public: Converter(Program *, nir_shader *, nv50_ir_prog_info *, nv50_ir_prog_info_out *); @@ -132,6 +131,7 @@ private: uint32_t getSlotAddress(nir_intrinsic_instr *, uint8_t idx, uint8_t slot); + uint8_t translateInterpMode(const struct nv50_ir_varying *var, operation& op); void setInterpolate(nv50_ir_varying *, uint8_t, bool centroid, @@ -191,6 +191,9 @@ private: // tex stuff unsigned int getNIRArgCount(TexInstruction::Target&); + struct nv50_ir_prog_info *info; + struct nv50_ir_prog_info_out *info_out; + nir_shader *nir; NirDefMap ssaDefs; @@ -205,6 +208,7 @@ private: Instruction *immInsertPos; int clipVertexOutput; + Value *outBase; // base address of vertex out patch (for TCP) union { struct { @@ -215,13 +219,16 @@ private: Converter::Converter(Program *prog, nir_shader *nir, nv50_ir_prog_info *info, nv50_ir_prog_info_out *info_out) - : ConverterCommon(prog, info, info_out), + : BuildUtil(prog), + info(info), + info_out(info_out), nir(nir), curLoopDepth(0), curIfDepth(0), exit(NULL), immInsertPos(NULL), - clipVertexOutput(-1) + clipVertexOutput(-1), + outBase(nullptr) { zero = mkImm((uint32_t)0); } @@ -832,6 +839,29 @@ vert_attrib_to_tgsi_semantic(gl_vert_attrib slot, unsigned *name, unsigned *inde } } +uint8_t +Converter::translateInterpMode(const struct nv50_ir_varying *var, operation& op) +{ + uint8_t mode = NV50_IR_INTERP_PERSPECTIVE; + + if (var->flat) + mode = NV50_IR_INTERP_FLAT; + else + if (var->linear) + mode = NV50_IR_INTERP_LINEAR; + else + if (var->sc) + mode = NV50_IR_INTERP_SC; + + op = (mode == NV50_IR_INTERP_PERSPECTIVE || mode == NV50_IR_INTERP_SC) + ? OP_PINTERP : OP_LINTERP; + + if (var->centroid) + mode |= NV50_IR_INTERP_CENTROID; + + return mode; +} + void Converter::setInterpolate(nv50_ir_varying *var, uint8_t mode,