2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2005 Blender Foundation. All rights reserved. */
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
2020-08-21 14:14:56 +02:00
|
|
|
*
|
|
|
|
|
* Uniform buffers API. Used to handle many uniforms update at once.
|
|
|
|
|
* Make sure that the data structure is compatible with what the implementation expect.
|
|
|
|
|
* (see "7.6.2.2 Standard Uniform Block Layout" from the OpenGL spec for more info about std140
|
|
|
|
|
* layout)
|
|
|
|
|
* Rule of thumb: Padding to 16bytes, don't use vec3, don't use arrays of anything that is not vec4
|
|
|
|
|
* aligned .
|
2017-02-07 11:20:15 +01:00
|
|
|
*/
|
|
|
|
|
|
2017-04-15 17:51:08 +10:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-03-02 15:28:47 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-07-14 17:40:54 +02:00
|
|
|
struct ListBase;
|
|
|
|
|
|
2020-09-08 03:34:47 +02:00
|
|
|
/** Opaque type hiding blender::gpu::UniformBuf. */
|
|
|
|
|
typedef struct GPUUniformBuf GPUUniformBuf;
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2020-08-20 23:09:37 +02:00
|
|
|
GPUUniformBuf *GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name);
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Create UBO from inputs list.
|
|
|
|
|
* Return NULL if failed to create or if \param inputs: is empty.
|
|
|
|
|
*
|
|
|
|
|
* \param inputs: ListBase of #BLI_genericNodeN(#GPUInput).
|
|
|
|
|
*/
|
2020-08-21 12:30:55 +02:00
|
|
|
GPUUniformBuf *GPU_uniformbuf_create_from_list(struct ListBase *inputs, const char *name);
|
2017-07-14 17:40:54 +02:00
|
|
|
|
2020-08-20 23:09:37 +02:00
|
|
|
#define GPU_uniformbuf_create(size) GPU_uniformbuf_create_ex(size, NULL, __func__);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2020-08-20 23:09:37 +02:00
|
|
|
void GPU_uniformbuf_free(GPUUniformBuf *ubo);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2020-08-20 23:09:37 +02:00
|
|
|
void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data);
|
2017-04-15 17:51:08 +10:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void GPU_uniformbuf_bind(GPUUniformBuf *ubo, int slot);
|
2020-08-20 23:09:37 +02:00
|
|
|
void GPU_uniformbuf_unbind(GPUUniformBuf *ubo);
|
|
|
|
|
void GPU_uniformbuf_unbind_all(void);
|
2017-07-14 17:40:54 +02:00
|
|
|
|
2022-04-14 18:47:58 +02:00
|
|
|
#define GPU_UBO_BLOCK_NAME "node_tree"
|
|
|
|
|
#define GPU_ATTRIBUTE_UBO_BLOCK_NAME "unf_attrs"
|
2017-07-14 17:40:54 +02:00
|
|
|
|
2020-03-02 15:28:47 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|