mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Make the Vulkan init flags a proper enum class
This commit is contained in:
@@ -158,7 +158,7 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if ((flags_ & VULKAN_FLAG_VALIDATE) && g_Config.sCustomDriver.empty()) {
|
||||
if ((flags_ & VulkanInitFlags::VALIDATE) && g_Config.sCustomDriver.empty()) {
|
||||
if (IsInstanceExtensionAvailable(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)) {
|
||||
// Enable the validation layers
|
||||
for (size_t i = 0; i < ARRAY_SIZE(validationLayers); i++) {
|
||||
@@ -170,7 +170,7 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
|
||||
INFO_LOG(Log::G3D, "Vulkan debug_utils validation enabled.");
|
||||
} else {
|
||||
ERROR_LOG(Log::G3D, "Validation layer extension not available - not enabling Vulkan validation.");
|
||||
flags_ &= ~VULKAN_FLAG_VALIDATE;
|
||||
flags_ &= ~VulkanInitFlags::VALIDATE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,15 +509,15 @@ bool VulkanContext::CheckLayers(const std::vector<LayerProperties> &layer_props,
|
||||
return true;
|
||||
}
|
||||
|
||||
int VulkanContext::GetPhysicalDeviceByName(const std::string &name) {
|
||||
int VulkanContext::GetPhysicalDeviceByName(std::string_view name) const {
|
||||
for (size_t i = 0; i < physical_devices_.size(); i++) {
|
||||
if (physicalDeviceProperties_[i].properties.deviceName == name)
|
||||
if (equals(physicalDeviceProperties_[i].properties.deviceName, name))
|
||||
return (int)i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int VulkanContext::GetBestPhysicalDevice() {
|
||||
int VulkanContext::GetBestPhysicalDevice() const {
|
||||
// Rules: Prefer discrete over embedded.
|
||||
// Prefer nVidia over Intel.
|
||||
|
||||
@@ -1375,10 +1375,10 @@ bool VulkanContext::InitSwapchain() {
|
||||
INFO_LOG(Log::G3D, "Supported present modes: %s", modes.c_str());
|
||||
for (size_t i = 0; i < presentModeCount; i++) {
|
||||
bool match = false;
|
||||
match = match || ((flags_ & VULKAN_FLAG_PRESENT_MAILBOX) && presentModes[i] == VK_PRESENT_MODE_MAILBOX_KHR);
|
||||
match = match || ((flags_ & VULKAN_FLAG_PRESENT_IMMEDIATE) && presentModes[i] == VK_PRESENT_MODE_IMMEDIATE_KHR);
|
||||
match = match || ((flags_ & VULKAN_FLAG_PRESENT_FIFO_RELAXED) && presentModes[i] == VK_PRESENT_MODE_FIFO_RELAXED_KHR);
|
||||
match = match || ((flags_ & VULKAN_FLAG_PRESENT_FIFO) && presentModes[i] == VK_PRESENT_MODE_FIFO_KHR);
|
||||
match = match || ((flags_ & VulkanInitFlags::PRESENT_MAILBOX) && presentModes[i] == VK_PRESENT_MODE_MAILBOX_KHR);
|
||||
match = match || ((flags_ & VulkanInitFlags::PRESENT_IMMEDIATE) && presentModes[i] == VK_PRESENT_MODE_IMMEDIATE_KHR);
|
||||
match = match || ((flags_ & VulkanInitFlags::PRESENT_FIFO_RELAXED) && presentModes[i] == VK_PRESENT_MODE_FIFO_RELAXED_KHR);
|
||||
match = match || ((flags_ & VulkanInitFlags::PRESENT_FIFO) && presentModes[i] == VK_PRESENT_MODE_FIFO_KHR);
|
||||
|
||||
// Default to the first present mode from the list.
|
||||
if (match || swapchainPresentMode == VK_PRESENT_MODE_MAX_ENUM_KHR) {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/GPU/Vulkan/VulkanLoader.h"
|
||||
#include "Common/GPU/Vulkan/VulkanDebug.h"
|
||||
@@ -20,13 +23,14 @@
|
||||
#define VK_PROFILE_BEGIN(vulkan, cmd, stage, ...) vulkan->GetProfiler()->Begin(cmd, stage, __VA_ARGS__);
|
||||
#define VK_PROFILE_END(vulkan, cmd, stage) vulkan->GetProfiler()->End(cmd, stage);
|
||||
|
||||
enum {
|
||||
VULKAN_FLAG_VALIDATE = 1,
|
||||
VULKAN_FLAG_PRESENT_MAILBOX = 2,
|
||||
VULKAN_FLAG_PRESENT_IMMEDIATE = 4,
|
||||
VULKAN_FLAG_PRESENT_FIFO_RELAXED = 8,
|
||||
VULKAN_FLAG_PRESENT_FIFO = 16,
|
||||
enum class VulkanInitFlags : uint32_t {
|
||||
VALIDATE = (1 << 0),
|
||||
PRESENT_MAILBOX = (1 << 1),
|
||||
PRESENT_IMMEDIATE = (1 << 2),
|
||||
PRESENT_FIFO_RELAXED = (1 << 3),
|
||||
PRESENT_FIFO = (1 << 4),
|
||||
};
|
||||
ENUM_CLASS_BITOPS(VulkanInitFlags);
|
||||
|
||||
enum {
|
||||
VULKAN_VENDOR_NVIDIA = 0x000010de,
|
||||
@@ -178,14 +182,14 @@ public:
|
||||
struct CreateInfo {
|
||||
const char *app_name;
|
||||
int app_ver;
|
||||
uint32_t flags;
|
||||
VulkanInitFlags flags;
|
||||
};
|
||||
|
||||
VkResult CreateInstance(const CreateInfo &info);
|
||||
void DestroyInstance();
|
||||
|
||||
int GetBestPhysicalDevice();
|
||||
int GetPhysicalDeviceByName(const std::string &name);
|
||||
int GetBestPhysicalDevice() const;
|
||||
int GetPhysicalDeviceByName(std::string_view name) const;
|
||||
|
||||
// Convenience method to avoid code duplication.
|
||||
// If it returns false, delete the context.
|
||||
@@ -202,8 +206,8 @@ public:
|
||||
|
||||
VkDevice GetDevice() const { return device_; }
|
||||
VkInstance GetInstance() const { return instance_; }
|
||||
uint32_t GetFlags() const { return flags_; }
|
||||
void UpdateFlags(uint32_t flags) { flags_ = flags; }
|
||||
VulkanInitFlags GetInitFlags() const { return flags_; }
|
||||
void UpdateInitFlags(VulkanInitFlags flags) { flags_ = flags; }
|
||||
|
||||
VulkanDeleteList &Delete() { return globalDeleteList_; }
|
||||
|
||||
@@ -483,7 +487,7 @@ private:
|
||||
// Swap chain extent
|
||||
VkExtent2D swapChainExtent_{};
|
||||
|
||||
int flags_ = 0;
|
||||
VulkanInitFlags flags_{};
|
||||
PerfClass devicePerfClass_ = PerfClass::SLOW;
|
||||
|
||||
int inflightFrames_ = MAX_INFLIGHT_FRAMES;
|
||||
|
||||
@@ -79,7 +79,7 @@ bool VulkanTexture::CreateDirect(int w, int h, int depth, int numMips, VkFormat
|
||||
|
||||
// The graphics debugger always "needs" TRANSFER_SRC but in practice doesn't matter -
|
||||
// unless validation is on. So let's only force it on when being validated, for now.
|
||||
if (vulkan_->GetFlags() & VULKAN_FLAG_VALIDATE) {
|
||||
if (vulkan_->GetInitFlags() & VulkanInitFlags::VALIDATE) {
|
||||
image_create_info.usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
}
|
||||
VmaAllocationCreateInfo allocCreateInfo{};
|
||||
|
||||
@@ -262,6 +262,7 @@ public:
|
||||
bool bUberShaderFragment;
|
||||
int iDefaultTab;
|
||||
int iScreenshotMode;
|
||||
bool bProhibitVulkanLayers;
|
||||
|
||||
std::vector<std::string> vPostShaderNames; // Off for chain end (only Off for no shader)
|
||||
std::map<std::string, float> mPostShaderSetting;
|
||||
|
||||
@@ -28,15 +28,15 @@ static const bool g_Validate = false;
|
||||
#endif
|
||||
|
||||
// TODO: Share this between backends.
|
||||
static uint32_t FlagsFromConfig() {
|
||||
uint32_t flags;
|
||||
static VulkanInitFlags FlagsFromConfig() {
|
||||
VulkanInitFlags flags;
|
||||
if (g_Config.bVSync) {
|
||||
flags = VULKAN_FLAG_PRESENT_FIFO;
|
||||
flags = VulkanInitFlags::PRESENT_FIFO;
|
||||
} else {
|
||||
flags = VULKAN_FLAG_PRESENT_MAILBOX | VULKAN_FLAG_PRESENT_IMMEDIATE;
|
||||
flags = VulkanInitFlags::PRESENT_MAILBOX | VulkanInitFlags::PRESENT_IMMEDIATE;
|
||||
}
|
||||
if (g_Validate) {
|
||||
flags |= VULKAN_FLAG_VALIDATE;
|
||||
flags |= VulkanInitFlags::VALIDATE;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -67,11 +67,10 @@ static const bool g_validate_ = true;
|
||||
static const bool g_validate_ = false;
|
||||
#endif
|
||||
|
||||
static uint32_t FlagsFromConfig() {
|
||||
uint32_t flags = 0;
|
||||
flags = g_Config.bVSync ? VULKAN_FLAG_PRESENT_FIFO : VULKAN_FLAG_PRESENT_MAILBOX;
|
||||
static VulkanInitFlags FlagsFromConfig() {
|
||||
VulkanInitFlags flags = g_Config.bVSync ? VulkanInitFlags::PRESENT_FIFO : VulkanInitFlags::PRESENT_MAILBOX;
|
||||
if (g_validate_) {
|
||||
flags |= VULKAN_FLAG_VALIDATE;
|
||||
flags |= VulkanInitFlags::VALIDATE;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
@@ -175,7 +174,7 @@ void WindowsVulkanContext::Shutdown() {
|
||||
void WindowsVulkanContext::Resize() {
|
||||
draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight());
|
||||
vulkan_->DestroySwapchain();
|
||||
vulkan_->UpdateFlags(FlagsFromConfig());
|
||||
vulkan_->UpdateInitFlags(FlagsFromConfig());
|
||||
vulkan_->InitSwapchain();
|
||||
draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight());
|
||||
}
|
||||
|
||||
+31
-1
@@ -1132,6 +1132,26 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\ViewControllerCommon.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\ViewControllerMetal.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\libretro\libretro.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -1644,6 +1664,16 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</None>
|
||||
<None Include="..\ios\ViewControllerMetal.mm">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</None>
|
||||
<None Include="..\libretro\jni\Android.mk" />
|
||||
<None Include="..\libretro\jni\Application.mk" />
|
||||
<None Include="..\libretro\Makefile" />
|
||||
@@ -1764,4 +1794,4 @@
|
||||
<UserProperties RESOURCE_FILE="DaSh.rc" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -580,6 +580,12 @@
|
||||
<ClInclude Include="..\UI\DarwinFileSystemServices.h">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\ViewControllerCommon.h">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\ViewControllerMetal.h">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="icon1.ico">
|
||||
@@ -592,12 +598,6 @@
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="..\README.md" />
|
||||
<None Include="aboutbox.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="version.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="..\assets\knownfuncs.ini">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
@@ -818,6 +818,9 @@
|
||||
<None Include="..\UI\DarwinFileSystemServices.mm">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</None>
|
||||
<None Include="..\ios\ViewControllerMetal.mm">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ppsspp.rc">
|
||||
@@ -856,4 +859,4 @@
|
||||
<Filter>Other Platforms\SDL</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -21,15 +21,15 @@ static const bool g_Validate = false;
|
||||
#endif
|
||||
|
||||
// TODO: Share this between backends.
|
||||
static uint32_t FlagsFromConfig() {
|
||||
uint32_t flags;
|
||||
static VulkanInitFlags FlagsFromConfig() {
|
||||
VulkanInitFlags flags;
|
||||
if (g_Config.bVSync) {
|
||||
flags = VULKAN_FLAG_PRESENT_FIFO;
|
||||
flags = VulkanInitFlags::PRESENT_FIFO;
|
||||
} else {
|
||||
flags = VULKAN_FLAG_PRESENT_MAILBOX | VULKAN_FLAG_PRESENT_IMMEDIATE;
|
||||
flags = VulkanInitFlags::PRESENT_MAILBOX | VulkanInitFlags::PRESENT_IMMEDIATE;
|
||||
}
|
||||
if (g_Validate) {
|
||||
flags |= VULKAN_FLAG_VALIDATE;
|
||||
flags |= VulkanInitFlags::VALIDATE;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
// https://www.progressconcepts.com/blog/ios-appdelegate-viewcontroller-method-order/
|
||||
|
||||
// TODO: Share this between backends.
|
||||
static uint32_t FlagsFromConfig() {
|
||||
uint32_t flags;
|
||||
static VulkanInitFlags FlagsFromConfig() {
|
||||
VulkanInitFlags flags;
|
||||
if (g_Config.bVSync) {
|
||||
flags = VULKAN_FLAG_PRESENT_FIFO;
|
||||
flags = VulkanInitFlags::PRESENT_FIFO;
|
||||
} else {
|
||||
flags = VULKAN_FLAG_PRESENT_MAILBOX | VULKAN_FLAG_PRESENT_IMMEDIATE;
|
||||
flags = VulkanInitFlags::PRESENT_MAILBOX | VulkanInitFlags::PRESENT_IMMEDIATE;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user