OGLShaderVariation.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // Copyright (c) 2008-2015 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "../../Container/RefCounted.h"
  24. #include "../../Container/ArrayPtr.h"
  25. #include "../../Graphics/GPUObject.h"
  26. #include "../../Graphics/GraphicsDefs.h"
  27. namespace Atomic
  28. {
  29. class Shader;
  30. class ShaderProgram;
  31. /// Vertex or pixel shader on the GPU.
  32. class ATOMIC_API ShaderVariation : public RefCounted, public GPUObject
  33. {
  34. REFCOUNTED(ShaderVariation)
  35. public:
  36. /// Construct.
  37. ShaderVariation(Shader* owner, ShaderType type);
  38. /// Destruct.
  39. virtual ~ShaderVariation();
  40. /// Mark the GPU resource destroyed on context destruction.
  41. virtual void OnDeviceLost();
  42. /// Release the shader.
  43. virtual void Release();
  44. /// Compile the shader. Return true if successful.
  45. bool Create();
  46. /// Set name.
  47. void SetName(const String& name);
  48. /// Set defines.
  49. void SetDefines(const String& defines);
  50. /// Return the owner resource.
  51. Shader* GetOwner() const;
  52. /// Return shader type.
  53. ShaderType GetShaderType() const { return type_; }
  54. /// Return name.
  55. const String& GetName() const { return name_; }
  56. /// Return defines.
  57. const String& GetDefines() const { return defines_; }
  58. /// Return full shader name.
  59. String GetFullName() const { return name_ + "(" + defines_ + ")"; }
  60. /// Return compile error/warning string.
  61. const String& GetCompilerOutput() const { return compilerOutput_; }
  62. private:
  63. /// Shader this variation belongs to.
  64. WeakPtr<Shader> owner_;
  65. /// Shader type.
  66. ShaderType type_;
  67. /// Shader name.
  68. String name_;
  69. /// Defines to use in compiling.
  70. String defines_;
  71. /// Shader compile error string.
  72. String compilerOutput_;
  73. };
  74. }