updating uniforms
This commit is contained in:
@@ -23,3 +23,4 @@
|
||||
#include <core/shader_input/gryphn_shader_layout.h>
|
||||
#include <core/buffers/gryphn_buffer.h>
|
||||
#include <core/uniforms/gryphn_uniform_pool.h>
|
||||
#include <core/uniforms/gryphn_uniform.h>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <vulkan/vulkan.h>
|
||||
#include "utils/gryphn_bool.h"
|
||||
#include <core/buffers/gryphn_buffer.h>
|
||||
|
||||
struct gnPlatformBuffer_t {
|
||||
VkBuffer buffer;
|
||||
|
24
rendering_api/vulkan/src/uniforms/vulkan_uniform.c
Normal file
24
rendering_api/vulkan/src/uniforms/vulkan_uniform.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "vulkan_uniform.h"
|
||||
#include "buffers/vulkan_buffer.h"
|
||||
#include "output_device/vulkan_output_devices.h"
|
||||
#include "core/uniforms/gryphn_uniform_pool.h"
|
||||
|
||||
void gnUpdateBufferUniformFn(gnUniform uniform, gnBufferUniformInfo* info) {
|
||||
VkDescriptorBufferInfo bufferInfo = {
|
||||
.buffer = info->buffer->buffer->buffer,
|
||||
.offset = info->offset,
|
||||
.range = info->size
|
||||
};
|
||||
|
||||
VkWriteDescriptorSet write = {
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
.descriptorCount = 1,
|
||||
.pBufferInfo = &bufferInfo,
|
||||
.dstSet = uniform->uniform->set,
|
||||
.dstBinding = info->binding,
|
||||
.dstArrayElement = 0
|
||||
};
|
||||
|
||||
vkUpdateDescriptorSets(uniform->pool->device->outputDevice->device, 1, &write, 0, NULL);
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include <vulkan/vulkan.h>
|
||||
#include "core/uniforms/gryphn_uniform.h"
|
||||
|
||||
typedef struct gnPlatformUniform_t {
|
||||
VkDescriptorSet set;
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include "core/submit/gryphn_submit.h"
|
||||
#include "core/present/gryphn_present.h"
|
||||
#include "core/buffers/gryphn_buffer.h"
|
||||
#include "core/uniforms/gryphn_uniform.h"
|
||||
|
||||
typedef struct gnFunctions_t {
|
||||
gnReturnCode (*_gnCreateInstance)(gnInstanceHandle instance, gnInstanceInfo info);
|
||||
@@ -91,6 +92,8 @@ typedef struct gnDeviceFunctions_t {
|
||||
gnUniform* (*_gnUniformPoolAllocateUniforms)(gnUniformPool pool, const gnUniformLayout layout);
|
||||
void (*_gnDestroyUniformPool)(gnUniformPool pool);
|
||||
|
||||
void (*_gnUpdateBufferUniform)(gnUniform uniform, gnBufferUniformInfo* bufferInfo);
|
||||
|
||||
gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
|
||||
void (*_gnSignalFence)(gnFenceHandle fence);
|
||||
void (*_gnWaitForFence)(gnFenceHandle fence, uint64_t timeout);
|
||||
|
@@ -92,6 +92,7 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti
|
||||
gnLoadDLLFunction(lib, functions->_gnCreateUniformPool, "gnCreateUniformPoolFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnUniformPoolAllocateUniforms, "gnUniformPoolAllocateUniformsFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnDestroyUniformPool, "gnDestroyUniformPoolFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnUpdateBufferUniform, "gnUpdateBufferUniformFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnCreateFence, "gnCreateFenceFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnSignalFence, "gnSignalFenceFn");
|
||||
gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn");
|
||||
|
8
src/core/uniforms/gryphn_uniform.c
Normal file
8
src/core/uniforms/gryphn_uniform.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "gryphn_uniform.h"
|
||||
#include "gryphn_uniform_pool.h"
|
||||
#include "core/output_device/gryphn_output_device.h"
|
||||
#include "core/gryphn_platform_functions.h"
|
||||
|
||||
void gnUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo bufferInfo) {
|
||||
uniform->pool->device->deviceFunctions->_gnUpdateBufferUniform(uniform, &bufferInfo);
|
||||
}
|
@@ -1,7 +1,21 @@
|
||||
#pragma once
|
||||
#include "stdint.h"
|
||||
#include "stdlib.h"
|
||||
#include "core/gryphn_handles.h"
|
||||
|
||||
typedef struct gnBufferUniformInfo {
|
||||
gnUniform uniform;
|
||||
uint32_t binding;
|
||||
gnBuffer buffer;
|
||||
size_t offset;
|
||||
size_t size;
|
||||
} gnBufferUniformInfo;
|
||||
|
||||
#ifdef GN_REVEAL_IMPL
|
||||
struct gnUniform_t {
|
||||
struct gnPlatformUniform_t* uniform;
|
||||
gnUniformPool pool;
|
||||
};
|
||||
#endif
|
||||
|
||||
void gnUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo bufferInfo);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "gryphn_uniform_pool.h"
|
||||
#include "core/output_device/gryphn_output_device.h"
|
||||
#include "core/gryphn_platform_functions.h"
|
||||
#include "gryphn_uniform.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
gnReturnCode gnCreateUniformPool(gnUniformPool* pool, gnDeviceHandle device) {
|
||||
@@ -9,8 +10,12 @@ gnReturnCode gnCreateUniformPool(gnUniformPool* pool, gnDeviceHandle device) {
|
||||
return device->deviceFunctions->_gnCreateUniformPool(*pool, device);
|
||||
}
|
||||
|
||||
// you own this memory now
|
||||
gnUniform* gnUniformPoolAllocateUniforms(gnUniformPool pool, const gnUniformLayout layout) {
|
||||
return pool->device->deviceFunctions->_gnUniformPoolAllocateUniforms(pool, layout);
|
||||
gnUniform* uniforms = pool->device->deviceFunctions->_gnUniformPoolAllocateUniforms(pool, layout);
|
||||
for (int i = 0; i < layout.uniformBindingCount; i++)
|
||||
uniforms[i]->pool = pool;
|
||||
return uniforms;
|
||||
}
|
||||
|
||||
void gnDestroyUniformPool(gnUniformPool pool) {
|
||||
|
Reference in New Issue
Block a user