rename to projects (DOES NOT COMPILE)
This commit is contained in:
12
projects/core/src/uniforms/gryphn_uniform.c
Normal file
12
projects/core/src/uniforms/gryphn_uniform.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "gryphn_uniform.h"
|
||||
#include "gryphn_uniform_pool.h"
|
||||
#include "output_device/gryphn_output_device.h"
|
||||
#include "gryphn_platform_functions.h"
|
||||
|
||||
void gnUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo bufferInfo) {
|
||||
uniform->pool->device->deviceFunctions->_gnUpdateBufferUniform(uniform, &bufferInfo);
|
||||
}
|
||||
|
||||
void gnUpdateImageUniform(gnUniform uniform, gnImageUniformInfo imageInfo) {
|
||||
uniform->pool->device->deviceFunctions->_gnUpdateImageUniform(uniform, &imageInfo);
|
||||
}
|
28
projects/core/src/uniforms/gryphn_uniform.h
Normal file
28
projects/core/src/uniforms/gryphn_uniform.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "stdint.h"
|
||||
#include "stdlib.h"
|
||||
#include "utils/lists/gryphn_array_list.h"
|
||||
#include "gryphn_handles.h"
|
||||
|
||||
typedef struct gnBufferUniformInfo {
|
||||
uint32_t binding;
|
||||
gnBuffer buffer;
|
||||
size_t offset;
|
||||
size_t size;
|
||||
} gnBufferUniformInfo;
|
||||
|
||||
typedef struct gnImageUniformInfo {
|
||||
uint32_t binding;
|
||||
gnTexture texture;
|
||||
} gnImageUniformInfo;
|
||||
|
||||
#ifdef GN_REVEAL_IMPL
|
||||
struct gnUniform_t {
|
||||
struct gnPlatformUniform_t* uniform;
|
||||
gnUniformPool pool;
|
||||
};
|
||||
#endif
|
||||
GN_ARRAY_LIST(gnUniform)
|
||||
|
||||
void gnUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo bufferInfo);
|
||||
void gnUpdateImageUniform(gnUniform uniform, gnImageUniformInfo imageInfo);
|
33
projects/core/src/uniforms/gryphn_uniform_layout.h
Normal file
33
projects/core/src/uniforms/gryphn_uniform_layout.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "stdint.h"
|
||||
#include "shader_module/gryphn_shader_module.h"
|
||||
|
||||
typedef enum gnUniformType {
|
||||
GN_UNIFORM_BUFFER_DESCRIPTOR,
|
||||
GN_IMAGE_DESCRIPTOR,
|
||||
GN_UNIFORM_TYPE_MAX
|
||||
} gnUniformType;
|
||||
|
||||
typedef struct gnUniformBinding {
|
||||
uint32_t binding;
|
||||
gnUniformType type;
|
||||
gnShaderModuleStage stage;
|
||||
} gnUniformBinding;
|
||||
|
||||
typedef struct gnUniformSet {
|
||||
uint32_t uniformBindingCount;
|
||||
gnUniformBinding* uniformBindings;
|
||||
} gnUniformSet;
|
||||
|
||||
typedef struct gnPushConstantLayout {
|
||||
gnShaderModuleStage stage;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
} gnPushConstantLayout;
|
||||
|
||||
typedef struct gnUniformLayout {
|
||||
uint32_t setCount;
|
||||
gnUniformSet* sets;
|
||||
uint32_t pushConstantCount;
|
||||
gnPushConstantLayout* pushConstants;
|
||||
} gnUniformLayout;
|
27
projects/core/src/uniforms/gryphn_uniform_pool.c
Normal file
27
projects/core/src/uniforms/gryphn_uniform_pool.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "gryphn_uniform_pool.h"
|
||||
#include "output_device/gryphn_output_device.h"
|
||||
#include "gryphn_platform_functions.h"
|
||||
#include "gryphn_uniform.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
gnReturnCode gnCreateUniformPool(gnUniformPool* pool, gnDeviceHandle device) {
|
||||
*pool = malloc(sizeof(struct gnUniformPool_t));
|
||||
(*pool)->device = device;
|
||||
return device->deviceFunctions->_gnCreateUniformPool(*pool, device);
|
||||
}
|
||||
|
||||
// you own this memory now
|
||||
gnUniformArrayList gnUniformPoolAllocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInfo) {
|
||||
gnUniform* uniforms = pool->device->deviceFunctions->_gnUniformPoolAllocateUniforms(pool, allocInfo);
|
||||
for (int i = 0; i < allocInfo.setCount; i++)
|
||||
uniforms[i]->pool = pool;
|
||||
|
||||
gnUniformArrayList list = gnUniformArrayListCreate();
|
||||
gnUniformArrayListResize(&list, allocInfo.setCount);
|
||||
for (int i = 0; i < allocInfo.setCount; i++) list.data[i] = uniforms[i];
|
||||
return list;
|
||||
}
|
||||
|
||||
void gnDestroyUniformPool(gnUniformPool pool) {
|
||||
pool->device->deviceFunctions->_gnDestroyUniformPool(pool);
|
||||
}
|
21
projects/core/src/uniforms/gryphn_uniform_pool.h
Normal file
21
projects/core/src/uniforms/gryphn_uniform_pool.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "utils/gryphn_error_code.h"
|
||||
#include "uniforms/gryphn_uniform_layout.h"
|
||||
#include "uniforms/gryphn_uniform.h"
|
||||
#include "gryphn_handles.h"
|
||||
|
||||
#ifdef GN_REVEAL_IMPL
|
||||
struct gnUniformPool_t {
|
||||
struct gnPlatformUniformPool_t* uniformPool;
|
||||
gnDeviceHandle device;
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct gnUniformAllocationInfo {
|
||||
const uint32_t setCount;
|
||||
const gnUniformSet* sets;
|
||||
} gnUniformAllocationInfo;
|
||||
|
||||
gnReturnCode gnCreateUniformPool(gnUniformPool* pool, gnDeviceHandle device);
|
||||
gnUniformArrayList gnUniformPoolAllocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInfo);
|
||||
void gnDestroyUniformPool(gnUniformPool pool);
|
Reference in New Issue
Block a user