CmHighLevelGpuProgram.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #include "CmHighLevelGpuProgram.h"
  25. #include "CmHighLevelGpuProgramManager.h"
  26. #include "CmRenderSystem.h"
  27. #include "CmException.h"
  28. #include "CmRenderSystem.h"
  29. #include "CmAsyncOp.h"
  30. #if CM_DEBUG_MODE
  31. #define THROW_IF_NOT_RENDER_THREAD throwIfNotRenderThread();
  32. #else
  33. #define THROW_IF_NOT_RENDER_THREAD
  34. #endif
  35. namespace CamelotEngine
  36. {
  37. //---------------------------------------------------------------------------
  38. HighLevelGpuProgram::HighLevelGpuProgram(const String& source, const String& entryPoint, const String& language,
  39. GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired)
  40. : GpuProgram(source, entryPoint, language, gptype, profile, isAdjacencyInfoRequired),
  41. mAssemblerProgram(0)
  42. {
  43. }
  44. //---------------------------------------------------------------------------
  45. HighLevelGpuProgram::~HighLevelGpuProgram()
  46. {
  47. }
  48. //---------------------------------------------------------------------------
  49. void HighLevelGpuProgram::initialize_internal()
  50. {
  51. if (isSupported())
  52. {
  53. // load constructed assembler program (if it exists)
  54. if (mAssemblerProgram != nullptr && mAssemblerProgram.get() != this)
  55. {
  56. mAssemblerProgram->initialize_internal();
  57. }
  58. }
  59. Resource::initialize_internal();
  60. }
  61. //---------------------------------------------------------------------------
  62. void HighLevelGpuProgram::destroy_internal()
  63. {
  64. if (mAssemblerProgram != nullptr && mAssemblerProgram.get() != this)
  65. {
  66. mAssemblerProgram = nullptr;
  67. }
  68. GpuProgram::destroy_internal();
  69. }
  70. //---------------------------------------------------------------------
  71. HighLevelGpuProgramPtr HighLevelGpuProgram::create(const String& source, const String& entryPoint,
  72. const String& language, GpuProgramType gptype, GpuProgramProfile profile)
  73. {
  74. return HighLevelGpuProgramManager::instance().create(source, entryPoint, language, gptype, profile);
  75. }
  76. }
  77. #undef THROW_IF_NOT_RENDER_THREAD