Compare commits

..

No commits in common. "e3fd8a5b2b8b2b8c73d497f7fb277e5be7491844" and "891e178008f5fbeec1f5910dcb09fc81992268d9" have entirely different histories.

3 changed files with 10 additions and 114 deletions

View File

@ -50,7 +50,3 @@ if (NOT ENGINE_HASH OR GIT_HASH_ERROR_CODE)
endif() endif()
string(REGEX REPLACE "^v" "" ENGINE_VERSION "${ENGINE_VERSION}") string(REGEX REPLACE "^v" "" ENGINE_VERSION "${ENGINE_VERSION}")
set(ENGINE_VERSION "${ENGINE_VERSION}-${CMAKE_BUILD_TYPE}")
message(STATUS "Engine Version: ${ENGINE_VERSION}")

View File

@ -200,7 +200,6 @@ addBinary (
SHADERS shaders/gradient.comp SHADERS shaders/gradient.comp
SHADERS shaders/gradient_color.comp SHADERS shaders/gradient_color.comp
SHADERS shaders/sky.comp
LIBS glfw fmt vk-bootstrap vulkan LIBS glfw fmt vk-bootstrap vulkan
IMGUI IMGUI
) )

View File

@ -723,6 +723,7 @@ void Engine::initSyncStructures() {
); );
}); });
#ifdef DEBUG #ifdef DEBUG
fmt::println("[Engine:Init] Sync structures created !"); fmt::println("[Engine:Init] Sync structures created !");
#endif #endif
@ -837,35 +838,22 @@ void Engine::initBackgroundPipelines() {
); );
// Create the actual shader // Create the actual shader
VkShaderModule gradientShader; VkShaderModule computeDrawShader;
if ( if (
!vkutil::loadShaderModule( !vkutil::loadShaderModule(
"shaders/gradient_color.spv", "shaders/gradient_color.spv",
_device, _device,
&gradientShader &computeDrawShader
) )
) { ) {
fmt::println("[Engine:Error] Error when building the compute shader !"); fmt::println("[Engine:Error] Error when building the compute shader !");
} }
// Create the second shader
VkShaderModule skyShader;
if (
!vkutil::loadShaderModule(
"shaders/sky.spv",
_device,
&skyShader
)
) {
fmt::println("[Engine:Error] Error while building the compute shader !");
}
// Fist Shader
VkPipelineShaderStageCreateInfo stageInfo{ VkPipelineShaderStageCreateInfo stageInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.pNext = nullptr, .pNext = nullptr,
.stage = VK_SHADER_STAGE_COMPUTE_BIT, .stage = VK_SHADER_STAGE_COMPUTE_BIT,
.module = gradientShader, .module = computeDrawShader,
.pName = "main" .pName = "main"
}; };
@ -876,15 +864,6 @@ void Engine::initBackgroundPipelines() {
.layout = _gradientPipelineLayout .layout = _gradientPipelineLayout
}; };
ComputeEffect gradient {
.name = "gradient",
.layout = _gradientPipelineLayout,
.data = {
.data1 = glm::vec4(1, 0, 0, 1),
.data2 = glm::vec4(0, 0, 1, 1)
}
};
VK_CHECK( VK_CHECK(
vkCreateComputePipelines( vkCreateComputePipelines(
_device, _device,
@ -892,50 +871,18 @@ void Engine::initBackgroundPipelines() {
1, 1,
&computePipelineCreateInfo, &computePipelineCreateInfo,
nullptr, nullptr,
&gradient.pipeline &_gradientPipeline
); );
); );
// Change the shader module to create the sky shader
computePipelineCreateInfo.stage.module = skyShader;
ComputeEffect sky {
.name = "sky",
.layout = _gradientPipelineLayout,
.data = {
.data1 = glm::vec4(0.1, 0.2, 0.4, 0.97)
}
};
VK_CHECK(
vkCreateComputePipelines(
_device,
VK_NULL_HANDLE,
1,
&computePipelineCreateInfo,
nullptr,
&sky.pipeline
);
);
// Add the effects into the array
backgroundEffects.push_back(gradient);
backgroundEffects.push_back(sky);
// Do some cleanup // Do some cleanup
vkDestroyShaderModule( vkDestroyShaderModule(
_device, _device,
gradientShader, computeDrawShader,
nullptr nullptr
); );
vkDestroyShaderModule( _mainDeletionQueue.pushFunction([this]() {
_device,
skyShader,
nullptr
);
_mainDeletionQueue.pushFunction([this, sky, gradient]() {
vkDestroyPipelineLayout( vkDestroyPipelineLayout(
_device, _device,
_gradientPipelineLayout, _gradientPipelineLayout,
@ -944,17 +891,10 @@ void Engine::initBackgroundPipelines() {
vkDestroyPipeline( vkDestroyPipeline(
_device, _device,
sky.pipeline, _gradientPipeline,
nullptr
);
vkDestroyPipeline(
_device,
gradient.pipeline,
nullptr nullptr
); );
}); });
#ifdef DEBUG #ifdef DEBUG
fmt::println("[Engine:Init] Compute pipelines initalized !"); fmt::println("[Engine:Init] Compute pipelines initalized !");
#endif #endif
@ -1096,41 +1036,6 @@ void Engine::buildImgui() {
// Main ImGui things // Main ImGui things
ImGui::ShowDemoWindow(); ImGui::ShowDemoWindow();
if(ImGui::Begin("background")) {
ComputeEffect& selected = backgroundEffects[currentBackgroundEffect];
ImGui::Text(
"Selected effect: %s",
selected.name
);
ImGui::SliderInt(
"Effect Index",
&currentBackgroundEffect,
0,
backgroundEffects.size() - 1
);
ImGui::InputFloat4(
"data1",
(float*)& selected.data.data1
);
ImGui::InputFloat4(
"data2",
(float*)& selected.data.data2
);
ImGui::InputFloat4(
"data3",
(float*)& selected.data.data3
);
ImGui::InputFloat4(
"data4",
(float*)& selected.data.data4
);
}
ImGui::End();
// Finish everything // Finish everything
ImGui::Render(); ImGui::Render();
} }
@ -1161,12 +1066,10 @@ void Engine::drawBackground(
VkImageSubresourceRange clearRange = vkinit::imageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT); VkImageSubresourceRange clearRange = vkinit::imageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT);
ComputeEffect& effect = backgroundEffects[currentBackgroundEffect];
vkCmdBindPipeline( vkCmdBindPipeline(
cmd, cmd,
VK_PIPELINE_BIND_POINT_COMPUTE, VK_PIPELINE_BIND_POINT_COMPUTE,
effect.pipeline _gradientPipeline
); );
vkCmdBindDescriptorSets( vkCmdBindDescriptorSets(
@ -1180,11 +1083,9 @@ void Engine::drawBackground(
nullptr nullptr
); );
/*
ComputePushConstants pc; ComputePushConstants pc;
pc.data1 = glm::vec4(1, 0, 0, 1); pc.data1 = glm::vec4(1, 0, 0, 1);
pc.data2 = glm::vec4(0, 0, 1, 1); pc.data2 = glm::vec4(0, 0, 1, 1);
*/
vkCmdPushConstants( vkCmdPushConstants(
cmd, cmd,
@ -1192,7 +1093,7 @@ void Engine::drawBackground(
VK_SHADER_STAGE_COMPUTE_BIT, VK_SHADER_STAGE_COMPUTE_BIT,
0, 0,
sizeof(ComputePushConstants), sizeof(ComputePushConstants),
&effect.data &pc
); );
vkCmdDispatch( vkCmdDispatch(