File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -275,7 +275,7 @@ void VKGSRender::load_texture_env()
275275
276276 auto get_border_color = [&](const rsx::Texture auto & tex)
277277 {
278- return m_device->get_custom_border_color_support ().require_border_color_remap
278+ return m_device->get_custom_border_color_support ().require_border_color_remap
279279 ? tex.remapped_border_color ()
280280 : rsx::decode_border_color (tex.border_color ());
281281 };
Original file line number Diff line number Diff line change @@ -182,16 +182,8 @@ namespace vk
182182 return found == m_generic_sampler_pool.end () ? nullptr : found->second .get ();
183183 }
184184
185- const auto block = m_custom_color_sampler_pool.equal_range (key.base_key );
186- for (auto it = block.first ; it != block.second ; ++it)
187- {
188- if (it->second ->key .border_color_key == key.border_color_key )
189- {
190- return it->second .get ();
191- }
192- }
193-
194- return nullptr ;
185+ const auto found = m_custom_color_sampler_pool.find (key);
186+ return found == m_custom_color_sampler_pool.end () ? nullptr : found->second .get ();
195187 }
196188
197189 cached_sampler_object_t * sampler_pool_t::emplace (const sampler_pool_key_t & key, std::unique_ptr<cached_sampler_object_t >& object)
@@ -204,7 +196,7 @@ namespace vk
204196 return iterator->second .get ();
205197 }
206198
207- const auto [iterator, _unused] = m_custom_color_sampler_pool.emplace (key. base_key , std::move (object));
199+ const auto [iterator, _unused] = m_custom_color_sampler_pool.emplace (key, std::move (object));
208200 return iterator->second .get ();
209201 }
210202
Original file line number Diff line number Diff line change @@ -64,6 +64,22 @@ namespace vk
6464 {
6565 u64 base_key;
6666 u64 border_color_key;
67+
68+ bool operator == (const sampler_pool_key_t & that) const
69+ {
70+ return this ->base_key == that.base_key &&
71+ this ->border_color_key == that.border_color_key ;
72+ }
73+ };
74+
75+ struct sampler_pool_key_hash
76+ {
77+ size_t operator ()(const vk::sampler_pool_key_t & k) const noexcept
78+ {
79+ usz result = k.base_key ;
80+ result ^= k.border_color_key + 0x9e3779b97f4a7c15ULL + (result << 6 ) + (result >> 2 );
81+ return result;
82+ }
6783 };
6884
6985 struct cached_sampler_object_t : public vk ::sampler, public rsx::ref_counted
@@ -75,7 +91,7 @@ namespace vk
7591 class sampler_pool_t
7692 {
7793 std::unordered_map<u64 , std::unique_ptr<cached_sampler_object_t >> m_generic_sampler_pool;
78- std::unordered_map<u64 , std::unique_ptr<cached_sampler_object_t >> m_custom_color_sampler_pool;
94+ std::unordered_map<sampler_pool_key_t , std::unique_ptr<cached_sampler_object_t >, sampler_pool_key_hash > m_custom_color_sampler_pool;
7995
8096 public:
8197
You can’t perform that action at this time.
0 commit comments