diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-05 18:33:56 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-05 18:49:14 +0300 |
commit | ab95cdaba970a30127d804bd1e66ad25ab021ec1 (patch) | |
tree | d0da883e11f81253cb7b3e5a75288ca69598e437 /source/blender/editors | |
parent | bac4606937514405641659d91a30bf3e6832cdf7 (diff) |
GPUTexture: Change texture creation API
This is to modernize the API:
- Add meaningful name to all textures (except DRW textures).
- Remove unused err_out argument: only used for offscreen python.
- Add mipmap count to creation functions for future changes.
- Clarify the data usage in creation functions.
This is a cleanup commit, there is no functional change.
# Conflicts:
# source/blender/gpu/GPU_texture.h
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 12 | ||||
-rw-r--r-- | source/blender/editors/screen/glutil.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_draw.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 3 |
5 files changed, 15 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 8801d2956bb..cadc2264bf4 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -866,16 +866,16 @@ void UI_icons_reload_internal_textures(void) icongltex.invw = 1.0f / b32buf->x; icongltex.invh = 1.0f / b32buf->y; - icongltex.tex[0] = GPU_texture_create_2d(b32buf->x, b32buf->y, GPU_RGBA8, NULL, NULL); - GPU_texture_add_mipmap(icongltex.tex[0], GPU_DATA_UNSIGNED_BYTE, 0, b32buf->rect); - GPU_texture_add_mipmap(icongltex.tex[0], GPU_DATA_UNSIGNED_BYTE, 1, b16buf->rect); + icongltex.tex[0] = GPU_texture_create_2d("icons", b32buf->x, b32buf->y, 2, GPU_RGBA8, NULL); + GPU_texture_update_mipmap(icongltex.tex[0], 0, GPU_DATA_UNSIGNED_BYTE, b32buf->rect); + GPU_texture_update_mipmap(icongltex.tex[0], 1, GPU_DATA_UNSIGNED_BYTE, b16buf->rect); } if (need_icons_with_border && icongltex.tex[1] == NULL) { icongltex.tex[1] = GPU_texture_create_2d( - b32buf_border->x, b32buf_border->y, GPU_RGBA8, NULL, NULL); - GPU_texture_add_mipmap(icongltex.tex[1], GPU_DATA_UNSIGNED_BYTE, 0, b32buf_border->rect); - GPU_texture_add_mipmap(icongltex.tex[1], GPU_DATA_UNSIGNED_BYTE, 1, b16buf_border->rect); + "icons_border", b32buf_border->x, b32buf_border->y, 2, GPU_RGBA8, NULL); + GPU_texture_update_mipmap(icongltex.tex[1], 0, GPU_DATA_UNSIGNED_BYTE, b32buf_border->rect); + GPU_texture_update_mipmap(icongltex.tex[1], 1, GPU_DATA_UNSIGNED_BYTE, b16buf_border->rect); } } diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index bcbb735d93d..33b918e6d4d 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -132,7 +132,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, eGPUDataFormat gpu_data = (use_float_data) ? GPU_DATA_FLOAT : GPU_DATA_UNSIGNED_BYTE; size_t stride = components * ((use_float_data) ? sizeof(float) : sizeof(uchar)); - GPUTexture *tex = GPU_texture_create_2d(tex_w, tex_h, gpu_format, NULL, NULL); + GPUTexture *tex = GPU_texture_create_2d("immDrawPixels", tex_w, tex_h, 1, gpu_format, NULL); GPU_texture_filter_mode(tex, use_filter); GPU_texture_wrap_mode(tex, false, true); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 4d885364440..08733a26187 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -348,7 +348,8 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima if (!target->overlay_texture) { eGPUTextureFormat format = col ? GPU_RGBA8 : GPU_R8; - target->overlay_texture = GPU_texture_create_2d(size, size, format, NULL, NULL); + target->overlay_texture = GPU_texture_create_2d( + "paint_cursor_overlay", size, size, 1, format, NULL); GPU_texture_update(target->overlay_texture, GPU_DATA_UNSIGNED_BYTE, buffer); if (!col) { @@ -466,7 +467,8 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) BLI_task_parallel_range(0, size, &data, load_tex_cursor_task_cb, &settings); if (!cursor_snap.overlay_texture) { - cursor_snap.overlay_texture = GPU_texture_create_2d(size, size, GPU_R8, NULL, NULL); + cursor_snap.overlay_texture = GPU_texture_create_2d( + "cursor_snap_overaly", size, size, 1, GPU_R8, NULL); GPU_texture_update(cursor_snap.overlay_texture, GPU_DATA_UNSIGNED_BYTE, buffer); GPU_texture_swizzle_set(cursor_snap.overlay_texture, "rrrr"); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 8fbf9fa2144..e12e4eb2231 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1211,7 +1211,8 @@ static void draw_plane_marker_image(Scene *scene, GPU_blend(GPU_BLEND_ALPHA); } - GPUTexture *texture = GPU_texture_create_2d(ibuf->x, ibuf->y, GPU_RGBA8, NULL, NULL); + GPUTexture *texture = GPU_texture_create_2d( + "plane_marker_image", ibuf->x, ibuf->y, 1, GPU_RGBA8, NULL); GPU_texture_update(texture, GPU_DATA_UNSIGNED_BYTE, display_buffer); GPU_texture_filter_mode(texture, false); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 9504ed88bb1..70735a8ec82 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1639,7 +1639,8 @@ static void sequencer_draw_display_buffer(const bContext *C, GPU_matrix_identity_projection_set(); } - GPUTexture *texture = GPU_texture_create_2d(ibuf->x, ibuf->y, format, NULL, NULL); + GPUTexture *texture = GPU_texture_create_2d( + "seq_display_buf", ibuf->x, ibuf->y, 1, format, NULL); GPU_texture_update(texture, data, display_buffer); GPU_texture_filter_mode(texture, false); |