Remove xcode/examples.h

This commit is contained in:
Gadgeteer 2023-07-19 16:19:15 +01:00
commit 2d2746c01d
41 changed files with 655 additions and 1014 deletions

View file

@ -1,7 +1,7 @@
/*
* Android Vulkan function pointer loader
*
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
@ -125,6 +125,18 @@ PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
PFN_vkCmdFillBuffer vkCmdFillBuffer;
PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
PFN_vkQueuePresentKHR vkQueuePresentKHR;
PFN_vkResetCommandBuffer vkResetCommandBuffer;
int32_t vks::android::screenDensity;
void *libVulkan;
@ -289,6 +301,18 @@ namespace vks
vkDestroySurfaceKHR = reinterpret_cast<PFN_vkDestroySurfaceKHR>(vkGetInstanceProcAddr(instance, "vkDestroySurfaceKHR"));
vkCmdFillBuffer = reinterpret_cast<PFN_vkCmdFillBuffer>(vkGetInstanceProcAddr(instance, "vkCmdFillBuffer"));
vkGetPhysicalDeviceSurfaceSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceSupportKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"));
vkGetPhysicalDeviceSurfaceCapabilitiesKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"));
vkGetPhysicalDeviceSurfaceFormatsKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR"));
vkGetPhysicalDeviceSurfacePresentModesKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR"));
vkCreateSwapchainKHR = reinterpret_cast<PFN_vkCreateSwapchainKHR>(vkGetInstanceProcAddr(instance, "vkCreateSwapchainKHR"));
vkDestroySwapchainKHR = reinterpret_cast<PFN_vkDestroySwapchainKHR>(vkGetInstanceProcAddr(instance, "vkDestroySwapchainKHR"));
vkGetSwapchainImagesKHR = reinterpret_cast<PFN_vkGetSwapchainImagesKHR>(vkGetInstanceProcAddr(instance, "vkGetSwapchainImagesKHR"));
vkAcquireNextImageKHR = reinterpret_cast<PFN_vkAcquireNextImageKHR>(vkGetInstanceProcAddr(instance, "vkAcquireNextImageKHR"));
vkQueuePresentKHR = reinterpret_cast<PFN_vkQueuePresentKHR>(vkGetInstanceProcAddr(instance, "vkQueuePresentKHR"));
vkResetCommandBuffer = reinterpret_cast<PFN_vkResetCommandBuffer>(vkGetInstanceProcAddr(instance, "vkResetCommandBuffer"));
}
void freeVulkanLibrary()

View file

@ -1,7 +1,7 @@
/*
* Android Vulkan function pointer prototypes
*
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
@ -12,6 +12,7 @@
#define VULKANANDROID_H
// Vulkan needs to be loaded dynamically on android
// While SDK 26 (and up) come with a loader, we also want to support older devices, so we manually load function pointers
#pragma once
@ -158,6 +159,18 @@ extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
extern PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
extern PFN_vkCmdFillBuffer vkCmdFillBuffer;
extern PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
extern PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
extern PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
extern PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
extern PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
extern PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
extern PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
extern PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
extern PFN_vkQueuePresentKHR vkQueuePresentKHR;
extern PFN_vkResetCommandBuffer vkResetCommandBuffer;
namespace vks
{
namespace android

View file

@ -1,259 +0,0 @@
/*
* Heightmap terrain generator
*
* Copyright (C) by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#include <glm/glm.hpp>
#include <glm/glm.hpp>
#include "vulkan/vulkan.h"
#include "VulkanDevice.h"
#include "VulkanBuffer.h"
#include <ktx.h>
#include <ktxvulkan.h>
namespace vks
{
class HeightMap
{
private:
uint16_t *heightdata;
uint32_t dim;
uint32_t scale;
vks::VulkanDevice *device = nullptr;
VkQueue copyQueue = VK_NULL_HANDLE;
public:
enum Topology { topologyTriangles, topologyQuads };
float heightScale = 1.0f;
float uvScale = 1.0f;
vks::Buffer vertexBuffer;
vks::Buffer indexBuffer;
struct Vertex {
glm::vec3 pos;
glm::vec3 normal;
glm::vec2 uv;
};
size_t vertexBufferSize = 0;
size_t indexBufferSize = 0;
uint32_t indexCount = 0;
HeightMap(vks::VulkanDevice *device, VkQueue copyQueue)
{
this->device = device;
this->copyQueue = copyQueue;
};
~HeightMap()
{
vertexBuffer.destroy();
indexBuffer.destroy();
delete[] heightdata;
}
float getHeight(uint32_t x, uint32_t y)
{
glm::ivec2 rpos = glm::ivec2(x, y) * glm::ivec2(scale);
rpos.x = std::max(0, std::min(rpos.x, (int)dim - 1));
rpos.y = std::max(0, std::min(rpos.y, (int)dim - 1));
rpos /= glm::ivec2(scale);
return *(heightdata + (rpos.x + rpos.y * dim) * scale) / 65535.0f * heightScale;
}
#if defined(__ANDROID__)
void loadFromFile(const std::string filename, uint32_t patchsize, glm::vec3 scale, Topology topology, AAssetManager* assetManager)
#else
void loadFromFile(const std::string filename, uint32_t patchsize, glm::vec3 scale, Topology topology)
#endif
{
assert(device);
assert(copyQueue != VK_NULL_HANDLE);
ktxResult result;
ktxTexture* ktxTexture;
#if defined(__ANDROID__)
AAsset* asset = AAssetManager_open(androidApp->activity->assetManager, filename.c_str(), AASSET_MODE_STREAMING);
assert(asset);
size_t size = AAsset_getLength(asset);
assert(size > 0);
void *textureData = malloc(size);
AAsset_read(asset, textureData, size);
AAsset_close(asset);
result = ktxTexture_CreateFromMemory(textureData, size, KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, target);
free(textureData);
#else
result = ktxTexture_CreateFromNamedFile(filename.c_str(), KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, &ktxTexture);
#endif
assert(result == KTX_SUCCESS);
ktx_size_t ktxSize = ktxTexture_GetImageSize(ktxTexture, 0);
ktx_uint8_t* ktxImage = ktxTexture_GetData(ktxTexture);
dim = ktxTexture->baseWidth;
heightdata = new uint16_t[dim * dim];
memcpy(heightdata, ktxImage, ktxSize);
this->scale = dim / patchsize;
ktxTexture_Destroy(ktxTexture);
// Generate vertices
Vertex * vertices = new Vertex[patchsize * patchsize * 4];
const float wx = 2.0f;
const float wy = 2.0f;
for (uint32_t x = 0; x < patchsize; x++)
{
for (uint32_t y = 0; y < patchsize; y++)
{
uint32_t index = (x + y * patchsize);
vertices[index].pos[0] = (x * wx + wx / 2.0f - (float)patchsize * wx / 2.0f) * scale.x;
vertices[index].pos[1] = -getHeight(x, y);
vertices[index].pos[2] = (y * wy + wy / 2.0f - (float)patchsize * wy / 2.0f) * scale.z;
vertices[index].uv = glm::vec2((float)x / patchsize, (float)y / patchsize) * uvScale;
}
}
for (uint32_t y = 0; y < patchsize; y++)
{
for (uint32_t x = 0; x < patchsize; x++)
{
float dx = getHeight(x < patchsize - 1 ? x + 1 : x, y) - getHeight(x > 0 ? x - 1 : x, y);
if (x == 0 || x == patchsize - 1)
dx *= 2.0f;
float dy = getHeight(x, y < patchsize - 1 ? y + 1 : y) - getHeight(x, y > 0 ? y - 1 : y);
if (y == 0 || y == patchsize - 1)
dy *= 2.0f;
glm::vec3 A = glm::vec3(1.0f, 0.0f, dx);
glm::vec3 B = glm::vec3(0.0f, 1.0f, dy);
glm::vec3 normal = (glm::normalize(glm::cross(A, B)) + 1.0f) * 0.5f;
vertices[x + y * patchsize].normal = glm::vec3(normal.x, normal.z, normal.y);
}
}
// Generate indices
const uint32_t w = (patchsize - 1);
uint32_t *indices;
switch (topology)
{
// Indices for triangles
case topologyTriangles:
{
indices = new uint32_t[w * w * 6];
for (uint32_t x = 0; x < w; x++)
{
for (uint32_t y = 0; y < w; y++)
{
uint32_t index = (x + y * w) * 6;
indices[index] = (x + y * patchsize);
indices[index + 1] = indices[index] + patchsize;
indices[index + 2] = indices[index + 1] + 1;
indices[index + 3] = indices[index + 1] + 1;
indices[index + 4] = indices[index] + 1;
indices[index + 5] = indices[index];
}
}
indexCount = (patchsize - 1) * (patchsize - 1) * 6;
indexBufferSize = (w * w * 6) * sizeof(uint32_t);
break;
}
// Indices for quad patches (tessellation)
case topologyQuads:
{
indices = new uint32_t[w * w * 4];
for (uint32_t x = 0; x < w; x++)
{
for (uint32_t y = 0; y < w; y++)
{
uint32_t index = (x + y * w) * 4;
indices[index] = (x + y * patchsize);
indices[index + 1] = indices[index] + patchsize;
indices[index + 2] = indices[index + 1] + 1;
indices[index + 3] = indices[index] + 1;
}
}
indexCount = (patchsize - 1) * (patchsize - 1) * 4;
indexBufferSize = (w * w * 4) * sizeof(uint32_t);
break;
}
}
assert(indexBufferSize > 0);
vertexBufferSize = (patchsize * patchsize * 4) * sizeof(Vertex);
// Generate Vulkan buffers
vks::Buffer vertexStaging, indexStaging;
// Create staging buffers
device->createBuffer(
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
&vertexStaging,
vertexBufferSize,
vertices);
device->createBuffer(
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
&indexStaging,
indexBufferSize,
indices);
// Device local (target) buffer
device->createBuffer(
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
&vertexBuffer,
vertexBufferSize);
device->createBuffer(
VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
&indexBuffer,
indexBufferSize);
// Copy from staging buffers
VkCommandBuffer copyCmd = device->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
VkBufferCopy copyRegion = {};
copyRegion.size = vertexBufferSize;
vkCmdCopyBuffer(
copyCmd,
vertexStaging.buffer,
vertexBuffer.buffer,
1,
&copyRegion);
copyRegion.size = indexBufferSize;
vkCmdCopyBuffer(
copyCmd,
indexStaging.buffer,
indexBuffer.buffer,
1,
&copyRegion);
device->flushCommandBuffer(copyCmd, copyQueue, true);
vkDestroyBuffer(device->logicalDevice, vertexStaging.buffer, nullptr);
vkFreeMemory(device->logicalDevice, vertexStaging.memory, nullptr);
vkDestroyBuffer(device->logicalDevice, indexStaging.buffer, nullptr);
vkFreeMemory(device->logicalDevice, indexStaging.memory, nullptr);
}
};
}

View file

@ -3,7 +3,7 @@
*
* A swap chain is a collection of framebuffers used for rendering and presentation to the windowing system
*
* Copyright (C) 2016-2021 by Sascha Willems - www.saschawillems.de
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
@ -103,7 +103,7 @@ void VulkanSwapChain::initSurface(uint32_t width, uint32_t height)
std::vector<VkBool32> supportsPresent(queueCount);
for (uint32_t i = 0; i < queueCount; i++)
{
fpGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, i, surface, &supportsPresent[i]);
vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, i, surface, &supportsPresent[i]);
}
// Search for a graphics and a present queue in the array of queue
@ -157,44 +157,30 @@ void VulkanSwapChain::initSurface(uint32_t width, uint32_t height)
// Get list of supported surface formats
uint32_t formatCount;
VK_CHECK_RESULT(fpGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &formatCount, NULL));
VK_CHECK_RESULT(vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &formatCount, NULL));
assert(formatCount > 0);
std::vector<VkSurfaceFormatKHR> surfaceFormats(formatCount);
VK_CHECK_RESULT(fpGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &formatCount, surfaceFormats.data()));
VK_CHECK_RESULT(vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &formatCount, surfaceFormats.data()));
// If the surface format list only includes one entry with VK_FORMAT_UNDEFINED,
// there is no preferred format, so we assume VK_FORMAT_B8G8R8A8_UNORM
if ((formatCount == 1) && (surfaceFormats[0].format == VK_FORMAT_UNDEFINED))
{
colorFormat = VK_FORMAT_B8G8R8A8_UNORM;
colorSpace = surfaceFormats[0].colorSpace;
}
else
{
// iterate over the list of available surface format and
// check for the presence of VK_FORMAT_B8G8R8A8_UNORM
bool found_B8G8R8A8_UNORM = false;
for (auto&& surfaceFormat : surfaceFormats)
{
if (surfaceFormat.format == VK_FORMAT_B8G8R8A8_UNORM)
{
colorFormat = surfaceFormat.format;
colorSpace = surfaceFormat.colorSpace;
found_B8G8R8A8_UNORM = true;
break;
}
}
// We want to get a format that best suits our needs, so we try to get one from a set of preferred formats
// Initialize the format to the first one returned by the implementation in case we can't find one of the preffered formats
VkSurfaceFormatKHR selectedFormat = surfaceFormats[0];
std::vector<VkFormat> preferredImageFormats = {
VK_FORMAT_B8G8R8A8_UNORM,
VK_FORMAT_R8G8B8A8_UNORM,
VK_FORMAT_A8B8G8R8_UNORM_PACK32
};
// in case VK_FORMAT_B8G8R8A8_UNORM is not available
// select the first available color format
if (!found_B8G8R8A8_UNORM)
{
colorFormat = surfaceFormats[0].format;
colorSpace = surfaceFormats[0].colorSpace;
for (auto& availableFormat : surfaceFormats) {
if (std::find(preferredImageFormats.begin(), preferredImageFormats.end(), availableFormat.format) != preferredImageFormats.end()) {
selectedFormat = availableFormat;
break;
}
}
colorFormat = selectedFormat.format;
colorSpace = selectedFormat.colorSpace;
}
/**
@ -210,16 +196,6 @@ void VulkanSwapChain::connect(VkInstance instance, VkPhysicalDevice physicalDevi
this->instance = instance;
this->physicalDevice = physicalDevice;
this->device = device;
fpGetPhysicalDeviceSurfaceSupportKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceSupportKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"));
fpGetPhysicalDeviceSurfaceCapabilitiesKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"));
fpGetPhysicalDeviceSurfaceFormatsKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceFormatsKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR"));
fpGetPhysicalDeviceSurfacePresentModesKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR>(vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR"));
fpCreateSwapchainKHR = reinterpret_cast<PFN_vkCreateSwapchainKHR>(vkGetDeviceProcAddr(device, "vkCreateSwapchainKHR"));
fpDestroySwapchainKHR = reinterpret_cast<PFN_vkDestroySwapchainKHR>(vkGetDeviceProcAddr(device, "vkDestroySwapchainKHR"));
fpGetSwapchainImagesKHR = reinterpret_cast<PFN_vkGetSwapchainImagesKHR>(vkGetDeviceProcAddr(device, "vkGetSwapchainImagesKHR"));
fpAcquireNextImageKHR = reinterpret_cast<PFN_vkAcquireNextImageKHR>(vkGetDeviceProcAddr(device, "vkAcquireNextImageKHR"));
fpQueuePresentKHR = reinterpret_cast<PFN_vkQueuePresentKHR>(vkGetDeviceProcAddr(device, "vkQueuePresentKHR"));
}
/**
@ -236,15 +212,15 @@ void VulkanSwapChain::create(uint32_t *width, uint32_t *height, bool vsync, bool
// Get physical device surface properties and formats
VkSurfaceCapabilitiesKHR surfCaps;
VK_CHECK_RESULT(fpGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, &surfCaps));
VK_CHECK_RESULT(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, &surfCaps));
// Get available present modes
uint32_t presentModeCount;
VK_CHECK_RESULT(fpGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &presentModeCount, NULL));
VK_CHECK_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &presentModeCount, NULL));
assert(presentModeCount > 0);
std::vector<VkPresentModeKHR> presentModes(presentModeCount);
VK_CHECK_RESULT(fpGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &presentModeCount, presentModes.data()));
VK_CHECK_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &presentModeCount, presentModes.data()));
VkExtent2D swapchainExtent = {};
// If width (and height) equals the special value 0xFFFFFFFF, the size of the surface will be set by the swapchain
@ -363,7 +339,7 @@ void VulkanSwapChain::create(uint32_t *width, uint32_t *height, bool vsync, bool
swapchainCI.imageUsage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
}
VK_CHECK_RESULT(fpCreateSwapchainKHR(device, &swapchainCI, nullptr, &swapChain));
VK_CHECK_RESULT(vkCreateSwapchainKHR(device, &swapchainCI, nullptr, &swapChain));
// If an existing swap chain is re-created, destroy the old swap chain
// This also cleans up all the presentable images
@ -373,13 +349,13 @@ void VulkanSwapChain::create(uint32_t *width, uint32_t *height, bool vsync, bool
{
vkDestroyImageView(device, buffers[i].view, nullptr);
}
fpDestroySwapchainKHR(device, oldSwapchain, nullptr);
vkDestroySwapchainKHR(device, oldSwapchain, nullptr);
}
VK_CHECK_RESULT(fpGetSwapchainImagesKHR(device, swapChain, &imageCount, NULL));
VK_CHECK_RESULT(vkGetSwapchainImagesKHR(device, swapChain, &imageCount, NULL));
// Get the swap chain images
images.resize(imageCount);
VK_CHECK_RESULT(fpGetSwapchainImagesKHR(device, swapChain, &imageCount, images.data()));
VK_CHECK_RESULT(vkGetSwapchainImagesKHR(device, swapChain, &imageCount, images.data()));
// Get the swap chain buffers containing the image and imageview
buffers.resize(imageCount);
@ -425,7 +401,7 @@ VkResult VulkanSwapChain::acquireNextImage(VkSemaphore presentCompleteSemaphore,
{
// By setting timeout to UINT64_MAX we will always wait until the next image has been acquired or an actual error is thrown
// With that we don't have to handle VK_NOT_READY
return fpAcquireNextImageKHR(device, swapChain, UINT64_MAX, presentCompleteSemaphore, (VkFence)nullptr, imageIndex);
return vkAcquireNextImageKHR(device, swapChain, UINT64_MAX, presentCompleteSemaphore, (VkFence)nullptr, imageIndex);
}
/**
@ -451,7 +427,7 @@ VkResult VulkanSwapChain::queuePresent(VkQueue queue, uint32_t imageIndex, VkSem
presentInfo.pWaitSemaphores = &waitSemaphore;
presentInfo.waitSemaphoreCount = 1;
}
return fpQueuePresentKHR(queue, &presentInfo);
return vkQueuePresentKHR(queue, &presentInfo);
}
@ -469,7 +445,7 @@ void VulkanSwapChain::cleanup()
}
if (surface != VK_NULL_HANDLE)
{
fpDestroySwapchainKHR(device, swapChain, nullptr);
vkDestroySwapchainKHR(device, swapChain, nullptr);
vkDestroySurfaceKHR(instance, surface, nullptr);
}
surface = VK_NULL_HANDLE;

View file

@ -3,7 +3,7 @@
*
* A swap chain is a collection of framebuffers used for rendering and presentation to the windowing system
*
* Copyright (C) 2016-2017 by Sascha Willems - www.saschawillems.de
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
@ -39,16 +39,6 @@ private:
VkDevice device;
VkPhysicalDevice physicalDevice;
VkSurfaceKHR surface;
// Function pointers
PFN_vkGetPhysicalDeviceSurfaceSupportKHR fpGetPhysicalDeviceSurfaceSupportKHR;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR fpGetPhysicalDeviceSurfaceCapabilitiesKHR;
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR fpGetPhysicalDeviceSurfaceFormatsKHR;
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR fpGetPhysicalDeviceSurfacePresentModesKHR;
PFN_vkCreateSwapchainKHR fpCreateSwapchainKHR;
PFN_vkDestroySwapchainKHR fpDestroySwapchainKHR;
PFN_vkGetSwapchainImagesKHR fpGetSwapchainImagesKHR;
PFN_vkAcquireNextImageKHR fpAcquireNextImageKHR;
PFN_vkQueuePresentKHR fpQueuePresentKHR;
public:
VkFormat colorFormat;
VkColorSpaceKHR colorSpace;

View file

@ -821,7 +821,7 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation)
settings.vsync = true;
}
if (commandLineParser.isSet("height")) {
height = commandLineParser.getValueAsInt("height", width);
height = commandLineParser.getValueAsInt("height", height);
}
if (commandLineParser.isSet("width")) {
width = commandLineParser.getValueAsInt("width", width);

View file

@ -80,7 +80,6 @@ private:
uint32_t destWidth;
uint32_t destHeight;
bool resizing = false;
void windowResize();
void handleMouseMove(int32_t x, int32_t y);
void nextFrame();
void updateOverlay();
@ -377,6 +376,8 @@ public:
/** @brief Loads a SPIR-V shader file for the given shader stage */
VkPipelineShaderStageCreateInfo loadShader(std::string fileName, VkShaderStageFlagBits stage);
void windowResize();
/** @brief Entry point for the main render loop */
void renderLoop();