BsGLSLProgramPipelineManager.h 2.2 KB

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