gfxD3D11StateBlock.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2015 GarageGames, LLC
  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
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell 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
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GFXD3D11STATEBLOCK_H_
  23. #define _GFXD3D11STATEBLOCK_H_
  24. #include "gfx/D3D11/gfxD3D11Device.h"
  25. #include "gfx/gfxStateBlock.h"
  26. namespace DictHash
  27. {
  28. U32 hash(const GFXSamplerStateDesc &data);
  29. }
  30. class GFXD3D11StateBlock : public GFXStateBlock
  31. {
  32. public:
  33. GFXD3D11StateBlock(const GFXStateBlockDesc& desc);
  34. virtual ~GFXD3D11StateBlock();
  35. /// Called by D3D11 device to active this state block.
  36. /// @param oldState The current state, used to make sure we don't set redundant states on the device. Pass NULL to reset all states.
  37. void activate(GFXD3D11StateBlock* oldState);
  38. //
  39. // GFXStateBlock interface
  40. //
  41. /// Returns the hash value of the desc that created this block
  42. virtual U32 getHashValue() const;
  43. /// Returns a GFXStateBlockDesc that this block represents
  44. virtual const GFXStateBlockDesc& getDesc() const;
  45. //
  46. // GFXResource
  47. //
  48. virtual void zombify() { }
  49. /// When called the resource should restore all device sensitive information destroyed by zombify()
  50. virtual void resurrect() { }
  51. private:
  52. D3D11_BLEND_DESC mBlendDesc;
  53. D3D11_RASTERIZER_DESC mRasterizerDesc;
  54. D3D11_DEPTH_STENCIL_DESC mDepthStencilDesc;
  55. D3D11_SAMPLER_DESC mSamplerDesc[GFX_TEXTURE_STAGE_COUNT];
  56. ID3D11BlendState* mBlendState;
  57. ID3D11DepthStencilState* mDepthStencilState;
  58. ID3D11RasterizerState* mRasterizerState;
  59. ID3D11SamplerState* mSamplerStates[GFX_TEXTURE_STAGE_COUNT];
  60. GFXStateBlockDesc mDesc;
  61. U32 mCachedHashValue;
  62. // Cached D3D specific things, these are "calculated" from GFXStateBlock
  63. U32 mColorMask;
  64. };
  65. typedef StrongRefPtr<GFXD3D11StateBlock> GFXD3D11StateBlockRef;
  66. #endif