Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 13 additions & 59 deletions Common/GPU/Vulkan/VulkanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
}

instance_layer_names_.clear();
device_layer_names_.clear();

// We can get the list of layers and extensions without an instance so we can use this information
// to enable the extensions we need that are available.
GetInstanceLayerProperties();
GetInstanceLayerExtensionList(nullptr, instance_extension_properties_);
GetInstanceLayerExtensionList(nullptr, &instance_extension_properties_);

if (!IsInstanceExtensionAvailable(VK_KHR_SURFACE_EXTENSION_NAME)) {
// Cannot create a Vulkan display without VK_KHR_SURFACE_EXTENSION.
Expand Down Expand Up @@ -176,7 +175,6 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
// Enable the validation layers
for (size_t i = 0; i < ARRAY_SIZE(validationLayers); i++) {
instance_layer_names_.push_back(validationLayers[i]);
device_layer_names_.push_back(validationLayers[i]);
}
instance_extensions_enabled_.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
extensionsLookup_.EXT_debug_utils = true;
Expand Down Expand Up @@ -234,7 +232,6 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
WARN_LOG(Log::G3D, "Validation on but instance layer not available - dropping layers");
// Drop the validation layers and try again.
instance_layer_names_.clear();
device_layer_names_.clear();
inst_info.enabledLayerCount = 0;
inst_info.ppEnabledLayerNames = nullptr;
res = vkCreateInstance(&inst_info, nullptr, &instance_);
Expand Down Expand Up @@ -403,7 +400,7 @@ void VulkanContext::DestroySurface() {
}
}

VkResult VulkanContext::GetInstanceLayerExtensionList(const char *layerName, std::vector<VkExtensionProperties> &extensions) {
VkResult VulkanContext::GetInstanceLayerExtensionList(const char *layerName, std::vector<VkExtensionProperties> *extensions) {
VkResult res;
do {
uint32_t instance_extension_count;
Expand All @@ -412,8 +409,8 @@ VkResult VulkanContext::GetInstanceLayerExtensionList(const char *layerName, std
return res;
if (instance_extension_count == 0)
return VK_SUCCESS;
extensions.resize(instance_extension_count);
res = vkEnumerateInstanceExtensionProperties(layerName, &instance_extension_count, extensions.data());
extensions->resize(instance_extension_count);
res = vkEnumerateInstanceExtensionProperties(layerName, &instance_extension_count, extensions->data());
} while (res == VK_INCOMPLETE);
return res;
}
Expand Down Expand Up @@ -445,71 +442,33 @@ VkResult VulkanContext::GetInstanceLayerProperties() {
} while (res == VK_INCOMPLETE);

// Now gather the extension list for each instance layer.
// (TODO: Is this meaningful, or used for anything?)
for (uint32_t i = 0; i < instance_layer_count; i++) {
LayerProperties layer_props;
layer_props.properties = vk_props[i];
res = GetInstanceLayerExtensionList(layer_props.properties.layerName, layer_props.extensions);
res = GetInstanceLayerExtensionList(layer_props.properties.layerName, &layer_props.extensions);
if (res != VK_SUCCESS)
return res;
instance_layer_properties_.push_back(layer_props);
}
return res;
}

// Pass layerName == nullptr to get the extension list for the device.
VkResult VulkanContext::GetDeviceLayerExtensionList(const char *layerName, std::vector<VkExtensionProperties> &extensions) {
VkResult VulkanContext::GetDeviceExtensionList(std::vector<VkExtensionProperties> *extensions) {
VkResult res;
do {
uint32_t device_extension_count;
res = vkEnumerateDeviceExtensionProperties(physical_devices_[physical_device_], layerName, &device_extension_count, nullptr);
res = vkEnumerateDeviceExtensionProperties(physical_devices_[physical_device_], nullptr, &device_extension_count, nullptr);
if (res != VK_SUCCESS)
return res;
if (!device_extension_count)
return VK_SUCCESS;
extensions.resize(device_extension_count);
res = vkEnumerateDeviceExtensionProperties(physical_devices_[physical_device_], layerName, &device_extension_count, extensions.data());
extensions->resize(device_extension_count);
res = vkEnumerateDeviceExtensionProperties(physical_devices_[physical_device_], nullptr, &device_extension_count, extensions->data());
} while (res == VK_INCOMPLETE);
return res;
}

VkResult VulkanContext::GetDeviceLayerProperties() {
/*
* It's possible, though very rare, that the number of
* instance layers could change. For example, installing something
* could include new layers that the loader would pick up
* between the initial query for the count and the
* request for VkLayerProperties. The loader indicates that
* by returning a VK_INCOMPLETE status and will update the
* the count parameter.
* The count parameter will be updated with the number of
* entries loaded into the data pointer - in case the number
* of layers went down or is smaller than the size given.
*/
uint32_t device_layer_count;
std::vector<VkLayerProperties> vk_props;
VkResult res;
do {
res = vkEnumerateDeviceLayerProperties(physical_devices_[physical_device_], &device_layer_count, nullptr);
if (res != VK_SUCCESS)
return res;
if (device_layer_count == 0)
return VK_SUCCESS;
vk_props.resize(device_layer_count);
res = vkEnumerateDeviceLayerProperties(physical_devices_[physical_device_], &device_layer_count, vk_props.data());
} while (res == VK_INCOMPLETE);

// Gather the list of extensions for each device layer.
for (uint32_t i = 0; i < device_layer_count; i++) {
LayerProperties layer_props;
layer_props.properties = vk_props[i];
res = GetDeviceLayerExtensionList(layer_props.properties.layerName, layer_props.extensions);
if (res != VK_SUCCESS)
return res;
device_layer_properties_.push_back(layer_props);
}
return res;
}

// Returns true if all layer names specified in check_names can be found in given layer properties.
bool VulkanContext::CheckLayers(const std::vector<LayerProperties> &layer_props, const std::vector<const char *> &layer_names) const {
uint32_t check_count = (uint32_t)layer_names.size();
Expand Down Expand Up @@ -609,11 +568,6 @@ VkResult VulkanContext::CreateDevice(int physical_device) {

vulkanDeviceApiVersion_ = physicalDeviceProperties_[physical_device].properties.apiVersion;

GetDeviceLayerProperties();
if (!CheckLayers(device_layer_properties_, device_layer_names_)) {
WARN_LOG(Log::G3D, "CheckLayers for device %d failed", physical_device);
}

queue_count = 0;
vkGetPhysicalDeviceQueueFamilyProperties(physical_devices_[physical_device_], &queue_count, nullptr);
_dbg_assert_(queue_count >= 1);
Expand Down Expand Up @@ -662,7 +616,7 @@ VkResult VulkanContext::CreateDevice(int physical_device) {
(memory_properties_.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) ? "HOST_COHERENT " : "");
}

GetDeviceLayerExtensionList(nullptr, device_extension_properties_);
GetDeviceExtensionList(&device_extension_properties_);

device_extensions_enabled_.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);

Expand Down Expand Up @@ -824,8 +778,8 @@ VkResult VulkanContext::CreateDevice(int physical_device) {
VkDeviceCreateInfo device_info{ VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
device_info.queueCreateInfoCount = 1;
device_info.pQueueCreateInfos = &queue_info;
device_info.enabledLayerCount = (uint32_t)device_layer_names_.size();
device_info.ppEnabledLayerNames = device_info.enabledLayerCount ? device_layer_names_.data() : nullptr;
device_info.enabledLayerCount = 0;
device_info.ppEnabledLayerNames = nullptr;
device_info.enabledExtensionCount = (uint32_t)device_extensions_enabled_.size();
device_info.ppEnabledExtensionNames = device_info.enabledExtensionCount ? device_extensions_enabled_.data() : nullptr;

Expand Down
8 changes: 2 additions & 6 deletions Common/GPU/Vulkan/VulkanContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,10 @@ class VulkanContext {
return queueFamilyProperties_[family];
}

VkResult GetInstanceLayerExtensionList(const char *layerName, std::vector<VkExtensionProperties> &extensions);
VkResult GetInstanceLayerExtensionList(const char *layerName, std::vector<VkExtensionProperties> *extensions);
VkResult GetInstanceLayerProperties();

VkResult GetDeviceLayerExtensionList(const char *layerName, std::vector<VkExtensionProperties> &extensions);
VkResult GetDeviceLayerProperties();
VkResult GetDeviceExtensionList(std::vector<VkExtensionProperties> *extensions);

const std::vector<VkExtensionProperties> &GetDeviceExtensionsAvailable() const {
return device_extension_properties_;
Expand Down Expand Up @@ -479,9 +478,6 @@ class VulkanContext {
std::vector<const char *> instance_extensions_enabled_;
std::vector<VkExtensionProperties> instance_extension_properties_;

std::vector<const char *> device_layer_names_;
std::vector<LayerProperties> device_layer_properties_;

std::vector<const char *> device_extensions_enabled_;
std::vector<VkExtensionProperties> device_extension_properties_;
VulkanExtensions extensionsLookup_{};
Expand Down
8 changes: 3 additions & 5 deletions GPU/Vulkan/TextureCacheVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,14 @@ void TextureCacheVulkan::DeviceRestore(Draw::DrawContext *draw) {
VkResult res = vkCreateSampler(vulkan->GetDevice(), &samp, nullptr, &samplerNearest_);
_assert_(res == VK_SUCCESS);

VkCommandBuffer cmdInit = (VkCommandBuffer)draw_->GetNativeObject(Draw::NativeObject::INIT_COMMANDBUFFER);
CompileScalingShader(cmdInit);
CompileScalingShader();

computeShaderManager_.DeviceRestore(draw);
}

void TextureCacheVulkan::NotifyConfigChanged() {
TextureCacheCommon::NotifyConfigChanged();
VkCommandBuffer cmdInit = (VkCommandBuffer)draw_->GetNativeObject(Draw::NativeObject::INIT_COMMANDBUFFER);
CompileScalingShader(cmdInit);
CompileScalingShader();
}

static std::string ReadShaderSrc(const Path &filename) {
Expand Down Expand Up @@ -364,7 +362,7 @@ bool TextureCacheVulkan::CompileMultipassShader(VulkanContext *vulkan, const Tex
return true;
}

void TextureCacheVulkan::CompileScalingShader(VkCommandBuffer cmdInit) {
void TextureCacheVulkan::CompileScalingShader() {
if (!draw_) {
// Something is very wrong.
return;
Expand Down
2 changes: 1 addition & 1 deletion GPU/Vulkan/TextureCacheVulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class TextureCacheVulkan : public TextureCacheCommon {

void BuildTexture(TexCacheEntry *const entry) override;

void CompileScalingShader(VkCommandBuffer cmdInit);
void CompileScalingShader();
bool CompileMultipassShader(VulkanContext *vulkan, const TextureShaderInfo &shaderInfo, std::string *error);
void ClearScalingShaders(VulkanContext *vulkan);
bool HasScalingShader() const;
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,20 @@ During this cycle, I've mostly focused on UX improvements.

- Rendering fixes
- Fix a bug in lens flare occlusion for the Syphon Filter games ([#21511])
- Fix a bug in the software renderer ([#21648])

- Misc UI improvements
- Soft keyboard has more symbols ([#21625])
- Basic deep link support on iOS ([#21615])
- Fix file picker problems on some Android devices (regression) ([#21614])
- Instant type-to-search in game browser ([#21559], [#21565], [#21630])
- Fix file picker problems on some Android devices (regression) ([#21614], [#21656])
- Fix crash in text edit fields on Mac/iOS ([#21601])
- PSP DVD prototypes can now load directly ([#21599], [#21601])
- Cheat UI has been cleaned up and supports titles and comments natively ([#21590])
- Instant type-to-search in game browser ([#21559], [#21565], [#21630])
- RetroAchievements subset display improvements ([#21536])
- Basic deep link support on iOS ([#21615])
- Soft keyboard has more symbols ([#21625])

- Other
- Fix important (but mostly rare) crash bug affecting games that draw a lot ([#21669])
- More plugin zip files can now auto-install ([#21556])
- Pause on lost-focus on Linux ([#21517])
- Frameskipping no longer breaks analog stick auto-rotation in GoW, however manual rotation still broken ([#21508])
Expand All @@ -67,6 +69,8 @@ During this cycle, I've mostly focused on UX improvements.
- Fix music looping in Death JR ([#21490])
- Hide the save-load indicator in the corner by default ([#21528])
- Fix crash in the remote debugger, by Nemoumbra ([#21652])
- Fix screenshot cropping bug ([#21665])
- mfplat.dll is no longer required on Windows unless you need camera/microphone ([#21660])

What's new in 1.20.3
--------------------
Expand Down Expand Up @@ -538,3 +542,9 @@ See [history.md](history.md).
[#21565]: https://github.com/hrydgard/ppsspp/issues/21565 "Improve search to support full-width chars and to clear search on navigation"
[#21630]: https://github.com/hrydgard/ppsspp/issues/21630 "Refactor type-to-search code for reuse, use in cheats dialog"
[#21595]: https://github.com/hrydgard/ppsspp/issues/21595 "loongarch: Fix Jit_WeightsU16Skin in VertexDecoderLoongArch64.cpp"
[#21648]: https://github.com/hrydgard/ppsspp/issues/21648 "Remove 2 cases for fast path for soft gpu"
[#21656]: https://github.com/hrydgard/ppsspp/issues/21656 "Fix the java exception reporting for Android file picker errors, fix some search issues"
[#21669]: https://github.com/hrydgard/ppsspp/issues/21669 "Add \"allocation slack\" to our pushbuffers. Fixes a memory overwrite bug"
[#21652]: https://github.com/hrydgard/ppsspp/issues/21652 "Critical bug in the remote debugger"
[#21665]: https://github.com/hrydgard/ppsspp/issues/21665 "Raw screenshot cropping fix"
[#21660]: https://github.com/hrydgard/ppsspp/issues/21660 "Remove the mfplat.dll hard dependency (now fully dynamic)."
Loading
Loading