BsD3D11HLSLProgramFactory.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 bs { namespace ct
  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<GpuProgram> D3D11HLSLProgramFactory::create(const GPU_PROGRAM_DESC& desc, GpuDeviceFlags deviceMask)
  19. {
  20. SPtr<GpuProgram> gpuProg;
  21. switch (desc.type)
  22. {
  23. case GPT_VERTEX_PROGRAM:
  24. gpuProg = bs_shared_ptr<D3D11GpuVertexProgram>(new (bs_alloc<D3D11GpuVertexProgram>())
  25. D3D11GpuVertexProgram(desc, deviceMask));
  26. break;
  27. case GPT_FRAGMENT_PROGRAM:
  28. gpuProg = bs_shared_ptr<D3D11GpuFragmentProgram>(new (bs_alloc<D3D11GpuFragmentProgram>())
  29. D3D11GpuFragmentProgram(desc, deviceMask));
  30. break;
  31. case GPT_HULL_PROGRAM:
  32. gpuProg = bs_shared_ptr<D3D11GpuHullProgram>(new (bs_alloc<D3D11GpuHullProgram>())
  33. D3D11GpuHullProgram(desc, deviceMask));
  34. break;
  35. case GPT_DOMAIN_PROGRAM:
  36. gpuProg = bs_shared_ptr<D3D11GpuDomainProgram>(new (bs_alloc<D3D11GpuDomainProgram>())
  37. D3D11GpuDomainProgram(desc, deviceMask));
  38. break;
  39. case GPT_GEOMETRY_PROGRAM:
  40. gpuProg = bs_shared_ptr<D3D11GpuGeometryProgram>(new (bs_alloc<D3D11GpuGeometryProgram>())
  41. D3D11GpuGeometryProgram(desc, deviceMask));
  42. break;
  43. case GPT_COMPUTE_PROGRAM:
  44. gpuProg = bs_shared_ptr<D3D11GpuComputeProgram>(new (bs_alloc<D3D11GpuComputeProgram>())
  45. D3D11GpuComputeProgram(desc, deviceMask));
  46. break;
  47. }
  48. if (gpuProg != nullptr)
  49. gpuProg->_setThisPtr(gpuProg);
  50. return gpuProg;
  51. }
  52. SPtr<GpuProgram> D3D11HLSLProgramFactory::create(GpuProgramType type, GpuDeviceFlags deviceMask)
  53. {
  54. SPtr<GpuProgram> gpuProg;
  55. GPU_PROGRAM_DESC desc;
  56. desc.type = type;
  57. switch (type)
  58. {
  59. case GPT_VERTEX_PROGRAM:
  60. gpuProg = bs_shared_ptr<D3D11GpuVertexProgram>(new (bs_alloc<D3D11GpuVertexProgram>())
  61. D3D11GpuVertexProgram(desc, deviceMask));
  62. break;
  63. case GPT_FRAGMENT_PROGRAM:
  64. gpuProg = bs_shared_ptr<D3D11GpuFragmentProgram>(new (bs_alloc<D3D11GpuFragmentProgram>())
  65. D3D11GpuFragmentProgram(desc, deviceMask));
  66. break;
  67. case GPT_HULL_PROGRAM:
  68. gpuProg = bs_shared_ptr<D3D11GpuHullProgram>(new (bs_alloc<D3D11GpuHullProgram>())
  69. D3D11GpuHullProgram(desc, deviceMask));
  70. break;
  71. case GPT_DOMAIN_PROGRAM:
  72. gpuProg = bs_shared_ptr<D3D11GpuDomainProgram>(new (bs_alloc<D3D11GpuDomainProgram>())
  73. D3D11GpuDomainProgram(desc, deviceMask));
  74. break;
  75. case GPT_GEOMETRY_PROGRAM:
  76. gpuProg = bs_shared_ptr<D3D11GpuGeometryProgram>(new (bs_alloc<D3D11GpuGeometryProgram>())
  77. D3D11GpuGeometryProgram(desc, deviceMask));
  78. break;
  79. case GPT_COMPUTE_PROGRAM:
  80. gpuProg = bs_shared_ptr<D3D11GpuComputeProgram>(new (bs_alloc<D3D11GpuComputeProgram>())
  81. D3D11GpuComputeProgram(desc, deviceMask));
  82. break;
  83. }
  84. if (gpuProg != nullptr)
  85. gpuProg->_setThisPtr(gpuProg);
  86. return gpuProg;
  87. }
  88. }}