Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fleroviux committed Apr 6, 2024
1 parent 34bc4fb commit 1361400
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/next/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(SOURCES
)

set(HEADERS
src/renderer2/render_backend/vulkan/render_backend.cpp
src/renderer2/backend/vulkan/render_backend.cpp
src/shader/triangle.frag.h
src/shader/triangle.vert.h
src/main_window.hpp
Expand Down
29 changes: 12 additions & 17 deletions app/next/src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ namespace zephyr {
required_extension_names.resize(extension_count);
SDL_Vulkan_GetInstanceExtensions(m_window, &extension_count, required_extension_names.data());

// TODO(fleroviux): add error handling
m_vk_instance = VulkanInstance::Create(app_info, required_extension_names, {"VK_LAYER_KHRONOS_validation"});
}

Expand All @@ -108,32 +107,28 @@ namespace zephyr {
}

void MainWindow::CreateLogicalDevice() {
// This is pretty much the same logic that we also used for instance layers
std::vector<const char*> device_layers{};
{
if(enable_validation_layers) {
const auto validation_layer_name = "VK_LAYER_KHRONOS_validation";
std::vector<const char*> required_device_layers{};

if(m_vk_physical_device->QueryDeviceLayerSupport(validation_layer_name)) {
device_layers.push_back(validation_layer_name);
} else {
ZEPHYR_WARN("Could not enable device validation layer");
}
if(enable_validation_layers) {
const auto validation_layer_name = "VK_LAYER_KHRONOS_validation";

if(m_vk_physical_device->QueryDeviceLayerSupport(validation_layer_name)) {
required_device_layers.push_back(validation_layer_name);
} else {
ZEPHYR_WARN("Could not enable device validation layer");
}
}

std::vector<const char*> required_extensions{
"VK_KHR_swapchain"
};
std::vector<const char*> required_device_extensions{"VK_KHR_swapchain"};

for(auto extension_name : required_extensions) {
for(auto extension_name : required_device_extensions) {
if(!m_vk_physical_device->QueryDeviceExtensionSupport(extension_name)) {
ZEPHYR_PANIC("Could not find device extension: {}", extension_name);
}
}

if(m_vk_physical_device->QueryDeviceExtensionSupport("VK_KHR_portability_subset")) {
required_extensions.push_back("VK_KHR_portability_subset");
required_device_extensions.push_back("VK_KHR_portability_subset");
}

std::optional<u32> graphics_plus_compute_queue_family_index;
Expand Down Expand Up @@ -236,7 +231,7 @@ namespace zephyr {
}
}

m_vk_device = m_vk_physical_device->CreateLogicalDevice(queue_create_infos, required_extensions);
m_vk_device = m_vk_physical_device->CreateLogicalDevice(queue_create_infos, required_device_extensions);

vkGetDeviceQueue(m_vk_device, graphics_plus_compute_queue_family_index.value(), 0u, &m_vk_graphics_compute_queue);

Expand Down
File renamed without changes.

0 comments on commit 1361400

Please sign in to comment.