shaderComp.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // 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 THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _SHADERCOMP_H_
  23. #define _SHADERCOMP_H_
  24. #ifndef _TVECTOR_H_
  25. #include "core/util/tVector.h"
  26. #endif
  27. #ifndef _MISCSHDRDAT_H_
  28. #include "materials/miscShdrDat.h"
  29. #endif
  30. class Stream;
  31. struct Var;
  32. //**************************************************************************
  33. // Shader Component - these objects are the main logical breakdown of a
  34. // high level shader. They represent the various data structures
  35. // and the main() procedure necessary to create a shader.
  36. //**************************************************************************
  37. class ShaderComponent
  38. {
  39. public:
  40. virtual ~ShaderComponent() {}
  41. virtual void print( Stream &stream, bool isVerterShader ){};
  42. virtual void printOnMain( Stream &stream, bool isVerterShader ){};
  43. };
  44. //**************************************************************************
  45. // Connector Struct Component - used for incoming Vertex struct and also the
  46. // "connection" struct shared by the vertex and pixel shader
  47. //**************************************************************************
  48. class ShaderConnector : public ShaderComponent
  49. {
  50. protected:
  51. enum Consts
  52. {
  53. NUM_TEX_REGS = 8,
  54. };
  55. enum Elements
  56. {
  57. POSITION = 0,
  58. NORMAL,
  59. COLOR,
  60. NUM_BASIC_ELEMS
  61. };
  62. Vector <Var*> mElementList;
  63. U32 mCurTexElem;
  64. U32 mCurBlendIndicesElem;
  65. U32 mCurBlendWeightsElem;
  66. U8 mName[32];
  67. public:
  68. ShaderConnector();
  69. virtual ~ShaderConnector();
  70. U32 getCurTexElem() { return mCurTexElem; }
  71. ///
  72. virtual Var* getElement( RegisterType type,
  73. U32 numElements = 1,
  74. U32 numRegisters = -1 ) = 0;
  75. virtual void setName( char *newName ) = 0;
  76. virtual void reset() = 0;
  77. virtual void sortVars() = 0;
  78. virtual void print( Stream &stream, bool isVerterShader ) = 0;
  79. };
  80. /// This is to provide common functionalty needed by vertex and pixel main defs
  81. class ParamsDef : public ShaderComponent
  82. {
  83. protected:
  84. virtual void assignConstantNumbers() {}
  85. };
  86. #endif // _SHADERCOMP_H_