BsD3D11HLSLProgramFactory.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsD3D11HLSLProgramFactory.h"
  4. #include "BsD3D11GpuProgram.h"
  5. namespace BansheeEngine
  6. {
  7. const String D3D11HLSLProgramFactory::LANGUAGE_NAME = "hlsl";
  8. D3D11HLSLProgramFactory::D3D11HLSLProgramFactory()
  9. {
  10. }
  11. D3D11HLSLProgramFactory::~D3D11HLSLProgramFactory()
  12. {
  13. }
  14. const String& D3D11HLSLProgramFactory::getLanguage(void) const
  15. {
  16. return LANGUAGE_NAME;
  17. }
  18. SPtr<GpuProgramCore> D3D11HLSLProgramFactory::create(const String& source, const String& entryPoint,
  19. GpuProgramType gptype, GpuProgramProfile profile, bool requireAdjacencyInfo)
  20. {
  21. SPtr<GpuProgramCore> gpuProg;
  22. switch (gptype)
  23. {
  24. case GPT_VERTEX_PROGRAM:
  25. gpuProg = bs_shared_ptr<D3D11GpuVertexProgramCore>(new (bs_alloc<D3D11GpuVertexProgramCore>())
  26. D3D11GpuVertexProgramCore(source, entryPoint, profile));
  27. break;
  28. case GPT_FRAGMENT_PROGRAM:
  29. gpuProg = bs_shared_ptr<D3D11GpuFragmentProgramCore>(new (bs_alloc<D3D11GpuFragmentProgramCore>())
  30. D3D11GpuFragmentProgramCore(source, entryPoint, profile));
  31. break;
  32. case GPT_HULL_PROGRAM:
  33. gpuProg = bs_shared_ptr<D3D11GpuHullProgramCore>(new (bs_alloc<D3D11GpuHullProgramCore>())
  34. D3D11GpuHullProgramCore(source, entryPoint, profile));
  35. break;
  36. case GPT_DOMAIN_PROGRAM:
  37. gpuProg = bs_shared_ptr<D3D11GpuDomainProgramCore>(new (bs_alloc<D3D11GpuDomainProgramCore>())
  38. D3D11GpuDomainProgramCore(source, entryPoint, profile));
  39. break;
  40. case GPT_GEOMETRY_PROGRAM:
  41. gpuProg = bs_shared_ptr<D3D11GpuGeometryProgramCore>(new (bs_alloc<D3D11GpuGeometryProgramCore>())
  42. D3D11GpuGeometryProgramCore(source, entryPoint, profile, requireAdjacencyInfo));
  43. break;
  44. case GPT_COMPUTE_PROGRAM:
  45. gpuProg = bs_shared_ptr<D3D11GpuComputeProgramCore>(new (bs_alloc<D3D11GpuComputeProgramCore>())
  46. D3D11GpuComputeProgramCore(source, entryPoint, profile));
  47. break;
  48. }
  49. if (gpuProg != nullptr)
  50. gpuProg->_setThisPtr(gpuProg);
  51. return gpuProg;
  52. }
  53. SPtr<GpuProgramCore> D3D11HLSLProgramFactory::create(GpuProgramType type)
  54. {
  55. SPtr<GpuProgramCore> gpuProg;
  56. switch (type)
  57. {
  58. case GPT_VERTEX_PROGRAM:
  59. gpuProg = bs_shared_ptr<D3D11GpuVertexProgramCore>(new (bs_alloc<D3D11GpuVertexProgramCore>())
  60. D3D11GpuVertexProgramCore("", "", GPP_NONE));
  61. break;
  62. case GPT_FRAGMENT_PROGRAM:
  63. gpuProg = bs_shared_ptr<D3D11GpuFragmentProgramCore>(new (bs_alloc<D3D11GpuFragmentProgramCore>())
  64. D3D11GpuFragmentProgramCore("", "", GPP_NONE));
  65. break;
  66. case GPT_HULL_PROGRAM:
  67. gpuProg = bs_shared_ptr<D3D11GpuHullProgramCore>(new (bs_alloc<D3D11GpuHullProgramCore>())
  68. D3D11GpuHullProgramCore("", "", GPP_NONE));
  69. break;
  70. case GPT_DOMAIN_PROGRAM:
  71. gpuProg = bs_shared_ptr<D3D11GpuDomainProgramCore>(new (bs_alloc<D3D11GpuDomainProgramCore>())
  72. D3D11GpuDomainProgramCore("", "", GPP_NONE));
  73. break;
  74. case GPT_GEOMETRY_PROGRAM:
  75. gpuProg = bs_shared_ptr<D3D11GpuGeometryProgramCore>(new (bs_alloc<D3D11GpuGeometryProgramCore>())
  76. D3D11GpuGeometryProgramCore("", "", GPP_NONE, false));
  77. break;
  78. case GPT_COMPUTE_PROGRAM:
  79. gpuProg = bs_shared_ptr<D3D11GpuComputeProgramCore>(new (bs_alloc<D3D11GpuComputeProgramCore>())
  80. D3D11GpuComputeProgramCore("", "", GPP_NONE));
  81. break;
  82. }
  83. if (gpuProg != nullptr)
  84. gpuProg->_setThisPtr(gpuProg);
  85. return gpuProg;
  86. }
  87. }