gfxD3D9StateBlock.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 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 _GFXD3D9STATEBLOCK_H_
  23. #define _GFXD3D9STATEBLOCK_H_
  24. #ifndef _GFXSTATEBLOCK_H_
  25. #include "gfx/gfxStateBlock.h"
  26. #endif
  27. struct IDirect3DDevice9;
  28. class GFXD3D9StateBlock : public GFXStateBlock
  29. {
  30. public:
  31. //
  32. // GFXD3D9StateBlock interface
  33. //
  34. GFXD3D9StateBlock(const GFXStateBlockDesc& desc, IDirect3DDevice9 *d3dDevice);
  35. virtual ~GFXD3D9StateBlock();
  36. /// Called by D3D9 device to active this state block.
  37. /// @param oldState The current state, used to make sure we don't set redundant states on the device. Pass NULL to reset all states.
  38. void activate(GFXD3D9StateBlock* oldState);
  39. //
  40. // GFXStateBlock interface
  41. //
  42. /// Returns the hash value of the desc that created this block
  43. virtual U32 getHashValue() const;
  44. /// Returns a GFXStateBlockDesc that this block represents
  45. virtual const GFXStateBlockDesc& getDesc() const;
  46. //
  47. // GFXResource
  48. //
  49. virtual void zombify() { }
  50. /// When called the resource should restore all device sensitive information destroyed by zombify()
  51. virtual void resurrect() { }
  52. private:
  53. GFXStateBlockDesc mDesc;
  54. U32 mCachedHashValue;
  55. IDirect3DDevice9 *mD3DDevice; ///< Handle for D3DDevice
  56. // Cached D3D specific things, these are "calculated" from GFXStateBlock
  57. U32 mColorMask;
  58. U32 mZBias;
  59. U32 mZSlopeBias;
  60. };
  61. typedef StrongRefPtr<GFXD3D9StateBlock> GFXD3D9StateBlockRef;
  62. #endif