Working ... uh sort of .. on Windows now to try on Linux.
This commit is contained in:
parent
a5c13d8654
commit
8f679dbe65
6 changed files with 66 additions and 37 deletions
5
README.md
Normal file
5
README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Notes
|
||||||
|
|
||||||
|
Currently running list of notes I need to remember for the README later:
|
||||||
|
|
||||||
|
* Running vulkaninfoSDK.exe gives you information about the GPU but no libraries.
|
||||||
15
main.cpp
15
main.cpp
|
|
@ -1,15 +1,16 @@
|
||||||
#include <vk_engine.h>
|
#include <vk_engine.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <format>
|
||||||
|
|
||||||
int main()
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
auto engine = std::make_unique<VulkanEngine>();
|
auto engine = std::make_unique<VulkanEngine>();
|
||||||
|
|
||||||
engine->init();
|
engine->init();
|
||||||
|
|
||||||
engine->run();
|
|
||||||
|
|
||||||
engine->cleanup();
|
engine->run();
|
||||||
|
|
||||||
return 0;
|
engine->cleanup();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
32
meson.build
32
meson.build
|
|
@ -30,16 +30,22 @@ if build_machine.system() == 'windows'
|
||||||
'-static-libgcc',
|
'-static-libgcc',
|
||||||
'-static-libstdc++',
|
'-static-libstdc++',
|
||||||
'-static',
|
'-static',
|
||||||
|
'-lstdc++exp',
|
||||||
language: 'cpp',
|
language: 'cpp',
|
||||||
)
|
)
|
||||||
|
|
||||||
sdl2_main = subproject('sld2').get_variable('sdl2_main')
|
|
||||||
opengl32 = cc.find_library('opengl32', required: true)
|
|
||||||
winmm = cc.find_library('winmm', required: true)
|
winmm = cc.find_library('winmm', required: true)
|
||||||
gdi32 = cc.find_library('gdi32', required: true)
|
gdi32 = cc.find_library('gdi32', required: true)
|
||||||
|
|
||||||
|
vulkan_inc = include_directories('C:/VulkanSDK/1.4.328.1/Include')
|
||||||
|
vulkan = cc.find_library('vulkan-1',
|
||||||
|
dirs: ['C:/VulkanSDK/1.4.328.1/Lib'],
|
||||||
|
has_headers: ['vulkan/vulkan.h'],
|
||||||
|
header_include_directories: [vulkan_inc],
|
||||||
|
required: true)
|
||||||
|
|
||||||
dependencies += [
|
dependencies += [
|
||||||
opengl32, winmm, gdi32, sdl2_main
|
winmm, gdi32, vulkan
|
||||||
]
|
]
|
||||||
exe_defaults += ['werror=true']
|
exe_defaults += ['werror=true']
|
||||||
|
|
||||||
|
|
@ -63,6 +69,7 @@ elif build_machine.system() == 'darwin'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
vma = subproject('vulkan-memory-allocator').get_variable('vma_allocator_dep')
|
vma = subproject('vulkan-memory-allocator').get_variable('vma_allocator_dep')
|
||||||
|
# vulkan_headers = subproject('vulkan-headers').get_variable('vulkan_headers_dep')
|
||||||
imgui = subproject('imgui').get_variable('imgui_dep')
|
imgui = subproject('imgui').get_variable('imgui_dep')
|
||||||
sdl2 = subproject('sdl2').get_variable('sdl2_dep')
|
sdl2 = subproject('sdl2').get_variable('sdl2_dep')
|
||||||
|
|
||||||
|
|
@ -76,10 +83,20 @@ glm = glm_proj.get_variable('glm_dep')
|
||||||
|
|
||||||
|
|
||||||
vk_opts = cmake.subproject_options()
|
vk_opts = cmake.subproject_options()
|
||||||
vk_opts.add_cmake_defines({
|
|
||||||
'VK_BOOTSTRAP_TEST': false,
|
if build_machine.system() == 'windows'
|
||||||
'VK_BOOTSTRAP_INSTALL': false,
|
vk_opts.add_cmake_defines({
|
||||||
})
|
'VK_BOOTSTRAP_TEST': false,
|
||||||
|
'VK_BOOTSTRAP_INSTALL': false,
|
||||||
|
'VK_BOOTSTRAP_VULKAN_HEADER_DIR': 'C:/VulkanSDK/1.4.328.1/Include'
|
||||||
|
})
|
||||||
|
else
|
||||||
|
vk_opts.add_cmake_defines({
|
||||||
|
'VK_BOOTSTRAP_TEST': false,
|
||||||
|
'VK_BOOTSTRAP_INSTALL': false,
|
||||||
|
})
|
||||||
|
endif
|
||||||
|
|
||||||
vkbootstrap_proj = cmake.subproject('vk-bootstrap', options: vk_opts)
|
vkbootstrap_proj = cmake.subproject('vk-bootstrap', options: vk_opts)
|
||||||
vkbootstrap = vkbootstrap_proj.get_variable('vk_bootstrap_dep')
|
vkbootstrap = vkbootstrap_proj.get_variable('vk_bootstrap_dep')
|
||||||
|
|
||||||
|
|
@ -106,5 +123,6 @@ tests = [
|
||||||
executable('hellovulk', sources,
|
executable('hellovulk', sources,
|
||||||
cpp_args: cpp_args,
|
cpp_args: cpp_args,
|
||||||
link_args: link_args,
|
link_args: link_args,
|
||||||
|
win_subsystem: 'windows',
|
||||||
override_options: exe_defaults,
|
override_options: exe_defaults,
|
||||||
dependencies: dependencies)
|
dependencies: dependencies)
|
||||||
|
|
|
||||||
7
scripts/reset_build.ps1
Normal file
7
scripts/reset_build.ps1
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
mv .\subprojects\packagecache .
|
||||||
|
rm -recurse -force .\subprojects\,.\builddir\
|
||||||
|
mkdir subprojects
|
||||||
|
mv .\packagecache .\subprojects\
|
||||||
|
mkdir builddir
|
||||||
|
cp wraps\*.wrap subprojects\
|
||||||
|
meson setup --default-library=static --prefer-static builddir
|
||||||
|
|
@ -20,7 +20,7 @@ constexpr bool bUseValidationLayers = true;
|
||||||
|
|
||||||
VulkanEngine* loadedEngine = nullptr;
|
VulkanEngine* loadedEngine = nullptr;
|
||||||
|
|
||||||
VulkanEngine& VulkanEngine::Get() {
|
VulkanEngine& VulkanEngine::Get() {
|
||||||
return *loadedEngine;
|
return *loadedEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ void VulkanEngine::init()
|
||||||
assert(loadedEngine == nullptr);
|
assert(loadedEngine == nullptr);
|
||||||
loadedEngine = this;
|
loadedEngine = this;
|
||||||
|
|
||||||
// We initialize SDL and create a window with it.
|
// We initialize SDL and create a window with it.
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN);
|
||||||
|
|
@ -54,7 +54,7 @@ void VulkanEngine::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanEngine::cleanup()
|
void VulkanEngine::cleanup()
|
||||||
{
|
{
|
||||||
if (_isInitialized) {
|
if (_isInitialized) {
|
||||||
vkDeviceWaitIdle(_device);
|
vkDeviceWaitIdle(_device);
|
||||||
|
|
||||||
|
|
@ -123,16 +123,16 @@ void VulkanEngine::draw()
|
||||||
|
|
||||||
VK_CHECK(vkEndCommandBuffer(cmd));
|
VK_CHECK(vkEndCommandBuffer(cmd));
|
||||||
|
|
||||||
//prepare the submission to the queue.
|
//prepare the submission to the queue.
|
||||||
//we want to wait on the _presentSemaphore, as that semaphore is signaled when the swapchain is ready
|
//we want to wait on the _presentSemaphore, as that semaphore is signaled when the swapchain is ready
|
||||||
//we will signal the _renderSemaphore, to signal that rendering has finished
|
//we will signal the _renderSemaphore, to signal that rendering has finished
|
||||||
|
|
||||||
VkCommandBufferSubmitInfo cmdinfo = vkinit::command_buffer_submit_info(cmd);
|
VkCommandBufferSubmitInfo cmdinfo = vkinit::command_buffer_submit_info(cmd);
|
||||||
|
|
||||||
VkSemaphoreSubmitInfo waitInfo = vkinit::semaphore_submit_info(VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR,get_current_frame()._swapchainSemaphore);
|
VkSemaphoreSubmitInfo waitInfo = vkinit::semaphore_submit_info(VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR,get_current_frame()._swapchainSemaphore);
|
||||||
VkSemaphoreSubmitInfo signalInfo = vkinit::semaphore_submit_info(VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, get_current_frame()._renderSemaphore);
|
VkSemaphoreSubmitInfo signalInfo = vkinit::semaphore_submit_info(VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT, get_current_frame()._renderSemaphore);
|
||||||
|
|
||||||
VkSubmitInfo2 submit = vkinit::submit_info(&cmdinfo,&signalInfo,&waitInfo);
|
VkSubmitInfo2 submit = vkinit::submit_info(&cmdinfo,&signalInfo,&waitInfo);
|
||||||
|
|
||||||
//submit command buffer to the queue and execute it.
|
//submit command buffer to the queue and execute it.
|
||||||
// _renderFence will now block until the graphic commands finish execution
|
// _renderFence will now block until the graphic commands finish execution
|
||||||
|
|
@ -140,7 +140,7 @@ void VulkanEngine::draw()
|
||||||
|
|
||||||
//prepare present
|
//prepare present
|
||||||
// this will put the image we just rendered to into the visible window.
|
// this will put the image we just rendered to into the visible window.
|
||||||
// we want to wait on the _renderSemaphore for that,
|
// we want to wait on the _renderSemaphore for that,
|
||||||
// as its necessary that drawing commands have finished before the image is displayed to the user
|
// as its necessary that drawing commands have finished before the image is displayed to the user
|
||||||
VkPresentInfoKHR presentInfo = {};
|
VkPresentInfoKHR presentInfo = {};
|
||||||
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
|
|
@ -171,7 +171,7 @@ void VulkanEngine::run()
|
||||||
//Handle events on queue
|
//Handle events on queue
|
||||||
while(SDL_PollEvent(&e) != 0)
|
while(SDL_PollEvent(&e) != 0)
|
||||||
{
|
{
|
||||||
//close the window when user alt-f4s or clicks the X button
|
//close the window when user alt-f4s or clicks the X button
|
||||||
if(e.type == SDL_QUIT) {
|
if(e.type == SDL_QUIT) {
|
||||||
bQuit = true;
|
bQuit = true;
|
||||||
}
|
}
|
||||||
|
|
@ -216,11 +216,11 @@ void VulkanEngine::init_vulkan() {
|
||||||
SDL_Vulkan_CreateSurface(_window, _instance, &_surface);
|
SDL_Vulkan_CreateSurface(_window, _instance, &_surface);
|
||||||
|
|
||||||
//vulkan 1.3 features
|
//vulkan 1.3 features
|
||||||
VkPhysicalDeviceVulkan13Features features{};
|
VkPhysicalDeviceVulkan13Features features13{};
|
||||||
|
|
||||||
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
|
features13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
|
||||||
features.dynamicRendering = true;
|
features13.dynamicRendering = true;
|
||||||
features.synchronization2 = true;
|
features13.synchronization2 = true;
|
||||||
|
|
||||||
//vulkan 1.2 features
|
//vulkan 1.2 features
|
||||||
VkPhysicalDeviceVulkan12Features features12{};
|
VkPhysicalDeviceVulkan12Features features12{};
|
||||||
|
|
@ -231,9 +231,9 @@ void VulkanEngine::init_vulkan() {
|
||||||
// use vkbootstrap to select a gpu
|
// use vkbootstrap to select a gpu
|
||||||
// We want a gpu that can write to the SDL surface
|
// We want a gpu that can write to the SDL surface
|
||||||
vkb::PhysicalDeviceSelector selector{ vkb_inst };
|
vkb::PhysicalDeviceSelector selector{ vkb_inst };
|
||||||
vkb::PhysicalDevice physicalDevice = selector
|
auto physicalDevice = selector
|
||||||
.set_minimum_version(1, 4)
|
.set_minimum_version(1, 3)
|
||||||
.set_required_features_13(features)
|
.set_required_features_13(features13)
|
||||||
.set_required_features_12(features12)
|
.set_required_features_12(features12)
|
||||||
.set_surface(_surface)
|
.set_surface(_surface)
|
||||||
.select()
|
.select()
|
||||||
|
|
@ -263,7 +263,7 @@ void VulkanEngine::init_vulkan() {
|
||||||
|
|
||||||
void VulkanEngine::create_swapchain(uint32_t width, uint32_t height) {
|
void VulkanEngine::create_swapchain(uint32_t width, uint32_t height) {
|
||||||
vkb::SwapchainBuilder swapchainBuilder{ _chosenGPU, _device, _surface};
|
vkb::SwapchainBuilder swapchainBuilder{ _chosenGPU, _device, _surface};
|
||||||
|
|
||||||
_swapchainImageFormat = VK_FORMAT_B8G8R8A8_UNORM;
|
_swapchainImageFormat = VK_FORMAT_B8G8R8A8_UNORM;
|
||||||
VkSurfaceFormatKHR surfaceFormat{};
|
VkSurfaceFormatKHR surfaceFormat{};
|
||||||
surfaceFormat.format=_swapchainImageFormat;
|
surfaceFormat.format=_swapchainImageFormat;
|
||||||
|
|
@ -373,8 +373,8 @@ void VulkanEngine::draw_background(VkCommandBuffer cmd)
|
||||||
|
|
||||||
|
|
||||||
void VulkanEngine::init_descriptors() {
|
void VulkanEngine::init_descriptors() {
|
||||||
std::vector<DescriptorAllocator::PoolSizeRatio> sizes =
|
std::vector<DescriptorAllocator::PoolSizeRatio> sizes =
|
||||||
{
|
{
|
||||||
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1 }
|
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -389,7 +389,7 @@ void VulkanEngine::init_descriptors() {
|
||||||
|
|
||||||
// other code
|
// other code
|
||||||
//allocate a descriptor set for our draw image
|
//allocate a descriptor set for our draw image
|
||||||
_drawImageDescriptors = globalDescriptorAllocator.allocate(_device,_drawImageDescriptorLayout);
|
_drawImageDescriptors = globalDescriptorAllocator.allocate(_device,_drawImageDescriptorLayout);
|
||||||
|
|
||||||
VkDescriptorImageInfo imgInfo{};
|
VkDescriptorImageInfo imgInfo{};
|
||||||
imgInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
imgInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
|
|
@ -442,7 +442,7 @@ void VulkanEngine::init_background_pipelines()
|
||||||
stageinfo.stage = VK_SHADER_STAGE_COMPUTE_BIT;
|
stageinfo.stage = VK_SHADER_STAGE_COMPUTE_BIT;
|
||||||
stageinfo.module = computeDrawShader;
|
stageinfo.module = computeDrawShader;
|
||||||
stageinfo.pName = "main";
|
stageinfo.pName = "main";
|
||||||
|
|
||||||
VkComputePipelineCreateInfo computePipelineCreateInfo{};
|
VkComputePipelineCreateInfo computePipelineCreateInfo{};
|
||||||
computePipelineCreateInfo.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
|
computePipelineCreateInfo.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
|
||||||
computePipelineCreateInfo.pNext = nullptr;
|
computePipelineCreateInfo.pNext = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
|
||||||
// #include <vulkan/vk_enum_string_helper.h>
|
// #include <vulkan/vk_enum_string_helper.h>
|
||||||
#include <vk_mem_alloc.h>
|
#include <vk_mem_alloc.h>
|
||||||
|
|
||||||
|
|
@ -38,4 +37,3 @@ struct AllocatedImage {
|
||||||
VkExtent3D imageExtent;
|
VkExtent3D imageExtent;
|
||||||
VkFormat imageFormat;
|
VkFormat imageFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue