Blender  V3.3
gpu_storage_buffer_private.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2022 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 #include "BLI_sys_types.h"
11 
12 struct GPUStorageBuf;
13 
14 namespace blender {
15 namespace gpu {
16 
17 #ifdef DEBUG
18 # define DEBUG_NAME_LEN 64
19 #else
20 # define DEBUG_NAME_LEN 8
21 #endif
22 
27 class StorageBuf {
28  protected:
32  void *data_ = nullptr;
35 
36  public:
37  StorageBuf(size_t size, const char *name);
38  virtual ~StorageBuf();
39 
40  virtual void update(const void *data) = 0;
41  virtual void bind(int slot) = 0;
42  virtual void unbind() = 0;
43  virtual void clear(eGPUTextureFormat internal_format,
44  eGPUDataFormat data_format,
45  void *data) = 0;
46  virtual void copy_sub(VertBuf *src, uint dst_offset, uint src_offset, uint copy_size) = 0;
47 };
48 
49 /* Syntactic sugar. */
50 static inline GPUStorageBuf *wrap(StorageBuf *vert)
51 {
52  return reinterpret_cast<GPUStorageBuf *>(vert);
53 }
54 static inline StorageBuf *unwrap(GPUStorageBuf *vert)
55 {
56  return reinterpret_cast<StorageBuf *>(vert);
57 }
58 static inline const StorageBuf *unwrap(const GPUStorageBuf *vert)
59 {
60  return reinterpret_cast<const StorageBuf *>(vert);
61 }
62 
63 #undef DEBUG_NAME_LEN
64 
65 } // namespace gpu
66 } // namespace blender
unsigned int uint
Definition: BLI_sys_types.h:67
struct GPUStorageBuf GPUStorageBuf
eGPUDataFormat
Definition: GPU_texture.h:170
eGPUTextureFormat
Definition: GPU_texture.h:83
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
virtual void clear(eGPUTextureFormat internal_format, eGPUDataFormat data_format, void *data)=0
StorageBuf(size_t size, const char *name)
virtual void unbind()=0
virtual void bind(int slot)=0
virtual void update(const void *data)=0
virtual void copy_sub(VertBuf *src, uint dst_offset, uint src_offset, uint copy_size)=0
SyclQueue void void * src
#define DEBUG_NAME_LEN
static GPUContext * wrap(Context *ctx)
static Context * unwrap(GPUContext *ctx)