Majorly cleaned up unnecessary includes and reformatted makefile to include shaders now.

This commit is contained in:
Lillian Salehi 2024-10-09 02:53:44 -05:00
parent 5fca2134fe
commit 0fefb85d0a
15 changed files with 29 additions and 46 deletions

View File

@ -2,14 +2,13 @@ CPPFLAGS=-g
LDFLAGS=-lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi LDFLAGS=-lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi
DEBUGFLAGS=-DDEBUG -fsanitize=address DEBUGFLAGS=-DDEBUG -fsanitize=address
GDBFLAGS= GDBFLAGS=
SRC = $(shell find . -name *.cpp) SRC = $(shell find . -name "*.cpp")
SHDRSRC = $(shell find . -name "*.frag" -o -name "*vert")
SPV = $(SHDRSRC:%.vert=%.spv) $(SHDRSRC:%.frag=%.spv)
OBJ = $(SRC:%.cpp=%.o) OBJ = $(SRC:%.cpp=%.o)
VERTEX = $(src/shaders/%.vert=%.spv)
FRAGMENT = $(src/shaders/%.frag=%.spv)
BIN=build/agnosiaengine BIN=build/agnosiaengine
.PHONY: all .PHONY: all
all: $(BIN) all: $(BIN)
@ -28,25 +27,30 @@ debug: $(BIN)
.PHONY: dep .PHONY: dep
dep: dep:
sudo pacman -S gcc glfw glm shaderc libxi libxxf86vm gdb glslc sudo pacman -S gcc glfw glm shaderc libxi libxxf86vm gdb shaderc
.PHONY: info .PHONY: info
info: info:
@echo "make: Build executable" @echo "make: Build executable"
@echo "make dep: Make all required dependencies" @echo "make dep: Make all required dependencies"
@echo "make debug: Make with Debug hooked in" @echo "make debug: Make with Debug hooked in"
@echo "make gdb: Make with GDB hooked in"
@echo "make clean: Clean all files" @echo "make clean: Clean all files"
@echo "make run: Run the executable after building" @echo "make run: Run the executable after building"
$(BIN): $(OBJ) $(VERTEX) $(FRAGMENT) $(BIN): $(OBJ) $(SPV)
mkdir -p build mkdir -p build
g++ $(CPPFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS) g++ $(CPPFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS)
%.o: %.cpp %.o: %.cpp
g++ -c -g $< -o $@ $(LDFLAGS) g++ -c -g $< -o $@ $(LDFLAGS)
%.spv: %.vert %.frag
%.spv: %.frag
glslc $< -o $@
%.spv: %.vert
glslc $< -o $@ glslc $< -o $@
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf build rm -rf build
find . -name "*.o" -type f -delete find . -name "*.o" -type f -delete
find . -name "*.spv" -type f -delete

View File

@ -1,12 +1,6 @@
#include "vulkandebuglibs.h" #include "vulkandebuglibs.h"
#include "../global.h"
using namespace Debug; using namespace Debug;
#include <cstdint>
#include <stdexcept>
#include <vulkan/vk_platform.h>
#include <cstring>
// This is our messenger object! It handles passing along debug messages to the debug callback we will also set. // This is our messenger object! It handles passing along debug messages to the debug callback we will also set.
VkDebugUtilsMessengerEXT debugMessenger; VkDebugUtilsMessengerEXT debugMessenger;
// This is the set of "layers" to hook into. Basically, layers are used to tell the messenger what data we want, its a filter. *validation* is the general blanket layer to cover incorrect usage. // This is the set of "layers" to hook into. Basically, layers are used to tell the messenger what data we want, its a filter. *validation* is the general blanket layer to cover incorrect usage.

View File

@ -1,6 +1,8 @@
#pragma once #pragma once
#include <vector>
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
#include <cstdint>
#include <cstring>
#include "../global.h"
namespace Debug { namespace Debug {
class vulkandebuglibs { class vulkandebuglibs {

View File

@ -1,16 +1,6 @@
#include "devicelibrary.h" #include "devicelibrary.h"
#include "global.h" #include "global.h"
#include <algorithm>
#include <cstdint>
#include <limits>
#include <optional>
#include <ostream>
#include <set>
#include <stdexcept>
#include <string>
#include <vector>
#include <vulkan/vulkan_core.h>
namespace DeviceControl { namespace DeviceControl {

View File

@ -1,7 +1,12 @@
#pragma once #pragma once
#include "global.h" #include "global.h"
#include <optional> #include <optional>
#include <vulkan/vulkan_core.h> #include <algorithm>
#include <limits>
#include <ostream>
#include <set>
#include <string>
#include <vector>
namespace DeviceControl { namespace DeviceControl {
class devicelibrary { class devicelibrary {
public: public:

View File

@ -5,7 +5,7 @@ Graphics::graphicspipeline graphicsPipeline;
RenderPresent::render renderPresentation; RenderPresent::render renderPresentation;
VkInstance vulkaninstance; VkInstance vulkaninstance;
// Getters and Setters!
void EntryApp::setFramebufferResized(bool setter) { void EntryApp::setFramebufferResized(bool setter) {
framebufferResized = setter; framebufferResized = setter;
} }
@ -29,8 +29,6 @@ void initWindow() {
glfwSetFramebufferSizeCallback(Global::window, framebufferResizeCallback); glfwSetFramebufferSizeCallback(Global::window, framebufferResizeCallback);
} }
void createInstance() { void createInstance() {
debugController.checkUnavailableValidationLayers(); // Check if there is a mistake with our Validation Layers. debugController.checkUnavailableValidationLayers(); // Check if there is a mistake with our Validation Layers.
@ -83,9 +81,6 @@ void cleanup() { // Similar to th
renderPresentation.destroyFenceSemaphores(); renderPresentation.destroyFenceSemaphores();
graphicsPipeline.destroyCommandPool(); graphicsPipeline.destroyCommandPool();
deviceLibs.destroyImageViews();
deviceLibs.destroySwapChain();
vkDestroyDevice(Global::device, nullptr); vkDestroyDevice(Global::device, nullptr);
if(Global::enableValidationLayers) { if(Global::enableValidationLayers) {
debugController.DestroyDebugUtilsMessengerEXT(vulkaninstance, nullptr); debugController.DestroyDebugUtilsMessengerEXT(vulkaninstance, nullptr);
@ -96,7 +91,7 @@ void cleanup() { // Similar to th
glfwDestroyWindow(Global::window); glfwDestroyWindow(Global::window);
glfwTerminate(); glfwTerminate();
} }
// External Functions
EntryApp& EntryApp::getInstance() { EntryApp& EntryApp::getInstance() {
static EntryApp instance; static EntryApp instance;
return instance; return instance;

View File

@ -19,6 +19,4 @@ class EntryApp {
bool framebufferResized; bool framebufferResized;
bool initialized; bool initialized;
}; };

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include "debug/vulkandebuglibs.h"
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <optional> #include <optional>
#include <vulkan/vulkan_core.h> #include <vulkan/vulkan_core.h>
#include "debug/vulkandebuglibs.h"
#define GLFW_INCLUDE_VULKAN #define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>

View File

@ -1,9 +1,5 @@
#include "graphicspipeline.h" #include "graphicspipeline.h"
#include "../devicelibrary.h"
#include <cstdint>
#include <fstream>
#include <stdexcept>
#include <vulkan/vulkan_core.h>
namespace Graphics { namespace Graphics {
std::vector<VkDynamicState> dynamicStates = { std::vector<VkDynamicState> dynamicStates = {
VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_VIEWPORT,
@ -57,8 +53,8 @@ namespace Graphics {
void graphicspipeline::createGraphicsPipeline() { void graphicspipeline::createGraphicsPipeline() {
// Note to self, for some reason the working directory is not where a read file is called from, but the project folder! // Note to self, for some reason the working directory is not where a read file is called from, but the project folder!
auto vertShaderCode = readFile("src/shaders/vert.spv"); auto vertShaderCode = readFile("src/shaders/vertex.spv");
auto fragShaderCode = readFile("src/shaders/frag.spv"); auto fragShaderCode = readFile("src/shaders/fragment.spv");
VkShaderModule vertShaderModule = createShaderModule(vertShaderCode, Global::device); VkShaderModule vertShaderModule = createShaderModule(vertShaderCode, Global::device);
VkShaderModule fragShaderModule = createShaderModule(fragShaderCode, Global::device); VkShaderModule fragShaderModule = createShaderModule(fragShaderCode, Global::device);
@ -208,7 +204,7 @@ namespace Graphics {
} }
void graphicspipeline::destroyRenderPass() { void graphicspipeline::destroyRenderPass() {
vkDestroyRenderPass(Global::device, renderPass, nullptr); vkDestroyRenderPass(Global::device, renderPass, nullptr);
std::cout << "Destroyed Render Pass Safely\n" << std::endl; if(Global::enableValidationLayers) std::cout << "Destroyed Render Pass Safely\n" << std::endl;
} }
void graphicspipeline::createFramebuffers() { void graphicspipeline::createFramebuffers() {
// Resize the container to hold all the framebuffers. // Resize the container to hold all the framebuffers.
@ -275,7 +271,6 @@ namespace Graphics {
if (vkBeginCommandBuffer(commandBuffer, &beginInfo) != VK_SUCCESS) { if (vkBeginCommandBuffer(commandBuffer, &beginInfo) != VK_SUCCESS) {
throw std::runtime_error("failed to begin recording command buffer!"); throw std::runtime_error("failed to begin recording command buffer!");
} }
if(Global::enableValidationLayers) std::cout << "Recording command buffer...\n" << std::endl;
VkRenderPassBeginInfo renderPassInfo{}; VkRenderPassBeginInfo renderPassInfo{};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "../global.h" #include "../global.h"
#include "../devicelibrary.h"
#include <fstream>
namespace Graphics { namespace Graphics {
class graphicspipeline { class graphicspipeline {
public: public:

View File

@ -1,7 +1,6 @@
#include "entrypoint.h" #include "entrypoint.h"
int main() { int main() {
EntryApp::getInstance().initialize(); EntryApp::getInstance().initialize();
try { try {
EntryApp::getInstance().run(); EntryApp::getInstance().run();
} catch (const std::exception &e) { } catch (const std::exception &e) {

Binary file not shown.

Binary file not shown.