Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion KaguEngine/extern/glfw
9 changes: 6 additions & 3 deletions KaguEngine/src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ void App::run() {

RenderSystem renderSystem{
m_Device,
m_Renderer.getSwapChainRenderPass(),
m_Renderer.getOffscreenFormat(),
m_Renderer.getOffscreenDepthFormat(),
m_GlobalSetLayout->getDescriptorSetLayout(), // set = 0 (UBO)
m_MaterialSetLayout->getDescriptorSetLayout() // set = 1 (textures)
};
PointLightSystem pointLightSystem{
m_Device,
m_Renderer.getSwapChainRenderPass(),
m_Renderer.getOffscreenFormat(),
m_Renderer.getOffscreenDepthFormat(),
m_GlobalSetLayout->getDescriptorSetLayout()
};
Camera camera{};
Expand Down Expand Up @@ -118,7 +120,7 @@ void App::run() {
m_Renderer.endOffscreenRenderPass(commandBuffer);

// ImGui rendering
m_Renderer.transitionOffscreenImageForImGui();
m_Renderer.transitionOffscreenImageForImGui(commandBuffer);
imGuiContext.render(m_Renderer);

// Present the image
Expand Down Expand Up @@ -200,6 +202,7 @@ void App::loadGameObjects() {
for (int i = 0; i < lightColors.size(); i++) {
auto pointLight = Entity::makePointLight(0.2f);
pointLight.color = lightColors[i];
pointLight.name = "Point Light " + std::to_string(i + 1);
auto rotateLight = glm::rotate(
glm::mat4(1.f),
static_cast<float>(i) * glm::two_pi<float>() / static_cast<float>(lightColors.size()),
Expand Down
26 changes: 19 additions & 7 deletions KaguEngine/src/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void Device::createInstance() {
appInfo.applicationVersion = VK_MAKE_VERSION(0, 0, 1);
appInfo.pEngineName = "Kagu Engine";
appInfo.engineVersion = VK_MAKE_VERSION(0, 0, 1);
appInfo.apiVersion = VK_API_VERSION_1_0;
appInfo.apiVersion = VK_API_VERSION_1_3;

VkInstanceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
Expand Down Expand Up @@ -139,9 +139,14 @@ void Device::pickPhysicalDevice() {

int Device::rateDeviceSuitability(const VkPhysicalDevice device) const {
VkPhysicalDeviceProperties supportedProperties;
VkPhysicalDeviceFeatures supportedFeatures;
vkGetPhysicalDeviceProperties(device, &supportedProperties);
vkGetPhysicalDeviceFeatures(device, &supportedFeatures);

VkPhysicalDeviceVulkan13Features features13{};
features13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
VkPhysicalDeviceFeatures2 features2{};
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
features2.pNext = &features13;
vkGetPhysicalDeviceFeatures2(device, &features2);

const QueueFamilyIndices indices = findQueueFamilies(device);

Expand All @@ -161,7 +166,7 @@ int Device::rateDeviceSuitability(const VkPhysicalDevice device) const {

// Check for needed features, the engine can't work without them.
if (!(indices.isComplete() && extensionsSupported && swapChainAdequate &&
supportedFeatures.geometryShader && supportedFeatures.samplerAnisotropy)) {
features2.features.samplerAnisotropy && features13.dynamicRendering)) {
return 0;
}

Expand All @@ -184,16 +189,23 @@ void Device::createLogicalDevice() {
queueCreateInfos.push_back(queueCreateInfo);
}

VkPhysicalDeviceFeatures deviceFeatures = {};
deviceFeatures.samplerAnisotropy = VK_TRUE;
VkPhysicalDeviceVulkan13Features deviceFeatures13{};
deviceFeatures13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
deviceFeatures13.dynamicRendering = VK_TRUE;

VkPhysicalDeviceFeatures2 deviceFeatures2{};
deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
deviceFeatures2.pNext = &deviceFeatures13;
deviceFeatures2.features.samplerAnisotropy = VK_TRUE;

VkDeviceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
createInfo.pNext = &deviceFeatures2;

createInfo.queueCreateInfoCount = static_cast<uint32_t>(queueCreateInfos.size());
createInfo.pQueueCreateInfos = queueCreateInfos.data();

createInfo.pEnabledFeatures = &deviceFeatures;
createInfo.pEnabledFeatures = nullptr; // This must be null if pNext is used
createInfo.enabledExtensionCount = static_cast<uint32_t>(m_DeviceExtensions.size());
createInfo.ppEnabledExtensionNames = m_DeviceExtensions.data();

Expand Down
5 changes: 3 additions & 2 deletions KaguEngine/src/ImGuiContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ void ImGuiContext::setupContext() const {
init_info.Device = deviceRef.device();
init_info.QueueFamily = indices.graphicsFamily;
init_info.Queue = deviceRef.graphicsQueue();
init_info.RenderPass = swapChainRef.getRenderPass();
init_info.PipelineCache = VK_NULL_HANDLE;
init_info.DescriptorPool = poolRef->getDescriptorPool();
init_info.Allocator = nullptr;
init_info.Subpass = 0;
init_info.MinImageCount = SwapChain::MAX_FRAMES_IN_FLIGHT;
init_info.MSAASamples = deviceRef.getSampleCount();
init_info.ImageCount = SwapChain::MAX_FRAMES_IN_FLIGHT;
init_info.UseDynamicRendering = true;
ImGui_ImplVulkan_Init(&init_info);
ImGui_ImplVulkan_CreateFontsTexture();
}
Expand Down Expand Up @@ -366,7 +366,8 @@ void ImGuiContext::renderSceneHierarchyPanel() {

if (ImGui::TreeNodeEx("Scene", ImGuiTreeNodeFlags_DefaultOpen)) {
for (auto& [id, entity] : entitiesRef) {
std::string name = entity.pointLight != nullptr ? std::string(ICON_FA_LIGHTBULB_O) + " Point Light " + std::to_string(id) : std::string(ICON_FA_CUBE) + " " + entity.name;
std::string name = entity.pointLight != nullptr ? std::string(ICON_FA_LIGHTBULB_O) + " " : std::string(ICON_FA_CUBE) + " ";
name += entity.name;

bool is_selected = (m_SelectedEntityID == id);
if (ImGui::Selectable(name.c_str(), is_selected)) {
Expand Down
14 changes: 10 additions & 4 deletions KaguEngine/src/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ void Pipeline::createGraphicsPipeline(const std::string &vertFilepath, const std
const PipelineConfigInfo &configInfo) {
assert(configInfo.pipelineLayout != VK_NULL_HANDLE &&
"Cannot create graphics pipeline: no pipelineLayout provided in configInfo");
assert(configInfo.renderPass != VK_NULL_HANDLE &&
"Cannot create graphics pipeline: no renderPass provided in configInfo");

const auto vertCode = readFile(vertFilepath);
const auto fragCode = readFile(fragFilepath);
Expand Down Expand Up @@ -83,8 +81,16 @@ void Pipeline::createGraphicsPipeline(const std::string &vertFilepath, const std
vertexInputInfo.pVertexAttributeDescriptions = attributeDescriptions.data();
vertexInputInfo.pVertexBindingDescriptions = bindingDescriptions.data();

VkPipelineRenderingCreateInfo renderingCreateInfo{};
renderingCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO;
renderingCreateInfo.colorAttachmentCount = 1;
renderingCreateInfo.pColorAttachmentFormats = &configInfo.colorAttachmentFormat;
renderingCreateInfo.depthAttachmentFormat = configInfo.depthAttachmentFormat;
renderingCreateInfo.stencilAttachmentFormat = configInfo.depthAttachmentFormat;

VkGraphicsPipelineCreateInfo pipelineInfo{};
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipelineInfo.pNext = &renderingCreateInfo;
pipelineInfo.stageCount = 2;
pipelineInfo.pStages = shaderStages;
pipelineInfo.pVertexInputState = &vertexInputInfo;
Expand All @@ -97,8 +103,8 @@ void Pipeline::createGraphicsPipeline(const std::string &vertFilepath, const std
pipelineInfo.pDynamicState = &configInfo.dynamicStateInfo;

pipelineInfo.layout = configInfo.pipelineLayout;
pipelineInfo.renderPass = configInfo.renderPass;
pipelineInfo.subpass = configInfo.subpass;
pipelineInfo.renderPass = VK_NULL_HANDLE;
pipelineInfo.subpass = 0;

pipelineInfo.basePipelineIndex = -1;
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE;
Expand Down
4 changes: 2 additions & 2 deletions KaguEngine/src/Pipeline.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ struct PipelineConfigInfo {
std::vector<VkDynamicState> dynamicStateEnables;
VkPipelineDynamicStateCreateInfo dynamicStateInfo;
VkPipelineLayout pipelineLayout = nullptr;
VkRenderPass renderPass = nullptr;
uint32_t subpass = 0;
VkFormat colorAttachmentFormat;
VkFormat depthAttachmentFormat;
};

class Pipeline {
Expand Down
Loading