Blender  V3.3
draw_manager_texture.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2016 Blender Foundation. */
3 
8 #include "draw_manager.h"
9 #include "draw_texture_pool.h"
10 
11 #ifndef NDEBUG
12 /* Maybe gpu_texture.c is a better place for this. */
14 {
15  /* Some formats do not work with frame-buffers. */
16  switch (format) {
17  /* Only add formats that are COMPATIBLE with FB.
18  * Generally they are multiple of 16bit. */
19  case GPU_R8:
20  case GPU_R8UI:
21  case GPU_R16F:
22  case GPU_R16I:
23  case GPU_R16UI:
24  case GPU_R16:
25  case GPU_R32F:
26  case GPU_R32UI:
27  case GPU_RG8:
28  case GPU_RG16:
29  case GPU_RG16F:
30  case GPU_RG16I:
31  case GPU_RG32F:
32  case GPU_RGB10_A2:
33  case GPU_R11F_G11F_B10F:
34  case GPU_RGBA8:
35  case GPU_RGBA16:
36  case GPU_RGBA16F:
37  case GPU_RGBA32F:
42  return true;
43  default:
44  return false;
45  }
46 }
47 #endif
48 
50 {
51  if (tex == NULL) {
52  return;
53  }
54 
55  if (flags & DRW_TEX_MIPMAP) {
58  }
59  else {
61  }
63  GPU_texture_wrap_mode(tex, flags & DRW_TEX_WRAP, true);
65 }
66 
69  DRWTextureFlag flags,
70  const float *fpixels)
71 {
72  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
73  GPUTexture *tex = GPU_texture_create_1d(__func__, w, mip_len, format, fpixels);
75 
76  return tex;
77 }
78 
80  int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
81 {
82  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
83  GPUTexture *tex = GPU_texture_create_2d(__func__, w, h, mip_len, format, fpixels);
85 
86  return tex;
87 }
88 
90  int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
91 {
92  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
93  GPUTexture *tex = GPU_texture_create_2d_array(__func__, w, h, d, mip_len, format, fpixels);
95 
96  return tex;
97 }
98 
100  int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
101 {
102  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
104  __func__, w, h, d, mip_len, format, GPU_DATA_FLOAT, fpixels);
106 
107  return tex;
108 }
109 
112  DRWTextureFlag flags,
113  const float *fpixels)
114 {
115  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
116  GPUTexture *tex = GPU_texture_create_cube(__func__, w, mip_len, format, fpixels);
118  return tex;
119 }
120 
122  int w, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
123 {
124  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
125  GPUTexture *tex = GPU_texture_create_cube_array(__func__, w, d, mip_len, format, fpixels);
127  return tex;
128 }
129 
131  int h,
133  DrawEngineType *engine_type)
134 {
137 
138  return tex;
139 }
140 
142  DrawEngineType *engine_type)
143 {
144  const float *size = DRW_viewport_size_get();
145  return DRW_texture_pool_query_2d((int)size[0], (int)size[1], format, engine_type);
146 }
147 
150  DRWTextureFlag flags)
151 {
152  if (*(tex) == NULL) {
153  const float *size = DRW_viewport_size_get();
154  *(tex) = DRW_texture_create_2d((int)size[0], (int)size[1], format, flags, NULL);
155  }
156 }
157 
159  GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags)
160 {
161  if (*(tex) == NULL) {
162  *(tex) = DRW_texture_create_2d(w, h, format, flags, NULL);
163  }
164 }
165 
167 {
169 }
170 
172 {
174 }
#define BLI_assert(a)
Definition: BLI_assert.h:46
DRWTextureFlag
Definition: DRW_render.h:139
@ DRW_TEX_MIPMAP
Definition: DRW_render.h:143
@ DRW_TEX_WRAP
Definition: DRW_render.h:141
@ DRW_TEX_FILTER
Definition: DRW_render.h:140
@ DRW_TEX_COMPARE
Definition: DRW_render.h:142
GPUTexture * GPU_texture_create_2d_array(const char *name, int w, int h, int d, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:297
void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat, bool use_clamp)
Definition: gpu_texture.cc:546
GPUTexture * GPU_texture_create_1d(const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:278
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter)
Definition: gpu_texture.cc:527
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:171
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:564
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
Definition: gpu_texture.cc:518
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:291
void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare)
Definition: gpu_texture.cc:510
eGPUTextureFormat
Definition: GPU_texture.h:83
@ GPU_R16UI
Definition: GPU_texture.h:111
@ GPU_RG16F
Definition: GPU_texture.h:103
@ GPU_R16I
Definition: GPU_texture.h:112
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:120
@ GPU_RGB10_A2
Definition: GPU_texture.h:117
@ GPU_R16F
Definition: GPU_texture.h:113
@ GPU_RG16I
Definition: GPU_texture.h:102
@ GPU_RGBA32F
Definition: GPU_texture.h:90
@ GPU_RG8
Definition: GPU_texture.h:97
@ GPU_RG16
Definition: GPU_texture.h:104
@ GPU_R16
Definition: GPU_texture.h:114
@ GPU_R8UI
Definition: GPU_texture.h:105
@ GPU_RGBA16
Definition: GPU_texture.h:94
@ GPU_RG32F
Definition: GPU_texture.h:100
@ GPU_R8
Definition: GPU_texture.h:107
@ GPU_DEPTH_COMPONENT24
Definition: GPU_texture.h:166
@ GPU_R32UI
Definition: GPU_texture.h:108
@ 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
GPUTexture * GPU_texture_create_3d(const char *name, int w, int h, int d, int mip_len, eGPUTextureFormat texture_format, eGPUDataFormat data_format, const void *data)
Definition: gpu_texture.cc:309
void GPU_texture_anisotropic_filter(GPUTexture *tex, bool use_aniso)
Definition: gpu_texture.cc:537
GPUTexture * GPU_texture_create_cube(const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:322
GPUTexture * GPU_texture_create_cube_array(const char *name, int w, int d, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:329
void GPU_texture_generate_mipmap(GPUTexture *tex)
Definition: gpu_texture.cc:498
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
DRWManager DST
Definition: draw_manager.c:104
const float * DRW_viewport_size_get(void)
Definition: draw_manager.c:288
GPUTexture * DRW_texture_create_cube_array(int w, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
void DRW_texture_generate_mipmaps(GPUTexture *tex)
void drw_texture_set_parameters(GPUTexture *tex, DRWTextureFlag flags)
GPUTexture * DRW_texture_create_3d(int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
void DRW_texture_free(GPUTexture *tex)
void DRW_texture_ensure_fullscreen_2d(GPUTexture **tex, eGPUTextureFormat format, DRWTextureFlag flags)
GPUTexture * DRW_texture_create_cube(int w, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
static bool drw_texture_format_supports_framebuffer(eGPUTextureFormat format)
GPUTexture * DRW_texture_pool_query_fullscreen(eGPUTextureFormat format, DrawEngineType *engine_type)
GPUTexture * DRW_texture_create_2d_array(int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
void DRW_texture_ensure_2d(GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags)
GPUTexture * DRW_texture_create_2d(int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
GPUTexture * DRW_texture_pool_query_2d(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type)
GPUTexture * DRW_texture_create_1d(int w, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
GPUTexture * DRW_texture_pool_query(DRWTexturePool *pool, int width, int height, eGPUTextureFormat format, void *user)
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
format
Definition: logImageCore.h:38
struct DRWTexturePool * texture_pool
Definition: draw_manager.h:540
DRWData * vmempool
Definition: draw_manager.h:562