From 0d15d7954aae003c0d004d3d740ff2e501401c7b Mon Sep 17 00:00:00 2001 From: David OK Date: Thu, 30 Nov 2023 13:20:11 +0000 Subject: [PATCH] MAINT: refactor code. --- cpp/examples/Shakti/Vulkan/CMakeLists.txt | 1 + .../Shakti/Vulkan/Common/CMakeLists.txt | 5 + .../Shakti/Vulkan/Common/HostUniforms.hpp | 18 ++ .../Shakti/Vulkan/Common/SignalHandler.cpp | 10 + .../Shakti/Vulkan/Common/SignalHandler.hpp | 39 ++++ .../Vulkan/hello_vulkan_image/CMakeLists.txt | 31 +-- .../Shakti/Vulkan/hello_vulkan_image/main.cpp | 187 +++++++++--------- .../hello_vulkan_triangle/CMakeLists.txt | 3 +- .../Vulkan/hello_vulkan_triangle/main.cpp | 67 +------ cpp/src/DO/Shakti/Vulkan/GraphicsPipeline.hpp | 79 +++----- .../Vulkan/test_vulkan_graphics_pipeline.cpp | 4 +- 11 files changed, 232 insertions(+), 212 deletions(-) create mode 100644 cpp/examples/Shakti/Vulkan/Common/CMakeLists.txt create mode 100644 cpp/examples/Shakti/Vulkan/Common/HostUniforms.hpp create mode 100644 cpp/examples/Shakti/Vulkan/Common/SignalHandler.cpp create mode 100644 cpp/examples/Shakti/Vulkan/Common/SignalHandler.hpp diff --git a/cpp/examples/Shakti/Vulkan/CMakeLists.txt b/cpp/examples/Shakti/Vulkan/CMakeLists.txt index f7cb00cc2..ba9cffc69 100644 --- a/cpp/examples/Shakti/Vulkan/CMakeLists.txt +++ b/cpp/examples/Shakti/Vulkan/CMakeLists.txt @@ -1,2 +1,3 @@ +add_subdirectory(Common) add_subdirectory(hello_vulkan_triangle) add_subdirectory(hello_vulkan_image) diff --git a/cpp/examples/Shakti/Vulkan/Common/CMakeLists.txt b/cpp/examples/Shakti/Vulkan/Common/CMakeLists.txt new file mode 100644 index 000000000..04aaf99be --- /dev/null +++ b/cpp/examples/Shakti/Vulkan/Common/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library( + SignalHandler # + HostUniforms.hpp # + SignalHandler.hpp SignalHandler.cpp) +target_include_directories(SignalHandler PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..) diff --git a/cpp/examples/Shakti/Vulkan/Common/HostUniforms.hpp b/cpp/examples/Shakti/Vulkan/Common/HostUniforms.hpp new file mode 100644 index 000000000..600b1c47a --- /dev/null +++ b/cpp/examples/Shakti/Vulkan/Common/HostUniforms.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include + + +struct ModelViewProjectionStack +{ + ModelViewProjectionStack() + { + model.setIdentity(); + view.setIdentity(); + projection.setIdentity(); + } + + Eigen::Transform model; + Eigen::Transform view; + Eigen::Transform projection; +}; diff --git a/cpp/examples/Shakti/Vulkan/Common/SignalHandler.cpp b/cpp/examples/Shakti/Vulkan/Common/SignalHandler.cpp new file mode 100644 index 000000000..afa5e6ea1 --- /dev/null +++ b/cpp/examples/Shakti/Vulkan/Common/SignalHandler.cpp @@ -0,0 +1,10 @@ +#pragma once + +#include "SignalHandler.hpp" + + +bool SignalHandler::initialized = false; +std::atomic_bool SignalHandler::ctrl_c_hit = false; +#if !defined(_WIN32) +struct sigaction SignalHandler::sigint_handler = {}; +#endif diff --git a/cpp/examples/Shakti/Vulkan/Common/SignalHandler.hpp b/cpp/examples/Shakti/Vulkan/Common/SignalHandler.hpp new file mode 100644 index 000000000..b99e79c69 --- /dev/null +++ b/cpp/examples/Shakti/Vulkan/Common/SignalHandler.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include + +#include +#include + + +struct SignalHandler +{ + static bool initialized; + static std::atomic_bool ctrl_c_hit; + static struct sigaction sigint_handler; + + static auto stop_render_loop(int) -> void + { + std::cout << "[CTRL+C HIT] Preparing to close the program!" << std::endl; + ctrl_c_hit = true; + } + + static auto init() -> void + { + if (initialized) + return; + +#if defined(_WIN32) + signal(SIGINT, stop_render_loop); + signal(SIGTERM, stop_render_loop); + signal(SIGABRT, stop_render_loop); +#else + sigint_handler.sa_handler = SignalHandler::stop_render_loop; + sigemptyset(&sigint_handler.sa_mask); + sigint_handler.sa_flags = 0; + sigaction(SIGINT, &sigint_handler, nullptr); +#endif + + initialized = true; + } +}; diff --git a/cpp/examples/Shakti/Vulkan/hello_vulkan_image/CMakeLists.txt b/cpp/examples/Shakti/Vulkan/hello_vulkan_image/CMakeLists.txt index eb7c03e57..9fbc05ed0 100644 --- a/cpp/examples/Shakti/Vulkan/hello_vulkan_image/CMakeLists.txt +++ b/cpp/examples/Shakti/Vulkan/hello_vulkan_image/CMakeLists.txt @@ -1,20 +1,25 @@ add_executable(hello_vulkan_image main.cpp) target_link_libraries( - hello_vulkan_image # - PRIVATE DO::Sara::Core # + hello_vulkan_image + PRIVATE SignalHandler # + DO::Sara::Core # DO::Shakti::Vulkan) -set_target_properties(hello_vulkan_image PROPERTIES FOLDER "Examples/Shakti/Vulkan") +set_target_properties(hello_vulkan_image PROPERTIES FOLDER + "Examples/Shakti/Vulkan") add_custom_target(compile_hello_vulkan_image_shaders) -set_target_properties(compile_hello_vulkan_image_shaders PROPERTIES FOLDER "Examples/Shakti/Vulkan") +set_target_properties(compile_hello_vulkan_image_shaders + PROPERTIES FOLDER "Examples/Shakti/Vulkan") add_custom_command( TARGET compile_hello_vulkan_image_shaders COMMAND ${CMAKE_COMMAND} -E make_directory $/hello_vulkan_image_shaders - COMMAND ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert -o - $/hello_vulkan_image_shaders/vert.spv - COMMAND ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag -o - $/hello_vulkan_image_shaders/frag.spv) + COMMAND + ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert -o + $/hello_vulkan_image_shaders/vert.spv + COMMAND + ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag -o + $/hello_vulkan_image_shaders/frag.spv) # file(GLOB SHADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.vert *.frag) add_custom_command( @@ -22,7 +27,9 @@ add_custom_command( PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory $/hello_vulkan_image_shaders - COMMAND ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert -o - $/hello_vulkan_image_shaders/vert.spv - COMMAND ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag -o - $/hello_vulkan_image_shaders/frag.spv) + COMMAND + ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert -o + $/hello_vulkan_image_shaders/vert.spv + COMMAND + ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag -o + $/hello_vulkan_image_shaders/frag.spv) diff --git a/cpp/examples/Shakti/Vulkan/hello_vulkan_image/main.cpp b/cpp/examples/Shakti/Vulkan/hello_vulkan_image/main.cpp index f855960f7..a33bb2616 100644 --- a/cpp/examples/Shakti/Vulkan/hello_vulkan_image/main.cpp +++ b/cpp/examples/Shakti/Vulkan/hello_vulkan_image/main.cpp @@ -11,6 +11,11 @@ #define GLFW_INCLUDE_VULKAN +#include "Geometry.hpp" + +#include "Common/HostUniforms.hpp" +#include "Common/SignalHandler.hpp" + #include #include #include @@ -22,15 +27,10 @@ #include -#include - -#include #include #include #include -#include "Geometry.hpp" - namespace glfw = DO::Kalpana::GLFW; namespace kvk = DO::Kalpana::Vulkan; @@ -38,59 +38,6 @@ namespace svk = DO::Shakti::Vulkan; namespace fs = std::filesystem; -struct SignalHandler -{ - static bool initialized; - static std::atomic_bool ctrl_c_hit; - static struct sigaction sigint_handler; - - static auto stop_render_loop(int) -> void - { - std::cout << "[CTRL+C HIT] Preparing to close the program!" << std::endl; - ctrl_c_hit = true; - } - - static auto init() -> void - { - if (initialized) - return; - -#if defined(_WIN32) - signal(SIGINT, stop_render_loop); - signal(SIGTERM, stop_render_loop); - signal(SIGABRT, stop_render_loop); -#else - sigint_handler.sa_handler = SignalHandler::stop_render_loop; - sigemptyset(&sigint_handler.sa_mask); - sigint_handler.sa_flags = 0; - sigaction(SIGINT, &sigint_handler, nullptr); -#endif - - initialized = true; - } -}; - -bool SignalHandler::initialized = false; -std::atomic_bool SignalHandler::ctrl_c_hit = false; -#if !defined(_WIN32) -struct sigaction SignalHandler::sigint_handler = {}; -#endif - - -struct ModelViewProjectionStack -{ - ModelViewProjectionStack() - { - model.setIdentity(); - view.setIdentity(); - projection.setIdentity(); - } - - Eigen::Transform model; - Eigen::Transform view; - Eigen::Transform projection; -}; - // clang-format off static const auto vertices = std::vector{ {{-0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}, {0.f, 0.f}}, @@ -106,6 +53,95 @@ static const auto indices = std::vector{ }; +class VulkanImagePipelineBuilder : public kvk::GraphicsPipeline::Builder +{ +public: + auto create() -> kvk::GraphicsPipeline override + { + load_shaders(); + initialize_fixed_functions(); + + auto graphics_pipeline = kvk::GraphicsPipeline{}; + + graphics_pipeline.device = device; + + graphics_pipeline.desc_set_layout = + svk::DescriptorSetLayout::Builder{device} + .push_uniform_buffer_layout_binding() + .push_image_sampler_layout_binding() + .create(); + + // Initialize the graphics pipeline layout. + SARA_DEBUG << "Initializing the graphics pipeline layout...\n"; + pipeline_layout_info = VkPipelineLayoutCreateInfo{}; + { + pipeline_layout_info.sType = + VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; + pipeline_layout_info.setLayoutCount = 1; + pipeline_layout_info.pSetLayouts = &static_cast( + graphics_pipeline.desc_set_layout); + pipeline_layout_info.pushConstantRangeCount = 0; + }; + auto status = vkCreatePipelineLayout( // + device, // + &pipeline_layout_info, // + nullptr, // + &graphics_pipeline.pipeline_layout // + ); + if (status != VK_SUCCESS) + throw std::runtime_error{fmt::format( + "Failed to create the graphics pipeline layout! Error code: {}", + static_cast(status))}; + + // Initialize the graphics pipeline. + SARA_DEBUG << "Initializing the graphics pipeline...\n"; + pipeline_info = {}; + { + pipeline_info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + + // - Vertex and fragment shaders. + pipeline_info.stageCount = + static_cast(shader_stage_infos.size()); + pipeline_info.pStages = shader_stage_infos.data(); + + // - Vertex buffer data format. + pipeline_info.pVertexInputState = &vertex_input_info; + // - We enumerate triangle vertices. + pipeline_info.pInputAssemblyState = &input_assembly; + pipeline_info.pViewportState = &viewport_state; + + // The rasterization state. + pipeline_info.pRasterizationState = &rasterization_state; + + // Rendering policy. + pipeline_info.pMultisampleState = &multisampling; + pipeline_info.pColorBlendState = &color_blend; + + pipeline_info.layout = graphics_pipeline.pipeline_layout; + pipeline_info.renderPass = render_pass.handle; + pipeline_info.subpass = 0; + pipeline_info.basePipelineHandle = VK_NULL_HANDLE; + pipeline_info.basePipelineIndex = -1; + }; + + status = vkCreateGraphicsPipelines( // + device, // + VK_NULL_HANDLE, // + 1, // + &pipeline_info, // + nullptr, // + &graphics_pipeline.pipeline // + ); + if (status != VK_SUCCESS) + throw std::runtime_error{ + fmt::format("Failed to create graphics pipeline! Error code: {}", + static_cast(status))}; + + return graphics_pipeline; + } +}; + + class VulkanImageRenderer : public kvk::GraphicsBackend { public: @@ -130,7 +166,7 @@ class VulkanImageRenderer : public kvk::GraphicsBackend transfer_element_data_to_vulkan(indices); make_descriptor_pool(); - make_ubo_descriptor_sets(); + make_descriptor_sets(); initialize_model_view_projection_ubos(); } @@ -256,32 +292,7 @@ class VulkanImageRenderer : public kvk::GraphicsBackend _desc_pool = desc_pool_builder.create(); } - auto make_ubo_descriptor_sets() -> void - { - // The number of frames in flight is the number of swapchain images. - // Let's say there are 3 frames in flight. - // - // We will construct 3 sets of descriptors, that is, we need one for each - // swapchain image. - const auto num_frames_in_flight = - static_cast(_swapchain.images.size()); - - // Each descriptor set has the same uniform descriptor layout. - const auto& ubo_layout = _graphics_pipeline.descriptor_set_layout(); - const auto ubo_layout_handle = - static_cast(ubo_layout); - - const auto desc_set_layouts = std::vector( - num_frames_in_flight, ubo_layout_handle); - - _desc_sets = svk::DescriptorSets{ - desc_set_layouts.data(), // - num_frames_in_flight, // - _desc_pool // - }; - } - - auto make_image_descriptor_sets() -> void + auto make_descriptor_sets() -> void { // The number of frames in flight is the number of swapchain images. // Let's say there are 3 frames in flight. @@ -292,9 +303,9 @@ class VulkanImageRenderer : public kvk::GraphicsBackend static_cast(_swapchain.images.size()); // Each descriptor set has the same uniform descriptor layout. - const auto& ubo_layout = _graphics_pipeline.descriptor_set_layout(); + const auto& desc_set_layout = _graphics_pipeline.desc_set_layout; const auto ubo_layout_handle = - static_cast(ubo_layout); + static_cast(desc_set_layout); const auto desc_set_layouts = std::vector( num_frames_in_flight, ubo_layout_handle); @@ -631,7 +642,7 @@ class VulkanImageRenderer : public kvk::GraphicsBackend // Pass the UBO to the graphics pipeline. vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, - _graphics_pipeline.pipeline_layout(), // + _graphics_pipeline.pipeline_layout, // 0, 1, // Find out later about this. &descriptor_set, // 0, nullptr); // Find out later about this. diff --git a/cpp/examples/Shakti/Vulkan/hello_vulkan_triangle/CMakeLists.txt b/cpp/examples/Shakti/Vulkan/hello_vulkan_triangle/CMakeLists.txt index 73d50924a..503a24b70 100644 --- a/cpp/examples/Shakti/Vulkan/hello_vulkan_triangle/CMakeLists.txt +++ b/cpp/examples/Shakti/Vulkan/hello_vulkan_triangle/CMakeLists.txt @@ -2,7 +2,8 @@ add_executable(hello_vulkan_triangle main.cpp) target_link_libraries( hello_vulkan_triangle # PRIVATE DO::Sara::Core # - DO::Shakti::Vulkan) + DO::Shakti::Vulkan # + SignalHandler) set_target_properties(hello_vulkan_triangle PROPERTIES FOLDER "Examples/Shakti/Vulkan") diff --git a/cpp/examples/Shakti/Vulkan/hello_vulkan_triangle/main.cpp b/cpp/examples/Shakti/Vulkan/hello_vulkan_triangle/main.cpp index 1721a565b..c1ec5c24f 100644 --- a/cpp/examples/Shakti/Vulkan/hello_vulkan_triangle/main.cpp +++ b/cpp/examples/Shakti/Vulkan/hello_vulkan_triangle/main.cpp @@ -11,6 +11,11 @@ #define GLFW_INCLUDE_VULKAN +#include "Geometry.hpp" + +#include "Common/HostUniforms.hpp" +#include "Common/SignalHandler.hpp" + #include #include #include @@ -22,15 +27,10 @@ #include -#include - -#include #include #include #include -#include "Geometry.hpp" - namespace glfw = DO::Kalpana::GLFW; namespace kvk = DO::Kalpana::Vulkan; @@ -38,59 +38,6 @@ namespace svk = DO::Shakti::Vulkan; namespace fs = std::filesystem; -struct SignalHandler -{ - static bool initialized; - static std::atomic_bool ctrl_c_hit; - static struct sigaction sigint_handler; - - static auto stop_render_loop(int) -> void - { - std::cout << "[CTRL+C HIT] Preparing to close the program!" << std::endl; - ctrl_c_hit = true; - } - - static auto init() -> void - { - if (initialized) - return; - -#if defined(_WIN32) - signal(SIGINT, stop_render_loop); - signal(SIGTERM, stop_render_loop); - signal(SIGABRT, stop_render_loop); -#else - sigint_handler.sa_handler = SignalHandler::stop_render_loop; - sigemptyset(&sigint_handler.sa_mask); - sigint_handler.sa_flags = 0; - sigaction(SIGINT, &sigint_handler, nullptr); -#endif - - initialized = true; - } -}; - -bool SignalHandler::initialized = false; -std::atomic_bool SignalHandler::ctrl_c_hit = false; -#if !defined(_WIN32) -struct sigaction SignalHandler::sigint_handler = {}; -#endif - - -struct ModelViewProjectionStack -{ - ModelViewProjectionStack() - { - model.setIdentity(); - view.setIdentity(); - projection.setIdentity(); - } - - Eigen::Transform model; - Eigen::Transform view; - Eigen::Transform projection; -}; - // clang-format off static const auto vertices = std::vector{ {{-0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}}, @@ -261,7 +208,7 @@ class VulkanTriangleRenderer : public kvk::GraphicsBackend static_cast(_swapchain.images.size()); // Each descriptor set has the same uniform descriptor layout. - const auto& ubo_layout = _graphics_pipeline.descriptor_set_layout(); + const auto& ubo_layout = _graphics_pipeline.desc_set_layout; const auto ubo_layout_handle = static_cast(ubo_layout); @@ -600,7 +547,7 @@ class VulkanTriangleRenderer : public kvk::GraphicsBackend // Pass the UBO to the graphics pipeline. vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, - _graphics_pipeline.pipeline_layout(), // + _graphics_pipeline.pipeline_layout, // 0, 1, // Find out later about this. &descriptor_set, // 0, nullptr); // Find out later about this. diff --git a/cpp/src/DO/Shakti/Vulkan/GraphicsPipeline.hpp b/cpp/src/DO/Shakti/Vulkan/GraphicsPipeline.hpp index 4e209283b..eb7291ea2 100644 --- a/cpp/src/DO/Shakti/Vulkan/GraphicsPipeline.hpp +++ b/cpp/src/DO/Shakti/Vulkan/GraphicsPipeline.hpp @@ -28,13 +28,10 @@ namespace DO::Kalpana::Vulkan { //! - what vertex shader //! - what fragment shader //! we want to use. - class GraphicsPipeline + struct GraphicsPipeline { - public: - struct Builder; - friend struct Builder; + class Builder; - public: GraphicsPipeline() = default; GraphicsPipeline(const GraphicsPipeline&) = delete; @@ -54,61 +51,45 @@ namespace DO::Kalpana::Vulkan { ~GraphicsPipeline() { - if (_device == nullptr) + if (device == nullptr) return; - if (_pipeline_layout != nullptr) + if (pipeline_layout != nullptr) { SARA_DEBUG << "Destroying graphics pipeline layout...\n"; - vkDestroyPipelineLayout(_device, _pipeline_layout, nullptr); + vkDestroyPipelineLayout(device, pipeline_layout, nullptr); } - if (_pipeline != nullptr) + if (pipeline != nullptr) { SARA_DEBUG << "Destroying graphics pipeline...\n"; - vkDestroyPipeline(_device, _pipeline, nullptr); + vkDestroyPipeline(device, pipeline, nullptr); } } - auto device() const -> VkDevice - { - return _device; - } - - auto descriptor_set_layout() const - -> const Shakti::Vulkan::DescriptorSetLayout& - { - return _desc_set_layout; - } - - auto pipeline_layout() const -> VkPipelineLayout - { - return _pipeline_layout; - } - operator VkPipeline() const { - return _pipeline; + return pipeline; } auto swap(GraphicsPipeline& other) -> void { - std::swap(_device, other._device); - _desc_set_layout.swap(other._desc_set_layout); - std::swap(_pipeline_layout, other._pipeline_layout); - std::swap(_pipeline, other._pipeline); + std::swap(device, other.device); + desc_set_layout.swap(other.desc_set_layout); + std::swap(pipeline_layout, other.pipeline_layout); + std::swap(pipeline, other.pipeline); } - private: - VkDevice _device = nullptr; + VkDevice device = nullptr; // Model View Projection matrix stack etc. - Shakti::Vulkan::DescriptorSetLayout _desc_set_layout; - VkPipelineLayout _pipeline_layout = nullptr; - VkPipeline _pipeline = nullptr; + Shakti::Vulkan::DescriptorSetLayout desc_set_layout; + VkPipelineLayout pipeline_layout = nullptr; + VkPipeline pipeline = nullptr; }; - struct GraphicsPipeline::Builder + class GraphicsPipeline::Builder { + public: Builder(const Shakti::Vulkan::Device& device, const Kalpana::Vulkan::RenderPass& render_pass) : device{device} @@ -210,9 +191,9 @@ namespace DO::Kalpana::Vulkan { auto graphics_pipeline = GraphicsPipeline{}; - graphics_pipeline._device = device; + graphics_pipeline.device = device; - graphics_pipeline._desc_set_layout = + graphics_pipeline.desc_set_layout = Shakti::Vulkan::DescriptorSetLayout::Builder{device} .push_uniform_buffer_layout_binding() .create(); @@ -224,15 +205,15 @@ namespace DO::Kalpana::Vulkan { pipeline_layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; pipeline_layout_info.setLayoutCount = 1; - pipeline_layout_info.pSetLayouts = - &static_cast(graphics_pipeline._desc_set_layout); + pipeline_layout_info.pSetLayouts = &static_cast( + graphics_pipeline.desc_set_layout); pipeline_layout_info.pushConstantRangeCount = 0; }; - auto status = vkCreatePipelineLayout( // - device, // - &pipeline_layout_info, // - nullptr, // - &graphics_pipeline._pipeline_layout // + auto status = vkCreatePipelineLayout( // + device, // + &pipeline_layout_info, // + nullptr, // + &graphics_pipeline.pipeline_layout // ); if (status != VK_SUCCESS) throw std::runtime_error{fmt::format( @@ -263,7 +244,7 @@ namespace DO::Kalpana::Vulkan { pipeline_info.pMultisampleState = &multisampling; pipeline_info.pColorBlendState = &color_blend; - pipeline_info.layout = graphics_pipeline._pipeline_layout; + pipeline_info.layout = graphics_pipeline.pipeline_layout; pipeline_info.renderPass = render_pass.handle; pipeline_info.subpass = 0; pipeline_info.basePipelineHandle = VK_NULL_HANDLE; @@ -276,7 +257,7 @@ namespace DO::Kalpana::Vulkan { 1, // &pipeline_info, // nullptr, // - &graphics_pipeline._pipeline // + &graphics_pipeline.pipeline // ); if (status != VK_SUCCESS) throw std::runtime_error{ @@ -296,7 +277,7 @@ namespace DO::Kalpana::Vulkan { return shader_stage_infos[1]; } - private: + protected: auto load_shaders() -> void { // Load the compiled shaders. diff --git a/cpp/test/Shakti/Vulkan/test_vulkan_graphics_pipeline.cpp b/cpp/test/Shakti/Vulkan/test_vulkan_graphics_pipeline.cpp index eaaa9fb90..58327ad9b 100644 --- a/cpp/test/Shakti/Vulkan/test_vulkan_graphics_pipeline.cpp +++ b/cpp/test/Shakti/Vulkan/test_vulkan_graphics_pipeline.cpp @@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(test_graphics_pipeline_build) .viewport_sizes(static_cast(w), static_cast(h)) .scissor_sizes(w, h) .create(); - BOOST_CHECK(graphics_pipeline.device() != nullptr); - BOOST_CHECK(graphics_pipeline.pipeline_layout() != nullptr); + BOOST_CHECK(graphics_pipeline.device != nullptr); + BOOST_CHECK(graphics_pipeline.pipeline_layout != nullptr); BOOST_CHECK(static_cast(graphics_pipeline) != nullptr); }