BsD3D11HLSLProgramFactory.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. }
  45. if (gpuProg != nullptr)
  46. gpuProg->_setThisPtr(gpuProg);
  47. return gpuProg;
  48. }
  49. SPtr<GpuProgramCore> D3D11HLSLProgramFactory::create(GpuProgramType type)
  50. {
  51. SPtr<GpuProgramCore> gpuProg;
  52. switch (type)
  53. {
  54. case GPT_VERTEX_PROGRAM:
  55. gpuProg = bs_shared_ptr<D3D11GpuVertexProgramCore>(new (bs_alloc<D3D11GpuVertexProgramCore>())
  56. D3D11GpuVertexProgramCore("", "", GPP_NONE));
  57. break;
  58. case GPT_FRAGMENT_PROGRAM:
  59. gpuProg = bs_shared_ptr<D3D11GpuFragmentProgramCore>(new (bs_alloc<D3D11GpuFragmentProgramCore>())
  60. D3D11GpuFragmentProgramCore("", "", GPP_NONE));
  61. break;
  62. case GPT_HULL_PROGRAM:
  63. gpuProg = bs_shared_ptr<D3D11GpuHullProgramCore>(new (bs_alloc<D3D11GpuHullProgramCore>())
  64. D3D11GpuHullProgramCore("", "", GPP_NONE));
  65. break;
  66. case GPT_DOMAIN_PROGRAM:
  67. gpuProg = bs_shared_ptr<D3D11GpuDomainProgramCore>(new (bs_alloc<D3D11GpuDomainProgramCore>())
  68. D3D11GpuDomainProgramCore("", "", GPP_NONE));
  69. break;
  70. case GPT_GEOMETRY_PROGRAM:
  71. gpuProg = bs_shared_ptr<D3D11GpuGeometryProgramCore>(new (bs_alloc<D3D11GpuGeometryProgramCore>())
  72. D3D11GpuGeometryProgramCore("", "", GPP_NONE, false));
  73. break;
  74. }
  75. if (gpuProg != nullptr)
  76. gpuProg->_setThisPtr(gpuProg);
  77. return gpuProg;
  78. }
  79. }