get the metal backend to compile (does not load)

This commit is contained in:
Greg Wells
2025-06-25 10:46:07 -04:00
parent 4306646c6e
commit 2c9e2260f4
39 changed files with 235 additions and 117 deletions

View File

@@ -1,7 +1,7 @@
#include "metal_buffer.h"
#include "core/buffers/gryphn_buffer.h"
#include "core/output_device/gryphn_output_device.h"
#include "core/devices/metal_output_devices.h"
#include "buffers/gryphn_buffer.h"
#include "output_device/gryphn_output_device.h"
#include "devices/metal_output_devices.h"
gnReturnCode gnCreateBufferFn(gnBufferHandle buffer, gnOutputDeviceHandle device, gnBufferInfo info) {
buffer->buffer = malloc(sizeof(struct gnPlatformBuffer_t));

View File

@@ -1,6 +1,6 @@
#pragma once
#include "core/command/command_buffer/gryphn_command_buffer.h"
#include "core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
#include "command/command_buffer/gryphn_command_buffer.h"
#include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
#import <Metal/MTLCommandBuffer.h>
#import <Metal/MTLCommandEncoder.h>

View File

@@ -1,5 +1,5 @@
#include "metal_command_buffer.h"
#include "core/commands/command_pool/metal_command_pool.h"
#include "commands/command_pool/metal_command_pool.h"
#import <Metal/Metal.h>
gnReturnCode gnCommandPoolAllocateCommandBuffersFn(gnCommandBufferHandle* commandBuffers, uint32_t count, struct gnCommandPool_t* pool) {

View File

@@ -1,6 +1,6 @@
#pragma once
#import <Metal/Metal.h>
#include "core/command/command_pool/gryphn_command_pool.h"
#include "command/command_pool/gryphn_command_pool.h"
typedef struct gnPlatformCommandPool_t {
id<MTLCommandQueue> commandQueue;

View File

@@ -1,7 +1,7 @@
#include "metal_command_pool.h"
#include "core/devices/metal_output_devices.h"
#include "devices/metal_output_devices.h"
gnReturnCode gnCreateCommandPoolFn(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, struct gnCommandPoolInfo_t info) {
gnReturnCode gnCreateCommandPoolFn(struct gnCommandPool_t* commandPool, struct gnOutputDevice_t* device, gnCommandPoolInfo info) {
commandPool->commandPool = malloc(sizeof(struct gnPlatformCommandPool_t));
commandPool->commandPool->commandQueue = [device->outputDevice->device newCommandQueue];

View File

@@ -1,12 +1,12 @@
#include "core/command/commands/gryphn_command.h"
#include "core/framebuffers/metal_framebuffer.h"
#include "core/commands/command_buffer/metal_command_buffer.h"
#include "core/pipelines/graphics_pipeline/metal_graphics_pipeline.h"
#include "core/buffer/metal_buffer.h"
#include "core/uniforms/metal_uniform.h"
#include "command/commands/gryphn_command.h"
#include "framebuffers/metal_framebuffer.h"
#include "commands/command_buffer/metal_command_buffer.h"
#include "pipelines/graphics_pipeline/metal_graphics_pipeline.h"
#include "buffer/metal_buffer.h"
#include "uniforms/metal_uniform.h"
#import <Metal/MTLRenderCommandEncoder.h>
void gnCommandBeginRenderPassFn(struct gnCommandBuffer_t* buffer, struct gnRenderPassInfo_t passInfo) {
void gnCommandBeginRenderPassFn(struct gnCommandBuffer_t* buffer, gnRenderPassInfo passInfo) {
int currentColorAttachment = 0;
for (int i = 0; i < passInfo.clearValueCount; i++) {
gnBool wasDepthStencil = gnFalse;
@@ -60,12 +60,12 @@ void gnCommandBindGraphicsPipelineFn(struct gnCommandBuffer_t* buffer, struct gn
buffer->commandBuffer->boundGraphcisPipeline = graphicsPipeline;
}
void gnCommandSetViewportFn(struct gnCommandBuffer_t* buffer, struct gnViewport_t viewport) {
void gnCommandSetViewportFn(struct gnCommandBuffer_t* buffer, gnViewport viewport) {
MTLViewport vp = {(double)viewport.position.x, (double)viewport.position.y, (double)viewport.size.x, (double)viewport.size.y, viewport.minDepth, viewport.maxDepth};
id<MTLRenderCommandEncoder> encoder = (id<MTLRenderCommandEncoder>)buffer->commandBuffer->encoder;
[encoder setViewport:vp];
}
void gnCommandSetScissorFn(struct gnCommandBuffer_t* buffer, struct gnScissor_t scissor) {
void gnCommandSetScissorFn(struct gnCommandBuffer_t* buffer, gnScissor scissor) {
MTLScissorRect scissorRect = { scissor.position.x, scissor.position.y, scissor.size.x, scissor.size.y };
id<MTLRenderCommandEncoder> encoder = (id<MTLRenderCommandEncoder>)buffer->commandBuffer->encoder;
[encoder setScissorRect:scissorRect];
@@ -116,12 +116,14 @@ void gnCommandDrawIndexedFn(gnCommandBufferHandle buffer, gnIndexType type, int
void gnCommandBindUniformFn(gnCommandBufferHandle buffer, gnUniform uniform, uint32_t set) {
id<MTLRenderCommandEncoder> encoder = (id<MTLRenderCommandEncoder>)buffer->commandBuffer->encoder;
if (uniform->uniform->type == GN_UNIFORM_BUFFER_DESCRIPTOR) {
gnBufferUniformInfo info = *(gnBufferUniformInfo*)uniform->uniform->data;
for (int i = 0; i < uniform->uniform->bindingCount; i++) {
if (uniform->uniform->bindings[i].type == GN_UNIFORM_BUFFER_DESCRIPTOR) {
gnBufferUniformInfo info = *(gnBufferUniformInfo*)uniform->uniform->bindings[i].data;
[encoder setVertexBuffer:info.buffer->buffer->buffer
offset:info.offset
atIndex:(info.binding + 1)
];
[encoder setVertexBuffer:info.buffer->buffer->buffer
offset:info.offset
atIndex:(info.binding + 1)
];
}
}
}

View File

@@ -1,7 +1,7 @@
#include <core/debugger/gryphn_debugger.h>
#include <debugger/gryphn_debugger.h>
// these do nothing because I am too lazy to write a debugger for metal at this point in time
gnReturnCode gnCreateDebuggerFn(gnDebuggerHandle debugger, gnInstanceHandle instance, const struct gnDebuggerInfo_t info) {
gnReturnCode gnCreateDebuggerFn(gnDebuggerHandle debugger, gnInstanceHandle instance, const gnDebuggerInfo info) {
return GN_SUCCESS;
}
void gnDestroyDebuggerFn(gnDebuggerHandle instance) {

View File

@@ -1,11 +1,11 @@
#include <core/output_device/gryphn_physical_output_device.h>
#include <output_device/gryphn_physical_output_device.h>
#include <Metal/Metal.h>
#include "metal_output_devices.h"
#include "core/instance/metal_instance.h"
#include "core/instance/gryphn_instance.h"
#include <core/debugger/gryphn_debugger.h>
#include "instance/metal_instance.h"
#include "instance/gryphn_instance.h"
#include <debugger/gryphn_debugger.h>
gnReturnCode gnCreateOutputDeviceFn(gnOutputDeviceHandle outputDevice, gnInstanceHandle instance, struct gnOutputDeviceInfo_t deviceInfo) {
gnReturnCode gnCreateOutputDeviceFn(gnOutputDeviceHandle outputDevice, gnInstanceHandle instance, gnOutputDeviceInfo deviceInfo) {
outputDevice->outputDevice = malloc(sizeof(gnPlatformOutputDevice));
outputDevice->outputDevice->device = deviceInfo.physicalDevice.physicalDevice->device.retain;
outputDevice->outputDevice->transferQueue = outputDevice->outputDevice->device.newCommandQueue;

View File

@@ -1,6 +1,6 @@
#pragma once
#include "core/instance/gryphn_instance.h"
#include "core/output_device/gryphn_output_device.h"
#include "instance/gryphn_instance.h"
#include "output_device/gryphn_output_device.h"
#include <Metal/Metal.h>
#include <MetalKit/MetalKit.h>

View File

@@ -1,7 +1,7 @@
#include <core/output_device/gryphn_physical_output_device.h>
#include <output_device/gryphn_physical_output_device.h>
#include <Metal/Metal.h>
#include "metal_output_devices.h"
#include "core/window_surface/gryphn_surface.h"
#include "window_surface/gryphn_surface.h"
gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstanceHandle instance, uint32_t* deviceCount) {
NSArray *devices = MTLCopyAllDevices();
@@ -34,6 +34,6 @@ gnPhysicalDevice* gnGetPhysicalDevicesFn(gnInstanceHandle instance, uint32_t* de
return devicesList;
}
gnBool gnQueueCanPresentToSurfaceFn(const struct gnPhysicalDevice_t device, uint32_t queueIndex, const struct gnWindowSurface_t windowSurface) {
gnBool gnQueueCanPresentToSurfaceFn(const gnPhysicalDevice device, uint32_t queueIndex, gnWindowSurface windowSurface) {
return gnTrue; // I belive that a window should always be able to present to a surface in metal
}

View File

@@ -1,5 +1,5 @@
#pragma once
#include "core/framebuffer/gryphn_framebuffer.h"
#include "framebuffer/gryphn_framebuffer.h"
#include "utils/gryphn_bool.h"
#include "utils/gryphn_image_format.h"
#import <Metal/Metal.h>

View File

@@ -1,8 +1,9 @@
#include "metal_framebuffer.h"
#include "core/debugger/gryphn_debugger.h"
#include "core/texture/metal_texture.h"
#include "core/renderpass/gryphn_render_pass_descriptor.h"
#include "core/instance/gryphn_instance.h"
#include "debugger/gryphn_debugger.h"
#include "texture/metal_texture.h"
#include "renderpass/gryphn_render_pass_descriptor.h"
#include "instance/gryphn_instance.h"
#include "output_device/gryphn_output_device.h"
gnBool isDepthFormat(gnImageFormat format) {
return gnFalse;
@@ -12,7 +13,7 @@ gnBool isStencilFormat(gnImageFormat format) {
return gnFalse;
}
MTLLoadAction mtlGryphnLoadOperation(enum gnLoadOperation_e loadOperation) {
MTLLoadAction mtlGryphnLoadOperation(gnLoadOperation loadOperation) {
switch(loadOperation) {
case GN_LOAD_OPERATION_LOAD: return MTLLoadActionLoad;
case GN_LOAD_OPERATION_CLEAR: return MTLLoadActionClear;
@@ -20,14 +21,14 @@ MTLLoadAction mtlGryphnLoadOperation(enum gnLoadOperation_e loadOperation) {
}
}
MTLStoreAction mtlGryphnStoreOperation(enum gnStoreOperation_e storeOperation) {
MTLStoreAction mtlGryphnStoreOperation(gnStoreOperation storeOperation) {
switch (storeOperation) {
case GN_STORE_OPERATION_STORE: return MTLStoreActionStore;
case GN_STORE_OPERATION_DONT_CARE: return MTLStoreActionDontCare;
}
}
gnReturnCode gnCreateFramebufferFn(struct gnFramebuffer_t* framebuffer, struct gnOutputDevice_t* device, struct gnFramebufferInfo_t info) {
gnReturnCode gnCreateFramebufferFn(gnFramebuffer framebuffer, gnOutputDevice device, gnFramebufferInfo info) {
framebuffer->framebuffer = malloc(sizeof(struct gnPlatformFramebuffer_t));
if (info.attachmentCount != info.renderPassDescriptor->info.attachmentCount) {
gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){

View File

@@ -1,5 +1,5 @@
#pragma once
#include "core/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
#include "pipelines/graphics_pipeline/gryphn_graphics_pipeline.h"
#import <Metal/Metal.h>
typedef struct gnPlatformGraphicsPipeline_t {

View File

@@ -1,10 +1,10 @@
#include "metal_graphics_pipeline.h"
#include "core/devices/metal_output_devices.h"
#include "core/debugger/gryphn_debugger.h"
#include "core/shader_module/metal_shader_module.h"
#include "core/surface/metal_surface.h"
#include "devices/metal_output_devices.h"
#include "debugger/gryphn_debugger.h"
#include "shader_module/metal_shader_module.h"
#include "surface/metal_surface.h"
MTLBlendFactor vkGryphnBlendFactor(enum gnBlendFactor_e factor) {
MTLBlendFactor vkGryphnBlendFactor(gnBlendFactor factor) {
switch (factor) {
case GN_BLEND_FACTOR_ZERO: return MTLBlendFactorZero;
case GN_BLEND_FACTOR_ONE: return MTLBlendFactorOne;
@@ -13,7 +13,7 @@ MTLBlendFactor vkGryphnBlendFactor(enum gnBlendFactor_e factor) {
}
}
MTLBlendOperation vkGryphnBlendOperation(enum gnBlendOperation_e operation) {
MTLBlendOperation vkGryphnBlendOperation(gnBlendOperation operation) {
switch(operation) {
case GN_OPERATION_ADD: return MTLBlendOperationAdd;
}
@@ -26,7 +26,7 @@ MTLVertexFormat mtlGryphnVertexFormat(gnVertexFormat format) {
}
}
gnReturnCode gnCreateGraphicsPipelineFn(struct gnGraphicsPipeline_t* graphicsPipeline, struct gnOutputDevice_t* device, struct gnGraphicsPipelineInfo_t info) {
gnReturnCode gnCreateGraphicsPipelineFn(gnGraphicsPipeline graphicsPipeline, gnOutputDevice device, gnGraphicsPipelineInfo info) {
graphicsPipeline->graphicsPipeline = malloc(sizeof(struct gnPlatformGraphicsPipeline_t));
MTLRenderPipelineDescriptor* descriptor = [[MTLRenderPipelineDescriptor alloc] init];

View File

@@ -1,14 +1,14 @@
#include "core/present/gryphn_present.h"
#include "core/instance/metal_instance.h"
#include "core/surface/metal_surface.h"
#include "core/devices/metal_output_devices.h"
#include "core/sync/semaphore/metal_semaphore.h"
#include "core/presentation_queue/metal_presentation_queue.h"
#include "core/debugger/gryphn_debugger.h"
#include "core/texture/metal_texture.h"
#include "present/gryphn_present.h"
#include "instance/metal_instance.h"
#include "surface/metal_surface.h"
#include "devices/metal_output_devices.h"
#include "sync/semaphore/metal_semaphore.h"
#include "presentation_queue/metal_presentation_queue.h"
#include "debugger/gryphn_debugger.h"
#include "texture/metal_texture.h"
#import <QuartzCore/CAMetalLayer.h>
gnReturnCode gnPresentFn(gnOutputDeviceHandle device, struct gnPresentInfo_t info) {
gnReturnCode gnPresentFn(gnOutputDeviceHandle device, gnPresentInfo info) {
for (int i = 0; i < info.waitCount; i++) {
while (!info.waitSemaphores[i]->semaphore->eventTriggered) {}
}

View File

@@ -1,6 +1,6 @@
#pragma once
#import <Metal/Metal.h>
#include "core/presentation_queue/gryphn_presentation_queue.h"
#include "presentation_queue/gryphn_presentation_queue.h"
typedef struct gnPlatformPresentationQueue_t {
int textureCount;

View File

@@ -1,11 +1,11 @@
#include "metal_presentation_queue.h"
#include "core/surface/metal_surface.h"
#include "core/devices/metal_output_devices.h"
#include "core/debugger/gryphn_debugger.h"
#include "core/texture/metal_texture.h"
#include "core/sync/semaphore/metal_semaphore.h"
#include "surface/metal_surface.h"
#include "devices/metal_output_devices.h"
#include "debugger/gryphn_debugger.h"
#include "texture/metal_texture.h"
#include "sync/semaphore/metal_semaphore.h"
gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueueHandle presentationQueue, const gnOutputDeviceHandle device, struct gnPresentationQueueInfo_t presentationInfo) {
gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueueHandle presentationQueue, const gnOutputDeviceHandle device, gnPresentationQueueInfo presentationInfo) {
if (presentationInfo.minImageCount > 3) {
gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){
.message = gnCreateString("On Metal you cannot have more than 3 images in a presentation queue")

View File

@@ -1,5 +1,5 @@
#pragma once
#include "core/renderpass/gryphn_render_pass_descriptor.h"
#include "renderpass/gryphn_render_pass_descriptor.h"
#import <Metal/MTLRenderPass.h>
typedef struct gnPlatformRenderPassDescriptor_t {

View File

@@ -1,6 +1,6 @@
#include "metal_render_pass.h"
gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* renderPass, struct gnOutputDevice_t* device, struct gnRenderPassDescriptorInfo_t info) {
gnReturnCode gnCreateRenderPassDescriptorFn(gnRenderPassDescriptor renderPass, gnOutputDevice device, gnRenderPassDescriptorInfo info) {
renderPass->renderPassDescriptor = malloc(sizeof(gnPlatformRenderPassDescriptor));
renderPass->renderPassDescriptor->passDescriptor = [[MTLRenderPassDescriptor alloc] init];

View File

@@ -1,5 +1,5 @@
#pragma once
#include "core/shader_module/gryphn_shader_module.h"
#include "shader_module/gryphn_shader_module.h"
#import <Metal/Metal.h>
typedef struct gnPlatformShaderModule_t {

View File

@@ -1,7 +1,7 @@
#include "metal_shader_module.h"
#include "spirv_cross_c.h"
#include "core/debugger/gryphn_debugger.h"
#include "core/devices/metal_output_devices.h"
#include "debugger/gryphn_debugger.h"
#include "devices/metal_output_devices.h"
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
@@ -12,7 +12,7 @@ void mtlSpirVErrorCallback(void *userdata, const char *error) {
});
}
gnReturnCode gnCreateShaderModuleFn(struct gnShaderModule_t *module, struct gnOutputDevice_t *device, struct gnShaderModuleInfo_t shaderModuleInfo) {
gnReturnCode gnCreateShaderModuleFn(gnShaderModule module, gnOutputDevice device, gnShaderModuleInfo shaderModuleInfo) {
module->shaderModule = malloc(sizeof(struct gnPlatformShaderModule_t));
spvc_context context = NULL;

View File

@@ -1,10 +1,11 @@
#include "core/submit/gryphn_submit.h"
#include "core/sync/semaphore/metal_semaphore.h"
#include "core/commands/command_buffer/metal_command_buffer.h"
#include "core/debugger/gryphn_debugger.h"
#include "core/commands/command_pool/metal_command_pool.h"
#include "submit/gryphn_submit.h"
#include "sync/semaphore/metal_semaphore.h"
#include "commands/command_buffer/metal_command_buffer.h"
#include "debugger/gryphn_debugger.h"
#include "commands/command_pool/metal_command_pool.h"
#include "sync/fence/gryphn_fence.h"
gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t info) {
gnReturnCode gnSubmitFn(gnDevice* device, gnSubmitInfo info) {
for (int i = 0; i < info.waitCount; i++) {
while (!info.waitSemaphores[i]->semaphore->eventTriggered) {}
}

View File

@@ -1,5 +1,5 @@
#pragma once
#include "core/window_surface/gryphn_surface.h"
#include "window_surface/gryphn_surface.h"
#import <QuartzCore/QuartzCore.h>
typedef struct gnPlatformWindowSurface_t {

View File

@@ -1,5 +1,5 @@
#include "metal_surface.h"
#include "core/window_surface/gryphn_surface_create_functions.h"
#include "window_surface/gryphn_surface_create_functions.h"
#import <AppKit/AppKit.h>
#import <Cocoa/Cocoa.h>
@@ -8,7 +8,7 @@
#import <Metal/Metal.h>
#import <CoreGraphics/CoreGraphics.h>
gnReturnCode gnCreateMacOSWindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, struct gnMacOSWindowSurfaceInfo_t createInfo) {
gnReturnCode gnCreateMacOSWindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstanceHandle instance, gnMacOSWindowSurfaceInfo createInfo) {
windowSurface->windowSurface = malloc(sizeof(gnPlatformWindowSurface));
windowSurface->windowSurface->layer = createInfo.layer;
return GN_SUCCESS;
@@ -18,12 +18,12 @@ void gnDestroyWindowSurfaceFn(struct gnWindowSurface_t *windowSurface) {
free(windowSurface->windowSurface);
}
struct gnSurfaceDetails_t gnGetSurfaceDetailsFn(
struct gnWindowSurface_t* windowSurface, struct gnPhysicalDevice_t device
gnSurfaceDetails gnGetSurfaceDetailsFn(
gnWindowSurface windowSurface, gnPhysicalDevice device
) {
struct gnSurfaceDetails_t surfaceDetails;
gnSurfaceDetails surfaceDetails;
surfaceDetails.formatCount = 1;
surfaceDetails.formats = (struct gnSurfaceFormat_t[1]){ { GN_FORMAT_BGRA8_SRGB, GN_COLOR_SPACE_SRGB_NONLINEAR } };
surfaceDetails.formats = (gnSurfaceFormat[]){ { GN_FORMAT_BGRA8_SRGB, GN_COLOR_SPACE_SRGB_NONLINEAR } };
surfaceDetails.minImageCount = 2;
surfaceDetails.maxImageCount = 3;
return surfaceDetails;

View File

@@ -1,5 +1,5 @@
#pragma once
#include "core/sync/fence/gryphn_fence.h"
#include "sync/fence/gryphn_fence.h"
#import <Metal/Metal.h>
#import <Metal/MTLEvent.h>

View File

@@ -1,5 +1,5 @@
#include "metal_fence.h"
#include "core/devices/metal_output_devices.h"
#include "devices/metal_output_devices.h"
gnReturnCode gnCreateFenceFn(struct gnFence_t* fence, struct gnOutputDevice_t* device) {
// fence->fence = malloc(sizeof(gnPlatformFence));

View File

@@ -1,5 +1,5 @@
#pragma once
#include "core/sync/semaphore/gryphn_semaphore.h"
#include "sync/semaphore/gryphn_semaphore.h"
#import <Metal/MTLEvent.h>
typedef struct gnPlatformSemaphore_t {

View File

@@ -1,13 +1,13 @@
#include "metal_semaphore.h"
#include "core/devices/metal_output_devices.h"
#include "devices/metal_output_devices.h"
gnReturnCode gnCreateSemaphoreFn(struct gnSemaphore_t* semaphore, struct gnOutputDevice_t* device) {
gnReturnCode gnCreateSemaphoreFn(gnSemaphore semaphore, gnOutputDevice device) {
semaphore->semaphore = malloc(sizeof(gnPlatformSemaphore));
semaphore->semaphore->event = [device->outputDevice->device newEvent];
return GN_SUCCESS;
}
void gnDestroySemaphoreFn(struct gnSemaphore_t* semaphore) {
void gnDestroySemaphoreFn(gnSemaphore semaphore) {
[semaphore->semaphore->event release];
free(semaphore->semaphore);
}

View File

@@ -1,5 +1,5 @@
#pragma once
#include "core/textures/gryphn_texture.h"
#include "textures/gryphn_texture.h"
#import <Metal/MTLTexture.h>
typedef struct gnPlatformTexture_t {

View File

@@ -1,7 +1,12 @@
#include <core/uniforms/gryphn_uniform.h>
#include <uniforms/gryphn_uniform.h>
#include "metal_uniform.h"
void gnUpdateBufferUniformFn(gnUniform uniform, gnBufferUniformInfo* info) {
uniform->uniform->data = malloc(sizeof(gnBufferUniformInfo));
memcpy(uniform->uniform->data, info, sizeof(gnBufferUniformInfo));
for (int i = 0; i < uniform->uniform->bindingCount; i++) {
if (uniform->uniform->bindings[i].binding == info->binding) {
uniform->uniform->bindings[i].data = malloc(sizeof(gnBufferUniformInfo));
memcpy(uniform->uniform->bindings[i].data, info, sizeof(gnBufferUniformInfo));
break;
}
}
}

View File

@@ -1,8 +1,14 @@
#pragma once
#include "core/uniforms/gryphn_uniform.h"
#include <core/uniforms/gryphn_uniform_pool.h>
#include "uniforms/gryphn_uniform.h"
#include <uniforms/gryphn_uniform_pool.h>
typedef struct metalUniformBinding {
gnUniformType type;
uint32_t binding;
void* data;
} metalUniformBinding;
typedef struct gnPlatformUniform_t {
gnUniformType type;
void* data;
uint32_t bindingCount;
metalUniformBinding* bindings;
} gnPlatformUniform;

View File

@@ -1,17 +1,21 @@
#include <core/uniforms/gryphn_uniform_pool.h>
#include <core/uniforms/gryphn_uniform.h>
#include <uniforms/gryphn_uniform_pool.h>
#include <uniforms/gryphn_uniform.h>
#include "metal_uniform.h"
gnReturnCode gnCreateUniformPoolFn(gnUniformPool pool, gnDeviceHandle device) {
return GN_SUCCESS;
}
gnUniform* gnUniformPoolAllocateUniformsFn(gnUniformPool pool, const gnUniformLayout layout) {
gnUniform* uniforms = malloc(sizeof(gnUniform) * layout.uniformBindingCount);
for (int i = 0; i < layout.uniformBindingCount; i++) {
gnUniform* gnUniformPoolAllocateUniformsFn(gnUniformPool pool, const gnUniformAllocationInfo allocInfo) {
gnUniform* uniforms = malloc(sizeof(gnUniform) * allocInfo.setCount);
for (int i = 0; i < allocInfo.setCount; i++) {
uniforms[i] = malloc(sizeof(struct gnUniform_t));
uniforms[i]->uniform = malloc(sizeof(struct gnPlatformUniform_t));
uniforms[i]->uniform->type = layout.uniformBindings[i].type;
uniforms[i]->uniform = malloc(sizeof(gnPlatformUniform));
uniforms[i]->uniform->bindings = malloc(sizeof(metalUniformBinding) * allocInfo.sets[i].uniformBindingCount);
for (int c = 0; c < allocInfo.sets[i].uniformBindingCount; c++) {
uniforms[i]->uniform->bindings[c].type = allocInfo.sets[i].uniformBindings[c].type;
uniforms[i]->uniform->bindings[c].binding = allocInfo.sets[i].uniformBindings[c].binding;
}
}
return uniforms;
}

View File

@@ -1,6 +1,5 @@
#pragma once
#include <vulkan/vulkan.h>
#include <core/uniforms/gryphn_uniform_pool.h>
#include <uniforms/gryphn_uniform_pool.h>
struct gnPlatformUniformPool_t {
};
typedef struct gnPlatformUniformPool_t {} gnPlatformUniformPool;