Specify a useful app version when loading Vulkan.

This commit is contained in:
Unknown W. Brackets 2016-03-12 14:03:26 -08:00 committed by Henrik Rydgard
parent 8efbcf8d42
commit c92790c5a8
6 changed files with 17 additions and 5 deletions

View File

@ -28,7 +28,7 @@
using namespace std;
VulkanContext::VulkanContext(const char *app_name, uint32_t flags)
VulkanContext::VulkanContext(const char *app_name, int app_ver, uint32_t flags)
: device_(nullptr),
gfx_queue_(VK_NULL_HANDLE),
#ifdef _WIN32
@ -88,8 +88,9 @@ VulkanContext::VulkanContext(const char *app_name, uint32_t flags)
app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
app_info.pNext = NULL;
app_info.pApplicationName = app_name;
app_info.applicationVersion = 1;
app_info.applicationVersion = app_ver;
app_info.pEngineName = app_name;
// Let's increment this when we make major engine/context changes.
app_info.engineVersion = 1;
#ifdef ANDROID
// For some strange reason, the Shield TV wants 1.0.2, not 1.0.3.

View File

@ -150,7 +150,7 @@ private:
// Optionally, it can create a depth buffer for you as well.
class VulkanContext {
public:
VulkanContext(const char *app_name, uint32_t flags);
VulkanContext(const char *app_name, int app_ver, uint32_t flags);
~VulkanContext();
VkResult CreateDevice(int physical_device);

View File

@ -54,8 +54,11 @@
#include "Common/Vulkan/VulkanContext.h"
#include "thin3d/thin3d.h"
#include "util/text/parsers.h"
#include "Windows/GPU/WindowsVulkanContext.h"
extern const char *PPSSPP_GIT_VERSION;
static const bool g_validate_ = true;
static VulkanContext *g_Vulkan;
@ -156,7 +159,8 @@ bool WindowsVulkanContext::Init(HINSTANCE hInst, HWND hWnd, std::string *error_m
g_LogOptions.breakOnWarning = true;
g_LogOptions.msgBoxOnError = false;
g_Vulkan = new VulkanContext("PPSSPP", (g_validate_ ? VULKAN_FLAG_VALIDATE : 0) | VULKAN_FLAG_PRESENT_MAILBOX);
Version gitVer(PPSSPP_GIT_VERSION);
g_Vulkan = new VulkanContext("PPSSPP", gitVer.ToInteger(), (g_validate_ ? VULKAN_FLAG_VALIDATE : 0) | VULKAN_FLAG_PRESENT_MAILBOX);
g_Vulkan->CreateDevice(0);
if (g_validate_) {
int bits = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;

View File

@ -245,7 +245,8 @@ bool AndroidVulkanContext::Init(ANativeWindow *wnd, int desiredBackbufferSizeX,
g_LogOptions.msgBoxOnError = false;
ILOG("Creating vulkan context");
g_Vulkan = new VulkanContext("PPSSPP", VULKAN_FLAG_PRESENT_MAILBOX | VULKAN_FLAG_PRESENT_FIFO_RELAXED);
Version gitVer(PPSSPP_GIT_VERSION);
g_Vulkan = new VulkanContext("PPSSPP", gitVer.ToInteger(), VULKAN_FLAG_PRESENT_MAILBOX | VULKAN_FLAG_PRESENT_FIFO_RELAXED);
if (!g_Vulkan->GetInstance()) {
ELOG("Failed to create vulkan context");
return false;

View File

@ -22,6 +22,11 @@ std::string Version::ToString() const {
return std::string(temp);
}
int Version::ToInteger() const {
// This allows for ~2000 major versions, ~100 minor versions, and ~10000 sub versions.
return major * 1000000 + minor * 10000 + sub;
}
bool ParseMacAddress(std::string str, uint8_t macAddr[6]) {
int mac[6];
if (6 != sscanf(str.c_str(), "%02x:%02x:%02x:%02x:%02x:%02x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5])) {

View File

@ -48,6 +48,7 @@ struct Version {
}
std::string ToString() const;
int ToInteger() const;
private:
bool ParseVersionString(std::string str);
};