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,52 @@
#include "metal_framebuffer.h"
#include "core/graphics_pipeline/metal_graphics_pipeline.h"
#include <core/devices/metal_output_devices.h>
#include <core/textures/metal_texture.h>
GN_EXPORT gnReturnCode gnCreateFramebufferAttachmentFn(gnFramebufferAttachment* attachment, gnPresentationQueue& queue) {
attachment->framebufferAttachment = new gnPlatformFramebufferAttachment();
// attachment->framebufferAttachment->framebufferAttachment = MTL::RenderPassAttachmentDescriptor::alloc()->init();
// MTL::RenderPassAttachmentDescriptor* descriptor = attachment->framebufferAttachment->framebufferAttachment;
// attachment->framebufferAttachment->framebufferAttachment->setTexture(attachment->texture->texture->texture->retain());
// descriptor->setLoadAction(MTL::LoadActionClear);
// descriptor->setStoreAction(MTL::StoreActionStore);
return GN_SUCCESS;
}
GN_EXPORT gnReturnCode gnCreateFramebufferFn(gnFramebuffer* framebuffer, const gnRenderPass& renderpass) {
framebuffer->framebuffer = new gnPlatformFramebuffer();
framebuffer->framebuffer->framebuffer = MTL::RenderPassDescriptor::alloc()->init();
framebuffer->framebuffer->framebuffer->setRenderTargetWidth(framebuffer->size.x);
framebuffer->framebuffer->framebuffer->setRenderTargetHeight(framebuffer->size.y);
framebuffer->framebuffer->framebuffer->setDepthAttachment(nullptr);
int currentColorAttachment = 0;
for (int i = 0; i < gnListLength(framebuffer->framebufferAttachments); i++) {
if (framebuffer->framebufferAttachments[i].bindPoint == GN_COLOR_ATTACHMENT) {
MTL::RenderPassColorAttachmentDescriptor* colorAttachment = framebuffer->framebuffer->framebuffer->colorAttachments()->object(currentColorAttachment)->retain();
colorAttachment->setTexture(framebuffer->framebufferAttachments[i].texture->texture->texture);
colorAttachment->setClearColor(MTL::ClearColor::Make(1.0f, 0.0f, 0.0f, 1.0f));
colorAttachment->setLoadAction(MTL::LoadActionClear);
colorAttachment->setStoreAction(MTL::StoreActionStore);
colorAttachment->release();
currentColorAttachment++;
} else if (framebuffer->framebufferAttachments[i].bindPoint == GN_DEPTH_STENCIL_ATTACHMENT) {
MTL::RenderPassDepthAttachmentDescriptor* depthAttachment = framebuffer->framebuffer->framebuffer->depthAttachment()->retain();
depthAttachment->setTexture(framebuffer->framebufferAttachments[i].texture->texture->texture);
depthAttachment->setLoadAction(MTL::LoadActionClear);
depthAttachment->setStoreAction(MTL::StoreActionStore);
depthAttachment->release();
MTL::RenderPassStencilAttachmentDescriptor* stencilAttachment = framebuffer->framebuffer->framebuffer->stencilAttachment()->retain();
stencilAttachment->setTexture(framebuffer->framebufferAttachments[i].texture->texture->texture);
stencilAttachment->setLoadAction(MTL::LoadActionClear);
stencilAttachment->setStoreAction(MTL::StoreActionStore);
stencilAttachment->release();
} else {
GN_RETURN_ERROR("fuck you (line 46 in metal_framebuffer.cpp)");
}
}
return GN_SUCCESS;
}
GN_EXPORT void gnDestroyFramebufferFn(const gnFramebuffer& framebuffer) {
framebuffer.framebuffer->framebuffer->release();
}

View File

@@ -0,0 +1,10 @@
#include <core/framebuffers/gryphn_framebuffer.h>
#include <Metal/Metal.hpp>
struct gnPlatformFramebuffer {
MTL::RenderPassDescriptor* framebuffer;
};
struct gnPlatformFramebufferAttachment {
MTL::RenderPassAttachmentDescriptor* framebufferAttachment;
};