BsD3D11HLSLProgramFactory.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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, GenAlloc>(new (bs_alloc<D3D11GpuVertexProgramCore, GenAlloc>())
  24. D3D11GpuVertexProgramCore(source, entryPoint, profile));
  25. case GPT_FRAGMENT_PROGRAM:
  26. gpuProg = bs_shared_ptr<D3D11GpuFragmentProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuFragmentProgramCore, GenAlloc>())
  27. D3D11GpuFragmentProgramCore(source, entryPoint, profile));
  28. case GPT_HULL_PROGRAM:
  29. gpuProg = bs_shared_ptr<D3D11GpuHullProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuHullProgramCore, GenAlloc>())
  30. D3D11GpuHullProgramCore(source, entryPoint, profile));
  31. case GPT_DOMAIN_PROGRAM:
  32. gpuProg = bs_shared_ptr<D3D11GpuDomainProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuDomainProgramCore, GenAlloc>())
  33. D3D11GpuDomainProgramCore(source, entryPoint, profile));
  34. case GPT_GEOMETRY_PROGRAM:
  35. gpuProg = bs_shared_ptr<D3D11GpuGeometryProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuGeometryProgramCore, GenAlloc>())
  36. D3D11GpuGeometryProgramCore(source, entryPoint, profile, requireAdjacencyInfo));
  37. }
  38. if (gpuProg != nullptr)
  39. gpuProg->_setThisPtr(gpuProg);
  40. return gpuProg;
  41. }
  42. SPtr<GpuProgramCore> D3D11HLSLProgramFactory::create(GpuProgramType type)
  43. {
  44. SPtr<GpuProgramCore> gpuProg;
  45. switch (type)
  46. {
  47. case GPT_VERTEX_PROGRAM:
  48. gpuProg = bs_shared_ptr<D3D11GpuVertexProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuVertexProgramCore, GenAlloc>())
  49. D3D11GpuVertexProgramCore("", "", GPP_NONE));
  50. case GPT_FRAGMENT_PROGRAM:
  51. gpuProg = bs_shared_ptr<D3D11GpuFragmentProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuFragmentProgramCore, GenAlloc>())
  52. D3D11GpuFragmentProgramCore("", "", GPP_NONE));
  53. case GPT_HULL_PROGRAM:
  54. gpuProg = bs_shared_ptr<D3D11GpuHullProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuHullProgramCore, GenAlloc>())
  55. D3D11GpuHullProgramCore("", "", GPP_NONE));
  56. case GPT_DOMAIN_PROGRAM:
  57. gpuProg = bs_shared_ptr<D3D11GpuDomainProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuDomainProgramCore, GenAlloc>())
  58. D3D11GpuDomainProgramCore("", "", GPP_NONE));
  59. case GPT_GEOMETRY_PROGRAM:
  60. gpuProg = bs_shared_ptr<D3D11GpuGeometryProgramCore, GenAlloc>(new (bs_alloc<D3D11GpuGeometryProgramCore, GenAlloc>())
  61. D3D11GpuGeometryProgramCore("", "", GPP_NONE, false));
  62. }
  63. if (gpuProg != nullptr)
  64. gpuProg->_setThisPtr(gpuProg);
  65. return gpuProg;
  66. }
  67. }