Made modifications to allow executation in linux (at least on my thinkpad). I hate that capitalization doesn't matter on windows files, it fucked up my directories
This commit is contained in:
parent
cc49f1b704
commit
36f515f53b
5
.gitignore
vendored
5
.gitignore
vendored
@ -9,10 +9,12 @@
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
.vscode/
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
@ -34,6 +36,9 @@ bld/
|
||||
[Ll]ogs/
|
||||
[Ll]ib/
|
||||
|
||||
# Cmake directory
|
||||
[Bb]uild/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
|
||||
@ -3,9 +3,14 @@
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-DDEBUG")
|
||||
set(CMAKE_CXX_FLAGS "-fsanitize=address -g -DDEBUG -D_DEBUG")
|
||||
|
||||
project(Pleascach)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
if(WIN32)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
endif()
|
||||
|
||||
file(GLOB SOURCES
|
||||
pléascach.cpp
|
||||
@ -21,6 +26,7 @@ if(UNIX)
|
||||
set(GLFW3_LIBRARY glfw)
|
||||
endif()
|
||||
|
||||
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR} include ${GLFW3_INCLUDE_DIR})
|
||||
|
||||
target_link_libraries(Pleascach ${GLFW3_LIBRARY} Vulkan::Vulkan)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#define INPUT_PTR GLFWwindow*
|
||||
|
||||
#include <input/input.hpp>
|
||||
#include <Input/Input.hpp>
|
||||
|
||||
#include <util/log.hpp>
|
||||
|
||||
@ -32,6 +32,7 @@ constexpr u32 operator ~ (InputModifierBit a) {
|
||||
|
||||
struct InputEvent {
|
||||
enum Tag {
|
||||
EXIT,
|
||||
RESIZE,
|
||||
CURSOR,
|
||||
KEY,
|
||||
@ -1,4 +1,4 @@
|
||||
#include <memory/memory.hpp>
|
||||
#include <Memory/Memory.hpp>
|
||||
|
||||
namespace mem {
|
||||
u32 choose_heap(vk::PhysicalDevice& phys_dev, const vk::MemoryRequirements& requirements, vk::MemoryPropertyFlags req_flags, vk::MemoryPropertyFlags pref_flags) {
|
||||
@ -22,5 +22,7 @@ namespace mem {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -2,4 +2,5 @@
|
||||
|
||||
|
||||
## Long Term Improvements
|
||||
- Properly query surface to find supported
|
||||
- Add pipeline caching
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
#include <renderer/command_buffer.hpp>
|
||||
#include <Renderer/CommandBuffer.hpp>
|
||||
#include <Renderer/Pipeline.hpp>
|
||||
|
||||
|
||||
CommandBuffer::CommandBuffer(vk::Device dev, u32 queue_family) {
|
||||
/* (For now) allow command buffers to be individually recycled */
|
||||
@ -17,7 +19,8 @@ CommandBuffer::CommandBuffer(vk::Device dev, u32 queue_family) {
|
||||
.commandBufferCount = 1,
|
||||
};
|
||||
|
||||
dev.allocateCommandBuffers(alloc_info);
|
||||
|
||||
command_buffer = dev.allocateCommandBuffers(alloc_info)[0];
|
||||
}
|
||||
|
||||
void CommandBuffer::begin() {
|
||||
@ -33,6 +36,14 @@ void CommandBuffer::copy(vk::Buffer in, vk::Buffer out, vk::ArrayProxy<const vk:
|
||||
command_buffer.copyBuffer(in, out, regions);
|
||||
}
|
||||
|
||||
void CommandBuffer::bind(const GraphicsPipeline& pipeline) {
|
||||
command_buffer.bindPipeline(vk::PipelineBindPoint::eGraphics, pipeline.pipeline);
|
||||
}
|
||||
|
||||
void CommandBuffer::bind(const ComputePipeline& pipeline) {
|
||||
command_buffer.bindPipeline(vk::PipelineBindPoint::eCompute, pipeline.pipeline);
|
||||
}
|
||||
|
||||
void CommandBuffer::end() {
|
||||
command_buffer.end();
|
||||
}
|
||||
@ -42,6 +53,5 @@ void CommandBuffer::recycle() {
|
||||
}
|
||||
|
||||
void CommandBuffer::cleanup(vk::Device dev) {
|
||||
dev.freeCommandBuffers(command_pool, command_buffer);
|
||||
dev.destroyCommandPool(command_pool);
|
||||
}
|
||||
@ -5,6 +5,9 @@
|
||||
|
||||
#include <util/int.hpp>
|
||||
|
||||
struct GraphicsPipeline;
|
||||
struct ComputePipeline;
|
||||
|
||||
struct CommandBuffer {
|
||||
CommandBuffer(vk::Device dev, u32 queue_family);
|
||||
|
||||
@ -16,6 +19,9 @@ struct CommandBuffer {
|
||||
/* copy between buffer */
|
||||
void copy(vk::Buffer in, vk::Buffer out, vk::ArrayProxy<const vk::BufferCopy> regions);
|
||||
|
||||
void bind(const GraphicsPipeline& pipeline);
|
||||
void bind(const ComputePipeline& pipeline);
|
||||
|
||||
/* stop recording commands */
|
||||
void end();
|
||||
|
||||
19
Renderer/Pipeline.cpp
Normal file
19
Renderer/Pipeline.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include <Renderer/Pipeline.hpp>
|
||||
|
||||
#include <Renderer/Shader.hpp>
|
||||
|
||||
ComputePipeline::ComputePipeline(vk::Device dev, const Shader& shader) {
|
||||
auto shader_info = vk::PipelineShaderStageCreateInfo {
|
||||
.stage = vk::ShaderStageFlagBits::eCompute,
|
||||
.module = shader,
|
||||
.pName = "main",
|
||||
};
|
||||
|
||||
auto layout = vk::PipelineLayoutCreateInfo {
|
||||
|
||||
};
|
||||
|
||||
auto create_info = vk::ComputePipelineCreateInfo {
|
||||
.stage = shader_info,
|
||||
};
|
||||
}
|
||||
27
Renderer/Pipeline.hpp
Normal file
27
Renderer/Pipeline.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#define VULKAN_HPP_NO_STRUCT_CONSTRUCTORS
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
struct Shader;
|
||||
|
||||
struct ComputePipeline {
|
||||
ComputePipeline(vk::Device dev, const Shader& shader);
|
||||
|
||||
vk::Pipeline pipeline;
|
||||
inline operator vk::Pipeline&() {
|
||||
return pipeline;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct GraphicsPipeline {
|
||||
GraphicsPipeline(vk::Device dev);
|
||||
vk::Pipeline pipeline;
|
||||
|
||||
inline operator vk::Pipeline&() {
|
||||
return pipeline;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#include <renderer/renderer.hpp>
|
||||
#include <window/window.hpp>
|
||||
#include <Renderer/Renderer.hpp>
|
||||
#include <Window/Window.hpp>
|
||||
|
||||
#include <util/log.hpp>
|
||||
|
||||
@ -8,11 +8,11 @@ using namespace std::string_literals;
|
||||
Renderer::Renderer(Window& win) : win(win) {
|
||||
/* Create Instance object */
|
||||
auto app_info = vk::ApplicationInfo {
|
||||
.pApplicationName = "Pléascach Demo",
|
||||
.pApplicationName = "Pl<EFBFBD>ascach Demo",
|
||||
.applicationVersion = VK_MAKE_API_VERSION(0, 0, 1, 0),
|
||||
.pEngineName = "Pléascach",
|
||||
.pEngineName = "Pl<EFBFBD>ascach",
|
||||
.engineVersion = VK_MAKE_API_VERSION(0, 0, 1, 0),
|
||||
.apiVersion = VK_API_VERSION_1_0,
|
||||
.apiVersion = VK_API_VERSION_1_1,
|
||||
};
|
||||
|
||||
const auto req_extensions = win.requiredExtensions();
|
||||
@ -29,7 +29,7 @@ Renderer::Renderer(Window& win) : win(win) {
|
||||
}
|
||||
|
||||
/* query and enable available layers if in DEBUG mode */
|
||||
#ifdef _DEBUG
|
||||
#ifdef DEBUG
|
||||
|
||||
auto layers = vk::enumerateInstanceLayerProperties();
|
||||
Log::info("%zu available instance layers\n", layers.size());
|
||||
@ -46,8 +46,8 @@ Renderer::Renderer(Window& win) : win(win) {
|
||||
.pApplicationInfo = &app_info,
|
||||
.enabledLayerCount = std::size(my_layers),
|
||||
.ppEnabledLayerNames = my_layers,
|
||||
.enabledExtensionCount = static_cast<u32>(extensions.size()),
|
||||
.ppEnabledExtensionNames = extension_names.data(),
|
||||
.enabledExtensionCount = static_cast<u32>(req_extensions.size()),
|
||||
.ppEnabledExtensionNames = req_extensions.data(),
|
||||
};
|
||||
|
||||
#else
|
||||
@ -55,8 +55,8 @@ Renderer::Renderer(Window& win) : win(win) {
|
||||
.pApplicationInfo = &app_info,
|
||||
.enabledLayerCount = 0,
|
||||
.ppEnabledLayerNames = nullptr,
|
||||
.enabledExtensionCount = static_cast<u32>(extensions.size()),
|
||||
.ppEnabledExtensionNames = extensions.data(),
|
||||
.enabledExtensionCount = static_cast<u32>(req_extensions.size()),
|
||||
.ppEnabledExtensionNames = req_extensions.data(),
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -108,11 +108,11 @@ Renderer::Renderer(Window& win) : win(win) {
|
||||
|
||||
/* enumerate available device features */
|
||||
std::vector<const char*> required_extensions;
|
||||
required_extensions.push_back("VK_KHR_swapchain");
|
||||
auto dev_extentions = phys_dev.enumerateDeviceExtensionProperties();
|
||||
Log::info("%zu available device extensions\n", dev_extentions.size());
|
||||
for (const auto& ext : dev_extentions) {
|
||||
Log::info("\t\"%s\"\n", ext.extensionName.data());
|
||||
required_extensions.push_back(ext.extensionName);
|
||||
}
|
||||
|
||||
auto dev_layers = phys_dev.enumerateDeviceLayerProperties();
|
||||
@ -161,6 +161,8 @@ void Renderer::draw() {
|
||||
command_buffer->recycle();
|
||||
command_buffer->begin();
|
||||
|
||||
|
||||
|
||||
command_buffer->end();
|
||||
}
|
||||
|
||||
@ -185,7 +187,6 @@ void Renderer::present() {
|
||||
}
|
||||
|
||||
Renderer::~Renderer() {
|
||||
command_buffer->cleanup(dev);
|
||||
swapchain.reset();
|
||||
dev.waitIdle();
|
||||
dev.destroy();
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
#define VULKAN_HPP_NO_STRUCT_CONSTRUCTORS
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
#include <renderer/swapchain.hpp>
|
||||
#include <renderer/command_buffer.hpp>
|
||||
#include <Renderer/Swapchain.hpp>
|
||||
#include <Renderer/CommandBuffer.hpp>
|
||||
|
||||
struct Window;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include <renderer/shader.hpp>
|
||||
#include <Renderer/Shader.hpp>
|
||||
|
||||
#include <util/log.hpp>
|
||||
|
||||
|
||||
@ -9,7 +9,9 @@ struct Shader {
|
||||
Shader(vk::Device dev, const std::string& fname);
|
||||
void cleanup(vk::Device dev);
|
||||
|
||||
|
||||
inline operator vk::ShaderModule() const {
|
||||
return module;
|
||||
}
|
||||
|
||||
inline operator vk::ShaderModule& () {
|
||||
return module;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include <renderer/swapchain.hpp>
|
||||
#include <Renderer/Swapchain.hpp>
|
||||
|
||||
Swapchain::Swapchain(vk::Device& dev, const vk::SurfaceKHR& surface, const vk::Extent2D& extent) : dev(dev), surface(surface) {
|
||||
create(extent);
|
||||
@ -10,7 +10,7 @@ void Swapchain::create(const vk::Extent2D& extent, vk::SwapchainKHR old_swapchai
|
||||
.surface = surface,
|
||||
/* at least double-buffered */
|
||||
.minImageCount = 3,
|
||||
.imageFormat = vk::Format::eR8G8B8A8Unorm,
|
||||
.imageFormat = vk::Format::eB8G8R8A8Unorm,
|
||||
.imageColorSpace = vk::ColorSpaceKHR::eSrgbNonlinear,
|
||||
.imageExtent = extent,
|
||||
.imageArrayLayers = 1,
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
|
||||
#define WINDOW_PTR GLFWwindow*
|
||||
#define INPUT_PTR GLFWwindow*
|
||||
#include <window/window.hpp>
|
||||
#include <input/input.hpp>
|
||||
#include <Window/Window.hpp>
|
||||
#include <Input/Input.hpp>
|
||||
|
||||
#include <util/log.hpp>
|
||||
|
||||
|
||||
@ -5,7 +5,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <input/input.hpp>
|
||||
#include <memory>
|
||||
|
||||
#include <Input/Input.hpp>
|
||||
|
||||
#ifndef WINDOW_PTR
|
||||
#define WINDOW_PTR void*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include <window/window.hpp>
|
||||
#include <input/input.hpp>
|
||||
#include <renderer/renderer.hpp>
|
||||
#include <Window/Window.hpp>
|
||||
#include <Input/Input.hpp>
|
||||
#include <Renderer/Renderer.hpp>
|
||||
|
||||
#include <util/log.hpp>
|
||||
|
||||
@ -30,6 +30,8 @@ int main() {
|
||||
break;
|
||||
case InputEvent::Tag::KEY:
|
||||
Log::info("Event Processed: Button 0x%x %d\n", event.key.key, event.key.state);
|
||||
break;
|
||||
case InputEvent::Tag::EXIT:
|
||||
win.close();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define VULKAN_HPP_NO_STRUCT_CONSTRUCTORS
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
struct ComputePipeline {
|
||||
ComputePipeline(vk::Device dev) {
|
||||
}
|
||||
|
||||
vk::Pipeline pipeline;
|
||||
inline operator vk::Pipeline&() {
|
||||
return pipeline;
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user