diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-02 01:57:32 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-02 01:57:32 +0300 |
commit | f0118e9aca8266512c87c8a9310b52056138596c (patch) | |
tree | 7ec4c32ac166264bf7e9b559be3fbcbe72161b71 /source/blender | |
parent | 5e5e198bbef843e28bcb91662dc1facafe6e5238 (diff) |
GPUShader: Remove GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE
This had only one use and it was for debugging. Remove the shader for now.
This also simplifies the debug drawing even if slower.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/intern/draw_debug.c | 38 | ||||
-rw-r--r-- | source/blender/gpu/GPU_shader.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_builtin.c | 9 | ||||
-rw-r--r-- | source/blender/gpu/tests/gpu_shader_builtin_test.cc | 1 |
4 files changed, 10 insertions, 40 deletions
diff --git a/source/blender/draw/intern/draw_debug.c b/source/blender/draw/intern/draw_debug.c index ef085a135be..b568119627e 100644 --- a/source/blender/draw/intern/draw_debug.c +++ b/source/blender/draw/intern/draw_debug.c @@ -16,6 +16,7 @@ #include "BLI_link_utils.h" #include "GPU_immediate.h" +#include "GPU_matrix.h" #include "draw_debug.h" #include "draw_manager.h" @@ -164,42 +165,23 @@ static void drw_debug_draw_spheres(void) return; } - float one = 1.0f; - GPUVertFormat vert_format = {0}; - uint mat = GPU_vertformat_attr_add( - &vert_format, "InstanceModelMatrix", GPU_COMP_F32, 16, GPU_FETCH_FLOAT); - uint col = GPU_vertformat_attr_add(&vert_format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - uint siz = GPU_vertformat_attr_add(&vert_format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); - - GPUVertBuf *inst_vbo = GPU_vertbuf_create_with_format(&vert_format); - - GPU_vertbuf_data_alloc(inst_vbo, count); + float persmat[4][4]; + DRW_view_persmat_get(NULL, persmat, false); - int v = 0; + GPUBatch *empty_sphere = DRW_cache_empty_sphere_get(); + GPU_batch_program_set_builtin(empty_sphere, GPU_SHADER_3D_UNIFORM_COLOR); while (DST.debug.spheres) { void *next = DST.debug.spheres->next; + float MVP[4][4]; - GPU_vertbuf_attr_set(inst_vbo, mat, v, DST.debug.spheres->mat[0]); - GPU_vertbuf_attr_set(inst_vbo, col, v, DST.debug.spheres->color); - GPU_vertbuf_attr_set(inst_vbo, siz, v, &one); - v++; + mul_m4_m4m4(MVP, persmat, DST.debug.spheres->mat); + GPU_batch_uniform_mat4(empty_sphere, "ModelViewProjectionMatrix", MVP); + GPU_batch_uniform_4fv(empty_sphere, "color", DST.debug.spheres->color); + GPU_batch_draw(empty_sphere); MEM_freeN(DST.debug.spheres); DST.debug.spheres = next; } - - GPUBatch *empty_sphere = DRW_cache_empty_sphere_get(); - - GPUBatch *draw_batch = GPU_batch_create(GPU_PRIM_LINES, empty_sphere->verts[0], NULL); - GPU_batch_instbuf_set(draw_batch, inst_vbo, true); - GPU_batch_program_set_builtin(draw_batch, GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); - - float persmat[4][4]; - DRW_view_persmat_get(NULL, persmat, false); - GPU_batch_uniform_mat4(draw_batch, "ViewProjectionMatrix", persmat); - - GPU_batch_draw(draw_batch); - GPU_batch_discard(draw_batch); } void drw_debug_draw(void) diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 0e7ce0889c2..b620fe9cc9d 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -338,8 +338,6 @@ typedef enum eGPUBuiltinShader { /* lines */ GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR, GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR, - /* instance */ - GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, /* Uniformly scaled */ /* grease pencil drawing */ GPU_SHADER_GPENCIL_STROKE, /* specialized for widget drawing */ diff --git a/source/blender/gpu/intern/gpu_shader_builtin.c b/source/blender/gpu/intern/gpu_shader_builtin.c index 6ab077da413..f6e416e7c48 100644 --- a/source/blender/gpu/intern/gpu_shader_builtin.c +++ b/source/blender/gpu/intern/gpu_shader_builtin.c @@ -266,14 +266,6 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { .create_info = "gpu_shader_3D_point_uniform_size_uniform_color_aa", .clipped_create_info = "gpu_shader_3D_point_uniform_size_uniform_color_aa_clipped"}, - [GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE] = - { - .name = "GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE", - .vert = datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl, - .frag = datatoc_gpu_shader_flat_color_frag_glsl, - .defs = "#define UNIFORM_SCALE\n", - }, - [GPU_SHADER_2D_AREA_BORDERS] = {.name = "GPU_SHADER_2D_AREA_BORDERS", .create_info = "gpu_shader_2D_area_borders"}, [GPU_SHADER_2D_WIDGET_BASE] = {.name = "GPU_SHADER_2D_WIDGET_BASE", @@ -326,7 +318,6 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader, GPU_SHADER_3D_UNIFORM_COLOR, GPU_SHADER_3D_SMOOTH_COLOR, GPU_SHADER_3D_DEPTH_ONLY, - GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA, GPU_SHADER_3D_FLAT_COLOR, GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR)); diff --git a/source/blender/gpu/tests/gpu_shader_builtin_test.cc b/source/blender/gpu/tests/gpu_shader_builtin_test.cc index 7ff047418fc..6ef8a032a73 100644 --- a/source/blender/gpu/tests/gpu_shader_builtin_test.cc +++ b/source/blender/gpu/tests/gpu_shader_builtin_test.cc @@ -26,7 +26,6 @@ static void test_shader_builtin() test_compile_builtin_shader(GPU_SHADER_3D_SMOOTH_COLOR); test_compile_builtin_shader(GPU_SHADER_3D_DEPTH_ONLY); test_compile_builtin_shader(GPU_SHADER_3D_FLAT_COLOR); - test_compile_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); test_compile_builtin_shader(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); test_compile_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); |