Compare commits

..

5 Commits

Author SHA1 Message Date
burkkyy 0f0b0d1434 Merge pull request 'Adding in sandbox + Logger upgrade' (#80) from sandbox into main
Reviewed-on: #80
2026-10-06 01:20:21 -07:00
burkkyy 777e407d67 sandbox simplfy 2026-10-06 01:16:28 -07:00
burkkyy e32e5f911f sandbox copying current application 2026-10-05 02:17:32 -07:00
burkkyy 5b2d50a925 stubbing out conway game of life 2026-10-05 02:16:55 -07:00
burkkyy f6f4f8b7c9 fixes to buffer class 2026-10-05 02:16:37 -07:00
6 changed files with 91 additions and 17 deletions
+2 -5
View File
@@ -36,17 +36,14 @@ Buffer::~Buffer() {
vmaDestroyBuffer(this->device.getAllocator(), this->buffer, this->allocation); vmaDestroyBuffer(this->device.getAllocator(), this->buffer, this->allocation);
} }
// VMA always maps the whole allocation, so `size` only exists to keep the vk::Result Buffer::map() {
// interface; `offset` is applied to the returned pointer.
vk::Result Buffer::map(vk::DeviceSize size, vk::DeviceSize offset) {
SOPHIA_ASSERT(buffer && allocation, "Called map on buffer before create"); SOPHIA_ASSERT(buffer && allocation, "Called map on buffer before create");
(void)size;
void* base = nullptr; void* base = nullptr;
vk::Result result = static_cast<vk::Result>( vk::Result result = static_cast<vk::Result>(
vmaMapMemory(this->device.getAllocator(), this->allocation, &base)); vmaMapMemory(this->device.getAllocator(), this->allocation, &base));
if (result == vk::Result::eSuccess) { if (result == vk::Result::eSuccess) {
this->mapped = static_cast<char*>(base) + offset; this->mapped = base;
} }
return result; return result;
} }
+2 -3
View File
@@ -19,8 +19,7 @@ class Buffer {
vk::DeviceSize minOffsetAlignment = 1); vk::DeviceSize minOffsetAlignment = 1);
~Buffer(); ~Buffer();
vk::Result map(vk::DeviceSize size = VK_WHOLE_SIZE, vk::Result map();
vk::DeviceSize offset = 0);
void unmap(); void unmap();
void writeToBuffer(void* data, vk::DeviceSize size = VK_WHOLE_SIZE, void writeToBuffer(void* data, vk::DeviceSize size = VK_WHOLE_SIZE,
@@ -41,7 +40,7 @@ class Buffer {
void* getMappedMemory() const { return mapped; } void* getMappedMemory() const { return mapped; }
uint32_t getInstanceCount() const { return instanceCount; } uint32_t getInstanceCount() const { return instanceCount; }
vk::DeviceSize getInstanceSize() const { return instanceSize; } vk::DeviceSize getInstanceSize() const { return instanceSize; }
vk::DeviceSize getAlignmentSize() const { return instanceSize; } vk::DeviceSize getAlignmentSize() const { return alignmentSize; }
vk::BufferUsageFlags getUsageFlags() const { return usageFlags; } vk::BufferUsageFlags getUsageFlags() const { return usageFlags; }
vk::MemoryPropertyFlags getMemoryPropertyFlags() const { vk::MemoryPropertyFlags getMemoryPropertyFlags() const {
return memoryPropertyFlags; return memoryPropertyFlags;
@@ -0,0 +1,3 @@
add_executable(conway_game_of_life main.cpp)
target_link_libraries(conway_game_of_life PRIVATE ${PROJECT_NAME})
@@ -0,0 +1,3 @@
#version 450
void main(){}
+13
View File
@@ -0,0 +1,13 @@
#include <iostream>
#include <sophia/application.hpp>
class ConwayGameOfLife : public sophia::Application {
public:
ConwayGameOfLife()
: Application{{.width = 800, .height = 600, .name = "ConwayGameOfLife"}} {
}
void onCreate() override {}
};
SOPHIA_MAIN(ConwayGameOfLife)
+68 -9
View File
@@ -1,18 +1,77 @@
#define GLFW_INCLUDE_VULKAN #define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint> #include <cstdint>
#include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <glm/mat4x4.hpp> #include <sophia/scene_registry.hpp>
#include <glm/vec4.hpp> #include <sophia/scene_view.hpp>
#include <vector> #include <tracy/Tracy.hpp>
#include <vulkan/vulkan.hpp>
#include "renderer/render_context.hpp"
#include "renderer/render_graph.hpp"
#include "renderer/scene_renderer.hpp"
#include "resources/resource_registry.hpp"
#include "vulkan/device.hpp"
#include "window.hpp"
constexpr uint32_t WIDTH = 1280; constexpr uint32_t WIDTH = 1280;
constexpr uint32_t HEIGHT = 720; constexpr uint32_t HEIGHT = 720;
constexpr const char* NAME = ""; constexpr const char* NAME = "sandbox";
int main() { return EXIT_SUCCESS; } int main() {
sophia::Window window{WIDTH, HEIGHT, NAME};
sophia::Device device{&window};
sophia::RenderContext renderContext{window, device};
sophia::ResourceRegistry resourceRegistry{device,
renderContext.getImageFormat()};
sophia::SceneRegistry sceneRegistry;
sophia::SceneRenderer sceneRenderer{sceneRegistry, resourceRegistry, device,
renderContext.getImageFormat()};
sophia::SceneView view;
view.scene = sceneRegistry.create();
view.clearColor = {0.01f, 0.01f, 0.02f, 1.0f};
view.camera = sceneRegistry.get(view.scene).createCamera();
while (!window.shouldClose()) {
glfwPollEvents();
vk::CommandBuffer commandBuffer = renderContext.beginFrame();
if (!commandBuffer) {
continue;
}
sceneRenderer.beginFrame(renderContext.getFrameIndex());
sophia::RenderGraph graph{renderContext.getTracyContext()};
sophia::ImageRef color = graph.importImage(renderContext.getCurrentImage(),
sophia::Access::Present);
sophia::ImageRef depth = graph.importImage(
renderContext.getCurrentDepthImage(), sophia::Access::DepthWrite);
graph.addPass(
"scene",
[&](sophia::RenderGraph::PassBuilder& pass) {
const sophia::vec4& c = view.clearColor;
pass.writeColor(color, vk::AttachmentLoadOp::eClear,
{c.r, c.g, c.b, c.a});
pass.writeDepth(depth, vk::AttachmentLoadOp::eClear);
},
[&](vk::CommandBuffer commandBuffer) {
ZoneScopedN("scene pass");
sceneRenderer.render(commandBuffer, view, view.camera,
renderContext.getExtent());
});
graph.execute(commandBuffer);
renderContext.endFrame();
FrameMark;
}
device.waitIdle();
return EXIT_SUCCESS;
}