| 861 | } |
| 862 | |
| 863 | void Tr2RenderContextBase::RenderBatchesForPicking( ITriRenderBatchAccumulator* batches, const BlueSharedString& techniqueName ) |
| 864 | { |
| 865 | CCP_STATS_ZONE( __FUNCTION__ ); |
| 866 | D3DPERF_EVENT( L"Tr2EffectStateManager::RenderBatchesForPicking" ); |
| 867 | |
| 868 | Tr2RenderContext* primaryContext = reinterpret_cast<Tr2RenderContext*>( this ); |
| 869 | Tr2RingBuffer::GetInstance<Float4x3>().PrepareBuffer( *primaryContext ); |
| 870 | Tr2RingBuffer::GetInstance<Tr2MorphTargetAnimationData>().PrepareBuffer( *primaryContext ); |
| 871 | |
| 872 | |
| 873 | Tr2RenderContext* renderContext = reinterpret_cast<Tr2RenderContext*>( this ); |
| 874 | UseTextures( batches, techniqueName, *renderContext ); |
| 875 | |
| 876 | const Tr2PerObjectData* curPerObjectData = nullptr; |
| 877 | |
| 878 | Tr2ConstantBufferAL* perObjectConstantBuffers[CBUFFER_COUNT]; |
| 879 | for( uint32_t i = 0; i != CBUFFER_COUNT; ++i ) |
| 880 | { |
| 881 | perObjectConstantBuffers[i] = &m_perObjectConstantBuffers[i]; |
| 882 | } |
| 883 | |
| 884 | for( auto& batch : batches->GetBatches() ) |
| 885 | { |
| 886 | uint32_t technique; |
| 887 | if( !batch.m_shader->GetTechniqueIndex( techniqueName, technique ) ) |
| 888 | { |
| 889 | continue; |
| 890 | } |
| 891 | |
| 892 | if( batch.m_objectData ) |
| 893 | { |
| 894 | if( batch.m_objectData != curPerObjectData ) |
| 895 | { |
| 896 | D3DPERF_EVENT( L"Set per-object data to device" ); |
| 897 | batch.m_objectData->SetPerObjectDataToDevice( perObjectConstantBuffers, batch.m_shader->GetShaderTypeMask( technique ), *renderContext ); |
| 898 | curPerObjectData = batch.m_objectData; |
| 899 | } |
| 900 | |
| 901 | uint32_t id = batch.m_objectData->GetUserData(); |
| 902 | if( m_objectIdVariable ) |
| 903 | { |
| 904 | m_objectIdVariable->SetValue( (float)id ); |
| 905 | } |
| 906 | |
| 907 | uint32_t areaID = batch.m_pickingData; |
| 908 | if( m_areaIdVariable ) |
| 909 | { |
| 910 | m_areaIdVariable->SetValue( (float)areaID ); |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | uint32_t passCount = batch.m_shader->GetPassCount( technique ); |
| 915 | CCP_ASSERT( passCount == 1 ); |
| 916 | |
| 917 | batch.m_shader->ApplyAllStateForPass( technique, 0, *renderContext ); |
| 918 | batch.m_material->ApplyMaterialDataForPass( technique, 0, *renderContext ); |
| 919 | Tr2GpuProfiler::GetProfiler().Begin( batch.m_material, "", *renderContext ); |
| 920 | SubmitGeometry( batch, *renderContext ); |
no test coverage detected