Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

515 lines
16 KiB

  1. //================ Copyright (c) Valve Corporation. All Rights Reserved. ===========================
  2. //
  3. //
  4. //
  5. //==================================================================================================
  6. #include "tier0/platform.h"
  7. #include "tier0/dbg.h"
  8. #include "tier1/strtools.h"
  9. #include "tier1/utlbuffer.h"
  10. #include "utlmap.h"
  11. #include "ps3gcmmemory.h"
  12. #include "gcmstate.h"
  13. #include "bitmap/imageformat_declarations.h"
  14. #include "gcmtexture.h"
  15. #include "memdbgon.h"
  16. #ifdef _CERT
  17. #define Debugger() ((void)0)
  18. #else
  19. #define Debugger() DebuggerBreak()
  20. #endif
  21. //--------------------------------------------------------------------------------------------------
  22. // Texture Layouts
  23. //--------------------------------------------------------------------------------------------------
  24. #ifdef _CERT
  25. #define GLMTEX_FMT_DESC( x )
  26. #else
  27. #define GLMTEX_FMT_DESC( x ) x ,
  28. #endif
  29. #define CELL_GCM_REMAP_MODE_OIO(order, inputARGB, outputARGB) \
  30. (((order)<<16)|((inputARGB))|((outputARGB)<<8))
  31. #define REMAPO( x ) CELL_GCM_TEXTURE_REMAP_ORDER_X##x##XY
  32. #define REMAP4(a,r,g,b) (((a)<<0)|((r)<<2)|((g)<<4)|((b)<<6))
  33. #define REMAP_ARGB REMAP4( CELL_GCM_TEXTURE_REMAP_FROM_A, CELL_GCM_TEXTURE_REMAP_FROM_R, CELL_GCM_TEXTURE_REMAP_FROM_G, CELL_GCM_TEXTURE_REMAP_FROM_B )
  34. #define REMAP_4 REMAP4( CELL_GCM_TEXTURE_REMAP_REMAP, CELL_GCM_TEXTURE_REMAP_REMAP, CELL_GCM_TEXTURE_REMAP_REMAP, CELL_GCM_TEXTURE_REMAP_REMAP )
  35. #define REMAP_13 REMAP4( CELL_GCM_TEXTURE_REMAP_ONE, CELL_GCM_TEXTURE_REMAP_REMAP, CELL_GCM_TEXTURE_REMAP_REMAP, CELL_GCM_TEXTURE_REMAP_REMAP )
  36. #define REMAP_4X(x) REMAP4( x, x, x, x )
  37. #define REMAP_13X(y, x) REMAP4( y, x, x, x )
  38. #define REMAP_ALL_DEFAULT CELL_GCM_REMAP_MODE_OIO( REMAPO(Y), REMAP_ARGB, REMAP_4 )
  39. #define REMAP_ALL_DEFAULT_X CELL_GCM_REMAP_MODE_OIO( REMAPO(X), REMAP_ARGB, REMAP_4 )
  40. #define CAP( x ) CPs3gcmTextureLayout::Format_t::kCap##x
  41. CPs3gcmTextureLayout::Format_t g_ps3texFormats[PS3_TEX_MAX_FORMAT_COUNT] =
  42. {
  43. // summ-name d3d-format
  44. // gcmRemap
  45. // gcmFormat
  46. // gcmPitchPer4X gcmFlags
  47. { GLMTEX_FMT_DESC("_D16") D3DFMT_D16,
  48. REMAP_ALL_DEFAULT,
  49. 8,
  50. CELL_GCM_TEXTURE_DEPTH16,
  51. 0 },
  52. { GLMTEX_FMT_DESC("_D24X8") D3DFMT_D24X8,
  53. REMAP_ALL_DEFAULT,
  54. 16,
  55. CELL_GCM_TEXTURE_DEPTH24_D8,
  56. 0 },
  57. { GLMTEX_FMT_DESC("_D24S8") D3DFMT_D24S8,
  58. REMAP_ALL_DEFAULT,
  59. 16,
  60. CELL_GCM_TEXTURE_DEPTH24_D8,
  61. 0 },
  62. { GLMTEX_FMT_DESC("_A8R8G8B8") D3DFMT_A8R8G8B8,
  63. REMAP_ALL_DEFAULT,
  64. 16,
  65. CELL_GCM_TEXTURE_A8R8G8B8,
  66. CAP(SRGB) },
  67. { GLMTEX_FMT_DESC("_X8R8G8B8") D3DFMT_X8R8G8B8,
  68. REMAP_ALL_DEFAULT,
  69. 16,
  70. CELL_GCM_TEXTURE_A8R8G8B8,
  71. CAP(SRGB) },
  72. { GLMTEX_FMT_DESC("_X1R5G5B5") D3DFMT_X1R5G5B5,
  73. CELL_GCM_REMAP_MODE_OIO( REMAPO(X), REMAP_ARGB, REMAP_13 ),
  74. 8,
  75. CELL_GCM_TEXTURE_R5G6B5,
  76. 0 },
  77. { GLMTEX_FMT_DESC("_A1R5G5B5") D3DFMT_A1R5G5B5,
  78. REMAP_ALL_DEFAULT_X,
  79. 8,
  80. CELL_GCM_TEXTURE_A1R5G5B5,
  81. 0 },
  82. { GLMTEX_FMT_DESC("_L8") D3DFMT_L8,
  83. CELL_GCM_REMAP_MODE_OIO( REMAPO(Y), REMAP_4X(CELL_GCM_TEXTURE_REMAP_FROM_B), REMAP_13 ),
  84. 4,
  85. CELL_GCM_TEXTURE_B8,
  86. 0 },
  87. { GLMTEX_FMT_DESC("_A8L8") D3DFMT_A8L8,
  88. CELL_GCM_REMAP_MODE_OIO( REMAPO(Y), REMAP_13X( CELL_GCM_TEXTURE_REMAP_FROM_G, CELL_GCM_TEXTURE_REMAP_FROM_B), REMAP_4 ),
  89. 8,
  90. CELL_GCM_TEXTURE_G8B8,
  91. 0 },
  92. { GLMTEX_FMT_DESC("_DXT1") D3DFMT_DXT1,
  93. CELL_GCM_REMAP_MODE_OIO( REMAPO(Y), REMAP_ARGB, REMAP_13 ),
  94. 8,
  95. CELL_GCM_TEXTURE_COMPRESSED_DXT1,
  96. CAP(SRGB) | CAP(4xBlocks) },
  97. { GLMTEX_FMT_DESC("_DXT3") D3DFMT_DXT3,
  98. REMAP_ALL_DEFAULT,
  99. 16,
  100. CELL_GCM_TEXTURE_COMPRESSED_DXT23,
  101. CAP(SRGB) | CAP(4xBlocks) },
  102. { GLMTEX_FMT_DESC("_DXT5") D3DFMT_DXT5,
  103. REMAP_ALL_DEFAULT,
  104. 16,
  105. CELL_GCM_TEXTURE_COMPRESSED_DXT45,
  106. CAP(SRGB) | CAP(4xBlocks) },
  107. { GLMTEX_FMT_DESC("_A16B16G16R16F") D3DFMT_A16B16G16R16F,
  108. REMAP_ALL_DEFAULT_X,
  109. 32,
  110. CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT,
  111. 0 },
  112. { GLMTEX_FMT_DESC("_A16B16G16R16") D3DFMT_A16B16G16R16,
  113. REMAP_ALL_DEFAULT_X,
  114. 64,
  115. CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT,
  116. 0 },
  117. { GLMTEX_FMT_DESC("_A32B32G32R32F") D3DFMT_A32B32G32R32F,
  118. REMAP_ALL_DEFAULT_X,
  119. 64,
  120. CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT,
  121. 0 },
  122. { GLMTEX_FMT_DESC("_R8G8B8") D3DFMT_R8G8B8,
  123. CELL_GCM_REMAP_MODE_OIO( REMAPO(Y),
  124. REMAP4( CELL_GCM_TEXTURE_REMAP_FROM_B, CELL_GCM_TEXTURE_REMAP_FROM_A, CELL_GCM_TEXTURE_REMAP_FROM_R, CELL_GCM_TEXTURE_REMAP_FROM_G ),
  125. REMAP_13 ),
  126. 16,
  127. CELL_GCM_TEXTURE_A8R8G8B8,
  128. CAP(SRGB) },
  129. { GLMTEX_FMT_DESC("_A8") D3DFMT_A8,
  130. CELL_GCM_REMAP_MODE_OIO( REMAPO(Y),
  131. REMAP4( CELL_GCM_TEXTURE_REMAP_FROM_B, CELL_GCM_TEXTURE_REMAP_FROM_R, CELL_GCM_TEXTURE_REMAP_FROM_B, CELL_GCM_TEXTURE_REMAP_FROM_B ),
  132. REMAP_13X( CELL_GCM_TEXTURE_REMAP_REMAP, CELL_GCM_TEXTURE_REMAP_ZERO ) ),
  133. 4,
  134. CELL_GCM_TEXTURE_B8,
  135. 0 },
  136. { GLMTEX_FMT_DESC("_R5G6B5") D3DFMT_R5G6B5,
  137. CELL_GCM_REMAP_MODE_OIO( REMAPO(Y),
  138. REMAP4( CELL_GCM_TEXTURE_REMAP_FROM_B, CELL_GCM_TEXTURE_REMAP_FROM_A, CELL_GCM_TEXTURE_REMAP_FROM_R, CELL_GCM_TEXTURE_REMAP_FROM_G ),
  139. REMAP_13 ),
  140. 16,
  141. CELL_GCM_TEXTURE_A8R8G8B8,
  142. CAP(SRGB) },
  143. { GLMTEX_FMT_DESC("_Q8W8V8U8") D3DFMT_Q8W8V8U8,
  144. REMAP_ALL_DEFAULT,
  145. 16,
  146. CELL_GCM_TEXTURE_A8R8G8B8,
  147. CAP(SRGB) },
  148. };
  149. uint g_nPs3texFormatCount = PS3_TEX_CANONICAL_FORMAT_COUNT;
  150. #undef CAP
  151. #undef GLMTEX_FMT_DESC
  152. static bool Ps3texLayoutLessFunc( CPs3gcmTextureLayout::Key_t const &a, CPs3gcmTextureLayout::Key_t const &b )
  153. {
  154. return ( memcmp( &a, &b, sizeof( CPs3gcmTextureLayout::Key_t ) ) < 0 );
  155. }
  156. static CUtlMap< CPs3gcmTextureLayout::Key_t, CPs3gcmTextureLayout const * > s_ps3texLayouts( Ps3texLayoutLessFunc );
  157. CPs3gcmTextureLayout const * CPs3gcmTextureLayout::New( Key_t const &k )
  158. {
  159. // look up 'key' in the map and see if it's a hit, if so, bump the refcount and return
  160. // if not, generate a completed layout based on the key, add to map, set refcount to 1, return that
  161. unsigned short index = s_ps3texLayouts.Find( k );
  162. if ( index != s_ps3texLayouts.InvalidIndex() )
  163. {
  164. CPs3gcmTextureLayout const *layout = s_ps3texLayouts[ index ];
  165. ++ layout->m_refCount;
  166. return layout;
  167. }
  168. // Need to generate complete information about the texture layout
  169. uint8 nMips = ( k.m_texFlags & kfMip ) ? k.m_nActualMipCount : 1;
  170. uint8 nFaces = ( k.m_texFlags & kfTypeCubeMap ) ? 6 : 1;
  171. uint32 nSlices = nMips * nFaces;
  172. // Allocate layout memory
  173. size_t numLayoutBytes = sizeof( CPs3gcmTextureLayout ) + nSlices * sizeof( Slice_t );
  174. CPs3gcmTextureLayout *layout = ( CPs3gcmTextureLayout * ) MemAlloc_AllocAligned( numLayoutBytes, 16 );
  175. memset( layout, 0, numLayoutBytes );
  176. memcpy( &layout->m_key, &k, sizeof( Key_t ) );
  177. layout->m_refCount = 1;
  178. // Find the format descriptor
  179. for ( int j = 0; j < PS3_TEX_CANONICAL_FORMAT_COUNT; ++ j )
  180. {
  181. if ( g_ps3texFormats[j].m_d3dFormat == k.m_texFormat )
  182. {
  183. layout->m_nFormat = j;
  184. break;
  185. }
  186. Assert( j != PS3_TEX_CANONICAL_FORMAT_COUNT - 1 );
  187. }
  188. layout->m_mipCount = nMips;
  189. //
  190. // Slices
  191. //
  192. bool bSwizzled = layout->IsSwizzled();
  193. size_t fmtPitch = layout->GetFormatPtr()->m_gcmPitchPer4X;
  194. size_t fmtPitchBlock = ( layout->GetFormatPtr()->m_gcmCaps & CPs3gcmTextureLayout::Format_t::kCap4xBlocks ) ? 16 : 4;
  195. size_t numDataBytes = 0;
  196. Slice_t *pSlice = &layout->m_slices[0];
  197. for ( int face = 0; face < nFaces; ++ face )
  198. {
  199. // For cubemaps every next face in swizzled addressing
  200. // must be aligned on 128-byte boundary
  201. if ( bSwizzled )
  202. {
  203. numDataBytes = ( numDataBytes + 127 ) & ~127;
  204. }
  205. for ( int mip = 0; mip < nMips; ++ mip, ++ pSlice )
  206. {
  207. for ( int j = 0; j < ARRAYSIZE( k.m_size ); ++ j )
  208. {
  209. pSlice->m_size[j] = k.m_size[j] >> mip;
  210. pSlice->m_size[j] = MAX( pSlice->m_size[j], 1 );
  211. }
  212. pSlice->m_storageOffset = numDataBytes;
  213. size_t numTexels;
  214. // For linear layout textures every mip row must be padded to the
  215. // width of the original highest level mip so that the pitch was
  216. // the same for every mip
  217. if ( bSwizzled )
  218. numTexels = ( pSlice->m_size[0] * pSlice->m_size[1] * pSlice->m_size[2] );
  219. else
  220. numTexels = ( k.m_size[0] * pSlice->m_size[1] * pSlice->m_size[2] );
  221. size_t numBytes = ( numTexels * fmtPitch ) / fmtPitchBlock;
  222. if ( layout->GetFormatPtr()->m_gcmCaps & CPs3gcmTextureLayout::Format_t::kCap4xBlocks )
  223. {
  224. // Ensure the size of the smallest mipmap levels of DXT1/3/5 textures (the 1x1 and 2x2 mips) is accurately computed.
  225. numBytes = MAX( numBytes, fmtPitch );
  226. }
  227. pSlice->m_storageSize = MAX( numBytes, 1 );
  228. numDataBytes += pSlice->m_storageSize;
  229. }
  230. }
  231. // Make the total size 128-byte aligned
  232. // Realistically it is required only for depth textures
  233. numDataBytes = ( numDataBytes + 127 ) & ~127;
  234. //
  235. // Tiled and ZCull memory adjustments
  236. //
  237. layout->m_gcmAllocType = GCM_MAINPOOLSIZE ? kAllocPs3gcmTextureData0 : kAllocPs3gcmTextureData;
  238. if ( layout->IsTiledMemory() )
  239. {
  240. if( g_nPs3texFormatCount >= PS3_TEX_MAX_FORMAT_COUNT )
  241. {
  242. Error("Modified ps3 format array overflow. Increase PS3_TEX_MAX_FORMAT_COUNT appropriately and recompile\n");
  243. }
  244. Format_t *pModifiedFormat = &g_ps3texFormats[g_nPs3texFormatCount];
  245. V_memcpy( pModifiedFormat, layout->GetFormatPtr(), sizeof( Format_t ) );
  246. layout->m_nFormat = g_nPs3texFormatCount;
  247. g_nPs3texFormatCount ++;
  248. if ( k.m_texFlags & kfTypeDepthStencil )
  249. {
  250. //
  251. // Tiled Zcull Surface
  252. //
  253. uint32 zcullSize[2] = { AlignValue( k.m_size[0], 64 ), AlignValue( k.m_size[1], 64 ) };
  254. uint32 nDepthPitch;
  255. if ( k.m_texFormat == D3DFMT_D16 )
  256. nDepthPitch = cellGcmGetTiledPitchSize( zcullSize[0] * 2 );
  257. else
  258. nDepthPitch = cellGcmGetTiledPitchSize( zcullSize[0] * 4 );
  259. pModifiedFormat->m_gcmPitchPer4X = nDepthPitch;
  260. uint32 uDepthBufferSize32bpp = nDepthPitch * zcullSize[1];
  261. uDepthBufferSize32bpp = AlignValue( uDepthBufferSize32bpp, PS3GCMALLOCATIONALIGN( kAllocPs3gcmDepthBuffer ) );
  262. Assert( uDepthBufferSize32bpp >= numDataBytes );
  263. numDataBytes = uDepthBufferSize32bpp;
  264. layout->m_gcmAllocType = kAllocPs3gcmDepthBuffer;
  265. }
  266. else
  267. {
  268. //
  269. // Tiled Color Surface
  270. //
  271. uint32 nTiledPitch = cellGcmGetTiledPitchSize( k.m_size[0] * layout->GetFormatPtr()->m_gcmPitchPer4X / 4 );
  272. pModifiedFormat->m_gcmPitchPer4X = nTiledPitch;
  273. // We Don't allocate any 512x512 RTs (they are used only when in PAL576i which can use the FB mem pool)
  274. /*if ( k.m_size[0] == 512 && k.m_size[1] == 512 && k.m_size[2] == 1 )
  275. layout->m_gcmAllocType = kAllocPs3gcmColorBuffer512;
  276. else*/
  277. if ( k.m_size[0] == g_ps3gcmGlobalState.m_nRenderSize[0] && k.m_size[1] == g_ps3gcmGlobalState.m_nRenderSize[1] && k.m_size[2] == 1 )
  278. layout->m_gcmAllocType = kAllocPs3gcmColorBufferFB;
  279. else if ( k.m_size[0] == g_ps3gcmGlobalState.m_nRenderSize[0]/4 && k.m_size[1] == g_ps3gcmGlobalState.m_nRenderSize[1]/4 && k.m_size[2] == 1 )
  280. layout->m_gcmAllocType = kAllocPs3gcmColorBufferFBQ;
  281. else
  282. layout->m_gcmAllocType = kAllocPs3gcmColorBufferMisc;
  283. uint32 uRenderSize = nTiledPitch * AlignValue( k.m_size[1], 32 ); // 32-line vertical alignment required in local memory
  284. if ( layout->m_gcmAllocType == kAllocPs3gcmColorBufferMisc )
  285. uRenderSize = AlignValue( uRenderSize, PS3GCMALLOCATIONALIGN( kAllocPs3gcmColorBufferMisc ) );
  286. Assert( uRenderSize >= numDataBytes );
  287. numDataBytes = uRenderSize;
  288. }
  289. }
  290. layout->m_storageTotalSize = numDataBytes;
  291. //
  292. // Finished creating the layout information
  293. //
  294. #ifndef _CERT
  295. // generate summary
  296. // "target, format, +/- mips, base size"
  297. char scratch[1024];
  298. char *targetname = targetname = "2D ";
  299. if ( layout->IsVolumeTex() )
  300. targetname = "3D ";
  301. if ( layout->IsCubeMap() )
  302. targetname = "CUBE";
  303. sprintf( scratch, "[%s %s %dx%dx%d mips=%d slices=%d flags=%02X%s]",
  304. targetname,
  305. layout->GetFormatPtr()->m_formatSummary,
  306. layout->m_key.m_size[0], layout->m_key.m_size[1], layout->m_key.m_size[2],
  307. nMips,
  308. nSlices,
  309. layout->m_key.m_texFlags,
  310. (layout->m_key.m_texFlags & kfSrgbEnabled) ? " SRGB" : ""
  311. );
  312. layout->m_layoutSummary = strdup( scratch );
  313. #endif
  314. // then insert into map. disregard returned index.
  315. s_ps3texLayouts.Insert( k, layout );
  316. return layout;
  317. }
  318. void CPs3gcmTextureLayout::Release() const
  319. {
  320. -- m_refCount;
  321. // keep the layout in the map for easy access
  322. Assert( m_refCount >= 0 );
  323. }
  324. //////////////////////////////////////////////////////////////////////////
  325. //
  326. // Texture management
  327. //
  328. CPs3gcmTexture * CPs3gcmTexture::New( CPs3gcmTextureLayout::Key_t const &key )
  329. {
  330. //
  331. // Allocate a new layout for the texture
  332. //
  333. CPs3gcmTextureLayout const *pLayout = CPs3gcmTextureLayout::New( key );
  334. if ( !pLayout )
  335. {
  336. Debugger();
  337. return NULL;
  338. }
  339. CPs3gcmTexture *tex = (CPs3gcmTexture *)MemAlloc_AllocAligned( sizeof( CPs3gcmTexture ), 16 );
  340. memset( tex, 0, sizeof( CPs3gcmTexture ) ); // NOTE: This clears the CPs3gcmLocalMemoryBlock
  341. tex->m_layout = pLayout;
  342. CPs3gcmAllocationType_t uAllocationType = pLayout->m_gcmAllocType;
  343. if ( key.m_texFlags & CPs3gcmTextureLayout::kfNoD3DMemory )
  344. {
  345. if ( ( uAllocationType == kAllocPs3gcmDepthBuffer ) || ( uAllocationType == kAllocPs3gcmColorBufferMisc ) )
  346. {
  347. Assert( 0 );
  348. Warning( "ERROR: (CPs3gcmTexture::New) depth/colour buffers should not be marked with kfNoD3DMemory!\n" );
  349. }
  350. else
  351. {
  352. // Early-out, storage will be allocated later (via IDirect3DDevice9::AllocateTextureStorage)
  353. return tex;
  354. }
  355. }
  356. tex->Allocate();
  357. return tex;
  358. }
  359. void CPs3gcmTexture::Release()
  360. {
  361. // Wait for RSX to finish using the texture memory
  362. // and free it later
  363. if ( m_lmBlock.Size() )
  364. {
  365. m_lmBlock.Free();
  366. }
  367. m_layout->Release();
  368. MemAlloc_FreeAligned( this );
  369. }
  370. bool CPs3gcmTexture::Allocate()
  371. {
  372. if ( m_lmBlock.Size() )
  373. {
  374. // Already allocated!
  375. Assert( 0 );
  376. Warning( "ERROR: CPs3gcmTexture::Allocate called twice!\n" );
  377. return true;
  378. }
  379. CPs3gcmAllocationType_t uAllocationType = m_layout->m_gcmAllocType;
  380. const CPs3gcmTextureLayout::Key_t & key = m_layout->m_key;
  381. // if kAllocPs3gcmTextureData0 (main memory) fails try kAllocPs3gcmTextureData
  382. if (!m_lmBlock.Alloc( uAllocationType, m_layout->m_storageTotalSize ) )
  383. {
  384. if (m_layout->m_gcmAllocType == kAllocPs3gcmTextureData0)
  385. {
  386. m_layout->m_gcmAllocType = kAllocPs3gcmTextureData;
  387. CPs3gcmAllocationType_t uAllocationType = m_layout->m_gcmAllocType;
  388. m_lmBlock.Alloc( uAllocationType, m_layout->m_storageTotalSize );
  389. }
  390. }
  391. if ( m_layout->IsTiledMemory() )
  392. {
  393. if ( uAllocationType == kAllocPs3gcmDepthBuffer )
  394. {
  395. bool bIs16BitDepth = ( m_layout->GetFormatPtr()->m_gcmFormat == CELL_GCM_TEXTURE_DEPTH16 ) || ( m_layout->m_nFormat == CELL_GCM_TEXTURE_DEPTH16_FLOAT );
  396. uint32 zcullSize[2] = { AlignValue( key.m_size[0], 64 ), AlignValue( key.m_size[1], 64 ) };
  397. uint32 uiZcullIndex = m_lmBlock.ZcullMemoryIndex();
  398. cellGcmBindZcull( uiZcullIndex,
  399. m_lmBlock.Offset(),
  400. zcullSize[0], zcullSize[1],
  401. m_lmBlock.ZcullMemoryStart(),
  402. bIs16BitDepth ? CELL_GCM_ZCULL_Z16 : CELL_GCM_ZCULL_Z24S8,
  403. CELL_GCM_SURFACE_CENTER_1,
  404. CELL_GCM_ZCULL_LESS,
  405. CELL_GCM_ZCULL_LONES,
  406. CELL_GCM_SCULL_SFUNC_ALWAYS,
  407. 0, 0 // sRef, sMask
  408. );
  409. uint32 uiTileIndex = m_lmBlock.TiledMemoryIndex();
  410. cellGcmSetTileInfo( uiTileIndex, CELL_GCM_LOCATION_LOCAL, m_lmBlock.Offset(),
  411. m_layout->m_storageTotalSize, m_layout->DefaultPitch(), bIs16BitDepth ? CELL_GCM_COMPMODE_DISABLED : CELL_GCM_COMPMODE_Z32_SEPSTENCIL_REGULAR,
  412. m_lmBlock.TiledMemoryTagAreaBase(), // The area base + size/0x10000 will be allocated as the tag area.
  413. 1 ); // Misc depth buffers on bank 1
  414. cellGcmBindTile( uiTileIndex );
  415. }
  416. else if ( uAllocationType == kAllocPs3gcmColorBufferMisc )
  417. {
  418. uint32 uiTileIndex = m_lmBlock.TiledMemoryIndex();
  419. cellGcmSetTileInfo( uiTileIndex, CELL_GCM_LOCATION_LOCAL, m_lmBlock.Offset(),
  420. m_layout->m_storageTotalSize, m_layout->DefaultPitch(), CELL_GCM_COMPMODE_DISABLED,
  421. m_lmBlock.TiledMemoryTagAreaBase(), // The area base + size/0x10000 will be allocated as the tag area.
  422. 1 ); // Tile misc color buffers on bank 1
  423. cellGcmBindTile( uiTileIndex );
  424. }
  425. }
  426. #ifdef _DEBUG
  427. memset( Data(), 0, m_layout->m_storageTotalSize ); // initialize texture data to BLACK in DEBUG
  428. #endif
  429. return true;
  430. }