"Fossies" - the Fresh Open Source Software Archive

Member "mesa-20.1.8/src/gallium/drivers/nouveau/codegen/nv50_ir_from_common.cpp" (16 Sep 2020, 3323 Bytes) of package /linux/misc/mesa-20.1.8.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "nv50_ir_from_common.cpp" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright 2011 Christoph Bumiller
    3  *
    4  * Permission is hereby granted, free of charge, to any person obtaining a
    5  * copy of this software and associated documentation files (the "Software"),
    6  * to deal in the Software without restriction, including without limitation
    7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    8  * and/or sell copies of the Software, and to permit persons to whom the
    9  * Software is furnished to do so, subject to the following conditions:
   10  *
   11  * The above copyright notice and this permission notice shall be included in
   12  * all copies or substantial portions of the Software.
   13  *
   14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   20  * OTHER DEALINGS IN THE SOFTWARE.
   21  */
   22 
   23 #include "codegen/nv50_ir_from_common.h"
   24 
   25 namespace nv50_ir {
   26 
   27 ConverterCommon::ConverterCommon(Program *prog, nv50_ir_prog_info *info)
   28    :  BuildUtil(prog),
   29       info(info) {}
   30 
   31 ConverterCommon::Subroutine *
   32 ConverterCommon::getSubroutine(unsigned ip)
   33 {
   34    std::map<unsigned, Subroutine>::iterator it = sub.map.find(ip);
   35 
   36    if (it == sub.map.end())
   37       it = sub.map.insert(std::make_pair(
   38               ip, Subroutine(new Function(prog, "SUB", ip)))).first;
   39 
   40    return &it->second;
   41 }
   42 
   43 ConverterCommon::Subroutine *
   44 ConverterCommon::getSubroutine(Function *f)
   45 {
   46    unsigned ip = f->getLabel();
   47    std::map<unsigned, Subroutine>::iterator it = sub.map.find(ip);
   48 
   49    if (it == sub.map.end())
   50       it = sub.map.insert(std::make_pair(ip, Subroutine(f))).first;
   51 
   52    return &it->second;
   53 }
   54 
   55 uint8_t
   56 ConverterCommon::translateInterpMode(const struct nv50_ir_varying *var, operation& op)
   57 {
   58    uint8_t mode = NV50_IR_INTERP_PERSPECTIVE;
   59 
   60    if (var->flat)
   61       mode = NV50_IR_INTERP_FLAT;
   62    else
   63    if (var->linear)
   64       mode = NV50_IR_INTERP_LINEAR;
   65    else
   66    if (var->sc)
   67       mode = NV50_IR_INTERP_SC;
   68 
   69    op = (mode == NV50_IR_INTERP_PERSPECTIVE || mode == NV50_IR_INTERP_SC)
   70       ? OP_PINTERP : OP_LINTERP;
   71 
   72    if (var->centroid)
   73       mode |= NV50_IR_INTERP_CENTROID;
   74 
   75    return mode;
   76 }
   77 
   78 void
   79 ConverterCommon::handleUserClipPlanes()
   80 {
   81    Value *res[8];
   82    int n, i, c;
   83 
   84    for (c = 0; c < 4; ++c) {
   85       for (i = 0; i < info->io.genUserClip; ++i) {
   86          Symbol *sym = mkSymbol(FILE_MEMORY_CONST, info->io.auxCBSlot,
   87                                 TYPE_F32, info->io.ucpBase + i * 16 + c * 4);
   88          Value *ucp = mkLoadv(TYPE_F32, sym, NULL);
   89          if (c == 0)
   90             res[i] = mkOp2v(OP_MUL, TYPE_F32, getScratch(), clipVtx[c], ucp);
   91          else
   92             mkOp3(OP_MAD, TYPE_F32, res[i], clipVtx[c], ucp, res[i]);
   93       }
   94    }
   95 
   96    const int first = info->numOutputs - (info->io.genUserClip + 3) / 4;
   97 
   98    for (i = 0; i < info->io.genUserClip; ++i) {
   99       n = i / 4 + first;
  100       c = i % 4;
  101       Symbol *sym =
  102          mkSymbol(FILE_SHADER_OUTPUT, 0, TYPE_F32, info->out[n].slot[c] * 4);
  103       mkStore(OP_EXPORT, TYPE_F32, sym, NULL, res[i]);
  104    }
  105 }
  106 
  107 } // namespace nv50_ir