chromium/third_party/angle/src/compiler/translator/tree_ops/glsl/ScalarizeVecAndMatConstructorArgs.cpp

//
// Copyright 2002 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Scalarize vector and matrix constructor args, so that vectors built from components don't have
// matrix arguments, and matrices built from components don't have vector arguments. This avoids
// driver bugs around vector and matrix constructors.
//

#include "compiler/translator/tree_ops/glsl/ScalarizeVecAndMatConstructorArgs.h"

#include "angle_gl.h"
#include "common/angleutils.h"
#include "compiler/translator/Compiler.h"
#include "compiler/translator/tree_util/IntermNode_util.h"
#include "compiler/translator/tree_util/IntermTraverse.h"

namespace sh
{

namespace
{
const TType *GetHelperType(const TType &type, TQualifier qualifier)
{}

// Traverser that converts a vector or matrix constructor to one that only uses scalars.  To support
// all the various places such a constructor could be found, a helper function is created for each
// such constructor.  The helper function takes the constructor arguments and creates the object.
//
// Constructors that are transformed are:
//
// - vecN(scalar): translates to vecN(scalar, ..., scalar)
// - vecN(vec1, vec2, ...): translates to vecN(vec1.x, vec1.y, vec2.x, ...)
// - vecN(matrix): translates to vecN(matrix[0][0], matrix[0][1], ...)
// - matNxM(scalar): translates to matNxM(scalar, 0, ..., 0
//                                        0, scalar, ..., 0
//                                        ...
//                                        0, 0, ..., scalar)
// - matNxM(vec1, vec2, ...): translates to matNxM(vec1.x, vec1.y, vec2.x, ...)
// - matNxM(matrixAxB): translates to matNxM(matrix[0][0], matrix[0][1], ..., 0
//                                           matrix[1][0], matrix[1][1], ..., 0
//                                           ...
//                                           0,            0,            ..., 1)
//
class ScalarizeTraverser : public TIntermTraverser
{};

bool ScalarizeTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
{}

bool ScalarizeTraverser::shouldScalarize(TIntermTyped *typed)
{}

const TFunction *ScalarizeTraverser::createHelper(TIntermAggregate *node)
{}

TIntermTyped *ScalarizeTraverser::createHelperCall(TIntermAggregate *node, const TFunction *helper)
{}

void ScalarizeTraverser::addHelperDefinition(const TFunction *helper, TIntermBlock *body)
{}

TIntermTyped *ScalarizeTraverser::createConstructor(TIntermTyped *typed)
{}

// Extract enough scalar arguments from the arguments of helper to produce enough arguments for the
// constructor call (given in componentCount).
void ScalarizeTraverser::extractComponents(const TFunction *helper,
                                           size_t componentCount,
                                           TIntermSequence *componentsOut)
{}

void ScalarizeTraverser::createConstructorVectorFromScalar(TIntermAggregate *node,
                                                           const TFunction *helper,
                                                           TIntermSequence *constructorArgsOut)
{}

void ScalarizeTraverser::createConstructorVectorFromMultiple(TIntermAggregate *node,
                                                             const TFunction *helper,
                                                             TIntermSequence *constructorArgsOut)
{}

void ScalarizeTraverser::createConstructorMatrixFromScalar(TIntermAggregate *node,
                                                           const TFunction *helper,
                                                           TIntermSequence *constructorArgsOut)
{}

void ScalarizeTraverser::createConstructorMatrixFromVectors(TIntermAggregate *node,
                                                            const TFunction *helper,
                                                            TIntermSequence *constructorArgsOut)
{}

void ScalarizeTraverser::createConstructorMatrixFromMatrix(TIntermAggregate *node,
                                                           const TFunction *helper,
                                                           TIntermSequence *constructorArgsOut)
{}

bool ScalarizeTraverser::update(TCompiler *compiler, TIntermBlock *root)
{}
}  // namespace

bool ScalarizeVecAndMatConstructorArgs(TCompiler *compiler,
                                       TIntermBlock *root,
                                       TSymbolTable *symbolTable)
{}
}  // namespace sh