BsD3D11HLSLProgramFactory.cpp 2.8 KB

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