Browse Source

[gl, vk, texture cache] Attempt to get correct MSAA image upload and download

test-revert-gpu-optim
CamilleLaVey 1 month ago
committed by lizzie
parent
commit
d3595fd2b1
  1. 4
      src/video_core/renderer_opengl/gl_texture_cache.h
  2. 4
      src/video_core/renderer_vulkan/vk_texture_cache.h
  3. 4
      src/video_core/texture_cache/image_base.cpp
  4. 50
      src/video_core/texture_cache/texture_cache.h
  5. 2
      src/video_core/texture_cache/texture_cache_base.h

4
src/video_core/renderer_opengl/gl_texture_cache.h

@ -97,6 +97,10 @@ public:
return true;
}
bool CanDownloadMSAA() const noexcept {
return true;
}
void CopyImage(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies);
void CopyImageMSAA(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies);

4
src/video_core/renderer_vulkan/vk_texture_cache.h

@ -85,6 +85,10 @@ public:
return msaa_copy_pass.operator bool();
}
bool CanDownloadMSAA() const noexcept {
return msaa_copy_pass.operator bool();
}
void AccelerateImageUpload(Image&, const StagingBufferRef&,
std::span<const VideoCommon::SwizzleParameters>);

4
src/video_core/texture_cache/image_base.cpp

@ -131,10 +131,6 @@ bool ImageBase::IsSafeDownload() const noexcept {
if (True(flags & ImageFlagBits::CpuModified)) {
return false;
}
if (info.num_samples > 1) {
LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
return false;
}
return true;
}

50
src/video_core/texture_cache/texture_cache.h

@ -101,8 +101,12 @@ void TextureCache<P>::RunGarbageCollector() {
if (!aggressive_mode && True(image.flags & ImageFlagBits::CostlyLoad)) {
return false;
}
const bool must_download =
image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap);
const bool supports_msaa_download = HasMsaaDownloadSupport(image.info);
if (!supports_msaa_download && image.info.num_samples > 1) {
LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
}
const bool must_download = supports_msaa_download && image.IsSafeDownload() &&
False(image.flags & ImageFlagBits::BadOverlap);
if (!high_priority_mode && must_download) {
return false;
}
@ -548,10 +552,14 @@ void TextureCache<P>::WriteMemory(DAddr cpu_addr, size_t size) {
template <class P>
void TextureCache<P>::DownloadMemory(DAddr cpu_addr, size_t size) {
boost::container::small_vector<ImageId, 16> images;
ForEachImageInRegion(cpu_addr, size, [&images](ImageId image_id, ImageBase& image) {
ForEachImageInRegion(cpu_addr, size, [this, &images](ImageId image_id, ImageBase& image) {
if (!image.IsSafeDownload()) {
return;
}
if (!HasMsaaDownloadSupport(image.info)) {
LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
return;
}
image.flags &= ~ImageFlagBits::GpuModified;
images.push_back(image_id);
});
@ -930,6 +938,17 @@ ImageId TextureCache<P>::DmaImageId(const Tegra::DMA::ImageOperand& operand, boo
return NULL_IMAGE_ID;
}
auto& image = slot_images[dst_id];
if (image.info.num_samples > 1) {
if (is_upload) {
if (!HasMsaaUploadSupport(image.info)) {
return NULL_IMAGE_ID;
}
} else {
if (!HasMsaaDownloadSupport(image.info)) {
return NULL_IMAGE_ID;
}
}
}
if (False(image.flags & ImageFlagBits::GpuModified)) {
// No need to waste time on an image that's synced with guest
return NULL_IMAGE_ID;
@ -1056,7 +1075,7 @@ void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) {
image.flags &= ~ImageFlagBits::CpuModified;
TrackImage(image, image_id);
if (image.info.num_samples > 1 && !runtime.CanUploadMSAA()) {
if (!HasMsaaUploadSupport(image.info)) {
LOG_WARNING(HW_GPU, "MSAA image uploads are not implemented");
runtime.TransitionImageLayout(image);
return;
@ -1274,6 +1293,16 @@ u64 TextureCache<P>::GetScaledImageSizeBytes(const ImageBase& image) {
return fitted_size;
}
template <class P>
bool TextureCache<P>::HasMsaaUploadSupport(const ImageInfo& info) const noexcept {
return info.num_samples <= 1 || runtime.CanUploadMSAA();
}
template <class P>
bool TextureCache<P>::HasMsaaDownloadSupport(const ImageInfo& info) const noexcept {
return info.num_samples <= 1 || runtime.CanDownloadMSAA();
}
template <class P>
void TextureCache<P>::QueueAsyncDecode(Image& image, ImageId image_id) {
UNIMPLEMENTED_IF(False(image.flags & ImageFlagBits::Converted));
@ -1575,6 +1604,10 @@ ImageId TextureCache<P>::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, DA
for (const auto& copy_object : join_copies_to_do) {
Image& overlap = slot_images[copy_object.id];
if (copy_object.is_alias) {
if (!HasMsaaDownloadSupport(overlap.info)) {
LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
continue;
}
if (!overlap.IsSafeDownload()) {
continue;
}
@ -2491,8 +2524,13 @@ void TextureCache<P>::BindRenderTarget(ImageViewId* old_id, ImageViewId new_id)
if (new_id) {
const ImageViewBase& old_view = slot_image_views[new_id];
if (True(old_view.flags & ImageViewFlagBits::PreemtiveDownload)) {
const PendingDownload new_download{true, 0, old_view.image_id};
uncommitted_downloads.emplace_back(new_download);
const ImageBase& image = slot_images[old_view.image_id];
if (!HasMsaaDownloadSupport(image.info)) {
LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
} else {
const PendingDownload new_download{true, 0, old_view.image_id};
uncommitted_downloads.emplace_back(new_download);
}
}
}
*old_id = new_id;

2
src/video_core/texture_cache/texture_cache_base.h

@ -426,6 +426,8 @@ private:
bool ScaleUp(Image& image);
bool ScaleDown(Image& image);
u64 GetScaledImageSizeBytes(const ImageBase& image);
[[nodiscard]] bool HasMsaaUploadSupport(const ImageInfo& info) const noexcept;
[[nodiscard]] bool HasMsaaDownloadSupport(const ImageInfo& info) const noexcept;
void QueueAsyncDecode(Image& image, ImageId image_id);
void TickAsyncDecode();

Loading…
Cancel
Save