2022-03-18 20:57:15 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2022 Blender Foundation. All rights reserved. */
|
2022-02-08 23:17:31 +01:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
|
|
|
|
*
|
|
|
|
|
* Storage buffers API. Used to handle many way bigger buffers than Uniform buffers update at once.
|
|
|
|
|
* Make sure that the data structure is compatible with what the implementation expect.
|
|
|
|
|
* (see "7.8 Shader Buffer Variables and Shader Storage Blocks" from the OpenGL spec for more info
|
|
|
|
|
* about std430 layout)
|
|
|
|
|
* Rule of thumb: Padding to 16bytes, don't use vec3.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-03-16 08:42:12 +01:00
|
|
|
#include "GPU_texture.h"
|
2022-02-08 23:17:31 +01:00
|
|
|
#include "GPU_vertex_buffer.h"
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
struct ListBase;
|
|
|
|
|
|
|
|
|
|
/** Opaque type hiding blender::gpu::StorageBuf. */
|
|
|
|
|
typedef struct GPUStorageBuf GPUStorageBuf;
|
|
|
|
|
|
|
|
|
|
GPUStorageBuf *GPU_storagebuf_create_ex(size_t size,
|
|
|
|
|
const void *data,
|
|
|
|
|
GPUUsageType usage,
|
|
|
|
|
const char *name);
|
|
|
|
|
|
|
|
|
|
#define GPU_storagebuf_create(size) \
|
|
|
|
|
GPU_storagebuf_create_ex(size, NULL, GPU_USAGE_DYNAMIC, __func__);
|
|
|
|
|
|
2022-03-16 08:38:33 +01:00
|
|
|
void GPU_storagebuf_free(GPUStorageBuf *ssbo);
|
2022-02-08 23:17:31 +01:00
|
|
|
|
2022-03-16 08:38:33 +01:00
|
|
|
void GPU_storagebuf_update(GPUStorageBuf *ssbo, const void *data);
|
2022-02-08 23:17:31 +01:00
|
|
|
|
2022-03-16 08:38:33 +01:00
|
|
|
void GPU_storagebuf_bind(GPUStorageBuf *ssbo, int slot);
|
|
|
|
|
void GPU_storagebuf_unbind(GPUStorageBuf *ssbo);
|
2022-02-08 23:17:31 +01:00
|
|
|
void GPU_storagebuf_unbind_all(void);
|
|
|
|
|
|
2022-03-16 08:42:12 +01:00
|
|
|
void GPU_storagebuf_clear(GPUStorageBuf *ssbo,
|
|
|
|
|
eGPUTextureFormat internal_format,
|
|
|
|
|
eGPUDataFormat data_format,
|
|
|
|
|
void *data);
|
|
|
|
|
void GPU_storagebuf_clear_to_zero(GPUStorageBuf *ssbo);
|
|
|
|
|
|
2022-05-18 21:49:08 +02:00
|
|
|
/**
|
|
|
|
|
* @brief Copy a part of a vertex buffer to a storage buffer.
|
|
|
|
|
* \a ssbo: destination storage buffer
|
|
|
|
|
* \a src: source vertex buffer
|
|
|
|
|
* \a dst_offset: where to start copying to (in bytes).
|
|
|
|
|
* \a src_offset: where to start copying from (in bytes).
|
|
|
|
|
* \a copy_size: byte size of the segment to copy.
|
|
|
|
|
*/
|
|
|
|
|
void GPU_storagebuf_copy_sub_from_vertbuf(
|
|
|
|
|
GPUStorageBuf *ssbo, GPUVertBuf *src, uint dst_offset, uint src_offset, uint copy_size);
|
|
|
|
|
|
2022-02-08 23:17:31 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|