2
0

BsGLSLProgramPipelineManager.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include "BsGLPrerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /**
  6. * @brief Wrapper around OpenGL pipeline object.
  7. */
  8. struct GLSLProgramPipeline
  9. {
  10. GLuint glHandle;
  11. };
  12. /**
  13. * @brief Managed OpenGL pipeline objects that are used for binding a certain combination
  14. * of GPU programs to the render system.
  15. *
  16. * @note In OpenGL you cannot bind GPU programs to the pipeline manually. Instead as a preprocessing step
  17. * you create a pipeline object containing the programs you plan on using, and then later you bind the
  18. * previously created pipeline object.
  19. */
  20. class GLSLProgramPipelineManager
  21. {
  22. public:
  23. ~GLSLProgramPipelineManager();
  24. /**
  25. * @brief Creates or returns an existing pipeline that uses the provided combination of GPU programs. Provide
  26. * null for unused programs.
  27. */
  28. const GLSLProgramPipeline* getPipeline(GLSLGpuProgramCore* vertexProgram, GLSLGpuProgramCore* fragmentProgram,
  29. GLSLGpuProgramCore* geometryProgram, GLSLGpuProgramCore* hullProgram, GLSLGpuProgramCore* domainProgram);
  30. private:
  31. /**
  32. * @brief Key that uniquely identifies a pipeline object.
  33. */
  34. struct ProgramPipelineKey
  35. {
  36. UINT32 vertexProgKey;
  37. UINT32 fragmentProgKey;
  38. UINT32 geometryProgKey;
  39. UINT32 hullProgKey;
  40. UINT32 domainProgKey;
  41. };
  42. /**
  43. * @brief Used for calculating a hash code from pipeline object key.
  44. */
  45. class ProgramPipelineKeyHashFunction
  46. {
  47. public:
  48. ::std::size_t operator()(const ProgramPipelineKey &key) const;
  49. };
  50. /**
  51. * @brief Used for comparing two pipeline objects for equality.
  52. */
  53. class ProgramPipelineKeyEqual
  54. {
  55. public:
  56. bool operator()(const ProgramPipelineKey &a, const ProgramPipelineKey &b) const;
  57. };
  58. typedef UnorderedMap<ProgramPipelineKey, GLSLProgramPipeline, ProgramPipelineKeyHashFunction, ProgramPipelineKeyEqual> ProgramPipelineMap;
  59. ProgramPipelineMap mPipelines;
  60. };
  61. }