Merge pull request #10990 from comex/ubsan
Fixes and workarounds to make UBSan happier on macOS
This commit is contained in:
commit
d3da1e6517
11 changed files with 42 additions and 32 deletions
|
@ -103,7 +103,9 @@ public:
|
|||
explicit QueryCacheBase(VideoCore::RasterizerInterface& rasterizer_,
|
||||
Core::Memory::Memory& cpu_memory_)
|
||||
: rasterizer{rasterizer_},
|
||||
cpu_memory{cpu_memory_}, streams{{CounterStream{static_cast<QueryCache&>(*this),
|
||||
// Use reinterpret_cast instead of static_cast as workaround for
|
||||
// UBSan bug (https://github.com/llvm/llvm-project/issues/59060)
|
||||
cpu_memory{cpu_memory_}, streams{{CounterStream{reinterpret_cast<QueryCache&>(*this),
|
||||
VideoCore::QueryType::SamplesPassed}}} {
|
||||
(void)slot_async_jobs.insert(); // Null value
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ namespace VideoCore {
|
|||
|
||||
using namespace Core::Memory;
|
||||
|
||||
RasterizerAccelerated::RasterizerAccelerated(Memory& cpu_memory_) : cpu_memory{cpu_memory_} {}
|
||||
RasterizerAccelerated::RasterizerAccelerated(Memory& cpu_memory_)
|
||||
: cached_pages(std::make_unique<CachedPages>()), cpu_memory{cpu_memory_} {}
|
||||
|
||||
RasterizerAccelerated::~RasterizerAccelerated() = default;
|
||||
|
||||
|
@ -26,7 +27,7 @@ void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int del
|
|||
std::atomic_thread_fence(std::memory_order_acquire);
|
||||
const u64 page_end = Common::DivCeil(addr + size, YUZU_PAGESIZE);
|
||||
for (u64 page = addr >> YUZU_PAGEBITS; page != page_end; ++page) {
|
||||
std::atomic_uint16_t& count = cached_pages.at(page >> 2).Count(page);
|
||||
std::atomic_uint16_t& count = cached_pages->at(page >> 2).Count(page);
|
||||
|
||||
if (delta > 0) {
|
||||
ASSERT_MSG(count.load(std::memory_order::relaxed) < UINT16_MAX, "Count may overflow!");
|
||||
|
|
|
@ -41,7 +41,8 @@ private:
|
|||
};
|
||||
static_assert(sizeof(CacheEntry) == 8, "CacheEntry should be 8 bytes!");
|
||||
|
||||
std::array<CacheEntry, 0x2000000> cached_pages;
|
||||
using CachedPages = std::array<CacheEntry, 0x2000000>;
|
||||
std::unique_ptr<CachedPages> cached_pages;
|
||||
Core::Memory::Memory& cpu_memory;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue