create imgae views
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
Swapchain::Swapchain(Device* device) : device_(device) {
|
Swapchain::Swapchain(Device* device) : device_(device) {
|
||||||
|
|
||||||
(void)createSwapchain();
|
(void)createSwapchain();
|
||||||
|
(void)createImageViews();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ bool Swapchain::createSwapchain() {
|
|||||||
swapchainCreateInfo.oldSwapchain = nullptr;
|
swapchainCreateInfo.oldSwapchain = nullptr;
|
||||||
|
|
||||||
vkSwapchain_ = vk::raii::SwapchainKHR(*logicalDevice, swapchainCreateInfo);
|
vkSwapchain_ = vk::raii::SwapchainKHR(*logicalDevice, swapchainCreateInfo);
|
||||||
swapchainImages_ = vkSwapchain_.getImages();
|
images_ = vkSwapchain_.getImages();
|
||||||
|
|
||||||
if(vkSwapchain_ == nullptr) {
|
if(vkSwapchain_ == nullptr) {
|
||||||
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Error: could not create the Vulkan Swapchain!" << std::endl;
|
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Error: could not create the Vulkan Swapchain!" << std::endl;
|
||||||
@@ -118,3 +119,24 @@ uint32_t Swapchain::chooseMinImageCount(vk::SurfaceCapabilitiesKHR const& capabi
|
|||||||
return minImageCount;
|
return minImageCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Swapchain::createImageViews() {
|
||||||
|
|
||||||
|
if(!imageViews_.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vk::ImageViewCreateInfo imageViewCreateInfo {
|
||||||
|
.viewType = vk::ImageViewType::e2D,
|
||||||
|
.format = surfaceFormat_.format,
|
||||||
|
.components = { vk::ComponentSwizzle::eIdentity, vk::ComponentSwizzle::eIdentity, vk::ComponentSwizzle::eIdentity, vk::ComponentSwizzle::eIdentity }, // default rgba
|
||||||
|
.subresourceRange = { vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1}, // aspect mask, baseMipLevel, levelCount, baseArrayLayer, layerCount
|
||||||
|
};
|
||||||
|
|
||||||
|
for(vk::Image &image : images_) {
|
||||||
|
imageViewCreateInfo.image = image;
|
||||||
|
imageViews_.emplace_back(*(device_->logicalDevice()), imageViewCreateInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ class Swapchain {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
vk::raii::SwapchainKHR vkSwapchain_ = nullptr;
|
vk::raii::SwapchainKHR vkSwapchain_ = nullptr;
|
||||||
std::vector<vk::Image> swapchainImages_;
|
std::vector<vk::Image> images_;
|
||||||
|
std::vector<vk::raii::ImageView> imageViews_;
|
||||||
|
|
||||||
Device* device_ = nullptr;
|
Device* device_ = nullptr;
|
||||||
vk::SurfaceFormatKHR surfaceFormat_;
|
vk::SurfaceFormatKHR surfaceFormat_;
|
||||||
@@ -29,4 +30,6 @@ class Swapchain {
|
|||||||
uint32_t chooseMinImageCount(vk::SurfaceCapabilitiesKHR const& capabilities);
|
uint32_t chooseMinImageCount(vk::SurfaceCapabilitiesKHR const& capabilities);
|
||||||
|
|
||||||
bool createSwapchain();
|
bool createSwapchain();
|
||||||
|
bool createImageViews();
|
||||||
|
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user