Texture Cache: Secure insertions against deletions.

This commit is contained in:
Fernando Sahmkow 2021-11-27 23:49:56 +01:00
parent ecefc932e6
commit 5a3463bc2b

View File

@ -1137,8 +1137,11 @@ typename TextureCache<P>::BlitImages TextureCache<P>::GetBlitImages(
} while (has_deleted_images); } while (has_deleted_images);
if (GetFormatType(dst_info.format) != SurfaceType::ColorTexture) { if (GetFormatType(dst_info.format) != SurfaceType::ColorTexture) {
// Make sure the images are depth and/or stencil textures. // Make sure the images are depth and/or stencil textures.
src_id = FindOrInsertImage(src_info, src_addr, RelaxedOptions{}); do {
dst_id = FindOrInsertImage(dst_info, dst_addr, RelaxedOptions{}); has_deleted_images = false;
src_id = FindOrInsertImage(src_info, src_addr, RelaxedOptions{});
dst_id = FindOrInsertImage(dst_info, dst_addr, RelaxedOptions{});
} while (has_deleted_images);
} }
return BlitImages{ return BlitImages{
.dst_id = dst_id, .dst_id = dst_id,
@ -1196,7 +1199,14 @@ template <class P>
ImageViewId TextureCache<P>::FindRenderTargetView(const ImageInfo& info, GPUVAddr gpu_addr, ImageViewId TextureCache<P>::FindRenderTargetView(const ImageInfo& info, GPUVAddr gpu_addr,
bool is_clear) { bool is_clear) {
const auto options = is_clear ? RelaxedOptions::Samples : RelaxedOptions{}; const auto options = is_clear ? RelaxedOptions::Samples : RelaxedOptions{};
const ImageId image_id = FindOrInsertImage(info, gpu_addr, options); ImageId image_id{};
bool delete_state = has_deleted_images;
do {
has_deleted_images = false;
image_id = FindOrInsertImage(info, gpu_addr, options);
delete_state |= has_deleted_images;
} while (has_deleted_images);
has_deleted_images = delete_state;
if (!image_id) { if (!image_id) {
return NULL_IMAGE_VIEW_ID; return NULL_IMAGE_VIEW_ID;
} }