mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-14 08:12:16 +00:00
vulkan: Add alternatives when nullDescriptor is not supported. (#1001)
* vulkan: Add alternatives when nullDescriptor is not supported. * vulkan: Set identifying name on null image/image view/buffer
This commit is contained in:
parent
eaa92b5a65
commit
4fe81231f6
8 changed files with 46 additions and 6 deletions
|
@ -31,7 +31,11 @@ BufferCache::BufferCache(const Vulkan::Instance& instance_, Vulkan::Scheduler& s
|
||||||
Vulkan::SetObjectName(instance.GetDevice(), gds_buffer.Handle(), "GDS Buffer");
|
Vulkan::SetObjectName(instance.GetDevice(), gds_buffer.Handle(), "GDS Buffer");
|
||||||
|
|
||||||
// Ensure the first slot is used for the null buffer
|
// Ensure the first slot is used for the null buffer
|
||||||
void(slot_buffers.insert(instance, scheduler, MemoryUsage::DeviceLocal, 0, ReadFlags, 1));
|
const auto null_id =
|
||||||
|
slot_buffers.insert(instance, scheduler, MemoryUsage::DeviceLocal, 0, ReadFlags, 1);
|
||||||
|
ASSERT(null_id.index == 0);
|
||||||
|
const vk::Buffer& null_buffer = slot_buffers[null_id].buffer;
|
||||||
|
Vulkan::SetObjectName(instance.GetDevice(), null_buffer, "Null Buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCache::~BufferCache() = default;
|
BufferCache::~BufferCache() = default;
|
||||||
|
|
|
@ -62,6 +62,11 @@ public:
|
||||||
return &gds_buffer;
|
return &gds_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves the buffer with the specified id.
|
||||||
|
[[nodiscard]] Buffer& GetBuffer(BufferId id) {
|
||||||
|
return slot_buffers[id];
|
||||||
|
}
|
||||||
|
|
||||||
/// Invalidates any buffer in the logical page range.
|
/// Invalidates any buffer in the logical page range.
|
||||||
void InvalidateMemory(VAddr device_addr, u64 size);
|
void InvalidateMemory(VAddr device_addr, u64 size);
|
||||||
|
|
||||||
|
|
|
@ -221,8 +221,12 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache,
|
||||||
const auto& image_view = texture_cache.FindTexture(image_info, view_info);
|
const auto& image_view = texture_cache.FindTexture(image_info, view_info);
|
||||||
const auto& image = texture_cache.GetImage(image_view.image_id);
|
const auto& image = texture_cache.GetImage(image_view.image_id);
|
||||||
image_infos.emplace_back(VK_NULL_HANDLE, *image_view.image_view, image.layout);
|
image_infos.emplace_back(VK_NULL_HANDLE, *image_view.image_view, image.layout);
|
||||||
} else {
|
} else if (instance.IsNullDescriptorSupported()) {
|
||||||
image_infos.emplace_back(VK_NULL_HANDLE, VK_NULL_HANDLE, vk::ImageLayout::eGeneral);
|
image_infos.emplace_back(VK_NULL_HANDLE, VK_NULL_HANDLE, vk::ImageLayout::eGeneral);
|
||||||
|
} else {
|
||||||
|
auto& null_image = texture_cache.GetImageView(VideoCore::NULL_IMAGE_VIEW_ID);
|
||||||
|
image_infos.emplace_back(VK_NULL_HANDLE, *null_image.image_view,
|
||||||
|
vk::ImageLayout::eGeneral);
|
||||||
}
|
}
|
||||||
set_writes.push_back({
|
set_writes.push_back({
|
||||||
.dstSet = VK_NULL_HANDLE,
|
.dstSet = VK_NULL_HANDLE,
|
||||||
|
|
|
@ -386,8 +386,11 @@ void GraphicsPipeline::BindResources(const Liverpool::Regs& regs,
|
||||||
push_data.AddOffset(binding, adjust);
|
push_data.AddOffset(binding, adjust);
|
||||||
}
|
}
|
||||||
buffer_infos.emplace_back(vk_buffer->Handle(), offset_aligned, size + adjust);
|
buffer_infos.emplace_back(vk_buffer->Handle(), offset_aligned, size + adjust);
|
||||||
} else {
|
} else if (instance.IsNullDescriptorSupported()) {
|
||||||
buffer_infos.emplace_back(VK_NULL_HANDLE, 0, VK_WHOLE_SIZE);
|
buffer_infos.emplace_back(VK_NULL_HANDLE, 0, VK_WHOLE_SIZE);
|
||||||
|
} else {
|
||||||
|
auto& null_buffer = buffer_cache.GetBuffer(VideoCore::NULL_BUFFER_ID);
|
||||||
|
buffer_infos.emplace_back(null_buffer.Handle(), 0, VK_WHOLE_SIZE);
|
||||||
}
|
}
|
||||||
set_writes.push_back({
|
set_writes.push_back({
|
||||||
.dstSet = VK_NULL_HANDLE,
|
.dstSet = VK_NULL_HANDLE,
|
||||||
|
@ -451,8 +454,12 @@ void GraphicsPipeline::BindResources(const Liverpool::Regs& regs,
|
||||||
const auto& image_view = texture_cache.FindTexture(image_info, view_info);
|
const auto& image_view = texture_cache.FindTexture(image_info, view_info);
|
||||||
const auto& image = texture_cache.GetImage(image_view.image_id);
|
const auto& image = texture_cache.GetImage(image_view.image_id);
|
||||||
image_infos.emplace_back(VK_NULL_HANDLE, *image_view.image_view, image.layout);
|
image_infos.emplace_back(VK_NULL_HANDLE, *image_view.image_view, image.layout);
|
||||||
} else {
|
} else if (instance.IsNullDescriptorSupported()) {
|
||||||
image_infos.emplace_back(VK_NULL_HANDLE, VK_NULL_HANDLE, vk::ImageLayout::eGeneral);
|
image_infos.emplace_back(VK_NULL_HANDLE, VK_NULL_HANDLE, vk::ImageLayout::eGeneral);
|
||||||
|
} else {
|
||||||
|
auto& null_image = texture_cache.GetImageView(VideoCore::NULL_IMAGE_VIEW_ID);
|
||||||
|
image_infos.emplace_back(VK_NULL_HANDLE, *null_image.image_view,
|
||||||
|
vk::ImageLayout::eGeneral);
|
||||||
}
|
}
|
||||||
set_writes.push_back({
|
set_writes.push_back({
|
||||||
.dstSet = VK_NULL_HANDLE,
|
.dstSet = VK_NULL_HANDLE,
|
||||||
|
|
|
@ -381,9 +381,12 @@ bool Instance::CreateDevice() {
|
||||||
device_chain.unlink<vk::PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT>();
|
device_chain.unlink<vk::PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT>();
|
||||||
}
|
}
|
||||||
if (robustness) {
|
if (robustness) {
|
||||||
device_chain.get<vk::PhysicalDeviceRobustness2FeaturesEXT>().nullDescriptor =
|
null_descriptor =
|
||||||
feature_chain.get<vk::PhysicalDeviceRobustness2FeaturesEXT>().nullDescriptor;
|
feature_chain.get<vk::PhysicalDeviceRobustness2FeaturesEXT>().nullDescriptor;
|
||||||
|
device_chain.get<vk::PhysicalDeviceRobustness2FeaturesEXT>().nullDescriptor =
|
||||||
|
null_descriptor;
|
||||||
} else {
|
} else {
|
||||||
|
null_descriptor = false;
|
||||||
device_chain.unlink<vk::PhysicalDeviceRobustness2FeaturesEXT>();
|
device_chain.unlink<vk::PhysicalDeviceRobustness2FeaturesEXT>();
|
||||||
}
|
}
|
||||||
if (!vertex_input_dynamic_state) {
|
if (!vertex_input_dynamic_state) {
|
||||||
|
|
|
@ -132,6 +132,11 @@ public:
|
||||||
return vertex_input_dynamic_state;
|
return vertex_input_dynamic_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true when the nullDescriptor feature of VK_EXT_robustness2 is supported.
|
||||||
|
bool IsNullDescriptorSupported() const {
|
||||||
|
return null_descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the vendor ID of the physical device
|
/// Returns the vendor ID of the physical device
|
||||||
u32 GetVendorID() const {
|
u32 GetVendorID() const {
|
||||||
return properties.vendorID;
|
return properties.vendorID;
|
||||||
|
@ -279,6 +284,7 @@ private:
|
||||||
bool workgroup_memory_explicit_layout{};
|
bool workgroup_memory_explicit_layout{};
|
||||||
bool color_write_en{};
|
bool color_write_en{};
|
||||||
bool vertex_input_dynamic_state{};
|
bool vertex_input_dynamic_state{};
|
||||||
|
bool null_descriptor{};
|
||||||
u64 min_imported_host_pointer_alignment{};
|
u64 min_imported_host_pointer_alignment{};
|
||||||
u32 subgroup_size{};
|
u32 subgroup_size{};
|
||||||
bool tooling_info{};
|
bool tooling_info{};
|
||||||
|
|
|
@ -29,10 +29,16 @@ TextureCache::TextureCache(const Vulkan::Instance& instance_, Vulkan::Scheduler&
|
||||||
info.UpdateSize();
|
info.UpdateSize();
|
||||||
const ImageId null_id = slot_images.insert(instance, scheduler, info);
|
const ImageId null_id = slot_images.insert(instance, scheduler, info);
|
||||||
ASSERT(null_id.index == 0);
|
ASSERT(null_id.index == 0);
|
||||||
|
const vk::Image& null_image = slot_images[null_id].image;
|
||||||
|
Vulkan::SetObjectName(instance.GetDevice(), null_image, "Null Image");
|
||||||
slot_images[null_id].flags = ImageFlagBits::Tracked;
|
slot_images[null_id].flags = ImageFlagBits::Tracked;
|
||||||
|
|
||||||
ImageViewInfo view_info;
|
ImageViewInfo view_info;
|
||||||
void(slot_image_views.insert(instance, view_info, slot_images[null_id], null_id));
|
const auto null_view_id =
|
||||||
|
slot_image_views.insert(instance, view_info, slot_images[null_id], null_id);
|
||||||
|
ASSERT(null_view_id.index == 0);
|
||||||
|
const vk::ImageView& null_image_view = slot_image_views[null_view_id].image_view.get();
|
||||||
|
Vulkan::SetObjectName(instance.GetDevice(), null_image_view, "Null Image View");
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache::~TextureCache() = default;
|
TextureCache::~TextureCache() = default;
|
||||||
|
|
|
@ -98,6 +98,11 @@ public:
|
||||||
return slot_images[id];
|
return slot_images[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves the image view with the specified id.
|
||||||
|
[[nodiscard]] ImageView& GetImageView(ImageId id) {
|
||||||
|
return slot_image_views[id];
|
||||||
|
}
|
||||||
|
|
||||||
bool IsMeta(VAddr address) const {
|
bool IsMeta(VAddr address) const {
|
||||||
return surface_metas.contains(address);
|
return surface_metas.contains(address);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue