2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2016 by Mike Erwin. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2018-07-17 14:46:44 +02:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
2018-07-17 14:46:44 +02:00
|
|
|
*
|
2018-07-18 00:12:21 +02:00
|
|
|
* GPU vertex buffer
|
2018-07-17 14:46:44 +02:00
|
|
|
*/
|
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
#pragma once
|
2016-09-13 02:41:43 -04:00
|
|
|
|
2024-06-18 21:10:45 +02:00
|
|
|
#include "BLI_span.hh"
|
2020-09-06 16:40:07 +02:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_vertex_format.hh"
|
2016-09-13 02:41:43 -04:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
enum GPUVertBufStatus {
|
2020-09-06 16:40:07 +02:00
|
|
|
/** Initial state. */
|
|
|
|
|
GPU_VERTBUF_INVALID = 0,
|
|
|
|
|
/** Was init with a vertex format. */
|
|
|
|
|
GPU_VERTBUF_INIT = (1 << 0),
|
2021-02-05 16:23:34 +11:00
|
|
|
/** Data has been touched and need to be re-uploaded. */
|
2020-09-06 16:40:07 +02:00
|
|
|
GPU_VERTBUF_DATA_DIRTY = (1 << 1),
|
|
|
|
|
/** The buffer has been created inside GPU memory. */
|
|
|
|
|
GPU_VERTBUF_DATA_UPLOADED = (1 << 2),
|
2024-03-23 01:24:18 +01:00
|
|
|
};
|
2020-09-06 16:40:07 +02:00
|
|
|
|
2020-10-01 23:51:01 +05:30
|
|
|
ENUM_OPERATORS(GPUVertBufStatus, GPU_VERTBUF_DATA_UPLOADED)
|
2020-09-06 16:40:07 +02:00
|
|
|
|
2019-01-29 08:40:46 +11:00
|
|
|
/**
|
2024-03-24 16:38:30 +01:00
|
|
|
* How to create a #VertBuf:
|
2020-09-06 22:09:51 +02:00
|
|
|
* 1) verts = GPU_vertbuf_calloc()
|
2019-01-29 08:40:46 +11:00
|
|
|
* 2) GPU_vertformat_attr_add(verts->format, ...)
|
|
|
|
|
* 3) GPU_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format
|
|
|
|
|
* 4) GPU_vertbuf_attr_fill(verts, pos, application_pos_buffer)
|
|
|
|
|
*/
|
2016-09-14 16:28:16 +02:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
enum GPUUsageType {
|
2018-07-17 14:46:44 +02:00
|
|
|
/* can be extended to support more types */
|
2022-09-01 22:14:18 +02:00
|
|
|
GPU_USAGE_STREAM = 0,
|
|
|
|
|
GPU_USAGE_STATIC = 1, /* do not keep data in memory */
|
|
|
|
|
GPU_USAGE_DYNAMIC = 2,
|
|
|
|
|
GPU_USAGE_DEVICE_ONLY = 3, /* Do not do host->device data transfers. */
|
|
|
|
|
|
|
|
|
|
/** Extended usage flags. */
|
|
|
|
|
/* Flag for vertex buffers used for textures. Skips additional padding/compaction to ensure
|
|
|
|
|
* format matches the texture exactly. Can be masked with other properties, and is stripped
|
|
|
|
|
* during VertBuf::init. */
|
|
|
|
|
GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY = 1 << 3,
|
2024-03-23 01:24:18 +01:00
|
|
|
};
|
2018-03-17 16:58:43 +01:00
|
|
|
|
2022-09-01 22:14:18 +02:00
|
|
|
ENUM_OPERATORS(GPUUsageType, GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY);
|
|
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
namespace blender::gpu {
|
2016-09-13 02:41:43 -04:00
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
/**
|
|
|
|
|
* Implementation of Vertex Buffers.
|
|
|
|
|
* Base class which is then specialized for each implementation (GL, VK, ...).
|
|
|
|
|
*/
|
|
|
|
|
class VertBuf {
|
|
|
|
|
public:
|
|
|
|
|
static size_t memory_usage;
|
|
|
|
|
|
|
|
|
|
GPUVertFormat format = {};
|
|
|
|
|
/** Number of verts we want to draw. */
|
|
|
|
|
uint vertex_len = 0;
|
|
|
|
|
/** Number of verts data. */
|
|
|
|
|
uint vertex_alloc = 0;
|
|
|
|
|
/** Status flag. */
|
|
|
|
|
GPUVertBufStatus flag = GPU_VERTBUF_INVALID;
|
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
|
/** Usage including extended usage flags. */
|
|
|
|
|
GPUUsageType extended_usage_ = GPU_USAGE_STATIC;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
protected:
|
2024-06-18 21:10:45 +02:00
|
|
|
/** NULL indicates data in VRAM (unmapped) */
|
|
|
|
|
uchar *data_ = nullptr;
|
|
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
/** Usage hint for GL optimization. */
|
|
|
|
|
GPUUsageType usage_ = GPU_USAGE_STATIC;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/** This counter will only avoid freeing the #VertBuf, not the data. */
|
|
|
|
|
int handle_refcount_ = 1;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
VertBuf();
|
|
|
|
|
virtual ~VertBuf();
|
|
|
|
|
|
2024-06-05 18:47:22 +02:00
|
|
|
void init(const GPUVertFormat &format, GPUUsageType usage);
|
2024-03-24 16:38:30 +01:00
|
|
|
void clear();
|
|
|
|
|
|
|
|
|
|
/* Data management. */
|
|
|
|
|
void allocate(uint vert_len);
|
|
|
|
|
void resize(uint vert_len);
|
|
|
|
|
void upload();
|
|
|
|
|
virtual void bind_as_ssbo(uint binding) = 0;
|
|
|
|
|
virtual void bind_as_texture(uint binding) = 0;
|
|
|
|
|
|
|
|
|
|
virtual void wrap_handle(uint64_t handle) = 0;
|
|
|
|
|
|
|
|
|
|
VertBuf *duplicate();
|
|
|
|
|
|
|
|
|
|
/* Size of the data allocated. */
|
|
|
|
|
size_t size_alloc_get() const
|
|
|
|
|
{
|
2024-06-18 21:10:45 +02:00
|
|
|
BLI_assert(this->format.packed);
|
|
|
|
|
return size_t(this->vertex_alloc) * this->format.stride;
|
2024-03-24 16:38:30 +01:00
|
|
|
}
|
|
|
|
|
/* Size of the data uploaded to the GPU. */
|
|
|
|
|
size_t size_used_get() const
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(format.packed);
|
2024-06-18 21:10:45 +02:00
|
|
|
return size_t(this->vertex_len) * this->format.stride;
|
2024-03-24 16:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void reference_add()
|
|
|
|
|
{
|
|
|
|
|
handle_refcount_++;
|
|
|
|
|
}
|
|
|
|
|
void reference_remove()
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(handle_refcount_ > 0);
|
|
|
|
|
handle_refcount_--;
|
|
|
|
|
if (handle_refcount_ == 0) {
|
|
|
|
|
delete this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPUUsageType get_usage_type() const
|
|
|
|
|
{
|
|
|
|
|
return usage_;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-18 21:10:45 +02:00
|
|
|
/**
|
|
|
|
|
* Returns access to the data allocated for the vertex buffer. The size of the data type must
|
|
|
|
|
* match the data type used on the GPU.
|
|
|
|
|
*/
|
|
|
|
|
template<typename T> MutableSpan<T> data()
|
|
|
|
|
{
|
|
|
|
|
return MutableSpan<uchar>(data_, this->size_alloc_get()).cast<T>();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
virtual void update_sub(uint start, uint len, const void *data) = 0;
|
|
|
|
|
virtual void read(void *data) const = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void acquire_data() = 0;
|
|
|
|
|
virtual void resize_data() = 0;
|
|
|
|
|
virtual void release_data() = 0;
|
|
|
|
|
virtual void upload_data() = 0;
|
|
|
|
|
virtual void duplicate_data(VertBuf *dst) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace blender::gpu
|
|
|
|
|
|
|
|
|
|
blender::gpu::VertBuf *GPU_vertbuf_calloc();
|
2024-06-05 18:47:22 +02:00
|
|
|
blender::gpu::VertBuf *GPU_vertbuf_create_with_format_ex(const GPUVertFormat &format,
|
|
|
|
|
GPUUsageType usage);
|
2018-03-17 16:58:43 +01:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
#define GPU_vertbuf_create_with_format(format) \
|
|
|
|
|
GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_STATIC)
|
2016-09-14 16:28:16 +02:00
|
|
|
|
2021-05-26 16:49:17 +02:00
|
|
|
/**
|
2023-02-13 08:34:19 +01:00
|
|
|
* (Download and) fill data with the data from the vertex buffer.
|
|
|
|
|
* NOTE: caller is responsible to reserve enough memory of the data parameter.
|
2021-05-26 16:49:17 +02:00
|
|
|
*/
|
2024-07-29 13:01:12 +10:00
|
|
|
void GPU_vertbuf_read(const blender::gpu::VertBuf *verts, void *data);
|
2021-12-09 20:01:47 +11:00
|
|
|
/** Same as discard but does not free. */
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_clear(blender::gpu::VertBuf *verts);
|
|
|
|
|
void GPU_vertbuf_discard(blender::gpu::VertBuf *);
|
2016-10-23 23:16:54 -04:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
2024-03-24 16:38:30 +01:00
|
|
|
* Avoid blender::gpu::VertBuf data-block being free but not its data.
|
2021-12-09 20:01:47 +11:00
|
|
|
*/
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_handle_ref_add(blender::gpu::VertBuf *verts);
|
|
|
|
|
void GPU_vertbuf_handle_ref_remove(blender::gpu::VertBuf *verts);
|
2020-08-10 01:35:59 +02:00
|
|
|
|
2024-06-05 18:47:22 +02:00
|
|
|
void GPU_vertbuf_init_with_format_ex(blender::gpu::VertBuf &verts,
|
|
|
|
|
const GPUVertFormat &format,
|
|
|
|
|
GPUUsageType);
|
2018-03-17 16:58:43 +01:00
|
|
|
|
2024-06-05 18:47:22 +02:00
|
|
|
void GPU_vertbuf_init_build_on_device(blender::gpu::VertBuf &verts,
|
|
|
|
|
const GPUVertFormat &format,
|
2024-03-24 16:38:30 +01:00
|
|
|
uint v_len);
|
OpenSubDiv: add support for an OpenGL evaluator
This evaluator is used in order to evaluate subdivision at render time, allowing for
faster renders of meshes with a subdivision surface modifier placed at the last
position in the modifier list.
When evaluating the subsurf modifier, we detect whether we can delegate evaluation
to the draw code. If so, the subdivision is first evaluated on the GPU using our own
custom evaluator (only the coarse data needs to be initially sent to the GPU), then,
buffers for the final `MeshBufferCache` are filled on the GPU using a set of
compute shaders. However, some buffers are still filled on the CPU side, if doing so
on the GPU is impractical (e.g. the line adjacency buffer used for x-ray, whose
logic is hardly GPU compatible).
This is done at the mesh buffer extraction level so that the result can be readily used
in the various OpenGL engines, without having to write custom geometry or tesselation
shaders.
We use our own subdivision evaluation shaders, instead of OpenSubDiv's vanilla one, in
order to control the data layout, and interpolation. For example, we store vertex colors
as compressed 16-bit integers, while OpenSubDiv's default evaluator only work for float
types.
In order to still access the modified geometry on the CPU side, for use in modifiers
or transform operators, a dedicated wrapper type is added `MESH_WRAPPER_TYPE_SUBD`.
Subdivision will be lazily evaluated via `BKE_object_get_evaluated_mesh` which will
create such a wrapper if possible. If the final subdivision surface is not needed on
the CPU side, `BKE_object_get_evaluated_mesh_no_subsurf` should be used.
Enabling or disabling GPU subdivision can be done through the user preferences (under
Viewport -> Subdivision).
See patch description for benchmarks.
Reviewed By: campbellbarton, jbakker, fclem, brecht, #eevee_viewport
Differential Revision: https://developer.blender.org/D12406
2021-12-27 16:34:47 +01:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
#define GPU_vertbuf_init_with_format(verts, format) \
|
|
|
|
|
GPU_vertbuf_init_with_format_ex(verts, format, GPU_USAGE_STATIC)
|
2016-09-14 16:28:16 +02:00
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
blender::gpu::VertBuf *GPU_vertbuf_duplicate(blender::gpu::VertBuf *verts);
|
2020-06-19 17:02:55 +02:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Create a new allocation, discarding any existing data.
|
|
|
|
|
*/
|
2024-06-05 18:47:22 +02:00
|
|
|
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len);
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Resize buffer keeping existing data.
|
|
|
|
|
*/
|
2024-06-05 18:47:22 +02:00
|
|
|
void GPU_vertbuf_data_resize(blender::gpu::VertBuf &verts, uint v_len);
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Set vertex count but does not change allocation.
|
|
|
|
|
* Only this many verts will be uploaded to the GPU and rendered.
|
|
|
|
|
* This is useful for streaming data.
|
|
|
|
|
*/
|
2024-06-05 18:47:22 +02:00
|
|
|
void GPU_vertbuf_data_len_set(blender::gpu::VertBuf &verts, uint v_len);
|
2016-09-13 02:41:43 -04:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* The most important #set_attr variant is the untyped one. Get it right first.
|
2019-01-29 07:46:25 +11:00
|
|
|
* It takes a void* so the app developer is responsible for matching their app data types
|
|
|
|
|
* to the vertex attribute's type and component count. They're in control of both, so this
|
2021-12-09 20:01:47 +11:00
|
|
|
* should not be a problem.
|
|
|
|
|
*/
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_attr_set(blender::gpu::VertBuf *, uint a_idx, uint v_idx, const void *data);
|
2019-08-14 23:29:46 +10:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/** Fills a whole vertex (all attributes). Data must match packed layout. */
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_vert_set(blender::gpu::VertBuf *verts, uint v_idx, const void *data);
|
2019-12-02 01:40:58 +01:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Tightly packed, non interleaved input data.
|
|
|
|
|
*/
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_attr_fill(blender::gpu::VertBuf *, uint a_idx, const void *data);
|
2019-08-14 23:29:46 +10:00
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_attr_fill_stride(blender::gpu::VertBuf *,
|
|
|
|
|
uint a_idx,
|
|
|
|
|
uint stride,
|
|
|
|
|
const void *data);
|
2016-09-13 02:41:43 -04:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* For low level access only.
|
2024-06-18 21:10:45 +02:00
|
|
|
*
|
|
|
|
|
* \note This is obsolete, use #VertBuf::data<T>() instead.
|
2021-12-09 20:01:47 +11:00
|
|
|
*/
|
2024-03-23 01:24:18 +01:00
|
|
|
struct GPUVertBufRaw {
|
2018-07-17 14:46:44 +02:00
|
|
|
uint size;
|
|
|
|
|
uint stride;
|
2018-07-18 23:09:31 +10:00
|
|
|
unsigned char *data;
|
|
|
|
|
unsigned char *data_init;
|
2023-12-04 15:13:06 +01:00
|
|
|
#ifndef NDEBUG
|
2018-07-17 14:46:44 +02:00
|
|
|
/* Only for overflow check */
|
2018-07-18 23:09:31 +10:00
|
|
|
unsigned char *_data_end;
|
2017-06-29 20:09:05 +10:00
|
|
|
#endif
|
2024-03-23 01:24:18 +01:00
|
|
|
};
|
2017-06-29 20:09:05 +10:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPU_INLINE void *GPU_vertbuf_raw_step(GPUVertBufRaw *a)
|
2018-07-17 14:46:44 +02:00
|
|
|
{
|
2018-07-18 23:09:31 +10:00
|
|
|
unsigned char *data = a->data;
|
2017-06-29 20:09:05 +10:00
|
|
|
a->data += a->stride;
|
2023-12-04 15:13:06 +01:00
|
|
|
#ifndef NDEBUG
|
2020-09-07 02:12:59 +02:00
|
|
|
BLI_assert(data < a->_data_end);
|
2023-01-05 11:01:32 +08:00
|
|
|
#endif
|
2017-06-29 20:09:05 +10:00
|
|
|
return (void *)data;
|
2018-07-17 14:46:44 +02:00
|
|
|
}
|
2017-06-29 20:09:05 +10:00
|
|
|
|
2024-09-27 10:50:55 +10:00
|
|
|
GPU_INLINE uint GPU_vertbuf_raw_used(const GPUVertBufRaw *a)
|
2018-07-17 14:46:44 +02:00
|
|
|
{
|
2017-06-29 20:33:24 +10:00
|
|
|
return ((a->data - a->data_init) / a->stride);
|
2018-07-17 14:46:44 +02:00
|
|
|
}
|
2016-09-14 16:28:16 +02:00
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_attr_get_raw_data(blender::gpu::VertBuf *, uint a_idx, GPUVertBufRaw *access);
|
2017-04-13 13:30:53 +10:00
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
const GPUVertFormat *GPU_vertbuf_get_format(const blender::gpu::VertBuf *verts);
|
|
|
|
|
uint GPU_vertbuf_get_vertex_alloc(const blender::gpu::VertBuf *verts);
|
|
|
|
|
uint GPU_vertbuf_get_vertex_len(const blender::gpu::VertBuf *verts);
|
|
|
|
|
GPUVertBufStatus GPU_vertbuf_get_status(const blender::gpu::VertBuf *verts);
|
|
|
|
|
void GPU_vertbuf_tag_dirty(blender::gpu::VertBuf *verts);
|
2020-09-06 16:40:07 +02:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* Should be rename to #GPU_vertbuf_data_upload.
|
|
|
|
|
*/
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_use(blender::gpu::VertBuf *);
|
|
|
|
|
void GPU_vertbuf_bind_as_ssbo(blender::gpu::VertBuf *verts, int binding);
|
|
|
|
|
void GPU_vertbuf_bind_as_texture(blender::gpu::VertBuf *verts, int binding);
|
2017-05-15 13:05:32 -04:00
|
|
|
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_wrap_handle(blender::gpu::VertBuf *verts, uint64_t handle);
|
OpenSubDiv: add support for an OpenGL evaluator
This evaluator is used in order to evaluate subdivision at render time, allowing for
faster renders of meshes with a subdivision surface modifier placed at the last
position in the modifier list.
When evaluating the subsurf modifier, we detect whether we can delegate evaluation
to the draw code. If so, the subdivision is first evaluated on the GPU using our own
custom evaluator (only the coarse data needs to be initially sent to the GPU), then,
buffers for the final `MeshBufferCache` are filled on the GPU using a set of
compute shaders. However, some buffers are still filled on the CPU side, if doing so
on the GPU is impractical (e.g. the line adjacency buffer used for x-ray, whose
logic is hardly GPU compatible).
This is done at the mesh buffer extraction level so that the result can be readily used
in the various OpenGL engines, without having to write custom geometry or tesselation
shaders.
We use our own subdivision evaluation shaders, instead of OpenSubDiv's vanilla one, in
order to control the data layout, and interpolation. For example, we store vertex colors
as compressed 16-bit integers, while OpenSubDiv's default evaluator only work for float
types.
In order to still access the modified geometry on the CPU side, for use in modifiers
or transform operators, a dedicated wrapper type is added `MESH_WRAPPER_TYPE_SUBD`.
Subdivision will be lazily evaluated via `BKE_object_get_evaluated_mesh` which will
create such a wrapper if possible. If the final subdivision surface is not needed on
the CPU side, `BKE_object_get_evaluated_mesh_no_subsurf` should be used.
Enabling or disabling GPU subdivision can be done through the user preferences (under
Viewport -> Subdivision).
See patch description for benchmarks.
Reviewed By: campbellbarton, jbakker, fclem, brecht, #eevee_viewport
Differential Revision: https://developer.blender.org/D12406
2021-12-27 16:34:47 +01:00
|
|
|
|
2021-12-09 20:01:47 +11:00
|
|
|
/**
|
|
|
|
|
* XXX: do not use!
|
|
|
|
|
* This is just a wrapper for the use of the Hair refine workaround.
|
|
|
|
|
* To be used with #GPU_vertbuf_use().
|
|
|
|
|
*/
|
2024-03-24 16:38:30 +01:00
|
|
|
void GPU_vertbuf_update_sub(blender::gpu::VertBuf *verts, uint start, uint len, const void *data);
|
2020-09-12 19:48:52 +02:00
|
|
|
|
2018-07-17 14:46:44 +02:00
|
|
|
/* Metrics */
|
2024-03-23 01:24:18 +01:00
|
|
|
uint GPU_vertbuf_get_memory_usage();
|
2017-04-13 13:30:53 +10:00
|
|
|
|
2018-07-17 14:46:44 +02:00
|
|
|
/* Macros */
|
2018-07-18 00:12:21 +02:00
|
|
|
#define GPU_VERTBUF_DISCARD_SAFE(verts) \
|
|
|
|
|
do { \
|
2024-03-23 01:24:18 +01:00
|
|
|
if (verts != nullptr) { \
|
2018-07-18 00:12:21 +02:00
|
|
|
GPU_vertbuf_discard(verts); \
|
2024-03-23 01:24:18 +01:00
|
|
|
verts = nullptr; \
|
2017-04-13 13:30:53 +10:00
|
|
|
} \
|
|
|
|
|
} while (0)
|