Update to latest zvulkan
This commit is contained in:
parent
4e78ba469c
commit
5e22b07db2
16 changed files with 260 additions and 219 deletions
|
|
@ -10,6 +10,15 @@
|
|||
#ifndef VOLK_H_
|
||||
#define VOLK_H_
|
||||
|
||||
//************************************************************************************
|
||||
//** IF YOU UPDATE THIS FILE TO A NEWER VERSION OF VOLK, ADD THIS TO THE NEW FILE:
|
||||
//************************************************************************************
|
||||
|
||||
#include "../vulkan.h" // note: zvulkan's version
|
||||
|
||||
//************************************************************************************
|
||||
//************************************************************************************
|
||||
|
||||
#if defined(VULKAN_H_) && !defined(VK_NO_PROTOTYPES)
|
||||
# error To use volk, you need to define VK_NO_PROTOTYPES before including vulkan.h
|
||||
#endif
|
||||
|
|
|
|||
127
libraries/ZVulkan/include/zvulkan/vulkan.h
Normal file
127
libraries/ZVulkan/include/zvulkan/vulkan.h
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
ZVulkan include header for vulkan.
|
||||
Include this one instead of the system vulkan.h header.
|
||||
|
||||
We can't use the system header because we don't want to include platform specific headers (windows.h and xlib.h in particular).
|
||||
On Linux we even have many competing platform technologies that may not always be available on the system building the project.
|
||||
*/
|
||||
|
||||
#ifndef VULKAN_H_
|
||||
#define VULKAN_H_
|
||||
|
||||
#define VK_NO_PROTOTYPES // Volk needs this
|
||||
|
||||
// Declare what we intend to support for each OS:
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define VK_USE_PLATFORM_WIN32_KHR
|
||||
#elif defined(__APPLE__)
|
||||
#define VK_USE_PLATFORM_MACOS_MVK
|
||||
#define VK_USE_PLATFORM_METAL_EXT
|
||||
#else
|
||||
#define VK_USE_PLATFORM_XLIB_KHR
|
||||
#define VK_USE_PLATFORM_WAYLAND_KHR
|
||||
#endif
|
||||
|
||||
#include "vulkan/vk_platform.h"
|
||||
#include "vulkan/vulkan_core.h"
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
#include "vulkan/vulkan_android.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
#include <zircon/types.h>
|
||||
#include "vulkan/vulkan_fuchsia.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_IOS_MVK
|
||||
#include "vulkan/vulkan_ios.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_MACOS_MVK
|
||||
#include "vulkan/vulkan_macos.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_METAL_EXT
|
||||
#include "vulkan/vulkan_metal.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_VI_NN
|
||||
#include "vulkan/vulkan_vi.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
|
||||
|
||||
//#include <wayland-client.h>
|
||||
struct wl_display;
|
||||
struct wl_surface;
|
||||
|
||||
#include "vulkan/vulkan_wayland.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
|
||||
// #include <windows.h>
|
||||
typedef unsigned long DWORD;
|
||||
typedef const wchar_t* LPCWSTR;
|
||||
typedef void* HANDLE;
|
||||
typedef struct HINSTANCE__* HINSTANCE;
|
||||
typedef struct HWND__* HWND;
|
||||
typedef struct HMONITOR__* HMONITOR;
|
||||
typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
|
||||
|
||||
#include "vulkan/vulkan_win32.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XCB_KHR
|
||||
#include <xcb/xcb.h>
|
||||
#include "vulkan/vulkan_xcb.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_KHR
|
||||
|
||||
// #include <X11/Xlib.h>
|
||||
typedef struct _XDisplay Display;
|
||||
typedef unsigned long XID;
|
||||
typedef unsigned long VisualID;
|
||||
typedef XID Window;
|
||||
|
||||
#include "vulkan/vulkan_xlib.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
|
||||
#include <directfb.h>
|
||||
#include "vulkan/vulkan_directfb.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include "vulkan/vulkan_xlib_xrandr.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_GGP
|
||||
#include <ggp_c/vulkan_types.h>
|
||||
#include "vulkan/vulkan_ggp.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VK_USE_PLATFORM_SCREEN_QNX
|
||||
#include <screen/screen.h>
|
||||
#include "vulkan/vulkan_screen.h"
|
||||
#endif
|
||||
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
#include "vulkan/vulkan_beta.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -13,8 +13,11 @@ public:
|
|||
|
||||
VulkanInstanceBuilder& ApiVersionsToTry(const std::vector<uint32_t>& versions);
|
||||
VulkanInstanceBuilder& RequireExtension(const std::string& extensionName);
|
||||
VulkanInstanceBuilder& RequireSurfaceExtensions(bool enable = true);
|
||||
VulkanInstanceBuilder& RequireExtensions(const std::vector<std::string>& extensions);
|
||||
VulkanInstanceBuilder& RequireExtensions(const std::vector<const char*>& extensions);
|
||||
VulkanInstanceBuilder& RequireExtensions(const char** extensions, size_t count);
|
||||
VulkanInstanceBuilder& OptionalExtension(const std::string& extensionName);
|
||||
VulkanInstanceBuilder& OptionalSwapchainColorspace();
|
||||
VulkanInstanceBuilder& DebugLayer(bool enable = true);
|
||||
|
||||
std::shared_ptr<VulkanInstance> Create();
|
||||
|
|
@ -26,23 +29,6 @@ private:
|
|||
bool debugLayer = false;
|
||||
};
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
|
||||
class VulkanSurfaceBuilder
|
||||
{
|
||||
public:
|
||||
VulkanSurfaceBuilder();
|
||||
|
||||
VulkanSurfaceBuilder& Win32Window(HWND handle);
|
||||
|
||||
std::shared_ptr<VulkanSurface> Create(std::shared_ptr<VulkanInstance> instance);
|
||||
|
||||
private:
|
||||
HWND hwnd = {};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class VulkanDeviceBuilder
|
||||
{
|
||||
public:
|
||||
|
|
@ -211,8 +197,8 @@ enum class ShaderType
|
|||
class ShaderIncludeResult
|
||||
{
|
||||
public:
|
||||
ShaderIncludeResult(std::string name, std::string text) : name(std::move(name)), text(std::move(text)) { }
|
||||
ShaderIncludeResult(std::string error) : text(std::move(error)) { }
|
||||
ShaderIncludeResult(std::string name, std::string text) : name(std::move(name)), text(std::move(text)) {}
|
||||
ShaderIncludeResult(std::string error) : text(std::move(error)) {}
|
||||
|
||||
std::string name; // fully resolved name of the included header file
|
||||
std::string text; // the file contents - or include error message if name is empty
|
||||
|
|
@ -247,7 +233,7 @@ public:
|
|||
ShaderBuilder& Code(std::vector<uint32_t> spirv) { code = std::move(spirv); return *this; }
|
||||
ShaderBuilder& DebugName(const char* name) { debugName = name; return *this; }
|
||||
|
||||
std::unique_ptr<VulkanShader> Create(const char *shadername, VulkanDevice *device);
|
||||
std::unique_ptr<VulkanShader> Create(const char* shadername, VulkanDevice* device);
|
||||
|
||||
private:
|
||||
std::vector<uint32_t> code;
|
||||
|
|
@ -403,9 +389,14 @@ public:
|
|||
GraphicsPipelineBuilder& AddVertexShader(VulkanShader *shader);
|
||||
GraphicsPipelineBuilder& AddFragmentShader(VulkanShader *shader);
|
||||
|
||||
GraphicsPipelineBuilder& AddConstant(uint32_t constantID, const void* data, size_t size);
|
||||
GraphicsPipelineBuilder& AddConstant(uint32_t constantID, uint32_t value);
|
||||
GraphicsPipelineBuilder& AddConstant(uint32_t constantID, int32_t value);
|
||||
GraphicsPipelineBuilder& AddConstant(uint32_t constantID, float value);
|
||||
|
||||
GraphicsPipelineBuilder& AddVertexBufferBinding(int index, size_t stride);
|
||||
GraphicsPipelineBuilder& AddVertexAttribute(int location, int binding, VkFormat format, size_t offset);
|
||||
|
||||
|
||||
GraphicsPipelineBuilder& AddDynamicState(VkDynamicState state);
|
||||
|
||||
GraphicsPipelineBuilder& PolygonMode(VkPolygonMode mode) {rasterizer.polygonMode = mode; return *this;};
|
||||
|
|
@ -433,6 +424,15 @@ private:
|
|||
std::vector<VkVertexInputAttributeDescription> vertexInputAttributes;
|
||||
std::vector<VkDynamicState> dynamicStates;
|
||||
|
||||
struct ShaderSpecialization
|
||||
{
|
||||
VkSpecializationInfo info = {};
|
||||
std::vector<VkSpecializationMapEntry> entries;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
||||
std::vector<std::unique_ptr<ShaderSpecialization>> specializations;
|
||||
|
||||
VulkanPipelineCache* cache = nullptr;
|
||||
const char* debugName = nullptr;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define VK_USE_PLATFORM_WIN32_KHR
|
||||
#elif defined(__APPLE__)
|
||||
#define VK_USE_PLATFORM_MACOS_MVK
|
||||
#define VK_USE_PLATFORM_METAL_EXT
|
||||
#endif
|
||||
|
||||
#include "vulkan.h"
|
||||
#include "volk/volk.h"
|
||||
#include "vk_mem_alloc/vk_mem_alloc.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,4 @@ public:
|
|||
|
||||
std::shared_ptr<VulkanInstance> Instance;
|
||||
VkSurfaceKHR Surface = VK_NULL_HANDLE;
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
|
||||
VulkanSurface(std::shared_ptr<VulkanInstance> instance, HWND window);
|
||||
HWND Window = 0;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public:
|
|||
VulkanSwapChain(VulkanDevice* device);
|
||||
~VulkanSwapChain();
|
||||
|
||||
void Create(int width, int height, int imageCount, bool vsync, bool hdr, bool exclusivefullscreen);
|
||||
void Create(int width, int height, int imageCount, bool vsync, bool hdr);
|
||||
bool Lost() const { return lost; }
|
||||
|
||||
int Width() const { return actualExtent.width; }
|
||||
|
|
@ -42,9 +42,9 @@ public:
|
|||
private:
|
||||
void SelectFormat(const VulkanSurfaceCapabilities& caps, bool hdr);
|
||||
|
||||
bool CreateSwapchain(int width, int height, int imageCount, bool vsync, bool hdr, bool exclusivefullscreen);
|
||||
bool CreateSwapchain(int width, int height, int imageCount, bool vsync, bool hdr);
|
||||
|
||||
VulkanSurfaceCapabilities GetSurfaceCapabilities(bool exclusivefullscreen);
|
||||
VulkanSurfaceCapabilities GetSurfaceCapabilities();
|
||||
|
||||
VulkanDevice* device = nullptr;
|
||||
bool lost = true;
|
||||
|
|
@ -52,7 +52,7 @@ private:
|
|||
VkExtent2D actualExtent = {};
|
||||
VkSwapchainKHR swapchain = VK_NULL_HANDLE;
|
||||
VkSurfaceFormatKHR format = {};
|
||||
VkPresentModeKHR presentMode;
|
||||
VkPresentModeKHR presentMode = {};
|
||||
std::vector<std::unique_ptr<VulkanImage>> images;
|
||||
std::vector<std::unique_ptr<VulkanImageView>> views;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue