shaderComp.h

Engine/source/shaderGen/shaderComp.h

More...

Classes:

class

This is to provide common functionalty needed by vertex and pixel main defs.

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23#ifndef _SHADERCOMP_H_
 24#define _SHADERCOMP_H_
 25
 26#ifndef _TVECTOR_H_
 27#include "core/util/tVector.h"
 28#endif
 29
 30#ifndef _MISCSHDRDAT_H_
 31#include "materials/miscShdrDat.h"
 32#endif
 33
 34class Stream;
 35struct Var;
 36
 37//**************************************************************************
 38// Shader Component - these objects are the main logical breakdown of a
 39//    high level shader.  They represent the various data structures
 40//    and the main() procedure necessary to create a shader.
 41//**************************************************************************
 42class ShaderComponent
 43{
 44public:
 45   virtual ~ShaderComponent() {}
 46   
 47   virtual void print( Stream &stream, bool isVerterShader ){};
 48   virtual void printOnMain( Stream &stream, bool isVerterShader ){};
 49};
 50
 51
 52//**************************************************************************
 53// Connector Struct Component - used for incoming Vertex struct and also the
 54//    "connection" struct shared by the vertex and pixel shader
 55//**************************************************************************
 56class ShaderConnector : public ShaderComponent
 57{
 58protected:
 59   enum Consts
 60   {
 61      NUM_TEX_REGS = 8,
 62   };
 63
 64   enum Elements
 65   {
 66      POSITION = 0,
 67      NORMAL,
 68      COLOR,
 69      NUM_BASIC_ELEMS
 70   };
 71
 72   Vector <Var*> mElementList;
 73
 74   U32 mCurTexElem;
 75   U32 mCurBlendIndicesElem;
 76   U32 mCurBlendWeightsElem;
 77   U8 mName[32];
 78
 79public:
 80
 81   ShaderConnector();
 82   virtual ~ShaderConnector();
 83
 84   U32 getCurTexElem() { return mCurTexElem; }
 85
 86   ///
 87   virtual Var* getElement(   RegisterType type, 
 88                              U32 numElements = 1, 
 89                              U32 numRegisters = -1 ) = 0;
 90
 91   virtual void setName( char *newName ) = 0;
 92   virtual void reset() = 0;
 93   virtual void sortVars() = 0;
 94
 95   virtual void print( Stream &stream, bool isVerterShader ) = 0;
 96};
 97
 98/// This is to provide common functionalty needed by vertex and pixel main defs
 99class ParamsDef : public ShaderComponent
100{
101protected:
102   virtual void assignConstantNumbers() {}
103};
104
105#endif // _SHADERCOMP_H_
106