summaryrefslogtreecommitdiff
path: root/tools/gfx/vulkan/vk-swap-chain.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-29 14:49:26 +0800
committerGitHub <noreply@github.com>2024-10-29 14:49:26 +0800
commitf65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch)
treeea1d61342cd29368e19135000ec2948813096205 /tools/gfx/vulkan/vk-swap-chain.cpp
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'tools/gfx/vulkan/vk-swap-chain.cpp')
-rw-r--r--tools/gfx/vulkan/vk-swap-chain.cpp61
1 files changed, 46 insertions, 15 deletions
diff --git a/tools/gfx/vulkan/vk-swap-chain.cpp b/tools/gfx/vulkan/vk-swap-chain.cpp
index 7580e01b3..4f9bd3ca2 100644
--- a/tools/gfx/vulkan/vk-swap-chain.cpp
+++ b/tools/gfx/vulkan/vk-swap-chain.cpp
@@ -1,8 +1,8 @@
// vk-swap-chain.cpp
#include "vk-swap-chain.h"
-#include "vk-util.h"
#include "../apple/cocoa-util.h"
+#include "vk-util.h"
namespace gfx
{
@@ -44,7 +44,9 @@ void SwapchainImpl::getWindowSize(int* widthOut, int* heightOut) const
#elif defined(SLANG_ENABLE_XLIB)
XWindowAttributes winAttr = {};
XGetWindowAttributes(
- (Display*)m_windowHandle.handleValues[0], (Window)m_windowHandle.handleValues[1], &winAttr);
+ (Display*)m_windowHandle.handleValues[0],
+ (Window)m_windowHandle.handleValues[1],
+ &winAttr);
*widthOut = winAttr.width;
*heightOut = winAttr.height;
@@ -78,22 +80,32 @@ Result SwapchainImpl::createSwapchainAndImages()
VkSurfaceCapabilitiesKHR surfaceCaps;
SLANG_VK_RETURN_ON_FAIL(m_api->vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
- m_api->m_physicalDevice, m_surface, &surfaceCaps));
+ m_api->m_physicalDevice,
+ m_surface,
+ &surfaceCaps));
}
VkPresentModeKHR presentMode;
List<VkPresentModeKHR> presentModes;
uint32_t numPresentModes = 0;
m_api->vkGetPhysicalDeviceSurfacePresentModesKHR(
- m_api->m_physicalDevice, m_surface, &numPresentModes, nullptr);
+ m_api->m_physicalDevice,
+ m_surface,
+ &numPresentModes,
+ nullptr);
presentModes.setCount(numPresentModes);
m_api->vkGetPhysicalDeviceSurfacePresentModesKHR(
- m_api->m_physicalDevice, m_surface, &numPresentModes, presentModes.getBuffer());
+ m_api->m_physicalDevice,
+ m_surface,
+ &numPresentModes,
+ presentModes.getBuffer());
{
int numCheckPresentOptions = 3;
VkPresentModeKHR presentOptions[] = {
- VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_FIFO_KHR};
+ VK_PRESENT_MODE_IMMEDIATE_KHR,
+ VK_PRESENT_MODE_MAILBOX_KHR,
+ VK_PRESENT_MODE_FIFO_KHR};
if (m_desc.enableVSync)
{
presentOptions[0] = VK_PRESENT_MODE_FIFO_KHR;
@@ -147,14 +159,19 @@ Result SwapchainImpl::createSwapchainAndImages()
{
vkImages.setCount(numSwapChainImages);
m_api->vkGetSwapchainImagesKHR(
- m_api->m_device, m_swapChain, &numSwapChainImages, vkImages.getBuffer());
+ m_api->m_device,
+ m_swapChain,
+ &numSwapChainImages,
+ vkImages.getBuffer());
}
for (GfxIndex i = 0; i < m_desc.imageCount; i++)
{
ITextureResource::Desc imageDesc = {};
imageDesc.allowedStates = ResourceStateSet(
- ResourceState::Present, ResourceState::RenderTarget, ResourceState::CopyDestination);
+ ResourceState::Present,
+ ResourceState::RenderTarget,
+ ResourceState::CopyDestination);
imageDesc.type = IResource::Type::Texture2D;
imageDesc.arraySize = 0;
imageDesc.format = m_desc.format;
@@ -213,7 +230,10 @@ Result SwapchainImpl::init(DeviceImpl* renderer, const ISwapchain::Desc& desc, W
VkSemaphoreCreateInfo semaphoreCreateInfo = {};
semaphoreCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
SLANG_VK_RETURN_ON_FAIL(renderer->m_api.vkCreateSemaphore(
- renderer->m_api.m_device, &semaphoreCreateInfo, nullptr, &m_nextImageSemaphore));
+ renderer->m_api.m_device,
+ &semaphoreCreateInfo,
+ nullptr,
+ &m_nextImageSemaphore));
m_queue = static_cast<CommandQueueImpl*>(desc.queue);
@@ -247,15 +267,24 @@ Result SwapchainImpl::init(DeviceImpl* renderer, const ISwapchain::Desc& desc, W
VkBool32 supported = false;
m_api->vkGetPhysicalDeviceSurfaceSupportKHR(
- m_api->m_physicalDevice, renderer->m_queueFamilyIndex, m_surface, &supported);
+ m_api->m_physicalDevice,
+ renderer->m_queueFamilyIndex,
+ m_surface,
+ &supported);
uint32_t numSurfaceFormats = 0;
List<VkSurfaceFormatKHR> surfaceFormats;
m_api->vkGetPhysicalDeviceSurfaceFormatsKHR(
- m_api->m_physicalDevice, m_surface, &numSurfaceFormats, nullptr);
+ m_api->m_physicalDevice,
+ m_surface,
+ &numSurfaceFormats,
+ nullptr);
surfaceFormats.setCount(int(numSurfaceFormats));
m_api->vkGetPhysicalDeviceSurfaceFormatsKHR(
- m_api->m_physicalDevice, m_surface, &numSurfaceFormats, surfaceFormats.getBuffer());
+ m_api->m_physicalDevice,
+ m_surface,
+ &numSurfaceFormats,
+ surfaceFormats.getBuffer());
// Look for a suitable format
List<VkFormat> formats;
@@ -360,8 +389,7 @@ int SwapchainImpl::acquireNextImage()
VK_NULL_HANDLE,
(uint32_t*)&m_currentImageIndex);
- if (
- result != VK_SUCCESS
+ if (result != VK_SUCCESS
#if SLANG_APPLE_FAMILY
&& result != VK_SUBOPTIMAL_KHR
#endif
@@ -376,7 +404,10 @@ int SwapchainImpl::acquireNextImage()
return m_currentImageIndex;
}
-Result SwapchainImpl::setFullScreenMode(bool mode) { return SLANG_FAIL; }
+Result SwapchainImpl::setFullScreenMode(bool mode)
+{
+ return SLANG_FAIL;
+}
} // namespace vk
} // namespace gfx