diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/intrusive_list.h | 631 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_event_info.h | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_object_name.h | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_server_port.h | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_server_session.h | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_session_request.h | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_shared_memory_info.h | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.h | 13 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 42 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 57 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.h | 6 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 136 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 33 |
18 files changed, 876 insertions, 100 deletions
diff --git a/src/common/intrusive_list.h b/src/common/intrusive_list.h new file mode 100644 index 000000000..d330dc1c2 --- /dev/null +++ b/src/common/intrusive_list.h | |||
| @@ -0,0 +1,631 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_funcs.h" | ||
| 7 | #include "common/parent_of_member.h" | ||
| 8 | |||
| 9 | namespace Common { | ||
| 10 | |||
| 11 | // Forward declare implementation class for Node. | ||
| 12 | namespace impl { | ||
| 13 | |||
| 14 | class IntrusiveListImpl; | ||
| 15 | |||
| 16 | } | ||
| 17 | |||
| 18 | class IntrusiveListNode { | ||
| 19 | YUZU_NON_COPYABLE(IntrusiveListNode); | ||
| 20 | |||
| 21 | private: | ||
| 22 | friend class impl::IntrusiveListImpl; | ||
| 23 | |||
| 24 | IntrusiveListNode* m_prev; | ||
| 25 | IntrusiveListNode* m_next; | ||
| 26 | |||
| 27 | public: | ||
| 28 | constexpr IntrusiveListNode() : m_prev(this), m_next(this) {} | ||
| 29 | |||
| 30 | constexpr bool IsLinked() const { | ||
| 31 | return m_next != this; | ||
| 32 | } | ||
| 33 | |||
| 34 | private: | ||
| 35 | constexpr void LinkPrev(IntrusiveListNode* node) { | ||
| 36 | // We can't link an already linked node. | ||
| 37 | ASSERT(!node->IsLinked()); | ||
| 38 | this->SplicePrev(node, node); | ||
| 39 | } | ||
| 40 | |||
| 41 | constexpr void SplicePrev(IntrusiveListNode* first, IntrusiveListNode* last) { | ||
| 42 | // Splice a range into the list. | ||
| 43 | auto last_prev = last->m_prev; | ||
| 44 | first->m_prev = m_prev; | ||
| 45 | last_prev->m_next = this; | ||
| 46 | m_prev->m_next = first; | ||
| 47 | m_prev = last_prev; | ||
| 48 | } | ||
| 49 | |||
| 50 | constexpr void LinkNext(IntrusiveListNode* node) { | ||
| 51 | // We can't link an already linked node. | ||
| 52 | ASSERT(!node->IsLinked()); | ||
| 53 | return this->SpliceNext(node, node); | ||
| 54 | } | ||
| 55 | |||
| 56 | constexpr void SpliceNext(IntrusiveListNode* first, IntrusiveListNode* last) { | ||
| 57 | // Splice a range into the list. | ||
| 58 | auto last_prev = last->m_prev; | ||
| 59 | first->m_prev = this; | ||
| 60 | last_prev->m_next = m_next; | ||
| 61 | m_next->m_prev = last_prev; | ||
| 62 | m_next = first; | ||
| 63 | } | ||
| 64 | |||
| 65 | constexpr void Unlink() { | ||
| 66 | this->Unlink(m_next); | ||
| 67 | } | ||
| 68 | |||
| 69 | constexpr void Unlink(IntrusiveListNode* last) { | ||
| 70 | // Unlink a node from a next node. | ||
| 71 | auto last_prev = last->m_prev; | ||
| 72 | m_prev->m_next = last; | ||
| 73 | last->m_prev = m_prev; | ||
| 74 | last_prev->m_next = this; | ||
| 75 | m_prev = last_prev; | ||
| 76 | } | ||
| 77 | |||
| 78 | constexpr IntrusiveListNode* GetPrev() { | ||
| 79 | return m_prev; | ||
| 80 | } | ||
| 81 | |||
| 82 | constexpr const IntrusiveListNode* GetPrev() const { | ||
| 83 | return m_prev; | ||
| 84 | } | ||
| 85 | |||
| 86 | constexpr IntrusiveListNode* GetNext() { | ||
| 87 | return m_next; | ||
| 88 | } | ||
| 89 | |||
| 90 | constexpr const IntrusiveListNode* GetNext() const { | ||
| 91 | return m_next; | ||
| 92 | } | ||
| 93 | }; | ||
| 94 | // DEPRECATED: static_assert(std::is_literal_type<IntrusiveListNode>::value); | ||
| 95 | |||
| 96 | namespace impl { | ||
| 97 | |||
| 98 | class IntrusiveListImpl { | ||
| 99 | YUZU_NON_COPYABLE(IntrusiveListImpl); | ||
| 100 | |||
| 101 | private: | ||
| 102 | IntrusiveListNode m_root_node; | ||
| 103 | |||
| 104 | public: | ||
| 105 | template <bool Const> | ||
| 106 | class Iterator; | ||
| 107 | |||
| 108 | using value_type = IntrusiveListNode; | ||
| 109 | using size_type = size_t; | ||
| 110 | using difference_type = ptrdiff_t; | ||
| 111 | using pointer = value_type*; | ||
| 112 | using const_pointer = const value_type*; | ||
| 113 | using reference = value_type&; | ||
| 114 | using const_reference = const value_type&; | ||
| 115 | using iterator = Iterator<false>; | ||
| 116 | using const_iterator = Iterator<true>; | ||
| 117 | using reverse_iterator = std::reverse_iterator<iterator>; | ||
| 118 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 119 | |||
| 120 | template <bool Const> | ||
| 121 | class Iterator { | ||
| 122 | public: | ||
| 123 | using iterator_category = std::bidirectional_iterator_tag; | ||
| 124 | using value_type = typename IntrusiveListImpl::value_type; | ||
| 125 | using difference_type = typename IntrusiveListImpl::difference_type; | ||
| 126 | using pointer = | ||
| 127 | std::conditional_t<Const, IntrusiveListImpl::const_pointer, IntrusiveListImpl::pointer>; | ||
| 128 | using reference = std::conditional_t<Const, IntrusiveListImpl::const_reference, | ||
| 129 | IntrusiveListImpl::reference>; | ||
| 130 | |||
| 131 | private: | ||
| 132 | pointer m_node; | ||
| 133 | |||
| 134 | public: | ||
| 135 | constexpr explicit Iterator(pointer n) : m_node(n) {} | ||
| 136 | |||
| 137 | constexpr bool operator==(const Iterator& rhs) const { | ||
| 138 | return m_node == rhs.m_node; | ||
| 139 | } | ||
| 140 | |||
| 141 | constexpr pointer operator->() const { | ||
| 142 | return m_node; | ||
| 143 | } | ||
| 144 | |||
| 145 | constexpr reference operator*() const { | ||
| 146 | return *m_node; | ||
| 147 | } | ||
| 148 | |||
| 149 | constexpr Iterator& operator++() { | ||
| 150 | m_node = m_node->m_next; | ||
| 151 | return *this; | ||
| 152 | } | ||
| 153 | |||
| 154 | constexpr Iterator& operator--() { | ||
| 155 | m_node = m_node->m_prev; | ||
| 156 | return *this; | ||
| 157 | } | ||
| 158 | |||
| 159 | constexpr Iterator operator++(int) { | ||
| 160 | const Iterator it{*this}; | ||
| 161 | ++(*this); | ||
| 162 | return it; | ||
| 163 | } | ||
| 164 | |||
| 165 | constexpr Iterator operator--(int) { | ||
| 166 | const Iterator it{*this}; | ||
| 167 | --(*this); | ||
| 168 | return it; | ||
| 169 | } | ||
| 170 | |||
| 171 | constexpr operator Iterator<true>() const { | ||
| 172 | return Iterator<true>(m_node); | ||
| 173 | } | ||
| 174 | |||
| 175 | constexpr Iterator<false> GetNonConstIterator() const { | ||
| 176 | return Iterator<false>(const_cast<IntrusiveListImpl::pointer>(m_node)); | ||
| 177 | } | ||
| 178 | }; | ||
| 179 | |||
| 180 | public: | ||
| 181 | constexpr IntrusiveListImpl() : m_root_node() {} | ||
| 182 | |||
| 183 | // Iterator accessors. | ||
| 184 | constexpr iterator begin() { | ||
| 185 | return iterator(m_root_node.GetNext()); | ||
| 186 | } | ||
| 187 | |||
| 188 | constexpr const_iterator begin() const { | ||
| 189 | return const_iterator(m_root_node.GetNext()); | ||
| 190 | } | ||
| 191 | |||
| 192 | constexpr iterator end() { | ||
| 193 | return iterator(std::addressof(m_root_node)); | ||
| 194 | } | ||
| 195 | |||
| 196 | constexpr const_iterator end() const { | ||
| 197 | return const_iterator(std::addressof(m_root_node)); | ||
| 198 | } | ||
| 199 | |||
| 200 | constexpr iterator iterator_to(reference v) { | ||
| 201 | // Only allow iterator_to for values in lists. | ||
| 202 | ASSERT(v.IsLinked()); | ||
| 203 | return iterator(std::addressof(v)); | ||
| 204 | } | ||
| 205 | |||
| 206 | constexpr const_iterator iterator_to(const_reference v) const { | ||
| 207 | // Only allow iterator_to for values in lists. | ||
| 208 | ASSERT(v.IsLinked()); | ||
| 209 | return const_iterator(std::addressof(v)); | ||
| 210 | } | ||
| 211 | |||
| 212 | // Content management. | ||
| 213 | constexpr bool empty() const { | ||
| 214 | return !m_root_node.IsLinked(); | ||
| 215 | } | ||
| 216 | |||
| 217 | constexpr size_type size() const { | ||
| 218 | return static_cast<size_type>(std::distance(this->begin(), this->end())); | ||
| 219 | } | ||
| 220 | |||
| 221 | constexpr reference back() { | ||
| 222 | return *m_root_node.GetPrev(); | ||
| 223 | } | ||
| 224 | |||
| 225 | constexpr const_reference back() const { | ||
| 226 | return *m_root_node.GetPrev(); | ||
| 227 | } | ||
| 228 | |||
| 229 | constexpr reference front() { | ||
| 230 | return *m_root_node.GetNext(); | ||
| 231 | } | ||
| 232 | |||
| 233 | constexpr const_reference front() const { | ||
| 234 | return *m_root_node.GetNext(); | ||
| 235 | } | ||
| 236 | |||
| 237 | constexpr void push_back(reference node) { | ||
| 238 | m_root_node.LinkPrev(std::addressof(node)); | ||
| 239 | } | ||
| 240 | |||
| 241 | constexpr void push_front(reference node) { | ||
| 242 | m_root_node.LinkNext(std::addressof(node)); | ||
| 243 | } | ||
| 244 | |||
| 245 | constexpr void pop_back() { | ||
| 246 | m_root_node.GetPrev()->Unlink(); | ||
| 247 | } | ||
| 248 | |||
| 249 | constexpr void pop_front() { | ||
| 250 | m_root_node.GetNext()->Unlink(); | ||
| 251 | } | ||
| 252 | |||
| 253 | constexpr iterator insert(const_iterator pos, reference node) { | ||
| 254 | pos.GetNonConstIterator()->LinkPrev(std::addressof(node)); | ||
| 255 | return iterator(std::addressof(node)); | ||
| 256 | } | ||
| 257 | |||
| 258 | constexpr void splice(const_iterator pos, IntrusiveListImpl& o) { | ||
| 259 | splice_impl(pos, o.begin(), o.end()); | ||
| 260 | } | ||
| 261 | |||
| 262 | constexpr void splice(const_iterator pos, IntrusiveListImpl& o, const_iterator first) { | ||
| 263 | const_iterator last(first); | ||
| 264 | std::advance(last, 1); | ||
| 265 | splice_impl(pos, first, last); | ||
| 266 | } | ||
| 267 | |||
| 268 | constexpr void splice(const_iterator pos, IntrusiveListImpl& o, const_iterator first, | ||
| 269 | const_iterator last) { | ||
| 270 | splice_impl(pos, first, last); | ||
| 271 | } | ||
| 272 | |||
| 273 | constexpr iterator erase(const_iterator pos) { | ||
| 274 | if (pos == this->end()) { | ||
| 275 | return this->end(); | ||
| 276 | } | ||
| 277 | iterator it(pos.GetNonConstIterator()); | ||
| 278 | (it++)->Unlink(); | ||
| 279 | return it; | ||
| 280 | } | ||
| 281 | |||
| 282 | constexpr void clear() { | ||
| 283 | while (!this->empty()) { | ||
| 284 | this->pop_front(); | ||
| 285 | } | ||
| 286 | } | ||
| 287 | |||
| 288 | private: | ||
| 289 | constexpr void splice_impl(const_iterator _pos, const_iterator _first, const_iterator _last) { | ||
| 290 | if (_first == _last) { | ||
| 291 | return; | ||
| 292 | } | ||
| 293 | iterator pos(_pos.GetNonConstIterator()); | ||
| 294 | iterator first(_first.GetNonConstIterator()); | ||
| 295 | iterator last(_last.GetNonConstIterator()); | ||
| 296 | first->Unlink(std::addressof(*last)); | ||
| 297 | pos->SplicePrev(std::addressof(*first), std::addressof(*first)); | ||
| 298 | } | ||
| 299 | }; | ||
| 300 | |||
| 301 | } // namespace impl | ||
| 302 | |||
| 303 | template <class T, class Traits> | ||
| 304 | class IntrusiveList { | ||
| 305 | YUZU_NON_COPYABLE(IntrusiveList); | ||
| 306 | |||
| 307 | private: | ||
| 308 | impl::IntrusiveListImpl m_impl; | ||
| 309 | |||
| 310 | public: | ||
| 311 | template <bool Const> | ||
| 312 | class Iterator; | ||
| 313 | |||
| 314 | using value_type = T; | ||
| 315 | using size_type = size_t; | ||
| 316 | using difference_type = ptrdiff_t; | ||
| 317 | using pointer = value_type*; | ||
| 318 | using const_pointer = const value_type*; | ||
| 319 | using reference = value_type&; | ||
| 320 | using const_reference = const value_type&; | ||
| 321 | using iterator = Iterator<false>; | ||
| 322 | using const_iterator = Iterator<true>; | ||
| 323 | using reverse_iterator = std::reverse_iterator<iterator>; | ||
| 324 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | ||
| 325 | |||
| 326 | template <bool Const> | ||
| 327 | class Iterator { | ||
| 328 | public: | ||
| 329 | friend class Common::IntrusiveList<T, Traits>; | ||
| 330 | |||
| 331 | using ImplIterator = | ||
| 332 | std::conditional_t<Const, Common::impl::IntrusiveListImpl::const_iterator, | ||
| 333 | Common::impl::IntrusiveListImpl::iterator>; | ||
| 334 | |||
| 335 | using iterator_category = std::bidirectional_iterator_tag; | ||
| 336 | using value_type = typename IntrusiveList::value_type; | ||
| 337 | using difference_type = typename IntrusiveList::difference_type; | ||
| 338 | using pointer = | ||
| 339 | std::conditional_t<Const, IntrusiveList::const_pointer, IntrusiveList::pointer>; | ||
| 340 | using reference = | ||
| 341 | std::conditional_t<Const, IntrusiveList::const_reference, IntrusiveList::reference>; | ||
| 342 | |||
| 343 | private: | ||
| 344 | ImplIterator m_iterator; | ||
| 345 | |||
| 346 | private: | ||
| 347 | constexpr explicit Iterator(ImplIterator it) : m_iterator(it) {} | ||
| 348 | |||
| 349 | constexpr ImplIterator GetImplIterator() const { | ||
| 350 | return m_iterator; | ||
| 351 | } | ||
| 352 | |||
| 353 | public: | ||
| 354 | constexpr bool operator==(const Iterator& rhs) const { | ||
| 355 | return m_iterator == rhs.m_iterator; | ||
| 356 | } | ||
| 357 | |||
| 358 | constexpr pointer operator->() const { | ||
| 359 | return std::addressof(Traits::GetParent(*m_iterator)); | ||
| 360 | } | ||
| 361 | |||
| 362 | constexpr reference operator*() const { | ||
| 363 | return Traits::GetParent(*m_iterator); | ||
| 364 | } | ||
| 365 | |||
| 366 | constexpr Iterator& operator++() { | ||
| 367 | ++m_iterator; | ||
| 368 | return *this; | ||
| 369 | } | ||
| 370 | |||
| 371 | constexpr Iterator& operator--() { | ||
| 372 | --m_iterator; | ||
| 373 | return *this; | ||
| 374 | } | ||
| 375 | |||
| 376 | constexpr Iterator operator++(int) { | ||
| 377 | const Iterator it{*this}; | ||
| 378 | ++m_iterator; | ||
| 379 | return it; | ||
| 380 | } | ||
| 381 | |||
| 382 | constexpr Iterator operator--(int) { | ||
| 383 | const Iterator it{*this}; | ||
| 384 | --m_iterator; | ||
| 385 | return it; | ||
| 386 | } | ||
| 387 | |||
| 388 | constexpr operator Iterator<true>() const { | ||
| 389 | return Iterator<true>(m_iterator); | ||
| 390 | } | ||
| 391 | }; | ||
| 392 | |||
| 393 | private: | ||
| 394 | static constexpr IntrusiveListNode& GetNode(reference ref) { | ||
| 395 | return Traits::GetNode(ref); | ||
| 396 | } | ||
| 397 | |||
| 398 | static constexpr IntrusiveListNode const& GetNode(const_reference ref) { | ||
| 399 | return Traits::GetNode(ref); | ||
| 400 | } | ||
| 401 | |||
| 402 | static constexpr reference GetParent(IntrusiveListNode& node) { | ||
| 403 | return Traits::GetParent(node); | ||
| 404 | } | ||
| 405 | |||
| 406 | static constexpr const_reference GetParent(IntrusiveListNode const& node) { | ||
| 407 | return Traits::GetParent(node); | ||
| 408 | } | ||
| 409 | |||
| 410 | public: | ||
| 411 | constexpr IntrusiveList() : m_impl() {} | ||
| 412 | |||
| 413 | // Iterator accessors. | ||
| 414 | constexpr iterator begin() { | ||
| 415 | return iterator(m_impl.begin()); | ||
| 416 | } | ||
| 417 | |||
| 418 | constexpr const_iterator begin() const { | ||
| 419 | return const_iterator(m_impl.begin()); | ||
| 420 | } | ||
| 421 | |||
| 422 | constexpr iterator end() { | ||
| 423 | return iterator(m_impl.end()); | ||
| 424 | } | ||
| 425 | |||
| 426 | constexpr const_iterator end() const { | ||
| 427 | return const_iterator(m_impl.end()); | ||
| 428 | } | ||
| 429 | |||
| 430 | constexpr const_iterator cbegin() const { | ||
| 431 | return this->begin(); | ||
| 432 | } | ||
| 433 | |||
| 434 | constexpr const_iterator cend() const { | ||
| 435 | return this->end(); | ||
| 436 | } | ||
| 437 | |||
| 438 | constexpr reverse_iterator rbegin() { | ||
| 439 | return reverse_iterator(this->end()); | ||
| 440 | } | ||
| 441 | |||
| 442 | constexpr const_reverse_iterator rbegin() const { | ||
| 443 | return const_reverse_iterator(this->end()); | ||
| 444 | } | ||
| 445 | |||
| 446 | constexpr reverse_iterator rend() { | ||
| 447 | return reverse_iterator(this->begin()); | ||
| 448 | } | ||
| 449 | |||
| 450 | constexpr const_reverse_iterator rend() const { | ||
| 451 | return const_reverse_iterator(this->begin()); | ||
| 452 | } | ||
| 453 | |||
| 454 | constexpr const_reverse_iterator crbegin() const { | ||
| 455 | return this->rbegin(); | ||
| 456 | } | ||
| 457 | |||
| 458 | constexpr const_reverse_iterator crend() const { | ||
| 459 | return this->rend(); | ||
| 460 | } | ||
| 461 | |||
| 462 | constexpr iterator iterator_to(reference v) { | ||
| 463 | return iterator(m_impl.iterator_to(GetNode(v))); | ||
| 464 | } | ||
| 465 | |||
| 466 | constexpr const_iterator iterator_to(const_reference v) const { | ||
| 467 | return const_iterator(m_impl.iterator_to(GetNode(v))); | ||
| 468 | } | ||
| 469 | |||
| 470 | // Content management. | ||
| 471 | constexpr bool empty() const { | ||
| 472 | return m_impl.empty(); | ||
| 473 | } | ||
| 474 | |||
| 475 | constexpr size_type size() const { | ||
| 476 | return m_impl.size(); | ||
| 477 | } | ||
| 478 | |||
| 479 | constexpr reference back() { | ||
| 480 | return GetParent(m_impl.back()); | ||
| 481 | } | ||
| 482 | |||
| 483 | constexpr const_reference back() const { | ||
| 484 | return GetParent(m_impl.back()); | ||
| 485 | } | ||
| 486 | |||
| 487 | constexpr reference front() { | ||
| 488 | return GetParent(m_impl.front()); | ||
| 489 | } | ||
| 490 | |||
| 491 | constexpr const_reference front() const { | ||
| 492 | return GetParent(m_impl.front()); | ||
| 493 | } | ||
| 494 | |||
| 495 | constexpr void push_back(reference ref) { | ||
| 496 | m_impl.push_back(GetNode(ref)); | ||
| 497 | } | ||
| 498 | |||
| 499 | constexpr void push_front(reference ref) { | ||
| 500 | m_impl.push_front(GetNode(ref)); | ||
| 501 | } | ||
| 502 | |||
| 503 | constexpr void pop_back() { | ||
| 504 | m_impl.pop_back(); | ||
| 505 | } | ||
| 506 | |||
| 507 | constexpr void pop_front() { | ||
| 508 | m_impl.pop_front(); | ||
| 509 | } | ||
| 510 | |||
| 511 | constexpr iterator insert(const_iterator pos, reference ref) { | ||
| 512 | return iterator(m_impl.insert(pos.GetImplIterator(), GetNode(ref))); | ||
| 513 | } | ||
| 514 | |||
| 515 | constexpr void splice(const_iterator pos, IntrusiveList& o) { | ||
| 516 | m_impl.splice(pos.GetImplIterator(), o.m_impl); | ||
| 517 | } | ||
| 518 | |||
| 519 | constexpr void splice(const_iterator pos, IntrusiveList& o, const_iterator first) { | ||
| 520 | m_impl.splice(pos.GetImplIterator(), o.m_impl, first.GetImplIterator()); | ||
| 521 | } | ||
| 522 | |||
| 523 | constexpr void splice(const_iterator pos, IntrusiveList& o, const_iterator first, | ||
| 524 | const_iterator last) { | ||
| 525 | m_impl.splice(pos.GetImplIterator(), o.m_impl, first.GetImplIterator(), | ||
| 526 | last.GetImplIterator()); | ||
| 527 | } | ||
| 528 | |||
| 529 | constexpr iterator erase(const_iterator pos) { | ||
| 530 | return iterator(m_impl.erase(pos.GetImplIterator())); | ||
| 531 | } | ||
| 532 | |||
| 533 | constexpr void clear() { | ||
| 534 | m_impl.clear(); | ||
| 535 | } | ||
| 536 | }; | ||
| 537 | |||
| 538 | template <auto T, class Derived = Common::impl::GetParentType<T>> | ||
| 539 | class IntrusiveListMemberTraits; | ||
| 540 | |||
| 541 | template <class Parent, IntrusiveListNode Parent::*Member, class Derived> | ||
| 542 | class IntrusiveListMemberTraits<Member, Derived> { | ||
| 543 | public: | ||
| 544 | using ListType = IntrusiveList<Derived, IntrusiveListMemberTraits>; | ||
| 545 | |||
| 546 | private: | ||
| 547 | friend class IntrusiveList<Derived, IntrusiveListMemberTraits>; | ||
| 548 | |||
| 549 | static constexpr IntrusiveListNode& GetNode(Derived& parent) { | ||
| 550 | return parent.*Member; | ||
| 551 | } | ||
| 552 | |||
| 553 | static constexpr IntrusiveListNode const& GetNode(Derived const& parent) { | ||
| 554 | return parent.*Member; | ||
| 555 | } | ||
| 556 | |||
| 557 | static Derived& GetParent(IntrusiveListNode& node) { | ||
| 558 | return Common::GetParentReference<Member, Derived>(std::addressof(node)); | ||
| 559 | } | ||
| 560 | |||
| 561 | static Derived const& GetParent(IntrusiveListNode const& node) { | ||
| 562 | return Common::GetParentReference<Member, Derived>(std::addressof(node)); | ||
| 563 | } | ||
| 564 | }; | ||
| 565 | |||
| 566 | template <auto T, class Derived = Common::impl::GetParentType<T>> | ||
| 567 | class IntrusiveListMemberTraitsByNonConstexprOffsetOf; | ||
| 568 | |||
| 569 | template <class Parent, IntrusiveListNode Parent::*Member, class Derived> | ||
| 570 | class IntrusiveListMemberTraitsByNonConstexprOffsetOf<Member, Derived> { | ||
| 571 | public: | ||
| 572 | using ListType = IntrusiveList<Derived, IntrusiveListMemberTraitsByNonConstexprOffsetOf>; | ||
| 573 | |||
| 574 | private: | ||
| 575 | friend class IntrusiveList<Derived, IntrusiveListMemberTraitsByNonConstexprOffsetOf>; | ||
| 576 | |||
| 577 | static constexpr IntrusiveListNode& GetNode(Derived& parent) { | ||
| 578 | return parent.*Member; | ||
| 579 | } | ||
| 580 | |||
| 581 | static constexpr IntrusiveListNode const& GetNode(Derived const& parent) { | ||
| 582 | return parent.*Member; | ||
| 583 | } | ||
| 584 | |||
| 585 | static Derived& GetParent(IntrusiveListNode& node) { | ||
| 586 | return *reinterpret_cast<Derived*>(reinterpret_cast<char*>(std::addressof(node)) - | ||
| 587 | GetOffset()); | ||
| 588 | } | ||
| 589 | |||
| 590 | static Derived const& GetParent(IntrusiveListNode const& node) { | ||
| 591 | return *reinterpret_cast<const Derived*>( | ||
| 592 | reinterpret_cast<const char*>(std::addressof(node)) - GetOffset()); | ||
| 593 | } | ||
| 594 | |||
| 595 | static uintptr_t GetOffset() { | ||
| 596 | return reinterpret_cast<uintptr_t>(std::addressof(reinterpret_cast<Derived*>(0)->*Member)); | ||
| 597 | } | ||
| 598 | }; | ||
| 599 | |||
| 600 | template <class Derived> | ||
| 601 | class IntrusiveListBaseNode : public IntrusiveListNode {}; | ||
| 602 | |||
| 603 | template <class Derived> | ||
| 604 | class IntrusiveListBaseTraits { | ||
| 605 | public: | ||
| 606 | using ListType = IntrusiveList<Derived, IntrusiveListBaseTraits>; | ||
| 607 | |||
| 608 | private: | ||
| 609 | friend class IntrusiveList<Derived, IntrusiveListBaseTraits>; | ||
| 610 | |||
| 611 | static constexpr IntrusiveListNode& GetNode(Derived& parent) { | ||
| 612 | return static_cast<IntrusiveListNode&>( | ||
| 613 | static_cast<IntrusiveListBaseNode<Derived>&>(parent)); | ||
| 614 | } | ||
| 615 | |||
| 616 | static constexpr IntrusiveListNode const& GetNode(Derived const& parent) { | ||
| 617 | return static_cast<const IntrusiveListNode&>( | ||
| 618 | static_cast<const IntrusiveListBaseNode<Derived>&>(parent)); | ||
| 619 | } | ||
| 620 | |||
| 621 | static constexpr Derived& GetParent(IntrusiveListNode& node) { | ||
| 622 | return static_cast<Derived&>(static_cast<IntrusiveListBaseNode<Derived>&>(node)); | ||
| 623 | } | ||
| 624 | |||
| 625 | static constexpr Derived const& GetParent(IntrusiveListNode const& node) { | ||
| 626 | return static_cast<const Derived&>( | ||
| 627 | static_cast<const IntrusiveListBaseNode<Derived>&>(node)); | ||
| 628 | } | ||
| 629 | }; | ||
| 630 | |||
| 631 | } // namespace Common | ||
diff --git a/src/core/hle/kernel/k_event_info.h b/src/core/hle/kernel/k_event_info.h index 25b3ff594..eacfa5dc6 100644 --- a/src/core/hle/kernel/k_event_info.h +++ b/src/core/hle/kernel/k_event_info.h | |||
| @@ -5,14 +5,15 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | 7 | ||
| 8 | #include <boost/intrusive/list.hpp> | 8 | #include "common/intrusive_list.h" |
| 9 | 9 | ||
| 10 | #include "core/hle/kernel/slab_helpers.h" | 10 | #include "core/hle/kernel/slab_helpers.h" |
| 11 | #include "core/hle/kernel/svc_types.h" | 11 | #include "core/hle/kernel/svc_types.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | 13 | namespace Kernel { |
| 14 | 14 | ||
| 15 | class KEventInfo : public KSlabAllocated<KEventInfo>, public boost::intrusive::list_base_hook<> { | 15 | class KEventInfo : public KSlabAllocated<KEventInfo>, |
| 16 | public Common::IntrusiveListBaseNode<KEventInfo> { | ||
| 16 | public: | 17 | public: |
| 17 | struct InfoCreateThread { | 18 | struct InfoCreateThread { |
| 18 | u32 thread_id{}; | 19 | u32 thread_id{}; |
diff --git a/src/core/hle/kernel/k_object_name.h b/src/core/hle/kernel/k_object_name.h index 2d97fc777..a8876fe37 100644 --- a/src/core/hle/kernel/k_object_name.h +++ b/src/core/hle/kernel/k_object_name.h | |||
| @@ -5,7 +5,8 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <boost/intrusive/list.hpp> | 8 | |
| 9 | #include "common/intrusive_list.h" | ||
| 9 | 10 | ||
| 10 | #include "core/hle/kernel/k_light_lock.h" | 11 | #include "core/hle/kernel/k_light_lock.h" |
| 11 | #include "core/hle/kernel/slab_helpers.h" | 12 | #include "core/hle/kernel/slab_helpers.h" |
| @@ -15,13 +16,14 @@ namespace Kernel { | |||
| 15 | 16 | ||
| 16 | class KObjectNameGlobalData; | 17 | class KObjectNameGlobalData; |
| 17 | 18 | ||
| 18 | class KObjectName : public KSlabAllocated<KObjectName>, public boost::intrusive::list_base_hook<> { | 19 | class KObjectName : public KSlabAllocated<KObjectName>, |
| 20 | public Common::IntrusiveListBaseNode<KObjectName> { | ||
| 19 | public: | 21 | public: |
| 20 | explicit KObjectName(KernelCore&) {} | 22 | explicit KObjectName(KernelCore&) {} |
| 21 | virtual ~KObjectName() = default; | 23 | virtual ~KObjectName() = default; |
| 22 | 24 | ||
| 23 | static constexpr size_t NameLengthMax = 12; | 25 | static constexpr size_t NameLengthMax = 12; |
| 24 | using List = boost::intrusive::list<KObjectName>; | 26 | using List = Common::IntrusiveListBaseTraits<KObjectName>::ListType; |
| 25 | 27 | ||
| 26 | static Result NewFromName(KernelCore& kernel, KAutoObject* obj, const char* name); | 28 | static Result NewFromName(KernelCore& kernel, KAutoObject* obj, const char* name); |
| 27 | static Result Delete(KernelCore& kernel, KAutoObject* obj, const char* name); | 29 | static Result Delete(KernelCore& kernel, KAutoObject* obj, const char* name); |
diff --git a/src/core/hle/kernel/k_server_port.h b/src/core/hle/kernel/k_server_port.h index 21c040e62..625280290 100644 --- a/src/core/hle/kernel/k_server_port.h +++ b/src/core/hle/kernel/k_server_port.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include <utility> | 8 | #include <utility> |
| 9 | 9 | ||
| 10 | #include <boost/intrusive/list.hpp> | 10 | #include "common/intrusive_list.h" |
| 11 | 11 | ||
| 12 | #include "core/hle/kernel/k_server_session.h" | 12 | #include "core/hle/kernel/k_server_session.h" |
| 13 | #include "core/hle/kernel/k_synchronization_object.h" | 13 | #include "core/hle/kernel/k_synchronization_object.h" |
| @@ -42,7 +42,7 @@ public: | |||
| 42 | bool IsSignaled() const override; | 42 | bool IsSignaled() const override; |
| 43 | 43 | ||
| 44 | private: | 44 | private: |
| 45 | using SessionList = boost::intrusive::list<KServerSession>; | 45 | using SessionList = Common::IntrusiveListBaseTraits<KServerSession>::ListType; |
| 46 | 46 | ||
| 47 | void CleanupSessions(); | 47 | void CleanupSessions(); |
| 48 | 48 | ||
diff --git a/src/core/hle/kernel/k_server_session.h b/src/core/hle/kernel/k_server_session.h index 5ee02f556..403891919 100644 --- a/src/core/hle/kernel/k_server_session.h +++ b/src/core/hle/kernel/k_server_session.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include <string> | 8 | #include <string> |
| 9 | #include <utility> | 9 | #include <utility> |
| 10 | 10 | ||
| 11 | #include <boost/intrusive/list.hpp> | 11 | #include "common/intrusive_list.h" |
| 12 | 12 | ||
| 13 | #include "core/hle/kernel/k_light_lock.h" | 13 | #include "core/hle/kernel/k_light_lock.h" |
| 14 | #include "core/hle/kernel/k_session_request.h" | 14 | #include "core/hle/kernel/k_session_request.h" |
| @@ -27,7 +27,7 @@ class KSession; | |||
| 27 | class KThread; | 27 | class KThread; |
| 28 | 28 | ||
| 29 | class KServerSession final : public KSynchronizationObject, | 29 | class KServerSession final : public KSynchronizationObject, |
| 30 | public boost::intrusive::list_base_hook<> { | 30 | public Common::IntrusiveListBaseNode<KServerSession> { |
| 31 | KERNEL_AUTOOBJECT_TRAITS(KServerSession, KSynchronizationObject); | 31 | KERNEL_AUTOOBJECT_TRAITS(KServerSession, KSynchronizationObject); |
| 32 | 32 | ||
| 33 | friend class ServiceThread; | 33 | friend class ServiceThread; |
| @@ -67,7 +67,8 @@ private: | |||
| 67 | KSession* m_parent{}; | 67 | KSession* m_parent{}; |
| 68 | 68 | ||
| 69 | /// List of threads which are pending a reply. | 69 | /// List of threads which are pending a reply. |
| 70 | boost::intrusive::list<KSessionRequest> m_request_list{}; | 70 | using RequestList = Common::IntrusiveListBaseTraits<KSessionRequest>::ListType; |
| 71 | RequestList m_request_list{}; | ||
| 71 | KSessionRequest* m_current_request{}; | 72 | KSessionRequest* m_current_request{}; |
| 72 | 73 | ||
| 73 | KLightLock m_lock; | 74 | KLightLock m_lock; |
diff --git a/src/core/hle/kernel/k_session_request.h b/src/core/hle/kernel/k_session_request.h index b5f04907b..283669e0a 100644 --- a/src/core/hle/kernel/k_session_request.h +++ b/src/core/hle/kernel/k_session_request.h | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | 7 | ||
| 8 | #include "common/intrusive_list.h" | ||
| 9 | |||
| 8 | #include "core/hle/kernel/k_auto_object.h" | 10 | #include "core/hle/kernel/k_auto_object.h" |
| 9 | #include "core/hle/kernel/k_event.h" | 11 | #include "core/hle/kernel/k_event.h" |
| 10 | #include "core/hle/kernel/k_memory_block.h" | 12 | #include "core/hle/kernel/k_memory_block.h" |
| @@ -16,7 +18,7 @@ namespace Kernel { | |||
| 16 | 18 | ||
| 17 | class KSessionRequest final : public KSlabAllocated<KSessionRequest>, | 19 | class KSessionRequest final : public KSlabAllocated<KSessionRequest>, |
| 18 | public KAutoObject, | 20 | public KAutoObject, |
| 19 | public boost::intrusive::list_base_hook<> { | 21 | public Common::IntrusiveListBaseNode<KSessionRequest> { |
| 20 | KERNEL_AUTOOBJECT_TRAITS(KSessionRequest, KAutoObject); | 22 | KERNEL_AUTOOBJECT_TRAITS(KSessionRequest, KAutoObject); |
| 21 | 23 | ||
| 22 | public: | 24 | public: |
diff --git a/src/core/hle/kernel/k_shared_memory_info.h b/src/core/hle/kernel/k_shared_memory_info.h index 75b73ba39..2d8ff20d6 100644 --- a/src/core/hle/kernel/k_shared_memory_info.h +++ b/src/core/hle/kernel/k_shared_memory_info.h | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <boost/intrusive/list.hpp> | 6 | #include "common/intrusive_list.h" |
| 7 | 7 | ||
| 8 | #include "core/hle/kernel/slab_helpers.h" | 8 | #include "core/hle/kernel/slab_helpers.h" |
| 9 | 9 | ||
| @@ -12,7 +12,7 @@ namespace Kernel { | |||
| 12 | class KSharedMemory; | 12 | class KSharedMemory; |
| 13 | 13 | ||
| 14 | class KSharedMemoryInfo final : public KSlabAllocated<KSharedMemoryInfo>, | 14 | class KSharedMemoryInfo final : public KSlabAllocated<KSharedMemoryInfo>, |
| 15 | public boost::intrusive::list_base_hook<> { | 15 | public Common::IntrusiveListBaseNode<KSharedMemoryInfo> { |
| 16 | 16 | ||
| 17 | public: | 17 | public: |
| 18 | explicit KSharedMemoryInfo(KernelCore&) {} | 18 | explicit KSharedMemoryInfo(KernelCore&) {} |
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index 9c1a41128..f9814ac8f 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include <utility> | 12 | #include <utility> |
| 13 | #include <vector> | 13 | #include <vector> |
| 14 | 14 | ||
| 15 | #include <boost/intrusive/list.hpp> | 15 | #include "common/intrusive_list.h" |
| 16 | 16 | ||
| 17 | #include "common/intrusive_red_black_tree.h" | 17 | #include "common/intrusive_red_black_tree.h" |
| 18 | #include "common/spin_lock.h" | 18 | #include "common/spin_lock.h" |
| @@ -119,7 +119,7 @@ s32 GetCurrentCoreId(KernelCore& kernel); | |||
| 119 | Core::Memory::Memory& GetCurrentMemory(KernelCore& kernel); | 119 | Core::Memory::Memory& GetCurrentMemory(KernelCore& kernel); |
| 120 | 120 | ||
| 121 | class KThread final : public KAutoObjectWithSlabHeapAndContainer<KThread, KWorkerTask>, | 121 | class KThread final : public KAutoObjectWithSlabHeapAndContainer<KThread, KWorkerTask>, |
| 122 | public boost::intrusive::list_base_hook<>, | 122 | public Common::IntrusiveListBaseNode<KThread>, |
| 123 | public KTimerTask { | 123 | public KTimerTask { |
| 124 | KERNEL_AUTOOBJECT_TRAITS(KThread, KSynchronizationObject); | 124 | KERNEL_AUTOOBJECT_TRAITS(KThread, KSynchronizationObject); |
| 125 | 125 | ||
| @@ -138,7 +138,7 @@ public: | |||
| 138 | public: | 138 | public: |
| 139 | using ThreadContext32 = Core::ARM_Interface::ThreadContext32; | 139 | using ThreadContext32 = Core::ARM_Interface::ThreadContext32; |
| 140 | using ThreadContext64 = Core::ARM_Interface::ThreadContext64; | 140 | using ThreadContext64 = Core::ARM_Interface::ThreadContext64; |
| 141 | using WaiterList = boost::intrusive::list<KThread>; | 141 | using WaiterList = Common::IntrusiveListBaseTraits<KThread>::ListType; |
| 142 | 142 | ||
| 143 | /** | 143 | /** |
| 144 | * Gets the thread's current priority | 144 | * Gets the thread's current priority |
| @@ -750,8 +750,9 @@ private: | |||
| 750 | ConditionVariableThreadTreeTraits::TreeType<LockWithPriorityInheritanceComparator>; | 750 | ConditionVariableThreadTreeTraits::TreeType<LockWithPriorityInheritanceComparator>; |
| 751 | 751 | ||
| 752 | public: | 752 | public: |
| 753 | class LockWithPriorityInheritanceInfo : public KSlabAllocated<LockWithPriorityInheritanceInfo>, | 753 | class LockWithPriorityInheritanceInfo |
| 754 | public boost::intrusive::list_base_hook<> { | 754 | : public KSlabAllocated<LockWithPriorityInheritanceInfo>, |
| 755 | public Common::IntrusiveListBaseNode<LockWithPriorityInheritanceInfo> { | ||
| 755 | public: | 756 | public: |
| 756 | explicit LockWithPriorityInheritanceInfo(KernelCore&) {} | 757 | explicit LockWithPriorityInheritanceInfo(KernelCore&) {} |
| 757 | 758 | ||
| @@ -839,7 +840,7 @@ public: | |||
| 839 | 840 | ||
| 840 | private: | 841 | private: |
| 841 | using LockWithPriorityInheritanceInfoList = | 842 | using LockWithPriorityInheritanceInfoList = |
| 842 | boost::intrusive::list<LockWithPriorityInheritanceInfo>; | 843 | Common::IntrusiveListBaseTraits<LockWithPriorityInheritanceInfo>::ListType; |
| 843 | 844 | ||
| 844 | ConditionVariableThreadTree* m_condvar_tree{}; | 845 | ConditionVariableThreadTree* m_condvar_tree{}; |
| 845 | u64 m_condvar_key{}; | 846 | u64 m_condvar_key{}; |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 0932fadc2..2f986097f 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -223,6 +223,9 @@ void Maxwell3D::ProcessMacro(u32 method, const u32* base_start, u32 amount, bool | |||
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | void Maxwell3D::RefreshParametersImpl() { | 225 | void Maxwell3D::RefreshParametersImpl() { |
| 226 | if (!Settings::IsGPULevelHigh()) { | ||
| 227 | return; | ||
| 228 | } | ||
| 226 | size_t current_index = 0; | 229 | size_t current_index = 0; |
| 227 | for (auto& segment : macro_segments) { | 230 | for (auto& segment : macro_segments) { |
| 228 | if (segment.first == 0) { | 231 | if (segment.first == 0) { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 90e35e307..4993d4709 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -1287,8 +1287,7 @@ bool AccelerateDMA::DmaBufferImageCopy(const Tegra::DMA::ImageCopy& copy_info, | |||
| 1287 | } | 1287 | } |
| 1288 | const u32 buffer_size = static_cast<u32>(buffer_operand.pitch * buffer_operand.height); | 1288 | const u32 buffer_size = static_cast<u32>(buffer_operand.pitch * buffer_operand.height); |
| 1289 | static constexpr auto sync_info = VideoCommon::ObtainBufferSynchronize::FullSynchronize; | 1289 | static constexpr auto sync_info = VideoCommon::ObtainBufferSynchronize::FullSynchronize; |
| 1290 | const auto post_op = IS_IMAGE_UPLOAD ? VideoCommon::ObtainBufferOperation::DoNothing | 1290 | const auto post_op = VideoCommon::ObtainBufferOperation::DoNothing; |
| 1291 | : VideoCommon::ObtainBufferOperation::MarkAsWritten; | ||
| 1292 | const auto [buffer, offset] = | 1291 | const auto [buffer, offset] = |
| 1293 | buffer_cache.ObtainBuffer(buffer_operand.address, buffer_size, sync_info, post_op); | 1292 | buffer_cache.ObtainBuffer(buffer_operand.address, buffer_size, sync_info, post_op); |
| 1294 | 1293 | ||
| @@ -1299,7 +1298,8 @@ bool AccelerateDMA::DmaBufferImageCopy(const Tegra::DMA::ImageCopy& copy_info, | |||
| 1299 | if constexpr (IS_IMAGE_UPLOAD) { | 1298 | if constexpr (IS_IMAGE_UPLOAD) { |
| 1300 | image->UploadMemory(buffer->Handle(), offset, copy_span); | 1299 | image->UploadMemory(buffer->Handle(), offset, copy_span); |
| 1301 | } else { | 1300 | } else { |
| 1302 | image->DownloadMemory(buffer->Handle(), offset, copy_span); | 1301 | texture_cache.DownloadImageIntoBuffer(image, buffer->Handle(), offset, copy_span, |
| 1302 | buffer_operand.address, buffer_size); | ||
| 1303 | } | 1303 | } |
| 1304 | return true; | 1304 | return true; |
| 1305 | } | 1305 | } |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 0b9c4a904..032a8ebc5 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -803,30 +803,40 @@ void Image::UploadMemory(const ImageBufferMap& map, | |||
| 803 | 803 | ||
| 804 | void Image::DownloadMemory(GLuint buffer_handle, size_t buffer_offset, | 804 | void Image::DownloadMemory(GLuint buffer_handle, size_t buffer_offset, |
| 805 | std::span<const VideoCommon::BufferImageCopy> copies) { | 805 | std::span<const VideoCommon::BufferImageCopy> copies) { |
| 806 | std::array buffer_handles{buffer_handle}; | ||
| 807 | std::array buffer_offsets{buffer_offset}; | ||
| 808 | DownloadMemory(buffer_handles, buffer_offsets, copies); | ||
| 809 | } | ||
| 810 | |||
| 811 | void Image::DownloadMemory(std::span<GLuint> buffer_handles, std::span<size_t> buffer_offsets, | ||
| 812 | std::span<const VideoCommon::BufferImageCopy> copies) { | ||
| 806 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); | 813 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); |
| 807 | if (is_rescaled) { | 814 | if (is_rescaled) { |
| 808 | ScaleDown(); | 815 | ScaleDown(); |
| 809 | } | 816 | } |
| 810 | glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API | 817 | glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API |
| 811 | glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer_handle); | 818 | for (size_t i = 0; i < buffer_handles.size(); i++) { |
| 812 | glPixelStorei(GL_PACK_ALIGNMENT, 1); | 819 | auto& buffer_handle = buffer_handles[i]; |
| 820 | glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer_handle); | ||
| 821 | glPixelStorei(GL_PACK_ALIGNMENT, 1); | ||
| 813 | 822 | ||
| 814 | u32 current_row_length = std::numeric_limits<u32>::max(); | 823 | u32 current_row_length = std::numeric_limits<u32>::max(); |
| 815 | u32 current_image_height = std::numeric_limits<u32>::max(); | 824 | u32 current_image_height = std::numeric_limits<u32>::max(); |
| 816 | 825 | ||
| 817 | for (const VideoCommon::BufferImageCopy& copy : copies) { | 826 | for (const VideoCommon::BufferImageCopy& copy : copies) { |
| 818 | if (copy.image_subresource.base_level >= gl_num_levels) { | 827 | if (copy.image_subresource.base_level >= gl_num_levels) { |
| 819 | continue; | 828 | continue; |
| 820 | } | 829 | } |
| 821 | if (current_row_length != copy.buffer_row_length) { | 830 | if (current_row_length != copy.buffer_row_length) { |
| 822 | current_row_length = copy.buffer_row_length; | 831 | current_row_length = copy.buffer_row_length; |
| 823 | glPixelStorei(GL_PACK_ROW_LENGTH, current_row_length); | 832 | glPixelStorei(GL_PACK_ROW_LENGTH, current_row_length); |
| 824 | } | 833 | } |
| 825 | if (current_image_height != copy.buffer_image_height) { | 834 | if (current_image_height != copy.buffer_image_height) { |
| 826 | current_image_height = copy.buffer_image_height; | 835 | current_image_height = copy.buffer_image_height; |
| 827 | glPixelStorei(GL_PACK_IMAGE_HEIGHT, current_image_height); | 836 | glPixelStorei(GL_PACK_IMAGE_HEIGHT, current_image_height); |
| 837 | } | ||
| 838 | CopyImageToBuffer(copy, buffer_offsets[i]); | ||
| 828 | } | 839 | } |
| 829 | CopyImageToBuffer(copy, buffer_offset); | ||
| 830 | } | 840 | } |
| 831 | if (is_rescaled) { | 841 | if (is_rescaled) { |
| 832 | ScaleUp(true); | 842 | ScaleUp(true); |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 911e4607a..0dd039ed2 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -215,6 +215,9 @@ public: | |||
| 215 | void DownloadMemory(GLuint buffer_handle, size_t buffer_offset, | 215 | void DownloadMemory(GLuint buffer_handle, size_t buffer_offset, |
| 216 | std::span<const VideoCommon::BufferImageCopy> copies); | 216 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 217 | 217 | ||
| 218 | void DownloadMemory(std::span<GLuint> buffer_handle, std::span<size_t> buffer_offset, | ||
| 219 | std::span<const VideoCommon::BufferImageCopy> copies); | ||
| 220 | |||
| 218 | void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); | 221 | void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); |
| 219 | 222 | ||
| 220 | GLuint StorageHandle() noexcept; | 223 | GLuint StorageHandle() noexcept; |
| @@ -376,6 +379,7 @@ struct TextureCacheParams { | |||
| 376 | using Sampler = OpenGL::Sampler; | 379 | using Sampler = OpenGL::Sampler; |
| 377 | using Framebuffer = OpenGL::Framebuffer; | 380 | using Framebuffer = OpenGL::Framebuffer; |
| 378 | using AsyncBuffer = u32; | 381 | using AsyncBuffer = u32; |
| 382 | using BufferType = GLuint; | ||
| 379 | }; | 383 | }; |
| 380 | 384 | ||
| 381 | using TextureCache = VideoCommon::TextureCache<TextureCacheParams>; | 385 | using TextureCache = VideoCommon::TextureCache<TextureCacheParams>; |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 985cc3203..a318d643e 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -696,6 +696,13 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline( | |||
| 696 | std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline( | 696 | std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline( |
| 697 | ShaderPools& pools, const ComputePipelineCacheKey& key, Shader::Environment& env, | 697 | ShaderPools& pools, const ComputePipelineCacheKey& key, Shader::Environment& env, |
| 698 | PipelineStatistics* statistics, bool build_in_parallel) try { | 698 | PipelineStatistics* statistics, bool build_in_parallel) try { |
| 699 | // TODO: Remove this when Intel fixes their shader compiler. | ||
| 700 | // https://github.com/IGCIT/Intel-GPU-Community-Issue-Tracker-IGCIT/issues/159 | ||
| 701 | if (device.GetDriverID() == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS) { | ||
| 702 | LOG_ERROR(Render_Vulkan, "Skipping 0x{:016x}", key.Hash()); | ||
| 703 | return nullptr; | ||
| 704 | } | ||
| 705 | |||
| 699 | LOG_INFO(Render_Vulkan, "0x{:016x}", key.Hash()); | 706 | LOG_INFO(Render_Vulkan, "0x{:016x}", key.Hash()); |
| 700 | 707 | ||
| 701 | Shader::Maxwell::Flow::CFG cfg{env, pools.flow_block, env.StartAddress()}; | 708 | Shader::Maxwell::Flow::CFG cfg{env, pools.flow_block, env.StartAddress()}; |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 673ab478e..2559a3aa7 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -781,8 +781,7 @@ bool AccelerateDMA::DmaBufferImageCopy(const Tegra::DMA::ImageCopy& copy_info, | |||
| 781 | } | 781 | } |
| 782 | const u32 buffer_size = static_cast<u32>(buffer_operand.pitch * buffer_operand.height); | 782 | const u32 buffer_size = static_cast<u32>(buffer_operand.pitch * buffer_operand.height); |
| 783 | static constexpr auto sync_info = VideoCommon::ObtainBufferSynchronize::FullSynchronize; | 783 | static constexpr auto sync_info = VideoCommon::ObtainBufferSynchronize::FullSynchronize; |
| 784 | const auto post_op = IS_IMAGE_UPLOAD ? VideoCommon::ObtainBufferOperation::DoNothing | 784 | const auto post_op = VideoCommon::ObtainBufferOperation::DoNothing; |
| 785 | : VideoCommon::ObtainBufferOperation::MarkAsWritten; | ||
| 786 | const auto [buffer, offset] = | 785 | const auto [buffer, offset] = |
| 787 | buffer_cache.ObtainBuffer(buffer_operand.address, buffer_size, sync_info, post_op); | 786 | buffer_cache.ObtainBuffer(buffer_operand.address, buffer_size, sync_info, post_op); |
| 788 | 787 | ||
| @@ -793,7 +792,8 @@ bool AccelerateDMA::DmaBufferImageCopy(const Tegra::DMA::ImageCopy& copy_info, | |||
| 793 | if constexpr (IS_IMAGE_UPLOAD) { | 792 | if constexpr (IS_IMAGE_UPLOAD) { |
| 794 | image->UploadMemory(buffer->Handle(), offset, copy_span); | 793 | image->UploadMemory(buffer->Handle(), offset, copy_span); |
| 795 | } else { | 794 | } else { |
| 796 | image->DownloadMemory(buffer->Handle(), offset, copy_span); | 795 | texture_cache.DownloadImageIntoBuffer(image, buffer->Handle(), offset, copy_span, |
| 796 | buffer_operand.address, buffer_size); | ||
| 797 | } | 797 | } |
| 798 | return true; | 798 | return true; |
| 799 | } | 799 | } |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index ae15f6976..d0a7d8f35 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -1,10 +1,11 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | 3 | ||
| 4 | #include <algorithm> | 4 | #include <algorithm> |
| 5 | #include <array> | 5 | #include <array> |
| 6 | #include <span> | 6 | #include <span> |
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | #include <boost/container/small_vector.hpp> | ||
| 8 | 9 | ||
| 9 | #include "common/bit_cast.h" | 10 | #include "common/bit_cast.h" |
| 10 | #include "common/bit_util.h" | 11 | #include "common/bit_util.h" |
| @@ -1343,14 +1344,31 @@ void Image::UploadMemory(const StagingBufferRef& map, std::span<const BufferImag | |||
| 1343 | 1344 | ||
| 1344 | void Image::DownloadMemory(VkBuffer buffer, VkDeviceSize offset, | 1345 | void Image::DownloadMemory(VkBuffer buffer, VkDeviceSize offset, |
| 1345 | std::span<const VideoCommon::BufferImageCopy> copies) { | 1346 | std::span<const VideoCommon::BufferImageCopy> copies) { |
| 1347 | std::array buffer_handles{ | ||
| 1348 | buffer, | ||
| 1349 | }; | ||
| 1350 | std::array buffer_offsets{ | ||
| 1351 | offset, | ||
| 1352 | }; | ||
| 1353 | DownloadMemory(buffer_handles, buffer_offsets, copies); | ||
| 1354 | } | ||
| 1355 | |||
| 1356 | void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<VkDeviceSize> offsets_span, | ||
| 1357 | std::span<const VideoCommon::BufferImageCopy> copies) { | ||
| 1346 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); | 1358 | const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); |
| 1347 | if (is_rescaled) { | 1359 | if (is_rescaled) { |
| 1348 | ScaleDown(); | 1360 | ScaleDown(); |
| 1349 | } | 1361 | } |
| 1350 | std::vector vk_copies = TransformBufferImageCopies(copies, offset, aspect_mask); | 1362 | boost::container::small_vector<VkBuffer, 1> buffers_vector{}; |
| 1363 | boost::container::small_vector<std::vector<VkBufferImageCopy>, 1> vk_copies; | ||
| 1364 | for (size_t index = 0; index < buffers_span.size(); index++) { | ||
| 1365 | buffers_vector.emplace_back(buffers_span[index]); | ||
| 1366 | vk_copies.emplace_back( | ||
| 1367 | TransformBufferImageCopies(copies, offsets_span[index], aspect_mask)); | ||
| 1368 | } | ||
| 1351 | scheduler->RequestOutsideRenderPassOperationContext(); | 1369 | scheduler->RequestOutsideRenderPassOperationContext(); |
| 1352 | scheduler->Record([buffer, image = *original_image, aspect_mask = aspect_mask, | 1370 | scheduler->Record([buffers = std::move(buffers_vector), image = *original_image, |
| 1353 | vk_copies](vk::CommandBuffer cmdbuf) { | 1371 | aspect_mask = aspect_mask, vk_copies](vk::CommandBuffer cmdbuf) { |
| 1354 | const VkImageMemoryBarrier read_barrier{ | 1372 | const VkImageMemoryBarrier read_barrier{ |
| 1355 | .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, | 1373 | .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, |
| 1356 | .pNext = nullptr, | 1374 | .pNext = nullptr, |
| @@ -1369,6 +1387,20 @@ void Image::DownloadMemory(VkBuffer buffer, VkDeviceSize offset, | |||
| 1369 | .layerCount = VK_REMAINING_ARRAY_LAYERS, | 1387 | .layerCount = VK_REMAINING_ARRAY_LAYERS, |
| 1370 | }, | 1388 | }, |
| 1371 | }; | 1389 | }; |
| 1390 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, | ||
| 1391 | 0, read_barrier); | ||
| 1392 | |||
| 1393 | for (size_t index = 0; index < buffers.size(); index++) { | ||
| 1394 | cmdbuf.CopyImageToBuffer(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buffers[index], | ||
| 1395 | vk_copies[index]); | ||
| 1396 | } | ||
| 1397 | |||
| 1398 | const VkMemoryBarrier memory_write_barrier{ | ||
| 1399 | .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, | ||
| 1400 | .pNext = nullptr, | ||
| 1401 | .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, | ||
| 1402 | .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, | ||
| 1403 | }; | ||
| 1372 | const VkImageMemoryBarrier image_write_barrier{ | 1404 | const VkImageMemoryBarrier image_write_barrier{ |
| 1373 | .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, | 1405 | .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, |
| 1374 | .pNext = nullptr, | 1406 | .pNext = nullptr, |
| @@ -1387,15 +1419,6 @@ void Image::DownloadMemory(VkBuffer buffer, VkDeviceSize offset, | |||
| 1387 | .layerCount = VK_REMAINING_ARRAY_LAYERS, | 1419 | .layerCount = VK_REMAINING_ARRAY_LAYERS, |
| 1388 | }, | 1420 | }, |
| 1389 | }; | 1421 | }; |
| 1390 | const VkMemoryBarrier memory_write_barrier{ | ||
| 1391 | .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, | ||
| 1392 | .pNext = nullptr, | ||
| 1393 | .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, | ||
| 1394 | .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, | ||
| 1395 | }; | ||
| 1396 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, | ||
| 1397 | 0, read_barrier); | ||
| 1398 | cmdbuf.CopyImageToBuffer(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buffer, vk_copies); | ||
| 1399 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | 1422 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1400 | 0, memory_write_barrier, nullptr, image_write_barrier); | 1423 | 0, memory_write_barrier, nullptr, image_write_barrier); |
| 1401 | }); | 1424 | }); |
| @@ -1405,7 +1428,13 @@ void Image::DownloadMemory(VkBuffer buffer, VkDeviceSize offset, | |||
| 1405 | } | 1428 | } |
| 1406 | 1429 | ||
| 1407 | void Image::DownloadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { | 1430 | void Image::DownloadMemory(const StagingBufferRef& map, std::span<const BufferImageCopy> copies) { |
| 1408 | DownloadMemory(map.buffer, map.offset, copies); | 1431 | std::array buffers{ |
| 1432 | map.buffer, | ||
| 1433 | }; | ||
| 1434 | std::array offsets{ | ||
| 1435 | map.offset, | ||
| 1436 | }; | ||
| 1437 | DownloadMemory(buffers, offsets, copies); | ||
| 1409 | } | 1438 | } |
| 1410 | 1439 | ||
| 1411 | bool Image::IsRescaled() const noexcept { | 1440 | bool Image::IsRescaled() const noexcept { |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index d5ee23f8d..c656c5386 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| @@ -141,6 +141,9 @@ public: | |||
| 141 | void DownloadMemory(VkBuffer buffer, VkDeviceSize offset, | 141 | void DownloadMemory(VkBuffer buffer, VkDeviceSize offset, |
| 142 | std::span<const VideoCommon::BufferImageCopy> copies); | 142 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 143 | 143 | ||
| 144 | void DownloadMemory(std::span<VkBuffer> buffers, std::span<VkDeviceSize> offsets, | ||
| 145 | std::span<const VideoCommon::BufferImageCopy> copies); | ||
| 146 | |||
| 144 | void DownloadMemory(const StagingBufferRef& map, | 147 | void DownloadMemory(const StagingBufferRef& map, |
| 145 | std::span<const VideoCommon::BufferImageCopy> copies); | 148 | std::span<const VideoCommon::BufferImageCopy> copies); |
| 146 | 149 | ||
| @@ -371,6 +374,7 @@ struct TextureCacheParams { | |||
| 371 | using Sampler = Vulkan::Sampler; | 374 | using Sampler = Vulkan::Sampler; |
| 372 | using Framebuffer = Vulkan::Framebuffer; | 375 | using Framebuffer = Vulkan::Framebuffer; |
| 373 | using AsyncBuffer = Vulkan::StagingBufferRef; | 376 | using AsyncBuffer = Vulkan::StagingBufferRef; |
| 377 | using BufferType = VkBuffer; | ||
| 374 | }; | 378 | }; |
| 375 | 379 | ||
| 376 | using TextureCache = VideoCommon::TextureCache<TextureCacheParams>; | 380 | using TextureCache = VideoCommon::TextureCache<TextureCacheParams>; |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index ed5c768d8..e601f8446 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -1,9 +1,10 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | 2 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <unordered_set> | 6 | #include <unordered_set> |
| 7 | #include <boost/container/small_vector.hpp> | ||
| 7 | 8 | ||
| 8 | #include "common/alignment.h" | 9 | #include "common/alignment.h" |
| 9 | #include "common/settings.h" | 10 | #include "common/settings.h" |
| @@ -17,15 +18,10 @@ | |||
| 17 | 18 | ||
| 18 | namespace VideoCommon { | 19 | namespace VideoCommon { |
| 19 | 20 | ||
| 20 | using Tegra::Texture::SwizzleSource; | ||
| 21 | using Tegra::Texture::TextureType; | ||
| 22 | using Tegra::Texture::TICEntry; | 21 | using Tegra::Texture::TICEntry; |
| 23 | using Tegra::Texture::TSCEntry; | 22 | using Tegra::Texture::TSCEntry; |
| 24 | using VideoCore::Surface::GetFormatType; | 23 | using VideoCore::Surface::GetFormatType; |
| 25 | using VideoCore::Surface::IsCopyCompatible; | ||
| 26 | using VideoCore::Surface::PixelFormat; | 24 | using VideoCore::Surface::PixelFormat; |
| 27 | using VideoCore::Surface::PixelFormatFromDepthFormat; | ||
| 28 | using VideoCore::Surface::PixelFormatFromRenderTargetFormat; | ||
| 29 | using VideoCore::Surface::SurfaceType; | 25 | using VideoCore::Surface::SurfaceType; |
| 30 | using namespace Common::Literals; | 26 | using namespace Common::Literals; |
| 31 | 27 | ||
| @@ -143,6 +139,13 @@ void TextureCache<P>::TickFrame() { | |||
| 143 | runtime.TickFrame(); | 139 | runtime.TickFrame(); |
| 144 | critical_gc = 0; | 140 | critical_gc = 0; |
| 145 | ++frame_tick; | 141 | ++frame_tick; |
| 142 | |||
| 143 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | ||
| 144 | for (auto& buffer : async_buffers_death_ring) { | ||
| 145 | runtime.FreeDeferredStagingBuffer(buffer); | ||
| 146 | } | ||
| 147 | async_buffers_death_ring.clear(); | ||
| 148 | } | ||
| 146 | } | 149 | } |
| 147 | 150 | ||
| 148 | template <class P> | 151 | template <class P> |
| @@ -661,25 +664,39 @@ template <class P> | |||
| 661 | void TextureCache<P>::CommitAsyncFlushes() { | 664 | void TextureCache<P>::CommitAsyncFlushes() { |
| 662 | // This is intentionally passing the value by copy | 665 | // This is intentionally passing the value by copy |
| 663 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | 666 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { |
| 664 | const std::span<const ImageId> download_ids = uncommitted_downloads; | 667 | auto& download_ids = uncommitted_downloads; |
| 665 | if (download_ids.empty()) { | 668 | if (download_ids.empty()) { |
| 666 | committed_downloads.emplace_back(std::move(uncommitted_downloads)); | 669 | committed_downloads.emplace_back(std::move(uncommitted_downloads)); |
| 667 | uncommitted_downloads.clear(); | 670 | uncommitted_downloads.clear(); |
| 668 | async_buffers.emplace_back(std::optional<AsyncBuffer>{}); | 671 | async_buffers.emplace_back(std::move(uncommitted_async_buffers)); |
| 672 | uncommitted_async_buffers.clear(); | ||
| 669 | return; | 673 | return; |
| 670 | } | 674 | } |
| 671 | size_t total_size_bytes = 0; | 675 | size_t total_size_bytes = 0; |
| 672 | for (const ImageId image_id : download_ids) { | 676 | size_t last_async_buffer_id = uncommitted_async_buffers.size(); |
| 673 | total_size_bytes += slot_images[image_id].unswizzled_size_bytes; | 677 | bool any_none_dma = false; |
| 678 | for (PendingDownload& download_info : download_ids) { | ||
| 679 | if (download_info.is_swizzle) { | ||
| 680 | total_size_bytes += | ||
| 681 | Common::AlignUp(slot_images[download_info.object_id].unswizzled_size_bytes, 64); | ||
| 682 | any_none_dma = true; | ||
| 683 | download_info.async_buffer_id = last_async_buffer_id; | ||
| 684 | } | ||
| 674 | } | 685 | } |
| 675 | auto download_map = runtime.DownloadStagingBuffer(total_size_bytes, true); | 686 | if (any_none_dma) { |
| 676 | for (const ImageId image_id : download_ids) { | 687 | auto download_map = runtime.DownloadStagingBuffer(total_size_bytes, true); |
| 677 | Image& image = slot_images[image_id]; | 688 | for (const PendingDownload& download_info : download_ids) { |
| 678 | const auto copies = FullDownloadCopies(image.info); | 689 | if (download_info.is_swizzle) { |
| 679 | image.DownloadMemory(download_map, copies); | 690 | Image& image = slot_images[download_info.object_id]; |
| 680 | download_map.offset += Common::AlignUp(image.unswizzled_size_bytes, 64); | 691 | const auto copies = FullDownloadCopies(image.info); |
| 692 | image.DownloadMemory(download_map, copies); | ||
| 693 | download_map.offset += Common::AlignUp(image.unswizzled_size_bytes, 64); | ||
| 694 | } | ||
| 695 | } | ||
| 696 | uncommitted_async_buffers.emplace_back(download_map); | ||
| 681 | } | 697 | } |
| 682 | async_buffers.emplace_back(download_map); | 698 | async_buffers.emplace_back(std::move(uncommitted_async_buffers)); |
| 699 | uncommitted_async_buffers.clear(); | ||
| 683 | } | 700 | } |
| 684 | committed_downloads.emplace_back(std::move(uncommitted_downloads)); | 701 | committed_downloads.emplace_back(std::move(uncommitted_downloads)); |
| 685 | uncommitted_downloads.clear(); | 702 | uncommitted_downloads.clear(); |
| @@ -691,39 +708,57 @@ void TextureCache<P>::PopAsyncFlushes() { | |||
| 691 | return; | 708 | return; |
| 692 | } | 709 | } |
| 693 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | 710 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { |
| 694 | const std::span<const ImageId> download_ids = committed_downloads.front(); | 711 | const auto& download_ids = committed_downloads.front(); |
| 695 | if (download_ids.empty()) { | 712 | if (download_ids.empty()) { |
| 696 | committed_downloads.pop_front(); | 713 | committed_downloads.pop_front(); |
| 697 | async_buffers.pop_front(); | 714 | async_buffers.pop_front(); |
| 698 | return; | 715 | return; |
| 699 | } | 716 | } |
| 700 | auto download_map = *async_buffers.front(); | 717 | auto download_map = std::move(async_buffers.front()); |
| 701 | std::span<u8> download_span = download_map.mapped_span; | ||
| 702 | for (size_t i = download_ids.size(); i > 0; i--) { | 718 | for (size_t i = download_ids.size(); i > 0; i--) { |
| 703 | const ImageBase& image = slot_images[download_ids[i - 1]]; | 719 | auto& download_info = download_ids[i - 1]; |
| 704 | const auto copies = FullDownloadCopies(image.info); | 720 | auto& download_buffer = download_map[download_info.async_buffer_id]; |
| 705 | download_map.offset -= Common::AlignUp(image.unswizzled_size_bytes, 64); | 721 | if (download_info.is_swizzle) { |
| 706 | std::span<u8> download_span_alt = download_span.subspan(download_map.offset); | 722 | const ImageBase& image = slot_images[download_info.object_id]; |
| 707 | SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span_alt, | 723 | const auto copies = FullDownloadCopies(image.info); |
| 708 | swizzle_data_buffer); | 724 | download_buffer.offset -= Common::AlignUp(image.unswizzled_size_bytes, 64); |
| 725 | std::span<u8> download_span = | ||
| 726 | download_buffer.mapped_span.subspan(download_buffer.offset); | ||
| 727 | SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span, | ||
| 728 | swizzle_data_buffer); | ||
| 729 | } else { | ||
| 730 | const BufferDownload& buffer_info = slot_buffer_downloads[download_info.object_id]; | ||
| 731 | std::span<u8> download_span = | ||
| 732 | download_buffer.mapped_span.subspan(download_buffer.offset); | ||
| 733 | gpu_memory->WriteBlockUnsafe(buffer_info.address, download_span.data(), | ||
| 734 | buffer_info.size); | ||
| 735 | slot_buffer_downloads.erase(download_info.object_id); | ||
| 736 | } | ||
| 737 | } | ||
| 738 | for (auto& download_buffer : download_map) { | ||
| 739 | async_buffers_death_ring.emplace_back(download_buffer); | ||
| 709 | } | 740 | } |
| 710 | runtime.FreeDeferredStagingBuffer(download_map); | ||
| 711 | committed_downloads.pop_front(); | 741 | committed_downloads.pop_front(); |
| 712 | async_buffers.pop_front(); | 742 | async_buffers.pop_front(); |
| 713 | } else { | 743 | } else { |
| 714 | const std::span<const ImageId> download_ids = committed_downloads.front(); | 744 | const auto& download_ids = committed_downloads.front(); |
| 715 | if (download_ids.empty()) { | 745 | if (download_ids.empty()) { |
| 716 | committed_downloads.pop_front(); | 746 | committed_downloads.pop_front(); |
| 717 | return; | 747 | return; |
| 718 | } | 748 | } |
| 719 | size_t total_size_bytes = 0; | 749 | size_t total_size_bytes = 0; |
| 720 | for (const ImageId image_id : download_ids) { | 750 | for (const PendingDownload& download_info : download_ids) { |
| 721 | total_size_bytes += slot_images[image_id].unswizzled_size_bytes; | 751 | if (download_info.is_swizzle) { |
| 752 | total_size_bytes += slot_images[download_info.object_id].unswizzled_size_bytes; | ||
| 753 | } | ||
| 722 | } | 754 | } |
| 723 | auto download_map = runtime.DownloadStagingBuffer(total_size_bytes); | 755 | auto download_map = runtime.DownloadStagingBuffer(total_size_bytes); |
| 724 | const size_t original_offset = download_map.offset; | 756 | const size_t original_offset = download_map.offset; |
| 725 | for (const ImageId image_id : download_ids) { | 757 | for (const PendingDownload& download_info : download_ids) { |
| 726 | Image& image = slot_images[image_id]; | 758 | if (!download_info.is_swizzle) { |
| 759 | continue; | ||
| 760 | } | ||
| 761 | Image& image = slot_images[download_info.object_id]; | ||
| 727 | const auto copies = FullDownloadCopies(image.info); | 762 | const auto copies = FullDownloadCopies(image.info); |
| 728 | image.DownloadMemory(download_map, copies); | 763 | image.DownloadMemory(download_map, copies); |
| 729 | download_map.offset += image.unswizzled_size_bytes; | 764 | download_map.offset += image.unswizzled_size_bytes; |
| @@ -732,8 +767,11 @@ void TextureCache<P>::PopAsyncFlushes() { | |||
| 732 | runtime.Finish(); | 767 | runtime.Finish(); |
| 733 | download_map.offset = original_offset; | 768 | download_map.offset = original_offset; |
| 734 | std::span<u8> download_span = download_map.mapped_span; | 769 | std::span<u8> download_span = download_map.mapped_span; |
| 735 | for (const ImageId image_id : download_ids) { | 770 | for (const PendingDownload& download_info : download_ids) { |
| 736 | const ImageBase& image = slot_images[image_id]; | 771 | if (!download_info.is_swizzle) { |
| 772 | continue; | ||
| 773 | } | ||
| 774 | const ImageBase& image = slot_images[download_info.object_id]; | ||
| 737 | const auto copies = FullDownloadCopies(image.info); | 775 | const auto copies = FullDownloadCopies(image.info); |
| 738 | SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span, | 776 | SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span, |
| 739 | swizzle_data_buffer); | 777 | swizzle_data_buffer); |
| @@ -834,6 +872,33 @@ std::pair<typename TextureCache<P>::Image*, BufferImageCopy> TextureCache<P>::Dm | |||
| 834 | } | 872 | } |
| 835 | 873 | ||
| 836 | template <class P> | 874 | template <class P> |
| 875 | void TextureCache<P>::DownloadImageIntoBuffer(typename TextureCache<P>::Image* image, | ||
| 876 | typename TextureCache<P>::BufferType buffer, | ||
| 877 | size_t buffer_offset, | ||
| 878 | std::span<const VideoCommon::BufferImageCopy> copies, | ||
| 879 | GPUVAddr address, size_t size) { | ||
| 880 | if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { | ||
| 881 | const BufferDownload new_buffer_download{address, size}; | ||
| 882 | auto slot = slot_buffer_downloads.insert(new_buffer_download); | ||
| 883 | const PendingDownload new_download{false, uncommitted_async_buffers.size(), slot}; | ||
| 884 | uncommitted_downloads.emplace_back(new_download); | ||
| 885 | auto download_map = runtime.DownloadStagingBuffer(size, true); | ||
| 886 | uncommitted_async_buffers.emplace_back(download_map); | ||
| 887 | std::array buffers{ | ||
| 888 | buffer, | ||
| 889 | download_map.buffer, | ||
| 890 | }; | ||
| 891 | std::array buffer_offsets{ | ||
| 892 | buffer_offset, | ||
| 893 | download_map.offset, | ||
| 894 | }; | ||
| 895 | image->DownloadMemory(buffers, buffer_offsets, copies); | ||
| 896 | } else { | ||
| 897 | image->DownloadMemory(buffer, buffer_offset, copies); | ||
| 898 | } | ||
| 899 | } | ||
| 900 | |||
| 901 | template <class P> | ||
| 837 | void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) { | 902 | void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) { |
| 838 | if (False(image.flags & ImageFlagBits::CpuModified)) { | 903 | if (False(image.flags & ImageFlagBits::CpuModified)) { |
| 839 | // Only upload modified images | 904 | // Only upload modified images |
| @@ -2209,7 +2274,8 @@ void TextureCache<P>::BindRenderTarget(ImageViewId* old_id, ImageViewId new_id) | |||
| 2209 | if (new_id) { | 2274 | if (new_id) { |
| 2210 | const ImageViewBase& old_view = slot_image_views[new_id]; | 2275 | const ImageViewBase& old_view = slot_image_views[new_id]; |
| 2211 | if (True(old_view.flags & ImageViewFlagBits::PreemtiveDownload)) { | 2276 | if (True(old_view.flags & ImageViewFlagBits::PreemtiveDownload)) { |
| 2212 | uncommitted_downloads.push_back(old_view.image_id); | 2277 | const PendingDownload new_download{true, 0, old_view.image_id}; |
| 2278 | uncommitted_downloads.emplace_back(new_download); | ||
| 2213 | } | 2279 | } |
| 2214 | } | 2280 | } |
| 2215 | *old_id = new_id; | 2281 | *old_id = new_id; |
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 5a5b4179c..758b7e212 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later | 2 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| @@ -40,14 +40,9 @@ struct ChannelState; | |||
| 40 | 40 | ||
| 41 | namespace VideoCommon { | 41 | namespace VideoCommon { |
| 42 | 42 | ||
| 43 | using Tegra::Texture::SwizzleSource; | ||
| 44 | using Tegra::Texture::TICEntry; | 43 | using Tegra::Texture::TICEntry; |
| 45 | using Tegra::Texture::TSCEntry; | 44 | using Tegra::Texture::TSCEntry; |
| 46 | using VideoCore::Surface::GetFormatType; | ||
| 47 | using VideoCore::Surface::IsCopyCompatible; | ||
| 48 | using VideoCore::Surface::PixelFormat; | 45 | using VideoCore::Surface::PixelFormat; |
| 49 | using VideoCore::Surface::PixelFormatFromDepthFormat; | ||
| 50 | using VideoCore::Surface::PixelFormatFromRenderTargetFormat; | ||
| 51 | using namespace Common::Literals; | 46 | using namespace Common::Literals; |
| 52 | 47 | ||
| 53 | struct ImageViewInOut { | 48 | struct ImageViewInOut { |
| @@ -119,6 +114,7 @@ class TextureCache : public VideoCommon::ChannelSetupCaches<TextureCacheChannelI | |||
| 119 | using Sampler = typename P::Sampler; | 114 | using Sampler = typename P::Sampler; |
| 120 | using Framebuffer = typename P::Framebuffer; | 115 | using Framebuffer = typename P::Framebuffer; |
| 121 | using AsyncBuffer = typename P::AsyncBuffer; | 116 | using AsyncBuffer = typename P::AsyncBuffer; |
| 117 | using BufferType = typename P::BufferType; | ||
| 122 | 118 | ||
| 123 | struct BlitImages { | 119 | struct BlitImages { |
| 124 | ImageId dst_id; | 120 | ImageId dst_id; |
| @@ -215,6 +211,10 @@ public: | |||
| 215 | const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::BufferOperand& buffer_operand, | 211 | const Tegra::DMA::ImageCopy& copy_info, const Tegra::DMA::BufferOperand& buffer_operand, |
| 216 | const Tegra::DMA::ImageOperand& image_operand, ImageId image_id, bool modifies_image); | 212 | const Tegra::DMA::ImageOperand& image_operand, ImageId image_id, bool modifies_image); |
| 217 | 213 | ||
| 214 | void DownloadImageIntoBuffer(Image* image, BufferType buffer, size_t buffer_offset, | ||
| 215 | std::span<const VideoCommon::BufferImageCopy> copies, | ||
| 216 | GPUVAddr address = 0, size_t size = 0); | ||
| 217 | |||
| 218 | /// Return true when a CPU region is modified from the GPU | 218 | /// Return true when a CPU region is modified from the GPU |
| 219 | [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); | 219 | [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); |
| 220 | 220 | ||
| @@ -424,17 +424,32 @@ private: | |||
| 424 | u64 critical_memory; | 424 | u64 critical_memory; |
| 425 | size_t critical_gc; | 425 | size_t critical_gc; |
| 426 | 426 | ||
| 427 | struct BufferDownload { | ||
| 428 | GPUVAddr address; | ||
| 429 | size_t size; | ||
| 430 | }; | ||
| 431 | |||
| 432 | struct PendingDownload { | ||
| 433 | bool is_swizzle; | ||
| 434 | size_t async_buffer_id; | ||
| 435 | SlotId object_id; | ||
| 436 | }; | ||
| 437 | |||
| 427 | SlotVector<Image> slot_images; | 438 | SlotVector<Image> slot_images; |
| 428 | SlotVector<ImageMapView> slot_map_views; | 439 | SlotVector<ImageMapView> slot_map_views; |
| 429 | SlotVector<ImageView> slot_image_views; | 440 | SlotVector<ImageView> slot_image_views; |
| 430 | SlotVector<ImageAlloc> slot_image_allocs; | 441 | SlotVector<ImageAlloc> slot_image_allocs; |
| 431 | SlotVector<Sampler> slot_samplers; | 442 | SlotVector<Sampler> slot_samplers; |
| 432 | SlotVector<Framebuffer> slot_framebuffers; | 443 | SlotVector<Framebuffer> slot_framebuffers; |
| 444 | SlotVector<BufferDownload> slot_buffer_downloads; | ||
| 433 | 445 | ||
| 434 | // TODO: This data structure is not optimal and it should be reworked | 446 | // TODO: This data structure is not optimal and it should be reworked |
| 435 | std::vector<ImageId> uncommitted_downloads; | 447 | |
| 436 | std::deque<std::vector<ImageId>> committed_downloads; | 448 | std::vector<PendingDownload> uncommitted_downloads; |
| 437 | std::deque<std::optional<AsyncBuffer>> async_buffers; | 449 | std::deque<std::vector<PendingDownload>> committed_downloads; |
| 450 | std::vector<AsyncBuffer> uncommitted_async_buffers; | ||
| 451 | std::deque<std::vector<AsyncBuffer>> async_buffers; | ||
| 452 | std::deque<AsyncBuffer> async_buffers_death_ring; | ||
| 438 | 453 | ||
| 439 | struct LRUItemParams { | 454 | struct LRUItemParams { |
| 440 | using ObjectType = ImageId; | 455 | using ObjectType = ImageId; |