shaderComp.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 ){};
  42. };
  43. //**************************************************************************
  44. // Connector Struct Component - used for incoming Vertex struct and also the
  45. // "connection" struct shared by the vertex and pixel shader
  46. //**************************************************************************
  47. class ShaderConnector : public ShaderComponent
  48. {
  49. protected:
  50. enum Consts
  51. {
  52. NUM_TEX_REGS = 8,
  53. };
  54. enum Elements
  55. {
  56. POSITION = 0,
  57. NORMAL,
  58. COLOR,
  59. NUM_BASIC_ELEMS
  60. };
  61. Vector <Var*> mElementList;
  62. U32 mCurTexElem;
  63. U8 mName[32];
  64. public:
  65. ShaderConnector();
  66. virtual ~ShaderConnector();
  67. ///
  68. virtual Var* getElement( RegisterType type,
  69. U32 numElements = 1,
  70. U32 numRegisters = -1 ) = 0;
  71. virtual void setName( char *newName ) = 0;
  72. virtual void reset() = 0;
  73. virtual void sortVars() = 0;
  74. virtual void print( Stream &stream ) = 0;
  75. };
  76. /// This is to provide common functionalty needed by vertex and pixel main defs
  77. class ParamsDef : public ShaderComponent
  78. {
  79. protected:
  80. virtual void assignConstantNumbers() {}
  81. };
  82. #endif // _SHADERCOMP_H_