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.

173 lines
6.1 KiB

  1. //================ Copyright (c) Valve Corporation. All Rights Reserved. ===========================
  2. //
  3. //
  4. //
  5. //==================================================================================================
  6. #include "buildworldlists_PS3.h"
  7. #include "gl_model_private.h"
  8. #include "host.h"
  9. #include "disp.h"
  10. #include "vprof.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. //--------------------------------------------------------------------------------------------------
  14. //
  15. //--------------------------------------------------------------------------------------------------
  16. CPS3BuildWorldListsJob g_BuildWorldListsJob;
  17. CPS3BuildWorldListsJob* g_pBuildWorldListsJob = &g_BuildWorldListsJob;
  18. job_buildworldlists::JobDescriptor_t g_buildWorldListsJobDescriptor[MAX_CONCURRENT_BUILDVIEWS] ALIGN128;
  19. job_buildworldlists::buildWorldListsDMAOut g_buildWorldListsDMAOutData[MAX_CONCURRENT_BUILDVIEWS] ALIGN128;
  20. //-----------------------------------------------------------------------------
  21. //
  22. //-----------------------------------------------------------------------------
  23. void CPS3BuildWorldListsJob::Init( void )
  24. {
  25. // Register with VJobs
  26. if( g_pVJobs )
  27. {
  28. g_pVJobs->Register( this );
  29. }
  30. }
  31. //-----------------------------------------------------------------------------
  32. //
  33. //-----------------------------------------------------------------------------
  34. void CPS3BuildWorldListsJob::Shutdown()
  35. {
  36. g_pVJobs->Unregister( this );
  37. }
  38. //-----------------------------------------------------------------------------
  39. //
  40. //-----------------------------------------------------------------------------
  41. void CPS3BuildWorldListsJob::OnVjobsInit()
  42. {
  43. for( int i = 0; i < MAX_CONCURRENT_BUILDVIEWS; i++ )
  44. {
  45. g_buildWorldListsJobDescriptor[i].header = *m_pRoot->m_pJobBuildWorldLists;
  46. g_buildWorldListsJobDescriptor[i].header.useInOutBuffer = 0;
  47. g_buildWorldListsJobDescriptor[i].header.sizeStack = (48*1024)/16;
  48. g_buildWorldListsJobDescriptor[i].header.sizeInOrInOut = 0;
  49. }
  50. }
  51. //-----------------------------------------------------------------------------
  52. //
  53. //-----------------------------------------------------------------------------
  54. void CPS3BuildWorldListsJob::OnVjobsShutdown()
  55. {
  56. }
  57. //--------------------------------------------------------------------------------------------------
  58. // PPU calls in here to build on SPU
  59. //--------------------------------------------------------------------------------------------------
  60. int gSPUBreak = 0;
  61. extern Vector modelorg;
  62. extern bool g_bViewerInSolidSpace;
  63. extern int r_visframecount;
  64. extern CUtlVector< Frustum_t, CUtlMemoryAligned< Frustum_t,16 > > g_AreaFrustum;
  65. extern unsigned char g_RenderAreaBits[32];
  66. extern Frustum_t g_Frustum;
  67. #define GET_OFFSET(type, field) ((uint32)&(((type *)0)->field))
  68. void CPS3BuildWorldListsJob::BuildWorldLists_SPU( job_buildworldlists::JobParams_t* pParam, job_buildworldlists::buildWorldListsDMAOut *pDMAOut,
  69. bool bDrawtopview, void *pEA_VolumeCuller, float *pOrthoCenter, float *pOrthoHalfDi, bool bTopViewNoBackfaceCulling, bool bTopViewNoVisCheck,
  70. bool bShadowDepth, void* pEA_Info, void *pEA_RenderListLeaves, int drawFlags,
  71. Frustum_t *pFrustum, Frustum_t *pAreaFrustum, unsigned char *pRenderAreaBits,
  72. int buildViewID )
  73. {
  74. SNPROF("BuildWorldLists_SPU");
  75. // Fill in remaining src Params, assume dma dst params already filled
  76. pParam->m_nDebugBreak = gSPUBreak;
  77. // which path
  78. pParam->m_bShadowDepth = bShadowDepth;
  79. pParam->m_bDrawTopView = bDrawtopview;
  80. pParam->m_bTopViewNoBackfaceCulling = bTopViewNoBackfaceCulling;
  81. pParam->m_bTopViewNoVisCheck = bTopViewNoVisCheck;
  82. pParam->m_eaVolumeCuller = uintp(pEA_VolumeCuller);
  83. if( !pEA_VolumeCuller )
  84. {
  85. pParam->m_orthoCenter[0] = pOrthoCenter[0];
  86. pParam->m_orthoCenter[1] = pOrthoCenter[1];
  87. pParam->m_orthoHalfDi[0] = pOrthoHalfDi[0];
  88. pParam->m_orthoHalfDi[1] = pOrthoHalfDi[1];
  89. }
  90. pParam->m_eaWorldNodes = uintp(host_state.worldbrush->nodes);
  91. pParam->m_visframecount = r_visframecount;
  92. pParam->m_pSurfaces2 = uintp(host_state.worldbrush->surfaces2);
  93. pParam->m_pmarksurfaces = uintp(host_state.worldbrush->marksurfaces);
  94. pParam->m_pLeafs = uintp(host_state.worldbrush->leafs);
  95. pParam->m_pDispInfos = uintp(((CDispArray*)host_state.worldbrush->hDispInfos)->m_pDispInfos);
  96. pParam->m_eaDispInfoReferences = uintp(host_state.worldbrush->m_pDispInfoReferences);
  97. memcpy((void*)pParam->m_ModelOrg, &modelorg, sizeof(modelorg));
  98. pParam->m_bViewerInSolidSpace = g_bViewerInSolidSpace;
  99. pParam->m_Disp_ParentSurfID_offset = GET_OFFSET(CDispInfo, m_ParentSurfID);
  100. pParam->m_Disp_BB_offset = GET_OFFSET(CDispInfo, m_BBoxMin);
  101. pParam->m_Disp_Info_Size = sizeof(CDispInfo);
  102. pParam->m_eaFrustum = uintp(pFrustum);
  103. pParam->m_eaAreaFrustum = uintp(pAreaFrustum);
  104. pParam->m_eaRenderAreaBits = uintp(pRenderAreaBits);
  105. pParam->m_nNumSortID = materials->GetNumSortIDs();
  106. pParam->m_nMaxVisitSurfaces = host_state.worldbrush->numsurfaces;
  107. pParam->m_nAreaFrustum = g_AreaFrustum.Count();
  108. pParam->m_eaInfo = uintp(pEA_Info);
  109. pParam->m_eaRenderListLeaves = uintp(pEA_RenderListLeaves);
  110. pParam->m_DrawFlags = drawFlags;
  111. pParam->m_buildViewID = buildViewID;
  112. pParam->m_eaDMAOut = uintp(pDMAOut);
  113. // hacky - careful - byte offset to size/Count() member of CUtlVector
  114. pParam->m_nUtlCountOffset = 12; //GET_OFFSET(CUtlVector<int>, m_Size);
  115. // Push Job
  116. ConVarRef r_PS3_SPU_BuildWRLists_ImmediateSync("r_PS3_SPU_BuildWRLists_ImmediateSync");
  117. if( r_PS3_SPU_BuildWRLists_ImmediateSync.GetInt() )
  118. {
  119. CELL_VERIFY( m_pRoot->m_queuePortBuildWorld[ buildViewID ].pushJob( &g_buildWorldListsJobDescriptor[ buildViewID ].header,
  120. sizeof(g_buildWorldListsJobDescriptor[0]), 0, CELL_SPURS_JOBQUEUE_FLAG_SYNC_JOB ) );
  121. CELL_VERIFY( m_pRoot->m_queuePortBuildWorld[ buildViewID ].sync(0) );
  122. }
  123. else
  124. {
  125. int syncTag = 1 + buildViewID;
  126. CELL_VERIFY( m_pRoot->m_queuePortBuildWorld[ buildViewID ].pushJob( &g_buildWorldListsJobDescriptor[ buildViewID ].header,
  127. sizeof(g_buildWorldListsJobDescriptor[0]), syncTag, CELL_SPURS_JOBQUEUE_FLAG_SYNC_JOB ) );
  128. //Msg("pushJob World(%d) SyncTag(%d)\n", buildViewID, syncTag );
  129. }
  130. }