Blender V4.3
gpu_storage_buffer_private.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BLI_span.hh"
12#include "BLI_sys_types.h"
13
14struct GPUStorageBuf;
15
16namespace blender {
17namespace gpu {
18
19class VertBuf;
20
21#ifndef NDEBUG
22# define DEBUG_NAME_LEN 64
23#else
24# define DEBUG_NAME_LEN 8
25#endif
26
32 protected:
36 void *data_ = nullptr;
39
40 public:
41 StorageBuf(size_t size, const char *name);
42 virtual ~StorageBuf();
43
44 virtual void update(const void *data) = 0;
45 virtual void bind(int slot) = 0;
46 virtual void unbind() = 0;
47 virtual void clear(uint32_t clear_value) = 0;
48 virtual void copy_sub(VertBuf *src, uint dst_offset, uint src_offset, uint copy_size) = 0;
49 virtual void read(void *data) = 0;
50 virtual void async_flush_to_host() = 0;
51 virtual void sync_as_indirect_buffer() = 0;
52};
53
54/* Syntactic sugar. */
55static inline GPUStorageBuf *wrap(StorageBuf *storage_buf)
56{
57 return reinterpret_cast<GPUStorageBuf *>(storage_buf);
58}
59static inline StorageBuf *unwrap(GPUStorageBuf *storage_buf)
60{
61 return reinterpret_cast<StorageBuf *>(storage_buf);
62}
63static inline const StorageBuf *unwrap(const GPUStorageBuf *storage_buf)
64{
65 return reinterpret_cast<const StorageBuf *>(storage_buf);
66}
67
68#undef DEBUG_NAME_LEN
69
70} // namespace gpu
71} // namespace blender
unsigned int uint
StorageBuf(size_t size, const char *name)
virtual void unbind()=0
virtual void bind(int slot)=0
virtual void read(void *data)=0
virtual void async_flush_to_host()=0
virtual void clear(uint32_t clear_value)=0
virtual void update(const void *data)=0
virtual void copy_sub(VertBuf *src, uint dst_offset, uint src_offset, uint copy_size)=0
virtual void sync_as_indirect_buffer()=0
DOF_REDUCE_GROUP_SIZE dof_buf scatter_fg_list_buf[] storage_buf(1, Qualifier::WRITE, "ScatterRect", "scatter_bg_list_buf[]") .storage_buf(2
#define DEBUG_NAME_LEN
static Context * unwrap(GPUContext *ctx)
static GPUContext * wrap(Context *ctx)
unsigned int uint32_t
Definition stdint.h:80