first commit

This commit is contained in:
Greg Wells
2025-05-05 19:29:42 -04:00
commit 406d669de0
284 changed files with 32727 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
#include "gryphn_buffer.h"
void gnBufferSetSize(gnBuffer& buffer, gnSize size) {
buffer.size = size;
}
void gnBufferSetType(gnBuffer& buffer, gnBufferType type) {
buffer.bufferType = type;
}
void gnBufferSetDataType(gnBuffer& buffer, gnBufferDataType type) {
buffer.dataType = type;
}

View File

@@ -0,0 +1,34 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "core/output_device/gryphn_output_device.h"
struct gnPlatformBuffer;
typedef enum gnBufferType {
GN_VERTEX_BUFFER = 0, GN_INDEX_BUFFER = 1, GN_UNIFORM_BUFFER = 2
} gnBufferType;
typedef enum gnBufferDataType {
GN_UINT8, GN_UINT16, GN_UINT32
} gnBufferDataType;
struct gnBuffer {
ACCESS_LEVEL:
gnPlatformBuffer* buffer = nullptr;
gnSize size;
gnBufferType bufferType;
gnBufferDataType dataType;
public:
gnBuffer() {}
};
void gnBufferSetSize(gnBuffer& buffer, gnSize size);
void gnBufferSetType(gnBuffer& buffer, gnBufferType type);
void gnBufferSetDataType(gnBuffer& buffer, gnBufferDataType type);
inline gnErrorCode (*gnCreateBuffer)(gnBuffer* buffer, const gnOutputDevice& outputDevice);
inline void (*gnBufferData)(gnBuffer& buffer, void* data);
inline void (*gnBufferMapData)(gnBuffer& buffer, void** data); // used to map data to a pointer without copying
inline void (*gnBufferSubData)(gnBuffer& buffer, gnSize offset, gnSize size, void* data);
inline void (*gnBufferClearData)(gnBuffer& buffer);
inline void (*gnDestroyBuffer)(gnBuffer& buffer);

View File

@@ -0,0 +1,18 @@
#pragma once
#include <gryphn/gryphn_utils.h>
struct gnPlatformBufferDescription;
struct gnGraphicsPipeline;
// I have zero fucking clue what this class does?????
// I know I wrote it but there are zero references to it so i think that its some black magic thing I wrote
// Imma pretend that I doesnt exist for now and just not write a metal implementation for it
// This is going to end horribly but who fucking cares
struct gnBufferDescription {
ACCESS_LEVEL:
gnPlatformBufferDescription* bufferDescription;
public:
gnBufferDescription();
};
inline gnReturnCode (*gnCreateBufferDescription)(gnBufferDescription* bufferDescription, const gnGraphicsPipeline& graphicsPipeline);

View File

@@ -0,0 +1,10 @@
#pragma once
#include <gryphn/gryphn_utils.h>
struct gnBindingDescription {
public:
gnInt binding;
gnSize stride;
public:
gnBindingDescription() {};
};

View File

@@ -0,0 +1,18 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_binding_description.h"
#include "gryphn_vertex_property.h"
struct gnPlatformVertexDescription;
struct gnVertexDescription {
ACCESS_LEVEL:
gnPlatformVertexDescription* vertexDescription = nullptr;
gnBindingDescription* bindingDescription;
public:
gnVertexDescription() {}
};
inline void (*gnVertexDescriptionSetBindingDescription)(gnVertexDescription& vertexDescription, const gnBindingDescription& description);
inline void (*gnVertexDescriptionSetPropertiesCount)(gnVertexDescription& vertexDescription, int count);
inline void (*gnVertexDescriptionSetProperty)(gnVertexDescription& vertexDescription, int index, const gnVertexProperty& property);

View File

@@ -0,0 +1,18 @@
#pragma once
#include <gryphn/gryphn_utils.h>
enum gnVertexDataFormat {
GN_FLOAT, GN_FLOAT2, GN_FLOAT3, GN_FLOAT4, GN_UINT
};
struct gnVertexProperty {
ACCESS_LEVEL:
public:
int binding;
int location;
gnVertexDataFormat format;
size_t offset;
public:
gnVertexProperty() {}
};

View File

@@ -0,0 +1,38 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_command_buffer.h"
#include "core/graphics_pipeline/gryphn_render_pass_frame.h"
#include "core/graphics_pipeline/gryphn_graphics_pipeline.h"
#include "core/buffers/gryphn_buffer.h"
#include "core/buffers/uniform_buffer_descriptor/gryphn_buffer_description.h"
#include "core/push_constant/gryphn_push_constant.h"
#include "core/uniform_descriptor/uniform_buffer/gryphn_uniform_buffer.h"
#include "core/uniform_descriptor/sampler/gryphn_sampler.h"
#include "core/shaders/gryphn_shader.h"
struct gnViewportDescriptionData {
gnVec2 offset;
gnVec2 size;
gnVec2 depth;
};
struct gnScissorDescriptionData {
gnUInt2 offset;
gnUInt2 extent;
};
inline gnReturnCode (*gnCommandBufferStart)(gnCommandBuffer& commandBuffer);
inline void (*gnCommandBeginRenderPass)(gnCommandBuffer& commandBuffer, const gnRenderPassFrame& frame);
inline void (*gnCommandSetGraphicsPipeline)(gnCommandBuffer& commandBuffer, const gnGraphicsPipeline& graphicsPipeline);
inline void (*gnCommandSetViewport)(gnCommandBuffer& commandBuffer, gnViewportDescriptionData data);
inline void (*gnCommandSetScissor)(gnCommandBuffer& commandBuffer, gnScissorDescriptionData data);
inline void (*_gnCommandDraw)(gnCommandBuffer& commandBuffer, int vertexCount, int instanceCount, int firstVertex, int firstInstance);
inline void gnCommandDraw(gnCommandBuffer& commandBuffer, int vertexCount, int instanceCount, int firstVertex = 0, int firstInstance = 0) { _gnCommandDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance); }
//void gnCommandDrawIndexedIndirect(const gnCommandBuffer &commandBuffer, const gnBuffer& buffer, gnSize offset, gnUInt drawCount, gnUInt stride);
inline void (*gnCommandDrawIndexed)(gnCommandBuffer& commandBuffer, gnUInt indexCount, gnUInt instanceCount, gnUInt firstIndex, gnInt vertexOffset, gnUInt firstInstance);
inline void (*gnCommandEndRenderPass)(gnCommandBuffer& commandBuffer);
inline void (*gnCommandBindBuffer)(gnCommandBuffer& commandBuffer, const gnBuffer& buffer);
inline void (*gnCommandBindBufferUniform)(gnCommandBuffer& commandBuffer, gnGraphicsPipeline& graphicsPipeline, gnBufferUniform& uniformBuffer, gnInt set);
inline void (*gnCommandBindSamplerUniform)(gnCommandBuffer& commandBuffer, const gnGraphicsPipeline& graphicsPipeline, const gnSamplerUniform& sampler, gnInt set);
inline void (*gnCommandPushConstant)(gnCommandBuffer& commandBuffer, const gnGraphicsPipeline& graphicsPipeline, const gnPushConstant& pushConstant, void* data);
inline gnReturnCode (*gnCommandBufferEnd)(gnCommandBuffer& commandBuffer);

View File

@@ -0,0 +1,21 @@
#pragma once
#include <gryphn/gryphn_utils.h>
struct gnPlatformCommandBuffer;
struct gnOutputDevice;
struct gnCommandBuffer {
ACCESS_LEVEL:
gnPlatformCommandBuffer* commandBuffer = nullptr;
public:
gnCommandBuffer() {}
};
inline gnReturnCode (*gnCreateCommandBuffer)(gnCommandBuffer* commandBuffer, const gnOutputDevice& outputDevice);
inline gnReturnCode (*_gnCreateCommandBuffers)(gnCommandBuffer* commandBuffers, gnUInt commandBufferCount, const gnOutputDevice& outputDevice);
inline void (*gnCommandBufferReset)(const gnCommandBuffer& commandBuffer);
inline void (*gnDestroyCommandBuffer)(const gnCommandBuffer& commandBuffer);
// because C doesnt support overloading this is how I am going to support overloading, fuck you
static inline gnReturnCode gnCreateCommandBuffers(gnList<gnCommandBuffer> *commandBuffers, const gnOutputDevice& outputDevice) { return _gnCreateCommandBuffers(gnListData(*commandBuffers), gnListLength(*commandBuffers), outputDevice); }
static inline gnReturnCode gnCreateCommandBuffers(std::vector<gnCommandBuffer>* commandBuffers, const gnOutputDevice &outputDevice) { return _gnCreateCommandBuffers(commandBuffers->data(), commandBuffers->size(), outputDevice); }

View File

@@ -0,0 +1,11 @@
#include "gryphn_command_present.h"
void gnCommandPresentDataSetSignalSemaphore(gnCommandPresentData& presentCommandData, gnSyncSemaphore& semaphore) {
presentCommandData.semaphore = &semaphore;
}
void gnCommandPresentDataSetPresentationQueue(gnCommandPresentData& presentCommandData, gnPresentationQueue& presentationQueue) {
presentCommandData.presentationQueue = &presentationQueue;
}
void gnCommandPresentDataSetImageIndex(gnCommandPresentData& presentCommandData, gnUInt* imageIndex) {
presentCommandData.imageIndex = imageIndex;
}

View File

@@ -0,0 +1,25 @@
#include <gryphn/gryphn_utils.h>
#include "core/sync_objects/gryphn_sync_semaphore.h"
#include "core/presentation_queue/gryphn_presentation_queue.h"
#include "core/presentation_queue/gryphn_present_queue_state.h"
struct gnPlatformCommandPresentData;
struct gnCommandBuffer;
struct gnCommandPresentData {
ACCESS_LEVEL:
gnPlatformCommandPresentData* commandPresentData = nullptr;
gnSyncSemaphore* semaphore;
gnPresentationQueue* presentationQueue;
gnUInt* imageIndex;
public:
gnCommandPresentData() {}
};
void gnCommandPresentDataSetSignalSemaphore(gnCommandPresentData& presentCommandData, gnSyncSemaphore& semaphore);
void gnCommandPresentDataSetPresentationQueue(gnCommandPresentData& presentCommandData, gnPresentationQueue& presentationQueue);
void gnCommandPresentDataSetImageIndex(gnCommandPresentData& presentCommandData, gnUInt* imageIndex);
inline gnPresentationQueueState (*gnCommandPresentGetValidPresentationQueue)(gnCommandPresentData& presentCommandData);
inline gnReturnCode (*gnCommandPresent)(gnCommandPresentData& presentCommandData);

View File

@@ -0,0 +1,11 @@
#include "gryphn_command_submit.h"
void gnCommandSubmitDataSetWaitSemaphore(gnCommandSubmitData& data, gnSyncSemaphore& semaphore) {
data.waitSemaphore = &semaphore;
}
void gnCommandSubmitDataSetCommandBuffer(gnCommandSubmitData& data, gnCommandBuffer& commandBuffer) {
data.commandBuffer = &commandBuffer;
}
void gnCommandSubmitDataSetSignalSemaphore(gnCommandSubmitData& data, gnSyncSemaphore& semaphore) {
data.signalSemaphore = &semaphore;
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "core/sync_objects/gryphn_sync_semaphore.h"
#include "core/sync_objects/gryphn_fence.h"
#include "core/commands/gryphn_command_buffer.h"
#include "core/presentation_queue/gryphn_present_queue_state.h"
struct gnPlatformCommandSubmitData;
struct gnCommandSubmitData {
ACCESS_LEVEL:
gnPlatformCommandSubmitData* commandSubmitData = nullptr;
gnSyncSemaphore *waitSemaphore = nullptr, *signalSemaphore = nullptr;
gnCommandBuffer* commandBuffer = nullptr;
public:
gnCommandSubmitData() {}
};
void gnCommandSubmitDataSetWaitSemaphore(gnCommandSubmitData& data, gnSyncSemaphore& semaphore);
void gnCommandSubmitDataSetCommandBuffer(gnCommandSubmitData& data, gnCommandBuffer& commandBuffer);
void gnCommandSubmitDataSetSignalSemaphore(gnCommandSubmitData& data, gnSyncSemaphore& semaphore);
inline gnPresentationQueueState (*gnCommandSubmitGetValidPresentationQueue)(gnCommandSubmitData& presentCommandData);
inline gnErrorCode (*gnCommandSubmit)(gnCommandSubmitData& data, const gnFence& fence);

View File

@@ -0,0 +1,9 @@
#include "gryphn_debugger.h"
void gnAddDebugLayer(gnDebugger& debugger, const gnString& layer) {
gnListAdd(debugger.debug_layers, layer);
}
const gnList<gnString>& gnDebuggerGetDebugLayers(gnDebugger& debugger) {
return debugger.debug_layers;
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include <iostream>
#include "gryphn_layers.h"
struct gnPlatformDebugger;
struct gnDebugger;
static gnDebugger* gnDebuggerInstance = nullptr;
inline void gnDebugError(gnString error);
struct gnDebugger {
ACCESS_LEVEL:
gnPlatformDebugger* debugger;
gnList<gnString> debug_layers = gnCreateList<gnString>();
public:
gnDebugger() {
if (debugger) gnDebugError("Debugger instance already created (you can only have one debugger)");
gnDebuggerInstance = this;
}
};
inline void gnDebugError(gnString error) { std::cout << gnToCString(error) << "\n"; }
void gnAddDebugLayer(gnDebugger& debugger, const gnString& layer);
const gnList<gnString>& gnDebuggerGetDebugLayers(gnDebugger& debugger);
inline gnReturnCode (*gnCreateDebugger)(gnDebugger* instance);
inline void (*gnDestroyDebugger)(gnDebugger& instance);

View File

@@ -0,0 +1,6 @@
#pragma once
#include <gryphn/gryphn_utils.h>
inline gnString (*gnGetPlatformLayerName)(const gnString& gnName);
#define GN_DEFAULT_DEBUG_LAYER gnGetPlatformLayerName("GN_DEFAULT_DEBUG_LAYER")

View File

@@ -0,0 +1,18 @@
#include "gryphn_framebuffer.h"
void gnFramebufferBindAtachment(gnFramebuffer& framebuffer, int index, gnFramebufferAttachment& attachment) {
if (index < gnListLength(framebuffer.framebufferAttachments)) {
gnListSet(framebuffer.framebufferAttachments, index, attachment);
} else {
gnListAdd(framebuffer.framebufferAttachments, attachment);
}
attachment.framebuffer = const_cast<gnFramebuffer*>(&framebuffer);
}
void gnFramebufferBindPresentationQueue(gnFramebuffer& framebuffer, gnPresentationQueue& queue) {
framebuffer.queue = &queue;
}
void gnFramebufferSetSize(gnFramebuffer& framebuffer, gnUInt2 size) {
framebuffer.size = {size.x, size.y};
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include "gryphn_framebuffer_attachment.h"
#include <core/graphics_pipeline/gryphn_render_pass.h>
struct gnPlatformFramebuffer;
struct gnGraphicsPipeline;
struct gnFramebuffer {
ACCESS_LEVEL:
gnPlatformFramebuffer* framebuffer = nullptr;
gnList<gnFramebufferAttachment> framebufferAttachments = gnCreateList<gnFramebufferAttachment>(0);
gnPresentationQueue* queue;
gnUInt2 size;
public:
gnFramebuffer() {}
};
void gnFramebufferBindAtachment(gnFramebuffer& framebuffer, int index, gnFramebufferAttachment& attachment);
void gnFramebufferBindPresentationQueue(gnFramebuffer& framebuffer, gnPresentationQueue& queue);
void gnFramebufferSetSize(gnFramebuffer& framebuffer, gnUInt2 size);
inline gnReturnCode (*gnCreateFramebuffer)(gnFramebuffer* framebuffer, const gnRenderPass& pipeline);
inline void (*gnDestroyFramebuffer)(const gnFramebuffer& framebuffer);

View File

@@ -0,0 +1,17 @@
#include "gryphn_framebuffer_attachment.h"
void gnFramebufferAttachmentSetSize(gnFramebufferAttachment& framebuffer, gnUInt2 newSize) {
framebuffer.size = newSize;
}
void gnFramebufferAttachmentSetColorMode(gnFramebufferAttachment& framebuffer, gnColorMode newColorMode) {
framebuffer.colorMode = newColorMode;
}
void gnFramebufferAttachmentBindTexture(gnFramebufferAttachment& framebuffer, gnTexture* texture) {
framebuffer.texture = texture;
}
void gnFramebufferAttachmentSetBindPoint(gnFramebufferAttachment& framebuffer, gnFramebufferAttachmentBindPoint bindPoint) {
framebuffer.bindPoint = bindPoint;
}

View File

@@ -0,0 +1,31 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "core/presentation_queue/gryphn_presentation_queue.h"
#include <core/textures/gryphn_texture.h>
struct gnPlatformFramebufferAttachment;
struct gnFramebuffer;
enum gnFramebufferAttachmentBindPoint {
GN_COLOR_ATTACHMENT, GN_DEPTH_ATTACHMENT, GN_STENCIL_ATTACHMENT, GN_DEPTH_STENCIL_ATTACHMENT
};
struct gnFramebufferAttachment {
ACCESS_LEVEL:
gnPlatformFramebufferAttachment* framebufferAttachment = nullptr;
gnUInt2 size;
gnColorMode colorMode;
gnFramebufferAttachmentBindPoint bindPoint = GN_COLOR_ATTACHMENT;
gnTexture* texture;
gnFramebuffer* framebuffer;
public:
gnFramebufferAttachment() {}
};
void gnFramebufferAttachmentSetSize(gnFramebufferAttachment& framebuffer, gnUInt2 newSize);
void gnFramebufferAttachmentSetColorMode(gnFramebufferAttachment& framebuffer, gnColorMode newColorMode);
void gnFramebufferAttachmentSetBindPoint(gnFramebufferAttachment& framebuffer, gnFramebufferAttachmentBindPoint bindPoint);
void gnFramebufferAttachmentBindTexture(gnFramebufferAttachment& framebuffer, gnTexture* texture);
inline gnReturnCode (*gnCreateFramebufferAttachment)(gnFramebufferAttachment* attachment, gnPresentationQueue& queue);

View File

@@ -0,0 +1,35 @@
#pragma once
#include <gryphn/gryphn_utils.h>
// this shit is lowkey only supported in vulkan, I think, I know for sure that OpenGL does not support this
// - me in 2024
//
// Now that ive become a little more knowledgable I know that OpenGL automatically works with a dynamic pipeline and vulkan does not
// so im going to change this list of dynamic states and how all this shit works
typedef enum gnDynamicState {
GN_DYNAMIC_STATE_VIEWPORT = 0,
GN_DYNAMIC_STATE_SCISSOR = 1,
// GN_DYNAMIC_STATE_LINE_WIDTH = 2,
// GN_DYNAMIC_STATE_DEPTH_BIAS = 3,
// GN_DYNAMIC_STATE_BLEND_CONSTANTS = 4,
// GN_DYNAMIC_STATE_DEPTH_BOUNDS = 5,
// GN_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6,
// GN_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7,
// GN_DYNAMIC_STATE_STENCIL_REFERENCE = 8,
// GN_DYNAMIC_STATE_CULL_MODE = 9,
// GN_DYNAMIC_STATE_FRONT_FACE = 10,
// GN_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY = 11,
// GN_DYNAMIC_STATE_VIEWPORT_WITH_COUNT = 12,
// GN_DYNAMIC_STATE_SCISSOR_WITH_COUNT = 13,
// GN_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE = 14,
// GN_DYNAMIC_STATE_DEPTH_TEST_ENABLE = 15,
// GN_DYNAMIC_STATE_DEPTH_WRITE_ENABLE = 16,
// GN_DYNAMIC_STATE_DEPTH_COMPARE_OP = 17,
// GN_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE = 18,
// GN_DYNAMIC_STATE_STENCIL_TEST_ENABLE = 19,
// GN_DYNAMIC_STATE_STENCIL_OP = 20,
// GN_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE = 21,
// GN_DYNAMIC_STATE_DEPTH_BIAS_ENABLE = 22,
// GN_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE = 23
} gnDynamicState;

View File

@@ -0,0 +1,65 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_dynamic_state.h"
#include "gryphn_render_pass.h"
#include "core/shaders/gryphn_shader.h"
#include "core/buffers/vertex_descriptions/gryphn_vertex_description.h"
#include "core/push_constant/gryphn_push_constant.h"
#include <core/uniform_descriptor/gryphn_uniform.h>
// things that are needed for compilation
struct gnOutputDevice;
struct gnBufferDescription;
struct gnUniformLayout;
// thse are some dumb things that I figured that would make code look nicer
typedef enum {
GN_POINTS, GN_LINES, GN_LINE_STRIP, GN_TRIANGLES
} gnPrimative; // todo support more primative types
typedef enum {
GN_POLYGON_FILLMODE_FILL, GN_POLYGON_FILLMODE_LINES, GN_POLYGON_FILLMODE_POINTS
} gnFillMode;
typedef enum {
GN_CULL_NONE, GN_CULL_BACKFACE, GN_CULL_FRONTFACE
} gnCullMode; // idk why you would cull all but idk I added this
typedef enum {
GN_CLOCKWISE, GN_COUNTER_CLOCKWISE
} gnFrontFaceDirection;
struct gnPlatformGraphicsPipeline;
struct gnGraphicsPipeline {
ACCESS_LEVEL:
gnPlatformGraphicsPipeline* graphicsPipeline = nullptr;
gnPrimative primative;
gnRenderPass* renderPass;
std::vector<gnUniformLayout*> uniformLayouts = {};
std::vector<gnPushConstant*> pushConstants = {};
public:
gnGraphicsPipeline() {}
};
inline void (*gnGraphicsPipelineSetPrimative)(gnGraphicsPipeline& pipeline, gnPrimative primative);
inline void (*gnGraphicsPipelineEnableDynamicStates)(gnGraphicsPipeline& pipeline, const gnBool enable);
inline void (*gnGraphicsPipelineEnableDynamicState)(gnGraphicsPipeline& pipeline, const gnDynamicState state);
inline void (*_gnGraphicsPipelineSetViewport)(gnGraphicsPipeline& pipeline, gnUInt2 position, gnUInt2 size, gnFloat minDepth, gnFloat maxDepth);
inline static void gnGraphicsPipelineSetViewport(gnGraphicsPipeline& pipeline, gnUInt2 position, gnUInt2 size, gnFloat minDepth = 0.0f, gnFloat maxDepth = 1.0f) { _gnGraphicsPipelineSetViewport(pipeline, position, size, minDepth, maxDepth); }
inline void (*gnGraphicsPipelineSetCrop)(gnGraphicsPipeline& graphicsPipeline, gnInt2 position, gnUInt2 size);
inline void (*gnGraphicsPipelineSetDepthClamp)(gnGraphicsPipeline& graphicsPipeline, gnBool enableDepthClamp);
inline void (*gnGraphicsPipelineSetFillMode)(gnGraphicsPipeline& graphicsPipeline, gnFillMode fillMode);
inline void (*gnGraphicsPipelineSetLineWidth)(gnGraphicsPipeline& graphicsPipeline, gnFloat lineWidth);
inline void (*gnGraphicsPipelineSetCullMode)(gnGraphicsPipeline& graphicsPipeline, gnCullMode cullMode, gnFrontFaceDirection direction);
inline void (*gnGraphicsPipelineSetMultisampling)(gnGraphicsPipeline& graphicsPipeline, gnBool enableMultisampling);
inline void (*gnGraphicsPipelineEnableDepthTest)(gnGraphicsPipeline& graphicsPipeline, gnBool depthTest);
inline void (*gnGraphicsPipelineSetColorBlend)(gnGraphicsPipeline& graphicsPipeline, gnBool colorBlend);
inline void (*gnGraphicsPipelineSetVertexDescription)(gnGraphicsPipeline& graphicsPipeline, const gnVertexDescription& vertexDescription);
inline void (*gnGraphicsPipelineBindShader)(gnGraphicsPipeline& graphicsPipeline, const gnShader& shader);
inline void (*gnGraphicsPipelineSetRenderPass)(gnGraphicsPipeline& graphicsPipeline, gnRenderPass& renderpass);
inline void (*gnGraphicsPipelineAddUniformLayout)(gnGraphicsPipeline& graphicsPipeline, const gnUniformLayout& uniformLayout);
inline void (*gnGraphicsPipelineAddPushConstant)(gnGraphicsPipeline& graphicsPipeline, const gnPushConstant& pushConstant);
inline gnReturnCode (*gnCreateGraphicsPipeline)(gnGraphicsPipeline* graphicsPipeline, gnOutputDevice& outputDevice);
inline void (*gnDestroyGraphicsPipeline)(gnGraphicsPipeline& graphicsPipeline);

View File

@@ -0,0 +1,22 @@
#include "gryphn_render_pass.h"
void gnRenderPassAddSubpass(gnRenderPass& renderPass, gnSubpass& subpass) {
gnListAdd(renderPass.subpasses, &subpass);
}
void gnRenderPassSetPresentationQueue(gnRenderPass& renderPass, gnPresentationQueue& presentationQueue) {
renderPass.presentationQueue = &presentationQueue;
gnRenderPassSetTarget(renderPass, GN_PRESENTATION_QUEUE);
}
void gnRenderPassSetAttachments(gnRenderPass& renderPass, int count, gnRenderpassAttachment* attachments) {
renderPass.attachments = attachments;
renderPass.attachmentCount = count;
}
void gnRenderPassSetTarget(gnRenderPass& renderPass, gnRenderPassTarget target) {
renderPass.target = target;
}
void gnRenderpassAttachmentSetColorMode(gnRenderpassAttachment& attachment, gnColorMode colorMode) {
attachment.colorMode = colorMode;
}

View File

@@ -0,0 +1,34 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_subpass.h"
#include "gryphn_render_pass_attchment.h"
#include "core/presentation_queue/gryphn_presentation_queue.h"
struct gnPlatformRenderPass;
struct gnOutputDevice;
typedef enum {
GN_SHADER_READ, GN_PRESENTATION_QUEUE
} gnRenderPassTarget;
struct gnRenderPass {
ACCESS_LEVEL:
gnPlatformRenderPass* renderpass = nullptr;
gnList<gnSubpass*> subpasses;
gnPresentationQueue* presentationQueue = nullptr;
gnRenderpassAttachment* attachments = nullptr;
int attachmentCount = 0;
gnRenderPassTarget target;
public:
gnRenderPass() {}
};
void gnRenderPassAddSubpass(gnRenderPass& renderPass, gnSubpass& subpass);
void gnRenderPassSetPresentationQueue(gnRenderPass& renderPass, gnPresentationQueue& presentationQueue);
void gnRenderPassSetAttachments(gnRenderPass& renderPass, int count, gnRenderpassAttachment* attachments);
void gnRenderPassSetTarget(gnRenderPass& renderPass, gnRenderPassTarget target);
inline gnReturnCode (*gnCreateRenderPass)(gnRenderPass* renderPass, const gnOutputDevice& outputDevice);
inline void (*gnDestroyRenderPass)(gnRenderPass& renderPass);

View File

@@ -0,0 +1,15 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include <core/textures/gryphn_texture.h>
struct gnPlatformRenderpassAttachment;
struct gnRenderpassAttachment {
ACCESS_LEVEL:
gnPlatformRenderpassAttachment* renderpassAttachment = nullptr;
gnColorMode colorMode;
public:
gnRenderpassAttachment() {}
};
void gnRenderpassAttachmentSetColorMode(gnRenderpassAttachment& attachment, gnColorMode colorMode);

View File

@@ -0,0 +1,17 @@
#include "gryphn_render_pass_frame.h"
void gnRenderPassFrameSetRenderPass(gnRenderPassFrame& frame, gnRenderPass& renderPass) {
frame.renderPass = &renderPass;
}
void gnRenderPassFrameSetFramebuffer(gnRenderPassFrame& frame, gnFramebuffer& framebuffer) {
frame.framebuffer = &framebuffer;
}
void gnRenderPassFrameSetOffset(gnRenderPassFrame& frame, gnUInt2 offset) {
frame.offset = offset;
}
void gnRenderPassFrameSetRenderArea(gnRenderPassFrame& frame, gnUInt2 area) {
frame.area = area;
}
void gnRenderPassFrameSetClearColor(gnRenderPassFrame& frame, gnColor& clearColor) {
frame.clearColor = clearColor;
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_render_pass.h"
struct gnPlatformRenderPassFrame;
struct gnFramebuffer;
struct gnRenderPassFrame {
ACCESS_LEVEL:
gnPlatformRenderPassFrame* renderPassFrame = nullptr;
gnRenderPass* renderPass;
gnFramebuffer* framebuffer;
gnUInt2 offset;
gnUInt2 area;
gnColor clearColor;
public:
gnRenderPassFrame() {}
};
void gnRenderPassFrameSetRenderPass(gnRenderPassFrame& frame, gnRenderPass& renderPass);
void gnRenderPassFrameSetFramebuffer(gnRenderPassFrame& frame, gnFramebuffer& framebuffer);
void gnRenderPassFrameSetOffset(gnRenderPassFrame& frame, gnUInt2 offset);
void gnRenderPassFrameSetRenderArea(gnRenderPassFrame& frame, gnUInt2 area);
void gnRenderPassFrameSetClearColor(gnRenderPassFrame& frame, gnColor& clearColor);

View File

@@ -0,0 +1,13 @@
#pragma once
#include <gryphn/gryphn_utils.h>
struct gnPlatformSubpass;
// I only think that this is a thing in vulkan
// - greg, march 11th 7:15
struct gnSubpass {
ACCESS_LEVEL:
gnPlatformSubpass* subpass = nullptr;
public:
gnSubpass() {}
};

View File

@@ -0,0 +1,25 @@
#pragma once
#include "gryphn/gryphn_utils.h"
enum gnRenderingAPI {
GN_RENDERINGAPI_NONE, // idk why im putting this
GN_RENDERINGAPI_SOFTWARE, // i kinda wanna write a software renderer
GN_RENDERINGAPI_OPENGL,
GN_RENDERINGAPI_VULKAN,
GN_RENDERINGAPI_DIRECTX11, GN_RENDERINGAPI_DIRECTX12,
GN_RENDERINGAPI_METAL
};
inline gnString gnRenderingAPIName(gnRenderingAPI api) {
switch (api) {
case GN_RENDERINGAPI_NONE: return "GN_RENDERINGAPI_NONE";
case GN_RENDERINGAPI_SOFTWARE: return "GN_RENDERINGAPI_SOFTWARE";
case GN_RENDERINGAPI_OPENGL: return "GN_RENDERINGAPI_OPENGL";
case GN_RENDERINGAPI_VULKAN: return "GN_RENDERINGAPI_VULKAN";
case GN_RENDERINGAPI_DIRECTX11: return "GN_RENDERINGAPI_DIRECTX11";
case GN_RENDERINGAPI_DIRECTX12: return "GN_RENDERINGAPI_DIRECTX12";
case GN_RENDERINGAPI_METAL: return "GN_RENDERINGAPI_METAL";
}
return "GN_INVALID_API";
}

View File

@@ -0,0 +1,8 @@
#pragma once
#include <gryphn/gryphn_utils.h>
typedef enum gnFeature {
GN_DYNAMIC_STATES, GN_SYNC_OBJECTS
} gnFeature;
inline gnBool (*gnAPISupports)(gnFeature feature);

View File

@@ -0,0 +1,154 @@
#include <core/init/gryphn_init.h>
#include <dlfcn.h>
#include <platform/gryphn_platform_include.h>
#include <algorithm>
#include <gryphn/gryphn.h>
bool RenderingAPISupported(gnRenderingAPI api) {
std::vector<gnRenderingAPI> supportedRenderingAPIS = gnGetSupportedRenderingAPIS();
return std::find(supportedRenderingAPIS.begin(), supportedRenderingAPIS.end(), api) != supportedRenderingAPIS.end();
}
static void* gnRenderingAPILIB;
//#define LOAD_FUNC(dll, func) gnPlatformLoadDLLFunction(dll, func, gnString(#func) + "Fn")
#define gnLoadDLLFunction(dll, func, func_name) \
gnPlatformLoadDLLFunction(dll, func, func_name); \
if (func == nullptr) return gnReturnError(gnString("GN_FUNC_(") + gnString(#func) + ")_NOT_LOADED")
gnReturnCode gnInit(gnRenderingAPI RenderingAPI) {
gnString libName = "";
switch (RenderingAPI) {
case GN_RENDERINGAPI_NONE: {
return { GN_FAILED, "GN_ERROR_RENDERINGAPI_NONE_UNSUPPORTED" };
}
case GN_RENDERINGAPI_SOFTWARE: {
return { GN_FAILED, "GN_ERROR_SOFRWARE_UNSUPPORTED" };
}
case GN_RENDERINGAPI_OPENGL: {
return { GN_FAILED, "GN_ERROR_OPENGL_UNSUPPORTED" };
}
case GN_RENDERINGAPI_VULKAN: {
if (!RenderingAPISupported(GN_RENDERINGAPI_VULKAN)) return { GN_FAILED, "GN_ERROR_VUKAN_UNSUPPORTED" };
libName = "GryphnVulkanImpl";
break;
}
case GN_RENDERINGAPI_DIRECTX11: {
return { GN_FAILED, "GN_ERROR_DIRECTX11_UNSUPPORTED" };
}
case GN_RENDERINGAPI_DIRECTX12: {
return { GN_FAILED, "GN_ERROR_DIRECTX12_UNSUPPORTED" };
}
case GN_RENDERINGAPI_METAL: {
if (!RenderingAPISupported(GN_RENDERINGAPI_METAL)) return { GN_FAILED, "GN_ERROR_METAL_UNSUPPORTED" };
libName = "GryphnMetalImpl";
break;
}
}
gnRenderingAPILIB = gnPlatformLoadDLL(gnString("gryphn/rendering_apis/") + libName);
if (!gnRenderingAPILIB) { return gnReturnError("GN_ERROR_UNABLE_TO_LOAD_DLL"); }
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateInstance, "gnCreateInstanceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyInstance, "gnDestroyInstanceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGetPlatformLayerName, "gnGetPlatformLayerNameFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnInstanceSetWindow, "gnInstanceSetWindowFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateDebugger, "gnCreateDebuggerFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyDebugger, "gnDestroyDebuggerFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGetPhysicalOutputDevices, "gnGetPhysicalOutputDevicesFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDeviceSupportsAPI, "gnDeviceSupportsAPIFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnRegisterOutputDevice, "gnRegisterOutputDeviceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnWaitForDevice, "gnWaitForDeviceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGetDevicePresentationDetails, "gnGetDevicePresentationDetailsFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnPresentationQueueGetNextImageAsync, "gnPresentationQueueGetNextImageAsyncFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnPresentationQueueGetState, "gnPresentationQueueGetStateFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreatePresentationQueue, "gnCreatePresentationQueueFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyPresentationQueue, "gnDestroyPresentationQueueFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetBindingDescription, "gnVertexDescriptionSetBindingDescriptionFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetPropertiesCount, "gnVertexDescriptionSetPropertiesCountFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetProperty, "gnVertexDescriptionSetPropertyFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateBuffer, "gnCreateBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBufferData, "gnBufferDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBufferMapData, "gnBufferMapDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyBuffer, "gnDestroyBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBufferSubData, "gnBufferSubDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBufferClearData, "gnBufferClearDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnTextureData, "gnTextureDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnTextureCubeMapData, "gnTextureCubeMapDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateTexture, "gnCreateTextureFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyTexture, "gnDestroyTextureFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateUniformLayout, "gnCreateUniformLayoutFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyUniformLayout, "gnDestroyUniformLayoutFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateRenderPass, "gnCreateRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyRenderPass, "gnDestroyRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFence, "gnCreateFenceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnWaitForFence, "gnWaitForFenceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnResetFence, "gnResetFenceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyFence, "gnDestroyFenceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateCommandBuffer, "gnCreateCommandBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, _gnCreateCommandBuffers, "_gnCreateCommandBuffersFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferReset, "gnCommandBufferResetFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyCommandBuffer, "gnDestroyCommandBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBuildShaderModule, "gnBuildShaderModuleFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyShaderModule, "gnDestroyShaderModuleFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBuildShader, "gnBuildShaderFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateUniform, "gnCreateUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyUniform, "gnDestroyUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnUpdateSamplerUniform, "gnUpdateSamplerUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnUpdateBufferUniform, "gnUpdateBufferUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnAPISupports, "gnAPISupportsFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetPrimative, "gnGraphicsPipelineSetPrimativeFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDynamicStates, "gnGraphicsPipelineEnableDynamicStatesFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDynamicState, "gnGraphicsPipelineEnableDynamicStateFn");
gnLoadDLLFunction(gnRenderingAPILIB, _gnGraphicsPipelineSetViewport, "_gnGraphicsPipelineSetViewportFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetCrop, "gnGraphicsPipelineSetCropFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetDepthClamp, "gnGraphicsPipelineSetDepthClampFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetFillMode, "gnGraphicsPipelineSetFillModeFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetLineWidth, "gnGraphicsPipelineSetLineWidthFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetCullMode, "gnGraphicsPipelineSetCullModeFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetMultisampling, "gnGraphicsPipelineSetMultisamplingFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDepthTest, "gnGraphicsPipelineEnableDepthTestFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetColorBlend, "gnGraphicsPipelineSetColorBlendFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetVertexDescription, "gnGraphicsPipelineSetVertexDescriptionFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineBindShader, "gnGraphicsPipelineBindShaderFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetRenderPass, "gnGraphicsPipelineSetRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineAddUniformLayout, "gnGraphicsPipelineAddUniformLayoutFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineAddPushConstant, "gnGraphicsPipelineAddPushConstantFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateGraphicsPipeline, "gnCreateGraphicsPipelineFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFramebuffer, "gnCreateFramebufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyFramebuffer, "gnDestroyFramebufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFramebufferAttachment, "gnCreateFramebufferAttachmentFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateSyncSemaphore, "gnCreateSyncSemaphoreFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroySyncSemaphore, "gnDestroySyncSemaphoreFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferStart, "gnCommandBufferStartFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferEnd, "gnCommandBufferEndFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBeginRenderPass, "gnCommandBeginRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetGraphicsPipeline, "gnCommandSetGraphicsPipelineFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindSamplerUniform, "gnCommandBindSamplerUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindBuffer, "gnCommandBindBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindBufferUniform, "gnCommandBindBufferUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPushConstant, "gnCommandPushConstantFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandDrawIndexed, "gnCommandDrawIndexedFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetViewport, "gnCommandSetViewportFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetScissor, "gnCommandSetScissorFn");
gnLoadDLLFunction(gnRenderingAPILIB, _gnCommandDraw, "gnCommandDrawFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandEndRenderPass, "gnCommandEndRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSubmitGetValidPresentationQueue, "gnCommandSubmitGetValidPresentationQueueFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSubmit, "gnCommandSubmitFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPresentGetValidPresentationQueue, "gnCommandPresentGetValidPresentationQueueFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPresent, "gnCommandPresentFn");
// fucking hell I just realized that I do have to load in all the commands
// I hate the way I chose to do this
return GN_SUCCESS;
}
void gnDestroy() {
dlclose(gnRenderingAPILIB);
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include <core/gryphn_rendering_api.h>
gnErrorCode gnInit(gnRenderingAPI RenderingAPI);
void gnDestroy();
inline gnString cachePath;
static void gnSetCachePath(const gnString& path) { cachePath = path; }
static const gnString& gnGetCachePath() { return cachePath; }

View File

@@ -0,0 +1,10 @@
#pragma once
#include <gryphn/gryphn_utils.h>
struct gnAppInfo {
public:
gnString ApplicationName;
gnString EngineName;
gnVersion ApplicationVersion;
gnVersion EngineVersion;
};

View File

@@ -0,0 +1,9 @@
#include "gryphn_instance.h"
void gnInstanceSetDebugger(gnInstance& instance, gnDebugger& debugger) {
instance.debugger = &debugger;
}
void gnInstanceSetAppInfo(gnInstance& instance, const gnAppInfo info) {
instance.AppInfo = info;
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "application_information/gryphn_app_info.h"
#include "core/debugger/gryphn_debugger.h"
#include <core/output_device/gryphn_output_device.h>
class GLFWwindow;
struct gnPlatformInstanceData;
struct gnInstance {
ACCESS_LEVEL:
bool valid = false;
gnPlatformInstanceData* instance = nullptr;
gnAppInfo AppInfo;
gnDebugger* debugger;
public:
gnInstance() {}
};
void gnInstanceSetAppInfo(gnInstance& instance, const gnAppInfo info);
void gnInstanceSetDebugger(gnInstance& instance, gnDebugger& debugger);
inline gnReturnCode (*gnCreateInstance)(gnInstance* instance);
inline void (*gnDestroyInstance)(gnInstance& instance);
inline gnReturnCode (*gnInstanceSetWindow)(gnInstance& instance, GLFWwindow* window);
// TODO: if instance creation fails add in a query to why the instance creation failed
// Lowkey thats a lot of work tho and I dont really want to do alllllll that

View File

@@ -0,0 +1,19 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_physical_output_device.h"
struct gnPlatformOutputDevice;
struct gnPhysicalOutputDevice;
struct gnInstance;
struct gnOutputDevice {
ACCESS_LEVEL:
gnPlatformOutputDevice* outputDevice = nullptr;
gnPhysicalOutputDevice* physicalOutputDevice;
public:
gnOutputDevice() {}
};
inline gnReturnCode (*gnRegisterOutputDevice)(gnOutputDevice* outputDevice, const gnInstance& instance, const gnPhysicalOutputDevice& physicalDevice);
inline void (*gnWaitForDevice)(const gnOutputDevice& device);
inline void (*gnDestroyOutputDevice)(gnOutputDevice& device);

View File

@@ -0,0 +1,3 @@
#include "gryphn_physical_output_device.h"
gnString gnGetPhysicalOutputDeviceName(const gnPhysicalOutputDevice& device) { return device.outputDeviceName; }

View File

@@ -0,0 +1,19 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "core/instance/gryphn_instance.h"
struct gnPlatformPhysicalOutputDevice;
struct gnInstance;
struct gnPhysicalOutputDevice {
ACCESS_LEVEL:
bool valid = false;
gnPlatformPhysicalOutputDevice* physicalOutputDevice = nullptr;
gnString outputDeviceName;
public:
gnPhysicalOutputDevice() {}
};
gnString gnGetPhysicalOutputDeviceName(const gnPhysicalOutputDevice& device);
inline bool (*gnDeviceSupportsAPI)(const gnPhysicalOutputDevice& device);
inline gnList<gnPhysicalOutputDevice> (*gnGetPhysicalOutputDevices)(const gnInstance& instance);

View File

@@ -0,0 +1,9 @@
#pragma once
#include "../output_device/gryphn_physical_output_device.h"
struct gnDevicePresentationDetails {
public:
int MinimumImageCount, MaximumImageCount;
};
inline gnDevicePresentationDetails (*gnGetDevicePresentationDetails)(const gnPhysicalOutputDevice& physicalOutputDevice);

View File

@@ -0,0 +1,5 @@
#pragma once
enum gnPresentationQueueState {
GN_OUT_OF_DATE, GN_SUBOPTIMAL, GN_VALID
};

View File

@@ -0,0 +1,7 @@
#pragma once
#include <gryphn/gryphn_utils.h>
struct gnPresentationDetails {
gnUInt ImageCount;
gnUInt2 ImageSize;
};

View File

@@ -0,0 +1,6 @@
#include "gryphn_presentation_queue.h"
gnTexture* gnGetPresentationQueueImage(gnPresentationQueue& presentationQueue, int index) {
// if (index < gnListLength(presentationQueue.images))
return gnListGetPtr(presentationQueue.images, index); // zero fucking error checking in this file, im not doing that shit
}

View File

@@ -0,0 +1,31 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_presentation_details.h"
#include "core/output_device/gryphn_output_device.h"
#include "core/sync_objects/gryphn_sync_semaphore.h"
#include "gryphn_present_queue_state.h"
#include "core/textures/gryphn_texture.h"
#include "gryphn_device_presentation_details.h"
struct gnPlatformPresentationQueue;
struct gnPresentationQueue {
ACCESS_LEVEL:
gnPlatformPresentationQueue* presentationQueue;
bool valid = false;
gnList<gnTexture> images = gnCreateList<gnTexture>();
public:
gnPresentationQueue() {}
};
gnTexture* gnGetPresentationQueueImage(gnPresentationQueue& presentationQueue, int index);
inline gnReturnCode (*gnCreatePresentationQueue)(gnPresentationQueue* presentationQueue, const gnOutputDevice& device, gnPresentationDetails& details);
inline void (*gnDestroyPresentationQueue)(gnPresentationQueue& queue);
inline gnImageFormat (*_gnPresentationQueueGetImageFormat)(gnPresentationQueue& presentationQueue);
inline gnImageFormat gnPresentationQueueGetImageFormat(gnPresentationQueue& presentationQueue) {
std::cout << "gnPresentationQueueGetImageFormat should lowkey become supported\n";
return _gnPresentationQueueGetImageFormat(presentationQueue);
}
inline gnPresentationQueueState (*gnPresentationQueueGetState)(gnPresentationQueue& presentationQueue);
inline gnReturnCode (*gnPresentationQueueGetNextImageAsync)(gnPresentationQueue& presentationQueue, const gnSyncSemaphore& semaphore, gnUInt* imageIndex);

View File

@@ -0,0 +1,11 @@
#include "gryphn_push_constant.h"
void gnPushConstantSetShaderStage(gnPushConstant& pushConstant, gnShaderModuleStage stage) {
pushConstant.stage = stage;
}
void gnPushConstantSetOffset(gnPushConstant& pushConstant, gnSize offset){
pushConstant.offset = offset;
}
void gnPushConstantSetSize(gnPushConstant& pushConstant, gnSize size) {
pushConstant.size = size;
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "core/shaders/gryphn_shader_module.h"
struct gnPlatformPushConstant;
struct gnPushConstant {
ACCESS_LEVEL:
gnPlatformPushConstant* pushConstant = nullptr;
gnShaderModuleStage stage = 0;
gnSize offset = 0;
gnSize size = 0;
public:
gnPushConstant() {}
};
void gnPushConstantSetShaderStage(gnPushConstant& pushConstant, gnShaderModuleStage stage);
void gnPushConstantSetOffset(gnPushConstant& pushConstant, gnSize offset);
void gnPushConstantSetSize(gnPushConstant& pushConstant, gnSize size);

View File

@@ -0,0 +1,3 @@
#include "gryphn_shader.h"
void gnShaderAddModule(gnShader& shader, gnShaderModule& module) { gnListAdd(shader.shaderModules, module); }

View File

@@ -0,0 +1,18 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_shader_module.h"
struct gnPlatformShader;
struct gnShader {
ACCESS_LEVEL:
gnPlatformShader* shader;
gnList<gnShaderModule> shaderModules = gnCreateList<gnShaderModule>();
public:
gnShader() {}
};
void gnShaderAddModule(gnShader& shader, gnShaderModule& module);
inline gnReturnCode (*gnBuildShader)(gnShader* shader);
inline void (*gnShaderDestroyModules)(gnShader& shader);

View File

@@ -0,0 +1,23 @@
#include "gryphn_shader_module.h"
void gnSetShaderModuleType(gnShaderModule& module, gnShaderModuleStage shaderModuleType) {
module.shaderType = shaderModuleType;
}
void gnSetShaderModuleUse(gnShaderModule& module, gnShaderUse shaderUse) {
module.shaderUse = shaderUse;
}
void gnSetShaderModuleCode(gnShaderModule& module, gnList<gnByte>& shaderModuleCode) {
module.codeSize = gnListLength(shaderModuleCode);
module.shaderData = gnListData(shaderModuleCode);
}
void gnSetShaderModuleCode(gnShaderModule& module, gnList<gnByte> shaderModuleCode) {
module.codeSize = gnListLength(shaderModuleCode);
module.shaderData = gnListData(shaderModuleCode);
}
void gnSetShaderModuleCode(gnShaderModule& module, const std::vector<char>& shaderModuleCode) {
module.codeSize = shaderModuleCode.size();
module.shaderData = const_cast<gnChar*>(shaderModuleCode.data());
}
gnBool gnContainsShaderStage(gnShaderModuleStage stage, gnShaderModuleStage stageToContain);

View File

@@ -0,0 +1,42 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "core/output_device/gryphn_output_device.h"
#include <vector>
typedef gnUByte gnShaderModuleStage;
#define GN_VERTEX_SHADER_MODULE 0x01
#define GN_FRAGMENT_SHADER_MODULE 0x10
typedef gnUInt gnShaderUse;
#define GN_GRAPHICS_PIPELINE 0
inline gnBool gnContainsShaderStage(gnShaderModuleStage stage, gnShaderModuleStage stageToContain) {
if ((stage & stageToContain) == stageToContain) return true;
return false;
}
struct gnPlatformShaderModule;
struct gnShaderModule {
ACCESS_LEVEL:
gnPlatformShaderModule* shaderModule = nullptr;
gnShaderModuleStage shaderType;
gnShaderUse shaderUse = GN_GRAPHICS_PIPELINE;
int codeSize = -1;
gnByte* shaderData = nullptr;
bool valid = false;
public:
gnShaderModule() {}
};
void gnSetShaderModuleType(gnShaderModule& module, gnShaderModuleStage shaderModuleType);
void gnSetShaderModuleUse(gnShaderModule& module, gnShaderUse shaderUse);
void gnSetShaderModuleCode(gnShaderModule& module, gnList<gnByte>& shaderModuleCode);
void gnSetShaderModuleCode(gnShaderModule& module, gnList<gnByte> shaderModuleCode);
void gnSetShaderModuleCode(gnShaderModule& module, const std::vector<char>& shaderModuleCode);
inline gnReturnCode (*gnBuildShaderModule)(gnShaderModule* module, const gnOutputDevice& outputDevice);
inline void (*gnDestroyShaderModule)(gnShaderModule& module);

View File

@@ -0,0 +1,17 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "core/output_device/gryphn_output_device.h"
struct gnPlatformFence;
struct gnFence {
ACCESS_LEVEL:
gnPlatformFence* fence = nullptr;
public:
gnFence() {}
};
inline gnReturnCode (*gnCreateFence)(gnFence* fence, const gnOutputDevice& device);
inline void (*gnWaitForFence)(const gnFence& fence);
inline void (*gnResetFence)(gnFence& fence);
inline void (*gnDestroyFence)(gnFence& fence);

View File

@@ -0,0 +1,15 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "core/output_device/gryphn_output_device.h"
struct gnPlatformSyncSemaphore;
struct gnSyncSemaphore {
ACCESS_LEVEL:
gnPlatformSyncSemaphore* semaphore = nullptr;
public:
gnSyncSemaphore() {}
};
inline gnReturnCode (*gnCreateSyncSemaphore)(gnSyncSemaphore* semaphore, const gnOutputDevice& device);
inline void (*gnDestroySyncSemaphore)(const gnSyncSemaphore& semaphore);

View File

@@ -0,0 +1,24 @@
#include "gryphn_texture.h"
void gnTextureSetType(gnTexture& texture, gnTextureType type) {
texture.textureType = type;
}
void gnTextureSetFormat(gnTexture& texture, gnColorMode format) {
texture.textureColorFormat = format;
}
void gnTextureSetExtent(gnTexture& texture, gnUInt2 extent) {
texture.textureExtent = extent;
}
void gnTextureSetDataSize(gnTexture& texture, gnUInt dataSize) {
texture.dataSize = dataSize;
}
void gnTextureSetMinFilter(gnTexture& texture, gnTextureFilter filter) {
texture.minFilter = filter;
}
void gnTextureSetMagFilter(gnTexture& texture, gnTextureFilter filter) {
texture.magFilter = filter;
}
// int gnTexture::currentTextureID = 0;
gnUInt gnGetTextureID(const gnTexture& texture) { return texture.TextureID; }

View File

@@ -0,0 +1,48 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "core/output_device/gryphn_output_device.h"
enum gnTextureType {
GN_TEXTURE_2D = 0, GN_TEXTURE_CUBE_MAP = 1
};
enum gnTextureFilter {
GN_FILTER_LINEAR = 0, GN_FILTER_NEAREST = 1
};
struct gnPlatformTexture;
static int currentTextureID = 0;
struct gnTexture {
ACCESS_LEVEL:
gnPlatformTexture* texture = nullptr;
gnTextureType textureType;
gnColorMode textureColorFormat;
gnUInt2 textureExtent;
gnTextureFilter minFilter = GN_FILTER_LINEAR;
gnTextureFilter magFilter = GN_FILTER_LINEAR;
gnUInt dataSize;
gnUInt TextureID;
public:
gnTexture() {
// I should handle this somewhere else but im not going to
TextureID = currentTextureID;
currentTextureID++;
}
};
void gnTextureSetType(gnTexture& texture, gnTextureType type);
void gnTextureSetFormat(gnTexture& texture, gnColorMode format);
void gnTextureSetExtent(gnTexture& texture, gnUInt2 extent);
inline void gnTextureSetSize(gnTexture& texture, gnUInt2 size) { gnTextureSetExtent(texture, size); }
void gnTextureSetMinFilter(gnTexture& texture, gnTextureFilter filter);
void gnTextureSetMagFilter(gnTexture& texture, gnTextureFilter filter);
gnUInt gnGetTextureID(gnTexture& texture);
inline void (*gnTextureData)(gnTexture& texture, gnSize dataSize, const void* data);
inline void (*gnTextureCubeMapData)(gnTexture& texture, gnSize imageDataSize, void* face1, void* face2, void* face3, void* face4, void* face5, void* face6);
inline gnErrorCode (*gnCreateTexture)(gnTexture* texture, const gnOutputDevice& outputDevice);
inline void (*gnDestroyTexture)(gnTexture& texture);

View File

@@ -0,0 +1,8 @@
#include "gryphn_uniform.h"
void gnUniformSetCount(gnUniform& uniform, gnUInt count) {
uniform.descriptorCount = count;
}
void gnUniformSetLayout(gnUniform& uniform, gnUniformLayout* uniformLayout) {
uniform.uniformLayout = uniformLayout;
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_uniform_layout.h"
struct gnPlatformUniform;
struct gnUniform {
ACCESS_LEVEL:
gnPlatformUniform* uniform = nullptr;
gnUniformLayout* uniformLayout;
int descriptorCount;
public:
gnUniform() {}
};
void gnUniformSetCount(gnUniform& uniform, gnUInt count);
void gnUniformSetLayout(gnUniform& uniform, gnUniformLayout* uniformLayout);
inline gnReturnCode (*gnCreateUniform)(gnUniform* uniform, gnOutputDevice& outputDevice);
inline void (*gnDestroyUniform)(gnUniform& uniform);

View File

@@ -0,0 +1,20 @@
#include "gryphn_uniform_layout.h"
void gnUniformLayoutBindingSetBinding(gnUniformLayoutBinding& uniformLayoutBinding, gnUInt binding) {
uniformLayoutBinding.binding = binding;
}
void gnUniformLayoutBindingSetShaderStage(gnUniformLayoutBinding& uniformLayoutBinding, gnShaderModuleStage stage) {
uniformLayoutBinding.stage = stage;
}
void gnUniformLayoutBindingSetType(gnUniformLayoutBinding& uniformLayoutBinding, gnUniformLayoutBindingType type) {
uniformLayoutBinding.type = type;
}
void gnUniformLayoutAddBinding(gnUniformLayout& uniformLayout, gnUniformLayoutBinding binding) {
uniformLayout.bindings.push_back(binding);
}
std::vector<gnUniformLayoutBinding> gnUniformLayoutGetBindings(gnUniformLayout& uniformLayout) {
return uniformLayout.bindings;
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "gryphn_uniform_layout_binding.h"
struct gnPlatformUniformLayout;
struct gnUniformLayout {
ACCESS_LEVEL:
gnPlatformUniformLayout* uniformLayout = nullptr;
std::vector<gnUniformLayoutBinding> bindings;
public:
gnUniformLayout() {}
};
void gnUniformLayoutAddBinding(gnUniformLayout& uniformLayout, gnUniformLayoutBinding binding);
std::vector<gnUniformLayoutBinding> gnUniformLayoutGetBindings(gnUniformLayout& uniformLayout);
inline gnReturnCode (*gnCreateUniformLayout)(gnUniformLayout* uniformLayout, gnOutputDevice& device);
inline void (*gnDestroyUniformLayout)(gnUniformLayout& uniformLayout);

View File

@@ -0,0 +1,24 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include <core/shaders/gryphn_shader.h>
struct gnPlatformUniformLayoutBinding;
typedef int gnUniformLayoutBindingType;
#define GN_UNIFORM_BUFFER_DESCRIPTOR 0
#define GN_SAMPLER_DESCRIPTOR 1
struct gnUniformLayoutBinding {
ACCESS_LEVEL:
gnPlatformUniformLayoutBinding* uniformLayoutBinding;
gnUInt binding = 0;
gnShaderModuleStage stage = GN_VERTEX_SHADER_MODULE;
gnUniformLayoutBindingType type = GN_UNIFORM_BUFFER_DESCRIPTOR;
public:
gnUniformLayoutBinding() {}
};
void gnUniformLayoutBindingSetBinding(gnUniformLayoutBinding& uniformLayoutBinding, gnUInt binding);
void gnUniformLayoutBindingSetShaderStage(gnUniformLayoutBinding& uniformLayoutBinding, gnShaderModuleStage stage);
void gnUniformLayoutBindingSetType(gnUniformLayoutBinding& uniformLayoutBinding, gnUniformLayoutBindingType type);

View File

@@ -0,0 +1,17 @@
#include "gryphn_sampler.h"
void gnSamplerUniformSetTexture(gnSamplerUniform& samplerUniform, const gnTexture& texture) {
samplerUniform.texture = const_cast<gnTexture*>(&texture);
}
void gnSamplerUniformSetTexture(gnSamplerUniform& samplerUniform, const gnTexture* texture) {
samplerUniform.texture = texture;
}
void gnSamplerUniformSetBinding(gnSamplerUniform& samplerUniform, gnUInt binding) {
samplerUniform.binding = binding;
}
void gnSamplerUniformSetUniformIndex(gnSamplerUniform& samplerUniform, gnUInt index) {
samplerUniform.index = index;
}
void gnSamplerUniformSetUniform(gnSamplerUniform& samplerUniform, const gnUniform& uniformDescriptor) {
samplerUniform.uniform = const_cast<gnUniform*>(&uniformDescriptor);
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "../gryphn_uniform.h"
#include "core/textures/gryphn_texture.h"
struct gnPlatformSamplerUniform;
struct gnSamplerUniform {
ACCESS_LEVEL:
gnPlatformSamplerUniform* samplerUniform = nullptr;
const gnTexture* texture;
gnUInt binding = 0;
gnUInt index = 0;
gnUniform* uniform;
public:
gnSamplerUniform() {}
};
void gnSamplerUniformSetTexture(gnSamplerUniform& samplerUniform, const gnTexture& texture);
void gnSamplerUniformSetTexture(gnSamplerUniform& samplerUniform, const gnTexture* texture);
void gnSamplerUniformSetBinding(gnSamplerUniform& samplerUniform, gnUInt binding);
void gnSamplerUniformSetUniformIndex(gnSamplerUniform& samplerUniform, gnUInt index);
void gnSamplerUniformSetUniform(gnSamplerUniform& samplerUniform, const gnUniform& uniformDescriptor);
inline void (*gnUpdateSamplerUniform)(gnSamplerUniform& samplerUniform, const gnOutputDevice& outputDevice);

View File

@@ -0,0 +1,35 @@
#include "gryphn_uniform_buffer.h"
void gnBufferUniformBindBuffer(gnBufferUniform& uniformBuffer, const gnBuffer& buffer) { uniformBuffer.buffer = const_cast<gnBuffer*>(&buffer); }
void gnBufferUniformSetSize(gnBufferUniform& uniformBuffer, gnSize size) { uniformBuffer.size = size; }
void gnBufferUniformSetOffset(gnBufferUniform& uniformBuffer, gnSize offset) { uniformBuffer.offset = offset; }
void gnBufferUniformSetBinding(gnBufferUniform& uniformBuffer, gnUInt binding) { uniformBuffer.binding = binding; }
void gnBufferUniformSetUniformIndex(gnBufferUniform& uniformBuffer, gnUInt index) { uniformBuffer.index = index; }
void gnBufferUniformSetUniform(gnBufferUniform& uniformBuffer, const gnUniform& uniform) { uniformBuffer.uniform = const_cast<gnUniform*>(&uniform); }
// void gnUniformBufferBindBuffer(const gnUniformBuffer& uniformBuffer, const gnBuffer& buffer) {
// const_cast<gnUniformBuffer*>(&uniformBuffer)->buffer = const_cast<gnBuffer*>(&buffer);
// }
// void gnUniformBufferSetSize(const gnUniformBuffer& uniformBuffer, gnSize size) {
// const_cast<gnUniformBuffer*>(&uniformBuffer)->size = size;
// }
// void gnUniformBufferSetOffset(const gnUniformBuffer& uniformBuffer, gnSize offset) {
// const_cast<gnUniformBuffer*>(&uniformBuffer)->offset = offset;
// }
// void gnUniformBufferSetBinding(const gnUniformBuffer& uniformBuffer, gnUInt binding) {
// const_cast<gnUniformBuffer*>(&uniformBuffer)->binding = binding;
// }
// void gnUniformBufferSetDescriptorIndex(const gnUniformBuffer& uniformBuffer, gnUInt index) {
// const_cast<gnUniformBuffer*>(&uniformBuffer)->index = index;
// }
// void gnUniformBufferSetDescriptorSet(const gnUniformBuffer& uniformBuffer, const gnDescriptorSet& descriptorSet) {
// const_cast<gnUniformBuffer*>(&uniformBuffer)->descriptorSet = const_cast<gnDescriptorSet*>(&descriptorSet);
// }
// /// I HAVE NO FUCKING CLUE WHAT THIS GOD DAMN FUNCITON EVER DID AND IF IT WILL EVER DO ANYTHING AGAIN
// void gnUniformBufferSetDescriptor(const gnUniformBuffer& uniformBuffer, const gnBufferDescription& bufferDescription) {
// //const_cast<gnUniformBuffer*>(&uniformBuffer)->bufferDescription = const_cast<gnBufferDescription*>(&bufferDescription);
// }

View File

@@ -0,0 +1,28 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "../gryphn_uniform.h"
#include "core/buffers/gryphn_buffer.h"
struct gnPlatformBufferUniform;
struct gnBufferUniform {
ACCESS_LEVEL:
gnPlatformBufferUniform* bufferUniform = nullptr;
gnSize size = 0;
gnSize offset = 0;
gnUInt binding = 0;
gnUInt index = 0;
gnBuffer* buffer = nullptr;
gnUniform* uniform;
public:
gnBufferUniform() {}
};
void gnBufferUniformBindBuffer(gnBufferUniform& uniformBuffer, const gnBuffer& buffer);
void gnBufferUniformSetSize(gnBufferUniform& uniformBuffer, gnSize size);
void gnBufferUniformSetOffset(gnBufferUniform& uniformBuffer, gnSize offset);
void gnBufferUniformSetBinding(gnBufferUniform& uniformBuffer, gnUInt binding);
void gnBufferUniformSetUniformIndex(gnBufferUniform& uniformBuffer, gnUInt index);
void gnBufferUniformSetUniform(gnBufferUniform& uniformBuffer, const gnUniform& uniform);
inline void (*gnUpdateBufferUniform)(gnBufferUniform& uniformBuffer, const gnOutputDevice& outputDevice);