mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-04-21 16:10:47 +03:00
TMP / Fixed vulkan_swap_chain.cpp
This commit is contained in:
parent
2dc60d589c
commit
1e88697457
@ -18,12 +18,12 @@ namespace progressia::desktop {
|
|||||||
SwapChain::SupportDetails
|
SwapChain::SupportDetails
|
||||||
SwapChain::querySwapChainSupport(VkPhysicalDevice device, Vulkan &vulkan) {
|
SwapChain::querySwapChainSupport(VkPhysicalDevice device, Vulkan &vulkan) {
|
||||||
SupportDetails details;
|
SupportDetails details;
|
||||||
auto surface = vulkan.getSurface().getVk();
|
auto *surface = vulkan.getSurface().getVk();
|
||||||
|
|
||||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface,
|
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface,
|
||||||
&details.capabilities);
|
&details.capabilities);
|
||||||
|
|
||||||
uint32_t formatCount;
|
uint32_t formatCount = 0;
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &formatCount,
|
vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &formatCount,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ SwapChain::querySwapChainSupport(VkPhysicalDevice device, Vulkan &vulkan) {
|
|||||||
details.formats.data());
|
details.formats.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t presentModeCount;
|
uint32_t presentModeCount = 0;
|
||||||
vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface,
|
vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface,
|
||||||
&presentModeCount, nullptr);
|
&presentModeCount, nullptr);
|
||||||
|
|
||||||
@ -189,6 +189,7 @@ void SwapChain::create() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-convert-member-functions-to-static): future-proofing
|
||||||
VkSurfaceFormatKHR SwapChain::chooseSurfaceFormat(
|
VkSurfaceFormatKHR SwapChain::chooseSurfaceFormat(
|
||||||
const std::vector<VkSurfaceFormatKHR> &supported) {
|
const std::vector<VkSurfaceFormatKHR> &supported) {
|
||||||
for (const auto &option : supported) {
|
for (const auto &option : supported) {
|
||||||
@ -203,6 +204,7 @@ VkSurfaceFormatKHR SwapChain::chooseSurfaceFormat(
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-convert-member-functions-to-static): future-proofing
|
||||||
bool SwapChain::isTripleBufferingSupported(
|
bool SwapChain::isTripleBufferingSupported(
|
||||||
const std::vector<VkPresentModeKHR> &supported) {
|
const std::vector<VkPresentModeKHR> &supported) {
|
||||||
return std::find(supported.begin(), supported.end(),
|
return std::find(supported.begin(), supported.end(),
|
||||||
@ -220,13 +222,15 @@ SwapChain::choosePresentMode(const std::vector<VkPresentModeKHR> &supported,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VkExtent2D
|
VkExtent2D
|
||||||
|
// NOLINTNEXTLINE(readability-convert-member-functions-to-static): future-proofing
|
||||||
SwapChain::chooseExtent(const VkSurfaceCapabilitiesKHR &capabilities) {
|
SwapChain::chooseExtent(const VkSurfaceCapabilitiesKHR &capabilities) {
|
||||||
if (capabilities.currentExtent.width !=
|
if (capabilities.currentExtent.width !=
|
||||||
std::numeric_limits<uint32_t>::max()) {
|
std::numeric_limits<uint32_t>::max()) {
|
||||||
return capabilities.currentExtent;
|
return capabilities.currentExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width, height;
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
glfwGetFramebufferSize(getGLFWWindowHandle(), &width, &height);
|
glfwGetFramebufferSize(getGLFWWindowHandle(), &width, &height);
|
||||||
|
|
||||||
VkExtent2D actualExtent = {static_cast<uint32_t>(width),
|
VkExtent2D actualExtent = {static_cast<uint32_t>(width),
|
||||||
@ -243,7 +247,7 @@ SwapChain::chooseExtent(const VkSurfaceCapabilitiesKHR &capabilities) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SwapChain::destroy() {
|
void SwapChain::destroy() {
|
||||||
for (auto framebuffer : framebuffers) {
|
for (auto *framebuffer : framebuffers) {
|
||||||
vkDestroyFramebuffer(vulkan.getDevice(), framebuffer, nullptr);
|
vkDestroyFramebuffer(vulkan.getDevice(), framebuffer, nullptr);
|
||||||
}
|
}
|
||||||
framebuffers.clear();
|
framebuffers.clear();
|
||||||
@ -260,7 +264,7 @@ void SwapChain::destroy() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto colorBufferView : colorBufferViews) {
|
for (auto *colorBufferView : colorBufferViews) {
|
||||||
vkDestroyImageView(vulkan.getDevice(), colorBufferView, nullptr);
|
vkDestroyImageView(vulkan.getDevice(), colorBufferView, nullptr);
|
||||||
}
|
}
|
||||||
colorBufferViews.clear();
|
colorBufferViews.clear();
|
||||||
@ -272,9 +276,8 @@ void SwapChain::destroy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SwapChain::SwapChain(Vulkan &vulkan)
|
SwapChain::SwapChain(Vulkan &vulkan)
|
||||||
: vk(VK_NULL_HANDLE), colorBuffer(nullptr),
|
: vk(VK_NULL_HANDLE), colorBuffer(nullptr), extent{0, 0},
|
||||||
colorBufferViews(), extent{0, 0}, depthBuffer(nullptr), framebuffers(),
|
depthBuffer(nullptr), vulkan(vulkan) {
|
||||||
vulkan(vulkan) {
|
|
||||||
auto details =
|
auto details =
|
||||||
querySwapChainSupport(vulkan.getPhysicalDevice().getVk(), vulkan);
|
querySwapChainSupport(vulkan.getPhysicalDevice().getVk(), vulkan);
|
||||||
auto surfaceFormat = chooseSurfaceFormat(details.formats);
|
auto surfaceFormat = chooseSurfaceFormat(details.formats);
|
||||||
@ -291,7 +294,7 @@ SwapChain::SwapChain(Vulkan &vulkan)
|
|||||||
VK_ATTACHMENT_LOAD_OP_CLEAR,
|
VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||||
VK_ATTACHMENT_STORE_OP_STORE,
|
VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
|
|
||||||
{{{0.0f, 0.0f, 0.0f, 1.0f}}},
|
{{{0.0F, 0.0F, 0.0F, 1.0F}}},
|
||||||
|
|
||||||
std::make_unique<Image>(static_cast<VkImage>(VK_NULL_HANDLE),
|
std::make_unique<Image>(static_cast<VkImage>(VK_NULL_HANDLE),
|
||||||
static_cast<VkImageView>(VK_NULL_HANDLE),
|
static_cast<VkImageView>(VK_NULL_HANDLE),
|
||||||
|
@ -16,7 +16,8 @@ Checks: "-*,\
|
|||||||
-readability-use-anyofallof,\
|
-readability-use-anyofallof,\
|
||||||
-cppcoreguidelines-pro-bounds-pointer-arithmetic,\
|
-cppcoreguidelines-pro-bounds-pointer-arithmetic,\
|
||||||
-performance-trivially-destructible,\
|
-performance-trivially-destructible,\
|
||||||
-modernize-make-unique"
|
-modernize-make-unique,\
|
||||||
|
-cppcoreguidelines-prefer-member-initializer"
|
||||||
|
|
||||||
# modernize-use-trailing-return-type
|
# modernize-use-trailing-return-type
|
||||||
# ignore reason: reduces readability
|
# ignore reason: reduces readability
|
||||||
@ -59,3 +60,6 @@ Checks: "-*,\
|
|||||||
# std::unique_ptr<S>(new S { 1, 2 }) // works
|
# std::unique_ptr<S>(new S { 1, 2 }) // works
|
||||||
# std::make_unique<S>(1, 2) // error
|
# std::make_unique<S>(1, 2) // error
|
||||||
# std::make_unique<S>({1, 2}) // error
|
# std::make_unique<S>({1, 2}) // error
|
||||||
|
|
||||||
|
# cppcoreguidelines-prefer-member-initializer
|
||||||
|
# ignore reason: rule fails to notice execution order dependencies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user