Skip to content

Commit 34bc350

Browse files
committed
Fixed userfaultfd path, removed dead code, simplified calculations
1 parent ea8d09b commit 34bc350

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

src/video_core/page_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct PageManager::Impl {
114114
// Notify rasterizer about the fault.
115115
const VAddr addr = msg.arg.pagefault.address;
116116
const VAddr addr_page = Common::AlignDown(addr, PAGESIZE);
117-
rasterizer->InvalidateMemory(addr_page, PAGESIZE);
117+
rasterizer->InvalidateMemory(addr, addr_page, PAGESIZE);
118118
}
119119
}
120120

src/video_core/texture_cache/texture_cache.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,8 @@ TextureCache::~TextureCache() = default;
4646
void TextureCache::InvalidateMemory(VAddr addr, VAddr addr_aligned, size_t size) {
4747
std::scoped_lock lock{mutex};
4848
ForEachImageInRegion(addr_aligned, size, [&](ImageId image_id, Image& image) {
49-
const auto addr_begin = addr;
50-
const auto addr_end = addr + size;
51-
const auto image_begin = image.info.guest_address;
5249
const auto image_end = image.info.guest_address + image.info.guest_size_bytes;
53-
if (addr_begin < image_end && image_begin < addr_end) {
50+
if (addr < image_end) {
5451
// Ensure image is reuploaded when accessed again.
5552
image.flags |= ImageFlagBits::CpuDirty;
5653
}
@@ -396,24 +393,11 @@ void TextureCache::RefreshImage(Image& image, Vulkan::Scheduler* custom_schedule
396393
const u32 height = std::max(image.info.size.height >> m, 1u);
397394
const u32 depth =
398395
image.info.props.is_volume ? std::max(image.info.size.depth >> m, 1u) : 1u;
399-
const auto& [mip_size, mip_pitch, mip_height, mip_ofs] = image.info.mips_layout[m];
400-
401-
// Protect GPU modified resources from accidental CPU reuploads.
402-
const bool is_gpu_modified = True(image.flags & ImageFlagBits::GpuModified);
403-
const bool is_gpu_dirty = True(image.flags & ImageFlagBits::GpuDirty);
404-
if (is_gpu_modified && !is_gpu_dirty) {
405-
const u8* addr = std::bit_cast<u8*>(image.info.guest_address);
406-
const u64 hash = XXH3_64bits(addr + mip_ofs, mip_size);
407-
if (image.mip_hashes[m] == hash) {
408-
continue;
409-
}
410-
image.mip_hashes[m] = hash;
411-
}
412-
396+
const auto& mip = image.info.mips_layout[m];
413397
image_copy.push_back({
414-
.bufferOffset = mip_ofs * num_layers,
415-
.bufferRowLength = static_cast<u32>(mip_pitch),
416-
.bufferImageHeight = static_cast<u32>(mip_height),
398+
.bufferOffset = mip.offset * num_layers,
399+
.bufferRowLength = static_cast<u32>(mip.pitch),
400+
.bufferImageHeight = static_cast<u32>(mip.height),
417401
.imageSubresource{
418402
.aspectMask = image.aspect_mask & ~vk::ImageAspectFlagBits::eStencil,
419403
.mipLevel = m,

0 commit comments

Comments
 (0)