Blender  V3.3
gpu_texture_private.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 #include "BLI_assert.h"
11 
12 #include "GPU_vertex_buffer.h"
13 
15 
16 namespace blender {
17 namespace gpu {
18 
19 typedef enum eGPUTextureFormatFlag {
20  GPU_FORMAT_DEPTH = (1 << 0),
21  GPU_FORMAT_STENCIL = (1 << 1),
22  GPU_FORMAT_INTEGER = (1 << 2),
23  GPU_FORMAT_FLOAT = (1 << 3),
25 
28 
30 
31 typedef enum eGPUTextureType {
32  GPU_TEXTURE_1D = (1 << 0),
33  GPU_TEXTURE_2D = (1 << 1),
34  GPU_TEXTURE_3D = (1 << 2),
35  GPU_TEXTURE_CUBE = (1 << 3),
36  GPU_TEXTURE_ARRAY = (1 << 4),
37  GPU_TEXTURE_BUFFER = (1 << 5),
38 
43 
45 
46 #ifdef DEBUG
47 # define DEBUG_NAME_LEN 64
48 #else
49 # define DEBUG_NAME_LEN 8
50 #endif
51 
52 /* Maximum number of FBOs a texture can be attached to. */
53 #define GPU_TEX_MAX_FBO_ATTACHED 32
54 
59 class Texture {
60  public:
64  int refcount = 1;
66  int src_w = 0, src_h = 0;
67 #ifndef GPU_NO_USE_PY_REFERENCES
72  void **py_ref = nullptr;
73 #endif
74 
75  protected:
76  /* ---- Texture format (immutable after init). ---- */
78  int w_, h_, d_;
85 
87  /* TODO(fclem): Should become immutable and the need for mipmaps should be specified upfront. */
88  int mipmaps_ = -1;
90  int mip_min_ = 0, mip_max_ = 0;
91 
94 
98 
99  public:
100  Texture(const char *name);
101  virtual ~Texture();
102 
103  /* Return true on success. */
104  bool init_1D(int w, int layers, int mip_len, eGPUTextureFormat format);
105  bool init_2D(int w, int h, int layers, int mip_len, eGPUTextureFormat format);
106  bool init_3D(int w, int h, int d, int mip_len, eGPUTextureFormat format);
107  bool init_cubemap(int w, int layers, int mip_len, eGPUTextureFormat format);
109  bool init_view(const GPUTexture *src,
111  int mip_start,
112  int mip_len,
113  int layer_start,
114  int layer_len,
115  bool cube_as_array);
116 
117  virtual void generate_mipmap() = 0;
118  virtual void copy_to(Texture *tex) = 0;
119  virtual void clear(eGPUDataFormat format, const void *data) = 0;
120  virtual void swizzle_set(const char swizzle_mask[4]) = 0;
121  virtual void stencil_texture_mode_set(bool use_stencil) = 0;
122  virtual void mip_range_set(int min, int max) = 0;
123  virtual void *read(int mip, eGPUDataFormat format) = 0;
124 
126  void detach_from(FrameBuffer *fb);
127  void update(eGPUDataFormat format, const void *data);
128 
129  virtual void update_sub(
130  int mip, int offset[3], int extent[3], eGPUDataFormat format, const void *data) = 0;
131 
132  /* TODO(fclem): Legacy. Should be removed at some point. */
133  virtual uint gl_bindcode_get() const = 0;
134  int width_get() const
135  {
136  return w_;
137  }
138  int height_get() const
139  {
140  return h_;
141  }
142  int depth_get() const
143  {
144  return d_;
145  }
146 
147  void mip_size_get(int mip, int r_size[3]) const
148  {
149  /* TODO: assert if lvl is below the limit of 1px in each dimension. */
150  int div = 1 << mip;
151  r_size[0] = max_ii(1, w_ / div);
152 
153  if (type_ == GPU_TEXTURE_1D_ARRAY) {
154  r_size[1] = h_;
155  }
156  else if (h_ > 0) {
157  r_size[1] = max_ii(1, h_ / div);
158  }
159 
161  r_size[2] = d_;
162  }
163  else if (d_ > 0) {
164  r_size[2] = max_ii(1, d_ / div);
165  }
166  }
167 
168  int mip_width_get(int mip) const
169  {
170  return max_ii(1, w_ / (1 << mip));
171  }
172  int mip_height_get(int mip) const
173  {
174  return (type_ == GPU_TEXTURE_1D_ARRAY) ? h_ : max_ii(1, h_ / (1 << mip));
175  }
176  int mip_depth_get(int mip) const
177  {
178  return (type_ & (GPU_TEXTURE_ARRAY | GPU_TEXTURE_CUBE)) ? d_ : max_ii(1, d_ / (1 << mip));
179  }
180 
181  /* Return number of dimension taking the array type into account. */
182  int dimensions_count() const
183  {
184  const int array = (type_ & GPU_TEXTURE_ARRAY) ? 1 : 0;
185  switch (type_ & ~GPU_TEXTURE_ARRAY) {
186  case GPU_TEXTURE_BUFFER:
187  return 1;
188  case GPU_TEXTURE_1D:
189  return 1 + array;
190  case GPU_TEXTURE_2D:
191  return 2 + array;
192  case GPU_TEXTURE_CUBE:
193  case GPU_TEXTURE_3D:
194  default:
195  return 3;
196  }
197  }
198  /* Return number of array layer (or face layer) for texture array or 1 for the others. */
199  int layer_count() const
200  {
201  switch (type_) {
203  return h_;
206  return d_;
207  default:
208  return 1;
209  }
210  }
211 
212  int mip_count() const
213  {
214  return mipmaps_;
215  }
216 
218  {
219  return format_;
220  }
222  {
223  return format_flag_;
224  }
226  {
227  return type_;
228  }
230  {
231  switch (format_) {
235  BLI_assert(slot == 0);
239  BLI_assert(slot == 0);
241  default:
242  return GPU_FB_COLOR_ATTACHMENT0 + slot;
243  }
244  }
245 
246  protected:
247  virtual bool init_internal() = 0;
248  virtual bool init_internal(GPUVertBuf *vbo) = 0;
249  virtual bool init_internal(const GPUTexture *src, int mip_offset, int layer_offset) = 0;
250 };
251 
252 /* Syntactic sugar. */
253 static inline GPUTexture *wrap(Texture *vert)
254 {
255  return reinterpret_cast<GPUTexture *>(vert);
256 }
257 static inline Texture *unwrap(GPUTexture *vert)
258 {
259  return reinterpret_cast<Texture *>(vert);
260 }
261 static inline const Texture *unwrap(const GPUTexture *vert)
262 {
263  return reinterpret_cast<const Texture *>(vert);
264 }
265 
266 #undef DEBUG_NAME_LEN
267 
269 {
270  switch (format) {
271  case GPU_RGBA32F:
272  return 32;
273  case GPU_RG32F:
274  case GPU_RGBA16F:
275  case GPU_RGBA16:
276  return 16;
277  case GPU_RGB16F:
278  return 12;
279  case GPU_DEPTH32F_STENCIL8: /* 32-bit depth, 8 bits stencil, and 24 unused bits. */
280  return 8;
281  case GPU_RG16F:
282  case GPU_RG16I:
283  case GPU_RG16UI:
284  case GPU_RG16:
287  case GPU_RGBA8UI:
288  case GPU_RGBA8:
289  case GPU_SRGB8_A8:
290  case GPU_RGB10_A2:
291  case GPU_R11F_G11F_B10F:
292  case GPU_R32F:
293  case GPU_R32UI:
294  case GPU_R32I:
295  return 4;
297  return 3;
299  case GPU_R16F:
300  case GPU_R16UI:
301  case GPU_R16I:
302  case GPU_RG8:
303  case GPU_R16:
304  return 2;
305  case GPU_R8:
306  case GPU_R8UI:
307  return 1;
308  case GPU_SRGB8_A8_DXT1:
309  case GPU_SRGB8_A8_DXT3:
310  case GPU_SRGB8_A8_DXT5:
311  case GPU_RGBA8_DXT1:
312  case GPU_RGBA8_DXT3:
313  case GPU_RGBA8_DXT5:
314  return 1; /* Incorrect but actual size is fractional. */
315  default:
316  BLI_assert_msg(0, "Texture format incorrect or unsupported");
317  return 0;
318  }
319 }
320 
321 inline size_t to_block_size(eGPUTextureFormat data_type)
322 {
323  switch (data_type) {
324  case GPU_SRGB8_A8_DXT1:
325  case GPU_RGBA8_DXT1:
326  return 8;
327  case GPU_SRGB8_A8_DXT3:
328  case GPU_SRGB8_A8_DXT5:
329  case GPU_RGBA8_DXT3:
330  case GPU_RGBA8_DXT5:
331  return 16;
332  default:
333  BLI_assert_msg(0, "Texture format is not a compressed format");
334  return 0;
335  }
336 }
337 
339 {
340  switch (format) {
344  return GPU_FORMAT_DEPTH;
348  case GPU_R8UI:
349  case GPU_RG16I:
350  case GPU_R16I:
351  case GPU_RG16UI:
352  case GPU_R16UI:
353  case GPU_R32UI:
354  return GPU_FORMAT_INTEGER;
355  case GPU_SRGB8_A8_DXT1:
356  case GPU_SRGB8_A8_DXT3:
357  case GPU_SRGB8_A8_DXT5:
358  case GPU_RGBA8_DXT1:
359  case GPU_RGBA8_DXT3:
360  case GPU_RGBA8_DXT5:
361  return GPU_FORMAT_COMPRESSED;
362  default:
363  return GPU_FORMAT_FLOAT;
364  }
365 }
366 
368 {
369  switch (format) {
370  case GPU_RGBA8:
371  case GPU_RGBA8I:
372  case GPU_RGBA8UI:
373  case GPU_RGBA16:
374  case GPU_RGBA16F:
375  case GPU_RGBA16I:
376  case GPU_RGBA16UI:
377  case GPU_RGBA32F:
378  case GPU_RGBA32I:
379  case GPU_RGBA32UI:
380  case GPU_SRGB8_A8:
381  case GPU_RGB10_A2:
382  return 4;
383  case GPU_RGB16F:
384  case GPU_R11F_G11F_B10F:
385  return 3;
386  case GPU_RG8:
387  case GPU_RG8I:
388  case GPU_RG8UI:
389  case GPU_RG16:
390  case GPU_RG16F:
391  case GPU_RG16I:
392  case GPU_RG16UI:
393  case GPU_RG32F:
394  case GPU_RG32I:
395  case GPU_RG32UI:
396  return 2;
397  default:
398  return 1;
399  }
400 }
401 
402 inline size_t to_bytesize(eGPUDataFormat data_format)
403 {
404  switch (data_format) {
405  case GPU_DATA_UBYTE:
406  return 1;
407  case GPU_DATA_FLOAT:
408  case GPU_DATA_INT:
409  case GPU_DATA_UINT:
410  return 4;
411  case GPU_DATA_UINT_24_8:
414  return 4;
415  default:
416  BLI_assert_msg(0, "Data format incorrect or unsupported");
417  return 0;
418  }
419 }
420 
421 inline size_t to_bytesize(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
422 {
423  return to_component_len(tex_format) * to_bytesize(data_format);
424 }
425 
426 /* Definitely not complete, edit according to the gl specification. */
427 inline bool validate_data_format(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
428 {
429  switch (tex_format) {
433  return data_format == GPU_DATA_FLOAT;
436  return data_format == GPU_DATA_UINT_24_8;
437  case GPU_R8UI:
438  case GPU_R16UI:
439  case GPU_RG16UI:
440  case GPU_R32UI:
441  return data_format == GPU_DATA_UINT;
442  case GPU_RG16I:
443  case GPU_R16I:
444  return data_format == GPU_DATA_INT;
445  case GPU_R8:
446  case GPU_RG8:
447  case GPU_RGBA8:
448  case GPU_RGBA8UI:
449  case GPU_SRGB8_A8:
450  return ELEM(data_format, GPU_DATA_UBYTE, GPU_DATA_FLOAT);
451  case GPU_RGB10_A2:
452  return ELEM(data_format, GPU_DATA_2_10_10_10_REV, GPU_DATA_FLOAT);
453  case GPU_R11F_G11F_B10F:
454  return ELEM(data_format, GPU_DATA_10_11_11_REV, GPU_DATA_FLOAT);
455  default:
456  return data_format == GPU_DATA_FLOAT;
457  }
458 }
459 
460 /* Ensure valid upload formats. With format conversion support, certain types can be extended to
461  * allow upload from differing source formats. If these cases are added, amend accordingly. */
462 inline bool validate_data_format_mtl(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
463 {
464  switch (tex_format) {
468  return ELEM(data_format, GPU_DATA_FLOAT, GPU_DATA_UINT);
471  /* Data can be provided as a 4-byte UINT. */
472  return ELEM(data_format, GPU_DATA_UINT_24_8, GPU_DATA_UINT);
473  case GPU_R8UI:
474  case GPU_R16UI:
475  case GPU_RG16UI:
476  case GPU_R32UI:
477  case GPU_RGBA32UI:
478  case GPU_RGBA16UI:
479  case GPU_RG8UI:
480  case GPU_RG32UI:
481  return data_format == GPU_DATA_UINT;
482  case GPU_R32I:
483  case GPU_RG16I:
484  case GPU_R16I:
485  case GPU_RGBA8I:
486  case GPU_RGBA32I:
487  case GPU_RGBA16I:
488  case GPU_RG8I:
489  case GPU_RG32I:
490  case GPU_R8I:
491  return data_format == GPU_DATA_INT;
492  case GPU_R8:
493  case GPU_RG8:
494  case GPU_RGBA8:
495  case GPU_RGBA8_DXT1:
496  case GPU_RGBA8_DXT3:
497  case GPU_RGBA8_DXT5:
498  case GPU_RGBA8UI:
499  case GPU_SRGB8_A8:
500  case GPU_SRGB8_A8_DXT1:
501  case GPU_SRGB8_A8_DXT3:
502  case GPU_SRGB8_A8_DXT5:
503  return ELEM(data_format, GPU_DATA_UBYTE, GPU_DATA_FLOAT);
504  case GPU_RGB10_A2:
505  return ELEM(data_format, GPU_DATA_2_10_10_10_REV, GPU_DATA_FLOAT);
506  case GPU_R11F_G11F_B10F:
507  return ELEM(data_format, GPU_DATA_10_11_11_REV, GPU_DATA_FLOAT);
508  case GPU_RGBA16F:
509  return ELEM(data_format, GPU_DATA_HALF_FLOAT, GPU_DATA_FLOAT);
510  case GPU_RGBA32F:
511  case GPU_RGBA16:
512  case GPU_RG32F:
513  case GPU_RG16F:
514  case GPU_RG16:
515  case GPU_R32F:
516  case GPU_R16F:
517  case GPU_R16:
518  case GPU_RGB16F:
519  return data_format == GPU_DATA_FLOAT;
520  default:
521  BLI_assert_msg(0, "Unrecognized data format");
522  return data_format == GPU_DATA_FLOAT;
523  }
524 }
525 
527 {
528  switch (tex_format) {
532  return GPU_DATA_FLOAT;
535  return GPU_DATA_UINT_24_8;
536  case GPU_R16UI:
537  case GPU_R32UI:
538  case GPU_RG16UI:
539  case GPU_RG32UI:
540  case GPU_RGBA16UI:
541  case GPU_RGBA32UI:
542  return GPU_DATA_UINT;
543  case GPU_R16I:
544  case GPU_R32I:
545  case GPU_R8I:
546  case GPU_RG16I:
547  case GPU_RG32I:
548  case GPU_RG8I:
549  case GPU_RGBA16I:
550  case GPU_RGBA32I:
551  case GPU_RGBA8I:
552  return GPU_DATA_INT;
553  case GPU_R8:
554  case GPU_R8UI:
555  case GPU_RG8:
556  case GPU_RG8UI:
557  case GPU_RGBA8:
558  case GPU_RGBA8UI:
559  case GPU_SRGB8_A8:
560  return GPU_DATA_UBYTE;
561  case GPU_RGB10_A2:
563  case GPU_R11F_G11F_B10F:
564  return GPU_DATA_10_11_11_REV;
565  default:
566  return GPU_DATA_FLOAT;
567  }
568 }
569 
571 {
572  switch (tex_format) {
576  return GPU_DEPTH_BIT;
580  default:
581  return GPU_COLOR_BIT;
582  }
583 }
584 
586 {
587  if (format->attr_len > 1 || format->attr_len == 0) {
588  BLI_assert_msg(0, "Incorrect vertex format for buffer texture");
589  return GPU_DEPTH_COMPONENT24;
590  }
591  switch (format->attrs[0].comp_len) {
592  case 1:
593  switch (format->attrs[0].comp_type) {
594  case GPU_COMP_I8:
595  return GPU_R8I;
596  case GPU_COMP_U8:
597  return GPU_R8UI;
598  case GPU_COMP_I16:
599  return GPU_R16I;
600  case GPU_COMP_U16:
601  return GPU_R16UI;
602  case GPU_COMP_I32:
603  return GPU_R32I;
604  case GPU_COMP_U32:
605  return GPU_R32UI;
606  case GPU_COMP_F32:
607  return GPU_R32F;
608  default:
609  break;
610  }
611  break;
612  case 2:
613  switch (format->attrs[0].comp_type) {
614  case GPU_COMP_I8:
615  return GPU_RG8I;
616  case GPU_COMP_U8:
617  return GPU_RG8UI;
618  case GPU_COMP_I16:
619  return GPU_RG16I;
620  case GPU_COMP_U16:
621  return GPU_RG16UI;
622  case GPU_COMP_I32:
623  return GPU_RG32I;
624  case GPU_COMP_U32:
625  return GPU_RG32UI;
626  case GPU_COMP_F32:
627  return GPU_RG32F;
628  default:
629  break;
630  }
631  break;
632  case 3:
633  /* Not supported until GL 4.0 */
634  break;
635  case 4:
636  switch (format->attrs[0].comp_type) {
637  case GPU_COMP_I8:
638  return GPU_RGBA8I;
639  case GPU_COMP_U8:
640  return GPU_RGBA8UI;
641  case GPU_COMP_I16:
642  return GPU_RGBA16I;
643  case GPU_COMP_U16:
644  /* NOTE: Checking the fetch mode to select the right GPU texture format. This can be
645  * added to other formats as well. */
646  switch (format->attrs[0].fetch_mode) {
647  case GPU_FETCH_INT:
648  return GPU_RGBA16UI;
650  return GPU_RGBA16;
652  return GPU_RGBA16F;
653  case GPU_FETCH_FLOAT:
654  return GPU_RGBA16F;
655  }
656  case GPU_COMP_I32:
657  return GPU_RGBA32I;
658  case GPU_COMP_U32:
659  return GPU_RGBA32UI;
660  case GPU_COMP_F32:
661  return GPU_RGBA32F;
662  default:
663  break;
664  }
665  break;
666  default:
667  break;
668  }
669  BLI_assert_msg(0, "Unsupported vertex format for buffer texture");
670  return GPU_DEPTH_COMPONENT24;
671 }
672 
673 } // namespace gpu
674 } // namespace blender
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
MINLINE int max_ii(int a, int b)
unsigned int uint
Definition: BLI_sys_types.h:67
#define ELEM(...)
eGPUFrameBufferBits
@ GPU_DEPTH_BIT
@ GPU_STENCIL_BIT
@ GPU_COLOR_BIT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
eGPUSamplerState
Definition: GPU_texture.h:25
@ GPU_SAMPLER_DEFAULT
Definition: GPU_texture.h:26
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
eGPUDataFormat
Definition: GPU_texture.h:170
@ GPU_DATA_HALF_FLOAT
Definition: GPU_texture.h:178
@ GPU_DATA_UINT_24_8
Definition: GPU_texture.h:175
@ GPU_DATA_INT
Definition: GPU_texture.h:172
@ GPU_DATA_10_11_11_REV
Definition: GPU_texture.h:176
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:174
@ GPU_DATA_UINT
Definition: GPU_texture.h:173
@ GPU_DATA_2_10_10_10_REV
Definition: GPU_texture.h:177
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:171
eGPUTextureFormat
Definition: GPU_texture.h:83
@ GPU_R16UI
Definition: GPU_texture.h:111
@ GPU_RG16F
Definition: GPU_texture.h:103
@ GPU_DEPTH32F_STENCIL8
Definition: GPU_texture.h:119
@ GPU_R16I
Definition: GPU_texture.h:112
@ GPU_SRGB8_A8
Definition: GPU_texture.h:121
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:120
@ GPU_RGB10_A2
Definition: GPU_texture.h:117
@ GPU_R32I
Definition: GPU_texture.h:109
@ GPU_RG8UI
Definition: GPU_texture.h:95
@ GPU_R16F
Definition: GPU_texture.h:113
@ GPU_SRGB8_A8_DXT5
Definition: GPU_texture.h:151
@ GPU_RG8I
Definition: GPU_texture.h:96
@ GPU_RG16I
Definition: GPU_texture.h:102
@ GPU_RG32UI
Definition: GPU_texture.h:98
@ GPU_RGBA32F
Definition: GPU_texture.h:90
@ GPU_RG8
Definition: GPU_texture.h:97
@ GPU_RG32I
Definition: GPU_texture.h:99
@ GPU_SRGB8_A8_DXT1
Definition: GPU_texture.h:149
@ GPU_RG16
Definition: GPU_texture.h:104
@ GPU_RGBA32UI
Definition: GPU_texture.h:88
@ GPU_R8I
Definition: GPU_texture.h:106
@ GPU_R16
Definition: GPU_texture.h:114
@ GPU_RG16UI
Definition: GPU_texture.h:101
@ GPU_RGBA8I
Definition: GPU_texture.h:86
@ GPU_RGBA8_DXT1
Definition: GPU_texture.h:152
@ GPU_RGBA8UI
Definition: GPU_texture.h:85
@ GPU_RGBA16UI
Definition: GPU_texture.h:91
@ GPU_RGBA16I
Definition: GPU_texture.h:92
@ GPU_R8UI
Definition: GPU_texture.h:105
@ GPU_RGBA16
Definition: GPU_texture.h:94
@ GPU_SRGB8_A8_DXT3
Definition: GPU_texture.h:150
@ GPU_RGBA8_DXT3
Definition: GPU_texture.h:153
@ GPU_RG32F
Definition: GPU_texture.h:100
@ GPU_R8
Definition: GPU_texture.h:107
@ GPU_DEPTH_COMPONENT24
Definition: GPU_texture.h:166
@ GPU_RGB16F
Definition: GPU_texture.h:127
@ GPU_R32UI
Definition: GPU_texture.h:108
@ GPU_RGBA32I
Definition: GPU_texture.h:89
@ GPU_RGBA8_DXT5
Definition: GPU_texture.h:154
@ GPU_DEPTH_COMPONENT32F
Definition: GPU_texture.h:165
@ GPU_DEPTH_COMPONENT16
Definition: GPU_texture.h:167
@ GPU_R11F_G11F_B10F
Definition: GPU_texture.h:118
@ GPU_RGBA8
Definition: GPU_texture.h:87
struct GPUVertBuf GPUVertBuf
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT_UNIT
@ GPU_FETCH_INT
@ GPU_FETCH_INT_TO_FLOAT
@ GPU_COMP_U16
@ GPU_COMP_F32
@ GPU_COMP_I32
@ GPU_COMP_I8
@ GPU_COMP_U32
@ GPU_COMP_I16
@ GPU_COMP_U8
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
virtual void mip_range_set(int min, int max)=0
virtual uint gl_bindcode_get() const =0
virtual bool init_internal(GPUVertBuf *vbo)=0
virtual void stencil_texture_mode_set(bool use_stencil)=0
void attach_to(FrameBuffer *fb, GPUAttachmentType type)
Definition: gpu_texture.cc:182
int mip_width_get(int mip) const
eGPUTextureFormat format_
int mip_depth_get(int mip) const
eGPUTextureFormatFlag format_flag_get() const
virtual void generate_mipmap()=0
bool init_view(const GPUTexture *src, eGPUTextureFormat format, int mip_start, int mip_len, int layer_start, int layer_len, bool cube_as_array)
Definition: gpu_texture.cc:133
eGPUTextureFormat format_get() const
eGPUTextureFormatFlag format_flag_
void update(eGPUDataFormat format, const void *data)
Definition: gpu_texture.cc:206
char name_[DEBUG_NAME_LEN]
FrameBuffer * fb_[GPU_TEX_MAX_FBO_ATTACHED]
virtual void swizzle_set(const char swizzle_mask[4])=0
bool init_buffer(GPUVertBuf *vbo, eGPUTextureFormat format)
Definition: gpu_texture.cc:118
GPUAttachmentType fb_attachment_[GPU_TEX_MAX_FBO_ATTACHED]
GPUAttachmentType attachment_type(int slot) const
bool init_1D(int w, int layers, int mip_len, eGPUTextureFormat format)
Definition: gpu_texture.cc:54
eGPUSamplerState sampler_state
int mip_height_get(int mip) const
virtual bool init_internal(const GPUTexture *src, int mip_offset, int layer_offset)=0
virtual void clear(eGPUDataFormat format, const void *data)=0
eGPUTextureType type_get() const
virtual bool init_internal()=0
bool init_cubemap(int w, int layers, int mip_len, eGPUTextureFormat format)
Definition: gpu_texture.cc:102
virtual void * read(int mip, eGPUDataFormat format)=0
virtual void update_sub(int mip, int offset[3], int extent[3], eGPUDataFormat format, const void *data)=0
void mip_size_get(int mip, int r_size[3]) const
virtual void copy_to(Texture *tex)=0
bool init_3D(int w, int h, int d, int mip_len, eGPUTextureFormat format)
Definition: gpu_texture.cc:86
Texture(const char *name)
Definition: gpu_texture.cc:25
void detach_from(FrameBuffer *fb)
Definition: gpu_texture.cc:194
bool init_2D(int w, int h, int layers, int mip_len, eGPUTextureFormat format)
Definition: gpu_texture.cc:70
SyclQueue void void * src
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx GPU_R32F
@ GPU_FB_DEPTH_STENCIL_ATTACHMENT
@ GPU_FB_COLOR_ATTACHMENT0
@ GPU_FB_DEPTH_ATTACHMENT
#define DEBUG_NAME_LEN
#define GPU_TEX_MAX_FBO_ATTACHED
BLI_INLINE float fb(float length, float L)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
format
Definition: logImageCore.h:38
ENUM_OPERATORS(MTLPipelineStateDirtyFlag, MTL_PIPELINE_STATE_CULLMODE_FLAG)
bool validate_data_format_mtl(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
bool validate_data_format(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
size_t to_block_size(eGPUTextureFormat data_type)
static GPUContext * wrap(Context *ctx)
static Context * unwrap(GPUContext *ctx)
eGPUFrameBufferBits to_framebuffer_bits(eGPUTextureFormat tex_format)
eGPUDataFormat to_data_format(eGPUTextureFormat tex_format)
static eGPUTextureFormat to_texture_format(const GPUVertFormat *format)
eGPUTextureFormatFlag to_format_flag(eGPUTextureFormat format)
static size_t to_bytesize(GPUIndexBufType type)
int to_component_len(eGPUTextureFormat format)
#define min(a, b)
Definition: sort.c:35
float max