diff options
| -rw-r--r-- | src/audio_core/sink/cubeb_sink.cpp | 20 | ||||
| -rw-r--r-- | src/tests/video_core/buffer_base.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/buffer_cache/buffer_base.h | 14 |
3 files changed, 29 insertions, 7 deletions
diff --git a/src/audio_core/sink/cubeb_sink.cpp b/src/audio_core/sink/cubeb_sink.cpp index 32c1b1cb3..9133f5388 100644 --- a/src/audio_core/sink/cubeb_sink.cpp +++ b/src/audio_core/sink/cubeb_sink.cpp | |||
| @@ -302,11 +302,21 @@ std::vector<std::string> ListCubebSinkDevices(bool capture) { | |||
| 302 | std::vector<std::string> device_list; | 302 | std::vector<std::string> device_list; |
| 303 | cubeb* ctx; | 303 | cubeb* ctx; |
| 304 | 304 | ||
| 305 | #ifdef _WIN32 | ||
| 306 | auto com_init_result = CoInitializeEx(nullptr, COINIT_MULTITHREADED); | ||
| 307 | #endif | ||
| 308 | |||
| 305 | if (cubeb_init(&ctx, "yuzu Device Enumerator", nullptr) != CUBEB_OK) { | 309 | if (cubeb_init(&ctx, "yuzu Device Enumerator", nullptr) != CUBEB_OK) { |
| 306 | LOG_CRITICAL(Audio_Sink, "cubeb_init failed"); | 310 | LOG_CRITICAL(Audio_Sink, "cubeb_init failed"); |
| 307 | return {}; | 311 | return {}; |
| 308 | } | 312 | } |
| 309 | 313 | ||
| 314 | #ifdef _WIN32 | ||
| 315 | if (SUCCEEDED(com_init_result)) { | ||
| 316 | CoUninitialize(); | ||
| 317 | } | ||
| 318 | #endif | ||
| 319 | |||
| 310 | auto type{capture ? CUBEB_DEVICE_TYPE_INPUT : CUBEB_DEVICE_TYPE_OUTPUT}; | 320 | auto type{capture ? CUBEB_DEVICE_TYPE_INPUT : CUBEB_DEVICE_TYPE_OUTPUT}; |
| 311 | cubeb_device_collection collection; | 321 | cubeb_device_collection collection; |
| 312 | if (cubeb_enumerate_devices(ctx, type, &collection) != CUBEB_OK) { | 322 | if (cubeb_enumerate_devices(ctx, type, &collection) != CUBEB_OK) { |
| @@ -329,12 +339,22 @@ std::vector<std::string> ListCubebSinkDevices(bool capture) { | |||
| 329 | u32 GetCubebLatency() { | 339 | u32 GetCubebLatency() { |
| 330 | cubeb* ctx; | 340 | cubeb* ctx; |
| 331 | 341 | ||
| 342 | #ifdef _WIN32 | ||
| 343 | auto com_init_result = CoInitializeEx(nullptr, COINIT_MULTITHREADED); | ||
| 344 | #endif | ||
| 345 | |||
| 332 | if (cubeb_init(&ctx, "yuzu Latency Getter", nullptr) != CUBEB_OK) { | 346 | if (cubeb_init(&ctx, "yuzu Latency Getter", nullptr) != CUBEB_OK) { |
| 333 | LOG_CRITICAL(Audio_Sink, "cubeb_init failed"); | 347 | LOG_CRITICAL(Audio_Sink, "cubeb_init failed"); |
| 334 | // Return a large latency so we choose SDL instead. | 348 | // Return a large latency so we choose SDL instead. |
| 335 | return 10000u; | 349 | return 10000u; |
| 336 | } | 350 | } |
| 337 | 351 | ||
| 352 | #ifdef _WIN32 | ||
| 353 | if (SUCCEEDED(com_init_result)) { | ||
| 354 | CoUninitialize(); | ||
| 355 | } | ||
| 356 | #endif | ||
| 357 | |||
| 338 | cubeb_stream_params params{}; | 358 | cubeb_stream_params params{}; |
| 339 | params.rate = TargetSampleRate; | 359 | params.rate = TargetSampleRate; |
| 340 | params.channels = 2; | 360 | params.channels = 2; |
diff --git a/src/tests/video_core/buffer_base.cpp b/src/tests/video_core/buffer_base.cpp index 1275cca24..734dbf4b6 100644 --- a/src/tests/video_core/buffer_base.cpp +++ b/src/tests/video_core/buffer_base.cpp | |||
| @@ -538,7 +538,7 @@ TEST_CASE("BufferBase: Cached write downloads") { | |||
| 538 | int num = 0; | 538 | int num = 0; |
| 539 | buffer.ForEachDownloadRangeAndClear(c, WORD, [&](u64 offset, u64 size) { ++num; }); | 539 | buffer.ForEachDownloadRangeAndClear(c, WORD, [&](u64 offset, u64 size) { ++num; }); |
| 540 | buffer.ForEachUploadRange(c, WORD, [&](u64 offset, u64 size) { ++num; }); | 540 | buffer.ForEachUploadRange(c, WORD, [&](u64 offset, u64 size) { ++num; }); |
| 541 | REQUIRE(num == 1); | 541 | REQUIRE(num == 0); |
| 542 | REQUIRE(!buffer.IsRegionCpuModified(c + PAGE, PAGE)); | 542 | REQUIRE(!buffer.IsRegionCpuModified(c + PAGE, PAGE)); |
| 543 | REQUIRE(!buffer.IsRegionGpuModified(c + PAGE, PAGE)); | 543 | REQUIRE(!buffer.IsRegionGpuModified(c + PAGE, PAGE)); |
| 544 | buffer.FlushCachedWrites(); | 544 | buffer.FlushCachedWrites(); |
diff --git a/src/video_core/buffer_cache/buffer_base.h b/src/video_core/buffer_cache/buffer_base.h index c47b7d866..92d77eef2 100644 --- a/src/video_core/buffer_cache/buffer_base.h +++ b/src/video_core/buffer_cache/buffer_base.h | |||
| @@ -430,7 +430,7 @@ private: | |||
| 430 | if (query_begin >= SizeBytes() || size < 0) { | 430 | if (query_begin >= SizeBytes() || size < 0) { |
| 431 | return; | 431 | return; |
| 432 | } | 432 | } |
| 433 | [[maybe_unused]] u64* const untracked_words = Array<Type::Untracked>(); | 433 | u64* const untracked_words = Array<Type::Untracked>(); |
| 434 | u64* const state_words = Array<type>(); | 434 | u64* const state_words = Array<type>(); |
| 435 | const u64 query_end = query_begin + std::min(static_cast<u64>(size), SizeBytes()); | 435 | const u64 query_end = query_begin + std::min(static_cast<u64>(size), SizeBytes()); |
| 436 | u64* const words_begin = state_words + query_begin / BYTES_PER_WORD; | 436 | u64* const words_begin = state_words + query_begin / BYTES_PER_WORD; |
| @@ -483,7 +483,7 @@ private: | |||
| 483 | NotifyRasterizer<true>(word_index, current_bits, ~u64{0}); | 483 | NotifyRasterizer<true>(word_index, current_bits, ~u64{0}); |
| 484 | } | 484 | } |
| 485 | // Exclude CPU modified pages when visiting GPU pages | 485 | // Exclude CPU modified pages when visiting GPU pages |
| 486 | const u64 word = current_word; | 486 | const u64 word = current_word & ~(type == Type::GPU ? untracked_words[word_index] : 0); |
| 487 | u64 page = page_begin; | 487 | u64 page = page_begin; |
| 488 | page_begin = 0; | 488 | page_begin = 0; |
| 489 | 489 | ||
| @@ -531,7 +531,7 @@ private: | |||
| 531 | [[nodiscard]] bool IsRegionModified(u64 offset, u64 size) const noexcept { | 531 | [[nodiscard]] bool IsRegionModified(u64 offset, u64 size) const noexcept { |
| 532 | static_assert(type != Type::Untracked); | 532 | static_assert(type != Type::Untracked); |
| 533 | 533 | ||
| 534 | [[maybe_unused]] const u64* const untracked_words = Array<Type::Untracked>(); | 534 | const u64* const untracked_words = Array<Type::Untracked>(); |
| 535 | const u64* const state_words = Array<type>(); | 535 | const u64* const state_words = Array<type>(); |
| 536 | const u64 num_query_words = size / BYTES_PER_WORD + 1; | 536 | const u64 num_query_words = size / BYTES_PER_WORD + 1; |
| 537 | const u64 word_begin = offset / BYTES_PER_WORD; | 537 | const u64 word_begin = offset / BYTES_PER_WORD; |
| @@ -539,7 +539,8 @@ private: | |||
| 539 | const u64 page_limit = Common::DivCeil(offset + size, BYTES_PER_PAGE); | 539 | const u64 page_limit = Common::DivCeil(offset + size, BYTES_PER_PAGE); |
| 540 | u64 page_index = (offset / BYTES_PER_PAGE) % PAGES_PER_WORD; | 540 | u64 page_index = (offset / BYTES_PER_PAGE) % PAGES_PER_WORD; |
| 541 | for (u64 word_index = word_begin; word_index < word_end; ++word_index, page_index = 0) { | 541 | for (u64 word_index = word_begin; word_index < word_end; ++word_index, page_index = 0) { |
| 542 | const u64 word = state_words[word_index]; | 542 | const u64 off_word = type == Type::GPU ? untracked_words[word_index] : 0; |
| 543 | const u64 word = state_words[word_index] & ~off_word; | ||
| 543 | if (word == 0) { | 544 | if (word == 0) { |
| 544 | continue; | 545 | continue; |
| 545 | } | 546 | } |
| @@ -563,7 +564,7 @@ private: | |||
| 563 | [[nodiscard]] std::pair<u64, u64> ModifiedRegion(u64 offset, u64 size) const noexcept { | 564 | [[nodiscard]] std::pair<u64, u64> ModifiedRegion(u64 offset, u64 size) const noexcept { |
| 564 | static_assert(type != Type::Untracked); | 565 | static_assert(type != Type::Untracked); |
| 565 | 566 | ||
| 566 | [[maybe_unused]] const u64* const untracked_words = Array<Type::Untracked>(); | 567 | const u64* const untracked_words = Array<Type::Untracked>(); |
| 567 | const u64* const state_words = Array<type>(); | 568 | const u64* const state_words = Array<type>(); |
| 568 | const u64 num_query_words = size / BYTES_PER_WORD + 1; | 569 | const u64 num_query_words = size / BYTES_PER_WORD + 1; |
| 569 | const u64 word_begin = offset / BYTES_PER_WORD; | 570 | const u64 word_begin = offset / BYTES_PER_WORD; |
| @@ -573,7 +574,8 @@ private: | |||
| 573 | u64 begin = std::numeric_limits<u64>::max(); | 574 | u64 begin = std::numeric_limits<u64>::max(); |
| 574 | u64 end = 0; | 575 | u64 end = 0; |
| 575 | for (u64 word_index = word_begin; word_index < word_end; ++word_index) { | 576 | for (u64 word_index = word_begin; word_index < word_end; ++word_index) { |
| 576 | const u64 word = state_words[word_index]; | 577 | const u64 off_word = type == Type::GPU ? untracked_words[word_index] : 0; |
| 578 | const u64 word = state_words[word_index] & ~off_word; | ||
| 577 | if (word == 0) { | 579 | if (word == 0) { |
| 578 | continue; | 580 | continue; |
| 579 | } | 581 | } |