PixelShader.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  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. #pragma once
  24. #include "GPUObject.h"
  25. #include "GraphicsDefs.h"
  26. #include "Resource.h"
  27. class Deserializer;
  28. /// Pixel shader resource
  29. class PixelShader : public Resource, public GPUObject
  30. {
  31. OBJECT(PixelShader);
  32. public:
  33. /// Construct
  34. PixelShader(Context* context);
  35. /// Destruct
  36. virtual ~PixelShader();
  37. /// Register object factory
  38. static void RegisterObject(Context* context);
  39. /// Load resource. Return true if successful
  40. virtual bool Load(Deserializer& source);
  41. /// Release shader
  42. virtual void Release();
  43. /// Return whether uses a specific shader parameter
  44. bool HasParameter(PSParameter parameter) const { return useParameter_[parameter]; }
  45. /// Return whether uses a texture unit
  46. bool HasTextureUnit(TextureUnit unit) const { return useTextureUnit_[unit]; }
  47. /// Return whether is Shader Model 3 format
  48. bool IsSM3() const { return isSM3_; }
  49. /// Check whether a shader parameter needs update
  50. bool NeedParameterUpdate(PSParameter parameter, const void* source);
  51. private:
  52. /// Load parameters from an XML file
  53. void LoadParameters();
  54. /// Clear parameter and texture unit use flags
  55. void ClearParameters();
  56. /// Parameter use flags
  57. bool useParameter_[MAX_PS_PARAMETERS];
  58. /// Texture unit use flags
  59. bool useTextureUnit_[MAX_TEXTURE_UNITS];
  60. /// Shader Model 3 flag
  61. bool isSM3_;
  62. };