[Bf-blender-cvs] [0de303adec3] uvimage-editor-drawing: Moved batch creation to draw module
Jeroen Bakker
noreply at git.blender.org
Tue Aug 18 16:39:38 CEST 2020
Commit: 0de303adec3cbb892b14c43af96c70f0b9bbcde6
Author: Jeroen Bakker
Date: Tue Aug 18 16:24:46 2020 +0200
Branches: uvimage-editor-drawing
https://developer.blender.org/rB0de303adec3cbb892b14c43af96c70f0b9bbcde6
Moved batch creation to draw module
===================================================================
M source/blender/blenkernel/BKE_image.h
M source/blender/blenkernel/intern/image_gpu.c
M source/blender/draw/engines/image/image_batches.c
M source/blender/draw/engines/image/image_engine.c
M source/blender/draw/engines/image/image_private.h
M source/blender/draw/engines/overlay/overlay_edit_uv.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 87d0d7dba1e..f052ba400fc 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -382,8 +382,6 @@ struct GPUTexture *BKE_image_get_gpu_tiles(struct Image *image,
struct GPUTexture *BKE_image_get_gpu_tilemap(struct Image *image,
struct ImageUser *iuser,
struct ImBuf *ibuf);
-struct GPUBatch *BKE_image_tiled_gpu_batch_create(struct Image *image);
-struct GPUBatch *BKE_image_tiled_border_gpu_batch_create(struct Image *image);
void BKE_image_update_gputexture(
struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h);
diff --git a/source/blender/blenkernel/intern/image_gpu.c b/source/blender/blenkernel/intern/image_gpu.c
index ab14648a6b5..53d096a100f 100644
--- a/source/blender/blenkernel/intern/image_gpu.c
+++ b/source/blender/blenkernel/intern/image_gpu.c
@@ -402,119 +402,6 @@ void BKE_image_free_unused_gpu_textures()
/** \} */
-/* -------------------------------------------------------------------- */
-/** \name GPU batch creation
- * \{ */
-GPUBatch *BKE_image_tiled_gpu_batch_create(Image *image)
-{
- BLI_assert(image);
- BLI_assert(image->source == IMA_SRC_TILED);
-
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- }
-
- GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
-
- const int32_t num_tiles = BLI_listbase_count(&image->tiles);
- const int32_t num_verts = num_tiles * 4;
- const int32_t num_patches = num_tiles * 2;
-
- GPU_vertbuf_data_alloc(vbo, num_verts);
-
- float local_pos[3] = {0.0f, 0.0f, 0.0f};
- int vbo_index = 0;
-
- const int32_t num_tris = num_patches * 2;
- GPUIndexBufBuilder elb;
- GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, num_tris * 3, num_verts);
-
- LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) {
- const int min_x = ((tile->tile_number - 1001) % 10);
- const int min_y = ((tile->tile_number - 1001) / 10);
- const int max_x = min_x + 1;
- const int max_y = min_y + 1;
- local_pos[0] = min_x;
- local_pos[1] = min_y;
- GPU_vertbuf_vert_set(vbo, vbo_index, &local_pos);
- local_pos[0] = max_x;
- local_pos[1] = min_y;
- GPU_vertbuf_vert_set(vbo, vbo_index + 1, &local_pos);
- local_pos[0] = max_x;
- local_pos[1] = max_y;
- GPU_vertbuf_vert_set(vbo, vbo_index + 2, &local_pos);
- local_pos[0] = min_x;
- local_pos[1] = max_y;
- GPU_vertbuf_vert_set(vbo, vbo_index + 3, &local_pos);
-
- GPU_indexbuf_add_tri_verts(&elb, vbo_index, vbo_index + 1, vbo_index + 2);
- GPU_indexbuf_add_tri_verts(&elb, vbo_index + 2, vbo_index + 3, vbo_index);
-
- vbo_index += 4;
- }
-
- GPUBatch *batch = GPU_batch_create_ex(
- GPU_PRIM_TRIS, vbo, GPU_indexbuf_build(&elb), GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
- return batch;
-}
-
-GPUBatch *BKE_image_tiled_border_gpu_batch_create(Image *image)
-{
- BLI_assert(image);
- BLI_assert(image->source == IMA_SRC_TILED);
-
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- }
-
- GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
-
- const int32_t num_tiles = BLI_listbase_count(&image->tiles);
- const int32_t num_verts = num_tiles * 4;
- const int32_t num_lines = num_tiles * 4;
- const int32_t num_indexes = num_lines * 2;
-
- GPU_vertbuf_data_alloc(vbo, num_verts);
-
- float local_pos[3] = {0.0f, 0.0f, 0.0f};
- int vbo_index = 0;
-
- GPUIndexBufBuilder elb;
- GPU_indexbuf_init(&elb, GPU_PRIM_LINES, num_indexes, num_verts);
-
- LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) {
- const int min_x = ((tile->tile_number - 1001) % 10);
- const int min_y = ((tile->tile_number - 1001) / 10);
- const int max_x = min_x + 1;
- const int max_y = min_y + 1;
- local_pos[0] = min_x;
- local_pos[1] = min_y;
- GPU_vertbuf_vert_set(vbo, vbo_index, &local_pos);
- local_pos[0] = max_x;
- local_pos[1] = min_y;
- GPU_vertbuf_vert_set(vbo, vbo_index + 1, &local_pos);
- local_pos[0] = max_x;
- local_pos[1] = max_y;
- GPU_vertbuf_vert_set(vbo, vbo_index + 2, &local_pos);
- local_pos[0] = min_x;
- local_pos[1] = max_y;
- GPU_vertbuf_vert_set(vbo, vbo_index + 3, &local_pos);
-
- GPU_indexbuf_add_line_verts(&elb, vbo_index, vbo_index + 1);
- GPU_indexbuf_add_line_verts(&elb, vbo_index + 1, vbo_index + 2);
- GPU_indexbuf_add_line_verts(&elb, vbo_index + 2, vbo_index + 3);
- GPU_indexbuf_add_line_verts(&elb, vbo_index + 3, vbo_index);
-
- vbo_index += 4;
- }
-
- GPUBatch *batch = GPU_batch_create_ex(
- GPU_PRIM_LINES, vbo, GPU_indexbuf_build(&elb), GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
- return batch;
-}
-/** \} */
/* -------------------------------------------------------------------- */
/** \name Deletion
diff --git a/source/blender/draw/engines/image/image_batches.c b/source/blender/draw/engines/image/image_batches.c
index e68febdf6cb..8fc3a6e3f33 100644
--- a/source/blender/draw/engines/image/image_batches.c
+++ b/source/blender/draw/engines/image/image_batches.c
@@ -78,3 +78,57 @@ GPUBatch *IMAGE_batches_image_create(rcti *rect)
return batch;
}
+
+GPUBatch *IMAGE_batches_image_tiled_create(Image *image)
+{
+ BLI_assert(image);
+ BLI_assert(image->source == IMA_SRC_TILED);
+
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ }
+
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+
+ const int32_t num_tiles = BLI_listbase_count(&image->tiles);
+ const int32_t num_verts = num_tiles * 4;
+ const int32_t num_patches = num_tiles * 2;
+
+ GPU_vertbuf_data_alloc(vbo, num_verts);
+
+ float local_pos[3] = {0.0f, 0.0f, 0.0f};
+ int vbo_index = 0;
+
+ const int32_t num_tris = num_patches * 2;
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, num_tris * 3, num_verts);
+
+ LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) {
+ const int min_x = ((tile->tile_number - 1001) % 10);
+ const int min_y = ((tile->tile_number - 1001) / 10);
+ const int max_x = min_x + 1;
+ const int max_y = min_y + 1;
+ local_pos[0] = min_x;
+ local_pos[1] = min_y;
+ GPU_vertbuf_vert_set(vbo, vbo_index, &local_pos);
+ local_pos[0] = max_x;
+ local_pos[1] = min_y;
+ GPU_vertbuf_vert_set(vbo, vbo_index + 1, &local_pos);
+ local_pos[0] = max_x;
+ local_pos[1] = max_y;
+ GPU_vertbuf_vert_set(vbo, vbo_index + 2, &local_pos);
+ local_pos[0] = min_x;
+ local_pos[1] = max_y;
+ GPU_vertbuf_vert_set(vbo, vbo_index + 3, &local_pos);
+
+ GPU_indexbuf_add_tri_verts(&elb, vbo_index, vbo_index + 1, vbo_index + 2);
+ GPU_indexbuf_add_tri_verts(&elb, vbo_index + 2, vbo_index + 3, vbo_index);
+
+ vbo_index += 4;
+ }
+
+ GPUBatch *batch = GPU_batch_create_ex(
+ GPU_PRIM_TRIS, vbo, GPU_indexbuf_build(&elb), GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX);
+ return batch;
+}
\ No newline at end of file
diff --git a/source/blender/draw/engines/image/image_engine.c b/source/blender/draw/engines/image/image_engine.c
index 0b67d04ecb2..c9bec00c871 100644
--- a/source/blender/draw/engines/image/image_engine.c
+++ b/source/blender/draw/engines/image/image_engine.c
@@ -56,7 +56,7 @@ static void image_batch_instances_update(IMAGE_Data *id, Image *image)
rcti instances;
if (is_tiled_texture) {
- pd->draw_batch = BKE_image_tiled_gpu_batch_create(image);
+ pd->draw_batch = IMAGE_batches_image_tiled_create(image);
}
else {
/* repeat */
diff --git a/source/blender/draw/engines/image/image_private.h b/source/blender/draw/engines/image/image_private.h
index 1747bfe921a..c9bddbd4912 100644
--- a/source/blender/draw/engines/image/image_private.h
+++ b/source/blender/draw/engines/image/image_private.h
@@ -64,4 +64,5 @@ void IMAGE_shader_library_ensure(void);
void IMAGE_shaders_free(void);
/* image_batches.c */
-struct GPUBatch *IMAGE_batches_image_create(struct rcti *rect);
\ No newline at end of file
+struct GPUBatch *IMAGE_batches_image_create(struct rcti *rect);
+struct GPUBatch *IMAGE_batches_image_tiled_create(Image *image);
\ No newline at end of file
diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c b/source/blender/draw/engines/overlay/overlay_edit_uv.c
index 3698b35459c..54c512da60d 100644
--- a/source/blender/draw/engines/overlay/overlay_edit_uv.c
+++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c
@@ -65,6 +65,62 @@ static OVERLAY_UVLineStyle edit_uv_line_style_from_space_image(const SpaceImage
}
}
+GPUBatch *edit_uv_tiled_border_gpu_batch_create(Image *image)
+{
+ BLI_assert(image);
+ BLI_assert(image->source == IMA_SRC_TILED);
+
+ static GPUVertFormat format = {0};
+ if (format.attr_len == 0) {
+ GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ }
+
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
+
+ const int32_t num_tiles = BLI_listbase_count(&image->tiles);
+ const int32_t num_verts = num_tiles * 4;
+ const int32_t num_lines = num_tiles * 4;
+ const int32_t num_indexes = num_lines * 2;
+
+ GPU_vertbuf_data_alloc(vbo, num_verts);
+
+ float local_pos[3] = {0.0f, 0.0f, 0.0f};
+ int vbo_index = 0;
+
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES, num_indexes, num_verts);
+
+ LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) {
+ const int min_x = ((tile->tile_number - 1001) % 10);
+ const int min_y = ((tile->tile_number - 1001) / 10);
+ const int max_x = min_x + 1;
+ const int max_y = min_y + 1;
+ local_pos[0] = min_x;
+ local_pos[1] = min_y;
+ GPU_vertbuf_vert_set(vbo, vbo_index, &local_pos);
+ local_pos[0] = max_x;
+ local_pos[1] = min_y;
+ GPU_vertbuf_vert_set(vbo, vbo_index + 1, &local_pos);
+ local_pos[0] = max_x;
+ local_pos[1] = max_y;
+ GPU_vertbuf_vert_set(vbo, vbo_index + 2, &local_pos);
+ local_pos[0] = min_x;
+ local_pos[1] = max_y;
+ GPU_vertbuf_vert_set(
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list