mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-21 11:26:56 +02:00
graphics: bind unbound textures as native null descriptors
This commit is contained in:
+17
-52
@@ -199,9 +199,7 @@ TextureCache::BindingType TextureCache::UploadBinding(const Image& image) {
|
||||
|
||||
ImageId TextureCache::InsertImage(const ImageInfo& info) {
|
||||
const auto id = m_slot_images.insert(m_graphics, m_scheduler, info);
|
||||
if (!info.data.Empty()) {
|
||||
RegisterImage(id);
|
||||
}
|
||||
RegisterImage(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -408,7 +406,7 @@ void TextureCache::UntrackImageTail(ImageId id) {
|
||||
}
|
||||
|
||||
void TextureCache::TrackImageDownload(ImageId id, Image& image) {
|
||||
if (m_readback_linear_images && !image.info.IsTiled() && !image.info.data.Empty()) {
|
||||
if (m_readback_linear_images && !image.info.IsTiled()) {
|
||||
if (!image.IsGpuModified()) {
|
||||
EXIT("TextureCache: cannot enroll a non-GPU-owned image for download\n");
|
||||
}
|
||||
@@ -452,27 +450,6 @@ TextureCache::ImageIds TextureCache::FindImagesInRegion(uint64_t address, uint64
|
||||
return result;
|
||||
}
|
||||
|
||||
ImageId TextureCache::GetNullImage(const ImageDesc& desc) {
|
||||
const auto format = desc.info.pixel_format;
|
||||
if (const auto found = m_null_images.find(format); found != m_null_images.end()) {
|
||||
return found->second;
|
||||
}
|
||||
ImageInfo info {};
|
||||
info.pixel_format = desc.info.pixel_format;
|
||||
info.guest_format = desc.info.guest_format;
|
||||
info.type = Prospero::ImageType::kColor2D;
|
||||
info.extent = {1, 1, 1};
|
||||
info.resources = {1, 1};
|
||||
info.pitch = 1;
|
||||
info.bytes_per_block = std::max(desc.info.bytes_per_block, 1u);
|
||||
info.samples = 1;
|
||||
info.tile_mode = Prospero::TileMode::kLinear;
|
||||
info.mip_layout[0] = {0, info.bytes_per_block, 1, 1};
|
||||
const auto id = InsertImage(info);
|
||||
m_null_images.emplace(format, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void TextureCache::ValidateImageDesc(const ImageDesc& desc) const {
|
||||
ImageOps::Validate(desc.info);
|
||||
if (desc.view_info.format == vk::Format::eUndefined || desc.view_info.level_count == 0 ||
|
||||
@@ -1026,9 +1003,6 @@ void TextureCache::UploadImage(Image& image, Buffer& source, uint64_t source_off
|
||||
|
||||
void TextureCache::InitializeImage(ImageId id) {
|
||||
auto& image = m_slot_images[id];
|
||||
if (image.info.data.Empty()) {
|
||||
return;
|
||||
}
|
||||
TrackImage(id);
|
||||
if (image.info.metadata.compression != VideoOutCompression::Uncompressed) {
|
||||
if (image.IsCpuDirty()) {
|
||||
@@ -1215,10 +1189,7 @@ ImageId TextureCache::FindImage(ImageDesc& desc, bool exact_format) {
|
||||
EXIT("TextureCache: image lookup requires a valid command buffer\n");
|
||||
}
|
||||
ValidateImageDesc(desc);
|
||||
if (desc.info.data.Empty()) {
|
||||
std::scoped_lock lock {m_lock};
|
||||
return GetNullImage(desc);
|
||||
}
|
||||
EXIT_IF(desc.info.data.Empty());
|
||||
const auto metadata_base_layer = desc.view_info.base_layer;
|
||||
|
||||
ImageId result {};
|
||||
@@ -1370,36 +1341,30 @@ vk::ImageView TextureCache::FindTexture(ImageId id, const ImageDesc& desc) {
|
||||
std::scoped_lock lock {m_lock};
|
||||
auto& image = m_slot_images[id];
|
||||
TouchImage(image);
|
||||
if (!image.info.data.Empty()) {
|
||||
if (!image.registered || image.depth_id || image.binding.needs_rebind) {
|
||||
EXIT("TextureCache: texture requires rediscovery before final acquisition\n");
|
||||
}
|
||||
if (!image.registered || image.depth_id || image.binding.needs_rebind) {
|
||||
EXIT("TextureCache: texture requires rediscovery before final acquisition\n");
|
||||
}
|
||||
if (desc.type == BindingType::Storage) {
|
||||
image.MarkGpuModified();
|
||||
}
|
||||
if (!image.info.data.Empty()) {
|
||||
RefreshImage(id);
|
||||
if (image.info.HasStencil() &&
|
||||
desc.info.data.address >= image.info.stencil.address &&
|
||||
desc.info.data.End() <= image.info.stencil.End()) {
|
||||
for (const auto stencil_id:
|
||||
FindImagesInRegion(image.info.stencil.address, image.info.stencil.size, false)) {
|
||||
const auto* stencil = m_slot_images.try_get(stencil_id);
|
||||
if (stencil != nullptr && stencil->depth_id == id &&
|
||||
stencil->info.data == image.info.stencil) {
|
||||
RefreshImage(stencil_id);
|
||||
break;
|
||||
}
|
||||
RefreshImage(id);
|
||||
if (image.info.HasStencil() &&
|
||||
desc.info.data.address >= image.info.stencil.address &&
|
||||
desc.info.data.End() <= image.info.stencil.End()) {
|
||||
for (const auto stencil_id:
|
||||
FindImagesInRegion(image.info.stencil.address, image.info.stencil.size, false)) {
|
||||
const auto* stencil = m_slot_images.try_get(stencil_id);
|
||||
if (stencil != nullptr && stencil->depth_id == id &&
|
||||
stencil->info.data == image.info.stencil) {
|
||||
RefreshImage(stencil_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (desc.type) {
|
||||
case BindingType::Texture: break;
|
||||
case BindingType::Storage:
|
||||
if (!image.info.data.Empty()) {
|
||||
CommitGpuWrite(image);
|
||||
}
|
||||
CommitGpuWrite(image);
|
||||
TrackImageDownload(id, image);
|
||||
break;
|
||||
default: EXIT("TextureCache: invalid texture binding\n");
|
||||
|
||||
Reference in New Issue
Block a user