BsD3D11HLSLProgramFactory.cpp 3.0 KB

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