Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 272 vs 273 for /trunk/Source Code/Hardware/Video/Headers/GFXDevice.h

Diff revisions: vs.
  @@ -46,7 +46,8 @@
46 46 ///Rough around the edges Adapter pattern
47 47 DEFINE_SINGLETON_EXT1(GFXDevice,RenderAPIWrapper)
48 48 friend class Frustum; ///< For matrix recovery operations
49 - typedef std::stack<mat4<F32>, vectorImpl<mat4<F32> > > matrixStackW;
49 + typedef std::stack<mat4<F32>, vectorImpl<mat4<F32> > > matrixStackW;
50 + typedef Unordered_map<I64, RenderStateBlock* > RenderStateMap;
50 51 public:
51 52 enum RenderTarget {
52 53 RENDER_TARGET_SCREEN = 0,
  @@ -143,8 +144,14 @@
143 144 inline void setPrevTextureId(const U32& id) {_prevTextureId = id;}
144 145 inline U32 getPrevTextureId() {return _prevTextureId;}
145 146 void closeRenderer();
146 - inline Renderer* getRenderer() {assert(_renderer != nullptr); return _renderer;}
147 - inline void setRenderer(Renderer* const renderer) {assert(renderer != nullptr); SAFE_UPDATE(_renderer, renderer);}
147 + inline Renderer* getRenderer() {
148 + DIVIDE_ASSERT(_renderer != nullptr, "GFXDevice error: Renderer requested but not created!");
149 + return _renderer;
150 + }
151 + inline void setRenderer(Renderer* const renderer) {
152 + DIVIDE_ASSERT(renderer != nullptr, "GFXDevice error: Tried to create an invalid renderer!");
153 + SAFE_UPDATE(_renderer, renderer);
154 + }
148 155 /*
149 156 /* Clipping plane management. All the clipping planes are handled by shader programs only!
150 157 */
  @@ -196,13 +203,12 @@
196 203 ///Creates a new API dependent stateblock based on the received description
197 204 ///Sets the current state block to the one passed as a param
198 205 ///It is not set immediately, but a call to "updateStates" is required
199 - RenderStateBlock* setStateBlock(const RenderStateBlock& block, bool forceUpdate = false);
206 + I64 setStateBlock(I64 stateBlockHash, bool forceUpdate = false);
200 207 /// Return or create a new state block using the given descriptor. DO NOT DELETE THE RETURNED STATE BLOCK! GFXDevice handles that!
201 - RenderStateBlock* getOrCreateStateBlock(RenderStateBlockDescriptor& descriptor);
208 + I64 getOrCreateStateBlock(RenderStateBlockDescriptor& descriptor);
209 + const RenderStateBlockDescriptor& getStateBlockDescriptor(I64 renderStateBlockHash) const;
202 210 ///Sets a standard state block
203 - inline RenderStateBlock* setDefaultStateBlock(bool forceUpdate = false) {return setStateBlock(*_defaultStateBlock, forceUpdate);}
204 - ///Update the graphics pipeline using the current rendering API with the state block passed
205 - inline void activateStateBlock(const RenderStateBlock& newBlock, RenderStateBlock* const oldBlock) const { _api.activateStateBlock(newBlock, oldBlock); }
211 + inline I64 setDefaultStateBlock(bool forceUpdate = false) {return setStateBlock(_defaultStateBlockHash, forceUpdate);}
206 212 ///If a new state has been set, update the Graphics pipeline
207 213 void updateStates(bool force = false);
208 214 /*//Render State Management */
  @@ -295,6 +301,8 @@
295 301 ~GFXDevice();
296 302 void previewDepthBuffer();
297 303 void updateViewportInternal(const vec4<I32>& viewport);
304 + ///Update the graphics pipeline using the current rendering API with the state block passed
305 + inline void activateStateBlock(const RenderStateBlock& newBlock, RenderStateBlock* const oldBlock) const { _api.activateStateBlock(newBlock, oldBlock); }
298 306
299 307 private:
300 308 Camera* _cubeCamera;
  @@ -322,17 +330,16 @@
322 330 FrameBuffer* _renderTarget[RenderTarget_PLACEHOLDER];
323 331 FrameBuffer* _depthRanges;
324 332 /*State management */
325 - typedef Unordered_map<I64, RenderStateBlock* > RenderStateMap;
326 333 RenderStateMap _stateBlockMap;
327 334 bool _stateBlockDirty;
328 335 bool _stateBlockByDescription;
329 - RenderStateBlock* _currentStateBlock;
330 - RenderStateBlock* _newStateBlock;
331 - RenderStateBlock* _defaultStateBlock;
332 - RenderStateBlock* _defaultStateNoDepth; //<The default render state buth with depth testing disabled
333 - RenderStateBlock* _state2DRendering; //<Special render state for 2D rendering
334 - RenderStateBlock* _stateDepthOnlyRendering;
335 - matrixStackW _worldMatrices;
336 + I64 _currentStateBlockHash;
337 + I64 _newStateBlockHash;
338 + I64 _defaultStateBlockHash;
339 + I64 _defaultStateNoDepthHash; //<The default render state buth with depth testing disabled
340 + I64 _state2DRenderingHash; //<Special render state for 2D rendering
341 + I64 _stateDepthOnlyRenderingHash;
342 + matrixStackW _worldMatrices;
336 343 mat4<F32> _WVCachedMatrix;
337 344 mat4<F32> _VPCachedMatrix;
338 345 mat4<F32> _WVPCachedMatrix;