Blender  V2.93
draw_manager_texture.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2016, Blender Foundation.
17  */
18 
23 #include "draw_manager.h"
24 
25 #ifndef NDEBUG
26 /* Maybe gpu_texture.c is a better place for this. */
28 {
29  /* Some formats do not work with frame-buffers. */
30  switch (format) {
31  /* Only add formats that are COMPATIBLE with FB.
32  * Generally they are multiple of 16bit. */
33  case GPU_R8:
34  case GPU_R8UI:
35  case GPU_R16F:
36  case GPU_R16I:
37  case GPU_R16UI:
38  case GPU_R16:
39  case GPU_R32F:
40  case GPU_R32UI:
41  case GPU_RG8:
42  case GPU_RG16:
43  case GPU_RG16F:
44  case GPU_RG16I:
45  case GPU_RG32F:
46  case GPU_RGB10_A2:
47  case GPU_R11F_G11F_B10F:
48  case GPU_RGBA8:
49  case GPU_RGBA16:
50  case GPU_RGBA16F:
51  case GPU_RGBA32F:
56  return true;
57  default:
58  return false;
59  }
60 }
61 #endif
62 
64 {
65  if (tex == NULL) {
66  return;
67  }
68 
69  if (flags & DRW_TEX_MIPMAP) {
72  }
73  else {
75  }
77  GPU_texture_wrap_mode(tex, flags & DRW_TEX_WRAP, true);
79 }
80 
83  DRWTextureFlag flags,
84  const float *fpixels)
85 {
86  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
87  GPUTexture *tex = GPU_texture_create_1d(__func__, w, mip_len, format, fpixels);
89 
90  return tex;
91 }
92 
94  int w, int h, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
95 {
96  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
97  GPUTexture *tex = GPU_texture_create_2d(__func__, w, h, mip_len, format, fpixels);
99 
100  return tex;
101 }
102 
104  int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
105 {
106  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
107  GPUTexture *tex = GPU_texture_create_2d_array(__func__, w, h, d, mip_len, format, fpixels);
109 
110  return tex;
111 }
112 
114  int w, int h, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
115 {
116  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
118  __func__, w, h, d, mip_len, format, GPU_DATA_FLOAT, fpixels);
120 
121  return tex;
122 }
123 
126  DRWTextureFlag flags,
127  const float *fpixels)
128 {
129  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
130  GPUTexture *tex = GPU_texture_create_cube(__func__, w, mip_len, format, fpixels);
132  return tex;
133 }
134 
136  int w, int d, eGPUTextureFormat format, DRWTextureFlag flags, const float *fpixels)
137 {
138  int mip_len = (flags & DRW_TEX_MIPMAP) ? 9999 : 1;
139  GPUTexture *tex = GPU_texture_create_cube_array(__func__, w, d, mip_len, format, fpixels);
141  return tex;
142 }
143 
145  int h,
147  DrawEngineType *engine_type)
148 {
151 
152  return tex;
153 }
154 
156  DrawEngineType *engine_type)
157 {
158  const float *size = DRW_viewport_size_get();
159  return DRW_texture_pool_query_2d((int)size[0], (int)size[1], format, engine_type);
160 }
161 
164  DRWTextureFlag flags)
165 {
166  if (*(tex) == NULL) {
167  const float *size = DRW_viewport_size_get();
168  *(tex) = DRW_texture_create_2d((int)size[0], (int)size[1], format, flags, NULL);
169  }
170 }
171 
173  GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags)
174 {
175  if (*(tex) == NULL) {
176  *(tex) = DRW_texture_create_2d(w, h, format, flags, NULL);
177  }
178 }
179 
181 {
183 }
184 
186 {
188 }
#define BLI_assert(a)
Definition: BLI_assert.h:58
DRWTextureFlag
Definition: DRW_render.h:138
@ DRW_TEX_MIPMAP
Definition: DRW_render.h:142
@ DRW_TEX_WRAP
Definition: DRW_render.h:140
@ DRW_TEX_FILTER
Definition: DRW_render.h:139
@ DRW_TEX_COMPARE
Definition: DRW_render.h:141
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:256
void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat, bool use_clamp)
Definition: gpu_texture.cc:496
GPUTexture * GPU_texture_create_1d(const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:237
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
void GPU_texture_mipmap_mode(GPUTexture *tex, bool use_mipmap, bool use_filter)
Definition: gpu_texture.cc:477
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:172
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:508
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
Definition: gpu_texture.cc:468
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:250
void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare)
Definition: gpu_texture.cc:460
eGPUTextureFormat
Definition: GPU_texture.h:84
@ GPU_R16UI
Definition: GPU_texture.h:112
@ GPU_RG16F
Definition: GPU_texture.h:104
@ GPU_R32F
Definition: GPU_texture.h:111
@ GPU_R16I
Definition: GPU_texture.h:113
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:121
@ GPU_RGB10_A2
Definition: GPU_texture.h:118
@ GPU_R16F
Definition: GPU_texture.h:114
@ GPU_RG16I
Definition: GPU_texture.h:103
@ GPU_RGBA32F
Definition: GPU_texture.h:91
@ GPU_RGBA16F
Definition: GPU_texture.h:94
@ GPU_RG8
Definition: GPU_texture.h:98
@ GPU_RG16
Definition: GPU_texture.h:105
@ GPU_R16
Definition: GPU_texture.h:115
@ GPU_R8UI
Definition: GPU_texture.h:106
@ GPU_RGBA16
Definition: GPU_texture.h:95
@ GPU_RG32F
Definition: GPU_texture.h:101
@ GPU_R8
Definition: GPU_texture.h:108
@ GPU_DEPTH_COMPONENT24
Definition: GPU_texture.h:167
@ GPU_R32UI
Definition: GPU_texture.h:109
@ GPU_DEPTH_COMPONENT32F
Definition: GPU_texture.h:166
@ GPU_DEPTH_COMPONENT16
Definition: GPU_texture.h:168
@ GPU_R11F_G11F_B10F
Definition: GPU_texture.h:119
@ GPU_RGBA8
Definition: GPU_texture.h:88
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:263
void GPU_texture_anisotropic_filter(GPUTexture *tex, bool use_aniso)
Definition: gpu_texture.cc:487
GPUTexture * GPU_texture_create_cube(const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:276
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:282
void GPU_texture_generate_mipmap(GPUTexture *tex)
Definition: gpu_texture.cc:447
GPUTexture * GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine, int width, int height, int format)
Definition: gpu_viewport.c:360
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:111
const float * DRW_viewport_size_get(void)
Definition: draw_manager.c:439
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)
format
Definition: logImageCore.h:47
GPUViewport * viewport
Definition: draw_manager.h:521