- Timestamp:
- 09/29/13 16:48:11 (11 years ago)
- Location:
- ps/trunk/source
- Files:
-
- 6 edited
-
graphics/ShaderDefines.cpp (modified) (2 diffs)
-
graphics/ShaderDefines.h (modified) (1 diff)
-
lib/allocators/allocator_adapters.h (modified) (1 diff)
-
renderer/DecalRData.cpp (modified) (1 diff)
-
renderer/ModelRenderer.cpp (modified) (11 diffs)
-
renderer/PatchRData.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/ShaderDefines.cpp
r13906 r13911 106 106 CShaderParams<value_t>::CShaderParams() 107 107 { 108 *this = s_Empty; 109 } 110 111 template<typename value_t> 112 CShaderParams<value_t>::CShaderParams(SItems* items) : m_Items(items) 113 { 114 } 115 116 template<typename value_t> 117 CShaderParams<value_t> CShaderParams<value_t>::CreateEmpty() 118 { 108 119 SItems items; 109 120 items.RecalcHash(); 110 m_Items = GetInterned(items);121 return CShaderParams(GetInterned(items)); 111 122 } 112 123 … … 268 279 template<> CShaderParams<CVector4D>::InternedItems_t CShaderParams<CVector4D>::s_InternedItems = CShaderParams<CVector4D>::InternedItems_t(); 269 280 281 template<> CShaderParams<CStrIntern> CShaderParams<CStrIntern>::s_Empty = CShaderParams<CStrIntern>::CreateEmpty(); 282 template<> CShaderParams<CVector4D> CShaderParams<CVector4D>::s_Empty = CShaderParams<CVector4D>::CreateEmpty(); 283 270 284 template class CShaderParams<CStrIntern>; 271 285 template class CShaderParams<CVector4D>; -
ps/trunk/source/graphics/ShaderDefines.h
r13906 r13911 119 119 */ 120 120 static SItems* GetInterned(const SItems& items); 121 122 CShaderParams(SItems* items); 123 static CShaderParams CreateEmpty(); 124 static CShaderParams s_Empty; 121 125 }; 122 126 -
ps/trunk/source/lib/allocators/allocator_adapters.h
r10410 r13911 116 116 }; 117 117 118 // (required to be declared by boost::unordered_map, but should never be called) 119 explicit NOTHROW_DEFINE ProxyAllocator(); 120 118 121 explicit NOTHROW_DEFINE ProxyAllocator(Allocator& allocator) 119 122 : allocator(&allocator) -
ps/trunk/source/renderer/DecalRData.cpp
r13906 r13911 122 122 if (material.GetSamplers().size() != 0) 123 123 { 124 CMaterial::SamplersVectorsamplers = material.GetSamplers();124 const CMaterial::SamplersVector& samplers = material.GetSamplers(); 125 125 size_t samplersNum = samplers.size(); 126 126 127 127 for (size_t s = 0; s < samplersNum; ++s) 128 128 { 129 CMaterial::TextureSampler &samp = samplers[s];129 const CMaterial::TextureSampler& samp = samplers[s]; 130 130 shader->BindTexture(samp.Name, samp.Sampler); 131 131 } -
ps/trunk/source/renderer/ModelRenderer.cpp
r13906 r13911 18 18 #include "precompiled.h" 19 19 20 #include "lib/allocators/allocator_adapters.h" 21 #include "lib/allocators/arena.h" 20 22 #include "lib/ogl.h" 21 23 #include "maths/Vector3D.h" … … 418 420 */ 419 421 420 typedef boost::unordered_map<SMRMaterialBucketKey, std::vector<CModel*>, SMRMaterialBucketKeyHash> MaterialBuckets_t; 421 MaterialBuckets_t materialBuckets; 422 Allocators::Arena<> arena(1*MiB); 423 typedef ProxyAllocator<void*, Allocators::Arena<> > ArenaProxyAllocator; 424 typedef std::vector<CModel*, ArenaProxyAllocator> ModelList_t; 425 typedef boost::unordered_map<SMRMaterialBucketKey, ModelList_t, SMRMaterialBucketKeyHash, 426 std::equal_to<SMRMaterialBucketKey>, ProxyAllocator<void*, Allocators::Arena<> > 427 > MaterialBuckets_t; 428 MaterialBuckets_t materialBuckets((MaterialBuckets_t::allocator_type(arena))); 422 429 423 430 { … … 433 440 for (size_t j = 0; j < condefs.GetSize(); ++j) 434 441 { 435 const CShaderConditionalDefines::CondDefine &item = condefs.GetItem(j);442 const CShaderConditionalDefines::CondDefine& item = condefs.GetItem(j); 436 443 int type = item.m_CondType; 437 444 switch (type) … … 455 462 CShaderDefines defs = model->GetMaterial().GetShaderDefines(condFlags); 456 463 SMRMaterialBucketKey key(model->GetMaterial().GetShaderEffect(), defs); 457 std::vector<CModel*>& bucketItems = materialBuckets[key]; 458 bucketItems.push_back(model); 459 } 460 } 461 462 std::vector<SMRSortByDistItem> sortByDistItems; 463 464 std::vector<CShaderTechniquePtr> sortByDistTechs; 464 465 MaterialBuckets_t::iterator it = materialBuckets.find(key); 466 if (it == materialBuckets.end()) 467 { 468 std::pair<MaterialBuckets_t::iterator, bool> inserted = materialBuckets.insert( 469 std::make_pair(key, ModelList_t(ModelList_t::allocator_type(arena)))); 470 inserted.first->second.reserve(32); 471 inserted.first->second.push_back(model); 472 } 473 else 474 { 475 it->second.push_back(model); 476 } 477 } 478 } 479 480 std::vector<SMRSortByDistItem, ArenaProxyAllocator> sortByDistItems((ArenaProxyAllocator(arena))); 481 482 std::vector<CShaderTechniquePtr, ArenaProxyAllocator> sortByDistTechs((ArenaProxyAllocator(arena))); 465 483 // indexed by sortByDistItems[i].techIdx 466 484 // (which stores indexes instead of CShaderTechniquePtr directly … … 469 487 // will keep it alive long enough) 470 488 471 std::vector<SMRTechBucket > techBuckets;489 std::vector<SMRTechBucket, ArenaProxyAllocator> techBuckets((ArenaProxyAllocator(arena))); 472 490 473 491 { … … 529 547 // we could avoid the cost of copying into this list by adding 530 548 // a stride length into techBuckets and not requiring contiguous CModel*s) 531 std::vector<CModel* > sortByDistModels;549 std::vector<CModel*, ArenaProxyAllocator> sortByDistModels((ArenaProxyAllocator(arena))); 532 550 533 551 if (!sortByDistItems.empty()) … … 578 596 // loops to avoid excessive reallocations. The token allocation of 64 elements 579 597 // should be plenty, though it is reallocated below (at a cost) if necessary. 580 std::vector<CTexture* > currentTexs;598 std::vector<CTexture*, ArenaProxyAllocator> currentTexs((ArenaProxyAllocator(arena))); 581 599 currentTexs.reserve(64); 582 600 … … 584 602 // statically in the ShaderRenderModifier class. texBindingNames uses interned strings to 585 603 // keep track of when bindings need to be reevaluated. 586 std::vector<CShaderProgram::Binding > texBindings;604 std::vector<CShaderProgram::Binding, ArenaProxyAllocator> texBindings((ArenaProxyAllocator(arena))); 587 605 texBindings.reserve(64); 588 std::vector<CStrIntern > texBindingNames;606 std::vector<CStrIntern, ArenaProxyAllocator> texBindingNames((ArenaProxyAllocator(arena))); 589 607 texBindingNames.reserve(64); 590 608 … … 634 652 continue; 635 653 636 CMaterial::SamplersVectorsamplers = model->GetMaterial().GetSamplers();654 const CMaterial::SamplersVector& samplers = model->GetMaterial().GetSamplers(); 637 655 size_t samplersNum = samplers.size(); 638 656 … … 654 672 for (size_t s = 0; s < samplersNum; ++s) 655 673 { 656 CMaterial::TextureSampler &samp = samplers[s];674 const CMaterial::TextureSampler& samp = samplers[s]; 657 675 658 676 CShaderProgram::Binding bind = texBindings[s]; … … 695 713 } 696 714 697 CShaderRenderQueriesrenderQueries = model->GetMaterial().GetRenderQueries();715 const CShaderRenderQueries& renderQueries = model->GetMaterial().GetRenderQueries(); 698 716 699 717 for (size_t q = 0; q < renderQueries.GetSize(); q++) -
ps/trunk/source/renderer/PatchRData.cpp
r13906 r13911 788 788 if (itt->first->GetMaterial().GetSamplers().size() != 0) 789 789 { 790 CMaterial::SamplersVectorsamplers = itt->first->GetMaterial().GetSamplers();790 const CMaterial::SamplersVector& samplers = itt->first->GetMaterial().GetSamplers(); 791 791 size_t samplersNum = samplers.size(); 792 792 793 793 for (size_t s = 0; s < samplersNum; ++s) 794 794 { 795 CMaterial::TextureSampler &samp = samplers[s];795 const CMaterial::TextureSampler& samp = samplers[s]; 796 796 shader->BindTexture(samp.Name, samp.Sampler); 797 797 } … … 1018 1018 if (itt->m_Texture) 1019 1019 { 1020 CMaterial::SamplersVectorsamplers = itt->m_Texture->GetMaterial().GetSamplers();1020 const CMaterial::SamplersVector& samplers = itt->m_Texture->GetMaterial().GetSamplers(); 1021 1021 size_t samplersNum = samplers.size(); 1022 1022 1023 1023 for (size_t s = 0; s < samplersNum; ++s) 1024 1024 { 1025 CMaterial::TextureSampler &samp = samplers[s];1025 const CMaterial::TextureSampler& samp = samplers[s]; 1026 1026 shader->BindTexture(samp.Name, samp.Sampler); 1027 1027 }
Note:
See TracChangeset
for help on using the changeset viewer.
