mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-13 06:38:34 +02:00
[gl, vk, texture cache] Attempt to get correct MSAA image upload and download
This commit is contained in:
parent
ee64c945fb
commit
cd2c4d8caf
5 changed files with 54 additions and 10 deletions
|
|
@ -97,6 +97,10 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CanDownloadMSAA() const noexcept {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CopyImage(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies);
|
void CopyImage(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies);
|
||||||
|
|
||||||
void CopyImageMSAA(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies);
|
void CopyImageMSAA(Image& dst, Image& src, std::span<const VideoCommon::ImageCopy> copies);
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,10 @@ public:
|
||||||
return msaa_copy_pass.operator bool();
|
return msaa_copy_pass.operator bool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CanDownloadMSAA() const noexcept {
|
||||||
|
return msaa_copy_pass.operator bool();
|
||||||
|
}
|
||||||
|
|
||||||
void AccelerateImageUpload(Image&, const StagingBufferRef&,
|
void AccelerateImageUpload(Image&, const StagingBufferRef&,
|
||||||
std::span<const VideoCommon::SwizzleParameters>);
|
std::span<const VideoCommon::SwizzleParameters>);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,10 +131,6 @@ bool ImageBase::IsSafeDownload() const noexcept {
|
||||||
if (True(flags & ImageFlagBits::CpuModified)) {
|
if (True(flags & ImageFlagBits::CpuModified)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (info.num_samples > 1) {
|
|
||||||
LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,12 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||||
if (!aggressive_mode && True(image.flags & ImageFlagBits::CostlyLoad)) {
|
if (!aggressive_mode && True(image.flags & ImageFlagBits::CostlyLoad)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const bool must_download =
|
const bool supports_msaa_download = HasMsaaDownloadSupport(image.info);
|
||||||
image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap);
|
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) {
|
if (!high_priority_mode && must_download) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -548,10 +552,14 @@ void TextureCache<P>::WriteMemory(DAddr cpu_addr, size_t size) {
|
||||||
template <class P>
|
template <class P>
|
||||||
void TextureCache<P>::DownloadMemory(DAddr cpu_addr, size_t size) {
|
void TextureCache<P>::DownloadMemory(DAddr cpu_addr, size_t size) {
|
||||||
boost::container::small_vector<ImageId, 16> images;
|
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()) {
|
if (!image.IsSafeDownload()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!HasMsaaDownloadSupport(image.info)) {
|
||||||
|
LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
|
||||||
|
return;
|
||||||
|
}
|
||||||
image.flags &= ~ImageFlagBits::GpuModified;
|
image.flags &= ~ImageFlagBits::GpuModified;
|
||||||
images.push_back(image_id);
|
images.push_back(image_id);
|
||||||
});
|
});
|
||||||
|
|
@ -930,6 +938,17 @@ ImageId TextureCache<P>::DmaImageId(const Tegra::DMA::ImageOperand& operand, boo
|
||||||
return NULL_IMAGE_ID;
|
return NULL_IMAGE_ID;
|
||||||
}
|
}
|
||||||
auto& image = slot_images[dst_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)) {
|
if (False(image.flags & ImageFlagBits::GpuModified)) {
|
||||||
// No need to waste time on an image that's synced with guest
|
// No need to waste time on an image that's synced with guest
|
||||||
return NULL_IMAGE_ID;
|
return NULL_IMAGE_ID;
|
||||||
|
|
@ -1056,7 +1075,7 @@ void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) {
|
||||||
image.flags &= ~ImageFlagBits::CpuModified;
|
image.flags &= ~ImageFlagBits::CpuModified;
|
||||||
TrackImage(image, image_id);
|
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");
|
LOG_WARNING(HW_GPU, "MSAA image uploads are not implemented");
|
||||||
runtime.TransitionImageLayout(image);
|
runtime.TransitionImageLayout(image);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1274,6 +1293,16 @@ u64 TextureCache<P>::GetScaledImageSizeBytes(const ImageBase& image) {
|
||||||
return fitted_size;
|
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>
|
template <class P>
|
||||||
void TextureCache<P>::QueueAsyncDecode(Image& image, ImageId image_id) {
|
void TextureCache<P>::QueueAsyncDecode(Image& image, ImageId image_id) {
|
||||||
UNIMPLEMENTED_IF(False(image.flags & ImageFlagBits::Converted));
|
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) {
|
for (const auto& copy_object : join_copies_to_do) {
|
||||||
Image& overlap = slot_images[copy_object.id];
|
Image& overlap = slot_images[copy_object.id];
|
||||||
if (copy_object.is_alias) {
|
if (copy_object.is_alias) {
|
||||||
|
if (!HasMsaaDownloadSupport(overlap.info)) {
|
||||||
|
LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!overlap.IsSafeDownload()) {
|
if (!overlap.IsSafeDownload()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -2491,8 +2524,13 @@ void TextureCache<P>::BindRenderTarget(ImageViewId* old_id, ImageViewId new_id)
|
||||||
if (new_id) {
|
if (new_id) {
|
||||||
const ImageViewBase& old_view = slot_image_views[new_id];
|
const ImageViewBase& old_view = slot_image_views[new_id];
|
||||||
if (True(old_view.flags & ImageViewFlagBits::PreemtiveDownload)) {
|
if (True(old_view.flags & ImageViewFlagBits::PreemtiveDownload)) {
|
||||||
const PendingDownload new_download{true, 0, old_view.image_id};
|
const ImageBase& image = slot_images[old_view.image_id];
|
||||||
uncommitted_downloads.emplace_back(new_download);
|
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;
|
*old_id = new_id;
|
||||||
|
|
|
||||||
|
|
@ -426,6 +426,8 @@ private:
|
||||||
bool ScaleUp(Image& image);
|
bool ScaleUp(Image& image);
|
||||||
bool ScaleDown(Image& image);
|
bool ScaleDown(Image& image);
|
||||||
u64 GetScaledImageSizeBytes(const ImageBase& 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 QueueAsyncDecode(Image& image, ImageId image_id);
|
||||||
void TickAsyncDecode();
|
void TickAsyncDecode();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue