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()
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_color.comp
SHADERS shaders/sky.comp
LIBS glfw fmt vk-bootstrap vulkan
IMGUI
)

View File

@ -723,6 +723,7 @@ void Engine::initSyncStructures() {
);
});
#ifdef DEBUG
fmt::println("[Engine:Init] Sync structures created !");
#endif
@ -837,35 +838,22 @@ void Engine::initBackgroundPipelines() {
);
// Create the actual shader
VkShaderModule gradientShader;
VkShaderModule computeDrawShader;
if (
!vkutil::loadShaderModule(
"shaders/gradient_color.spv",
_device,
&gradientShader
&computeDrawShader
)
) {
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{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.pNext = nullptr,
.stage = VK_SHADER_STAGE_COMPUTE_BIT,
.module = gradientShader,
.module = computeDrawShader,
.pName = "main"
};
@ -876,15 +864,6 @@ void Engine::initBackgroundPipelines() {
.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(
vkCreateComputePipelines(
_device,
@ -892,50 +871,18 @@ void Engine::initBackgroundPipelines() {
1,
&computePipelineCreateInfo,
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
vkDestroyShaderModule(
_device,
gradientShader,
computeDrawShader,
nullptr
);
vkDestroyShaderModule(
_device,
skyShader,
nullptr
);
_mainDeletionQueue.pushFunction([this, sky, gradient]() {
_mainDeletionQueue.pushFunction([this]() {
vkDestroyPipelineLayout(
_device,
_gradientPipelineLayout,
@ -944,17 +891,10 @@ void Engine::initBackgroundPipelines() {
vkDestroyPipeline(
_device,
sky.pipeline,
nullptr
);
vkDestroyPipeline(
_device,
gradient.pipeline,
_gradientPipeline,
nullptr
);
});
#ifdef DEBUG
fmt::println("[Engine:Init] Compute pipelines initalized !");
#endif
@ -1096,41 +1036,6 @@ void Engine::buildImgui() {
// Main ImGui things
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
ImGui::Render();
}
@ -1161,12 +1066,10 @@ void Engine::drawBackground(
VkImageSubresourceRange clearRange = vkinit::imageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT);
ComputeEffect& effect = backgroundEffects[currentBackgroundEffect];
vkCmdBindPipeline(
cmd,
VK_PIPELINE_BIND_POINT_COMPUTE,
effect.pipeline
_gradientPipeline
);
vkCmdBindDescriptorSets(
@ -1180,11 +1083,9 @@ void Engine::drawBackground(
nullptr
);
/*
ComputePushConstants pc;
pc.data1 = glm::vec4(1, 0, 0, 1);
pc.data2 = glm::vec4(0, 0, 1, 1);
*/
vkCmdPushConstants(
cmd,
@ -1192,7 +1093,7 @@ void Engine::drawBackground(
VK_SHADER_STAGE_COMPUTE_BIT,
0,
sizeof(ComputePushConstants),
&effect.data
&pc
);
vkCmdDispatch(