BsGpuProgram.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "RenderAPI/BsGpuProgram.h"
  4. #include "RenderAPI/BsRenderAPICapabilities.h"
  5. #include "RenderAPI/BsRenderAPI.h"
  6. #include "RenderAPI/BsGpuParams.h"
  7. #include "RenderAPI/BsGpuParamDesc.h"
  8. #include "Managers/BsGpuProgramManager.h"
  9. #include "RTTI/BsGpuProgramRTTI.h"
  10. namespace bs
  11. {
  12. GpuProgramProperties::GpuProgramProperties(const String& source, const String& entryPoint, GpuProgramType gptype)
  13. :mType(gptype), mEntryPoint(entryPoint), mSource(source)
  14. { }
  15. GpuProgram::GpuProgram(const GPU_PROGRAM_DESC& desc)
  16. : mNeedsAdjacencyInfo(desc.requiresAdjacency), mLanguage(desc.language)
  17. , mProperties(desc.source, desc.entryPoint, desc.type)
  18. {
  19. }
  20. bool GpuProgram::isCompiled() const
  21. {
  22. return getCore()->isCompiled();
  23. }
  24. String GpuProgram::getCompileErrorMessage() const
  25. {
  26. return getCore()->getCompileErrorMessage();
  27. }
  28. SPtr<GpuParamDesc> GpuProgram::getParamDesc() const
  29. {
  30. return getCore()->getParamDesc();
  31. }
  32. SPtr<ct::GpuProgram> GpuProgram::getCore() const
  33. {
  34. return std::static_pointer_cast<ct::GpuProgram>(mCoreSpecific);
  35. }
  36. SPtr<ct::CoreObject> GpuProgram::createCore() const
  37. {
  38. GPU_PROGRAM_DESC desc;
  39. desc.source = mProperties.getSource();
  40. desc.entryPoint = mProperties.getEntryPoint();
  41. desc.language = mLanguage;
  42. desc.type = mProperties.getType();
  43. desc.requiresAdjacency = mNeedsAdjacencyInfo;
  44. return ct::GpuProgramManager::instance().createInternal(desc);
  45. }
  46. SPtr<GpuProgram> GpuProgram::create(const GPU_PROGRAM_DESC& desc)
  47. {
  48. return GpuProgramManager::instance().create(desc);
  49. }
  50. /************************************************************************/
  51. /* SERIALIZATION */
  52. /************************************************************************/
  53. RTTITypeBase* GpuProgram::getRTTIStatic()
  54. {
  55. return GpuProgramRTTI::instance();
  56. }
  57. RTTITypeBase* GpuProgram::getRTTI() const
  58. {
  59. return GpuProgram::getRTTIStatic();
  60. }
  61. namespace ct
  62. {
  63. GpuProgram::GpuProgram(const GPU_PROGRAM_DESC& desc, GpuDeviceFlags deviceMask)
  64. :mNeedsAdjacencyInfo(desc.requiresAdjacency), mIsCompiled(false), mProperties(desc.source, desc.entryPoint,
  65. desc.type)
  66. {
  67. mParametersDesc = bs_shared_ptr_new<GpuParamDesc>();
  68. }
  69. bool GpuProgram::isSupported() const
  70. {
  71. return true;
  72. }
  73. SPtr<GpuProgram> GpuProgram::create(const GPU_PROGRAM_DESC& desc, GpuDeviceFlags deviceMask)
  74. {
  75. return GpuProgramManager::instance().create(desc, deviceMask);
  76. }
  77. }
  78. }