redo uniform allocation
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
typedef struct type##_t* type##Handle; \
|
||||
typedef struct type##_t* type
|
||||
|
||||
#define GN_HANDLE_ALIAS(alias, handle) \
|
||||
#define GN_HANDLE_ALIAS(handle, alias) \
|
||||
typedef struct handle##_t* alias##Handle; \
|
||||
typedef struct handle##_t* alias
|
||||
|
||||
@@ -15,7 +15,7 @@ GN_HANDLE(gnPresentationQueue);
|
||||
GN_HANDLE(gnTexture);
|
||||
GN_HANDLE(gnRenderPassDescriptor);
|
||||
GN_HANDLE(gnOutputDevice);
|
||||
GN_HANDLE_ALIAS(gnDevice, gnOutputDevice);
|
||||
GN_HANDLE_ALIAS(gnOutputDevice, gnDevice);
|
||||
GN_HANDLE(gnShaderModule);
|
||||
GN_HANDLE(gnGraphicsPipeline);
|
||||
GN_HANDLE(gnCommandPool);
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "core/buffers/gryphn_buffer.h"
|
||||
#include "core/uniforms/gryphn_uniform.h"
|
||||
#include "core/textures/gryphn_texture.h"
|
||||
#include "core/uniforms/gryphn_uniform_pool.h"
|
||||
|
||||
typedef struct gnFunctions_t {
|
||||
gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, gnInstanceInfo info);
|
||||
@@ -86,7 +87,7 @@ typedef struct gnDeviceFunctions_t {
|
||||
void (*_gnDestroyBuffer)(gnBufferHandle buffer);
|
||||
|
||||
gnReturnCode (*_gnCreateUniformPool)(gnUniformPool pool, gnDeviceHandle device);
|
||||
gnUniform* (*_gnUniformPoolAllocateUniforms)(gnUniformPool pool, const gnUniformLayout layout);
|
||||
gnUniform* (*_gnUniformPoolAllocateUniforms)(gnUniformPool pool, gnUniformAllocationInfo allocInfo);
|
||||
void (*_gnDestroyUniformPool)(gnUniformPool pool);
|
||||
|
||||
void (*_gnUpdateBufferUniform)(gnUniform uniform, gnBufferUniformInfo* bufferInfo);
|
||||
|
@@ -11,14 +11,14 @@ gnReturnCode gnCreateUniformPool(gnUniformPool* pool, gnDeviceHandle device) {
|
||||
}
|
||||
|
||||
// you own this memory now
|
||||
gnUniformArrayList gnUniformPoolAllocateUniforms(gnUniformPool pool, const gnUniformLayout layout, uint32_t count) {
|
||||
gnUniform* uniforms = pool->device->deviceFunctions->_gnUniformPoolAllocateUniforms(pool, layout);
|
||||
for (int i = 0; i < layout.uniformBindingCount; i++)
|
||||
gnUniformArrayList gnUniformPoolAllocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInfo) {
|
||||
gnUniform* uniforms = pool->device->deviceFunctions->_gnUniformPoolAllocateUniforms(pool, allocInfo);
|
||||
for (int i = 0; i < allocInfo.layoutCount; i++)
|
||||
uniforms[i]->pool = pool;
|
||||
|
||||
gnUniformArrayList list = gnUniformArrayListCreate();
|
||||
gnUniformArrayListResize(&list, layout.uniformBindingCount);
|
||||
for (int i = 0; i < layout.uniformBindingCount; i++) list.data[i] = uniforms[i];
|
||||
gnUniformArrayListResize(&list, allocInfo.layoutCount);
|
||||
for (int i = 0; i < allocInfo.layoutCount; i++) list.data[i] = uniforms[i];
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@@ -11,6 +11,11 @@ struct gnUniformPool_t {
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct gnUniformAllocationInfo {
|
||||
const uint32_t layoutCount;
|
||||
const gnUniformLayout* layouts;
|
||||
} gnUniformAllocationInfo;
|
||||
|
||||
gnReturnCode gnCreateUniformPool(gnUniformPool* pool, gnDeviceHandle device);
|
||||
gnUniformArrayList gnUniformPoolAllocateUniforms(gnUniformPool pool, const gnUniformLayout layout);
|
||||
gnUniformArrayList gnUniformPoolAllocateUniforms(gnUniformPool pool, gnUniformAllocationInfo allocInfo);
|
||||
void gnDestroyUniformPool(gnUniformPool pool);
|
||||
|
Reference in New Issue
Block a user