Advertisement
Guest User

mrtt patch ogre 1.8

a guest
Dec 8th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.18 KB | None | 0 0
  1. # HG changeset patch
  2. # User Beyzend <abcdefg@gmail.com>
  3. # Date 1323214148 25200
  4. # Node ID 9e2dd5eabefdfbff8e46b53e8f458d2fba262d70
  5. # Parent 3b0558273b253023aa124d28d5f4cfdf638a4f19
  6. -merged Crashy's patch
  7.  
  8. diff -r 3b0558273b25 -r 9e2dd5eabefd RenderSystems/Direct3D11/include/OgreD3D11DepthBuffer.h
  9. --- a/RenderSystems/Direct3D11/include/OgreD3D11DepthBuffer.h Tue Dec 06 13:49:19 2011 -0700
  10. +++ b/RenderSystems/Direct3D11/include/OgreD3D11DepthBuffer.h Tue Dec 06 16:29:08 2011 -0700
  11. @@ -36,7 +36,7 @@
  12. class D3D11DepthBuffer : public DepthBuffer
  13. {
  14. public:
  15. - D3D11DepthBuffer( uint16 poolId,
  16. + D3D11DepthBuffer( uint16 poolId, D3D11RenderSystem *renderSystem,
  17. ID3D11DepthStencilView *depthBufferView,
  18. uint32 width, uint32 height,
  19. uint32 fsaa, uint32 multiSampleQuality, bool isManual );
  20. @@ -50,6 +50,7 @@
  21. protected:
  22. ID3D11DepthStencilView *mDepthStencilView; //aka. actual "DepthBuffer"
  23. uint32 mMultiSampleQuality;
  24. + D3D11RenderSystem *mRenderSystem;
  25. };
  26. }
  27. #endif
  28. diff -r 3b0558273b25 -r 9e2dd5eabefd RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h
  29. --- a/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h Tue Dec 06 13:49:19 2011 -0700
  30. +++ b/RenderSystems/Direct3D11/include/OgreD3D11RenderSystem.h Tue Dec 06 16:29:08 2011 -0700
  31. @@ -131,9 +131,11 @@
  32.  
  33. PolygonMode mPolygonMode;
  34.  
  35. - FilterOptions FilterMinification;
  36. - FilterOptions FilterMagnification;
  37. - FilterOptions FilterMips;
  38. + FilterOptions FilterMinification[OGRE_MAX_TEXTURE_LAYERS];
  39. + FilterOptions FilterMagnification[OGRE_MAX_TEXTURE_LAYERS];
  40. + FilterOptions FilterMips[OGRE_MAX_TEXTURE_LAYERS];
  41. +
  42. + bool CompareEnabled[OGRE_MAX_TEXTURE_LAYERS];
  43.  
  44. D3D11_RECT mScissorRect;
  45.  
  46. @@ -356,7 +358,10 @@
  47.  
  48. /// @copydoc RenderSystem::getDisplayMonitorCount
  49. unsigned int getDisplayMonitorCount() const {return 1;} //todo
  50. -
  51. +
  52. + //Added Missing filter options from Crashy's patch as these FilterOptions weren't defined in the header in that patch.
  53. + void _setTextureUnitCompareEnabled(size_t unit, bool compare);
  54. + void _setTextureUnitCompareFunction(size_t unit, CompareFunction function);
  55. };
  56. }
  57. #endif
  58. diff -r 3b0558273b25 -r 9e2dd5eabefd RenderSystems/Direct3D11/src/OgreD3D11DepthBuffer.cpp
  59. --- a/RenderSystems/Direct3D11/src/OgreD3D11DepthBuffer.cpp Tue Dec 06 13:49:19 2011 -0700
  60. +++ b/RenderSystems/Direct3D11/src/OgreD3D11DepthBuffer.cpp Tue Dec 06 16:29:08 2011 -0700
  61. @@ -31,13 +31,14 @@
  62.  
  63. namespace Ogre
  64. {
  65. - D3D11DepthBuffer::D3D11DepthBuffer( uint16 poolId,
  66. + D3D11DepthBuffer::D3D11DepthBuffer( uint16 poolId, D3D11RenderSystem *renderSystem,
  67. ID3D11DepthStencilView *depthBufferView,
  68. uint32 width, uint32 height,
  69. uint32 fsaa, uint32 multiSampleQuality, bool isManual ) :
  70. DepthBuffer( poolId, 0, width, height, fsaa, "", isManual ),
  71. mDepthStencilView( depthBufferView ),
  72. - mMultiSampleQuality( multiSampleQuality )
  73. + mMultiSampleQuality( multiSampleQuality ),
  74. + mRenderSystem(renderSystem)
  75. {
  76. /*D3D11_DEPTH_STENCIL_VIEW_DESC pDesc;
  77. mDepthStencilView->GetDesc( &pDesc );
  78. @@ -65,7 +66,7 @@
  79. {
  80. //TODO:
  81. //Urgh! This bit of "isTexture" is a bit ugly and potentially unsafe
  82. - bool isTexture = true;
  83. + /*bool isTexture = true;
  84. renderTarget->getCustomAttribute( "isTexture", &isTexture );
  85.  
  86. ID3D11Texture2D *D3D11texture;
  87. @@ -93,6 +94,53 @@
  88. }
  89.  
  90. return false;
  91. + */
  92. +
  93. + D3D11_TEXTURE2D_DESC BBDesc;
  94. +
  95. + bool isTexture = false;
  96. + renderTarget->getCustomAttribute( "isTexture", &isTexture );
  97. +
  98. + if(isTexture)
  99. + {
  100. + ID3D11Texture2D *D3D11texture;
  101. + D3D11HardwarePixelBuffer *pBuffer;
  102. + renderTarget->getCustomAttribute( "BUFFER", &pBuffer );
  103. + D3D11texture = static_cast<ID3D11Texture2D*>( pBuffer->getParentTexture()->getTextureResource() );
  104. + D3D11texture->GetDesc(&BBDesc);
  105. + }
  106. + else
  107. + {
  108. + ID3D11Texture2D* pBack[OGRE_MAX_MULTIPLE_RENDER_TARGETS];
  109. + memset( pBack, 0, sizeof(pBack) );
  110. + renderTarget->getCustomAttribute( "DDBACKBUFFER", &pBack );
  111. +
  112. + if( pBack[0] )
  113. + {
  114. + pBack[0]->GetDesc(&BBDesc);
  115. + }
  116. + else
  117. + {
  118. + ID3D11Texture2D *D3D11texture;
  119. + renderTarget->getCustomAttribute( "ID3D11Texture2D", &D3D11texture );
  120. + D3D11texture->GetDesc( &BBDesc );
  121. + }
  122. + }
  123. +
  124. + //RenderSystem will determine if bitdepths match (i.e. 32 bit RT don't like 16 bit Depth)
  125. + //This is the same function used to create them. Note results are usually cached so this should
  126. + //be quick
  127. +
  128. + //TODO: Needs to check format too!
  129. + if( mFsaa == BBDesc.SampleDesc.Count &&
  130. + mMultiSampleQuality == BBDesc.SampleDesc.Quality &&
  131. + this->getWidth() == renderTarget->getWidth() &&
  132. + this->getHeight() == renderTarget->getHeight() )
  133. + {
  134. + return true;
  135. + }
  136. +
  137. + return false;
  138. }
  139. //---------------------------------------------------------------------
  140. ID3D11DepthStencilView* D3D11DepthBuffer::getDepthStencilView() const
  141. diff -r 3b0558273b25 -r 9e2dd5eabefd RenderSystems/Direct3D11/src/OgreD3D11MultiRenderTarget.cpp
  142. --- a/RenderSystems/Direct3D11/src/OgreD3D11MultiRenderTarget.cpp Tue Dec 06 13:49:19 2011 -0700
  143. +++ b/RenderSystems/Direct3D11/src/OgreD3D11MultiRenderTarget.cpp Tue Dec 06 16:29:08 2011 -0700
  144. @@ -66,18 +66,19 @@
  145. /// If there is another target bound, compare sizes
  146. if(targets[y]->getWidth() != buffer->getWidth() ||
  147. targets[y]->getHeight() != buffer->getHeight() ||
  148. - PixelUtil::getNumElemBits(targets[y]->getFormat()) !=
  149. + PixelUtil::getNumElemBits(targets[y]->getFormat()) !=
  150. PixelUtil::getNumElemBits(buffer->getFormat()))
  151. {
  152. OGRE_EXCEPT(
  153. - Exception::ERR_INVALIDPARAMS,
  154. - "MultiRenderTarget surfaces are not of same size or bit depth",
  155. + Exception::ERR_INVALIDPARAMS,
  156. + "MultiRenderTarget surfaces are not of same size or bit depth",
  157. "D3D11MultiRenderTarget::bindSurface"
  158. );
  159. }
  160. }
  161.  
  162. targets[attachment] = buffer;
  163. + //mRenderTargets[attachment] = target;
  164. checkAndUpdate();
  165. }
  166. //---------------------------------------------------------------------
  167. @@ -144,6 +145,21 @@
  168. mWidth = 0;
  169. mHeight = 0;
  170. }
  171. +
  172. + /*if(name == "ID3D11RenderTargetView")
  173. + {
  174. + ID3D11RenderTargetView ** pRTView = (ID3D11RenderTargetView**)pData;
  175. +
  176. + memset(pRTView,0,sizeof(pRTView));
  177. +
  178. + for(int y=0; y<OGRE_MAX_MULTIPLE_RENDER_TARGETS && mRenderTargets[y]; ++y)
  179. + {
  180. + ID3D11RenderTargetView * view;
  181. + mRenderTargets[y]->getCustomAttribute("ID3D11RenderTargetView",&view);
  182. + pRTView[y]=view;
  183. + }
  184. + return;
  185. + }*/
  186. }
  187. //---------------------------------------------------------------------
  188.  
  189. diff -r 3b0558273b25 -r 9e2dd5eabefd RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp
  190. --- a/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp Tue Dec 06 13:49:19 2011 -0700
  191. +++ b/RenderSystems/Direct3D11/src/OgreD3D11RenderSystem.cpp Tue Dec 06 16:29:08 2011 -0700
  192. @@ -1,10 +1,10 @@
  193. /*
  194. ------------------------------------------------------------------------------
  195. +
  196. This source file is part of OGRE
  197. (Object-oriented Graphics Rendering Engine)
  198. For the latest info, see http://www.ogre3d.org/
  199.  
  200. -Copyright (c) 2000-2009 Torus Knot Software Ltd
  201. +Copyright (c) 2000-2011 Torus Knot Software Ltd
  202.  
  203. Permission is hereby granted, free of charge, to any person obtaining a copy
  204. of this software and associated documentation files (the "Software"), to deal
  205. @@ -23,7 +23,7 @@
  206. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  207. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  208. THE SOFTWARE.
  209. ------------------------------------------------------------------------------
  210. +
  211. */
  212. #include "OgreD3D11RenderSystem.h"
  213. #include "OgreD3D11Prerequisites.h"
  214. @@ -1192,7 +1192,7 @@
  215. }
  216.  
  217. //Create the abstract container
  218. - D3D11DepthBuffer *newDepthBuffer = new D3D11DepthBuffer( DepthBuffer::POOL_DEFAULT, depthStencilView,
  219. + D3D11DepthBuffer *newDepthBuffer = new D3D11DepthBuffer( DepthBuffer::POOL_DEFAULT,this, depthStencilView,
  220. descDepth.Width, descDepth.Height,
  221. descDepth.SampleDesc.Count, descDepth.SampleDesc.Quality,
  222. false );
  223. @@ -1217,7 +1217,7 @@
  224. }
  225.  
  226. //Create a new container for it
  227. - D3D11DepthBuffer *newDepthBuffer = new D3D11DepthBuffer( DepthBuffer::POOL_DEFAULT, depthSurface,
  228. + D3D11DepthBuffer *newDepthBuffer = new D3D11DepthBuffer( DepthBuffer::POOL_DEFAULT,this, depthSurface,
  229. width, height, fsaa, fsaaQuality, true );
  230.  
  231. //Add the 'main' depth buffer to the pool
  232. @@ -1514,9 +1514,12 @@
  233. //---------------------------------------------------------------------
  234. void D3D11RenderSystem::_setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage )
  235. {
  236. - mSceneAlphaRejectFunc = func;
  237. - mSceneAlphaRejectValue = value;
  238. + mSceneAlphaRejectFunc = func;
  239. + mSceneAlphaRejectValue = value;
  240. +
  241. +
  242. mSceneAlphaToCoverage = alphaToCoverage;
  243. + //Do nothing, alpha rejection unavailable in Direct3D11
  244. }
  245. //---------------------------------------------------------------------
  246. void D3D11RenderSystem::_setCullingMode( CullingMode mode )
  247. @@ -1626,19 +1629,29 @@
  248. {
  249. switch(ftype) {
  250. case FT_MIN:
  251. - FilterMinification = filter;
  252. + FilterMinification[unit] = filter;
  253. break;
  254. case FT_MAG:
  255. - FilterMagnification = filter;
  256. + FilterMagnification[unit] = filter;
  257. break;
  258. case FT_MIP:
  259. - FilterMips = filter;
  260. + FilterMips[unit] = filter;
  261. break;
  262. }
  263.  
  264. - mTexStageDesc[unit].samplerDesc.Filter = D3D11Mappings::get(FilterMinification, FilterMagnification, FilterMips);
  265. + mTexStageDesc[unit].samplerDesc.Filter = D3D11Mappings::get(FilterMinification[unit], FilterMagnification[unit], FilterMips[unit],CompareEnabled[unit]);
  266.  
  267. }
  268. + //---------------------------------------------------------------------
  269. + void D3D11RenderSystem::_setTextureUnitCompareEnabled(size_t unit, bool compare)
  270. + {
  271. + CompareEnabled[unit] = compare;
  272. + }
  273. + //---------------------------------------------------------------------
  274. + void D3D11RenderSystem::_setTextureUnitCompareFunction(size_t unit, CompareFunction function)
  275. + {
  276. + mTexStageDesc[unit].samplerDesc.ComparisonFunc = D3D11Mappings::get(function);
  277. + }
  278. //---------------------------------------------------------------------
  279. DWORD D3D11RenderSystem::_getCurrentAnisotropy(size_t unit)
  280. {
  281. @@ -1654,9 +1667,17 @@
  282. mActiveRenderTarget = target;
  283. if (mActiveRenderTarget)
  284. {
  285. - ID3D11RenderTargetView * pRTView = NULL;
  286. + ID3D11RenderTargetView * pRTView[OGRE_MAX_MULTIPLE_RENDER_TARGETS];
  287. + memset(pRTView, 0, sizeof(pRTView));
  288. +
  289. + uint count = 0;
  290. target->getCustomAttribute( "ID3D11RenderTargetView", &pRTView );
  291.  
  292. + while(pRTView[count] != NULL)
  293. + {
  294. + count++;
  295. + }
  296. +
  297. //Retrieve depth buffer
  298. D3D11DepthBuffer *depthBuffer = static_cast<D3D11DepthBuffer*>(target->getDepthBuffer());
  299.  
  300. @@ -1670,8 +1691,7 @@
  301. //Retrieve depth buffer again (it may have changed)
  302. depthBuffer = static_cast<D3D11DepthBuffer*>(target->getDepthBuffer());
  303.  
  304. -
  305. - // we need to clear the state
  306. + // we need to clear the state
  307. mDevice.GetImmediateContext()->ClearState();
  308.  
  309. if (mDevice.isError())
  310. @@ -1685,8 +1705,8 @@
  311.  
  312.  
  313. // now switch to the new render target
  314. - mDevice.GetImmediateContext()->OMSetRenderTargets(1,
  315. - &pRTView,
  316. + mDevice.GetImmediateContext()->OMSetRenderTargets(count,
  317. + pRTView,
  318. depthBuffer ? depthBuffer->getDepthStencilView() : 0 );
  319.  
  320.  
  321. @@ -1698,7 +1718,6 @@
  322. "D3D11RenderSystem::_setViewport");
  323. }
  324. }
  325. - // TODO - support MRT
  326.  
  327. }
  328. //---------------------------------------------------------------------
  329. @@ -1941,7 +1960,6 @@
  330. opState->mTextures[opState->mTexturesCount] = texture;
  331. opState->mTexturesCount++;
  332.  
  333. - stage.samplerDesc.ComparisonFunc = D3D11Mappings::get(mSceneAlphaRejectFunc);
  334. stage.samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
  335. stage.currentSamplerDesc = stage.samplerDesc;
  336.  
  337. @@ -2472,19 +2490,20 @@
  338. if (mActiveRenderTarget)
  339. {
  340. ID3D11RenderTargetView * pRTView[OGRE_MAX_MULTIPLE_RENDER_TARGETS];
  341. - std::memset(pRTView, 0, sizeof(pRTView));
  342. + memset(pRTView, 0, sizeof(pRTView));
  343.  
  344. mActiveRenderTarget->getCustomAttribute( "ID3D11RenderTargetView", &pRTView );
  345.  
  346. - if (buffers & FBT_COLOUR)
  347. + uint count = 0;
  348. + while(pRTView[count] != NULL)
  349. {
  350. - float ClearColor[4];
  351. - D3D11Mappings::get(colour, ClearColor);
  352. - for(size_t i = 0; i < OGRE_MAX_MULTIPLE_RENDER_TARGETS; ++i)
  353. + if (buffers & FBT_COLOUR)
  354. {
  355. - if(pRTView[i])
  356. - mDevice.GetImmediateContext()->ClearRenderTargetView( pRTView[i], ClearColor );
  357. + float ClearColor[4];
  358. + D3D11Mappings::get(colour, ClearColor);
  359. + mDevice.GetImmediateContext()->ClearRenderTargetView( pRTView[count], ClearColor );
  360. }
  361. + count++;
  362. }
  363. UINT ClearFlags = 0;
  364. if (buffers & FBT_DEPTH)
  365. @@ -2825,10 +2844,12 @@
  366. ZeroMemory( &mDepthStencilDesc, sizeof(mDepthStencilDesc));
  367. ZeroMemory( &mScissorRect, sizeof(mScissorRect));
  368.  
  369. - FilterMinification = FO_NONE;
  370. - FilterMagnification = FO_NONE;
  371. - FilterMips = FO_NONE;
  372. -
  373. + for(size_t i = 0; i < OGRE_MAX_TEXTURE_LAYERS; ++i)
  374. + {
  375. + FilterMinification[i] = FO_NONE;
  376. + FilterMagnification[i] = FO_NONE;
  377. + FilterMips[i] = FO_NONE;
  378. + }
  379. mPolygonMode = PM_SOLID;
  380.  
  381. ZeroMemory(mTexStageDesc, OGRE_MAX_TEXTURE_LAYERS * sizeof(sD3DTextureStageDesc));
  382. diff -r 3b0558273b25 -r 9e2dd5eabefd RenderSystems/Direct3D11/src/OgreD3D11Texture.cpp
  383. --- a/RenderSystems/Direct3D11/src/OgreD3D11Texture.cpp Tue Dec 06 13:49:19 2011 -0700
  384. +++ b/RenderSystems/Direct3D11/src/OgreD3D11Texture.cpp Tue Dec 06 16:29:08 2011 -0700
  385. @@ -965,6 +965,7 @@
  386. {
  387. // IDXGISurface ** pSurf = (IDXGISurface **)pData;
  388. //*pSurf = static_cast<D3D11HardwarePixelBuffer*>(mBuffer)->getSurface();
  389. + *static_cast<HardwarePixelBuffer**>(pData) = mBuffer;
  390. return;
  391. }
  392. else if(name == "HWND")
  393. @@ -973,6 +974,11 @@
  394. *pHwnd = NULL;
  395. return;
  396. }
  397. + else if(name == "isTexture")
  398. + {
  399. + bool *b = reinterpret_cast< bool * >( pData );
  400. + *b = true;
  401. + }
  402. else if(name == "BUFFER")
  403. {
  404. *static_cast<HardwarePixelBuffer**>(pData) = mBuffer;
  405.  
  406.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement