From 8cd7828792419fb4eac9a2a477968535b4c71535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 18 Jul 2018 00:12:21 +0200 Subject: GWN: Port to GPU module: Replace GWN prefix by GPU --- build_files/cmake/macros.cmake | 2 +- intern/opencolorio/ocio_impl_glsl.cc | 14 +- release/scripts/modules/bpy_types.py | 16 +- source/blender/blenfont/intern/blf_font.c | 40 +- source/blender/blenfont/intern/blf_glyph.c | 6 +- .../blender/blenfont/intern/blf_internal_types.h | 6 +- source/blender/blenkernel/BKE_animsys.h | 2 +- source/blender/blenkernel/BKE_pbvh.h | 4 +- source/blender/blenkernel/intern/anim.c | 12 +- source/blender/blenkernel/intern/cloth.c | 4 +- source/blender/blenkernel/intern/pbvh.c | 6 +- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/draw/DRW_engine.h | 4 +- source/blender/draw/engines/basic/basic_engine.c | 4 +- source/blender/draw/engines/eevee/eevee_bloom.c | 2 +- .../draw/engines/eevee/eevee_depth_of_field.c | 2 +- source/blender/draw/engines/eevee/eevee_effects.c | 2 +- .../blender/draw/engines/eevee/eevee_lightcache.c | 26 +- .../blender/draw/engines/eevee/eevee_lightprobes.c | 12 +- source/blender/draw/engines/eevee/eevee_lights.c | 4 +- source/blender/draw/engines/eevee/eevee_lookdev.c | 2 +- .../blender/draw/engines/eevee/eevee_materials.c | 10 +- .../blender/draw/engines/eevee/eevee_motion_blur.c | 2 +- .../blender/draw/engines/eevee/eevee_occlusion.c | 2 +- source/blender/draw/engines/eevee/eevee_private.h | 4 +- .../draw/engines/eevee/eevee_screen_raytrace.c | 2 +- .../blender/draw/engines/eevee/eevee_subsurface.c | 2 +- .../draw/engines/external/external_engine.c | 2 +- .../draw/engines/workbench/workbench_deferred.c | 8 +- .../draw/engines/workbench/workbench_forward.c | 6 +- source/blender/draw/intern/DRW_render.h | 30 +- source/blender/draw/intern/draw_anim_viz.c | 26 +- source/blender/draw/intern/draw_armature.c | 16 +- source/blender/draw/intern/draw_cache.c | 1546 ++++++++++---------- source/blender/draw/intern/draw_cache.h | 209 ++- source/blender/draw/intern/draw_cache_impl.h | 104 +- source/blender/draw/intern/draw_cache_impl_curve.c | 260 ++-- .../blender/draw/intern/draw_cache_impl_displist.c | 98 +- .../blender/draw/intern/draw_cache_impl_lattice.c | 86 +- source/blender/draw/intern/draw_cache_impl_mesh.c | 1160 +++++++-------- .../blender/draw/intern/draw_cache_impl_metaball.c | 20 +- .../draw/intern/draw_cache_impl_particles.c | 304 ++-- source/blender/draw/intern/draw_common.c | 64 +- source/blender/draw/intern/draw_common.h | 30 +- source/blender/draw/intern/draw_debug.c | 38 +- source/blender/draw/intern/draw_hair_private.h | 18 +- source/blender/draw/intern/draw_instance_data.c | 68 +- source/blender/draw/intern/draw_instance_data.h | 8 +- source/blender/draw/intern/draw_manager.c | 76 +- source/blender/draw/intern/draw_manager.h | 24 +- source/blender/draw/intern/draw_manager_data.c | 126 +- source/blender/draw/intern/draw_manager_exec.c | 18 +- .../blender/draw/intern/draw_manager_profiling.c | 2 +- source/blender/draw/intern/draw_view.c | 44 +- source/blender/draw/modes/edit_curve_mode.c | 2 +- source/blender/draw/modes/edit_lattice_mode.c | 2 +- source/blender/draw/modes/edit_mesh_mode.c | 8 +- source/blender/draw/modes/edit_surface_mode.c | 2 +- source/blender/draw/modes/edit_text_mode.c | 2 +- source/blender/draw/modes/object_mode.c | 38 +- source/blender/draw/modes/overlay_mode.c | 2 +- source/blender/draw/modes/paint_texture_mode.c | 10 +- source/blender/draw/modes/paint_vertex_mode.c | 2 +- source/blender/draw/modes/paint_weight_mode.c | 2 +- source/blender/draw/modes/particle_mode.c | 6 +- source/blender/draw/modes/pose_mode.c | 2 +- .../editors/animation/anim_channels_defines.c | 12 +- source/blender/editors/animation/anim_draw.c | 16 +- source/blender/editors/animation/anim_markers.c | 8 +- source/blender/editors/animation/keyframes_draw.c | 20 +- source/blender/editors/curve/editcurve_paint.c | 16 +- .../editors/gizmo_library/gizmo_draw_utils.c | 34 +- .../gizmo_library/gizmo_types/arrow2d_gizmo.c | 6 +- .../gizmo_library/gizmo_types/arrow3d_gizmo.c | 8 +- .../gizmo_library/gizmo_types/button2d_gizmo.c | 18 +- .../gizmo_library/gizmo_types/cage2d_gizmo.c | 76 +- .../gizmo_library/gizmo_types/cage3d_gizmo.c | 12 +- .../gizmo_library/gizmo_types/dial3d_gizmo.c | 12 +- .../gizmo_library/gizmo_types/grab3d_gizmo.c | 6 +- .../gizmo_library/gizmo_types/primitive3d_gizmo.c | 6 +- source/blender/editors/gpencil/drawgpencil.c | 92 +- source/blender/editors/gpencil/gpencil_brush.c | 4 +- source/blender/editors/gpencil/gpencil_paint.c | 4 +- source/blender/editors/include/ED_keyframes_draw.h | 2 +- source/blender/editors/interface/interface_draw.c | 238 +-- source/blender/editors/interface/interface_icons.c | 26 +- .../editors/interface/interface_icons_event.c | 6 +- .../blender/editors/interface/interface_intern.h | 6 +- source/blender/editors/interface/interface_panel.c | 36 +- .../blender/editors/interface/interface_widgets.c | 168 +-- source/blender/editors/interface/view2d.c | 24 +- source/blender/editors/mask/mask_draw.c | 32 +- source/blender/editors/mesh/editmesh_knife.c | 26 +- source/blender/editors/mesh/editmesh_loopcut.c | 6 +- source/blender/editors/physics/particle_edit.c | 2 +- source/blender/editors/screen/area.c | 50 +- source/blender/editors/screen/glutil.c | 16 +- source/blender/editors/screen/screen_draw.c | 30 +- source/blender/editors/sculpt_paint/paint_cursor.c | 34 +- source/blender/editors/sculpt_paint/paint_image.c | 8 +- source/blender/editors/sculpt_paint/paint_stroke.c | 8 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 2 +- source/blender/editors/space_action/action_draw.c | 10 +- .../editors/space_clip/clip_dopesheet_draw.c | 18 +- source/blender/editors/space_clip/clip_draw.c | 74 +- .../blender/editors/space_clip/clip_graph_draw.c | 12 +- source/blender/editors/space_clip/clip_utils.c | 4 +- .../blender/editors/space_console/console_draw.c | 4 +- source/blender/editors/space_file/file_draw.c | 14 +- source/blender/editors/space_graph/graph_draw.c | 46 +- source/blender/editors/space_graph/space_graph.c | 6 +- source/blender/editors/space_image/image_draw.c | 16 +- source/blender/editors/space_info/textview.c | 12 +- source/blender/editors/space_nla/nla_draw.c | 38 +- source/blender/editors/space_node/drawnode.c | 124 +- source/blender/editors/space_node/node_draw.c | 22 +- .../blender/editors/space_outliner/outliner_draw.c | 42 +- .../editors/space_sequencer/sequencer_draw.c | 40 +- source/blender/editors/space_text/text_draw.c | 22 +- source/blender/editors/space_view3d/drawobject.c | 98 +- source/blender/editors/space_view3d/view3d_draw.c | 32 +- source/blender/editors/space_view3d/view3d_fly.c | 6 +- .../space_view3d/view3d_gizmo_navigate_type.c | 20 +- .../editors/space_view3d/view3d_gizmo_ruler.c | 14 +- .../blender/editors/space_view3d/view3d_intern.h | 2 +- source/blender/editors/space_view3d/view3d_ruler.c | 14 +- source/blender/editors/space_view3d/view3d_walk.c | 6 +- source/blender/editors/transform/transform.c | 32 +- .../editors/transform/transform_constraints.c | 6 +- .../blender/editors/transform/transform_generics.c | 4 +- source/blender/editors/transform/transform_snap.c | 6 +- source/blender/editors/util/ed_util.c | 4 +- source/blender/editors/uvedit/uvedit_draw.c | 124 +- .../blender/editors/uvedit/uvedit_smart_stitch.c | 88 +- source/blender/gpu/CMakeLists.txt | 2 +- source/blender/gpu/GPU_attr_binding.h | 14 +- source/blender/gpu/GPU_batch.h | 158 +- source/blender/gpu/GPU_batch_presets.h | 12 +- source/blender/gpu/GPU_batch_utils.h | 6 +- source/blender/gpu/GPU_buffer_id.h | 14 +- source/blender/gpu/GPU_buffers.h | 2 +- source/blender/gpu/GPU_common.h | 14 +- source/blender/gpu/GPU_context.h | 20 +- source/blender/gpu/GPU_element.h | 68 +- source/blender/gpu/GPU_immediate.h | 14 +- source/blender/gpu/GPU_immediate_util.h | 4 +- source/blender/gpu/GPU_matrix.h | 4 +- source/blender/gpu/GPU_primitive.h | 50 +- source/blender/gpu/GPU_shader_interface.h | 96 +- source/blender/gpu/GPU_texture.h | 4 +- source/blender/gpu/GPU_vertex_array_id.h | 14 +- source/blender/gpu/GPU_vertex_buffer.h | 88 +- source/blender/gpu/GPU_vertex_format.h | 86 +- source/blender/gpu/intern/gpu_attr_binding.c | 26 +- .../blender/gpu/intern/gpu_attr_binding_private.h | 16 +- source/blender/gpu/intern/gpu_batch.c | 240 +-- source/blender/gpu/intern/gpu_batch_presets.c | 76 +- source/blender/gpu/intern/gpu_batch_private.h | 16 +- source/blender/gpu/intern/gpu_batch_utils.c | 54 +- source/blender/gpu/intern/gpu_buffer_id.cpp | 8 +- source/blender/gpu/intern/gpu_buffers.c | 154 +- source/blender/gpu/intern/gpu_codegen.c | 2 +- source/blender/gpu/intern/gpu_element.c | 120 +- source/blender/gpu/intern/gpu_immediate.c | 170 +-- source/blender/gpu/intern/gpu_immediate_util.c | 50 +- source/blender/gpu/intern/gpu_matrix.c | 14 +- source/blender/gpu/intern/gpu_primitive.c | 60 +- source/blender/gpu/intern/gpu_primitive_private.h | 12 +- source/blender/gpu/intern/gpu_shader.c | 20 +- source/blender/gpu/intern/gpu_shader_interface.c | 154 +- source/blender/gpu/intern/gpu_shader_private.h | 2 +- source/blender/gpu/intern/gpu_texture.c | 20 +- source/blender/gpu/intern/gpu_vertex_array_id.cpp | 40 +- source/blender/gpu/intern/gpu_vertex_buffer.c | 98 +- source/blender/gpu/intern/gpu_vertex_format.c | 96 +- .../blender/gpu/intern/gpu_vertex_format_private.h | 14 +- source/blender/gpu/intern/gpu_viewport.c | 4 +- source/blender/makesdna/DNA_action_types.h | 6 +- source/blender/makesdna/DNA_windowmanager_types.h | 2 +- source/blender/python/CMakeLists.txt | 2 +- source/blender/python/gawain/CMakeLists.txt | 47 - source/blender/python/gawain/gwn_py_api.c | 63 - source/blender/python/gawain/gwn_py_api.h | 30 - source/blender/python/gawain/gwn_py_types.c | 847 ----------- source/blender/python/gawain/gwn_py_types.h | 67 - source/blender/python/gpu/CMakeLists.txt | 46 + source/blender/python/gpu/gpu_py_api.c | 63 + source/blender/python/gpu/gpu_py_api.h | 30 + source/blender/python/gpu/gpu_py_types.c | 847 +++++++++++ source/blender/python/gpu/gpu_py_types.h | 67 + source/blender/python/intern/bpy_interface.c | 4 +- source/blender/render/extern/include/RE_pipeline.h | 2 +- .../blender/render/intern/include/render_types.h | 2 +- source/blender/render/intern/source/pipeline.c | 16 +- source/blender/windowmanager/intern/wm_draw.c | 4 +- source/blender/windowmanager/intern/wm_files.c | 4 +- source/blender/windowmanager/intern/wm_gesture.c | 18 +- source/blender/windowmanager/intern/wm_operators.c | 16 +- source/blender/windowmanager/intern/wm_playanim.c | 16 +- source/blender/windowmanager/intern/wm_stereo.c | 24 +- source/blender/windowmanager/intern/wm_window.c | 12 +- 201 files changed, 5517 insertions(+), 5547 deletions(-) delete mode 100644 source/blender/python/gawain/CMakeLists.txt delete mode 100644 source/blender/python/gawain/gwn_py_api.c delete mode 100644 source/blender/python/gawain/gwn_py_api.h delete mode 100644 source/blender/python/gawain/gwn_py_types.c delete mode 100644 source/blender/python/gawain/gwn_py_types.h create mode 100644 source/blender/python/gpu/CMakeLists.txt create mode 100644 source/blender/python/gpu/gpu_py_api.c create mode 100644 source/blender/python/gpu/gpu_py_api.h create mode 100644 source/blender/python/gpu/gpu_py_types.c create mode 100644 source/blender/python/gpu/gpu_py_types.h diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index b2ec8f6e7a9..0ceaee08e64 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -621,7 +621,7 @@ function(SETUP_BLENDER_SORTED_LIBS) bf_python bf_python_ext bf_python_mathutils - bf_python_gawain + bf_python_gpu bf_python_bmesh bf_freestyle bf_ikplugin diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc index 10acdb9d281..78c73a6e3bf 100644 --- a/intern/opencolorio/ocio_impl_glsl.cc +++ b/intern/opencolorio/ocio_impl_glsl.cc @@ -98,7 +98,7 @@ typedef struct OCIO_GLSLShader { GLuint ocio_shader; GLuint vert_shader; GLuint program; - Gwn_ShaderInterface *shader_interface; + GPUShaderInterface *shader_interface; } GLSLDrawState; typedef struct OCIO_GLSLDrawState { @@ -251,7 +251,7 @@ static void freeGLSLShader(OCIO_GLSLShader *shader) } if (shader->shader_interface) { - GWN_shaderinterface_discard(shader->shader_interface); + GPU_shaderinterface_discard(shader->shader_interface); } if (shader->ocio_shader) { @@ -424,9 +424,9 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc if (shader->program) { if (shader->shader_interface) { - GWN_shaderinterface_discard(shader->shader_interface); + GPU_shaderinterface_discard(shader->shader_interface); } - shader->shader_interface = GWN_shaderinterface_create(shader->program); + shader->shader_interface = GPU_shaderinterface_create(shader->program); } } } @@ -461,9 +461,9 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc * * TODO(sergey): Look into some nicer solution. */ - Gwn_VertFormat *format = immVertexFormat(); - GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindProgram(shader->program, shader->shader_interface); immUniform1i("image_texture", 0); diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index f4fd188c641..d6d4ecd6fce 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -587,7 +587,7 @@ class Gizmo(StructRNA): _rna_gizmo_target_get_range as target_get_range, ) - # Convenience wrappers around private `_gawain` module. + # Convenience wrappers around private `_gpu` module. def draw_custom_shape(self, shape, *, matrix=None, select_id=None): """ Draw a shape created form :class:`bpy.types.Gizmo.draw_custom_shape`. @@ -638,19 +638,19 @@ class Gizmo(StructRNA): :return: The newly created shape. :rtype: Undefined (it may change). """ - from _gawain.types import ( - Gwn_Batch, - Gwn_VertBuf, - Gwn_VertFormat, + from _gpu.types import ( + GPUBatch, + GPUVertBuf, + GPUVertFormat, ) dims = len(verts[0]) if dims not in {2, 3}: raise ValueError("Expected 2D or 3D vertex") - fmt = Gwn_VertFormat() + fmt = GPUVertFormat() pos_id = fmt.attr_add(id="pos", comp_type='F32', len=dims, fetch_mode='FLOAT') - vbo = Gwn_VertBuf(len=len(verts), format=fmt) + vbo = GPUVertBuf(len=len(verts), format=fmt) vbo.fill(id=pos_id, data=verts) - batch = Gwn_Batch(type=type, buf=vbo) + batch = GPUBatch(type=type, buf=vbo) return (batch, dims) diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3f4c430ee4b..ea81106e60f 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -91,31 +91,31 @@ static SpinLock ft_lib_mutex; **/ static void blf_batch_draw_init(void) { - Gwn_VertFormat format = {0}; - g_batch.pos_loc = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - g_batch.tex_loc = GWN_vertformat_attr_add(&format, "tex", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - g_batch.col_loc = GWN_vertformat_attr_add(&format, "col", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat format = {0}; + g_batch.pos_loc = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + g_batch.tex_loc = GPU_vertformat_attr_add(&format, "tex", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + g_batch.col_loc = GPU_vertformat_attr_add(&format, "col", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); - g_batch.verts = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STREAM); - GWN_vertbuf_data_alloc(g_batch.verts, BLF_BATCH_DRAW_LEN_MAX); + g_batch.verts = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STREAM); + GPU_vertbuf_data_alloc(g_batch.verts, BLF_BATCH_DRAW_LEN_MAX); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step); g_batch.glyph_len = 0; - g_batch.batch = GWN_batch_create_ex(GWN_PRIM_POINTS, g_batch.verts, NULL, GWN_BATCH_OWNS_VBO); + g_batch.batch = GPU_batch_create_ex(GPU_PRIM_POINTS, g_batch.verts, NULL, GPU_BATCH_OWNS_VBO); } static void blf_batch_draw_exit(void) { - GWN_BATCH_DISCARD_SAFE(g_batch.batch); + GPU_BATCH_DISCARD_SAFE(g_batch.batch); } void blf_batch_draw_vao_clear(void) { if (g_batch.batch) { - gwn_batch_vao_cache_clear(g_batch.batch); + GPU_batch_vao_cache_clear(g_batch.batch); } } @@ -190,20 +190,20 @@ void blf_batch_draw(void) UI_widgetbase_draw_cache_flush(); GPU_texture_bind(g_batch.tex_bind_state, 0); - GWN_vertbuf_vertex_count_set(g_batch.verts, g_batch.glyph_len); - GWN_vertbuf_use(g_batch.verts); /* send data */ + GPU_vertbuf_vertex_count_set(g_batch.verts, g_batch.glyph_len); + GPU_vertbuf_use(g_batch.verts); /* send data */ GPUBuiltinShader shader = (g_batch.simple_shader) ? GPU_SHADER_TEXT_SIMPLE : GPU_SHADER_TEXT; - GWN_batch_program_set_builtin(g_batch.batch, shader); - GWN_batch_uniform_1i(g_batch.batch, "glyph", 0); - GWN_batch_draw(g_batch.batch); + GPU_batch_program_set_builtin(g_batch.batch, shader); + GPU_batch_uniform_1i(g_batch.batch, "glyph", 0); + GPU_batch_draw(g_batch.batch); GPU_blend(false); /* restart to 1st vertex data pointers */ - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step); - GWN_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.pos_loc, &g_batch.pos_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.tex_loc, &g_batch.tex_step); + GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.col_loc, &g_batch.col_step); g_batch.glyph_len = 0; } diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 8dc11443124..30e31bb2580 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -382,10 +382,10 @@ static void blf_texture_draw(const unsigned char color[4], const float uv[2][2], { /* Only one vertex per glyph, geometry shader expand it into a quad. */ /* TODO Get rid of Geom Shader because it's not optimal AT ALL for the GPU */ - copy_v4_fl4(GWN_vertbuf_raw_step(&g_batch.pos_step), x1 + g_batch.ofs[0], y1 + g_batch.ofs[1], + copy_v4_fl4(GPU_vertbuf_raw_step(&g_batch.pos_step), x1 + g_batch.ofs[0], y1 + g_batch.ofs[1], x2 + g_batch.ofs[0], y2 + g_batch.ofs[1]); - copy_v4_v4(GWN_vertbuf_raw_step(&g_batch.tex_step), (float *)uv); - copy_v4_v4_uchar(GWN_vertbuf_raw_step(&g_batch.col_step), color); + copy_v4_v4(GPU_vertbuf_raw_step(&g_batch.tex_step), (float *)uv); + copy_v4_v4_uchar(GPU_vertbuf_raw_step(&g_batch.col_step), color); g_batch.glyph_len++; /* Flush cache if it's full. */ if (g_batch.glyph_len == BLF_BATCH_DRAW_LEN_MAX) { diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 03bf7fa67d8..265835f4c75 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -38,9 +38,9 @@ typedef struct BatchBLF { struct FontBLF *font; /* can only batch glyph from the same font */ - struct Gwn_Batch *batch; - struct Gwn_VertBuf *verts; - struct Gwn_VertBufRaw pos_step, tex_step, col_step; + struct GPUBatch *batch; + struct GPUVertBuf *verts; + struct GPUVertBufRaw pos_step, tex_step, col_step; unsigned int pos_loc, tex_loc, col_loc; unsigned int glyph_len; float ofs[2]; /* copy of font->pos */ diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index b16e8c17a12..9e8e7f7b724 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -153,7 +153,7 @@ char *BKE_animdata_driver_path_hack(struct bContext *C, struct PointerRNA *ptr, char *base_path); /* ************************************* */ -/* Gwn_Batch AnimData API */ +/* GPUBatch AnimData API */ /* Define for callback looper used in BKE_animdata_main_cb */ typedef void (*ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data); diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 78c766f6115..095f442ca50 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -30,7 +30,7 @@ #include "BLI_ghash.h" #include "BLI_utildefines.h" -struct Gwn_Batch; +struct GPUBatch; struct CCGElem; struct CCGKey; struct CCGDerivedMesh; @@ -131,7 +131,7 @@ bool BKE_pbvh_node_find_nearest_to_ray( void BKE_pbvh_draw_cb( PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, - void (*draw_fn)(void *user_data, struct Gwn_Batch *batch), void *user_data); + void (*draw_fn)(void *user_data, struct GPUBatch *batch), void *user_data); /* PBVH Access */ typedef enum { diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 07b8b69bc70..eed8943cd5b 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -114,9 +114,9 @@ void animviz_free_motionpath_cache(bMotionPath *mpath) if (mpath->points) MEM_freeN(mpath->points); - GWN_VERTBUF_DISCARD_SAFE(mpath->points_vbo); - GWN_BATCH_DISCARD_SAFE(mpath->batch_line); - GWN_BATCH_DISCARD_SAFE(mpath->batch_points); + GPU_VERTBUF_DISCARD_SAFE(mpath->points_vbo); + GPU_BATCH_DISCARD_SAFE(mpath->batch_line); + GPU_BATCH_DISCARD_SAFE(mpath->batch_points); /* reset the relevant parameters */ mpath->points = NULL; @@ -495,9 +495,9 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) BLI_dlrbTree_free(&mpt->keys); /* Free previous batches to force update. */ - GWN_VERTBUF_DISCARD_SAFE(mpath->points_vbo); - GWN_BATCH_DISCARD_SAFE(mpath->batch_line); - GWN_BATCH_DISCARD_SAFE(mpath->batch_points); + GPU_VERTBUF_DISCARD_SAFE(mpath->points_vbo); + GPU_BATCH_DISCARD_SAFE(mpath->batch_line); + GPU_BATCH_DISCARD_SAFE(mpath->batch_points); } } diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index ccef747a31c..caf5b94b30e 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -924,7 +924,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, Mesh *mesh ) } /*************************************************************************************** - * SPRING NETWORK GWN_BATCH_BUILDING IMPLEMENTATION BEGIN + * SPRING NETWORK GPU_BATCH_BUILDING IMPLEMENTATION BEGIN ***************************************************************************************/ BLI_INLINE void spring_verts_ordered_set(ClothSpring *spring, int v0, int v1) @@ -1506,5 +1506,5 @@ static int cloth_build_springs ( ClothModifierData *clmd, Mesh *mesh ) } /* cloth_build_springs */ /*************************************************************************************** - * SPRING NETWORK GWN_BATCH_BUILDING IMPLEMENTATION END + * SPRING NETWORK GPU_BATCH_BUILDING IMPLEMENTATION END ***************************************************************************************/ diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 0a4cd3ec3c1..3e7a9b7ce24 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2077,7 +2077,7 @@ static void pbvh_node_check_mask_changed(PBVH *bvh, PBVHNode *node) struct PBVHNodeDrawCallbackData { - void (*draw_fn)(void *user_data, Gwn_Batch *batch); + void (*draw_fn)(void *user_data, GPUBatch *batch); void *user_data; bool fast; }; @@ -2087,7 +2087,7 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) struct PBVHNodeDrawCallbackData *data = data_v; if (!(node->flag & PBVH_FullyHidden)) { - Gwn_Batch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast); + GPUBatch *triangles = GPU_pbvh_buffers_batch_get(node->draw_buffers, data->fast); if (triangles != NULL) { data->draw_fn(data->user_data, triangles); } @@ -2099,7 +2099,7 @@ static void pbvh_node_draw_cb(PBVHNode *node, void *data_v) */ void BKE_pbvh_draw_cb( PBVH *bvh, float (*planes)[4], float (*fnors)[3], bool fast, - void (*draw_fn)(void *user_data, Gwn_Batch *batch), void *user_data) + void (*draw_fn)(void *user_data, GPUBatch *batch), void *user_data) { struct PBVHNodeDrawCallbackData draw_data = { .fast = fast, diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 18a6198254e..ab94b5334bd 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7018,7 +7018,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) direct_link_area_map(fd, &win->global_areas); win->ghostwin = NULL; - win->gwnctx = NULL; + win->gpuctx = NULL; win->eventstate = NULL; win->cursor_keymap_status = NULL; win->tweak = NULL; diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index ab2001dcb6a..eb037d081e1 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -138,8 +138,8 @@ void DRW_opengl_context_disable(void); void DRW_opengl_render_context_enable(void *re_gl_context); void DRW_opengl_render_context_disable(void *re_gl_context); -void DRW_gawain_render_context_enable(void *re_gwn_context); -void DRW_gawain_render_context_disable(void *re_gwn_context); +void DRW_gawain_render_context_enable(void *re_gpu_context); +void DRW_gawain_render_context_disable(void *re_gpu_context); void DRW_deferred_shader_remove(struct GPUMaterial *mat); diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 5a315cde2b5..a9c758d5b6f 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -160,13 +160,13 @@ static void basic_cache_populate(void *vedata, Object *ob) ParticleSettings *part = psys->part; const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as; if (draw_as == PART_DRAW_PATH) { - struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL); + struct GPUBatch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL); DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL); } } } - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { bool do_cull = false; /* TODO (we probably wan't to take this from the viewport?) */ #ifdef USE_DEPTH diff --git a/source/blender/draw/engines/eevee/eevee_bloom.c b/source/blender/draw/engines/eevee/eevee_bloom.c index 2ec6f841409..d111c28b256 100644 --- a/source/blender/draw/engines/eevee/eevee_bloom.c +++ b/source/blender/draw/engines/eevee/eevee_bloom.c @@ -196,7 +196,7 @@ int EEVEE_bloom_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata) static DRWShadingGroup *eevee_create_bloom_pass( const char *name, EEVEE_EffectsInfo *effects, struct GPUShader *sh, DRWPass **pass, bool upsample) { - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); *pass = DRW_pass_create(name, DRW_STATE_WRITE_COLOR); diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c index b9f7624552c..cb54ad3a164 100644 --- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c +++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c @@ -192,7 +192,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_ * - Finally composite the 2 blurred buffers with the original render. **/ DRWShadingGroup *grp; - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); psl->dof_down = DRW_pass_create("DoF Downsample", DRW_STATE_WRITE_COLOR); diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index d7a978066d5..28658d5126c 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -302,7 +302,7 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) downsample_write = DRW_STATE_WRITE_COLOR; } - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); { psl->color_downsample_ps = DRW_pass_create( diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index a6d11f1edac..4f5ad5159cf 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -83,8 +83,8 @@ extern void DRW_opengl_context_disable(void); extern void DRW_opengl_render_context_enable(void *re_gl_context); extern void DRW_opengl_render_context_disable(void *re_gl_context); -extern void DRW_gawain_render_context_enable(void *re_gwn_context); -extern void DRW_gawain_render_context_disable(void *re_gwn_context); +extern void DRW_gawain_render_context_enable(void *re_gpu_context); +extern void DRW_gawain_render_context_disable(void *re_gpu_context); typedef struct EEVEE_LightBake { Depsgraph *depsgraph; @@ -144,7 +144,7 @@ typedef struct EEVEE_LightBake { bool own_light_cache; /* If the lightcache was created for baking, it's first owned by the baker. */ int delay; /* ms. delay the start of the baking to not slowdown interactions (TODO remove) */ - void *gl_context, *gwn_context; /* If running in parallel (in a separate thread), use this context. */ + void *gl_context, *gpu_context; /* If running in parallel (in a separate thread), use this context. */ } EEVEE_LightBake; /* -------------------------------------------------------------------- */ @@ -369,10 +369,10 @@ static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake) { if (lbake->gl_context) { DRW_opengl_render_context_enable(lbake->gl_context); - if (lbake->gwn_context == NULL) { - lbake->gwn_context = GWN_context_create(); + if (lbake->gpu_context == NULL) { + lbake->gpu_context = GPU_context_create(); } - DRW_gawain_render_context_enable(lbake->gwn_context); + DRW_gawain_render_context_enable(lbake->gpu_context); } else { DRW_opengl_context_enable(); @@ -382,7 +382,7 @@ static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake) static void eevee_lightbake_context_disable(EEVEE_LightBake *lbake) { if (lbake->gl_context) { - DRW_gawain_render_context_disable(lbake->gwn_context); + DRW_gawain_render_context_disable(lbake->gpu_context); DRW_opengl_render_context_disable(lbake->gl_context); } else { @@ -586,7 +586,7 @@ static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake) { if (lbake->gl_context) { DRW_opengl_render_context_enable(lbake->gl_context); - DRW_gawain_render_context_enable(lbake->gwn_context); + DRW_gawain_render_context_enable(lbake->gpu_context); } else if (!lbake->resource_only) { DRW_opengl_context_enable(); @@ -605,17 +605,17 @@ static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake) GPU_FRAMEBUFFER_FREE_SAFE(lbake->rt_fb[i]); } - if (lbake->gwn_context) { - DRW_gawain_render_context_disable(lbake->gwn_context); - DRW_gawain_render_context_enable(lbake->gwn_context); - GWN_context_discard(lbake->gwn_context); + if (lbake->gpu_context) { + DRW_gawain_render_context_disable(lbake->gpu_context); + DRW_gawain_render_context_enable(lbake->gpu_context); + GPU_context_discard(lbake->gpu_context); } if (lbake->gl_context && lbake->own_resources) { /* Delete the baking context. */ DRW_opengl_render_context_disable(lbake->gl_context); WM_opengl_context_dispose(lbake->gl_context); - lbake->gwn_context = NULL; + lbake->gpu_context = NULL; lbake->gl_context = NULL; } else if (lbake->gl_context) { diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 1b341aced07..691d6ffe6eb 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -74,8 +74,8 @@ static struct { struct GPUTexture *depth_array_placeholder; struct GPUTexture *cube_face_minmaxz; - struct Gwn_VertFormat *format_probe_display_cube; - struct Gwn_VertFormat *format_probe_display_planar; + struct GPUVertFormat *format_probe_display_cube; + struct GPUVertFormat *format_probe_display_planar; } e_data = {NULL}; /* Engine data */ extern char datatoc_background_vert_glsl[]; @@ -395,7 +395,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRW_shgroup_uniform_float(grp, "intensityFac", &pinfo->intensity_fac, 1); DRW_shgroup_uniform_texture(grp, "probeHdr", rt_color); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); } @@ -414,7 +414,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley); DRW_shgroup_uniform_texture(grp, "probeDepth", rt_depth); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); } @@ -424,7 +424,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_grid_fill_sh, psl->probe_grid_fill); DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &light_cache->grid_tx.tex); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); } } @@ -447,7 +447,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat { psl->probe_background = DRW_pass_create("World Probe Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRWShadingGroup *grp = NULL; Scene *scene = draw_ctx->scene; diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index dc9ce29a148..2c970fa5285 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -425,7 +425,7 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob) /* Add a shadow caster to the shadowpasses */ void EEVEE_lights_cache_shcaster_add( - EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob) + EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_StorageList *stl, struct GPUBatch *geom, Object *ob) { DRW_shgroup_call_object_add( stl->g_data->shadow_shgrp, @@ -434,7 +434,7 @@ void EEVEE_lights_cache_shcaster_add( void EEVEE_lights_cache_shcaster_material_add( EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_PassList *psl, struct GPUMaterial *gpumat, - struct Gwn_Batch *geom, struct Object *ob, float *alpha_threshold) + struct GPUBatch *geom, struct Object *ob, float *alpha_threshold) { /* TODO / PERF : reuse the same shading group for objects with the same material */ DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, psl->shadow_pass); diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index 2e568d97c07..345a28590c6 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -60,7 +60,7 @@ void EEVEE_lookdev_cache_init( if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) { StudioLight *sl = BKE_studiolight_find(v3d->shading.studio_light, STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE); if (sl && (sl->flag & STUDIOLIGHT_ORIENTATION_WORLD)) { - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); GPUTexture *tex = NULL; /* If one of the component is missing we start from scratch. */ diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 20d755d2245..39f7443145f 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -135,7 +135,7 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h)) DRW_shgroup_uniform_texture(grp, "texHammersley", e_data.hammersley); DRW_shgroup_uniform_texture(grp, "texJitter", e_data.jitter); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut"); @@ -197,7 +197,7 @@ static struct GPUTexture *create_ggx_refraction_lut_texture(int w, int h) DRW_shgroup_uniform_texture(grp, "texHammersley", hammersley); DRW_shgroup_uniform_texture(grp, "utilTex", e_data.util_tex); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRW_shgroup_call_add(grp, geom, NULL); float *texels = MEM_mallocN(sizeof(float[2]) * w * h, "lut"); @@ -946,7 +946,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) { psl->background_pass = DRW_pass_create("Background Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL); - struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *geom = DRW_cache_fullscreen_quad_get(); DRWShadingGroup *grp = NULL; const DRWContextState *draw_ctx = DRW_context_state_get(); @@ -1477,7 +1477,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld char *auto_layer_names; int *auto_layer_is_srgb; int auto_layer_count; - struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get( + struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get( ob, gpumat_array, materials_len, &auto_layer_names, &auto_layer_is_srgb, @@ -1690,7 +1690,7 @@ void EEVEE_materials_cache_finish(EEVEE_Data *vedata) if (LOOK_DEV_OVERLAY_ENABLED(v3d)) { EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); EEVEE_LampsInfo *linfo = sldata->lamps; - struct Gwn_Batch *sphere = DRW_cache_sphere_get(); + struct GPUBatch *sphere = DRW_cache_sphere_get(); static float mat1[4][4]; static float color[3] = {0.8f, 0.8f, 0.8f}; static float metallic_on = 1.0f; diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c index 6dabc8f91cb..08745850bd4 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.c +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c @@ -178,7 +178,7 @@ void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat EEVEE_EffectsInfo *effects = stl->effects; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); if ((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0) { psl->motion_blur = DRW_pass_create("Motion Blur", DRW_STATE_WRITE_COLOR); diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c index f39fbe33a71..8ede22cda5a 100644 --- a/source/blender/draw/engines/eevee/eevee_occlusion.c +++ b/source/blender/draw/engines/eevee/eevee_occlusion.c @@ -183,7 +183,7 @@ void EEVEE_occlusion_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) EEVEE_EffectsInfo *effects = stl->effects; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); if ((effects->enabled_effects & EFFECT_GTAO) != 0) { /** Occlusion algorithm overview diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 1e43d6fba08..6ef24d03df8 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -815,10 +815,10 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata); void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, struct Object *ob); void EEVEE_lights_cache_shcaster_add( - EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob); + EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, struct GPUBatch *geom, Object *ob); void EEVEE_lights_cache_shcaster_material_add( EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl, - struct GPUMaterial *gpumat, struct Gwn_Batch *geom, struct Object *ob, + struct GPUMaterial *gpumat, struct GPUBatch *geom, struct Object *ob, float *alpha_threshold); void EEVEE_lights_cache_shcaster_object_add(EEVEE_ViewLayerData *sldata, struct Object *ob); void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata); diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c index ef949c32eed..204b730f8da 100644 --- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c +++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c @@ -189,7 +189,7 @@ void EEVEE_screen_raytrace_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *v EEVEE_EffectsInfo *effects = stl->effects; LightCache *lcache = stl->g_data->light_cache; - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); if ((effects->enabled_effects & EFFECT_SSR) != 0) { int options = (effects->reflection_trace_full) ? SSR_FULL_TRACE : 0; diff --git a/source/blender/draw/engines/eevee/eevee_subsurface.c b/source/blender/draw/engines/eevee/eevee_subsurface.c index 6ee3b9cc286..9667f2ac9d7 100644 --- a/source/blender/draw/engines/eevee/eevee_subsurface.c +++ b/source/blender/draw/engines/eevee/eevee_subsurface.c @@ -204,7 +204,7 @@ void EEVEE_subsurface_add_pass( EEVEE_PassList *psl = vedata->psl; EEVEE_StorageList *stl = vedata->stl; EEVEE_EffectsInfo *effects = stl->effects; - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); DRWShadingGroup *grp = DRW_shgroup_create(e_data.sss_sh[0], psl->sss_blur_ps); DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex()); diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c index 35ff777b885..b2c30ba723c 100644 --- a/source/blender/draw/engines/external/external_engine.c +++ b/source/blender/draw/engines/external/external_engine.c @@ -128,7 +128,7 @@ static void external_cache_populate(void *vedata, Object *ob) if (!DRW_object_is_renderable(ob)) return; - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { /* Depth Prepass */ DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat); diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 0ad755049b1..cf53004e126 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -678,7 +678,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (me->mloopuv) { const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol)); struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len); - struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; + struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; if (materials_len > 0 && geom_array) { for (int i = 0; i < materials_len; i++) { if (geom_array[i] == NULL) { @@ -701,7 +701,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (!is_drawn) { if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) { /* No material split needed */ - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type); if (is_sculpt_mode) { @@ -719,7 +719,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) gpumat_array[i] = NULL; } - struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get( + struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get( ob, gpumat_array, materials_len, NULL, NULL, NULL); if (mat_geom) { for (int i = 0; i < materials_len; ++i) { @@ -742,7 +742,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (SHADOW_ENABLED(wpd) && (ob->display.flag & OB_SHOW_SHADOW)) { bool is_manifold; - struct Gwn_Batch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold); + struct GPUBatch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold); if (geom_shadow) { if (is_sculpt_mode) { /* Currently unsupported in sculpt mode. We could revert to the slow diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index e0e0bdea0f5..2a65feeb28c 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -483,7 +483,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (me->mloopuv) { const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol)); struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len); - struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; + struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; if (materials_len > 0 && geom_array) { for (int i = 0; i < materials_len; i++) { if (geom_array[i] == NULL) { @@ -516,7 +516,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) if (!is_drawn) { if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) { /* No material split needed */ - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type); if (is_sculpt_mode) { @@ -536,7 +536,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) gpumat_array[i] = NULL; } - struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get( + struct GPUBatch **mat_geom = DRW_cache_object_surface_material_get( ob, gpumat_array, materials_len, NULL, NULL, NULL); if (mat_geom) { for (int i = 0; i < materials_len; ++i) { diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 16a17f4f21d..adcfe2524c7 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -71,7 +71,7 @@ struct GPUMaterial; struct GPUTexture; struct GPUUniformBuffer; struct Object; -struct Gwn_Batch; +struct GPUBatch; struct DefaultFramebufferList; struct DefaultTextureList; struct DRWTextStore; @@ -306,7 +306,7 @@ typedef struct DRWInstanceAttribFormat { int components; } DRWInstanceAttribFormat; -struct Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize); +struct GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize); #define DRW_shgroup_instance_format(format, ...) do { \ if (format == NULL) { \ DRWInstanceAttribFormat drw_format[] = __VA_ARGS__;\ @@ -317,25 +317,25 @@ struct Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttrib DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass); DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass); DRWShadingGroup *DRW_shgroup_material_instance_create( - struct GPUMaterial *material, DRWPass *pass, struct Gwn_Batch *geom, struct Object *ob, - struct Gwn_VertFormat *format); + struct GPUMaterial *material, DRWPass *pass, struct GPUBatch *geom, struct Object *ob, + struct GPUVertFormat *format); DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create(struct GPUMaterial *material, DRWPass *pass, int size); DRWShadingGroup *DRW_shgroup_instance_create( - struct GPUShader *shader, DRWPass *pass, struct Gwn_Batch *geom, struct Gwn_VertFormat *format); + struct GPUShader *shader, DRWPass *pass, struct GPUBatch *geom, struct GPUVertFormat *format); DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass); DRWShadingGroup *DRW_shgroup_line_batch_create_with_format( - struct GPUShader *shader, DRWPass *pass, struct Gwn_VertFormat *format); + struct GPUShader *shader, DRWPass *pass, struct GPUVertFormat *format); DRWShadingGroup *DRW_shgroup_line_batch_create( struct GPUShader *shader, DRWPass *pass); DRWShadingGroup *DRW_shgroup_empty_tri_batch_create( struct GPUShader *shader, DRWPass *pass, int size); DRWShadingGroup *DRW_shgroup_transform_feedback_create( - struct GPUShader *shader, DRWPass *pass, struct Gwn_VertBuf *tf_target); + struct GPUShader *shader, DRWPass *pass, struct GPUVertBuf *tf_target); typedef void (DRWCallGenerateFn)( DRWShadingGroup *shgroup, - void (*draw_fn)(DRWShadingGroup *shgroup, struct Gwn_Batch *geom), + void (*draw_fn)(DRWShadingGroup *shgroup, struct GPUBatch *geom), void *user_data); /* return final visibility */ @@ -343,27 +343,27 @@ typedef bool (DRWCallVisibilityFn)( bool vis_in, void *user_data); -void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batch); +void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch); void DRW_shgroup_free(struct DRWShadingGroup *shgroup); -void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4]); +void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4]); void DRW_shgroup_call_range_add( - DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count); + DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_count); void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4]); void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]); void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4]); void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, struct Object *ob); -void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, bool bypass_culling); +void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, bool bypass_culling); #define DRW_shgroup_call_object_add(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, false) #define DRW_shgroup_call_object_add_no_cull(shgroup, geom, ob) DRW_shgroup_call_object_add_ex(shgroup, geom, ob, true) void DRW_shgroup_call_object_add_with_callback( - DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, + DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, DRWCallVisibilityFn *callback, void *user_data); /* Used for drawing a batch with instancing without instance attribs. */ void DRW_shgroup_call_instances_add( - DRWShadingGroup *shgroup, struct Gwn_Batch *geom, float (*obmat)[4], uint *count); + DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4], uint *count); void DRW_shgroup_call_object_instances_add( - DRWShadingGroup *shgroup, struct Gwn_Batch *geom, struct Object *ob, uint *count); + DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, uint *count); void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shgroup, struct Object *ob, float (*obmat)[4]); void DRW_shgroup_call_generate_add( DRWShadingGroup *shgroup, DRWCallGenerateFn *geometry_fn, void *user_data, float (*obmat)[4]); diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c index e634710980a..95894783cfe 100644 --- a/source/blender/draw/intern/draw_anim_viz.c +++ b/source/blender/draw/intern/draw_anim_viz.c @@ -98,36 +98,36 @@ struct { /* *************************** Path Cache *********************************** */ /* Just convert the CPU cache to GPU cache. */ -static Gwn_VertBuf *mpath_vbo_get(bMotionPath *mpath) +static GPUVertBuf *mpath_vbo_get(bMotionPath *mpath) { if (!mpath->points_vbo) { - Gwn_VertFormat format = {0}; + GPUVertFormat format = {0}; /* Match structure of bMotionPathVert. */ - uint pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - GWN_vertformat_attr_add(&format, "flag", GWN_COMP_I32, 1, GWN_FETCH_INT); - mpath->points_vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(mpath->points_vbo, mpath->length); + uint pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + GPU_vertformat_attr_add(&format, "flag", GPU_COMP_I32, 1, GPU_FETCH_INT); + mpath->points_vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(mpath->points_vbo, mpath->length); /* meh... a useless memcpy. */ - Gwn_VertBufRaw raw_data; - GWN_vertbuf_attr_get_raw_data(mpath->points_vbo, pos, &raw_data); - memcpy(GWN_vertbuf_raw_step(&raw_data), mpath->points, sizeof(bMotionPathVert) * mpath->length); + GPUVertBufRaw raw_data; + GPU_vertbuf_attr_get_raw_data(mpath->points_vbo, pos, &raw_data); + memcpy(GPU_vertbuf_raw_step(&raw_data), mpath->points, sizeof(bMotionPathVert) * mpath->length); } return mpath->points_vbo; } -static Gwn_Batch *mpath_batch_line_get(bMotionPath *mpath) +static GPUBatch *mpath_batch_line_get(bMotionPath *mpath) { if (!mpath->batch_line) { - mpath->batch_line = GWN_batch_create(GWN_PRIM_LINE_STRIP, mpath_vbo_get(mpath), NULL); + mpath->batch_line = GPU_batch_create(GPU_PRIM_LINE_STRIP, mpath_vbo_get(mpath), NULL); } return mpath->batch_line; } -static Gwn_Batch *mpath_batch_points_get(bMotionPath *mpath) +static GPUBatch *mpath_batch_points_get(bMotionPath *mpath) { if (!mpath->batch_points) { - mpath->batch_points = GWN_batch_create(GWN_PRIM_POINTS, mpath_vbo_get(mpath), NULL); + mpath->batch_points = GPU_batch_create(GPU_PRIM_POINTS, mpath_vbo_get(mpath), NULL); } return mpath->batch_points; } diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index 9bc8b70b67c..b49ca4d0d00 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -134,11 +134,11 @@ static void drw_shgroup_bone_octahedral( const float bone_color[4], const float hint_color[4], const float outline_color[4]) { if (g_data.bone_octahedral_outline == NULL) { - struct Gwn_Batch *geom = DRW_cache_bone_octahedral_wire_get(); + struct GPUBatch *geom = DRW_cache_bone_octahedral_wire_get(); g_data.bone_octahedral_outline = shgroup_instance_bone_shape_outline(g_data.passes.bone_outline, geom); } if (g_data.bone_octahedral_solid == NULL) { - struct Gwn_Batch *geom = DRW_cache_bone_octahedral_get(); + struct GPUBatch *geom = DRW_cache_bone_octahedral_get(); g_data.bone_octahedral_solid = shgroup_instance_bone_shape_solid(g_data.passes.bone_solid, geom); } float final_bonemat[4][4]; @@ -155,11 +155,11 @@ static void drw_shgroup_bone_box( const float bone_color[4], const float hint_color[4], const float outline_color[4]) { if (g_data.bone_box_wire == NULL) { - struct Gwn_Batch *geom = DRW_cache_bone_box_wire_get(); + struct GPUBatch *geom = DRW_cache_bone_box_wire_get(); g_data.bone_box_outline = shgroup_instance_bone_shape_outline(g_data.passes.bone_outline, geom); } if (g_data.bone_box_solid == NULL) { - struct Gwn_Batch *geom = DRW_cache_bone_box_get(); + struct GPUBatch *geom = DRW_cache_bone_box_get(); g_data.bone_box_solid = shgroup_instance_bone_shape_solid(g_data.passes.bone_solid, geom); } float final_bonemat[4][4]; @@ -319,9 +319,9 @@ static void drw_shgroup_bone_custom_solid( Object *custom) { /* grr, not re-using instances! */ - struct Gwn_Batch *surf = DRW_cache_object_surface_get(custom); - struct Gwn_Batch *edges = DRW_cache_object_edge_detection_get(custom, NULL); - struct Gwn_Batch *ledges = DRW_cache_object_loose_edges_get(custom); + struct GPUBatch *surf = DRW_cache_object_surface_get(custom); + struct GPUBatch *edges = DRW_cache_object_edge_detection_get(custom, NULL); + struct GPUBatch *ledges = DRW_cache_object_loose_edges_get(custom); float final_bonemat[4][4]; if (surf || edges || ledges) { @@ -352,7 +352,7 @@ static void drw_shgroup_bone_custom_wire( const float color[4], Object *custom) { /* grr, not re-using instances! */ - struct Gwn_Batch *geom = DRW_cache_object_wire_outline_get(custom); + struct GPUBatch *geom = DRW_cache_object_wire_outline_get(custom); if (geom) { DRWShadingGroup *shgrp_geom_wire = shgroup_instance_wire(g_data.passes.bone_wire, geom); float final_bonemat[4][4], final_color[4]; diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index d23b9e693ce..bb73a8c1b19 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -47,85 +47,85 @@ /* Batch's only (free'd as an array) */ static struct DRWShapeCache { - Gwn_Batch *drw_single_vertice; - Gwn_Batch *drw_cursor; - Gwn_Batch *drw_cursor_only_circle; - Gwn_Batch *drw_fullscreen_quad; - Gwn_Batch *drw_fullscreen_quad_texcoord; - Gwn_Batch *drw_quad; - Gwn_Batch *drw_sphere; - Gwn_Batch *drw_screenspace_circle; - Gwn_Batch *drw_plain_axes; - Gwn_Batch *drw_single_arrow; - Gwn_Batch *drw_cube; - Gwn_Batch *drw_circle; - Gwn_Batch *drw_square; - Gwn_Batch *drw_line; - Gwn_Batch *drw_line_endpoints; - Gwn_Batch *drw_empty_cube; - Gwn_Batch *drw_empty_sphere; - Gwn_Batch *drw_empty_cylinder; - Gwn_Batch *drw_empty_capsule_body; - Gwn_Batch *drw_empty_capsule_cap; - Gwn_Batch *drw_empty_cone; - Gwn_Batch *drw_arrows; - Gwn_Batch *drw_axis_names; - Gwn_Batch *drw_image_plane; - Gwn_Batch *drw_image_plane_wire; - Gwn_Batch *drw_field_wind; - Gwn_Batch *drw_field_force; - Gwn_Batch *drw_field_vortex; - Gwn_Batch *drw_field_tube_limit; - Gwn_Batch *drw_field_cone_limit; - Gwn_Batch *drw_lamp; - Gwn_Batch *drw_lamp_shadows; - Gwn_Batch *drw_lamp_sunrays; - Gwn_Batch *drw_lamp_area_square; - Gwn_Batch *drw_lamp_area_disk; - Gwn_Batch *drw_lamp_hemi; - Gwn_Batch *drw_lamp_spot; - Gwn_Batch *drw_lamp_spot_square; - Gwn_Batch *drw_speaker; - Gwn_Batch *drw_lightprobe_cube; - Gwn_Batch *drw_lightprobe_planar; - Gwn_Batch *drw_lightprobe_grid; - Gwn_Batch *drw_bone_octahedral; - Gwn_Batch *drw_bone_octahedral_wire; - Gwn_Batch *drw_bone_box; - Gwn_Batch *drw_bone_box_wire; - Gwn_Batch *drw_bone_wire_wire; - Gwn_Batch *drw_bone_envelope; - Gwn_Batch *drw_bone_envelope_outline; - Gwn_Batch *drw_bone_point; - Gwn_Batch *drw_bone_point_wire; - Gwn_Batch *drw_bone_stick; - Gwn_Batch *drw_bone_arrows; - Gwn_Batch *drw_camera; - Gwn_Batch *drw_camera_frame; - Gwn_Batch *drw_camera_tria; - Gwn_Batch *drw_camera_focus; - Gwn_Batch *drw_particle_cross; - Gwn_Batch *drw_particle_circle; - Gwn_Batch *drw_particle_axis; + GPUBatch *drw_single_vertice; + GPUBatch *drw_cursor; + GPUBatch *drw_cursor_only_circle; + GPUBatch *drw_fullscreen_quad; + GPUBatch *drw_fullscreen_quad_texcoord; + GPUBatch *drw_quad; + GPUBatch *drw_sphere; + GPUBatch *drw_screenspace_circle; + GPUBatch *drw_plain_axes; + GPUBatch *drw_single_arrow; + GPUBatch *drw_cube; + GPUBatch *drw_circle; + GPUBatch *drw_square; + GPUBatch *drw_line; + GPUBatch *drw_line_endpoints; + GPUBatch *drw_empty_cube; + GPUBatch *drw_empty_sphere; + GPUBatch *drw_empty_cylinder; + GPUBatch *drw_empty_capsule_body; + GPUBatch *drw_empty_capsule_cap; + GPUBatch *drw_empty_cone; + GPUBatch *drw_arrows; + GPUBatch *drw_axis_names; + GPUBatch *drw_image_plane; + GPUBatch *drw_image_plane_wire; + GPUBatch *drw_field_wind; + GPUBatch *drw_field_force; + GPUBatch *drw_field_vortex; + GPUBatch *drw_field_tube_limit; + GPUBatch *drw_field_cone_limit; + GPUBatch *drw_lamp; + GPUBatch *drw_lamp_shadows; + GPUBatch *drw_lamp_sunrays; + GPUBatch *drw_lamp_area_square; + GPUBatch *drw_lamp_area_disk; + GPUBatch *drw_lamp_hemi; + GPUBatch *drw_lamp_spot; + GPUBatch *drw_lamp_spot_square; + GPUBatch *drw_speaker; + GPUBatch *drw_lightprobe_cube; + GPUBatch *drw_lightprobe_planar; + GPUBatch *drw_lightprobe_grid; + GPUBatch *drw_bone_octahedral; + GPUBatch *drw_bone_octahedral_wire; + GPUBatch *drw_bone_box; + GPUBatch *drw_bone_box_wire; + GPUBatch *drw_bone_wire_wire; + GPUBatch *drw_bone_envelope; + GPUBatch *drw_bone_envelope_outline; + GPUBatch *drw_bone_point; + GPUBatch *drw_bone_point_wire; + GPUBatch *drw_bone_stick; + GPUBatch *drw_bone_arrows; + GPUBatch *drw_camera; + GPUBatch *drw_camera_frame; + GPUBatch *drw_camera_tria; + GPUBatch *drw_camera_focus; + GPUBatch *drw_particle_cross; + GPUBatch *drw_particle_circle; + GPUBatch *drw_particle_axis; } SHC = {NULL}; void DRW_shape_cache_free(void) { - uint i = sizeof(SHC) / sizeof(Gwn_Batch *); - Gwn_Batch **batch = (Gwn_Batch **)&SHC; + uint i = sizeof(SHC) / sizeof(GPUBatch *); + GPUBatch **batch = (GPUBatch **)&SHC; while (i--) { - GWN_BATCH_DISCARD_SAFE(*batch); + GPU_BATCH_DISCARD_SAFE(*batch); batch++; } } void DRW_shape_cache_reset(void) { - uint i = sizeof(SHC) / sizeof(Gwn_Batch *); - Gwn_Batch **batch = (Gwn_Batch **)&SHC; + uint i = sizeof(SHC) / sizeof(GPUBatch *); + GPUBatch **batch = (GPUBatch **)&SHC; while (i--) { if (*batch) { - gwn_batch_vao_cache_clear(*batch); + GPU_batch_vao_cache_clear(*batch); } batch++; } @@ -137,22 +137,22 @@ void DRW_shape_cache_reset(void) * \{ */ static void UNUSED_FUNCTION(add_fancy_edge)( - Gwn_VertBuf *vbo, uint pos_id, uint n1_id, uint n2_id, + GPUVertBuf *vbo, uint pos_id, uint n1_id, uint n2_id, uint *v_idx, const float co1[3], const float co2[3], const float n1[3], const float n2[3]) { - GWN_vertbuf_attr_set(vbo, n1_id, *v_idx, n1); - GWN_vertbuf_attr_set(vbo, n2_id, *v_idx, n2); - GWN_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co1); + GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1); + GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2); + GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co1); - GWN_vertbuf_attr_set(vbo, n1_id, *v_idx, n1); - GWN_vertbuf_attr_set(vbo, n2_id, *v_idx, n2); - GWN_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co2); + GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1); + GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2); + GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co2); } #if 0 /* UNUSED */ static void add_lat_lon_vert( - Gwn_VertBuf *vbo, uint pos_id, uint nor_id, + GPUVertBuf *vbo, uint pos_id, uint nor_id, uint *v_idx, const float rad, const float lat, const float lon) { float pos[3], nor[3]; @@ -161,23 +161,23 @@ static void add_lat_lon_vert( nor[2] = sinf(lat) * sinf(lon); mul_v3_v3fl(pos, nor, rad); - GWN_vertbuf_attr_set(vbo, nor_id, *v_idx, nor); - GWN_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, pos); + GPU_vertbuf_attr_set(vbo, nor_id, *v_idx, nor); + GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, pos); } #endif -static Gwn_VertBuf *fill_arrows_vbo(const float scale) +static GPUVertBuf *fill_arrows_vbo(const float scale) { /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Line */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 6 * 3); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 6 * 3); float v1[3] = {0.0, 0.0, 0.0}; float v2[3] = {0.0, 0.0, 0.0}; @@ -189,21 +189,21 @@ static Gwn_VertBuf *fill_arrows_vbo(const float scale) v2[axis] = 1.0f; mul_v3_v3fl(vtmp1, v1, scale); mul_v3_v3fl(vtmp2, v2, scale); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 0, vtmp1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 1, vtmp2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 0, vtmp1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 1, vtmp2); v1[axis] = 0.85f; v1[arrow_axis] = -0.08f; mul_v3_v3fl(vtmp1, v1, scale); mul_v3_v3fl(vtmp2, v2, scale); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 2, vtmp1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 3, vtmp2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 2, vtmp1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 3, vtmp2); v1[arrow_axis] = 0.08f; mul_v3_v3fl(vtmp1, v1, scale); mul_v3_v3fl(vtmp2, v2, scale); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 4, vtmp1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 5, vtmp2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 4, vtmp1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 5, vtmp2); /* reset v1 & v2 to zero */ v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f; @@ -212,18 +212,18 @@ static Gwn_VertBuf *fill_arrows_vbo(const float scale) return vbo; } -static Gwn_VertBuf *sphere_wire_vbo(const float rad) +static GPUVertBuf *sphere_wire_vbo(const float rad) { #define NSEGMENTS 32 /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 2 * 3); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2 * 3); /* a single ring of vertices */ float p[NSEGMENTS][2]; @@ -248,7 +248,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad) else v[0] = 0.0f, v[1] = cv[0], v[2] = cv[1]; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + j + (NSEGMENTS * 2 * axis), v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + j + (NSEGMENTS * 2 * axis), v); } } } @@ -259,7 +259,7 @@ static Gwn_VertBuf *sphere_wire_vbo(const float rad) /* Quads */ /* Use this one for rendering fullscreen passes. For 3D objects use DRW_cache_quad_get(). */ -Gwn_Batch *DRW_cache_fullscreen_quad_get(void) +GPUBatch *DRW_cache_fullscreen_quad_get(void) { if (!SHC.drw_fullscreen_quad) { /* Use a triangle instead of a real quad */ @@ -268,85 +268,57 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void) float uvs[3][2] = {{ 0.0f, 0.0f}, { 2.0f, 0.0f}, { 0.0f, 2.0f}}; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, uvs; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.uvs = GPU_vertformat_attr_add(&format, "uvs", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + GPU_vertformat_alias_add(&format, "texCoord"); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 3); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 3); for (int i = 0; i < 3; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); - GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); + GPU_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]); } - SHC.drw_fullscreen_quad = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_fullscreen_quad = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_fullscreen_quad; } -Gwn_Batch *DRW_cache_fullscreen_quad_texcoord_get(void) -{ - if (!SHC.drw_fullscreen_quad_texcoord) { - /* Use a triangle instead of a real quad */ - /* https://www.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau - slide 14 */ - float pos[3][2] = {{-1.0f, -1.0f}, { 3.0f, -1.0f}, {-1.0f, 3.0f}}; - float texCoord[3][2] = {{ 0.0f, 0.0f}, { 2.0f, 0.0f}, { 0.0f, 2.0f}}; - - /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; - static struct { uint pos, texCoord; } attr_id; - if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.texCoord = GWN_vertformat_attr_add(&format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - } - - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 3); - - for (int i = 0; i < 3; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); - GWN_vertbuf_attr_set(vbo, attr_id.texCoord, i, texCoord[i]); - } - - SHC.drw_fullscreen_quad_texcoord = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); - } - return SHC.drw_fullscreen_quad_texcoord; -} - /* Just a regular quad with 4 vertices. */ -Gwn_Batch *DRW_cache_quad_get(void) +GPUBatch *DRW_cache_quad_get(void) { if (!SHC.drw_quad) { float pos[4][2] = {{-1.0f, -1.0f}, { 1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}}; float uvs[4][2] = {{ 0.0f, 0.0f}, { 1.0f, 0.0f}, {1.0f, 1.0f}, { 0.0f, 1.0f}}; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, uvs; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.uvs = GPU_vertformat_attr_add(&format, "uvs", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 4); for (int i = 0; i < 4; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); - GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]); + GPU_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]); } - SHC.drw_quad = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_quad = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_quad; } /* Sphere */ -Gwn_Batch *DRW_cache_sphere_get(void) +GPUBatch *DRW_cache_sphere_get(void) { if (!SHC.drw_sphere) { SHC.drw_sphere = gpu_batch_sphere(32, 24); @@ -361,7 +333,7 @@ Gwn_Batch *DRW_cache_sphere_get(void) /** \name Common * \{ */ -Gwn_Batch *DRW_cache_cube_get(void) +GPUBatch *DRW_cache_cube_get(void) { if (!SHC.drw_cube) { const GLfloat verts[8][3] = { @@ -391,25 +363,25 @@ Gwn_Batch *DRW_cache_cube_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 36); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 36); for (int i = 0; i < 36; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); } - SHC.drw_cube = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_cube = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_cube; } -Gwn_Batch *DRW_cache_empty_cube_get(void) +GPUBatch *DRW_cache_empty_cube_get(void) { if (!SHC.drw_empty_cube) { const GLfloat verts[8][3] = { @@ -426,54 +398,54 @@ Gwn_Batch *DRW_cache_empty_cube_get(void) const GLubyte indices[24] = {0, 1, 1, 3, 3, 2, 2, 0, 0, 4, 4, 5, 5, 7, 7, 6, 6, 4, 1, 5, 3, 7, 2, 6}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 24); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 24); for (int i = 0; i < 24; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); } - SHC.drw_empty_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_cube = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_cube; } -Gwn_Batch *DRW_cache_circle_get(void) +GPUBatch *DRW_cache_circle_get(void) { #define CIRCLE_RESOL 64 if (!SHC.drw_circle) { float v[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL); for (int a = 0; a < CIRCLE_RESOL; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); } - SHC.drw_circle = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_circle = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_circle; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_square_get(void) +GPUBatch *DRW_cache_square_get(void) { if (!SHC.drw_square) { float p[4][3] = {{ 1.0f, 0.0f, 1.0f}, @@ -482,26 +454,26 @@ Gwn_Batch *DRW_cache_square_get(void) {-1.0f, 0.0f, 1.0f}}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 8); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 8); for (int i = 0; i < 4; i++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2, p[i % 4]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, p[(i + 1) % 4]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2, p[i % 4]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, p[(i + 1) % 4]); } - SHC.drw_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_square = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_square; } -Gwn_Batch *DRW_cache_single_line_get(void) +GPUBatch *DRW_cache_single_line_get(void) { /* Z axis line */ if (!SHC.drw_line) { @@ -509,24 +481,24 @@ Gwn_Batch *DRW_cache_single_line_get(void) float v2[3] = {0.0f, 0.0f, 1.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); - SHC.drw_line = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_line = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_line; } -Gwn_Batch *DRW_cache_single_line_endpoints_get(void) +GPUBatch *DRW_cache_single_line_endpoints_get(void) { /* Z axis line */ if (!SHC.drw_line_endpoints) { @@ -534,46 +506,46 @@ Gwn_Batch *DRW_cache_single_line_endpoints_get(void) float v2[3] = {0.0f, 0.0f, 1.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); - SHC.drw_line_endpoints = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_line_endpoints = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_line_endpoints; } -Gwn_Batch *DRW_cache_screenspace_circle_get(void) +GPUBatch *DRW_cache_screenspace_circle_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_screenspace_circle) { float v[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL + 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL + 1); for (int a = 0; a <= CIRCLE_RESOL; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); } - SHC.drw_screenspace_circle = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_screenspace_circle = GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_screenspace_circle; #undef CIRCLE_RESOL @@ -586,7 +558,7 @@ Gwn_Batch *DRW_cache_screenspace_circle_get(void) /** \name Common Object API * \{ */ -Gwn_Batch *DRW_cache_object_wire_outline_get(Object *ob) +GPUBatch *DRW_cache_object_wire_outline_get(Object *ob) { switch (ob->type) { case OB_MESH: @@ -598,7 +570,7 @@ Gwn_Batch *DRW_cache_object_wire_outline_get(Object *ob) } } -Gwn_Batch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold) +GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold) { switch (ob->type) { case OB_MESH: @@ -622,7 +594,7 @@ void DRW_cache_object_face_wireframe_get( } } -Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob) +GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob) { switch (ob->type) { case OB_MESH: @@ -634,7 +606,7 @@ Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob) } } -Gwn_Batch *DRW_cache_object_surface_get(Object *ob) +GPUBatch *DRW_cache_object_surface_get(Object *ob) { switch (ob->type) { case OB_MESH: @@ -652,7 +624,7 @@ Gwn_Batch *DRW_cache_object_surface_get(Object *ob) } } -Gwn_Batch **DRW_cache_object_surface_material_get( +GPUBatch **DRW_cache_object_surface_material_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { @@ -687,7 +659,7 @@ Gwn_Batch **DRW_cache_object_surface_material_get( /** \name Empties * \{ */ -Gwn_Batch *DRW_cache_plain_axes_get(void) +GPUBatch *DRW_cache_plain_axes_get(void) { if (!SHC.drw_plain_axes) { int axis; @@ -695,46 +667,46 @@ Gwn_Batch *DRW_cache_plain_axes_get(void) float v2[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 6); for (axis = 0; axis < 3; axis++) { v1[axis] = 1.0f; v2[axis] = -1.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 2, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, axis * 2 + 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 2, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 2 + 1, v2); /* reset v1 & v2 to zero for next axis */ v1[axis] = v2[axis] = 0.0f; } - SHC.drw_plain_axes = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_plain_axes = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_plain_axes; } -Gwn_Batch *DRW_cache_single_arrow_get(void) +GPUBatch *DRW_cache_single_arrow_get(void) { if (!SHC.drw_single_arrow) { float v1[3] = {0.0f, 0.0f, 1.0f}, v2[3], v3[3]; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Square Pyramid */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 12); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 12); v2[0] = 0.035f; v2[1] = 0.035f; v3[0] = -0.035f; v3[1] = 0.035f; @@ -750,26 +722,26 @@ Gwn_Batch *DRW_cache_single_arrow_get(void) v3[0] = -v3[0]; } - GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 0, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 1, v2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 2, v3); + GPU_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 2, v3); } - SHC.drw_single_arrow = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_single_arrow = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_single_arrow; } -Gwn_Batch *DRW_cache_empty_sphere_get(void) +GPUBatch *DRW_cache_empty_sphere_get(void) { if (!SHC.drw_empty_sphere) { - Gwn_VertBuf *vbo = sphere_wire_vbo(1.0f); - SHC.drw_empty_sphere = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + GPUVertBuf *vbo = sphere_wire_vbo(1.0f); + SHC.drw_empty_sphere = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_sphere; } -Gwn_Batch *DRW_cache_empty_cone_get(void) +GPUBatch *DRW_cache_empty_cone_get(void) { #define NSEGMENTS 8 if (!SHC.drw_empty_cone) { @@ -782,14 +754,14 @@ Gwn_Batch *DRW_cache_empty_cone_get(void) } /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 4); for (int i = 0; i < NSEGMENTS; ++i) { float cv[2], v[3]; @@ -798,26 +770,26 @@ Gwn_Batch *DRW_cache_empty_cone_get(void) /* cone sides */ v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1]; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v); v[0] = 0.0f, v[1] = 2.0f, v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v); /* end ring */ v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1]; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v); cv[0] = p[(i + 1) % NSEGMENTS][0]; cv[1] = p[(i + 1) % NSEGMENTS][1]; v[0] = cv[0], v[1] = 0.0f, v[2] = cv[1]; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v); } - SHC.drw_empty_cone = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_cone = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_cone; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_empty_cylinder_get(void) +GPUBatch *DRW_cache_empty_cylinder_get(void) { #define NSEGMENTS 12 if (!SHC.drw_empty_cylinder) { @@ -830,14 +802,14 @@ Gwn_Batch *DRW_cache_empty_cylinder_get(void) } /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 6); for (int i = 0; i < NSEGMENTS; ++i) { float cv[2], pv[2], v[3]; @@ -848,30 +820,30 @@ Gwn_Batch *DRW_cache_empty_cylinder_get(void) /* cylinder sides */ copy_v3_fl3(v, cv[0], cv[1], -1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6, v); copy_v3_fl3(v, cv[0], cv[1], 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 1, v); /* top ring */ copy_v3_fl3(v, cv[0], cv[1], 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 2, v); copy_v3_fl3(v, pv[0], pv[1], 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 3, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 3, v); /* bottom ring */ copy_v3_fl3(v, cv[0], cv[1], -1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 4, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 4, v); copy_v3_fl3(v, pv[0], pv[1], -1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 5, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 6 + 5, v); } - SHC.drw_empty_cylinder = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_cylinder = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_cylinder; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_empty_capsule_body_get(void) +GPUBatch *DRW_cache_empty_capsule_body_get(void) { if (!SHC.drw_empty_capsule_body) { const float pos[8][3] = { @@ -886,22 +858,22 @@ Gwn_Batch *DRW_cache_empty_capsule_body_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 8); - GWN_vertbuf_attr_fill(vbo, attr_id.pos, pos); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 8); + GPU_vertbuf_attr_fill(vbo, attr_id.pos, pos); - SHC.drw_empty_capsule_body = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_capsule_body = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_capsule_body; } -Gwn_Batch *DRW_cache_empty_capsule_cap_get(void) +GPUBatch *DRW_cache_empty_capsule_cap_get(void) { #define NSEGMENTS 24 /* Must be multiple of 2. */ if (!SHC.drw_empty_capsule_cap) { @@ -914,23 +886,23 @@ Gwn_Batch *DRW_cache_empty_capsule_cap_get(void) } /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (NSEGMENTS * 2) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (NSEGMENTS * 2) * 2); /* Base circle */ int vidx = 0; for (int i = 0; i < NSEGMENTS; ++i) { float v[3] = {0.0f, 0.0f, 0.0f}; copy_v2_v2(v, p[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); copy_v2_v2(v, p[(i+1) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } for (int i = 0; i < NSEGMENTS / 2; ++i) { @@ -939,149 +911,149 @@ Gwn_Batch *DRW_cache_empty_capsule_cap_get(void) int pi = (i + 1) % NSEGMENTS; /* Y half circle */ copy_v3_fl3(v, p[ci][0], 0.0f, p[ci][1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); copy_v3_fl3(v, p[pi][0], 0.0f, p[pi][1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); /* X half circle */ copy_v3_fl3(v, 0.0f, p[ci][0], p[ci][1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); copy_v3_fl3(v, 0.0f, p[pi][0], p[pi][1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } - SHC.drw_empty_capsule_cap = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_empty_capsule_cap = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_empty_capsule_cap; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_arrows_get(void) +GPUBatch *DRW_cache_arrows_get(void) { if (!SHC.drw_arrows) { - Gwn_VertBuf *vbo = fill_arrows_vbo(1.0f); + GPUVertBuf *vbo = fill_arrows_vbo(1.0f); - SHC.drw_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_arrows = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_arrows; } -Gwn_Batch *DRW_cache_axis_names_get(void) +GPUBatch *DRW_cache_axis_names_get(void) { if (!SHC.drw_axis_names) { const float size = 0.1f; float v1[3], v2[3]; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { /* Using 3rd component as axis indicator */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Line */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 14); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 14); /* X */ copy_v3_fl3(v1, -size, size, 0.0f); copy_v3_fl3(v2, size, -size, 0.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); copy_v3_fl3(v1, size, size, 0.0f); copy_v3_fl3(v2, -size, -size, 0.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 3, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 3, v2); /* Y */ copy_v3_fl3(v1, -size + 0.25f * size, size, 1.0f); copy_v3_fl3(v2, 0.0f, 0.0f, 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 4, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 5, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 4, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 5, v2); copy_v3_fl3(v1, size - 0.25f * size, size, 1.0f); copy_v3_fl3(v2, -size + 0.25f * size, -size, 1.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 6, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 7, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 6, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 7, v2); /* Z */ copy_v3_fl3(v1, -size, size, 2.0f); copy_v3_fl3(v2, size, size, 2.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 8, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 9, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 8, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 9, v2); copy_v3_fl3(v1, size, size, 2.0f); copy_v3_fl3(v2, -size, -size, 2.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 10, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 11, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 10, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 11, v2); copy_v3_fl3(v1, -size, -size, 2.0f); copy_v3_fl3(v2, size, -size, 2.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 12, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 13, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 12, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 13, v2); - SHC.drw_axis_names = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_axis_names = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_axis_names; } -Gwn_Batch *DRW_cache_image_plane_get(void) +GPUBatch *DRW_cache_image_plane_get(void) { if (!SHC.drw_image_plane) { const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, texCoords; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.texCoords = GWN_vertformat_attr_add(&format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.texCoords = GPU_vertformat_attr_add(&format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 4); for (uint j = 0; j < 4; j++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); - GWN_vertbuf_attr_set(vbo, attr_id.texCoords, j, quad[j]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); + GPU_vertbuf_attr_set(vbo, attr_id.texCoords, j, quad[j]); } - SHC.drw_image_plane = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_image_plane = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_image_plane; } -Gwn_Batch *DRW_cache_image_plane_wire_get(void) +GPUBatch *DRW_cache_image_plane_wire_get(void) { if (!SHC.drw_image_plane_wire) { const float quad[4][2] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 4); for (uint j = 0; j < 4; j++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); } - SHC.drw_image_plane_wire = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_image_plane_wire = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_image_plane_wire; } /* Force Field */ -Gwn_Batch *DRW_cache_field_wind_get(void) +GPUBatch *DRW_cache_field_wind_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_field_wind) { float v[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 4); for (int i = 0; i < 4; i++) { float z = 0.05f * (float)i; @@ -1089,36 +1061,36 @@ Gwn_Batch *DRW_cache_field_wind_get(void) v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v); } } - SHC.drw_field_wind = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_wind = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_wind; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_field_force_get(void) +GPUBatch *DRW_cache_field_force_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_field_force) { float v[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 3); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 3); for (int i = 0; i < 3; i++) { float radius = 1.0f + 0.5f * (float)i; @@ -1126,22 +1098,22 @@ Gwn_Batch *DRW_cache_field_force_get(void) v[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2, v); v[0] = radius * sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[1] = radius * cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * CIRCLE_RESOL * 2 + a * 2 + 1, v); } } - SHC.drw_field_force = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_force = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_force; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_field_vortex_get(void) +GPUBatch *DRW_cache_field_vortex_get(void) { #define SPIRAL_RESOL 32 if (!SHC.drw_field_vortex) { @@ -1149,36 +1121,36 @@ Gwn_Batch *DRW_cache_field_vortex_get(void) uint v_idx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, SPIRAL_RESOL * 2 + 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, SPIRAL_RESOL * 2 + 1); for (int a = SPIRAL_RESOL; a > -1; a--) { v[0] = sinf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL); v[1] = cosf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } for (int a = 1; a <= SPIRAL_RESOL; a++) { v[0] = -sinf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL); v[1] = -cosf((2.0f * M_PI * a) / ((float)SPIRAL_RESOL)) * (a / (float)SPIRAL_RESOL); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } - SHC.drw_field_vortex = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_vortex = GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_vortex; #undef SPIRAL_RESOL } -Gwn_Batch *DRW_cache_field_tube_limit_get(void) +GPUBatch *DRW_cache_field_tube_limit_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_field_tube_limit) { @@ -1186,14 +1158,14 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void) uint v_idx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8); /* Caps */ for (int i = 0; i < 2; i++) { @@ -1202,12 +1174,12 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void) v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } } /* Side Edges */ @@ -1217,17 +1189,17 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void) v[0] = sinf((2.0f * M_PI * a) / 4.0f); v[1] = cosf((2.0f * M_PI * a) / 4.0f); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } } - SHC.drw_field_tube_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_tube_limit = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_tube_limit; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_field_cone_limit_get(void) +GPUBatch *DRW_cache_field_cone_limit_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_field_cone_limit) { @@ -1235,14 +1207,14 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) uint v_idx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 + 8); /* Caps */ for (int i = 0; i < 2; i++) { @@ -1251,12 +1223,12 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } } /* Side Edges */ @@ -1266,11 +1238,11 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) v[0] = z * sinf((2.0f * M_PI * a) / 4.0f); v[1] = z * cosf((2.0f * M_PI * a) / 4.0f); v[2] = z; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } } - SHC.drw_field_cone_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_field_cone_limit = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_field_cone_limit; #undef CIRCLE_RESOL @@ -1283,84 +1255,84 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) /** \name Lamps * \{ */ -Gwn_Batch *DRW_cache_lamp_get(void) +GPUBatch *DRW_cache_lamp_get(void) { #define NSEGMENTS 8 if (!SHC.drw_lamp) { float v[2]; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2); for (int a = 0; a < NSEGMENTS * 2; a += 2) { v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2)); v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v); } - SHC.drw_lamp = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_lamp_shadows_get(void) +GPUBatch *DRW_cache_lamp_shadows_get(void) { #define NSEGMENTS 10 if (!SHC.drw_lamp_shadows) { float v[2]; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2); for (int a = 0; a < NSEGMENTS * 2; a += 2) { v[0] = sinf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2)); v[1] = cosf((2.0f * M_PI * a) / ((float)NSEGMENTS * 2)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2)); v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)NSEGMENTS * 2)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a + 1, v); } - SHC.drw_lamp_shadows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_shadows = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_shadows; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_lamp_sunrays_get(void) +GPUBatch *DRW_cache_lamp_sunrays_get(void) { if (!SHC.drw_lamp_sunrays) { float v[2], v1[2], v2[2]; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 32); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 32); for (int a = 0; a < 8; a++) { v[0] = sinf((2.0f * M_PI * a) / 8.0f); @@ -1368,86 +1340,86 @@ Gwn_Batch *DRW_cache_lamp_sunrays_get(void) mul_v2_v2fl(v1, v, 1.6f); mul_v2_v2fl(v2, v, 1.9f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 1, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 1, v2); mul_v2_v2fl(v1, v, 2.2f); mul_v2_v2fl(v2, v, 2.5f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 2, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 3, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 2, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a * 4 + 3, v2); } - SHC.drw_lamp_sunrays = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_sunrays = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_sunrays; } -Gwn_Batch *DRW_cache_lamp_area_square_get(void) +GPUBatch *DRW_cache_lamp_area_square_get(void) { if (!SHC.drw_lamp_area_square) { float v1[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 8); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 8); v1[0] = v1[1] = 0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); v1[0] = -0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 1, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2, v1); v1[1] = -0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 3, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 4, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 3, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 4, v1); v1[0] = 0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 5, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 6, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 5, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 6, v1); v1[1] = 0.5f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 7, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 7, v1); - SHC.drw_lamp_area_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_area_square = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_area_square; } -Gwn_Batch *DRW_cache_lamp_area_disk_get(void) +GPUBatch *DRW_cache_lamp_area_disk_get(void) { #define NSEGMENTS 32 if (!SHC.drw_lamp_area_disk) { /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 2 * NSEGMENTS); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 2 * NSEGMENTS); float v[3] = {0.0f, 0.5f, 0.0f}; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v); for (int a = 1; a < NSEGMENTS; a++) { v[0] = 0.5f * sinf(2.0f * (float)M_PI * a / NSEGMENTS); v[1] = 0.5f * cosf(2.0f * (float)M_PI * a / NSEGMENTS); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * a - 1, v); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * a - 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * a, v); } copy_v3_fl3(v, 0.0f, 0.5f, 0.0f); - GWN_vertbuf_attr_set(vbo, attr_id.pos, (2 * NSEGMENTS) - 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, (2 * NSEGMENTS) - 1, v); - SHC.drw_lamp_area_disk = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_area_disk = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_area_disk; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_lamp_hemi_get(void) +GPUBatch *DRW_cache_lamp_hemi_get(void) { #define CIRCLE_RESOL 32 if (!SHC.drw_lamp_hemi) { @@ -1455,26 +1427,26 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void) int vidx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 - 6 * 2 * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL * 2 * 2 - 6 * 2 * 2); /* XZ plane */ for (int a = 3; a < CIRCLE_RESOL / 2 - 3; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL) - M_PI / 2); v[2] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL) - M_PI / 2) - 1.0f; v[1] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); v[0] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL) - M_PI / 2); v[2] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL) - M_PI / 2) - 1.0f; v[1] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } /* XY plane */ @@ -1482,12 +1454,12 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void) v[2] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)) - 1.0f; v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[0] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); v[2] = sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)) - 1.0f; v[1] = cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[0] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } /* YZ plane full circle */ @@ -1496,22 +1468,22 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void) for (int a = 0; a < CIRCLE_RESOL; a++) { v[1] = rad * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[0] = rad * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); v[1] = rad * sinf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); v[0] = rad * cosf((2.0f * M_PI * (a + 1)) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } - SHC.drw_lamp_hemi = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_hemi = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_hemi; #undef CIRCLE_RESOL } -Gwn_Batch *DRW_cache_lamp_spot_get(void) +GPUBatch *DRW_cache_lamp_spot_get(void) { #define NSEGMENTS 32 if (!SHC.drw_lamp_spot) { @@ -1533,16 +1505,16 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void) } /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, n1, n2; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.n1 = GPU_vertformat_attr_add(&format, "N1", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.n2 = GPU_vertformat_attr_add(&format, "N2", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, NSEGMENTS * 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 4); for (int i = 0; i < NSEGMENTS; ++i) { float cv[2], v[3]; @@ -1551,36 +1523,36 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void) /* cone sides */ v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4, v); v[0] = 0.0f, v[1] = 0.0f, v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 1, v); - GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4, n[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 1, n[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4, n[(i + 1) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 1, n[(i + 1) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4, n[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 1, n[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4, n[(i + 1) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 1, n[(i + 1) % NSEGMENTS]); /* end ring */ v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 2, v); cv[0] = p[(i + 1) % NSEGMENTS][0]; cv[1] = p[(i + 1) % NSEGMENTS][1]; v[0] = cv[0], v[1] = cv[1], v[2] = -1.0f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v); - GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 2, n[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 3, n[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 2, neg[(i) % NSEGMENTS]); - GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 3, neg[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 2, n[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n1, i * 4 + 3, n[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 2, neg[(i) % NSEGMENTS]); + GPU_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 3, neg[(i) % NSEGMENTS]); } - SHC.drw_lamp_spot = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_spot = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_spot; #undef NSEGMENTS } -Gwn_Batch *DRW_cache_lamp_spot_square_get(void) +GPUBatch *DRW_cache_lamp_spot_square_get(void) { if (!SHC.drw_lamp_spot_square) { float p[5][3] = {{ 0.0f, 0.0f, 0.0f}, @@ -1592,25 +1564,25 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void) uint v_idx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 16); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 16); /* piramid sides */ for (int i = 1; i <= 4; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[0]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[0]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[i]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[(i % 4) + 1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[((i + 1) % 4) + 1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[(i % 4) + 1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[((i + 1) % 4) + 1]); } - SHC.drw_lamp_spot_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lamp_spot_square = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lamp_spot_square; } @@ -1622,7 +1594,7 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void) /** \name Speaker * \{ */ -Gwn_Batch *DRW_cache_speaker_get(void) +GPUBatch *DRW_cache_speaker_get(void) { if (!SHC.drw_speaker) { float v[3]; @@ -1630,30 +1602,30 @@ Gwn_Batch *DRW_cache_speaker_get(void) int vidx = 0; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 3 * segments * 2 + 4 * 4); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 3 * segments * 2 + 4 * 4); for (int j = 0; j < 3; j++) { float z = 0.25f * j - 0.125f; float r = (j == 0 ? 0.5f : 0.25f); copy_v3_fl3(v, r, 0.0f, z); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); for (int i = 1; i < segments; i++) { float x = cosf(2.f * (float)M_PI * i / segments) * r; float y = sinf(2.f * (float)M_PI * i / segments) * r; copy_v3_fl3(v, x, y, z); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } copy_v3_fl3(v, r, 0.0f, z); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } for (int j = 0; j < 4; j++) { @@ -1667,14 +1639,14 @@ Gwn_Batch *DRW_cache_speaker_get(void) float z = 0.25f * i - 0.125f; copy_v3_fl3(v, x, y, z); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); if (i == 1) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v); } } } - SHC.drw_speaker = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_speaker = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_speaker; } @@ -1686,7 +1658,7 @@ Gwn_Batch *DRW_cache_speaker_get(void) /** \name Probe * \{ */ -Gwn_Batch *DRW_cache_lightprobe_cube_get(void) +GPUBatch *DRW_cache_lightprobe_cube_get(void) { if (!SHC.drw_lightprobe_cube) { int v_idx = 0; @@ -1703,35 +1675,35 @@ Gwn_Batch *DRW_cache_lightprobe_cube_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (6 + 3) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (6 + 3) * 2); for (int i = 0; i < 6; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 6]); } - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - SHC.drw_lightprobe_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lightprobe_cube = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_cube; } -Gwn_Batch *DRW_cache_lightprobe_grid_get(void) +GPUBatch *DRW_cache_lightprobe_grid_get(void) { if (!SHC.drw_lightprobe_grid) { int v_idx = 0; @@ -1748,47 +1720,47 @@ Gwn_Batch *DRW_cache_lightprobe_grid_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (6 * 2 + 3) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (6 * 2 + 3) * 2); for (int i = 0; i < 6; ++i) { float tmp_v1[3], tmp_v2[3], tmp_tr[3]; copy_v3_v3(tmp_v1, v[i]); copy_v3_v3(tmp_v2, v[(i + 1) % 6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2); /* Internal wires. */ for (int j = 1; j < 2; ++j) { mul_v3_v3fl(tmp_tr, v[(i / 2) * 2 + 1], -0.5f * j); add_v3_v3v3(tmp_v1, v[i], tmp_tr); add_v3_v3v3(tmp_v2, v[(i + 1) % 6], tmp_tr); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, tmp_v2); } } - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - SHC.drw_lightprobe_grid = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lightprobe_grid = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_grid; } -Gwn_Batch *DRW_cache_lightprobe_planar_get(void) +GPUBatch *DRW_cache_lightprobe_planar_get(void) { if (!SHC.drw_lightprobe_planar) { int v_idx = 0; @@ -1801,21 +1773,21 @@ Gwn_Batch *DRW_cache_lightprobe_planar_get(void) }; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 4 * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 4 * 2); for (int i = 0; i < 4; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 4]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 4]); } - SHC.drw_lightprobe_planar = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_lightprobe_planar = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_planar; } @@ -1924,45 +1896,45 @@ static const float bone_octahedral_solid_normals[8][3] = { { 0.00000000f, 0.11043154f, 0.99388373f} }; -Gwn_Batch *DRW_cache_bone_octahedral_get(void) +GPUBatch *DRW_cache_bone_octahedral_get(void) { if (!SHC.drw_bone_octahedral) { uint v_idx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor, snor; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.snor = GPU_vertformat_attr_add(&format, "snor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 24); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 24); for (int i = 0; i < 8; i++) { for (int j = 0; j < 3; ++j) { - GWN_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_octahedral_solid_normals[i]); - GWN_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_octahedral_smooth_normals[bone_octahedral_solid_tris[i][j]]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][j]]); + GPU_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_octahedral_solid_normals[i]); + GPU_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_octahedral_smooth_normals[bone_octahedral_solid_tris[i][j]]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][j]]); } } - SHC.drw_bone_octahedral = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, - GWN_BATCH_OWNS_VBO); + SHC.drw_bone_octahedral = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, + GPU_BATCH_OWNS_VBO); } return SHC.drw_bone_octahedral; } -Gwn_Batch *DRW_cache_bone_octahedral_wire_get(void) +GPUBatch *DRW_cache_bone_octahedral_wire_get(void) { if (!SHC.drw_bone_octahedral_wire) { - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, 12, 24); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 24); for (int i = 0; i < 12; i++) { - GWN_indexbuf_add_line_adj_verts(&elb, + GPU_indexbuf_add_line_adj_verts(&elb, bone_octahedral_wire_lines_adjacency[i][0], bone_octahedral_wire_lines_adjacency[i][1], bone_octahedral_wire_lines_adjacency[i][2], @@ -1970,10 +1942,10 @@ Gwn_Batch *DRW_cache_bone_octahedral_wire_get(void) } /* HACK Reuse vertex buffer. */ - Gwn_Batch *pos_nor_batch = DRW_cache_bone_octahedral_get(); + GPUBatch *pos_nor_batch = DRW_cache_bone_octahedral_get(); - SHC.drw_bone_octahedral_wire = GWN_batch_create_ex(GWN_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GWN_indexbuf_build(&elb), - GWN_BATCH_OWNS_INDEX); + SHC.drw_bone_octahedral_wire = GPU_batch_create_ex(GPU_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GPU_indexbuf_build(&elb), + GPU_BATCH_OWNS_INDEX); } return SHC.drw_bone_octahedral_wire; } @@ -2090,45 +2062,45 @@ static const float bone_box_solid_normals[12][3] = { { 0.0f, 1.0f, 0.0f}, }; -Gwn_Batch *DRW_cache_bone_box_get(void) +GPUBatch *DRW_cache_bone_box_get(void) { if (!SHC.drw_bone_box) { uint v_idx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor, snor; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.snor = GWN_vertformat_attr_add(&format, "snor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.snor = GPU_vertformat_attr_add(&format, "snor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 36); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 36); for (int i = 0; i < 12; i++) { for (int j = 0; j < 3; j++) { - GWN_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_box_solid_normals[i]); - GWN_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_box_smooth_normals[bone_box_solid_tris[i][j]]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_box_verts[bone_box_solid_tris[i][j]]); + GPU_vertbuf_attr_set(vbo, attr_id.nor, v_idx, bone_box_solid_normals[i]); + GPU_vertbuf_attr_set(vbo, attr_id.snor, v_idx, bone_box_smooth_normals[bone_box_solid_tris[i][j]]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_box_verts[bone_box_solid_tris[i][j]]); } } - SHC.drw_bone_box = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, - GWN_BATCH_OWNS_VBO); + SHC.drw_bone_box = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, + GPU_BATCH_OWNS_VBO); } return SHC.drw_bone_box; } -Gwn_Batch *DRW_cache_bone_box_wire_get(void) +GPUBatch *DRW_cache_bone_box_wire_get(void) { if (!SHC.drw_bone_box_wire) { - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, 12, 36); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 36); for (int i = 0; i < 12; i++) { - GWN_indexbuf_add_line_adj_verts(&elb, + GPU_indexbuf_add_line_adj_verts(&elb, bone_box_wire_lines_adjacency[i][0], bone_box_wire_lines_adjacency[i][1], bone_box_wire_lines_adjacency[i][2], @@ -2136,10 +2108,10 @@ Gwn_Batch *DRW_cache_bone_box_wire_get(void) } /* HACK Reuse vertex buffer. */ - Gwn_Batch *pos_nor_batch = DRW_cache_bone_box_get(); + GPUBatch *pos_nor_batch = DRW_cache_bone_box_get(); - SHC.drw_bone_box_wire = GWN_batch_create_ex(GWN_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GWN_indexbuf_build(&elb), - GWN_BATCH_OWNS_INDEX); + SHC.drw_bone_box_wire = GPU_batch_create_ex(GPU_PRIM_LINES_ADJ, pos_nor_batch->verts[0], GPU_indexbuf_build(&elb), + GPU_BATCH_OWNS_INDEX); } return SHC.drw_bone_box_wire; } @@ -2153,7 +2125,7 @@ static void benv_lat_lon_to_co(const float lat, const float lon, float r_nor[3]) r_nor[2] = cosf(lat); } -Gwn_Batch *DRW_cache_bone_envelope_solid_get(void) +GPUBatch *DRW_cache_bone_envelope_solid_get(void) { if (!SHC.drw_bone_envelope) { const int lon_res = 24; @@ -2162,15 +2134,15 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void) const float lat_inc = M_PI / lat_res; uint v_idx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, ((lat_res + 1) * 2) * lon_res * 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, ((lat_res + 1) * 2) * lon_res * 1); float lon = 0.0f; for (int i = 0; i < lon_res; i++, lon += lon_inc) { @@ -2184,24 +2156,24 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void) benv_lat_lon_to_co(lat, lon, co1); benv_lat_lon_to_co(lat, lon + lon_inc, co2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2); } /* Closing the loop */ benv_lat_lon_to_co(M_PI, lon, co1); benv_lat_lon_to_co(M_PI, lon + lon_inc, co2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2); } - SHC.drw_bone_envelope = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_envelope = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_bone_envelope; } -Gwn_Batch *DRW_cache_bone_envelope_outline_get(void) +GPUBatch *DRW_cache_bone_envelope_outline_get(void) { if (!SHC.drw_bone_envelope_outline) { # define CIRCLE_RESOL 64 @@ -2209,16 +2181,16 @@ Gwn_Batch *DRW_cache_bone_envelope_outline_get(void) const float radius = 1.0f; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos0, pos1, pos2; } attr_id; if (format.attr_len == 0) { - attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.pos2 = GWN_vertformat_attr_add(&format, "pos2", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos0 = GPU_vertformat_attr_add(&format, "pos0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.pos1 = GPU_vertformat_attr_add(&format, "pos1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.pos2 = GPU_vertformat_attr_add(&format, "pos2", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2); v0[0] = radius * sinf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL)); v0[1] = radius * cosf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL)); @@ -2230,31 +2202,31 @@ Gwn_Batch *DRW_cache_bone_envelope_outline_get(void) for (int a = 0; a < CIRCLE_RESOL; a++) { v2[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v2[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); copy_v2_v2(v0, v1); copy_v2_v2(v1, v2); } v2[0] = 0.0f; v2[1] = radius; - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); - - SHC.drw_bone_envelope_outline = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2); + + SHC.drw_bone_envelope_outline = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); # undef CIRCLE_RESOL } return SHC.drw_bone_envelope_outline; } -Gwn_Batch *DRW_cache_bone_point_get(void) +GPUBatch *DRW_cache_bone_point_get(void) { if (!SHC.drw_bone_point) { #if 0 /* old style geometry sphere */ @@ -2265,16 +2237,16 @@ Gwn_Batch *DRW_cache_bone_point_get(void) const float lat_inc = M_PI / lat_res; uint v_idx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (lat_res - 1) * lon_res * 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (lat_res - 1) * lon_res * 6); float lon = 0.0f; for (int i = 0; i < lon_res; i++, lon += lon_inc) { @@ -2294,56 +2266,56 @@ Gwn_Batch *DRW_cache_bone_point_get(void) } } - SHC.drw_bone_point = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_point = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); #else # define CIRCLE_RESOL 64 float v[2]; const float radius = 0.05f; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL); for (int a = 0; a < CIRCLE_RESOL; a++) { v[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); + GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v); } - SHC.drw_bone_point = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_point = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO); # undef CIRCLE_RESOL #endif } return SHC.drw_bone_point; } -Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void) +GPUBatch *DRW_cache_bone_point_wire_outline_get(void) { if (!SHC.drw_bone_point_wire) { #if 0 /* old style geometry sphere */ - Gwn_VertBuf *vbo = sphere_wire_vbo(0.05f); - SHC.drw_bone_point_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + GPUVertBuf *vbo = sphere_wire_vbo(0.05f); + SHC.drw_bone_point_wire = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); #else # define CIRCLE_RESOL 64 float v0[2], v1[2]; const float radius = 0.05f; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos0, pos1; } attr_id; if (format.attr_len == 0) { - attr_id.pos0 = GWN_vertformat_attr_add(&format, "pos0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.pos1 = GWN_vertformat_attr_add(&format, "pos1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos0 = GPU_vertformat_attr_add(&format, "pos0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.pos1 = GPU_vertformat_attr_add(&format, "pos1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (CIRCLE_RESOL + 1) * 2); v0[0] = radius * sinf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL)); v0[1] = radius * cosf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL)); @@ -2352,20 +2324,20 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void) for (int a = 0; a < CIRCLE_RESOL; a++) { v1[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v1[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); copy_v2_v2(v0, v1); } v1[0] = 0.0f; v1[1] = radius; - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); - GWN_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); - GWN_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0); + GPU_vertbuf_attr_set(vbo, attr_id.pos1, v++, v1); - SHC.drw_bone_point_wire = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_point_wire = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); # undef CIRCLE_RESOL #endif } @@ -2382,7 +2354,7 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void) #define POS_TAIL (1 << 5) #define POS_BONE (1 << 6) -Gwn_Batch *DRW_cache_bone_stick_get(void) +GPUBatch *DRW_cache_bone_stick_get(void) { if (!SHC.drw_bone_stick) { #define CIRCLE_RESOL 12 @@ -2392,20 +2364,20 @@ Gwn_Batch *DRW_cache_bone_stick_get(void) float pos[2]; /* Position Only 2D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, flag; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.flag = GWN_vertformat_attr_add(&format, "flag", GWN_COMP_U32, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.flag = GPU_vertformat_attr_add(&format, "flag", GPU_COMP_U32, 1, GPU_FETCH_INT); } const uint vcount = (CIRCLE_RESOL + 1) * 2 + 6; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vcount); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vcount); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex(&elb, GWN_PRIM_TRI_FAN, (CIRCLE_RESOL + 2) * 2 + 6 + 2, vcount, true); + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex(&elb, GPU_PRIM_TRI_FAN, (CIRCLE_RESOL + 2) * 2 + 6 + 2, vcount, true); /* head/tail points */ for (int i = 0; i < 2; ++i) { @@ -2413,22 +2385,22 @@ Gwn_Batch *DRW_cache_bone_stick_get(void) copy_v2_fl(pos, 0.0f); flag = (i == 0) ? POS_HEAD : POS_TAIL; flag |= (i == 0) ? COL_HEAD : COL_TAIL; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, pos); - GWN_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos); + GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); + GPU_indexbuf_add_generic_vert(&elb, v++); /* circle vertices */ flag |= COL_WIRE; for (int a = 0; a < CIRCLE_RESOL; a++) { pos[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); pos[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, pos); - GWN_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos); + GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); + GPU_indexbuf_add_generic_vert(&elb, v++); } /* Close the circle */ - GWN_indexbuf_add_generic_vert(&elb, v - CIRCLE_RESOL); + GPU_indexbuf_add_generic_vert(&elb, v - CIRCLE_RESOL); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); } /* Bone rectangle */ @@ -2437,25 +2409,25 @@ Gwn_Batch *DRW_cache_bone_stick_get(void) pos[1] = (i == 0 || i == 3) ? 0.0f : ((i < 3) ? 1.0f : -1.0f); flag = ((i < 2 || i > 4) ? POS_HEAD : POS_TAIL) | ((i == 0 || i == 3) ? 0 : COL_WIRE) | COL_BONE | POS_BONE; - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, pos); - GWN_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos); + GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); + GPU_indexbuf_add_generic_vert(&elb, v++); } - SHC.drw_bone_stick = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, GWN_indexbuf_build(&elb), - GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + SHC.drw_bone_stick = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, GPU_indexbuf_build(&elb), + GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); #undef CIRCLE_RESOL } return SHC.drw_bone_stick; } static void set_bone_axis_vert( - Gwn_VertBuf *vbo, uint axis, uint pos, uint col, + GPUVertBuf *vbo, uint axis, uint pos, uint col, uint *v, const float *a, const float *p, const float *c) { - GWN_vertbuf_attr_set(vbo, axis, *v, a); - GWN_vertbuf_attr_set(vbo, pos, *v, p); - GWN_vertbuf_attr_set(vbo, col, *v, c); + GPU_vertbuf_attr_set(vbo, axis, *v, a); + GPU_vertbuf_attr_set(vbo, pos, *v, p); + GPU_vertbuf_attr_set(vbo, col, *v, c); *v += 1; } @@ -2530,21 +2502,21 @@ static float axis_name_shadow[8][2] = { #undef S_X #undef S_Y -Gwn_Batch *DRW_cache_bone_arrows_get(void) +GPUBatch *DRW_cache_bone_arrows_get(void) { if (!SHC.drw_bone_arrows) { /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint axis, pos, col; } attr_id; if (format.attr_len == 0) { - attr_id.axis = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - attr_id.pos = GWN_vertformat_attr_add(&format, "screenPos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.col = GWN_vertformat_attr_add(&format, "colorAxis", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.axis = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "screenPos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.col = GPU_vertformat_attr_add(&format, "colorAxis", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } /* Line */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, (2 + MARKER_LEN * MARKER_FILL_LAYER) * 3 + + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, (2 + MARKER_LEN * MARKER_FILL_LAYER) * 3 + (X_LEN + Y_LEN + Z_LEN) * (1 + SHADOW_RES)); uint v = 0; @@ -2607,7 +2579,7 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void) } } - SHC.drw_bone_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_bone_arrows = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_bone_arrows; } @@ -2642,52 +2614,52 @@ static const float camera_coords_frame_tri[3] = { /** Draw a loop of lines. */ static void camera_fill_lines_loop_fl_v1( - Gwn_VertBufRaw *pos_step, + GPUVertBufRaw *pos_step, const float *coords, const uint coords_len) { for (uint i = 0, i_prev = coords_len - 1; i < coords_len; i_prev = i++) { - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i_prev]; - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i_prev]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i]; } } /** Fan lines out from the first vertex. */ static void camera_fill_lines_fan_fl_v1( - Gwn_VertBufRaw *pos_step, + GPUVertBufRaw *pos_step, const float *coords, const uint coords_len) { for (uint i = 1; i < coords_len; i++) { - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[0]; - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[0]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i]; } } /** Simply fill the array. */ static void camera_fill_array_fl_v1( - Gwn_VertBufRaw *pos_step, + GPUVertBufRaw *pos_step, const float *coords, const uint coords_len) { for (uint i = 0; i < coords_len; i++) { - *((float *)GWN_vertbuf_raw_step(pos_step)) = coords[i]; + *((float *)GPU_vertbuf_raw_step(pos_step)) = coords[i]; } } -Gwn_Batch *DRW_cache_camera_get(void) +GPUBatch *DRW_cache_camera_get(void) { if (!SHC.drw_camera) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = 22; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); /* camera cone (from center to frame) */ camera_fill_lines_fan_fl_v1(&pos_step, camera_coords_frame_bounds, ARRAY_SIZE(camera_coords_frame_bounds)); @@ -2698,62 +2670,62 @@ Gwn_Batch *DRW_cache_camera_get(void) /* camera triangle (above the frame) */ camera_fill_lines_loop_fl_v1(&pos_step, camera_coords_frame_tri, ARRAY_SIZE(camera_coords_frame_tri)); - BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step)); - SHC.drw_camera = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_camera = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_camera; } -Gwn_Batch *DRW_cache_camera_frame_get(void) +GPUBatch *DRW_cache_camera_frame_get(void) { if (!SHC.drw_camera_frame) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = 8; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); /* camera frame (skip center) */ camera_fill_lines_loop_fl_v1(&pos_step, &camera_coords_frame_bounds[1], ARRAY_SIZE(camera_coords_frame_bounds) - 1); - BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step)); - SHC.drw_camera_frame = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_camera_frame = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_camera_frame; } -Gwn_Batch *DRW_cache_camera_tria_get(void) +GPUBatch *DRW_cache_camera_tria_get(void) { if (!SHC.drw_camera_tria) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } /* Vertices */ - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = 3; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); /* camera triangle (above the frame) */ camera_fill_array_fl_v1(&pos_step, camera_coords_frame_tri, ARRAY_SIZE(camera_coords_frame_tri)); - BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step)); - SHC.drw_camera_tria = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_camera_tria = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_camera_tria; } @@ -2766,24 +2738,24 @@ Gwn_Batch *DRW_cache_camera_tria_get(void) * \{ */ /* Object Center */ -Gwn_Batch *DRW_cache_single_vert_get(void) +GPUBatch *DRW_cache_single_vert_get(void) { if (!SHC.drw_single_vertice) { float v1[3] = {0.0f, 0.0f, 0.0f}; /* Position Only 3D format */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 1); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); - SHC.drw_single_vertice = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_single_vertice = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_single_vertice; } @@ -2795,7 +2767,7 @@ Gwn_Batch *DRW_cache_single_vert_get(void) /** \name Meshes * \{ */ -Gwn_Batch *DRW_cache_mesh_surface_overlay_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_overlay_get(Object *ob) { BLI_assert(ob->type == OB_MESH); Mesh *me = ob->data; @@ -2804,7 +2776,7 @@ Gwn_Batch *DRW_cache_mesh_surface_overlay_get(Object *ob) void DRW_cache_mesh_wire_overlay_get( Object *ob, - Gwn_Batch **r_tris, Gwn_Batch **r_ledges, Gwn_Batch **r_lverts) + GPUBatch **r_tris, GPUBatch **r_ledges, GPUBatch **r_lverts) { BLI_assert(ob->type == OB_MESH); @@ -2817,7 +2789,7 @@ void DRW_cache_mesh_wire_overlay_get( void DRW_cache_mesh_normals_overlay_get( Object *ob, - Gwn_Batch **r_tris, Gwn_Batch **r_ledges, Gwn_Batch **r_lverts) + GPUBatch **r_tris, GPUBatch **r_ledges, GPUBatch **r_lverts) { BLI_assert(ob->type == OB_MESH); @@ -2828,7 +2800,7 @@ void DRW_cache_mesh_normals_overlay_get( *r_lverts = DRW_mesh_batch_cache_get_overlay_loose_verts(me); } -Gwn_Batch *DRW_cache_face_centers_get(Object *ob) +GPUBatch *DRW_cache_face_centers_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2837,7 +2809,7 @@ Gwn_Batch *DRW_cache_face_centers_get(Object *ob) return DRW_mesh_batch_cache_get_overlay_facedots(me); } -Gwn_Batch *DRW_cache_mesh_wire_outline_get(Object *ob) +GPUBatch *DRW_cache_mesh_wire_outline_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2845,7 +2817,7 @@ Gwn_Batch *DRW_cache_mesh_wire_outline_get(Object *ob) return DRW_mesh_batch_cache_get_fancy_edges(me); } -Gwn_Batch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold) +GPUBatch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold) { BLI_assert(ob->type == OB_MESH); @@ -2853,7 +2825,7 @@ Gwn_Batch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold) return DRW_mesh_batch_cache_get_edge_detection(me, r_is_manifold); } -Gwn_Batch *DRW_cache_mesh_surface_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2861,7 +2833,7 @@ Gwn_Batch *DRW_cache_mesh_surface_get(Object *ob) return DRW_mesh_batch_cache_get_triangles_with_normals(me); } -Gwn_Batch *DRW_cache_mesh_loose_edges_get(Object *ob) +GPUBatch *DRW_cache_mesh_loose_edges_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2869,7 +2841,7 @@ Gwn_Batch *DRW_cache_mesh_loose_edges_get(Object *ob) return DRW_mesh_batch_cache_get_loose_edges_with_normals(me); } -Gwn_Batch *DRW_cache_mesh_surface_weights_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2877,7 +2849,7 @@ Gwn_Batch *DRW_cache_mesh_surface_weights_get(Object *ob) return DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(me, ob->actdef - 1); } -Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_vert_colors_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2886,7 +2858,7 @@ Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(Object *ob) } /* Return list of batches */ -Gwn_Batch **DRW_cache_mesh_surface_shaded_get( +GPUBatch **DRW_cache_mesh_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { @@ -2898,7 +2870,7 @@ Gwn_Batch **DRW_cache_mesh_surface_shaded_get( } /* Return list of batches */ -Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(Object *ob) +GPUBatch **DRW_cache_mesh_surface_texpaint_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2906,7 +2878,7 @@ Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(Object *ob) return DRW_mesh_batch_cache_get_surface_texpaint(me); } -Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2914,7 +2886,7 @@ Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob) return DRW_mesh_batch_cache_get_surface_texpaint_single(me); } -Gwn_Batch *DRW_cache_mesh_surface_verts_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_verts_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2922,7 +2894,7 @@ Gwn_Batch *DRW_cache_mesh_surface_verts_get(Object *ob) return DRW_mesh_batch_cache_get_points_with_normals(me); } -Gwn_Batch *DRW_cache_mesh_edges_get(Object *ob) +GPUBatch *DRW_cache_mesh_edges_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2930,7 +2902,7 @@ Gwn_Batch *DRW_cache_mesh_edges_get(Object *ob) return DRW_mesh_batch_cache_get_all_edges(me); } -Gwn_Batch *DRW_cache_mesh_verts_get(Object *ob) +GPUBatch *DRW_cache_mesh_verts_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2938,7 +2910,7 @@ Gwn_Batch *DRW_cache_mesh_verts_get(Object *ob) return DRW_mesh_batch_cache_get_all_verts(me); } -Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool use_sel) +GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool use_sel) { BLI_assert(ob->type == OB_MESH); @@ -2946,7 +2918,7 @@ Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, boo return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel); } -Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob) +GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2954,7 +2926,7 @@ Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob) return DRW_mesh_batch_cache_get_weight_overlay_faces(me); } -Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob) +GPUBatch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob) { BLI_assert(ob->type == OB_MESH); @@ -2977,7 +2949,7 @@ void DRW_cache_mesh_sculpt_coords_ensure(Object *ob) /** \name Curve * \{ */ -Gwn_Batch *DRW_cache_curve_edge_wire_get(Object *ob) +GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob) { BLI_assert(ob->type == OB_CURVE); @@ -2985,7 +2957,7 @@ Gwn_Batch *DRW_cache_curve_edge_wire_get(Object *ob) return DRW_curve_batch_cache_get_wire_edge(cu, ob->curve_cache); } -Gwn_Batch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size) +GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size) { BLI_assert(ob->type == OB_CURVE); @@ -2993,7 +2965,7 @@ Gwn_Batch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size) return DRW_curve_batch_cache_get_normal_edge(cu, ob->curve_cache, normal_size); } -Gwn_Batch *DRW_cache_curve_edge_overlay_get(Object *ob) +GPUBatch *DRW_cache_curve_edge_overlay_get(Object *ob) { BLI_assert(ob->type == OB_CURVE); @@ -3001,7 +2973,7 @@ Gwn_Batch *DRW_cache_curve_edge_overlay_get(Object *ob) return DRW_curve_batch_cache_get_overlay_edges(cu); } -Gwn_Batch *DRW_cache_curve_vert_overlay_get(Object *ob) +GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob) { BLI_assert(ob->type == OB_CURVE); @@ -3009,7 +2981,7 @@ Gwn_Batch *DRW_cache_curve_vert_overlay_get(Object *ob) return DRW_curve_batch_cache_get_overlay_verts(cu); } -Gwn_Batch *DRW_cache_curve_surface_get(Object *ob) +GPUBatch *DRW_cache_curve_surface_get(Object *ob) { BLI_assert(ob->type == OB_CURVE); @@ -3018,7 +2990,7 @@ Gwn_Batch *DRW_cache_curve_surface_get(Object *ob) } /* Return list of batches */ -Gwn_Batch **DRW_cache_curve_surface_shaded_get( +GPUBatch **DRW_cache_curve_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) { BLI_assert(ob->type == OB_CURVE); @@ -3034,13 +3006,13 @@ Gwn_Batch **DRW_cache_curve_surface_shaded_get( /** \name MetaBall * \{ */ -Gwn_Batch *DRW_cache_mball_surface_get(Object *ob) +GPUBatch *DRW_cache_mball_surface_get(Object *ob) { BLI_assert(ob->type == OB_MBALL); return DRW_metaball_batch_cache_get_triangles_with_normals(ob); } -Gwn_Batch **DRW_cache_mball_surface_shaded_get( +GPUBatch **DRW_cache_mball_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) { BLI_assert(ob->type == OB_MBALL); @@ -3055,7 +3027,7 @@ Gwn_Batch **DRW_cache_mball_surface_shaded_get( /** \name Font * \{ */ -Gwn_Batch *DRW_cache_text_edge_wire_get(Object *ob) +GPUBatch *DRW_cache_text_edge_wire_get(Object *ob) { BLI_assert(ob->type == OB_FONT); @@ -3063,7 +3035,7 @@ Gwn_Batch *DRW_cache_text_edge_wire_get(Object *ob) return DRW_curve_batch_cache_get_wire_edge(cu, ob->curve_cache); } -Gwn_Batch *DRW_cache_text_surface_get(Object *ob) +GPUBatch *DRW_cache_text_surface_get(Object *ob) { BLI_assert(ob->type == OB_FONT); struct Curve *cu = ob->data; @@ -3073,7 +3045,7 @@ Gwn_Batch *DRW_cache_text_surface_get(Object *ob) return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->curve_cache); } -Gwn_Batch **DRW_cache_text_surface_shaded_get( +GPUBatch **DRW_cache_text_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) { BLI_assert(ob->type == OB_FONT); @@ -3084,14 +3056,14 @@ Gwn_Batch **DRW_cache_text_surface_shaded_get( return DRW_curve_batch_cache_get_surface_shaded(cu, ob->curve_cache, gpumat_array, gpumat_array_len); } -Gwn_Batch *DRW_cache_text_cursor_overlay_get(Object *ob) +GPUBatch *DRW_cache_text_cursor_overlay_get(Object *ob) { BLI_assert(ob->type == OB_FONT); struct Curve *cu = ob->data; return DRW_curve_batch_cache_get_overlay_cursor(cu); } -Gwn_Batch *DRW_cache_text_select_overlay_get(Object *ob) +GPUBatch *DRW_cache_text_select_overlay_get(Object *ob) { BLI_assert(ob->type == OB_FONT); struct Curve *cu = ob->data; @@ -3105,7 +3077,7 @@ Gwn_Batch *DRW_cache_text_select_overlay_get(Object *ob) /** \name Surface * \{ */ -Gwn_Batch *DRW_cache_surf_surface_get(Object *ob) +GPUBatch *DRW_cache_surf_surface_get(Object *ob) { BLI_assert(ob->type == OB_SURF); @@ -3114,7 +3086,7 @@ Gwn_Batch *DRW_cache_surf_surface_get(Object *ob) } /* Return list of batches */ -Gwn_Batch **DRW_cache_surf_surface_shaded_get( +GPUBatch **DRW_cache_surf_surface_shaded_get( Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) { BLI_assert(ob->type == OB_SURF); @@ -3130,7 +3102,7 @@ Gwn_Batch **DRW_cache_surf_surface_shaded_get( /** \name Lattice * \{ */ -Gwn_Batch *DRW_cache_lattice_verts_get(Object *ob) +GPUBatch *DRW_cache_lattice_verts_get(Object *ob) { BLI_assert(ob->type == OB_LATTICE); @@ -3138,7 +3110,7 @@ Gwn_Batch *DRW_cache_lattice_verts_get(Object *ob) return DRW_lattice_batch_cache_get_all_verts(lt); } -Gwn_Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight) +GPUBatch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight) { BLI_assert(ob->type == OB_LATTICE); @@ -3152,7 +3124,7 @@ Gwn_Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight) return DRW_lattice_batch_cache_get_all_edges(lt, use_weight, actdef); } -Gwn_Batch *DRW_cache_lattice_vert_overlay_get(Object *ob) +GPUBatch *DRW_cache_lattice_vert_overlay_get(Object *ob) { BLI_assert(ob->type == OB_LATTICE); @@ -3167,17 +3139,17 @@ Gwn_Batch *DRW_cache_lattice_vert_overlay_get(Object *ob) /** \name Particles * \{ */ -Gwn_Batch *DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md) +GPUBatch *DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md) { return DRW_particles_batch_cache_get_hair(object, psys, md); } -Gwn_Batch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys) +GPUBatch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys) { return DRW_particles_batch_cache_get_dots(object, psys); } -Gwn_Batch *DRW_cache_particles_get_edit_strands( +GPUBatch *DRW_cache_particles_get_edit_strands( Object *object, ParticleSystem *psys, struct PTCacheEdit *edit) @@ -3185,7 +3157,7 @@ Gwn_Batch *DRW_cache_particles_get_edit_strands( return DRW_particles_batch_cache_get_edit_strands(object, psys, edit); } -Gwn_Batch *DRW_cache_particles_get_edit_inner_points( +GPUBatch *DRW_cache_particles_get_edit_inner_points( Object *object, ParticleSystem *psys, struct PTCacheEdit *edit) @@ -3193,7 +3165,7 @@ Gwn_Batch *DRW_cache_particles_get_edit_inner_points( return DRW_particles_batch_cache_get_edit_inner_points(object, psys, edit); } -Gwn_Batch *DRW_cache_particles_get_edit_tip_points( +GPUBatch *DRW_cache_particles_get_edit_tip_points( Object *object, ParticleSystem *psys, struct PTCacheEdit *edit) @@ -3201,100 +3173,100 @@ Gwn_Batch *DRW_cache_particles_get_edit_tip_points( return DRW_particles_batch_cache_get_edit_tip_points(object, psys, edit); } -Gwn_Batch *DRW_cache_particles_get_prim(int type) +GPUBatch *DRW_cache_particles_get_prim(int type) { switch (type) { case PART_DRAW_CROSS: if (!SHC.drw_particle_cross) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, axis_id; if (format.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); + pos_id = GPU_vertformat_attr_add(&format, "inst_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + axis_id = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 6); /* X axis */ float co[3] = {-1.0f, 0.0f, 0.0f}; int axis = -1; - GWN_vertbuf_attr_set(vbo, pos_id, 0, co); - GWN_vertbuf_attr_set(vbo, axis_id, 0, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 0, co); + GPU_vertbuf_attr_set(vbo, axis_id, 0, &axis); co[0] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 1, co); - GWN_vertbuf_attr_set(vbo, axis_id, 1, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 1, co); + GPU_vertbuf_attr_set(vbo, axis_id, 1, &axis); /* Y axis */ co[0] = 0.0f; co[1] = -1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 2, co); - GWN_vertbuf_attr_set(vbo, axis_id, 2, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 2, co); + GPU_vertbuf_attr_set(vbo, axis_id, 2, &axis); co[1] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 3, co); - GWN_vertbuf_attr_set(vbo, axis_id, 3, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 3, co); + GPU_vertbuf_attr_set(vbo, axis_id, 3, &axis); /* Z axis */ co[1] = 0.0f; co[2] = -1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 4, co); - GWN_vertbuf_attr_set(vbo, axis_id, 4, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 4, co); + GPU_vertbuf_attr_set(vbo, axis_id, 4, &axis); co[2] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 5, co); - GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 5, co); + GPU_vertbuf_attr_set(vbo, axis_id, 5, &axis); - SHC.drw_particle_cross = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_particle_cross = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_particle_cross; case PART_DRAW_AXIS: if (!SHC.drw_particle_axis) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, axis_id; if (format.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); + pos_id = GPU_vertformat_attr_add(&format, "inst_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + axis_id = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 6); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 6); /* X axis */ float co[3] = {0.0f, 0.0f, 0.0f}; int axis = 0; - GWN_vertbuf_attr_set(vbo, pos_id, 0, co); - GWN_vertbuf_attr_set(vbo, axis_id, 0, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 0, co); + GPU_vertbuf_attr_set(vbo, axis_id, 0, &axis); co[0] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 1, co); - GWN_vertbuf_attr_set(vbo, axis_id, 1, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 1, co); + GPU_vertbuf_attr_set(vbo, axis_id, 1, &axis); /* Y axis */ co[0] = 0.0f; axis = 1; - GWN_vertbuf_attr_set(vbo, pos_id, 2, co); - GWN_vertbuf_attr_set(vbo, axis_id, 2, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 2, co); + GPU_vertbuf_attr_set(vbo, axis_id, 2, &axis); co[1] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 3, co); - GWN_vertbuf_attr_set(vbo, axis_id, 3, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 3, co); + GPU_vertbuf_attr_set(vbo, axis_id, 3, &axis); /* Z axis */ co[1] = 0.0f; axis = 2; - GWN_vertbuf_attr_set(vbo, pos_id, 4, co); - GWN_vertbuf_attr_set(vbo, axis_id, 4, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 4, co); + GPU_vertbuf_attr_set(vbo, axis_id, 4, &axis); co[2] = 1.0f; - GWN_vertbuf_attr_set(vbo, pos_id, 5, co); - GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, 5, co); + GPU_vertbuf_attr_set(vbo, axis_id, 5, &axis); - SHC.drw_particle_axis = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_particle_axis = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_particle_axis; @@ -3304,26 +3276,26 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) float v[3] = {0.0f, 0.0f, 0.0f}; int axis = -1; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, axis_id; if (format.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format, "inst_pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - axis_id = GWN_vertformat_attr_add(&format, "axis", GWN_COMP_I32, 1, GWN_FETCH_INT); + pos_id = GPU_vertformat_attr_add(&format, "inst_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + axis_id = GPU_vertformat_attr_add(&format, "axis", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, CIRCLE_RESOL); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, CIRCLE_RESOL); for (int a = 0; a < CIRCLE_RESOL; a++) { v[0] = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[1] = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL)); v[2] = 0.0f; - GWN_vertbuf_attr_set(vbo, pos_id, a, v); - GWN_vertbuf_attr_set(vbo, axis_id, a, &axis); + GPU_vertbuf_attr_set(vbo, pos_id, a, v); + GPU_vertbuf_attr_set(vbo, axis_id, a, &axis); } - SHC.drw_particle_circle = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); + SHC.drw_particle_circle = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_particle_circle; @@ -3337,9 +3309,9 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) } /* 3D cursor */ -Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) +GPUBatch *DRW_cache_cursor_get(bool crosshair_lines) { - Gwn_Batch **drw_cursor = crosshair_lines ? &SHC.drw_cursor : &SHC.drw_cursor_only_circle; + GPUBatch **drw_cursor = crosshair_lines ? &SHC.drw_cursor : &SHC.drw_cursor_only_circle; if (*drw_cursor == NULL) { const float f5 = 0.25f; @@ -3353,18 +3325,18 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) uchar red[3] = {255, 0, 0}; uchar white[3] = {255, 255, 255}; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, color; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.color = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.color = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex(&elb, GWN_PRIM_LINE_STRIP, index_len, vert_len, true); + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len, true); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_len); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vert_len); int v = 0; for (int i = 0; i < segments; ++i) { @@ -3373,59 +3345,59 @@ Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines) float y = f10 * sinf(angle); if (i % 2 == 0) - GWN_vertbuf_attr_set(vbo, attr_id.color, v, red); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, red); else - GWN_vertbuf_attr_set(vbo, attr_id.color, v, white); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, white); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){x, y}); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){x, y}); + GPU_indexbuf_add_generic_vert(&elb, v++); } - GWN_indexbuf_add_generic_vert(&elb, 0); + GPU_indexbuf_add_generic_vert(&elb, 0); if (crosshair_lines) { uchar crosshair_color[3]; UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); - GWN_indexbuf_add_primitive_restart(&elb); + GPU_indexbuf_add_primitive_restart(&elb); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); - GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20}); - GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); - GWN_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); + GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20}); + GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color); + GPU_indexbuf_add_generic_vert(&elb, v++); } - Gwn_IndexBuf *ibo = GWN_indexbuf_build(&elb); + GPUIndexBuf *ibo = GPU_indexbuf_build(&elb); - *drw_cursor = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, ibo, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + *drw_cursor = GPU_batch_create_ex(GPU_PRIM_LINE_STRIP, vbo, ibo, GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); } return *drw_cursor; } diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 07c8a571256..129c0252f30 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -26,7 +26,7 @@ #ifndef __DRAW_CACHE_H__ #define __DRAW_CACHE_H__ -struct Gwn_Batch; +struct GPUBatch; struct GPUMaterial; struct ModifierData; struct Object; @@ -36,163 +36,162 @@ void DRW_shape_cache_free(void); void DRW_shape_cache_reset(void); /* 3D cursor */ -struct Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines); +struct GPUBatch *DRW_cache_cursor_get(bool crosshair_lines); /* Common Shapes */ -struct Gwn_Batch *DRW_cache_fullscreen_quad_get(void); -struct Gwn_Batch *DRW_cache_fullscreen_quad_texcoord_get(void); -struct Gwn_Batch *DRW_cache_quad_get(void); -struct Gwn_Batch *DRW_cache_cube_get(void); -struct Gwn_Batch *DRW_cache_sphere_get(void); -struct Gwn_Batch *DRW_cache_single_vert_get(void); -struct Gwn_Batch *DRW_cache_single_line_get(void); -struct Gwn_Batch *DRW_cache_single_line_endpoints_get(void); -struct Gwn_Batch *DRW_cache_screenspace_circle_get(void); +struct GPUBatch *DRW_cache_fullscreen_quad_get(void); +struct GPUBatch *DRW_cache_quad_get(void); +struct GPUBatch *DRW_cache_cube_get(void); +struct GPUBatch *DRW_cache_sphere_get(void); +struct GPUBatch *DRW_cache_single_vert_get(void); +struct GPUBatch *DRW_cache_single_line_get(void); +struct GPUBatch *DRW_cache_single_line_endpoints_get(void); +struct GPUBatch *DRW_cache_screenspace_circle_get(void); /* Common Object */ -struct Gwn_Batch *DRW_cache_object_wire_outline_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold); -struct Gwn_Batch *DRW_cache_object_surface_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_object_loose_edges_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_object_surface_material_get( +struct GPUBatch *DRW_cache_object_wire_outline_get(struct Object *ob); +struct GPUBatch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold); +struct GPUBatch *DRW_cache_object_surface_get(struct Object *ob); +struct GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob); +struct GPUBatch **DRW_cache_object_surface_material_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count); void DRW_cache_object_face_wireframe_get( Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count); /* Empties */ -struct Gwn_Batch *DRW_cache_plain_axes_get(void); -struct Gwn_Batch *DRW_cache_single_arrow_get(void); -struct Gwn_Batch *DRW_cache_empty_cube_get(void); -struct Gwn_Batch *DRW_cache_circle_get(void); -struct Gwn_Batch *DRW_cache_square_get(void); -struct Gwn_Batch *DRW_cache_empty_sphere_get(void); -struct Gwn_Batch *DRW_cache_empty_cylinder_get(void); -struct Gwn_Batch *DRW_cache_empty_cone_get(void); -struct Gwn_Batch *DRW_cache_empty_capsule_cap_get(void); -struct Gwn_Batch *DRW_cache_empty_capsule_body_get(void); -struct Gwn_Batch *DRW_cache_arrows_get(void); -struct Gwn_Batch *DRW_cache_axis_names_get(void); -struct Gwn_Batch *DRW_cache_image_plane_get(void); -struct Gwn_Batch *DRW_cache_image_plane_wire_get(void); +struct GPUBatch *DRW_cache_plain_axes_get(void); +struct GPUBatch *DRW_cache_single_arrow_get(void); +struct GPUBatch *DRW_cache_empty_cube_get(void); +struct GPUBatch *DRW_cache_circle_get(void); +struct GPUBatch *DRW_cache_square_get(void); +struct GPUBatch *DRW_cache_empty_sphere_get(void); +struct GPUBatch *DRW_cache_empty_cylinder_get(void); +struct GPUBatch *DRW_cache_empty_cone_get(void); +struct GPUBatch *DRW_cache_empty_capsule_cap_get(void); +struct GPUBatch *DRW_cache_empty_capsule_body_get(void); +struct GPUBatch *DRW_cache_arrows_get(void); +struct GPUBatch *DRW_cache_axis_names_get(void); +struct GPUBatch *DRW_cache_image_plane_get(void); +struct GPUBatch *DRW_cache_image_plane_wire_get(void); /* Force Field */ -struct Gwn_Batch *DRW_cache_field_wind_get(void); -struct Gwn_Batch *DRW_cache_field_force_get(void); -struct Gwn_Batch *DRW_cache_field_vortex_get(void); -struct Gwn_Batch *DRW_cache_field_tube_limit_get(void); -struct Gwn_Batch *DRW_cache_field_cone_limit_get(void); +struct GPUBatch *DRW_cache_field_wind_get(void); +struct GPUBatch *DRW_cache_field_force_get(void); +struct GPUBatch *DRW_cache_field_vortex_get(void); +struct GPUBatch *DRW_cache_field_tube_limit_get(void); +struct GPUBatch *DRW_cache_field_cone_limit_get(void); /* Lamps */ -struct Gwn_Batch *DRW_cache_lamp_get(void); -struct Gwn_Batch *DRW_cache_lamp_shadows_get(void); -struct Gwn_Batch *DRW_cache_lamp_sunrays_get(void); -struct Gwn_Batch *DRW_cache_lamp_area_square_get(void); -struct Gwn_Batch *DRW_cache_lamp_area_disk_get(void); -struct Gwn_Batch *DRW_cache_lamp_hemi_get(void); -struct Gwn_Batch *DRW_cache_lamp_spot_get(void); -struct Gwn_Batch *DRW_cache_lamp_spot_square_get(void); +struct GPUBatch *DRW_cache_lamp_get(void); +struct GPUBatch *DRW_cache_lamp_shadows_get(void); +struct GPUBatch *DRW_cache_lamp_sunrays_get(void); +struct GPUBatch *DRW_cache_lamp_area_square_get(void); +struct GPUBatch *DRW_cache_lamp_area_disk_get(void); +struct GPUBatch *DRW_cache_lamp_hemi_get(void); +struct GPUBatch *DRW_cache_lamp_spot_get(void); +struct GPUBatch *DRW_cache_lamp_spot_square_get(void); /* Camera */ -struct Gwn_Batch *DRW_cache_camera_get(void); -struct Gwn_Batch *DRW_cache_camera_frame_get(void); -struct Gwn_Batch *DRW_cache_camera_tria_get(void); +struct GPUBatch *DRW_cache_camera_get(void); +struct GPUBatch *DRW_cache_camera_frame_get(void); +struct GPUBatch *DRW_cache_camera_tria_get(void); /* Speaker */ -struct Gwn_Batch *DRW_cache_speaker_get(void); +struct GPUBatch *DRW_cache_speaker_get(void); /* Probe */ -struct Gwn_Batch *DRW_cache_lightprobe_cube_get(void); -struct Gwn_Batch *DRW_cache_lightprobe_grid_get(void); -struct Gwn_Batch *DRW_cache_lightprobe_planar_get(void); +struct GPUBatch *DRW_cache_lightprobe_cube_get(void); +struct GPUBatch *DRW_cache_lightprobe_grid_get(void); +struct GPUBatch *DRW_cache_lightprobe_planar_get(void); /* Bones */ -struct Gwn_Batch *DRW_cache_bone_octahedral_get(void); -struct Gwn_Batch *DRW_cache_bone_octahedral_wire_get(void); -struct Gwn_Batch *DRW_cache_bone_box_get(void); -struct Gwn_Batch *DRW_cache_bone_box_wire_get(void); -struct Gwn_Batch *DRW_cache_bone_envelope_solid_get(void); -struct Gwn_Batch *DRW_cache_bone_envelope_outline_get(void); -struct Gwn_Batch *DRW_cache_bone_envelope_head_wire_outline_get(void); -struct Gwn_Batch *DRW_cache_bone_point_get(void); -struct Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void); -struct Gwn_Batch *DRW_cache_bone_stick_get(void); -struct Gwn_Batch *DRW_cache_bone_arrows_get(void); +struct GPUBatch *DRW_cache_bone_octahedral_get(void); +struct GPUBatch *DRW_cache_bone_octahedral_wire_get(void); +struct GPUBatch *DRW_cache_bone_box_get(void); +struct GPUBatch *DRW_cache_bone_box_wire_get(void); +struct GPUBatch *DRW_cache_bone_envelope_solid_get(void); +struct GPUBatch *DRW_cache_bone_envelope_outline_get(void); +struct GPUBatch *DRW_cache_bone_envelope_head_wire_outline_get(void); +struct GPUBatch *DRW_cache_bone_point_get(void); +struct GPUBatch *DRW_cache_bone_point_wire_outline_get(void); +struct GPUBatch *DRW_cache_bone_stick_get(void); +struct GPUBatch *DRW_cache_bone_arrows_get(void); /* Meshes */ -struct Gwn_Batch *DRW_cache_mesh_surface_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_overlay_get(struct Object *ob); void DRW_cache_mesh_wire_overlay_get( struct Object *ob, - struct Gwn_Batch **r_tris, struct Gwn_Batch **r_ledges, struct Gwn_Batch **r_lverts); + struct GPUBatch **r_tris, struct GPUBatch **r_ledges, struct GPUBatch **r_lverts); void DRW_cache_mesh_normals_overlay_get( struct Object *ob, - struct Gwn_Batch **r_tris, struct Gwn_Batch **r_ledges, struct Gwn_Batch **r_lverts); -struct Gwn_Batch *DRW_cache_face_centers_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_wire_outline_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold); -struct Gwn_Batch *DRW_cache_mesh_surface_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_loose_edges_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_surface_weights_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_surface_verts_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_edges_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_verts_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel); -struct Gwn_Batch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_mesh_surface_shaded_get( + struct GPUBatch **r_tris, struct GPUBatch **r_ledges, struct GPUBatch **r_lverts); +struct GPUBatch *DRW_cache_face_centers_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_wire_outline_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold); +struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_loose_edges_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_verts_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_edges_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_verts_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel); +struct GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob); +struct GPUBatch **DRW_cache_mesh_surface_shaded_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count); -struct Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob); +struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob); void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob); /* Curve */ -struct Gwn_Batch *DRW_cache_curve_surface_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_curve_surface_shaded_get( +struct GPUBatch *DRW_cache_curve_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_curve_surface_shaded_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); -struct Gwn_Batch *DRW_cache_curve_surface_verts_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_curve_edge_wire_get(struct Object *ob); +struct GPUBatch *DRW_cache_curve_surface_verts_get(struct Object *ob); +struct GPUBatch *DRW_cache_curve_edge_wire_get(struct Object *ob); /* edit-mode */ -struct Gwn_Batch *DRW_cache_curve_edge_normal_get(struct Object *ob, float normal_size); -struct Gwn_Batch *DRW_cache_curve_edge_overlay_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_curve_vert_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_curve_edge_normal_get(struct Object *ob, float normal_size); +struct GPUBatch *DRW_cache_curve_edge_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_curve_vert_overlay_get(struct Object *ob); /* Font */ -struct Gwn_Batch *DRW_cache_text_edge_wire_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_text_surface_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_text_surface_shaded_get( +struct GPUBatch *DRW_cache_text_edge_wire_get(struct Object *ob); +struct GPUBatch *DRW_cache_text_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_text_surface_shaded_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); /* edit-mode */ -struct Gwn_Batch *DRW_cache_text_cursor_overlay_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_text_select_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_text_cursor_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_text_select_overlay_get(struct Object *ob); /* Surface */ -struct Gwn_Batch *DRW_cache_surf_surface_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_surf_surface_shaded_get( +struct GPUBatch *DRW_cache_surf_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_surf_surface_shaded_get( struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); /* Lattice */ -struct Gwn_Batch *DRW_cache_lattice_verts_get(struct Object *ob); -struct Gwn_Batch *DRW_cache_lattice_wire_get(struct Object *ob, bool use_weight); -struct Gwn_Batch *DRW_cache_lattice_vert_overlay_get(struct Object *ob); +struct GPUBatch *DRW_cache_lattice_verts_get(struct Object *ob); +struct GPUBatch *DRW_cache_lattice_wire_get(struct Object *ob, bool use_weight); +struct GPUBatch *DRW_cache_lattice_vert_overlay_get(struct Object *ob); /* Particles */ -struct Gwn_Batch *DRW_cache_particles_get_hair( +struct GPUBatch *DRW_cache_particles_get_hair( struct Object *object, struct ParticleSystem *psys, struct ModifierData *md); -struct Gwn_Batch *DRW_cache_particles_get_dots( +struct GPUBatch *DRW_cache_particles_get_dots( struct Object *object, struct ParticleSystem *psys); -struct Gwn_Batch *DRW_cache_particles_get_edit_strands( +struct GPUBatch *DRW_cache_particles_get_edit_strands( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_cache_particles_get_edit_inner_points( +struct GPUBatch *DRW_cache_particles_get_edit_inner_points( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_cache_particles_get_edit_tip_points( +struct GPUBatch *DRW_cache_particles_get_edit_tip_points( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_cache_particles_get_prim(int type); +struct GPUBatch *DRW_cache_particles_get_prim(int type); /* Metaball */ -struct Gwn_Batch *DRW_cache_mball_surface_get(struct Object *ob); -struct Gwn_Batch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); +struct GPUBatch *DRW_cache_mball_surface_get(struct Object *ob); +struct GPUBatch **DRW_cache_mball_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); #endif /* __DRAW_CACHE_H__ */ diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index 5773daf8e96..eeb7b1c41ee 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -29,9 +29,9 @@ struct CurveCache; struct GPUMaterial; struct GPUTexture; -struct Gwn_Batch; -struct Gwn_IndexBuf; -struct Gwn_VertBuf; +struct GPUBatch; +struct GPUIndexBuf; +struct GPUVertBuf; struct ListBase; struct ModifierData; struct ParticleSystem; @@ -59,71 +59,71 @@ void DRW_particle_batch_cache_dirty(struct ParticleSystem *psys, int mode); void DRW_particle_batch_cache_free(struct ParticleSystem *psys); /* Curve */ -struct Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu, struct CurveCache *ob_curve_cache); -struct Gwn_Batch *DRW_curve_batch_cache_get_normal_edge( +struct GPUBatch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu, struct CurveCache *ob_curve_cache); +struct GPUBatch *DRW_curve_batch_cache_get_normal_edge( struct Curve *cu, struct CurveCache *ob_curve_cache, float normal_size); -struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(struct Curve *cu); -struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(struct Curve *cu); +struct GPUBatch *DRW_curve_batch_cache_get_overlay_edges(struct Curve *cu); +struct GPUBatch *DRW_curve_batch_cache_get_overlay_verts(struct Curve *cu); -struct Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals( +struct GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals( struct Curve *cu, struct CurveCache *ob_curve_cache); -struct Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( +struct GPUBatch **DRW_curve_batch_cache_get_surface_shaded( struct Curve *cu, struct CurveCache *ob_curve_cache, struct GPUMaterial **gpumat_array, uint gpumat_array_len); /* Metaball */ -struct Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob); -struct Gwn_Batch **DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len); +struct GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob); +struct GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len); /* Curve (Font) */ -struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu); -struct Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(struct Curve *cu); +struct GPUBatch *DRW_curve_batch_cache_get_overlay_cursor(struct Curve *cu); +struct GPUBatch *DRW_curve_batch_cache_get_overlay_select(struct Curve *cu); /* DispList */ -struct Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(struct ListBase *lb); -struct Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(struct ListBase *lb); -struct Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material( +struct GPUVertBuf *DRW_displist_vertbuf_calc_pos_with_normals(struct ListBase *lb); +struct GPUIndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(struct ListBase *lb); +struct GPUIndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material( struct ListBase *lb, uint gpumat_array_len); -struct Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material( +struct GPUBatch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material( struct ListBase *lb, uint gpumat_array_len); /* Lattice */ -struct Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef); -struct Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt); -struct Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt); +struct GPUBatch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef); +struct GPUBatch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt); +struct GPUBatch *DRW_lattice_batch_cache_get_overlay_verts(struct Lattice *lt); /* Mesh */ -struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( +struct GPUBatch **DRW_mesh_batch_cache_get_surface_shaded( struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count); -struct Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel); -struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset); -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide); -struct Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me); -struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me); +struct GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel); +struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, int defgroup); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide); +struct GPUBatch *DRW_mesh_batch_cache_get_loose_edges_with_normals(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_nor(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me); /* edit-mesh selection (use generic function for faces) */ -struct Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset); -struct Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset); -struct Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset); +struct GPUBatch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset); +struct GPUBatch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset); +struct GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset); /* Object mode Wireframe overlays */ void DRW_mesh_batch_cache_get_wireframes_face_texbuf( struct Mesh *me, struct GPUTexture **verts_data, struct GPUTexture **face_indices, int *tri_count); @@ -131,15 +131,15 @@ void DRW_mesh_batch_cache_get_wireframes_face_texbuf( void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me); /* Particles */ -struct Gwn_Batch *DRW_particles_batch_cache_get_hair( +struct GPUBatch *DRW_particles_batch_cache_get_hair( struct Object *object, struct ParticleSystem *psys, struct ModifierData *md); -struct Gwn_Batch *DRW_particles_batch_cache_get_dots( +struct GPUBatch *DRW_particles_batch_cache_get_dots( struct Object *object, struct ParticleSystem *psys); -struct Gwn_Batch *DRW_particles_batch_cache_get_edit_strands( +struct GPUBatch *DRW_particles_batch_cache_get_edit_strands( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points( +struct GPUBatch *DRW_particles_batch_cache_get_edit_inner_points( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); -struct Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points( +struct GPUBatch *DRW_particles_batch_cache_get_edit_tip_points( struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit); #endif /* __DRAW_CACHE_IMPL_H__ */ diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 4de1dfd24f5..cfaa3c6914f 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -298,43 +298,43 @@ enum { }; /* ---------------------------------------------------------------------- */ -/* Curve Gwn_Batch Cache */ +/* Curve GPUBatch Cache */ typedef struct CurveBatchCache { /* center-line */ struct { - Gwn_VertBuf *verts; - Gwn_VertBuf *edges; - Gwn_Batch *batch; - Gwn_IndexBuf *elem; + GPUVertBuf *verts; + GPUVertBuf *edges; + GPUBatch *batch; + GPUIndexBuf *elem; } wire; /* normals */ struct { - Gwn_VertBuf *verts; - Gwn_VertBuf *edges; - Gwn_Batch *batch; - Gwn_IndexBuf *elem; + GPUVertBuf *verts; + GPUVertBuf *edges; + GPUBatch *batch; + GPUIndexBuf *elem; } normal; /* control handles and vertices */ struct { - Gwn_Batch *edges; - Gwn_Batch *verts; + GPUBatch *edges; + GPUBatch *verts; } overlay; struct { - Gwn_VertBuf *verts; - Gwn_IndexBuf *triangles_in_order; - Gwn_Batch **shaded_triangles; - Gwn_Batch *batch; + GPUVertBuf *verts; + GPUIndexBuf *triangles_in_order; + GPUBatch **shaded_triangles; + GPUBatch *batch; int mat_len; } surface; /* 3d text */ struct { - Gwn_Batch *select; - Gwn_Batch *cursor; + GPUBatch *select; + GPUBatch *cursor; } text; /* settings to determine if cache is invalid */ @@ -348,7 +348,7 @@ typedef struct CurveBatchCache { bool is_editmode; } CurveBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ static bool curve_batch_cache_valid(Curve *cu) { @@ -434,12 +434,12 @@ void DRW_curve_batch_cache_dirty(Curve *cu, int mode) break; case BKE_CURVE_BATCH_DIRTY_SELECT: /* editnurb */ - GWN_BATCH_DISCARD_SAFE(cache->overlay.verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay.edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay.verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay.edges); /* editfont */ - GWN_BATCH_DISCARD_SAFE(cache->text.select); - GWN_BATCH_DISCARD_SAFE(cache->text.cursor); + GPU_BATCH_DISCARD_SAFE(cache->text.select); + GPU_BATCH_DISCARD_SAFE(cache->text.cursor); break; default: BLI_assert(0); @@ -453,34 +453,34 @@ static void curve_batch_cache_clear(Curve *cu) return; } - GWN_BATCH_DISCARD_SAFE(cache->overlay.verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay.edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay.verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay.edges); - GWN_VERTBUF_DISCARD_SAFE(cache->surface.verts); - GWN_INDEXBUF_DISCARD_SAFE(cache->surface.triangles_in_order); + GPU_VERTBUF_DISCARD_SAFE(cache->surface.verts); + GPU_INDEXBUF_DISCARD_SAFE(cache->surface.triangles_in_order); if (cache->surface.shaded_triangles) { for (int i = 0; i < cache->surface.mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); } } MEM_SAFE_FREE(cache->surface.shaded_triangles); - GWN_BATCH_DISCARD_SAFE(cache->surface.batch); + GPU_BATCH_DISCARD_SAFE(cache->surface.batch); /* don't own vbo & elems */ - GWN_BATCH_DISCARD_SAFE(cache->wire.batch); - GWN_VERTBUF_DISCARD_SAFE(cache->wire.verts); - GWN_VERTBUF_DISCARD_SAFE(cache->wire.edges); - GWN_INDEXBUF_DISCARD_SAFE(cache->wire.elem); + GPU_BATCH_DISCARD_SAFE(cache->wire.batch); + GPU_VERTBUF_DISCARD_SAFE(cache->wire.verts); + GPU_VERTBUF_DISCARD_SAFE(cache->wire.edges); + GPU_INDEXBUF_DISCARD_SAFE(cache->wire.elem); /* don't own vbo & elems */ - GWN_BATCH_DISCARD_SAFE(cache->normal.batch); - GWN_VERTBUF_DISCARD_SAFE(cache->normal.verts); - GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges); - GWN_INDEXBUF_DISCARD_SAFE(cache->normal.elem); + GPU_BATCH_DISCARD_SAFE(cache->normal.batch); + GPU_VERTBUF_DISCARD_SAFE(cache->normal.verts); + GPU_VERTBUF_DISCARD_SAFE(cache->normal.edges); + GPU_INDEXBUF_DISCARD_SAFE(cache->normal.elem); /* 3d text */ - GWN_BATCH_DISCARD_SAFE(cache->text.cursor); - GWN_BATCH_DISCARD_SAFE(cache->text.select); + GPU_BATCH_DISCARD_SAFE(cache->text.cursor); + GPU_BATCH_DISCARD_SAFE(cache->text.select); } void DRW_curve_batch_cache_free(Curve *cu) @@ -494,30 +494,30 @@ void DRW_curve_batch_cache_free(Curve *cu) /** \name Private Curve Cache API * \{ */ -/* Gwn_Batch cache usage. */ -static Gwn_VertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, CurveBatchCache *cache) +/* GPUBatch cache usage. */ +static GPUVertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_WIRE); BLI_assert(rdata->ob_curve_cache != NULL); if (cache->wire.verts == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } const int vert_len = curve_render_data_wire_verts_len_get(rdata); - Gwn_VertBuf *vbo = cache->wire.verts = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_len); + GPUVertBuf *vbo = cache->wire.verts = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vert_len); int vbo_len_used = 0; for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) { if (bl->nr > 0) { const int i_end = vbo_len_used + bl->nr; for (const BevPoint *bevp = bl->bevpoints; vbo_len_used < i_end; vbo_len_used++, bevp++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bevp->vec); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bevp->vec); } } } @@ -527,7 +527,7 @@ static Gwn_VertBuf *curve_batch_cache_get_wire_verts(CurveRenderData *rdata, Cur return cache->wire.verts; } -static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUIndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_WIRE); BLI_assert(rdata->ob_curve_cache != NULL); @@ -537,8 +537,8 @@ static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cu const int edge_len = curve_render_data_wire_edges_len_get(rdata); int edge_len_used = 0; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); int i = 0; for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) { @@ -554,7 +554,7 @@ static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cu i += 1; } for (; i < i_end; i_prev = i++) { - GWN_indexbuf_add_line_verts(&elb, i_prev, i); + GPU_indexbuf_add_line_verts(&elb, i_prev, i); edge_len_used += 1; } } @@ -567,30 +567,30 @@ static Gwn_IndexBuf *curve_batch_cache_get_wire_edges(CurveRenderData *rdata, Cu BLI_assert(edge_len_used == edge_len); } - cache->wire.elem = GWN_indexbuf_build(&elb); + cache->wire.elem = GPU_indexbuf_build(&elb); } return cache->wire.elem; } -static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUVertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_NORMAL); BLI_assert(rdata->ob_curve_cache != NULL); if (cache->normal.verts == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } const int normal_len = curve_render_data_normal_len_get(rdata); const int vert_len = normal_len * 3; - Gwn_VertBuf *vbo = cache->normal.verts = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_len); + GPUVertBuf *vbo = cache->normal.verts = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vert_len); int vbo_len_used = 0; const BevList *bl; @@ -622,9 +622,9 @@ static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, C add_v3_v3(vec_a, bevp->vec); add_v3_v3(vec_b, bevp->vec); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_a); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, bevp->vec); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_b); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_a); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, bevp->vec); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, vec_b); bevp += skip + 1; nr -= skip; @@ -636,7 +636,7 @@ static Gwn_VertBuf *curve_batch_cache_get_normal_verts(CurveRenderData *rdata, C return cache->normal.verts; } -static Gwn_IndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUIndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_NORMAL); BLI_assert(rdata->ob_curve_cache != NULL); @@ -646,19 +646,19 @@ static Gwn_IndexBuf *curve_batch_cache_get_normal_edges(CurveRenderData *rdata, const int vert_len = normal_len * 3; const int edge_len = normal_len * 2; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); int vbo_len_used = 0; for (int i = 0; i < normal_len; i++) { - GWN_indexbuf_add_line_verts(&elb, vbo_len_used + 0, vbo_len_used + 1); - GWN_indexbuf_add_line_verts(&elb, vbo_len_used + 1, vbo_len_used + 2); + GPU_indexbuf_add_line_verts(&elb, vbo_len_used + 0, vbo_len_used + 1); + GPU_indexbuf_add_line_verts(&elb, vbo_len_used + 1, vbo_len_used + 2); vbo_len_used += 3; } BLI_assert(vbo_len_used == vert_len); - cache->normal.elem = GWN_indexbuf_build(&elb); + cache->normal.elem = GPU_indexbuf_build(&elb); } return cache->normal.elem; @@ -673,18 +673,18 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) CurveRenderData *rdata = curve_render_data_create(cu, NULL, options); if (cache->overlay.verts == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = curve_render_data_overlay_verts_len_get(rdata); int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); int i = 0; for (Nurb *nu = rdata->nurbs->first; nu; nu = nu->next) { if (nu->bezt) { @@ -697,16 +697,16 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) if (rdata->hide_handles) { vflag = (bezt->f2 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); vbo_len_used += 1; } else { for (int j = 0; j < 3; j++) { vflag = ((&bezt->f1)[j] & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j]); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j]); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); vbo_len_used += 1; } } @@ -721,8 +721,8 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) const bool is_active = (i == rdata->actvert); char vflag; vflag = (bp->f1 & SELECT) ? (is_active ? VFLAG_VERTEX_ACTIVE : VFLAG_VERTEX_SELECTED) : 0; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp->vec); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp->vec); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &vflag); vbo_len_used += 1; } i += 1; @@ -731,29 +731,29 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) i += nu->pntsu; } if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } - cache->overlay.verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->overlay.verts = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); } if ((cache->overlay.edges == NULL) && (rdata->hide_handles == false)) { /* Note: we could reference indices to vertices (above) */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int edge_len = curve_render_data_overlay_edges_len_get(rdata); const int vbo_len_capacity = edge_len * 2; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); int i = 0; for (Nurb *nu = rdata->nurbs->first; nu; nu = nu->next, i++) { const bool is_active_nurb = (i == cu->actnu); @@ -766,7 +766,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) for (int j = 0; j < 2; j += 1) { /* same vertex twice, only check different selection */ - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[1]); vbo_len_used += 1; col_id = (&bezt->h1)[j]; @@ -777,8 +777,8 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) col_id |= ACTIVE_NURB; } - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j * 2]); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bezt->vec[j * 2]); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id); vbo_len_used += 1; } } @@ -794,11 +794,11 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) col_id |= ACTIVE_NURB; } - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_prev->vec); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_prev->vec); vbo_len_used += 1; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_curr->vec); - GWN_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, bp_curr->vec); + GPU_vertbuf_attr_set(vbo, attr_id.data, vbo_len_used, &col_id); vbo_len_used += 1; } @@ -806,16 +806,16 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) } } if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } - cache->overlay.edges = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->overlay.edges = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } curve_render_data_free(rdata); } -static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUBatch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_SURFACE); if (cache->surface.batch == NULL) { @@ -827,8 +827,8 @@ static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, if (cache->surface.triangles_in_order == NULL) { cache->surface.triangles_in_order = DRW_displist_indexbuf_calc_triangles_in_order(lb); } - cache->surface.batch = GWN_batch_create( - GWN_PRIM_TRIS, cache->surface.verts, cache->surface.triangles_in_order); + cache->surface.batch = GPU_batch_create( + GPU_PRIM_TRIS, cache->surface.verts, cache->surface.triangles_in_order); } return cache->surface.batch; @@ -843,21 +843,21 @@ static Gwn_Batch *curve_batch_cache_get_pos_and_normals(CurveRenderData *rdata, * \{ */ -static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUBatch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_TEXT_SELECT); if (cache->text.select == NULL) { EditFont *ef = rdata->text.edit_font; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = ef->selboxes_len * 6; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); float box[4][3]; @@ -904,37 +904,37 @@ static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, C add_v2_v2(box[3], &sb->x); } - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[1]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[3]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[0]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[2]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[3]); } BLI_assert(vbo_len_used == vbo_len_capacity); - cache->text.select = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->text.select = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } return cache->text.select; } -static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, CurveBatchCache *cache) +static GPUBatch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, CurveBatchCache *cache) { BLI_assert(rdata->types & CU_DATATYPE_TEXT_SELECT); if (cache->text.cursor == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = 4; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); for (int i = 0; i < 4; i++) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]); } - cache->text.cursor = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->text.cursor = GPU_batch_create_ex(GPU_PRIM_TRI_FAN, vbo, NULL, GPU_BATCH_OWNS_VBO); } return cache->text.cursor; } @@ -946,7 +946,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, C /** \name Public Object/Curve API * \{ */ -Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache) +GPUBatch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_cache) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -954,8 +954,8 @@ Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_c /* create batch from Curve */ CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_WIRE); - cache->wire.batch = GWN_batch_create( - GWN_PRIM_LINES, + cache->wire.batch = GPU_batch_create( + GPU_PRIM_LINES, curve_batch_cache_get_wire_verts(rdata, cache), curve_batch_cache_get_wire_edges(rdata, cache)); @@ -964,15 +964,15 @@ Gwn_Batch *DRW_curve_batch_cache_get_wire_edge(Curve *cu, CurveCache *ob_curve_c return cache->wire.batch; } -Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cache, float normal_size) +GPUBatch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve_cache, float normal_size) { CurveBatchCache *cache = curve_batch_cache_get(cu); if (cache->normal.batch != NULL) { cache->normal_size = normal_size; if (cache->normal_size != normal_size) { - GWN_BATCH_DISCARD_SAFE(cache->normal.batch); - GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges); + GPU_BATCH_DISCARD_SAFE(cache->normal.batch); + GPU_VERTBUF_DISCARD_SAFE(cache->normal.edges); } } cache->normal_size = normal_size; @@ -981,8 +981,8 @@ Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve /* create batch from Curve */ CurveRenderData *rdata = curve_render_data_create(cu, ob_curve_cache, CU_DATATYPE_NORMAL); - cache->normal.batch = GWN_batch_create( - GWN_PRIM_LINES, + cache->normal.batch = GPU_batch_create( + GPU_PRIM_LINES, curve_batch_cache_get_normal_verts(rdata, cache), curve_batch_cache_get_normal_edges(rdata, cache)); @@ -992,7 +992,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve return cache->normal.batch; } -Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu) +GPUBatch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -1003,7 +1003,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_overlay_edges(Curve *cu) return cache->overlay.edges; } -Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu) +GPUBatch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -1014,7 +1014,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_overlay_verts(Curve *cu) return cache->overlay.verts; } -Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals( +GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals( struct Curve *cu, struct CurveCache *ob_curve_cache) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -1030,7 +1030,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_triangles_with_normals( return cache->surface.batch; } -Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( +GPUBatch **DRW_curve_batch_cache_get_surface_shaded( struct Curve *cu, struct CurveCache *ob_curve_cache, struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len) { @@ -1040,7 +1040,7 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( /* TODO: deduplicate code */ if (cache->surface.shaded_triangles) { for (int i = 0; i < cache->surface.mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->surface.shaded_triangles[i]); } } MEM_SAFE_FREE(cache->surface.shaded_triangles); @@ -1058,7 +1058,7 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( else { cache->surface.shaded_triangles = MEM_mallocN( sizeof(*cache->surface.shaded_triangles) * gpumat_array_len, __func__); - Gwn_IndexBuf **el = DRW_displist_indexbuf_calc_triangles_in_order_split_by_material( + GPUIndexBuf **el = DRW_displist_indexbuf_calc_triangles_in_order_split_by_material( lb, gpumat_array_len); if (cache->surface.verts == NULL) { @@ -1066,8 +1066,8 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( } for (int i = 0; i < gpumat_array_len; ++i) { - cache->surface.shaded_triangles[i] = GWN_batch_create_ex( - GWN_PRIM_TRIS, cache->surface.verts, el[i], GWN_BATCH_OWNS_INDEX); + cache->surface.shaded_triangles[i] = GPU_batch_create_ex( + GPU_PRIM_TRIS, cache->surface.verts, el[i], GPU_BATCH_OWNS_INDEX); } MEM_freeN(el); /* Save `el` in cache? */ @@ -1085,7 +1085,7 @@ Gwn_Batch **DRW_curve_batch_cache_get_surface_shaded( /** \name Public Object/Font API * \{ */ -Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(Curve *cu) +GPUBatch *DRW_curve_batch_cache_get_overlay_select(Curve *cu) { CurveBatchCache *cache = curve_batch_cache_get(cu); @@ -1100,7 +1100,7 @@ Gwn_Batch *DRW_curve_batch_cache_get_overlay_select(Curve *cu) return cache->text.select; } -Gwn_Batch *DRW_curve_batch_cache_get_overlay_cursor(Curve *cu) +GPUBatch *DRW_curve_batch_cache_get_overlay_cursor(Curve *cu) { CurveBatchCache *cache = curve_batch_cache_get(cu); diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index 8d187af0501..5ea0f6fb05d 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -87,49 +87,49 @@ static int curve_render_surface_tri_len_get(const ListBase *lb) return tri_len; } -static void displist_indexbufbuilder_set(Gwn_IndexBufBuilder *elb, const DispList *dl, const int ofs) +static void displist_indexbufbuilder_set(GPUIndexBufBuilder *elb, const DispList *dl, const int ofs) { if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { const int *idx = dl->index; if (dl->type == DL_INDEX3) { const int i_end = dl->parts; for (int i = 0; i < i_end; i++, idx += 3) { - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs); } } else if (dl->type == DL_SURF) { const int i_end = dl->totindex; for (int i = 0; i < i_end; i++, idx += 4) { - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs); - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[3] + ofs, idx[2] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[1] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[3] + ofs, idx[2] + ofs); } } else { BLI_assert(dl->type == DL_INDEX4); const int i_end = dl->parts; for (int i = 0; i < i_end; i++, idx += 4) { - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[1] + ofs, idx[2] + ofs); if (idx[2] != idx[3]) { - GWN_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs); + GPU_indexbuf_add_tri_verts(elb, idx[0] + ofs, idx[2] + ofs, idx[3] + ofs); } } } } } -Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) +GPUVertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, curve_render_surface_vert_len_get(lb)); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, curve_render_surface_vert_len_get(lb)); BKE_displist_normals_add(lb); @@ -141,9 +141,9 @@ Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) const float *fp_no = dl->nors; const int vbo_end = vbo_len_used + dl_vert_len(dl); while (vbo_len_used < vbo_end) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, fp_co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used, fp_co); if (fp_no) { - GWN_vertbuf_attr_set(vbo, attr_id.nor, vbo_len_used, fp_no); + GPU_vertbuf_attr_set(vbo, attr_id.nor, vbo_len_used, fp_no); if (ndata_is_single == false) { fp_no += 3; } @@ -157,13 +157,13 @@ Gwn_VertBuf *DRW_displist_vertbuf_calc_pos_with_normals(ListBase *lb) return vbo; } -Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb) +GPUIndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb) { const int tri_len = curve_render_surface_tri_len_get(lb); const int vert_len = curve_render_surface_vert_len_get(lb); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len); int ofs = 0; for (const DispList *dl = lb->first; dl; dl = dl->next) { @@ -171,14 +171,14 @@ Gwn_IndexBuf *DRW_displist_indexbuf_calc_triangles_in_order(ListBase *lb) ofs += dl_vert_len(dl); } - return GWN_indexbuf_build(&elb); + return GPU_indexbuf_build(&elb); } -Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(ListBase *lb, uint gpumat_array_len) +GPUIndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(ListBase *lb, uint gpumat_array_len) { - Gwn_IndexBuf **shaded_triangles_in_order = MEM_callocN( + GPUIndexBuf **shaded_triangles_in_order = MEM_callocN( sizeof(*shaded_triangles_in_order) * gpumat_array_len, __func__); - Gwn_IndexBufBuilder *elb = BLI_array_alloca(elb, gpumat_array_len); + GPUIndexBufBuilder *elb = BLI_array_alloca(elb, gpumat_array_len); const int tri_len = curve_render_surface_tri_len_get(lb); const int vert_len = curve_render_surface_vert_len_get(lb); @@ -186,7 +186,7 @@ Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(L /* Init each index buffer builder */ for (i = 0; i < gpumat_array_len; i++) { - GWN_indexbuf_init(&elb[i], GWN_PRIM_TRIS, tri_len, vert_len); + GPU_indexbuf_init(&elb[i], GPU_PRIM_TRIS, tri_len, vert_len); } /* calc each index buffer builder */ @@ -198,56 +198,56 @@ Gwn_IndexBuf **DRW_displist_indexbuf_calc_triangles_in_order_split_by_material(L /* build each indexbuf */ for (i = 0; i < gpumat_array_len; i++) { - shaded_triangles_in_order[i] = GWN_indexbuf_build(&elb[i]); + shaded_triangles_in_order[i] = GPU_indexbuf_build(&elb[i]); } return shaded_triangles_in_order; } static void displist_vertbuf_attr_set_tri_pos_normals_and_uv( - Gwn_VertBufRaw *pos_step, Gwn_VertBufRaw *nor_step, Gwn_VertBufRaw *uv_step, + GPUVertBufRaw *pos_step, GPUVertBufRaw *nor_step, GPUVertBufRaw *uv_step, const float v1[3], const float v2[3], const float v3[3], const float n1[3], const float n2[3], const float n3[3], const float uv1[2], const float uv2[2], const float uv3[2]) { - copy_v3_v3(GWN_vertbuf_raw_step(pos_step), v1); - copy_v3_v3(GWN_vertbuf_raw_step(nor_step), n1); - copy_v2_v2(GWN_vertbuf_raw_step(uv_step), uv1); + copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v1); + copy_v3_v3(GPU_vertbuf_raw_step(nor_step), n1); + copy_v2_v2(GPU_vertbuf_raw_step(uv_step), uv1); - copy_v3_v3(GWN_vertbuf_raw_step(pos_step), v2); - copy_v3_v3(GWN_vertbuf_raw_step(nor_step), n2); - copy_v2_v2(GWN_vertbuf_raw_step(uv_step), uv2); + copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v2); + copy_v3_v3(GPU_vertbuf_raw_step(nor_step), n2); + copy_v2_v2(GPU_vertbuf_raw_step(uv_step), uv2); - copy_v3_v3(GWN_vertbuf_raw_step(pos_step), v3); - copy_v3_v3(GWN_vertbuf_raw_step(nor_step), n3); - copy_v2_v2(GWN_vertbuf_raw_step(uv_step), uv3); + copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v3); + copy_v3_v3(GPU_vertbuf_raw_step(nor_step), n3); + copy_v2_v2(GPU_vertbuf_raw_step(uv_step), uv3); } -Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(ListBase *lb, uint gpumat_array_len) +GPUBatch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(ListBase *lb, uint gpumat_array_len) { - static Gwn_VertFormat shaded_triangles_format = { 0 }; + static GPUVertFormat shaded_triangles_format = { 0 }; static struct { uint pos, nor, uv; } attr_id; if (shaded_triangles_format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&shaded_triangles_format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&shaded_triangles_format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.uv = GWN_vertformat_attr_add(&shaded_triangles_format, "u", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&shaded_triangles_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&shaded_triangles_format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.uv = GPU_vertformat_attr_add(&shaded_triangles_format, "u", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_Batch **shaded_triangles = MEM_mallocN(sizeof(*shaded_triangles) * gpumat_array_len, __func__); + GPUBatch **shaded_triangles = MEM_mallocN(sizeof(*shaded_triangles) * gpumat_array_len, __func__); - Gwn_VertBuf **vbo = BLI_array_alloca(vbo, gpumat_array_len); + GPUVertBuf **vbo = BLI_array_alloca(vbo, gpumat_array_len); uint *vbo_len_capacity = BLI_array_alloca(vbo_len_capacity, gpumat_array_len); - Gwn_VertBufRaw *pos_step, *nor_step, *uv_step; + GPUVertBufRaw *pos_step, *nor_step, *uv_step; pos_step = BLI_array_alloca(pos_step, gpumat_array_len); nor_step = BLI_array_alloca(nor_step, gpumat_array_len); uv_step = BLI_array_alloca(uv_step, gpumat_array_len); /* Create each vertex buffer */ for (int i = 0; i < gpumat_array_len; i++) { - vbo[i] = GWN_vertbuf_create_with_format(&shaded_triangles_format); + vbo[i] = GPU_vertbuf_create_with_format(&shaded_triangles_format); vbo_len_capacity[i] = 0; } @@ -258,10 +258,10 @@ Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(Lis /* Alloc each vertex buffer and get each raw data */ for (int i = 0; i < gpumat_array_len; i++) { - GWN_vertbuf_data_alloc(vbo[i], vbo_len_capacity[i]); - GWN_vertbuf_attr_get_raw_data(vbo[i], attr_id.pos, &pos_step[i]); - GWN_vertbuf_attr_get_raw_data(vbo[i], attr_id.nor, &nor_step[i]); - GWN_vertbuf_attr_get_raw_data(vbo[i], attr_id.uv, &uv_step[i]); + GPU_vertbuf_data_alloc(vbo[i], vbo_len_capacity[i]); + GPU_vertbuf_attr_get_raw_data(vbo[i], attr_id.pos, &pos_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo[i], attr_id.nor, &nor_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo[i], attr_id.uv, &uv_step[i]); } BKE_displist_normals_add(lb); @@ -388,11 +388,11 @@ Gwn_Batch **DRW_displist_batch_calc_tri_pos_normals_and_uv_split_by_material(Lis } for (int i = 0; i < gpumat_array_len; i++) { - uint vbo_len_used = GWN_vertbuf_raw_used(&pos_step[i]); + uint vbo_len_used = GPU_vertbuf_raw_used(&pos_step[i]); if (vbo_len_capacity[i] != vbo_len_used) { - GWN_vertbuf_data_resize(vbo[i], vbo_len_used); + GPU_vertbuf_data_resize(vbo[i], vbo_len_used); } - shaded_triangles[i] = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo[i], NULL, GWN_BATCH_OWNS_VBO); + shaded_triangles[i] = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo[i], NULL, GPU_BATCH_OWNS_VBO); } return shaded_triangles; diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c index 99dce2d7343..d6acc4112d6 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.c +++ b/source/blender/draw/intern/draw_cache_impl_lattice.c @@ -279,16 +279,16 @@ enum { }; /* ---------------------------------------------------------------------- */ -/* Lattice Gwn_Batch Cache */ +/* Lattice GPUBatch Cache */ typedef struct LatticeBatchCache { - Gwn_VertBuf *pos; - Gwn_IndexBuf *edges; + GPUVertBuf *pos; + GPUIndexBuf *edges; - Gwn_Batch *all_verts; - Gwn_Batch *all_edges; + GPUBatch *all_verts; + GPUBatch *all_edges; - Gwn_Batch *overlay_verts; + GPUBatch *overlay_verts; /* settings to determine if cache is invalid */ bool is_dirty; @@ -301,7 +301,7 @@ typedef struct LatticeBatchCache { bool is_editmode; } LatticeBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ static bool lattice_batch_cache_valid(Lattice *lt) { @@ -373,7 +373,7 @@ void DRW_lattice_batch_cache_dirty(Lattice *lt, int mode) break; case BKE_LATTICE_BATCH_DIRTY_SELECT: /* TODO Separate Flag vbo */ - GWN_BATCH_DISCARD_SAFE(cache->overlay_verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay_verts); break; default: BLI_assert(0); @@ -387,12 +387,12 @@ static void lattice_batch_cache_clear(Lattice *lt) return; } - GWN_BATCH_DISCARD_SAFE(cache->all_verts); - GWN_BATCH_DISCARD_SAFE(cache->all_edges); - GWN_BATCH_DISCARD_SAFE(cache->overlay_verts); + GPU_BATCH_DISCARD_SAFE(cache->all_verts); + GPU_BATCH_DISCARD_SAFE(cache->all_edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay_verts); - GWN_VERTBUF_DISCARD_SAFE(cache->pos); - GWN_INDEXBUF_DISCARD_SAFE(cache->edges); + GPU_VERTBUF_DISCARD_SAFE(cache->pos); + GPU_INDEXBUF_DISCARD_SAFE(cache->edges); } void DRW_lattice_batch_cache_free(Lattice *lt) @@ -401,38 +401,38 @@ void DRW_lattice_batch_cache_free(Lattice *lt) MEM_SAFE_FREE(lt->batch_cache); } -/* Gwn_Batch cache usage. */ -static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache, +/* GPUBatch cache usage. */ +static GPUVertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, LatticeBatchCache *cache, bool use_weight, const int actdef) { BLI_assert(rdata->types & LR_DATATYPE_VERT); if (cache->pos == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, col; } attr_id; - GWN_vertformat_clear(&format); + GPU_vertformat_clear(&format); /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); if (use_weight) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); } const int vert_len = lattice_render_data_verts_len_get(rdata); - cache->pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->pos, vert_len); + cache->pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(cache->pos, vert_len); for (int i = 0; i < vert_len; ++i) { const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i); - GWN_vertbuf_attr_set(cache->pos, attr_id.pos, i, bp->vec); + GPU_vertbuf_attr_set(cache->pos, attr_id.pos, i, bp->vec); if (use_weight) { float w_col[4]; lattice_render_data_weight_col_get(rdata, i, actdef, w_col); - GWN_vertbuf_attr_set(cache->pos, attr_id.col, i, w_col); + GPU_vertbuf_attr_set(cache->pos, attr_id.col, i, w_col); } } } @@ -440,7 +440,7 @@ static Gwn_VertBuf *lattice_batch_cache_get_pos(LatticeRenderData *rdata, Lattic return cache->pos; } -static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, LatticeBatchCache *cache) +static GPUIndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, LatticeBatchCache *cache) { BLI_assert(rdata->types & (LR_DATATYPE_VERT | LR_DATATYPE_EDGE)); @@ -449,8 +449,8 @@ static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Lat const int edge_len = lattice_render_data_edges_len_get(rdata); int edge_len_real = 0; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); #define LATT_INDEX(u, v, w) \ ((((w) * rdata->dims.v_len + (v)) * rdata->dims.u_len) + (u)) @@ -463,17 +463,17 @@ static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Lat int uxt = (u == 0 || u == rdata->dims.u_len - 1); if (w && ((uxt || vxt) || !rdata->show_only_outside)) { - GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v, w - 1), LATT_INDEX(u, v, w)); + GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v, w - 1), LATT_INDEX(u, v, w)); BLI_assert(edge_len_real <= edge_len); edge_len_real++; } if (v && ((uxt || wxt) || !rdata->show_only_outside)) { - GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v - 1, w), LATT_INDEX(u, v, w)); + GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u, v - 1, w), LATT_INDEX(u, v, w)); BLI_assert(edge_len_real <= edge_len); edge_len_real++; } if (u && ((vxt || wxt) || !rdata->show_only_outside)) { - GWN_indexbuf_add_line_verts(&elb, LATT_INDEX(u - 1, v, w), LATT_INDEX(u, v, w)); + GPU_indexbuf_add_line_verts(&elb, LATT_INDEX(u - 1, v, w), LATT_INDEX(u, v, w)); BLI_assert(edge_len_real <= edge_len); edge_len_real++; } @@ -490,7 +490,7 @@ static Gwn_IndexBuf *lattice_batch_cache_get_edges(LatticeRenderData *rdata, Lat BLI_assert(edge_len_real == edge_len); } - cache->edges = GWN_indexbuf_build(&elb); + cache->edges = GPU_indexbuf_build(&elb); } return cache->edges; @@ -505,18 +505,18 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt) LatticeRenderData *rdata = lattice_render_data_create(lt, options); if (cache->overlay_verts == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_U8, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT); } const int vert_len = lattice_render_data_verts_len_get(rdata); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vert_len); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vert_len); for (int i = 0; i < vert_len; ++i) { const BPoint *bp = lattice_render_data_vert_bpoint(rdata, i); @@ -530,17 +530,17 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt) } } - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, bp->vec); - GWN_vertbuf_attr_set(vbo, attr_id.data, i, &vflag); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, bp->vec); + GPU_vertbuf_attr_set(vbo, attr_id.data, i, &vflag); } - cache->overlay_verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->overlay_verts = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); } lattice_render_data_free(rdata); } -Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, const int actdef) +GPUBatch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, const int actdef) { LatticeBatchCache *cache = lattice_batch_cache_get(lt); @@ -548,7 +548,7 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, c /* create batch from Lattice */ LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT | LR_DATATYPE_EDGE); - cache->all_edges = GWN_batch_create(GWN_PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache, use_weight, actdef), + cache->all_edges = GPU_batch_create(GPU_PRIM_LINES, lattice_batch_cache_get_pos(rdata, cache, use_weight, actdef), lattice_batch_cache_get_edges(rdata, cache)); lattice_render_data_free(rdata); @@ -557,14 +557,14 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_edges(Lattice *lt, bool use_weight, c return cache->all_edges; } -Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt) +GPUBatch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt) { LatticeBatchCache *cache = lattice_batch_cache_get(lt); if (cache->all_verts == NULL) { LatticeRenderData *rdata = lattice_render_data_create(lt, LR_DATATYPE_VERT); - cache->all_verts = GWN_batch_create(GWN_PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache, false, -1), NULL); + cache->all_verts = GPU_batch_create(GPU_PRIM_POINTS, lattice_batch_cache_get_pos(rdata, cache, false, -1), NULL); lattice_render_data_free(rdata); } @@ -572,7 +572,7 @@ Gwn_Batch *DRW_lattice_batch_cache_get_all_verts(Lattice *lt) return cache->all_verts; } -Gwn_Batch *DRW_lattice_batch_cache_get_overlay_verts(Lattice *lt) +GPUBatch *DRW_lattice_batch_cache_get_overlay_verts(Lattice *lt) { LatticeBatchCache *cache = lattice_batch_cache_get(lt); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 7a72622cb9e..5ca1c65054c 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -202,8 +202,8 @@ typedef struct MeshRenderData { float (*poly_normals)[3]; float (*vert_weight_color)[3]; char (*vert_color)[3]; - Gwn_PackedNormal *poly_normals_pack; - Gwn_PackedNormal *vert_normals_pack; + GPUPackedNormal *poly_normals_pack; + GPUPackedNormal *vert_normals_pack; bool *edge_select_bool; } MeshRenderData; @@ -952,7 +952,7 @@ static int mesh_render_data_polys_len_get(const MeshRenderData *rdata) /** Ensure #MeshRenderData.poly_normals_pack */ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata) { - Gwn_PackedNormal *pnors_pack = rdata->poly_normals_pack; + GPUPackedNormal *pnors_pack = rdata->poly_normals_pack; if (pnors_pack == NULL) { if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; @@ -962,7 +962,7 @@ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata) pnors_pack = rdata->poly_normals_pack = MEM_mallocN(sizeof(*pnors_pack) * rdata->poly_len, __func__); BM_ITER_MESH_INDEX(efa, &fiter, bm, BM_FACES_OF_MESH, i) { - pnors_pack[i] = GWN_normal_convert_i10_v3(efa->no); + pnors_pack[i] = GPU_normal_convert_i10_v3(efa->no); } } else { @@ -977,7 +977,7 @@ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata) pnors_pack = rdata->poly_normals_pack = MEM_mallocN(sizeof(*pnors_pack) * rdata->poly_len, __func__); for (int i = 0; i < rdata->poly_len; i++) { - pnors_pack[i] = GWN_normal_convert_i10_v3(pnors[i]); + pnors_pack[i] = GPU_normal_convert_i10_v3(pnors[i]); } } } @@ -986,7 +986,7 @@ static void mesh_render_data_ensure_poly_normals_pack(MeshRenderData *rdata) /** Ensure #MeshRenderData.vert_normals_pack */ static void mesh_render_data_ensure_vert_normals_pack(MeshRenderData *rdata) { - Gwn_PackedNormal *vnors_pack = rdata->vert_normals_pack; + GPUPackedNormal *vnors_pack = rdata->vert_normals_pack; if (vnors_pack == NULL) { if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; @@ -996,7 +996,7 @@ static void mesh_render_data_ensure_vert_normals_pack(MeshRenderData *rdata) vnors_pack = rdata->vert_normals_pack = MEM_mallocN(sizeof(*vnors_pack) * rdata->vert_len, __func__); BM_ITER_MESH_INDEX(eve, &viter, bm, BM_VERT, i) { - vnors_pack[i] = GWN_normal_convert_i10_v3(eve->no); + vnors_pack[i] = GPU_normal_convert_i10_v3(eve->no); } } else { @@ -1413,7 +1413,7 @@ static uchar mesh_render_data_vertex_flag(MeshRenderData *rdata, const BMVert *e } static void add_overlay_tri( - MeshRenderData *rdata, Gwn_VertBuf *vbo_pos, Gwn_VertBuf *vbo_nor, Gwn_VertBuf *vbo_data, + MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data, const uint pos_id, const uint vnor_id, const uint lnor_id, const uint data_id, const BMLoop **bm_looptri, const int base_vert_idx) { @@ -1426,24 +1426,24 @@ static void add_overlay_tri( for (uint i = 0; i < 3; i++) { int vidx = BM_elem_index_get(bm_looptri[i]->v); const float *pos = rdata->edit_data->vertexCos[vidx]; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); } } else { for (uint i = 0; i < 3; i++) { const float *pos = bm_looptri[i]->v->co; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); } } } if (vbo_nor) { /* TODO real loop normal */ - Gwn_PackedNormal lnor = GWN_normal_convert_i10_v3(bm_looptri[0]->f->no); + GPUPackedNormal lnor = GPU_normal_convert_i10_v3(bm_looptri[0]->f->no); for (uint i = 0; i < 3; i++) { - Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(bm_looptri[i]->v->no); - GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor); - GWN_vertbuf_attr_set(vbo_nor, lnor_id, base_vert_idx + i, &lnor); + GPUPackedNormal vnor = GPU_normal_convert_i10_v3(bm_looptri[i]->v->no); + GPU_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor); + GPU_vertbuf_attr_set(vbo_nor, lnor_id, base_vert_idx + i, &lnor); } } @@ -1457,7 +1457,7 @@ static void add_overlay_tri( mesh_render_data_edge_flag(rdata, bm_looptri[i_next]->e, &eattr); } eattr.v_flag = fflag | vflag; - GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr); + GPU_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr); i_prev = i; i = i_next; @@ -1466,7 +1466,7 @@ static void add_overlay_tri( } static void add_overlay_loose_edge( - MeshRenderData *rdata, Gwn_VertBuf *vbo_pos, Gwn_VertBuf *vbo_nor, Gwn_VertBuf *vbo_data, + MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data, const uint pos_id, const uint vnor_id, const uint data_id, const BMEdge *eed, const int base_vert_idx) { @@ -1476,21 +1476,21 @@ static void add_overlay_loose_edge( for (uint i = 0; i < 2; i++) { int vidx = BM_elem_index_get((&eed->v1)[i]); const float *pos = rdata->edit_data->vertexCos[vidx]; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); } } else { for (int i = 0; i < 2; ++i) { const float *pos = (&eed->v1)[i]->co; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx + i, pos); } } } if (vbo_nor) { for (int i = 0; i < 2; ++i) { - Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3((&eed->v1)[i]->no); - GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor); + GPUPackedNormal vnor = GPU_normal_convert_i10_v3((&eed->v1)[i]->no); + GPU_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx + i, &vnor); } } @@ -1499,13 +1499,13 @@ static void add_overlay_loose_edge( mesh_render_data_edge_flag(rdata, eed, &eattr); for (int i = 0; i < 2; ++i) { eattr.v_flag = mesh_render_data_vertex_flag(rdata, (&eed->v1)[i]); - GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr); + GPU_vertbuf_attr_set(vbo_data, data_id, base_vert_idx + i, &eattr); } } } static void add_overlay_loose_vert( - MeshRenderData *rdata, Gwn_VertBuf *vbo_pos, Gwn_VertBuf *vbo_nor, Gwn_VertBuf *vbo_data, + MeshRenderData *rdata, GPUVertBuf *vbo_pos, GPUVertBuf *vbo_nor, GPUVertBuf *vbo_data, const uint pos_id, const uint vnor_id, const uint data_id, const BMVert *eve, const int base_vert_idx) { @@ -1514,23 +1514,23 @@ static void add_overlay_loose_vert( if (rdata->edit_data && rdata->edit_data->vertexCos) { int vidx = BM_elem_index_get(eve); const float *pos = rdata->edit_data->vertexCos[vidx]; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos); } else { const float *pos = eve->co; - GWN_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos); + GPU_vertbuf_attr_set(vbo_pos, pos_id, base_vert_idx, pos); } } if (vbo_nor) { - Gwn_PackedNormal vnor = GWN_normal_convert_i10_v3(eve->no); - GWN_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx, &vnor); + GPUPackedNormal vnor = GPU_normal_convert_i10_v3(eve->no); + GPU_vertbuf_attr_set(vbo_nor, vnor_id, base_vert_idx, &vnor); } if (vbo_data) { uchar vflag[4] = {0, 0, 0, 0}; vflag[0] = mesh_render_data_vertex_flag(rdata, eve); - GWN_vertbuf_attr_set(vbo_data, data_id, base_vert_idx, vflag); + GPU_vertbuf_attr_set(vbo_data, data_id, base_vert_idx, vflag); } } @@ -1539,96 +1539,96 @@ static void add_overlay_loose_vert( /* ---------------------------------------------------------------------- */ -/** \name Mesh Gwn_Batch Cache +/** \name Mesh GPUBatch Cache * \{ */ typedef struct MeshBatchCache { - Gwn_VertBuf *pos_in_order; - Gwn_IndexBuf *edges_in_order; - Gwn_IndexBuf *edges_adjacency; /* Store edges with adjacent vertices. */ - Gwn_IndexBuf *triangles_in_order; - Gwn_IndexBuf *ledges_in_order; + GPUVertBuf *pos_in_order; + GPUIndexBuf *edges_in_order; + GPUIndexBuf *edges_adjacency; /* Store edges with adjacent vertices. */ + GPUIndexBuf *triangles_in_order; + GPUIndexBuf *ledges_in_order; GPUTexture *pos_in_order_tx; /* Depending on pos_in_order */ - Gwn_Batch *all_verts; - Gwn_Batch *all_edges; - Gwn_Batch *all_triangles; + GPUBatch *all_verts; + GPUBatch *all_edges; + GPUBatch *all_triangles; - Gwn_VertBuf *pos_with_normals; - Gwn_VertBuf *tri_aligned_uv; /* Active UV layer (mloopuv) */ + GPUVertBuf *pos_with_normals; + GPUVertBuf *tri_aligned_uv; /* Active UV layer (mloopuv) */ /** * Other uses are all positions or loose elements. * This stores all visible elements, needed for selection. */ - Gwn_VertBuf *ed_fcenter_pos_with_nor_and_sel; - Gwn_VertBuf *ed_edge_pos; - Gwn_VertBuf *ed_vert_pos; + GPUVertBuf *ed_fcenter_pos_with_nor_and_sel; + GPUVertBuf *ed_edge_pos; + GPUVertBuf *ed_vert_pos; - Gwn_Batch *triangles_with_normals; - Gwn_Batch *ledges_with_normals; + GPUBatch *triangles_with_normals; + GPUBatch *ledges_with_normals; /* Skip hidden (depending on paint select mode) */ - Gwn_Batch *triangles_with_weights; - Gwn_Batch *triangles_with_vert_colors; + GPUBatch *triangles_with_weights; + GPUBatch *triangles_with_vert_colors; /* Always skip hidden */ - Gwn_Batch *triangles_with_select_mask; - Gwn_Batch *triangles_with_select_id; + GPUBatch *triangles_with_select_mask; + GPUBatch *triangles_with_select_id; uint triangles_with_select_id_offset; - Gwn_Batch *facedot_with_select_id; /* shares vbo with 'overlay_facedots' */ - Gwn_Batch *edges_with_select_id; - Gwn_Batch *verts_with_select_id; + GPUBatch *facedot_with_select_id; /* shares vbo with 'overlay_facedots' */ + GPUBatch *edges_with_select_id; + GPUBatch *verts_with_select_id; uint facedot_with_select_id_offset; uint edges_with_select_id_offset; uint verts_with_select_id_offset; - Gwn_Batch *points_with_normals; - Gwn_Batch *fancy_edges; /* owns its vertex buffer (not shared) */ + GPUBatch *points_with_normals; + GPUBatch *fancy_edges; /* owns its vertex buffer (not shared) */ - Gwn_Batch *edge_detection; + GPUBatch *edge_detection; - Gwn_VertBuf *edges_face_overlay; + GPUVertBuf *edges_face_overlay; GPUTexture *edges_face_overlay_tx; int edges_face_overlay_tri_count; /* Number of tri in edges_face_overlay(_adj)_tx */ /* Maybe have shaded_triangles_data split into pos_nor and uv_tangent * to minimize data transfer for skinned mesh. */ - Gwn_VertFormat shaded_triangles_format; - Gwn_VertBuf *shaded_triangles_data; - Gwn_IndexBuf **shaded_triangles_in_order; - Gwn_Batch **shaded_triangles; + GPUVertFormat shaded_triangles_format; + GPUVertBuf *shaded_triangles_data; + GPUIndexBuf **shaded_triangles_in_order; + GPUBatch **shaded_triangles; /* Texture Paint.*/ /* per-texture batch */ - Gwn_Batch **texpaint_triangles; - Gwn_Batch *texpaint_triangles_single; + GPUBatch **texpaint_triangles; + GPUBatch *texpaint_triangles_single; /* Edit Cage Mesh buffers */ - Gwn_VertBuf *ed_tri_pos; - Gwn_VertBuf *ed_tri_nor; /* LoopNor, VertNor */ - Gwn_VertBuf *ed_tri_data; + GPUVertBuf *ed_tri_pos; + GPUVertBuf *ed_tri_nor; /* LoopNor, VertNor */ + GPUVertBuf *ed_tri_data; - Gwn_VertBuf *ed_ledge_pos; - Gwn_VertBuf *ed_ledge_nor; /* VertNor */ - Gwn_VertBuf *ed_ledge_data; + GPUVertBuf *ed_ledge_pos; + GPUVertBuf *ed_ledge_nor; /* VertNor */ + GPUVertBuf *ed_ledge_data; - Gwn_VertBuf *ed_lvert_pos; - Gwn_VertBuf *ed_lvert_nor; /* VertNor */ - Gwn_VertBuf *ed_lvert_data; + GPUVertBuf *ed_lvert_pos; + GPUVertBuf *ed_lvert_nor; /* VertNor */ + GPUVertBuf *ed_lvert_data; - Gwn_Batch *overlay_triangles; - Gwn_Batch *overlay_triangles_nor; /* GWN_PRIM_POINTS */ - Gwn_Batch *overlay_loose_edges; - Gwn_Batch *overlay_loose_edges_nor; /* GWN_PRIM_POINTS */ - Gwn_Batch *overlay_loose_verts; - Gwn_Batch *overlay_facedots; + GPUBatch *overlay_triangles; + GPUBatch *overlay_triangles_nor; /* GPU_PRIM_POINTS */ + GPUBatch *overlay_loose_edges; + GPUBatch *overlay_loose_edges_nor; /* GPU_PRIM_POINTS */ + GPUBatch *overlay_loose_verts; + GPUBatch *overlay_facedots; - Gwn_Batch *overlay_weight_faces; - Gwn_Batch *overlay_weight_verts; - Gwn_Batch *overlay_paint_edges; + GPUBatch *overlay_weight_faces; + GPUBatch *overlay_weight_verts; + GPUBatch *overlay_paint_edges; /* arrays of bool uniform names (and value) that will be use to * set srgb conversion for auto attribs.*/ @@ -1653,7 +1653,7 @@ typedef struct MeshBatchCache { bool is_manifold; } MeshBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ static bool mesh_batch_cache_valid(Mesh *me) { @@ -1742,21 +1742,21 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode) cache->is_maybe_dirty = true; break; case BKE_MESH_BATCH_DIRTY_SELECT: - GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); /* Contains select flag */ - GWN_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos); - - GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges); - GWN_BATCH_DISCARD_SAFE(cache->overlay_facedots); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); /* Contains select flag */ + GPU_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos); + + GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay_facedots); /* Edit mode selection. */ - GWN_BATCH_DISCARD_SAFE(cache->facedot_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->facedot_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id); break; case BKE_MESH_BATCH_DIRTY_ALL: cache->is_dirty = true; @@ -1777,7 +1777,7 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode) /** * This only clear the batches associated to the given vertex buffer. **/ -static void mesh_batch_cache_clear_selective(Mesh *me, Gwn_VertBuf *vert) +static void mesh_batch_cache_clear_selective(Mesh *me, GPUVertBuf *vert) { MeshBatchCache *cache = me->runtime.batch_cache; if (!cache) { @@ -1787,26 +1787,26 @@ static void mesh_batch_cache_clear_selective(Mesh *me, Gwn_VertBuf *vert) BLI_assert(vert != NULL); if (cache->pos_with_normals == vert) { - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_weights); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask); - GWN_BATCH_DISCARD_SAFE(cache->points_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->ledges_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask); + GPU_BATCH_DISCARD_SAFE(cache->points_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->ledges_with_normals); if (cache->shaded_triangles) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]); } } MEM_SAFE_FREE(cache->shaded_triangles); if (cache->texpaint_triangles) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]); } } MEM_SAFE_FREE(cache->texpaint_triangles); - GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single); + GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single); } /* TODO: add the other ones if needed. */ else { @@ -1822,69 +1822,69 @@ static void mesh_batch_cache_clear(Mesh *me) return; } - GWN_BATCH_DISCARD_SAFE(cache->all_verts); - GWN_BATCH_DISCARD_SAFE(cache->all_edges); - GWN_BATCH_DISCARD_SAFE(cache->all_triangles); + GPU_BATCH_DISCARD_SAFE(cache->all_verts); + GPU_BATCH_DISCARD_SAFE(cache->all_edges); + GPU_BATCH_DISCARD_SAFE(cache->all_triangles); - GWN_VERTBUF_DISCARD_SAFE(cache->pos_in_order); + GPU_VERTBUF_DISCARD_SAFE(cache->pos_in_order); DRW_TEXTURE_FREE_SAFE(cache->pos_in_order_tx); - GWN_INDEXBUF_DISCARD_SAFE(cache->edges_in_order); - GWN_INDEXBUF_DISCARD_SAFE(cache->triangles_in_order); - GWN_INDEXBUF_DISCARD_SAFE(cache->ledges_in_order); - - GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_nor); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_tri_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_nor); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_nor); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data); - GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles); - GWN_BATCH_DISCARD_SAFE(cache->overlay_triangles_nor); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges); - GWN_BATCH_DISCARD_SAFE(cache->overlay_loose_edges_nor); - - GWN_BATCH_DISCARD_SAFE(cache->overlay_weight_faces); - GWN_BATCH_DISCARD_SAFE(cache->overlay_weight_verts); - GWN_BATCH_DISCARD_SAFE(cache->overlay_paint_edges); - GWN_BATCH_DISCARD_SAFE(cache->overlay_facedots); - - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->points_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->ledges_with_normals); - GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_normals); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_weights); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); - GWN_VERTBUF_DISCARD_SAFE(cache->tri_aligned_uv); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos); - GWN_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask); - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->facedot_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id); - GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id); - - GWN_BATCH_DISCARD_SAFE(cache->fancy_edges); - - GWN_INDEXBUF_DISCARD_SAFE(cache->edges_adjacency); - GWN_BATCH_DISCARD_SAFE(cache->edge_detection); - - GWN_VERTBUF_DISCARD_SAFE(cache->edges_face_overlay); + GPU_INDEXBUF_DISCARD_SAFE(cache->edges_in_order); + GPU_INDEXBUF_DISCARD_SAFE(cache->triangles_in_order); + GPU_INDEXBUF_DISCARD_SAFE(cache->ledges_in_order); + + GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_nor); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_tri_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_nor); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_ledge_data); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_nor); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_lvert_data); + GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles); + GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles_nor); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges_nor); + + GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_faces); + GPU_BATCH_DISCARD_SAFE(cache->overlay_weight_verts); + GPU_BATCH_DISCARD_SAFE(cache->overlay_paint_edges); + GPU_BATCH_DISCARD_SAFE(cache->overlay_facedots); + + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->points_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->ledges_with_normals); + GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); + GPU_VERTBUF_DISCARD_SAFE(cache->tri_aligned_uv); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_fcenter_pos_with_nor_and_sel); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_edge_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->ed_vert_pos); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_mask); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->facedot_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id); + + GPU_BATCH_DISCARD_SAFE(cache->fancy_edges); + + GPU_INDEXBUF_DISCARD_SAFE(cache->edges_adjacency); + GPU_BATCH_DISCARD_SAFE(cache->edge_detection); + + GPU_VERTBUF_DISCARD_SAFE(cache->edges_face_overlay); DRW_TEXTURE_FREE_SAFE(cache->edges_face_overlay_tx); - GWN_VERTBUF_DISCARD_SAFE(cache->shaded_triangles_data); + GPU_VERTBUF_DISCARD_SAFE(cache->shaded_triangles_data); if (cache->shaded_triangles_in_order) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_INDEXBUF_DISCARD_SAFE(cache->shaded_triangles_in_order[i]); + GPU_INDEXBUF_DISCARD_SAFE(cache->shaded_triangles_in_order[i]); } } if (cache->shaded_triangles) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->shaded_triangles[i]); } } @@ -1896,12 +1896,12 @@ static void mesh_batch_cache_clear(Mesh *me) if (cache->texpaint_triangles) { for (int i = 0; i < cache->mat_len; ++i) { - GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]); + GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles[i]); } } MEM_SAFE_FREE(cache->texpaint_triangles); - GWN_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single); + GPU_BATCH_DISCARD_SAFE(cache->texpaint_triangles_single); } @@ -1911,9 +1911,9 @@ void DRW_mesh_batch_cache_free(Mesh *me) MEM_SAFE_FREE(me->runtime.batch_cache); } -/* Gwn_Batch cache usage. */ +/* GPUBatch cache usage. */ -static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUVertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); #define USE_COMP_MESH_DATA @@ -1928,9 +1928,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, return NULL; } - Gwn_VertFormat *format = &cache->shaded_triangles_format; + GPUVertFormat *format = &cache->shaded_triangles_format; - GWN_vertformat_clear(format); + GPU_vertformat_clear(format); /* initialize vertex format */ uint *layers_combined_id = BLI_array_alloca(layers_combined_id, layers_combined_len); @@ -1968,14 +1968,14 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, /* UV */ const char *attrib_name = mesh_render_data_uv_layer_uuid_get(rdata, i); #if defined(USE_COMP_MESH_DATA) && 0 /* these are clamped. Maybe use them as an option in the future */ - uv_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_I16, 2, GWN_FETCH_INT_TO_FLOAT_UNIT); + uv_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT); #else - uv_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uv_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); #endif /* Auto Name */ attrib_name = mesh_render_data_uv_auto_layer_uuid_get(rdata, i); - GWN_vertformat_alias_add(format, attrib_name); + GPU_vertformat_alias_add(format, attrib_name); /* +1 include null terminator. */ auto_ofs += 1 + BLI_snprintf_rlen( @@ -1983,7 +1983,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, cache->auto_layer_is_srgb[auto_id++] = 0; /* tag as not srgb */ if (i == rdata->cd.layers.uv_active) { - GWN_vertformat_alias_add(format, "u"); + GPU_vertformat_alias_add(format, "u"); } } @@ -1993,25 +1993,25 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, * That may cause some problem but I could not make it to fail (fclem) */ #ifdef USE_COMP_MESH_DATA /* Tangents need more precision than 10_10_10 */ - tangent_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + tangent_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); #else - tangent_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + tangent_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_F32, 3, GPU_FETCH_FLOAT); #endif if (i == rdata->cd.layers.tangent_active) { - GWN_vertformat_alias_add(format, "t"); + GPU_vertformat_alias_add(format, "t"); } } for (uint i = 0; i < vcol_len; i++) { const char *attrib_name = mesh_render_data_vcol_layer_uuid_get(rdata, i); - vcol_id[i] = GWN_vertformat_attr_add(format, attrib_name, GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + vcol_id[i] = GPU_vertformat_attr_add(format, attrib_name, GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); /* Auto layer */ if (rdata->cd.layers.auto_vcol[i]) { attrib_name = mesh_render_data_vcol_auto_layer_uuid_get(rdata, i); - GWN_vertformat_alias_add(format, attrib_name); + GPU_vertformat_alias_add(format, attrib_name); /* +1 include null terminator. */ auto_ofs += 1 + BLI_snprintf_rlen( @@ -2020,23 +2020,23 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, } if (i == rdata->cd.layers.vcol_active) { - GWN_vertformat_alias_add(format, "c"); + GPU_vertformat_alias_add(format, "c"); } } const uint tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_VertBuf *vbo = cache->shaded_triangles_data = GWN_vertbuf_create_with_format(format); + GPUVertBuf *vbo = cache->shaded_triangles_data = GPU_vertbuf_create_with_format(format); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw *layers_combined_step = BLI_array_alloca(layers_combined_step, layers_combined_len); + GPUVertBufRaw *layers_combined_step = BLI_array_alloca(layers_combined_step, layers_combined_len); - Gwn_VertBufRaw *uv_step = layers_combined_step; - Gwn_VertBufRaw *tangent_step = uv_step + uv_len; - Gwn_VertBufRaw *vcol_step = tangent_step + tangent_len; + GPUVertBufRaw *uv_step = layers_combined_step; + GPUVertBufRaw *tangent_step = uv_step + uv_len; + GPUVertBufRaw *vcol_step = tangent_step + tangent_len; /* Not needed, just for sanity. */ if (uv_len == 0) { uv_step = NULL; } @@ -2044,16 +2044,16 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, if (vcol_len == 0) { vcol_step = NULL; } for (uint i = 0; i < uv_len; i++) { - GWN_vertbuf_attr_get_raw_data(vbo, uv_id[i], &uv_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo, uv_id[i], &uv_step[i]); } for (uint i = 0; i < tangent_len; i++) { - GWN_vertbuf_attr_get_raw_data(vbo, tangent_id[i], &tangent_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo, tangent_id[i], &tangent_step[i]); } for (uint i = 0; i < vcol_len; i++) { - GWN_vertbuf_attr_get_raw_data(vbo, vcol_id[i], &vcol_step[i]); + GPU_vertbuf_attr_get_raw_data(vbo, vcol_id[i], &vcol_step[i]); } - /* TODO deduplicate all verts and make use of Gwn_IndexBuf in + /* TODO deduplicate all verts and make use of GPUIndexBuf in * mesh_batch_cache_get_triangles_in_order_split_by_material. */ if (rdata->edit_bmesh) { for (uint i = 0; i < tri_len; i++) { @@ -2066,7 +2066,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, const uint layer_offset = rdata->cd.offset.uv[j]; for (uint t = 0; t < 3; t++) { const float *elem = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(bm_looptri[t], layer_offset))->uv; - copy_v2_v2(GWN_vertbuf_raw_step(&uv_step[j]), elem); + copy_v2_v2(GPU_vertbuf_raw_step(&uv_step[j]), elem); } } /* TANGENTs */ @@ -2074,7 +2074,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, float (*layer_data)[4] = rdata->cd.layers.tangent[j]; for (uint t = 0; t < 3; t++) { const float *elem = layer_data[BM_elem_index_get(bm_looptri[t])]; - normal_float_to_short_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem); + normal_float_to_short_v3(GPU_vertbuf_raw_step(&tangent_step[j]), elem); } } /* VCOLs */ @@ -2082,7 +2082,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, const uint layer_offset = rdata->cd.offset.vcol[j]; for (uint t = 0; t < 3; t++) { const uchar *elem = &((MLoopCol *)BM_ELEM_CD_GET_VOID_P(bm_looptri[t], layer_offset))->r; - copy_v3_v3_uchar(GWN_vertbuf_raw_step(&vcol_step[j]), elem); + copy_v3_v3_uchar(GPU_vertbuf_raw_step(&vcol_step[j]), elem); } } } @@ -2096,7 +2096,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, const MLoopUV *layer_data = rdata->cd.layers.uv[j]; for (uint t = 0; t < 3; t++) { const float *elem = layer_data[mlt->tri[t]].uv; - copy_v2_v2(GWN_vertbuf_raw_step(&uv_step[j]), elem); + copy_v2_v2(GPU_vertbuf_raw_step(&uv_step[j]), elem); } } /* TANGENTs */ @@ -2105,9 +2105,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, for (uint t = 0; t < 3; t++) { const float *elem = layer_data[mlt->tri[t]]; #ifdef USE_COMP_MESH_DATA - normal_float_to_short_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem); + normal_float_to_short_v3(GPU_vertbuf_raw_step(&tangent_step[j]), elem); #else - copy_v3_v3(GWN_vertbuf_raw_step(&tangent_step[j]), elem); + copy_v3_v3(GPU_vertbuf_raw_step(&tangent_step[j]), elem); #endif } } @@ -2116,25 +2116,25 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, const MLoopCol *layer_data = rdata->cd.layers.vcol[j]; for (uint t = 0; t < 3; t++) { const uchar *elem = &layer_data[mlt->tri[t]].r; - copy_v3_v3_uchar(GWN_vertbuf_raw_step(&vcol_step[j]), elem); + copy_v3_v3_uchar(GPU_vertbuf_raw_step(&vcol_step[j]), elem); } } } } - vbo_len_used = GWN_vertbuf_raw_used(&layers_combined_step[0]); + vbo_len_used = GPU_vertbuf_raw_used(&layers_combined_step[0]); #ifndef NDEBUG /* Check all layers are write aligned. */ if (layers_combined_len > 1) { for (uint i = 1; i < layers_combined_len; i++) { - BLI_assert(vbo_len_used == GWN_vertbuf_raw_used(&layers_combined_step[i])); + BLI_assert(vbo_len_used == GPU_vertbuf_raw_used(&layers_combined_step[i])); } } #endif if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } @@ -2143,7 +2143,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata, return cache->shaded_triangles_data; } -static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( +static GPUVertBuf *mesh_batch_cache_get_tri_uv_active( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPUV)); @@ -2157,19 +2157,19 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( uint vidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint uv; } attr_id; if (format.attr_len == 0) { - attr_id.uv = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.uv = GPU_vertformat_attr_add(&format, "uv", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_VertBuf *vbo = cache->tri_aligned_uv = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = cache->tri_aligned_uv = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); BMEditMesh *embm = rdata->edit_bmesh; @@ -2189,7 +2189,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( const int index = BM_elem_index_get(loop); if (index != -1) { const float *elem = ((MLoopUV *)BM_ELEM_CD_GET_VOID_P(loop, layer_offset))->uv; - GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, elem); + GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, elem); } } } @@ -2198,9 +2198,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( /* object mode */ for (int i = 0; i < tri_len; i++) { const MLoopTri *mlt = &rdata->mlooptri[i]; - GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[0]].uv); - GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[1]].uv); - GWN_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[2]].uv); + GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[0]].uv); + GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[1]].uv); + GPU_vertbuf_attr_set(vbo, attr_id.uv, vidx++, mloopuv[mlt->tri[2]].uv); } } @@ -2213,36 +2213,36 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_uv_active( return cache->tri_aligned_uv; } -static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( +static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( MeshRenderData *rdata, const bool use_hide, - Gwn_VertBuf **r_vbo) + GPUVertBuf **r_vbo) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); if (*r_vbo == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_VertBuf *vbo = *r_vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = *r_vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step, nor_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.nor, &nor_step); + GPUVertBufRaw pos_step, nor_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.nor, &nor_step); float (*lnors)[3] = rdata->loop_normals; if (rdata->edit_bmesh) { - Gwn_PackedNormal *pnors_pack, *vnors_pack; + GPUPackedNormal *pnors_pack, *vnors_pack; if (lnors == NULL) { mesh_render_data_ensure_poly_normals_pack(rdata); @@ -2264,18 +2264,18 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( if (lnors) { for (uint t = 0; t < 3; t++) { const float *nor = lnors[BM_elem_index_get(bm_looptri[t])]; - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_v3(nor); + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = GPU_normal_convert_i10_v3(nor); } } else if (BM_elem_flag_test(bm_face, BM_ELEM_SMOOTH)) { for (uint t = 0; t < 3; t++) { - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = vnors_pack[BM_elem_index_get(bm_looptri[t]->v)]; + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = vnors_pack[BM_elem_index_get(bm_looptri[t]->v)]; } } else { - const Gwn_PackedNormal *snor_pack = &pnors_pack[BM_elem_index_get(bm_face)]; + const GPUPackedNormal *snor_pack = &pnors_pack[BM_elem_index_get(bm_face)]; for (uint t = 0; t < 3; t++) { - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = *snor_pack; + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = *snor_pack; } } @@ -2284,12 +2284,12 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( for (uint t = 0; t < 3; t++) { int vidx = BM_elem_index_get(bm_looptri[t]->v); const float *pos = rdata->edit_data->vertexCos[vidx]; - copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), pos); + copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), pos); } } else { for (uint t = 0; t < 3; t++) { - copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), bm_looptri[t]->v->co); + copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), bm_looptri[t]->v->co); } } } @@ -2317,85 +2317,85 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( if (lnors) { for (uint t = 0; t < 3; t++) { const float *nor = lnors[mlt->tri[t]]; - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_v3(nor); + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = GPU_normal_convert_i10_v3(nor); } } else if (mp->flag & ME_SMOOTH) { for (uint t = 0; t < 3; t++) { const MVert *mv = &rdata->mvert[vtri[t]]; - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = GWN_normal_convert_i10_s3(mv->no); + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = GPU_normal_convert_i10_s3(mv->no); } } else { - const Gwn_PackedNormal *pnors_pack = &rdata->poly_normals_pack[mlt->poly]; + const GPUPackedNormal *pnors_pack = &rdata->poly_normals_pack[mlt->poly]; for (uint t = 0; t < 3; t++) { - *((Gwn_PackedNormal *)GWN_vertbuf_raw_step(&nor_step)) = *pnors_pack; + *((GPUPackedNormal *)GPU_vertbuf_raw_step(&nor_step)) = *pnors_pack; } } for (uint t = 0; t < 3; t++) { const MVert *mv = &rdata->mvert[vtri[t]]; - copy_v3_v3(GWN_vertbuf_raw_step(&pos_step), mv->co); + copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), mv->co); } } } - vbo_len_used = GWN_vertbuf_raw_used(&pos_step); - BLI_assert(vbo_len_used == GWN_vertbuf_raw_used(&nor_step)); + vbo_len_used = GPU_vertbuf_raw_used(&pos_step); + BLI_assert(vbo_len_used == GPU_vertbuf_raw_used(&nor_step)); if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return *r_vbo; } -static Gwn_VertBuf *mesh_batch_cache_get_tri_pos_and_normals( +static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals( MeshRenderData *rdata, MeshBatchCache *cache) { return mesh_batch_cache_get_tri_pos_and_normals_ex( rdata, false, &cache->pos_with_normals); } -static Gwn_VertBuf *mesh_create_tri_pos_and_normals_visible_only( +static GPUVertBuf *mesh_create_tri_pos_and_normals_visible_only( MeshRenderData *rdata) { - Gwn_VertBuf *vbo_dummy = NULL; + GPUVertBuf *vbo_dummy = NULL; return mesh_batch_cache_get_tri_pos_and_normals_ex( rdata, true, &vbo_dummy); } -static Gwn_VertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag( +static GPUVertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); if (cache->ed_fcenter_pos_with_nor_and_sel == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.data = GWN_vertformat_attr_add(&format, "norAndFlag", GWN_COMP_I10, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.data = GPU_vertformat_attr_add(&format, "norAndFlag", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); } const int vbo_len_capacity = mesh_render_data_polys_len_get(rdata); int vidx = 0; - Gwn_VertBuf *vbo = cache->ed_fcenter_pos_with_nor_and_sel = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBuf *vbo = cache->ed_fcenter_pos_with_nor_and_sel = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); for (int i = 0; i < vbo_len_capacity; ++i) { float pcenter[3], pnor[3]; bool selected = false; if (mesh_render_data_pnors_pcenter_select_get(rdata, i, pnor, pcenter, &selected)) { - Gwn_PackedNormal nor = { .x = 0, .y = 0, .z = -511 }; - nor = GWN_normal_convert_i10_v3(pnor); + GPUPackedNormal nor = { .x = 0, .y = 0, .z = -511 }; + nor = GPU_normal_convert_i10_v3(pnor); nor.w = selected ? 1 : 0; - GWN_vertbuf_attr_set(vbo, attr_id.data, vidx, &nor); + GPU_vertbuf_attr_set(vbo, attr_id.data, vidx, &nor); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, pcenter); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, pcenter); vidx += 1; } @@ -2403,30 +2403,30 @@ static Gwn_VertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag( const int vbo_len_used = vidx; BLI_assert(vbo_len_used <= vbo_len_capacity); if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return cache->ed_fcenter_pos_with_nor_and_sel; } -static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( +static GPUVertBuf *mesh_batch_cache_get_edges_visible( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE)); if (cache->ed_edge_pos == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } const int vbo_len_capacity = mesh_render_data_edges_len_get(rdata) * 2; int vidx = 0; - Gwn_VertBuf *vbo = cache->ed_edge_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBuf *vbo = cache->ed_edge_pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; BMIter iter; @@ -2434,9 +2434,9 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v1->co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v1->co); vidx += 1; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v2->co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, eed->v2->co); vidx += 1; } } @@ -2447,7 +2447,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( } const int vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } UNUSED_VARS_NDEBUG(vbo_len_used); } @@ -2455,23 +2455,23 @@ static Gwn_VertBuf *mesh_batch_cache_get_edges_visible( return cache->ed_edge_pos; } -static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( +static GPUVertBuf *mesh_batch_cache_get_verts_visible( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); if (cache->ed_vert_pos == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, data; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata); uint vidx = 0; - Gwn_VertBuf *vbo = cache->ed_vert_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPUVertBuf *vbo = cache->ed_vert_pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; BMIter iter; @@ -2479,7 +2479,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, eve->co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, eve->co); vidx += 1; } } @@ -2488,14 +2488,14 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( for (int i = 0; i < vbo_len_capacity; i++) { const MVert *mv = &rdata->mvert[i]; if (!(mv->flag & ME_HIDE)) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx, mv->co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx, mv->co); vidx += 1; } } } const uint vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } UNUSED_VARS_NDEBUG(vbo_len_used); @@ -2504,24 +2504,24 @@ static Gwn_VertBuf *mesh_batch_cache_get_verts_visible( return cache->ed_vert_pos; } -static Gwn_VertBuf *mesh_create_facedot_select_id( +static GPUVertBuf *mesh_create_facedot_select_id( MeshRenderData *rdata, uint select_id_offset) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT); } const int vbo_len_capacity = mesh_render_data_polys_len_get(rdata); int vidx = 0; - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); uint select_index = select_id_offset; if (rdata->edit_bmesh) { @@ -2533,7 +2533,7 @@ static Gwn_VertBuf *mesh_create_facedot_select_id( if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { int select_id; GPU_select_index_get(select_index, &select_id); - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; } select_index += 1; @@ -2545,31 +2545,31 @@ static Gwn_VertBuf *mesh_create_facedot_select_id( } const int vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_edges_select_id( +static GPUVertBuf *mesh_create_edges_select_id( MeshRenderData *rdata, uint select_id_offset) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT); } const int vbo_len_capacity = mesh_render_data_edges_len_get(rdata) * 2; int vidx = 0; - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); uint select_index = select_id_offset; if (rdata->edit_bmesh) { @@ -2581,9 +2581,9 @@ static Gwn_VertBuf *mesh_create_edges_select_id( if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { int select_id; GPU_select_index_get(select_index, &select_id); - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; } select_index += 1; @@ -2595,31 +2595,31 @@ static Gwn_VertBuf *mesh_create_edges_select_id( } const int vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_verts_select_id( +static GPUVertBuf *mesh_create_verts_select_id( MeshRenderData *rdata, uint select_id_offset) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT); } const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata); int vidx = 0; - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); uint select_index = select_id_offset; if (rdata->edit_bmesh) { @@ -2631,7 +2631,7 @@ static Gwn_VertBuf *mesh_create_verts_select_id( if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { int select_id; GPU_select_index_get(select_index, &select_id); - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; } select_index += 1; @@ -2643,7 +2643,7 @@ static Gwn_VertBuf *mesh_create_verts_select_id( if (!(mv->flag & ME_HIDE)) { int select_id; GPU_select_index_get(select_index, &select_id); - GWN_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, vidx, &select_id); vidx += 1; } select_index += 1; @@ -2651,36 +2651,36 @@ static Gwn_VertBuf *mesh_create_verts_select_id( } const int vbo_len_used = vidx; if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_tri_weights( +static GPUVertBuf *mesh_create_tri_weights( MeshRenderData *rdata, bool use_hide, int defgroup) { BLI_assert( rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_DVERT)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const int tri_len = mesh_render_data_looptri_len_get(rdata); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); mesh_render_data_ensure_vert_weight_color(rdata, defgroup); const float (*vert_weight_color)[3] = rdata->vert_weight_color; @@ -2692,7 +2692,7 @@ static Gwn_VertBuf *mesh_create_tri_weights( if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { const int v_index = BM_elem_index_get(ltri[tri_corner]->v); - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]); } } } @@ -2703,7 +2703,7 @@ static Gwn_VertBuf *mesh_create_tri_weights( if (!(use_hide && (rdata->mpoly[mlt->poly].flag & ME_HIDE))) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { const uint v_index = rdata->mloop[mlt->tri[tri_corner]].v; - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_weight_color[v_index]); } } } @@ -2711,36 +2711,36 @@ static Gwn_VertBuf *mesh_create_tri_weights( vbo_len_used = cidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_tri_vert_colors( +static GPUVertBuf *mesh_create_tri_vert_colors( MeshRenderData *rdata, bool use_hide) { BLI_assert( rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } const int tri_len = mesh_render_data_looptri_len_get(rdata); - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const uint vbo_len_capacity = tri_len * 3; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); mesh_render_data_ensure_vert_color(rdata); const char (*vert_color)[3] = rdata->vert_color; @@ -2752,7 +2752,7 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors( if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { const int l_index = BM_elem_index_get(ltri[tri_corner]); - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]); } } } @@ -2763,7 +2763,7 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors( if (!(use_hide && (rdata->mpoly[mlt->poly].flag & ME_HIDE))) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { const uint l_index = mlt->tri[tri_corner]; - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, vert_color[l_index]); } } } @@ -2771,37 +2771,37 @@ static Gwn_VertBuf *mesh_create_tri_vert_colors( const uint vbo_len_used = cidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_create_tri_select_id( +static GPUVertBuf *mesh_create_tri_select_id( MeshRenderData *rdata, bool use_hide, uint select_id_offset) { BLI_assert( rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY)); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint col; } attr_id; if (format.attr_len == 0) { - attr_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_I32, 1, GPU_FETCH_INT); } const int tri_len = mesh_render_data_looptri_len_get(rdata); - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = tri_len * 3; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (rdata->edit_bmesh) { for (int i = 0; i < tri_len; i++) { @@ -2812,7 +2812,7 @@ static Gwn_VertBuf *mesh_create_tri_select_id( int select_id; GPU_select_index_get(poly_index + select_id_offset, &select_id); for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id); } } } @@ -2825,7 +2825,7 @@ static Gwn_VertBuf *mesh_create_tri_select_id( int select_id; GPU_select_index_get(poly_index + select_id_offset, &select_id); for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id); + GPU_vertbuf_attr_set(vbo, attr_id.col, cidx++, &select_id); } } } @@ -2833,29 +2833,29 @@ static Gwn_VertBuf *mesh_create_tri_select_id( vbo_len_used = cidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( +static GPUVertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); if (cache->pos_in_order == NULL) { - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, nor; } attr_id; if (format.attr_len == 0) { /* Normal is padded so that the vbo can be used as a buffer texture */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); } - Gwn_VertBuf *vbo = cache->pos_in_order = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = cache->pos_in_order = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = mesh_render_data_verts_len_get(rdata); - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (rdata->edit_bmesh) { BMesh *bm = rdata->edit_bmesh->bm; @@ -2867,15 +2867,15 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( static short no_short[4]; normal_float_to_short_v3(no_short, eve->no); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, eve->co); - GWN_vertbuf_attr_set(vbo, attr_id.nor, i, no_short); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, eve->co); + GPU_vertbuf_attr_set(vbo, attr_id.nor, i, no_short); } BLI_assert(i == vbo_len_capacity); } else { for (int i = 0; i < vbo_len_capacity; ++i) { - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->mvert[i].co); - GWN_vertbuf_attr_set(vbo, attr_id.nor, i, rdata->mvert[i].no); /* XXX actually reading 4 shorts */ + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->mvert[i].co); + GPU_vertbuf_attr_set(vbo, attr_id.nor, i, rdata->mvert[i].no); /* XXX actually reading 4 shorts */ } } } @@ -2883,26 +2883,26 @@ static Gwn_VertBuf *mesh_batch_cache_get_vert_pos_and_nor_in_order( return cache->pos_in_order; } -static Gwn_VertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id) +static GPUVertFormat *edit_mesh_overlay_pos_format(uint *r_pos_id) { - static Gwn_VertFormat format_pos = { 0 }; + static GPUVertFormat format_pos = { 0 }; static uint pos_id; if (format_pos.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format_pos, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format_pos, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } *r_pos_id = pos_id; return &format_pos; } -static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lnor_id) +static GPUVertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lnor_id) { - static Gwn_VertFormat format_nor = { 0 }; - static Gwn_VertFormat format_nor_loop = { 0 }; + static GPUVertFormat format_nor = { 0 }; + static GPUVertFormat format_nor_loop = { 0 }; static uint vnor_id, vnor_loop_id, lnor_id; if (format_nor.attr_len == 0) { - vnor_id = GWN_vertformat_attr_add(&format_nor, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - vnor_loop_id = GWN_vertformat_attr_add(&format_nor_loop, "vnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - lnor_id = GWN_vertformat_attr_add(&format_nor_loop, "lnor", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + vnor_id = GPU_vertformat_attr_add(&format_nor, "vnor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); + vnor_loop_id = GPU_vertformat_attr_add(&format_nor_loop, "vnor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); + lnor_id = GPU_vertformat_attr_add(&format_nor_loop, "lnor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } if (r_lnor_id) { *r_vnor_id = vnor_loop_id; @@ -2915,12 +2915,12 @@ static Gwn_VertFormat *edit_mesh_overlay_nor_format(uint *r_vnor_id, uint *r_lno } } -static Gwn_VertFormat *edit_mesh_overlay_data_format(uint *r_data_id) +static GPUVertFormat *edit_mesh_overlay_data_format(uint *r_data_id) { - static Gwn_VertFormat format_flag = { 0 }; + static GPUVertFormat format_flag = { 0 }; static uint data_id; if (format_flag.attr_len == 0) { - data_id = GWN_vertformat_attr_add(&format_flag, "data", GWN_COMP_U8, 4, GWN_FETCH_INT); + data_id = GPU_vertformat_attr_add(&format_flag, "data", GPU_COMP_U8, 4, GPU_FETCH_INT); } *r_data_id = data_id; return &format_flag; @@ -2937,28 +2937,28 @@ static void mesh_batch_cache_create_overlay_tri_buffers( int vbo_len_used = 0; /* Positions */ - Gwn_VertBuf *vbo_pos = NULL; + GPUVertBuf *vbo_pos = NULL; static struct { uint pos, vnor, lnor, data; } attr_id; if (cache->ed_tri_pos == NULL) { vbo_pos = cache->ed_tri_pos = - GWN_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); - GWN_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); + GPU_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); } /* Normals */ - Gwn_VertBuf *vbo_nor = NULL; + GPUVertBuf *vbo_nor = NULL; if (cache->ed_tri_nor == NULL) { vbo_nor = cache->ed_tri_nor = - GWN_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, &attr_id.lnor)); - GWN_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, &attr_id.lnor)); + GPU_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); } /* Data */ - Gwn_VertBuf *vbo_data = NULL; + GPUVertBuf *vbo_data = NULL; if (cache->ed_tri_data == NULL) { vbo_data = cache->ed_tri_data = - GWN_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); - GWN_vertbuf_data_alloc(vbo_data, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); + GPU_vertbuf_data_alloc(vbo_data, vbo_len_capacity); } for (int i = 0; i < tri_len; i++) { @@ -2976,13 +2976,13 @@ static void mesh_batch_cache_create_overlay_tri_buffers( /* Finish */ if (vbo_len_used != vbo_len_capacity) { if (vbo_pos != NULL) { - GWN_vertbuf_data_resize(vbo_pos, vbo_len_used); + GPU_vertbuf_data_resize(vbo_pos, vbo_len_used); } if (vbo_nor != NULL) { - GWN_vertbuf_data_resize(vbo_nor, vbo_len_used); + GPU_vertbuf_data_resize(vbo_nor, vbo_len_used); } if (vbo_data != NULL) { - GWN_vertbuf_data_resize(vbo_data, vbo_len_used); + GPU_vertbuf_data_resize(vbo_data, vbo_len_used); } } } @@ -2998,28 +2998,28 @@ static void mesh_batch_cache_create_overlay_ledge_buffers( int vbo_len_used = 0; /* Positions */ - Gwn_VertBuf *vbo_pos = NULL; + GPUVertBuf *vbo_pos = NULL; static struct { uint pos, vnor, data; } attr_id; if (cache->ed_ledge_pos == NULL) { vbo_pos = cache->ed_ledge_pos = - GWN_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); - GWN_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); + GPU_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); } /* Normals */ - Gwn_VertBuf *vbo_nor = NULL; + GPUVertBuf *vbo_nor = NULL; if (cache->ed_ledge_nor == NULL) { vbo_nor = cache->ed_ledge_nor = - GWN_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL)); - GWN_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL)); + GPU_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); } /* Data */ - Gwn_VertBuf *vbo_data = NULL; + GPUVertBuf *vbo_data = NULL; if (cache->ed_ledge_data == NULL) { vbo_data = cache->ed_ledge_data = - GWN_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); - GWN_vertbuf_data_alloc(vbo_data, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); + GPU_vertbuf_data_alloc(vbo_data, vbo_len_capacity); } if (rdata->edit_bmesh) { @@ -3039,13 +3039,13 @@ static void mesh_batch_cache_create_overlay_ledge_buffers( /* Finish */ if (vbo_len_used != vbo_len_capacity) { if (vbo_pos != NULL) { - GWN_vertbuf_data_resize(vbo_pos, vbo_len_used); + GPU_vertbuf_data_resize(vbo_pos, vbo_len_used); } if (vbo_nor != NULL) { - GWN_vertbuf_data_resize(vbo_nor, vbo_len_used); + GPU_vertbuf_data_resize(vbo_nor, vbo_len_used); } if (vbo_data != NULL) { - GWN_vertbuf_data_resize(vbo_data, vbo_len_used); + GPU_vertbuf_data_resize(vbo_data, vbo_len_used); } } } @@ -3064,27 +3064,27 @@ static void mesh_batch_cache_create_overlay_lvert_buffers( static struct { uint pos, vnor, data; } attr_id; /* Positions */ - Gwn_VertBuf *vbo_pos = NULL; + GPUVertBuf *vbo_pos = NULL; if (cache->ed_lvert_pos == NULL) { vbo_pos = cache->ed_lvert_pos = - GWN_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); - GWN_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_pos_format(&attr_id.pos)); + GPU_vertbuf_data_alloc(vbo_pos, vbo_len_capacity); } /* Normals */ - Gwn_VertBuf *vbo_nor = NULL; + GPUVertBuf *vbo_nor = NULL; if (cache->ed_lvert_nor == NULL) { vbo_nor = cache->ed_lvert_nor = - GWN_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL)); - GWN_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_nor_format(&attr_id.vnor, NULL)); + GPU_vertbuf_data_alloc(vbo_nor, vbo_len_capacity); } /* Data */ - Gwn_VertBuf *vbo_data = NULL; + GPUVertBuf *vbo_data = NULL; if (cache->ed_lvert_data == NULL) { vbo_data = cache->ed_lvert_data = - GWN_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); - GWN_vertbuf_data_alloc(vbo_data, vbo_len_capacity); + GPU_vertbuf_create_with_format(edit_mesh_overlay_data_format(&attr_id.data)); + GPU_vertbuf_data_alloc(vbo_data, vbo_len_capacity); } for (uint i = 0; i < lvert_len; i++) { @@ -3099,19 +3099,19 @@ static void mesh_batch_cache_create_overlay_lvert_buffers( /* Finish */ if (vbo_len_used != vbo_len_capacity) { if (vbo_pos != NULL) { - GWN_vertbuf_data_resize(vbo_pos, vbo_len_used); + GPU_vertbuf_data_resize(vbo_pos, vbo_len_used); } if (vbo_nor != NULL) { - GWN_vertbuf_data_resize(vbo_nor, vbo_len_used); + GPU_vertbuf_data_resize(vbo_nor, vbo_len_used); } if (vbo_data != NULL) { - GWN_vertbuf_data_resize(vbo_data, vbo_len_used); + GPU_vertbuf_data_resize(vbo_data, vbo_len_used); } } } /* Position */ -static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_pos( +static GPUVertBuf *mesh_batch_cache_get_edit_tri_pos( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3123,7 +3123,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_pos( return cache->ed_tri_pos; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_pos( +static GPUVertBuf *mesh_batch_cache_get_edit_ledge_pos( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3135,7 +3135,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_pos( return cache->ed_ledge_pos; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_pos( +static GPUVertBuf *mesh_batch_cache_get_edit_lvert_pos( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3148,7 +3148,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_pos( } /* Normal */ -static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_nor( +static GPUVertBuf *mesh_batch_cache_get_edit_tri_nor( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3160,7 +3160,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_nor( return cache->ed_tri_nor; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_nor( +static GPUVertBuf *mesh_batch_cache_get_edit_ledge_nor( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3172,7 +3172,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_nor( return cache->ed_ledge_nor; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_nor( +static GPUVertBuf *mesh_batch_cache_get_edit_lvert_nor( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3185,7 +3185,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_nor( } /* Data */ -static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_data( +static GPUVertBuf *mesh_batch_cache_get_edit_tri_data( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3197,7 +3197,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_tri_data( return cache->ed_tri_data; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_data( +static GPUVertBuf *mesh_batch_cache_get_edit_ledge_data( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3209,7 +3209,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_ledge_data( return cache->ed_ledge_data; } -static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_data( +static GPUVertBuf *mesh_batch_cache_get_edit_lvert_data( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & MR_DATATYPE_VERT); @@ -3221,7 +3221,7 @@ static Gwn_VertBuf *mesh_batch_cache_get_edit_lvert_data( return cache->ed_lvert_data; } -static Gwn_IndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUIndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE)); @@ -3229,8 +3229,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, const int vert_len = mesh_render_data_verts_len_get(rdata); const int edge_len = mesh_render_data_edges_len_get(rdata); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); BLI_assert(rdata->types & MR_DATATYPE_EDGE); @@ -3240,24 +3240,24 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_in_order(MeshRenderData *rdata, BMEdge *eed; BM_ITER_MESH(eed, &eiter, bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - GWN_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2)); + GPU_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2)); } } } else { const MEdge *ed = rdata->medge; for (int i = 0; i < edge_len; i++, ed++) { - GWN_indexbuf_add_line_verts(&elb, ed->v1, ed->v2); + GPU_indexbuf_add_line_verts(&elb, ed->v1, ed->v2); } } - cache->edges_in_order = GWN_indexbuf_build(&elb); + cache->edges_in_order = GPU_indexbuf_build(&elb); } return cache->edges_in_order; } #define NO_EDGE INT_MAX -static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUIndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI)); @@ -3268,8 +3268,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, cache->is_manifold = true; /* Allocate max but only used indices are sent to GPU. */ - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, tri_len * 3, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, tri_len * 3, vert_len); EdgeHash *eh = BLI_edgehash_new_ex(__func__, tri_len * 3); /* Create edges for each pair of triangles sharing an edge. */ @@ -3310,12 +3310,12 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, if (inv_opposite == inv_indices) { /* Don't share edge if triangles have non matching winding. */ - GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0); - GWN_indexbuf_add_line_adj_verts(&elb, v_opposite, v1, v2, v_opposite); + GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0); + GPU_indexbuf_add_line_adj_verts(&elb, v_opposite, v1, v2, v_opposite); cache->is_manifold = false; } else { - GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v_opposite); + GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v_opposite); } } } @@ -3336,13 +3336,13 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata, if (v_data < 0) { /* inv_opposite */ SWAP(uint, v1, v2); } - GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0); + GPU_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0); cache->is_manifold = false; } BLI_edgehashIterator_free(ehi); BLI_edgehash_free(eh, NULL); - cache->edges_adjacency = GWN_indexbuf_build(&elb); + cache->edges_adjacency = GPU_indexbuf_build(&elb); } return cache->edges_adjacency; @@ -3395,16 +3395,16 @@ static EdgeHash *create_looptri_edge_adjacency_hash(MeshRenderData *rdata) return eh; } -static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRenderData *rdata) +static GPUVertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRenderData *rdata) { const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_VertFormat format = {0}; - uint index_id = GWN_vertformat_attr_add(&format, "index", GWN_COMP_U32, 1, GWN_FETCH_INT); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertFormat format = {0}; + uint index_id = GPU_vertformat_attr_add(&format, "index", GPU_COMP_U32, 1, GPU_FETCH_INT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); int vbo_len_capacity = tri_len * 3; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); int vidx = 0; EdgeHash *eh = NULL; @@ -3442,7 +3442,7 @@ static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRender if (eav->vert_index[1] == -1) { value |= (1 << 31); } - GWN_vertbuf_attr_set(vbo, index_id, vidx++, &value); + GPU_vertbuf_attr_set(vbo, index_id, vidx++, &value); } } @@ -3451,7 +3451,7 @@ static Gwn_VertBuf *mesh_batch_cache_create_edges_overlay_texture_buf(MeshRender int vbo_len_used = vidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } return vbo; @@ -3467,10 +3467,10 @@ static GPUTexture *mesh_batch_cache_get_edges_overlay_texture_buf(MeshRenderData return cache->edges_face_overlay_tx; } - Gwn_VertBuf *vbo = cache->edges_face_overlay = mesh_batch_cache_create_edges_overlay_texture_buf(rdata); + GPUVertBuf *vbo = cache->edges_face_overlay = mesh_batch_cache_create_edges_overlay_texture_buf(rdata); /* Upload data early because we need to create the texture for it. */ - GWN_vertbuf_use(vbo); + GPU_vertbuf_use(vbo); cache->edges_face_overlay_tx = GPU_texture_create_from_vertbuf(vbo); cache->edges_face_overlay_tri_count = vbo->vertex_alloc / 3; @@ -3482,15 +3482,15 @@ static GPUTexture *mesh_batch_cache_get_vert_pos_and_nor_in_order_buf(MeshRender BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI)); if (cache->pos_in_order_tx == NULL) { - Gwn_VertBuf *pos_in_order = mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache); - GWN_vertbuf_use(pos_in_order); /* Upload early for buffer texture creation. */ + GPUVertBuf *pos_in_order = mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache); + GPU_vertbuf_use(pos_in_order); /* Upload early for buffer texture creation. */ cache->pos_in_order_tx = GPU_texture_create_buffer(GPU_R32F, pos_in_order->vbo_id); } return cache->pos_in_order_tx; } -static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUIndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI)); @@ -3498,15 +3498,15 @@ static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rda const int vert_len = mesh_render_data_verts_len_get(rdata); const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len); if (rdata->edit_bmesh) { for (int i = 0; i < tri_len; ++i) { const BMLoop **ltri = (const BMLoop **)rdata->edit_bmesh->looptris[i]; if (!BM_elem_flag_test(ltri[0]->f, BM_ELEM_HIDDEN)) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_indexbuf_add_generic_vert(&elb, BM_elem_index_get(ltri[tri_corner]->v)); + GPU_indexbuf_add_generic_vert(&elb, BM_elem_index_get(ltri[tri_corner]->v)); } } } @@ -3515,18 +3515,18 @@ static Gwn_IndexBuf *mesh_batch_cache_get_triangles_in_order(MeshRenderData *rda for (int i = 0; i < tri_len; ++i) { const MLoopTri *mlt = &rdata->mlooptri[i]; for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_indexbuf_add_generic_vert(&elb, mlt->tri[tri_corner]); + GPU_indexbuf_add_generic_vert(&elb, mlt->tri[tri_corner]); } } } - cache->triangles_in_order = GWN_indexbuf_build(&elb); + cache->triangles_in_order = GPU_indexbuf_build(&elb); } return cache->triangles_in_order; } -static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, MeshBatchCache *cache) +static GPUIndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI)); @@ -3535,8 +3535,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mes const int edge_len = mesh_render_data_edges_len_get(rdata); /* Alloc max (edge_len) and upload only needed range. */ - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_LINES, edge_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_LINES, edge_len, vert_len); if (rdata->edit_bmesh) { /* No need to support since edit mesh already draw them. @@ -3546,7 +3546,7 @@ static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mes BMEdge *eed; BM_ITER_MESH(eed, &eiter, bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BM_edge_is_wire(eed)) { - GWN_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2)); + GPU_indexbuf_add_line_verts(&elb, BM_elem_index_get(eed->v1), BM_elem_index_get(eed->v2)); } } } @@ -3554,17 +3554,17 @@ static Gwn_IndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mes for (int i = 0; i < edge_len; ++i) { const MEdge *medge = &rdata->medge[i]; if (medge->flag & ME_LOOSEEDGE) { - GWN_indexbuf_add_line_verts(&elb, medge->v1, medge->v2); + GPU_indexbuf_add_line_verts(&elb, medge->v1, medge->v2); } } } - cache->ledges_in_order = GWN_indexbuf_build(&elb); + cache->ledges_in_order = GPU_indexbuf_build(&elb); } return cache->ledges_in_order; } -static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( +static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( MeshRenderData *rdata, MeshBatchCache *cache) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_POLY)); @@ -3576,7 +3576,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( int *mat_tri_len = MEM_callocN(sizeof(*mat_tri_len) * mat_len, __func__); cache->shaded_triangles_in_order = MEM_callocN(sizeof(*cache->shaded_triangles) * mat_len, __func__); - Gwn_IndexBufBuilder *elb = MEM_callocN(sizeof(*elb) * mat_len, __func__); + GPUIndexBufBuilder *elb = MEM_callocN(sizeof(*elb) * mat_len, __func__); /* Note that polygons (not triangles) are used here. * This OK because result is _guaranteed_ to be the same. */ @@ -3602,7 +3602,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( /* Init ELBs. */ for (int i = 0; i < mat_len; ++i) { - GWN_indexbuf_init(&elb[i], GWN_PRIM_TRIS, mat_tri_len[i], tri_len * 3); + GPU_indexbuf_init(&elb[i], GPU_PRIM_TRIS, mat_tri_len[i], tri_len * 3); } /* Populate ELBs. */ @@ -3616,7 +3616,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { const short ma_id = efa->mat_nr < mat_len ? efa->mat_nr : 0; for (int j = 2; j < efa->len; j++) { - GWN_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); + GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); nidx += 3; } } @@ -3627,7 +3627,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( const MPoly *mp = &rdata->mpoly[i]; ; const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0; for (int j = 2; j < mp->totloop; j++) { - GWN_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); + GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); nidx += 3; } } @@ -3635,7 +3635,7 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( /* Build ELBs. */ for (int i = 0; i < mat_len; ++i) { - cache->shaded_triangles_in_order[i] = GWN_indexbuf_build(&elb[i]); + cache->shaded_triangles_in_order[i] = GPU_indexbuf_build(&elb[i]); } MEM_freeN(mat_tri_len); @@ -3645,30 +3645,30 @@ static Gwn_IndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( return cache->shaded_triangles_in_order; } -static Gwn_VertBuf *mesh_create_edge_pos_with_sel( +static GPUVertBuf *mesh_create_edge_pos_with_sel( MeshRenderData *rdata, bool use_wire, bool use_select_bool) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP)); BLI_assert(rdata->edit_bmesh == NULL); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint vidx = 0, cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, sel; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.sel = GWN_vertformat_attr_add(&format, "select", GWN_COMP_U8, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.sel = GPU_vertformat_attr_add(&format, "select", GPU_COMP_U8, 1, GPU_FETCH_INT); } const int edge_len = mesh_render_data_edges_len_get(rdata); - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = edge_len * 2; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); if (use_select_bool) { mesh_render_data_ensure_edge_select_bool(rdata, use_wire); @@ -3689,23 +3689,23 @@ static Gwn_VertBuf *mesh_create_edge_pos_with_sel( continue; } - GWN_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel); - GWN_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel); + GPU_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel); + GPU_vertbuf_attr_set(vbo, attr_id.sel, cidx++, &edge_vert_sel); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v1].co); - GWN_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v2].co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v1].co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, rdata->mvert[ed->v2].co); } vbo_len_used = vidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; } -static Gwn_IndexBuf *mesh_create_tri_overlay_weight_faces( +static GPUIndexBuf *mesh_create_tri_overlay_weight_faces( MeshRenderData *rdata) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI)); @@ -3714,57 +3714,57 @@ static Gwn_IndexBuf *mesh_create_tri_overlay_weight_faces( const int vert_len = mesh_render_data_verts_len_get(rdata); const int tri_len = mesh_render_data_looptri_len_get(rdata); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tri_len, vert_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len); for (int i = 0; i < tri_len; ++i) { const MLoopTri *mlt = &rdata->mlooptri[i]; if (!(rdata->mpoly[mlt->poly].flag & (ME_FACE_SEL | ME_HIDE))) { for (uint tri_corner = 0; tri_corner < 3; tri_corner++) { - GWN_indexbuf_add_generic_vert(&elb, rdata->mloop[mlt->tri[tri_corner]].v); + GPU_indexbuf_add_generic_vert(&elb, rdata->mloop[mlt->tri[tri_corner]].v); } } } - return GWN_indexbuf_build(&elb); + return GPU_indexbuf_build(&elb); } } /** * Non-edit mode vertices (only used for weight-paint mode). */ -static Gwn_VertBuf *mesh_create_vert_pos_with_overlay_data( +static GPUVertBuf *mesh_create_vert_pos_with_overlay_data( MeshRenderData *rdata) { BLI_assert(rdata->types & (MR_DATATYPE_VERT)); BLI_assert(rdata->edit_bmesh == NULL); - Gwn_VertBuf *vbo; + GPUVertBuf *vbo; { uint cidx = 0; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint data; } attr_id; if (format.attr_len == 0) { - attr_id.data = GWN_vertformat_attr_add(&format, "data", GWN_COMP_I8, 1, GWN_FETCH_INT); + attr_id.data = GPU_vertformat_attr_add(&format, "data", GPU_COMP_I8, 1, GPU_FETCH_INT); } const int vert_len = mesh_render_data_verts_len_get(rdata); - vbo = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); const int vbo_len_capacity = vert_len; int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); for (int i = 0; i < vert_len; i++) { const MVert *mv = &rdata->mvert[i]; const char data = mv->flag & (SELECT | ME_HIDE); - GWN_vertbuf_attr_set(vbo, attr_id.data, cidx++, &data); + GPU_vertbuf_attr_set(vbo, attr_id.data, cidx++, &data); } vbo_len_used = cidx; if (vbo_len_capacity != vbo_len_used) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } } return vbo; @@ -3778,7 +3778,7 @@ static Gwn_VertBuf *mesh_create_vert_pos_with_overlay_data( /** \name Public API * \{ */ -Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_all_edges(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3787,8 +3787,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->all_edges = GWN_batch_create( - GWN_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + cache->all_edges = GPU_batch_create( + GPU_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), mesh_batch_cache_get_edges_in_order(rdata, cache)); mesh_render_data_free(rdata); @@ -3797,7 +3797,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *me) return cache->all_edges; } -Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3806,8 +3806,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->all_triangles = GWN_batch_create( - GWN_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + cache->all_triangles = GPU_batch_create( + GPU_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), mesh_batch_cache_get_triangles_in_order(rdata, cache)); mesh_render_data_free(rdata); @@ -3816,7 +3816,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me) return cache->all_triangles; } -Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3824,8 +3824,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->triangles_with_normals = GWN_batch_create( - GWN_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); + cache->triangles_with_normals = GPU_batch_create( + GPU_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); mesh_render_data_free(rdata); } @@ -3833,7 +3833,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) return cache->triangles_with_normals; } -Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3841,8 +3841,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->ledges_with_normals = GWN_batch_create( - GWN_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + cache->ledges_with_normals = GPU_batch_create( + GPU_PRIM_LINES, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), mesh_batch_cache_get_loose_edges(rdata, cache)); mesh_render_data_free(rdata); @@ -3851,7 +3851,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me) return cache->ledges_with_normals; } -Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, int defgroup) +GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, int defgroup) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3861,14 +3861,14 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_DVERT; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->triangles_with_weights = GWN_batch_create_ex( - GWN_PRIM_TRIS, mesh_create_tri_weights(rdata, use_hide, defgroup), NULL, GWN_BATCH_OWNS_VBO); + cache->triangles_with_weights = GPU_batch_create_ex( + GPU_PRIM_TRIS, mesh_create_tri_weights(rdata, use_hide, defgroup), NULL, GPU_BATCH_OWNS_VBO); - Gwn_VertBuf *vbo_tris = use_hide ? + GPUVertBuf *vbo_tris = use_hide ? mesh_create_tri_pos_and_normals_visible_only(rdata) : mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - GWN_batch_vertbuf_add_ex(cache->triangles_with_weights, vbo_tris, use_hide); + GPU_batch_vertbuf_add_ex(cache->triangles_with_weights, vbo_tris, use_hide); mesh_render_data_free(rdata); } @@ -3876,7 +3876,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me, return cache->triangles_with_weights; } -Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3886,13 +3886,13 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPCOL; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->triangles_with_vert_colors = GWN_batch_create_ex( - GWN_PRIM_TRIS, mesh_create_tri_vert_colors(rdata, use_hide), NULL, GWN_BATCH_OWNS_VBO); + cache->triangles_with_vert_colors = GPU_batch_create_ex( + GPU_PRIM_TRIS, mesh_create_tri_vert_colors(rdata, use_hide), NULL, GPU_BATCH_OWNS_VBO); - Gwn_VertBuf *vbo_tris = use_hide ? + GPUVertBuf *vbo_tris = use_hide ? mesh_create_tri_pos_and_normals_visible_only(rdata) : mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - GWN_batch_vertbuf_add_ex(cache->triangles_with_vert_colors, vbo_tris, use_hide); + GPU_batch_vertbuf_add_ex(cache->triangles_with_vert_colors, vbo_tris, use_hide); mesh_render_data_free(rdata); } @@ -3901,14 +3901,14 @@ Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh } -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id( +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id( struct Mesh *me, bool use_hide, uint select_id_offset) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->triangles_with_select_id_offset != select_id_offset) { cache->triangles_with_select_id_offset = select_id_offset; - GWN_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->triangles_with_select_id); } if (cache->triangles_with_select_id == NULL) { @@ -3916,13 +3916,13 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id( MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->triangles_with_select_id = GWN_batch_create_ex( - GWN_PRIM_TRIS, mesh_create_tri_select_id(rdata, use_hide, select_id_offset), NULL, GWN_BATCH_OWNS_VBO); + cache->triangles_with_select_id = GPU_batch_create_ex( + GPU_PRIM_TRIS, mesh_create_tri_select_id(rdata, use_hide, select_id_offset), NULL, GPU_BATCH_OWNS_VBO); - Gwn_VertBuf *vbo_tris = use_hide ? + GPUVertBuf *vbo_tris = use_hide ? mesh_create_tri_pos_and_normals_visible_only(rdata) : mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - GWN_batch_vertbuf_add_ex(cache->triangles_with_select_id, vbo_tris, use_hide); + GPU_batch_vertbuf_add_ex(cache->triangles_with_select_id, vbo_tris, use_hide); mesh_render_data_free(rdata); } @@ -3934,7 +3934,7 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_id( * Same as #DRW_mesh_batch_cache_get_triangles_with_select_id * without the ID's, use to mask out geometry, eg - dont select face-dots behind other faces. */ -struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide) +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->triangles_with_select_mask == NULL) { @@ -3942,12 +3942,12 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mes MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - Gwn_VertBuf *vbo_tris = use_hide ? + GPUVertBuf *vbo_tris = use_hide ? mesh_create_tri_pos_and_normals_visible_only(rdata) : mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - cache->triangles_with_select_mask = GWN_batch_create_ex( - GWN_PRIM_TRIS, vbo_tris, NULL, use_hide ? GWN_BATCH_OWNS_VBO : 0); + cache->triangles_with_select_mask = GPU_batch_create_ex( + GPU_PRIM_TRIS, vbo_tris, NULL, use_hide ? GPU_BATCH_OWNS_VBO : 0); mesh_render_data_free(rdata); } @@ -3955,7 +3955,7 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mes return cache->triangles_with_select_mask; } -Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3963,8 +3963,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->points_with_normals = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); + cache->points_with_normals = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); mesh_render_data_free(rdata); } @@ -3972,7 +3972,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me) return cache->points_with_normals; } -Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_all_verts(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -3980,8 +3980,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *me) /* create batch from DM */ MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT); - cache->all_verts = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL); + cache->all_verts = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL); mesh_render_data_free(rdata); } @@ -3989,21 +3989,21 @@ Gwn_Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *me) return cache->all_verts; } -Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->fancy_edges == NULL) { /* create batch from DM */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, n1, n2; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - attr_id.n1 = GWN_vertformat_attr_add(&format, "N1", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - attr_id.n2 = GWN_vertformat_attr_add(&format, "N2", GWN_COMP_I10, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + attr_id.n1 = GPU_vertformat_attr_add(&format, "N1", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); + attr_id.n2 = GPU_vertformat_attr_add(&format, "N2", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); MeshRenderData *rdata = mesh_render_data_create( me, MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_POLY); @@ -4012,7 +4012,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) const int vbo_len_capacity = edge_len * 2; /* these are PRIM_LINE verts, not mesh verts */ int vbo_len_used = 0; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); for (int i = 0; i < edge_len; ++i) { float *vcos1, *vcos2; float *pnor1 = NULL, *pnor2 = NULL; @@ -4020,33 +4020,33 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) if (mesh_render_data_edge_vcos_manifold_pnors(rdata, i, &vcos1, &vcos2, &pnor1, &pnor2, &is_manifold)) { - Gwn_PackedNormal n1value = { .x = 0, .y = 0, .z = +511 }; - Gwn_PackedNormal n2value = { .x = 0, .y = 0, .z = -511 }; + GPUPackedNormal n1value = { .x = 0, .y = 0, .z = +511 }; + GPUPackedNormal n2value = { .x = 0, .y = 0, .z = -511 }; if (is_manifold) { - n1value = GWN_normal_convert_i10_v3(pnor1); - n2value = GWN_normal_convert_i10_v3(pnor2); + n1value = GPU_normal_convert_i10_v3(pnor1); + n2value = GPU_normal_convert_i10_v3(pnor2); } - const Gwn_PackedNormal *n1 = &n1value; - const Gwn_PackedNormal *n2 = &n2value; + const GPUPackedNormal *n1 = &n1value; + const GPUPackedNormal *n2 = &n2value; - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * i, vcos1); - GWN_vertbuf_attr_set(vbo, attr_id.n1, 2 * i, n1); - GWN_vertbuf_attr_set(vbo, attr_id.n2, 2 * i, n2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * i, vcos1); + GPU_vertbuf_attr_set(vbo, attr_id.n1, 2 * i, n1); + GPU_vertbuf_attr_set(vbo, attr_id.n2, 2 * i, n2); - GWN_vertbuf_attr_set(vbo, attr_id.pos, 2 * i + 1, vcos2); - GWN_vertbuf_attr_set(vbo, attr_id.n1, 2 * i + 1, n1); - GWN_vertbuf_attr_set(vbo, attr_id.n2, 2 * i + 1, n2); + GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * i + 1, vcos2); + GPU_vertbuf_attr_set(vbo, attr_id.n1, 2 * i + 1, n1); + GPU_vertbuf_attr_set(vbo, attr_id.n2, 2 * i + 1, n2); vbo_len_used += 2; } } if (vbo_len_used != vbo_len_capacity) { - GWN_vertbuf_data_resize(vbo, vbo_len_used); + GPU_vertbuf_data_resize(vbo, vbo_len_used); } - cache->fancy_edges = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + cache->fancy_edges = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); mesh_render_data_free(rdata); } @@ -4054,7 +4054,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me) return cache->fancy_edges; } -Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold) +GPUBatch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4063,8 +4063,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold MeshRenderData *rdata = mesh_render_data_create(me, options); - cache->edge_detection = GWN_batch_create_ex( - GWN_PRIM_LINES_ADJ, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + cache->edge_detection = GPU_batch_create_ex( + GPU_PRIM_LINES_ADJ, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), mesh_batch_cache_get_edges_adjacency(rdata, cache), 0); mesh_render_data_free(rdata); @@ -4111,42 +4111,42 @@ static void mesh_batch_cache_create_overlay_batches(Mesh *me) MeshRenderData *rdata = mesh_render_data_create(me, options); if (cache->overlay_triangles == NULL) { - cache->overlay_triangles = GWN_batch_create( - GWN_PRIM_TRIS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_nor(rdata, cache)); - GWN_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_data(rdata, cache)); + cache->overlay_triangles = GPU_batch_create( + GPU_PRIM_TRIS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_nor(rdata, cache)); + GPU_batch_vertbuf_add(cache->overlay_triangles, mesh_batch_cache_get_edit_tri_data(rdata, cache)); } if (cache->overlay_loose_edges == NULL) { - cache->overlay_loose_edges = GWN_batch_create( - GWN_PRIM_LINES, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_nor(rdata, cache)); - GWN_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_data(rdata, cache)); + cache->overlay_loose_edges = GPU_batch_create( + GPU_PRIM_LINES, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_nor(rdata, cache)); + GPU_batch_vertbuf_add(cache->overlay_loose_edges, mesh_batch_cache_get_edit_ledge_data(rdata, cache)); } if (cache->overlay_loose_verts == NULL) { - cache->overlay_loose_verts = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_edit_lvert_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_nor(rdata, cache)); - GWN_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_data(rdata, cache)); + cache->overlay_loose_verts = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_edit_lvert_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_nor(rdata, cache)); + GPU_batch_vertbuf_add(cache->overlay_loose_verts, mesh_batch_cache_get_edit_lvert_data(rdata, cache)); } if (cache->overlay_triangles_nor == NULL) { - cache->overlay_triangles_nor = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_triangles_nor, mesh_batch_cache_get_edit_tri_nor(rdata, cache)); + cache->overlay_triangles_nor = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_triangles_nor, mesh_batch_cache_get_edit_tri_nor(rdata, cache)); } if (cache->overlay_loose_edges_nor == NULL) { - cache->overlay_loose_edges_nor = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL); - GWN_batch_vertbuf_add(cache->overlay_loose_edges_nor, mesh_batch_cache_get_edit_ledge_nor(rdata, cache)); + cache->overlay_loose_edges_nor = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL); + GPU_batch_vertbuf_add(cache->overlay_loose_edges_nor, mesh_batch_cache_get_edit_ledge_nor(rdata, cache)); } mesh_render_data_free(rdata); } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4157,7 +4157,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles(Mesh *me) return cache->overlay_triangles; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4168,7 +4168,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges(Mesh *me) return cache->overlay_loose_edges; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_verts(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4179,7 +4179,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(Mesh *me) return cache->overlay_loose_verts; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4190,7 +4190,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me) return cache->overlay_triangles_nor; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4201,15 +4201,15 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me) return cache->overlay_loose_edges_nor; } -Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->overlay_facedots == NULL) { MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY); - cache->overlay_facedots = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL); + cache->overlay_facedots = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL); mesh_render_data_free(rdata); } @@ -4217,13 +4217,13 @@ Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(Mesh *me) return cache->overlay_facedots; } -Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint select_id_offset) +GPUBatch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint select_id_offset) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->facedot_with_select_id_offset != select_id_offset) { cache->facedot_with_select_id_offset = select_id_offset; - GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id); } if (cache->facedot_with_select_id == NULL) { @@ -4231,10 +4231,10 @@ Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint selec /* We only want the 'pos', not the normals or flag. * Use since this is almost certainly already created. */ - cache->facedot_with_select_id = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL); + cache->facedot_with_select_id = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_facedot_pos_with_normals_and_flag(rdata, cache), NULL); - GWN_batch_vertbuf_add_ex( + GPU_batch_vertbuf_add_ex( cache->facedot_with_select_id, mesh_create_facedot_select_id(rdata, select_id_offset), true); @@ -4244,22 +4244,22 @@ Gwn_Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *me, uint selec return cache->facedot_with_select_id; } -Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_id_offset) +GPUBatch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_id_offset) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->edges_with_select_id_offset != select_id_offset) { cache->edges_with_select_id_offset = select_id_offset; - GWN_BATCH_DISCARD_SAFE(cache->edges_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->edges_with_select_id); } if (cache->edges_with_select_id == NULL) { MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT | MR_DATATYPE_EDGE); - cache->edges_with_select_id = GWN_batch_create( - GWN_PRIM_LINES, mesh_batch_cache_get_edges_visible(rdata, cache), NULL); + cache->edges_with_select_id = GPU_batch_create( + GPU_PRIM_LINES, mesh_batch_cache_get_edges_visible(rdata, cache), NULL); - GWN_batch_vertbuf_add_ex( + GPU_batch_vertbuf_add_ex( cache->edges_with_select_id, mesh_create_edges_select_id(rdata, select_id_offset), true); @@ -4269,22 +4269,22 @@ Gwn_Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *me, uint select_i return cache->edges_with_select_id; } -Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_id_offset) +GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_id_offset) { MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->verts_with_select_id_offset != select_id_offset) { cache->verts_with_select_id_offset = select_id_offset; - GWN_BATCH_DISCARD_SAFE(cache->verts_with_select_id); + GPU_BATCH_DISCARD_SAFE(cache->verts_with_select_id); } if (cache->verts_with_select_id == NULL) { MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT); - cache->verts_with_select_id = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_verts_visible(rdata, cache), NULL); + cache->verts_with_select_id = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_verts_visible(rdata, cache), NULL); - GWN_batch_vertbuf_add_ex( + GPU_batch_vertbuf_add_ex( cache->verts_with_select_id, mesh_create_verts_select_id(rdata, select_id_offset), true); @@ -4294,7 +4294,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_i return cache->verts_with_select_id; } -Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( +GPUBatch **DRW_mesh_batch_cache_get_surface_shaded( Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { @@ -4311,16 +4311,16 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( cache->shaded_triangles = MEM_callocN(sizeof(*cache->shaded_triangles) * mat_len, __func__); - Gwn_IndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache); + GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache); - Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - Gwn_VertBuf *vbo_shading = mesh_batch_cache_get_tri_shading_data(rdata, cache); + GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo_shading = mesh_batch_cache_get_tri_shading_data(rdata, cache); for (int i = 0; i < mat_len; ++i) { - cache->shaded_triangles[i] = GWN_batch_create( - GWN_PRIM_TRIS, vbo, el[i]); + cache->shaded_triangles[i] = GPU_batch_create( + GPU_PRIM_TRIS, vbo, el[i]); if (vbo_shading) { - GWN_batch_vertbuf_add(cache->shaded_triangles[i], vbo_shading); + GPU_batch_vertbuf_add(cache->shaded_triangles[i], vbo_shading); } } @@ -4336,7 +4336,7 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_shaded( return cache->shaded_triangles; } -Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) +GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4350,15 +4350,15 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) cache->texpaint_triangles = MEM_callocN(sizeof(*cache->texpaint_triangles) * mat_len, __func__); - Gwn_IndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache); + GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache); - Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); for (int i = 0; i < mat_len; ++i) { - cache->texpaint_triangles[i] = GWN_batch_create( - GWN_PRIM_TRIS, vbo, el[i]); - Gwn_VertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache); + cache->texpaint_triangles[i] = GPU_batch_create( + GPU_PRIM_TRIS, vbo, el[i]); + GPUVertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache); if (vbo_uv) { - GWN_batch_vertbuf_add(cache->texpaint_triangles[i], vbo_uv); + GPU_batch_vertbuf_add(cache->texpaint_triangles[i], vbo_uv); } } mesh_render_data_free(rdata); @@ -4367,7 +4367,7 @@ Gwn_Batch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) return cache->texpaint_triangles; } -Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4377,20 +4377,20 @@ Gwn_Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me) MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOPUV; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - cache->texpaint_triangles_single = GWN_batch_create( - GWN_PRIM_TRIS, vbo, NULL); - Gwn_VertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache); + cache->texpaint_triangles_single = GPU_batch_create( + GPU_PRIM_TRIS, vbo, NULL); + GPUVertBuf *vbo_uv = mesh_batch_cache_get_tri_uv_active(rdata, cache); if (vbo_uv) { - GWN_batch_vertbuf_add(cache->texpaint_triangles_single, vbo_uv); + GPU_batch_vertbuf_add(cache->texpaint_triangles_single, vbo_uv); } mesh_render_data_free(rdata); } return cache->texpaint_triangles_single; } -Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel) +GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4399,8 +4399,8 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->overlay_paint_edges = GWN_batch_create_ex( - GWN_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel), NULL, GWN_BATCH_OWNS_VBO); + cache->overlay_paint_edges = GPU_batch_create_ex( + GPU_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel), NULL, GPU_BATCH_OWNS_VBO); mesh_render_data_free(rdata); } @@ -4408,7 +4408,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire return cache->overlay_paint_edges; } -Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4417,9 +4417,9 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me) const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - cache->overlay_weight_faces = GWN_batch_create_ex( - GWN_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), - mesh_create_tri_overlay_weight_faces(rdata), GWN_BATCH_OWNS_INDEX); + cache->overlay_weight_faces = GPU_batch_create_ex( + GPU_PRIM_TRIS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), + mesh_create_tri_overlay_weight_faces(rdata), GPU_BATCH_OWNS_INDEX); mesh_render_data_free(rdata); } @@ -4427,7 +4427,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_faces(Mesh *me) return cache->overlay_weight_faces; } -Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4435,10 +4435,10 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me) /* create batch from Mesh */ MeshRenderData *rdata = mesh_render_data_create(me, MR_DATATYPE_VERT); - cache->overlay_weight_verts = GWN_batch_create( - GWN_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL); + cache->overlay_weight_verts = GPU_batch_create( + GPU_PRIM_POINTS, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache), NULL); - GWN_batch_vertbuf_add_ex( + GPU_batch_vertbuf_add_ex( cache->overlay_weight_verts, mesh_create_vert_pos_with_overlay_data(rdata), true); mesh_render_data_free(rdata); @@ -4458,7 +4458,7 @@ void DRW_mesh_cache_sculpt_coords_ensure(Mesh *me) /* XXX Force update of all the batches that contains the pos_with_normals buffer. * TODO(fclem): Ideally, Gawain should provide a way to update a buffer without destroying it. */ mesh_batch_cache_clear_selective(me, cache->pos_with_normals); - GWN_VERTBUF_DISCARD_SAFE(cache->pos_with_normals); + GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals); } cache->is_sculpt_points_tag = false; } diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c index 24930921bee..375b0ba6bb2 100644 --- a/source/blender/draw/intern/draw_cache_impl_metaball.c +++ b/source/blender/draw/intern/draw_cache_impl_metaball.c @@ -45,18 +45,18 @@ static void metaball_batch_cache_clear(MetaBall *mb); /* ---------------------------------------------------------------------- */ -/* MetaBall Gwn_Batch Cache */ +/* MetaBall GPUBatch Cache */ typedef struct MetaBallBatchCache { - Gwn_Batch *batch; - Gwn_Batch **shaded_triangles; + GPUBatch *batch; + GPUBatch **shaded_triangles; int mat_len; /* settings to determine if cache is invalid */ bool is_dirty; } MetaBallBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ static bool metaball_batch_cache_valid(MetaBall *mb) { @@ -113,7 +113,7 @@ static void metaball_batch_cache_clear(MetaBall *mb) return; } - GWN_BATCH_DISCARD_SAFE(cache->batch); + GPU_BATCH_DISCARD_SAFE(cache->batch); /* Note: shaded_triangles[0] is already freed by cache->batch */ MEM_SAFE_FREE(cache->shaded_triangles); cache->mat_len = 0; @@ -130,7 +130,7 @@ void DRW_mball_batch_cache_free(MetaBall *mb) /** \name Public Object/MetaBall API * \{ */ -Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob) +GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob) { if (!BKE_mball_is_basis(ob)) { return NULL; @@ -141,17 +141,17 @@ Gwn_Batch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob) if (cache->batch == NULL) { ListBase *lb = &ob->curve_cache->disp; - cache->batch = GWN_batch_create_ex( - GWN_PRIM_TRIS, + cache->batch = GPU_batch_create_ex( + GPU_PRIM_TRIS, DRW_displist_vertbuf_calc_pos_with_normals(lb), DRW_displist_indexbuf_calc_triangles_in_order(lb), - GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); } return cache->batch; } -Gwn_Batch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, MetaBall *mb, struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len) +GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, MetaBall *mb, struct GPUMaterial **UNUSED(gpumat_array), uint gpumat_array_len) { if (!BKE_mball_is_basis(ob)) { return NULL; diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index df67d34d566..b56396261d3 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -61,11 +61,11 @@ static void particle_batch_cache_clear(ParticleSystem *psys); /* ---------------------------------------------------------------------- */ -/* Particle Gwn_Batch Cache */ +/* Particle GPUBatch Cache */ typedef struct ParticlePointCache { - Gwn_VertBuf *pos; - Gwn_Batch *points; + GPUVertBuf *pos; + GPUBatch *points; int elems_len; int point_len; } ParticlePointCache; @@ -80,19 +80,19 @@ typedef struct ParticleBatchCache { /* Control points when in edit mode. */ ParticleHairCache edit_hair; - Gwn_VertBuf *edit_inner_pos; - Gwn_Batch *edit_inner_points; + GPUVertBuf *edit_inner_pos; + GPUBatch *edit_inner_points; int edit_inner_point_len; - Gwn_VertBuf *edit_tip_pos; - Gwn_Batch *edit_tip_points; + GPUVertBuf *edit_tip_pos; + GPUBatch *edit_tip_points; int edit_tip_point_len; /* Settings to determine if cache is invalid. */ bool is_dirty; } ParticleBatchCache; -/* Gwn_Batch cache management. */ +/* GPUBatch cache management. */ typedef struct HairAttributeID { uint pos; @@ -158,39 +158,39 @@ void DRW_particle_batch_cache_dirty(ParticleSystem *psys, int mode) static void particle_batch_cache_clear_point(ParticlePointCache *point_cache) { - GWN_BATCH_DISCARD_SAFE(point_cache->points); - GWN_VERTBUF_DISCARD_SAFE(point_cache->pos); + GPU_BATCH_DISCARD_SAFE(point_cache->points); + GPU_VERTBUF_DISCARD_SAFE(point_cache->pos); } static void particle_batch_cache_clear_hair(ParticleHairCache *hair_cache) { /* TODO more granular update tagging. */ - GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_point_buf); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_point_buf); DRW_TEXTURE_FREE_SAFE(hair_cache->point_tex); - GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_strand_buf); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_strand_buf); DRW_TEXTURE_FREE_SAFE(hair_cache->strand_tex); for (int i = 0; i < MAX_MTFACE; ++i) { - GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_uv_buf[i]); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_uv_buf[i]); DRW_TEXTURE_FREE_SAFE(hair_cache->uv_tex[i]); } for (int i = 0; i < MAX_MCOL; ++i) { - GWN_VERTBUF_DISCARD_SAFE(hair_cache->proc_col_buf[i]); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->proc_col_buf[i]); DRW_TEXTURE_FREE_SAFE(hair_cache->col_tex[i]); } for (int i = 0; i < MAX_HAIR_SUBDIV; ++i) { - GWN_VERTBUF_DISCARD_SAFE(hair_cache->final[i].proc_buf); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->final[i].proc_buf); DRW_TEXTURE_FREE_SAFE(hair_cache->final[i].proc_tex); for (int j = 0; j < MAX_THICKRES; ++j) { - GWN_BATCH_DISCARD_SAFE(hair_cache->final[i].proc_hairs[j]); + GPU_BATCH_DISCARD_SAFE(hair_cache->final[i].proc_hairs[j]); } } /* "Normal" legacy hairs */ - GWN_BATCH_DISCARD_SAFE(hair_cache->hairs); - GWN_VERTBUF_DISCARD_SAFE(hair_cache->pos); - GWN_INDEXBUF_DISCARD_SAFE(hair_cache->indices); + GPU_BATCH_DISCARD_SAFE(hair_cache->hairs); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->pos); + GPU_INDEXBUF_DISCARD_SAFE(hair_cache->indices); } static void particle_batch_cache_clear(ParticleSystem *psys) @@ -205,10 +205,10 @@ static void particle_batch_cache_clear(ParticleSystem *psys) particle_batch_cache_clear_hair(&cache->edit_hair); - GWN_BATCH_DISCARD_SAFE(cache->edit_inner_points); - GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); - GWN_BATCH_DISCARD_SAFE(cache->edit_tip_points); - GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); + GPU_BATCH_DISCARD_SAFE(cache->edit_inner_points); + GPU_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); + GPU_BATCH_DISCARD_SAFE(cache->edit_tip_points); + GPU_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); } void DRW_particle_batch_cache_free(ParticleSystem *psys) @@ -514,7 +514,7 @@ static int particle_batch_cache_fill_segments( uint *col_id, float (***r_parent_uvs)[2], MCol ***r_parent_mcol, - Gwn_IndexBufBuilder *elb, + GPUIndexBufBuilder *elb, HairAttributeID *attr_id, ParticleHairCache *hair_cache) { @@ -561,12 +561,12 @@ static int particle_batch_cache_fill_segments( else { sub_v3_v3v3(tangent, path[j + 1].co, path[j - 1].co); } - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[j].co); - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent); - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &i); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[j].co); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &i); if (psmd != NULL) { for (int k = 0; k < num_uv_layers; k++) { - GWN_vertbuf_attr_set( + GPU_vertbuf_attr_set( hair_cache->pos, uv_id[k], curr_point, (is_simple && is_child) ? (*r_parent_uvs)[psys->child[i].parent][k] : uv[k]); @@ -578,22 +578,22 @@ static int particle_batch_cache_fill_segments( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], scol); - GWN_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol); + GPU_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol); } } - GWN_indexbuf_add_generic_vert(elb, curr_point); + GPU_indexbuf_add_generic_vert(elb, curr_point); curr_point++; } sub_v3_v3v3(tangent, path[path->segments].co, path[path->segments - 1].co); int global_index = i + global_offset; - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[path->segments].co); - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent); - GWN_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &global_index); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->pos, curr_point, path[path->segments].co); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->tan, curr_point, tangent); + GPU_vertbuf_attr_set(hair_cache->pos, attr_id->ind, curr_point, &global_index); if (psmd != NULL) { for (int k = 0; k < num_uv_layers; k++) { - GWN_vertbuf_attr_set( + GPU_vertbuf_attr_set( hair_cache->pos, uv_id[k], curr_point, (is_simple && is_child) ? (*r_parent_uvs)[psys->child[i].parent][k] : uv[k]); @@ -605,7 +605,7 @@ static int particle_batch_cache_fill_segments( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], scol); - GWN_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol); + GPU_vertbuf_attr_set(hair_cache->pos, col_id[k], curr_point, scol); } if (!is_simple) { MEM_freeN(uv); @@ -613,8 +613,8 @@ static int particle_batch_cache_fill_segments( } } /* Finish the segment and add restart primitive. */ - GWN_indexbuf_add_generic_vert(elb, curr_point); - GWN_indexbuf_add_primitive_restart(elb); + GPU_indexbuf_add_generic_vert(elb, curr_point); + GPU_indexbuf_add_primitive_restart(elb); curr_point++; } return curr_point; @@ -623,7 +623,7 @@ static int particle_batch_cache_fill_segments( static void particle_batch_cache_fill_segments_proc_pos( ParticleCacheKey **path_cache, const int num_path_keys, - Gwn_VertBufRaw *attr_step) + GPUVertBufRaw *attr_step) { for (int i = 0; i < num_path_keys; i++) { ParticleCacheKey *path = path_cache[i]; @@ -633,7 +633,7 @@ static void particle_batch_cache_fill_segments_proc_pos( float total_len = 0.0f; float *co_prev = NULL, *seg_data_first; for (int j = 0; j <= path->segments; j++) { - float *seg_data = (float *)GWN_vertbuf_raw_step(attr_step); + float *seg_data = (float *)GPU_vertbuf_raw_step(attr_step); copy_v3_v3(seg_data, path[j].co); if (co_prev) { total_len += len_v3v3(co_prev, path[j].co); @@ -658,7 +658,7 @@ static int particle_batch_cache_fill_segments_indices( const int start_index, const int num_path_keys, const int res, - Gwn_IndexBufBuilder *elb) + GPUIndexBufBuilder *elb) { int curr_point = start_index; for (int i = 0; i < num_path_keys; i++) { @@ -667,9 +667,9 @@ static int particle_batch_cache_fill_segments_indices( continue; } for (int k = 0; k < res; k++) { - GWN_indexbuf_add_generic_vert(elb, curr_point++); + GPU_indexbuf_add_generic_vert(elb, curr_point++); } - GWN_indexbuf_add_primitive_restart(elb); + GPU_indexbuf_add_primitive_restart(elb); } return curr_point; } @@ -681,9 +681,9 @@ static int particle_batch_cache_fill_strands_data( const ParticleSource particle_source, const int start_index, const int num_path_keys, - Gwn_VertBufRaw *data_step, - float (***r_parent_uvs)[2], Gwn_VertBufRaw *uv_step, MTFace **mtfaces, int num_uv_layers, - MCol ***r_parent_mcol, Gwn_VertBufRaw *col_step, MCol **mcols, int num_col_layers) + GPUVertBufRaw *data_step, + float (***r_parent_uvs)[2], GPUVertBufRaw *uv_step, MTFace **mtfaces, int num_uv_layers, + MCol ***r_parent_mcol, GPUVertBufRaw *col_step, MCol **mcols, int num_col_layers) { const bool is_simple = (psys->part->childtype == PART_CHILD_PARTICLES); const bool is_child = (particle_source == PARTICLE_SOURCE_CHILDREN); @@ -705,7 +705,7 @@ static int particle_batch_cache_fill_strands_data( continue; } - uint *seg_data = (uint *)GWN_vertbuf_raw_step(data_step); + uint *seg_data = (uint *)GPU_vertbuf_raw_step(data_step); *seg_data = (curr_point & 0xFFFFFF) | (path->segments << 24); curr_point += path->segments + 1; @@ -730,11 +730,11 @@ static int particle_batch_cache_fill_strands_data( *r_parent_mcol, &mcol); for (int k = 0; k < num_uv_layers; k++) { - float *t_uv = (float *)GWN_vertbuf_raw_step(uv_step + k); + float *t_uv = (float *)GPU_vertbuf_raw_step(uv_step + k); copy_v2_v2(t_uv, uv[k]); } for (int k = 0; k < num_col_layers; k++) { - ushort *scol = (ushort *)GWN_vertbuf_raw_step(col_step + k); + ushort *scol = (ushort *)GPU_vertbuf_raw_step(col_step + k); particle_pack_mcol( (is_simple && is_child) ? &(*r_parent_mcol)[psys->child[i].parent][k] : &mcol[k], @@ -754,17 +754,17 @@ static void particle_batch_cache_ensure_procedural_final_points( int subdiv) { /* Same format as point_tex. */ - Gwn_VertFormat format = { 0 }; - GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat format = { 0 }; + GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - cache->final[subdiv].proc_buf = GWN_vertbuf_create_with_format(&format); + cache->final[subdiv].proc_buf = GPU_vertbuf_create_with_format(&format); /* Create a destination buffer for the tranform feedback. Sized appropriately */ /* Thoses are points! not line segments. */ - GWN_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_len); + GPU_vertbuf_data_alloc(cache->final[subdiv].proc_buf, cache->final[subdiv].strands_res * cache->strands_len); /* Create vbo immediatly to bind to texture buffer. */ - GWN_vertbuf_use(cache->final[subdiv].proc_buf); + GPU_vertbuf_use(cache->final[subdiv].proc_buf); cache->final[subdiv].proc_tex = GPU_texture_create_from_vertbuf(cache->final[subdiv].proc_buf); } @@ -791,37 +791,37 @@ static void particle_batch_cache_ensure_procedural_strand_data( } } - Gwn_VertBufRaw data_step; - Gwn_VertBufRaw uv_step[MAX_MTFACE]; - Gwn_VertBufRaw col_step[MAX_MCOL]; + GPUVertBufRaw data_step; + GPUVertBufRaw uv_step[MAX_MTFACE]; + GPUVertBufRaw col_step[MAX_MCOL]; MTFace *mtfaces[MAX_MTFACE] = {NULL}; MCol *mcols[MAX_MCOL] = {NULL}; float (**parent_uvs)[2] = NULL; MCol **parent_mcol = NULL; - Gwn_VertFormat format_data = {0}; - uint data_id = GWN_vertformat_attr_add(&format_data, "data", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat format_data = {0}; + uint data_id = GPU_vertformat_attr_add(&format_data, "data", GPU_COMP_U32, 1, GPU_FETCH_INT); - Gwn_VertFormat format_uv = {0}; - uint uv_id = GWN_vertformat_attr_add(&format_uv, "uv", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat format_uv = {0}; + uint uv_id = GPU_vertformat_attr_add(&format_uv, "uv", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - Gwn_VertFormat format_col = {0}; - uint col_id = GWN_vertformat_attr_add(&format_col, "col", GWN_COMP_U16, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat format_col = {0}; + uint col_id = GPU_vertformat_attr_add(&format_col, "col", GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); memset(cache->uv_layer_names, 0, sizeof(cache->uv_layer_names)); memset(cache->col_layer_names, 0, sizeof(cache->col_layer_names)); /* Strand Data */ - cache->proc_strand_buf = GWN_vertbuf_create_with_format(&format_data); - GWN_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_len); - GWN_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step); + cache->proc_strand_buf = GPU_vertbuf_create_with_format(&format_data); + GPU_vertbuf_data_alloc(cache->proc_strand_buf, cache->strands_len); + GPU_vertbuf_attr_get_raw_data(cache->proc_strand_buf, data_id, &data_step); /* UV layers */ for (int i = 0; i < cache->num_uv_layers; i++) { - cache->proc_uv_buf[i] = GWN_vertbuf_create_with_format(&format_uv); - GWN_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len); - GWN_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]); + cache->proc_uv_buf[i] = GPU_vertbuf_create_with_format(&format_uv); + GPU_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len); + GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]); const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i); uint hash = BLI_ghashutil_strhash_p(name); @@ -835,9 +835,9 @@ static void particle_batch_cache_ensure_procedural_strand_data( } /* Vertex colors */ for (int i = 0; i < cache->num_col_layers; i++) { - cache->proc_col_buf[i] = GWN_vertbuf_create_with_format(&format_col); - GWN_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len); - GWN_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]); + cache->proc_col_buf[i] = GPU_vertbuf_create_with_format(&format_col); + GPU_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len); + GPU_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]); const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i); uint hash = BLI_ghashutil_strhash_p(name); @@ -914,15 +914,15 @@ static void particle_batch_cache_ensure_procedural_strand_data( } /* Create vbo immediatly to bind to texture buffer. */ - GWN_vertbuf_use(cache->proc_strand_buf); + GPU_vertbuf_use(cache->proc_strand_buf); cache->strand_tex = GPU_texture_create_from_vertbuf(cache->proc_strand_buf); for (int i = 0; i < cache->num_uv_layers; i++) { - GWN_vertbuf_use(cache->proc_uv_buf[i]); + GPU_vertbuf_use(cache->proc_uv_buf[i]); cache->uv_tex[i] = GPU_texture_create_from_vertbuf(cache->proc_uv_buf[i]); } for (int i = 0; i < cache->num_col_layers; i++) { - GWN_vertbuf_use(cache->proc_col_buf[i]); + GPU_vertbuf_use(cache->proc_col_buf[i]); cache->col_tex[i] = GPU_texture_create_from_vertbuf(cache->proc_col_buf[i]); } } @@ -943,19 +943,19 @@ static void particle_batch_cache_ensure_procedural_indices( int verts_per_hair = cache->final[subdiv].strands_res * thickness_res; /* +1 for primitive restart */ int element_count = (verts_per_hair + 1) * cache->strands_len; - Gwn_PrimType prim_type = (thickness_res == 1) ? GWN_PRIM_LINE_STRIP : GWN_PRIM_TRI_STRIP; + GPUPrimType prim_type = (thickness_res == 1) ? GPU_PRIM_LINE_STRIP : GPU_PRIM_TRI_STRIP; - static Gwn_VertFormat format = { 0 }; - GWN_vertformat_clear(&format); + static GPUVertFormat format = { 0 }; + GPU_vertformat_clear(&format); /* initialize vertex format */ - GWN_vertformat_attr_add(&format, "dummy", GWN_COMP_U8, 1, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, 1); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 1); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex(&elb, prim_type, element_count, element_count, true); + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex(&elb, prim_type, element_count, element_count, true); if (edit != NULL && edit->pathcache != NULL) { particle_batch_cache_fill_segments_indices( @@ -976,11 +976,11 @@ static void particle_batch_cache_ensure_procedural_indices( } } - cache->final[subdiv].proc_hairs[thickness_res - 1] = GWN_batch_create_ex( + cache->final[subdiv].proc_hairs[thickness_res - 1] = GPU_batch_create_ex( prim_type, vbo, - GWN_indexbuf_build(&elb), - GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + GPU_indexbuf_build(&elb), + GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); } static void particle_batch_cache_ensure_procedural_pos( @@ -993,14 +993,14 @@ static void particle_batch_cache_ensure_procedural_pos( } /* initialize vertex format */ - Gwn_VertFormat format = {0}; - uint pos_id = GWN_vertformat_attr_add(&format, "posTime", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat format = {0}; + uint pos_id = GPU_vertformat_attr_add(&format, "posTime", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - cache->proc_point_buf = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->proc_point_buf, cache->point_len); + cache->proc_point_buf = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(cache->proc_point_buf, cache->point_len); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &pos_step); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(cache->proc_point_buf, pos_id, &pos_step); if (edit != NULL && edit->pathcache != NULL) { particle_batch_cache_fill_segments_proc_pos( @@ -1027,7 +1027,7 @@ static void particle_batch_cache_ensure_procedural_pos( } /* Create vbo immediatly to bind to texture buffer. */ - GWN_vertbuf_use(cache->proc_point_buf); + GPU_vertbuf_use(cache->proc_point_buf); cache->point_tex = GPU_texture_create_from_vertbuf(cache->proc_point_buf); } @@ -1045,10 +1045,10 @@ static void particle_batch_cache_ensure_pos_and_seg( int curr_point = 0; ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; - GWN_VERTBUF_DISCARD_SAFE(hair_cache->pos); - GWN_INDEXBUF_DISCARD_SAFE(hair_cache->indices); + GPU_VERTBUF_DISCARD_SAFE(hair_cache->pos); + GPU_INDEXBUF_DISCARD_SAFE(hair_cache->indices); - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; HairAttributeID attr_id; uint *uv_id = NULL; uint *col_id = NULL; @@ -1072,12 +1072,12 @@ static void particle_batch_cache_ensure_pos_and_seg( } } - GWN_vertformat_clear(&format); + GPU_vertformat_clear(&format); /* initialize vertex format */ - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.tan = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - attr_id.ind = GWN_vertformat_attr_add(&format, "ind", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.tan = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + attr_id.ind = GPU_vertformat_attr_add(&format, "ind", GPU_COMP_I32, 1, GPU_FETCH_INT); if (psmd) { uv_id = MEM_mallocN(sizeof(*uv_id) * num_uv_layers, "UV attrib format"); @@ -1088,10 +1088,10 @@ static void particle_batch_cache_ensure_pos_and_seg( char uuid[32]; BLI_snprintf(uuid, sizeof(uuid), "u%u", BLI_ghashutil_strhash_p(name)); - uv_id[i] = GWN_vertformat_attr_add(&format, uuid, GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uv_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (i == active_uv) { - GWN_vertformat_alias_add(&format, "u"); + GPU_vertformat_alias_add(&format, "u"); } } @@ -1100,21 +1100,21 @@ static void particle_batch_cache_ensure_pos_and_seg( char uuid[32]; BLI_snprintf(uuid, sizeof(uuid), "c%u", BLI_ghashutil_strhash_p(name)); - col_id[i] = GWN_vertformat_attr_add(&format, uuid, GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + col_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (i == active_col) { - GWN_vertformat_alias_add(&format, "c"); + GPU_vertformat_alias_add(&format, "c"); } } } - hair_cache->pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len); + hair_cache->pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex( + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex( &elb, - GWN_PRIM_LINE_STRIP, + GPU_PRIM_LINE_STRIP, hair_cache->elems_len, hair_cache->point_len, true); @@ -1183,7 +1183,7 @@ static void particle_batch_cache_ensure_pos_and_seg( if (psmd != NULL) { MEM_freeN(uv_id); } - hair_cache->indices = GWN_indexbuf_build(&elb); + hair_cache->indices = GPU_indexbuf_build(&elb); } static void particle_batch_cache_ensure_pos( @@ -1195,7 +1195,7 @@ static void particle_batch_cache_ensure_pos( return; } - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, rot_id, val_id; int i, curr_point; ParticleData *pa; @@ -1217,17 +1217,17 @@ static void particle_batch_cache_ensure_pos( } } - GWN_VERTBUF_DISCARD_SAFE(point_cache->pos); + GPU_VERTBUF_DISCARD_SAFE(point_cache->pos); if (format.attr_len == 0) { /* initialize vertex format */ - pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - rot_id = GWN_vertformat_attr_add(&format, "rot", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - val_id = GWN_vertformat_attr_add(&format, "val", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + rot_id = GPU_vertformat_attr_add(&format, "rot", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + val_id = GPU_vertformat_attr_add(&format, "val", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } - point_cache->pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(point_cache->pos, psys->totpart); + point_cache->pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(point_cache->pos, psys->totpart); for (curr_point = 0, i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) { state.time = DEG_get_ctime(draw_ctx->depsgraph); @@ -1237,8 +1237,8 @@ static void particle_batch_cache_ensure_pos( float val; - GWN_vertbuf_attr_set(point_cache->pos, pos_id, curr_point, pa->state.co); - GWN_vertbuf_attr_set(point_cache->pos, rot_id, curr_point, pa->state.rot); + GPU_vertbuf_attr_set(point_cache->pos, pos_id, curr_point, pa->state.co); + GPU_vertbuf_attr_set(point_cache->pos, rot_id, curr_point, pa->state.rot); switch (psys->part->draw_col) { case PART_DRAW_COL_VEL: @@ -1254,13 +1254,13 @@ static void particle_batch_cache_ensure_pos( break; } - GWN_vertbuf_attr_set(point_cache->pos, val_id, curr_point, &val); + GPU_vertbuf_attr_set(point_cache->pos, val_id, curr_point, &val); curr_point++; } if (curr_point != psys->totpart) { - GWN_vertbuf_data_resize(point_cache->pos, curr_point); + GPU_vertbuf_data_resize(point_cache->pos, curr_point); } } @@ -1334,7 +1334,7 @@ static void drw_particle_get_hair_source( } } -Gwn_Batch *DRW_particles_batch_cache_get_hair( +GPUBatch *DRW_particles_batch_cache_get_hair( Object *object, ParticleSystem *psys, ModifierData *md) @@ -1346,27 +1346,27 @@ Gwn_Batch *DRW_particles_batch_cache_get_hair( drw_particle_get_hair_source(object, psys, md, NULL, &source); ensure_seg_pt_count(source.edit, source.psys, &cache->hair); particle_batch_cache_ensure_pos_and_seg(source.edit, source.psys, source.md, &cache->hair); - cache->hair.hairs = GWN_batch_create( - GWN_PRIM_LINE_STRIP, + cache->hair.hairs = GPU_batch_create( + GPU_PRIM_LINE_STRIP, cache->hair.pos, cache->hair.indices); } return cache->hair.hairs; } -Gwn_Batch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *psys) +GPUBatch *DRW_particles_batch_cache_get_dots(Object *object, ParticleSystem *psys) { ParticleBatchCache *cache = particle_batch_cache_get(psys); if (cache->point.points == NULL) { particle_batch_cache_ensure_pos(object, psys, &cache->point); - cache->point.points = GWN_batch_create(GWN_PRIM_POINTS, cache->point.pos, NULL); + cache->point.points = GPU_batch_create(GPU_PRIM_POINTS, cache->point.pos, NULL); } return cache->point.points; } -Gwn_Batch *DRW_particles_batch_cache_get_edit_strands( +GPUBatch *DRW_particles_batch_cache_get_edit_strands( Object *object, ParticleSystem *psys, PTCacheEdit *edit) @@ -1378,8 +1378,8 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_strands( drw_particle_update_ptcache_edit(object, psys, edit); ensure_seg_pt_count(edit, psys, &cache->edit_hair); particle_batch_cache_ensure_pos_and_seg(edit, psys, NULL, &cache->edit_hair); - cache->edit_hair.hairs = GWN_batch_create( - GWN_PRIM_LINE_STRIP, + cache->edit_hair.hairs = GPU_batch_create( + GPU_PRIM_LINE_STRIP, cache->edit_hair.pos, cache->edit_hair.indices); return cache->edit_hair.hairs; @@ -1419,19 +1419,19 @@ static void particle_batch_cache_ensure_edit_inner_pos( return; } - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, color_id; - GWN_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->edit_inner_pos); if (format.attr_len == 0) { /* initialize vertex format */ - pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); } - cache->edit_inner_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len); + cache->edit_inner_pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len); float selected_color[4], normal_color[4]; edit_colors_get(edit, selected_color, normal_color); @@ -1441,19 +1441,19 @@ static void particle_batch_cache_ensure_edit_inner_pos( const PTCacheEditPoint *point = &edit->points[point_index]; for (int key_index = 0; key_index < point->totkey - 1; key_index++) { PTCacheEditKey *key = &point->keys[key_index]; - GWN_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co); + GPU_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co); if (key->flag & PEK_SELECT) { - GWN_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, selected_color); + GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, selected_color); } else { - GWN_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, normal_color); + GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, normal_color); } global_key_index++; } } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points( +GPUBatch *DRW_particles_batch_cache_get_edit_inner_points( Object *object, ParticleSystem *psys, PTCacheEdit *edit) @@ -1465,8 +1465,8 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_inner_points( drw_particle_update_ptcache_edit(object, psys, edit); ensure_edit_inner_points_count(edit, cache); particle_batch_cache_ensure_edit_inner_pos(edit, cache); - cache->edit_inner_points = GWN_batch_create( - GWN_PRIM_POINTS, + cache->edit_inner_points = GPU_batch_create( + GPU_PRIM_POINTS, cache->edit_inner_pos, NULL); return cache->edit_inner_points; @@ -1490,19 +1490,19 @@ static void particle_batch_cache_ensure_edit_tip_pos( return; } - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint pos_id, color_id; - GWN_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->edit_tip_pos); if (format.attr_len == 0) { /* initialize vertex format */ - pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - color_id = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + color_id = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); } - cache->edit_tip_pos = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len); + cache->edit_tip_pos = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len); float selected_color[4], normal_color[4]; edit_colors_get(edit, selected_color, normal_color); @@ -1510,17 +1510,17 @@ static void particle_batch_cache_ensure_edit_tip_pos( for (int point_index = 0; point_index < edit->totpoint; point_index++) { const PTCacheEditPoint *point = &edit->points[point_index]; PTCacheEditKey *key = &point->keys[point->totkey - 1]; - GWN_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co); + GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, point_index, key->world_co); if (key->flag & PEK_SELECT) { - GWN_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, selected_color); + GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, selected_color); } else { - GWN_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, normal_color); + GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, point_index, normal_color); } } } -Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points( +GPUBatch *DRW_particles_batch_cache_get_edit_tip_points( Object *object, ParticleSystem *psys, PTCacheEdit *edit) @@ -1532,8 +1532,8 @@ Gwn_Batch *DRW_particles_batch_cache_get_edit_tip_points( drw_particle_update_ptcache_edit(object, psys, edit); ensure_edit_tip_points_count(edit, cache); particle_batch_cache_ensure_edit_tip_pos(edit, cache); - cache->edit_tip_points = GWN_batch_create( - GWN_PRIM_POINTS, + cache->edit_tip_points = GPU_batch_create( + GPU_PRIM_POINTS, cache->edit_tip_pos, NULL); return cache->edit_tip_points; diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index df80300417e..c9fc5eba079 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -208,29 +208,29 @@ static struct { } g_shaders = {NULL}; static struct { - struct Gwn_VertFormat *instance_screenspace; - struct Gwn_VertFormat *instance_color; - struct Gwn_VertFormat *instance_screen_aligned; - struct Gwn_VertFormat *instance_scaled; - struct Gwn_VertFormat *instance_sized; - struct Gwn_VertFormat *instance_outline; - struct Gwn_VertFormat *instance; - struct Gwn_VertFormat *instance_camera; - struct Gwn_VertFormat *instance_distance_lines; - struct Gwn_VertFormat *instance_spot; - struct Gwn_VertFormat *instance_bone; - struct Gwn_VertFormat *instance_bone_stick; - struct Gwn_VertFormat *instance_bone_outline; - struct Gwn_VertFormat *instance_bone_envelope; - struct Gwn_VertFormat *instance_bone_envelope_distance; - struct Gwn_VertFormat *instance_bone_envelope_outline; - struct Gwn_VertFormat *instance_mball_handles; - struct Gwn_VertFormat *dynlines_color; + struct GPUVertFormat *instance_screenspace; + struct GPUVertFormat *instance_color; + struct GPUVertFormat *instance_screen_aligned; + struct GPUVertFormat *instance_scaled; + struct GPUVertFormat *instance_sized; + struct GPUVertFormat *instance_outline; + struct GPUVertFormat *instance; + struct GPUVertFormat *instance_camera; + struct GPUVertFormat *instance_distance_lines; + struct GPUVertFormat *instance_spot; + struct GPUVertFormat *instance_bone; + struct GPUVertFormat *instance_bone_stick; + struct GPUVertFormat *instance_bone_outline; + struct GPUVertFormat *instance_bone_envelope; + struct GPUVertFormat *instance_bone_envelope_distance; + struct GPUVertFormat *instance_bone_envelope_outline; + struct GPUVertFormat *instance_mball_handles; + struct GPUVertFormat *dynlines_color; } g_formats = {NULL}; void DRW_globals_free(void) { - struct Gwn_VertFormat **format = &g_formats.instance_screenspace; + struct GPUVertFormat **format = &g_formats.instance_screenspace; for (int i = 0; i < sizeof(g_formats) / sizeof(void *); ++i, ++format) { MEM_SAFE_FREE(*format); } @@ -304,7 +304,7 @@ DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float color[4 return grp; } -DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Gwn_Batch *geom, float *size) +DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct GPUBatch *geom, float *size) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR); @@ -322,7 +322,7 @@ DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Gwn_Batch *g return grp; } -DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct GPUBatch *geom) { static float light[3] = {0.0f, 0.0f, 1.0f}; GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR); @@ -338,7 +338,7 @@ DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR); @@ -352,7 +352,7 @@ DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED); @@ -368,7 +368,7 @@ DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Gwn_Batch return grp; } -DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS); @@ -384,7 +384,7 @@ DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Gwn_Batch *ge return grp; } -DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE); @@ -399,7 +399,7 @@ DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); @@ -414,7 +414,7 @@ DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct Gwn_Batch *geom, int *baseid) +DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct GPUBatch *geom, int *baseid) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE); @@ -430,7 +430,7 @@ DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct Gwn_Batch *geom, return grp; } -DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_CAMERA); @@ -447,7 +447,7 @@ DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom) return grp; } -DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_DISTANCE_LINES); static float point_size = 4.0f; @@ -465,7 +465,7 @@ DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Gwn_Batch return grp; } -DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct GPUBatch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR); static const int True = true; @@ -600,7 +600,7 @@ DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass) } /* Only works with batches with adjacency infos. */ -DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct GPUBatch *geom) { if (g_shaders.shape_outline == NULL) { g_shaders.shape_outline = DRW_shader_create( @@ -623,7 +623,7 @@ DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct Gwn_B return grp; } -DRWShadingGroup *shgroup_instance_bone_shape_solid(DRWPass *pass, struct Gwn_Batch *geom) +DRWShadingGroup *shgroup_instance_bone_shape_solid(DRWPass *pass, struct GPUBatch *geom) { if (g_shaders.shape_solid == NULL) { g_shaders.shape_solid = DRW_shader_create( diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index b4ae0600f02..80b2ec8db71 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -28,7 +28,7 @@ struct DRWPass; struct DRWShadingGroup; -struct Gwn_Batch; +struct GPUBatch; struct GPUMaterial; struct Object; struct ViewLayer; @@ -112,25 +112,25 @@ struct DRWShadingGroup *shgroup_dynlines_dashed_uniform_color(struct DRWPass *pa struct DRWShadingGroup *shgroup_dynpoints_uniform_color(struct DRWPass *pass, float color[4], float *size); struct DRWShadingGroup *shgroup_groundlines_uniform_color(struct DRWPass *pass, float color[4]); struct DRWShadingGroup *shgroup_groundpoints_uniform_color(struct DRWPass *pass, float color[4]); -struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct Gwn_Batch *geom, float *size); -struct DRWShadingGroup *shgroup_instance_solid(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_wire(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_outline(struct DRWPass *pass, struct Gwn_Batch *geom, int *baseid); -struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct Gwn_Batch *geom); +struct DRWShadingGroup *shgroup_instance_screenspace(struct DRWPass *pass, struct GPUBatch *geom, float *size); +struct DRWShadingGroup *shgroup_instance_solid(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_wire(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_screen_aligned(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_axis_names(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_image_plane(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_scaled(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_outline(struct DRWPass *pass, struct GPUBatch *geom, int *baseid); +struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct GPUBatch *geom); struct DRWShadingGroup *shgroup_instance_mball_handles(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_axes(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_envelope_distance(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_envelope_outline(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass); -struct DRWShadingGroup *shgroup_instance_bone_shape_outline(struct DRWPass *pass, struct Gwn_Batch *geom); -struct DRWShadingGroup *shgroup_instance_bone_shape_solid(struct DRWPass *pass, struct Gwn_Batch *geom); +struct DRWShadingGroup *shgroup_instance_bone_shape_outline(struct DRWPass *pass, struct GPUBatch *geom); +struct DRWShadingGroup *shgroup_instance_bone_shape_solid(struct DRWPass *pass, struct GPUBatch *geom); struct DRWShadingGroup *shgroup_instance_bone_sphere_outline(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_sphere_solid(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_stick(struct DRWPass *pass); diff --git a/source/blender/draw/intern/draw_debug.c b/source/blender/draw/intern/draw_debug.c index 64e76a339c1..8af13d66c28 100644 --- a/source/blender/draw/intern/draw_debug.c +++ b/source/blender/draw/intern/draw_debug.c @@ -147,13 +147,13 @@ static void drw_debug_draw_lines(void) return; } - Gwn_VertFormat *vert_format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(vert_format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *vert_format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(vert_format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, count * 2); + immBegin(GPU_PRIM_LINES, count * 2); while (DST.debug.lines) { void *next = DST.debug.lines->next; @@ -181,36 +181,36 @@ static void drw_debug_draw_spheres(void) } float one = 1.0f; - Gwn_VertFormat vert_format = {0}; - uint mat = GWN_vertformat_attr_add(&vert_format, "InstanceModelMatrix", GWN_COMP_F32, 16, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(&vert_format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint siz = GWN_vertformat_attr_add(&vert_format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); + 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); - Gwn_VertBuf *inst_vbo = GWN_vertbuf_create_with_format(&vert_format); + GPUVertBuf *inst_vbo = GPU_vertbuf_create_with_format(&vert_format); - GWN_vertbuf_data_alloc(inst_vbo, count); + GPU_vertbuf_data_alloc(inst_vbo, count); int v = 0; while (DST.debug.spheres) { void *next = DST.debug.spheres->next; - GWN_vertbuf_attr_set(inst_vbo, mat, v, DST.debug.spheres->mat[0]); - GWN_vertbuf_attr_set(inst_vbo, col, v, DST.debug.spheres->color); - GWN_vertbuf_attr_set(inst_vbo, siz, v, &one); + 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++; MEM_freeN(DST.debug.spheres); DST.debug.spheres = next; } - Gwn_Batch *empty_sphere = DRW_cache_empty_sphere_get(); + GPUBatch *empty_sphere = DRW_cache_empty_sphere_get(); - Gwn_Batch *draw_batch = GWN_batch_create(GWN_PRIM_LINES, empty_sphere->verts[0], NULL); - GWN_batch_instbuf_set(draw_batch, inst_vbo, true); - GWN_batch_program_set_builtin(draw_batch, GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); + 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); - GWN_batch_draw(draw_batch); - GWN_batch_discard(draw_batch); + GPU_batch_draw(draw_batch); + GPU_batch_discard(draw_batch); } void drw_debug_draw(void) diff --git a/source/blender/draw/intern/draw_hair_private.h b/source/blender/draw/intern/draw_hair_private.h index 17acd7e6259..41f91e02459 100644 --- a/source/blender/draw/intern/draw_hair_private.h +++ b/source/blender/draw/intern/draw_hair_private.h @@ -42,32 +42,32 @@ struct ParticleHairCache; typedef struct ParticleHairFinalCache { /* Output of the subdivision stage: vertex buff sized to subdiv level. */ - Gwn_VertBuf *proc_buf; + GPUVertBuf *proc_buf; GPUTexture *proc_tex; /* Just contains a huge index buffer used to draw the final hair. */ - Gwn_Batch *proc_hairs[MAX_THICKRES]; + GPUBatch *proc_hairs[MAX_THICKRES]; int strands_res; /* points per hair, at least 2 */ } ParticleHairFinalCache; typedef struct ParticleHairCache { - Gwn_VertBuf *pos; - Gwn_IndexBuf *indices; - Gwn_Batch *hairs; + GPUVertBuf *pos; + GPUIndexBuf *indices; + GPUBatch *hairs; /* Hair Procedural display: Interpolation is done on the GPU. */ - Gwn_VertBuf *proc_point_buf; /* Input control points */ + GPUVertBuf *proc_point_buf; /* Input control points */ GPUTexture *point_tex; - Gwn_VertBuf *proc_strand_buf; /* Infos of control points strands (segment count and base index) */ + GPUVertBuf *proc_strand_buf; /* Infos of control points strands (segment count and base index) */ GPUTexture *strand_tex; - Gwn_VertBuf *proc_uv_buf[MAX_MTFACE]; + GPUVertBuf *proc_uv_buf[MAX_MTFACE]; GPUTexture *uv_tex[MAX_MTFACE]; char uv_layer_names[MAX_MTFACE][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]; - Gwn_VertBuf *proc_col_buf[MAX_MCOL]; + GPUVertBuf *proc_col_buf[MAX_MCOL]; GPUTexture *col_tex[MAX_MCOL]; char col_layer_names[MAX_MCOL][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]; diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c index e322d4780d5..89cffd6c19c 100644 --- a/source/blender/draw/intern/draw_instance_data.c +++ b/source/blender/draw/intern/draw_instance_data.c @@ -45,17 +45,17 @@ typedef struct DRWBatchingBuffer { struct DRWShadingGroup *shgroup; /* Link back to the owning shGroup. Also tells if it's used */ - Gwn_VertFormat *format; /* Identifier. */ - Gwn_VertBuf *vert; /* Gwn_VertBuf contained in the Gwn_Batch. */ - Gwn_Batch *batch; /* Gwn_Batch containing the Gwn_VertBuf. */ + GPUVertFormat *format; /* Identifier. */ + GPUVertBuf *vert; /* GPUVertBuf contained in the GPUBatch. */ + GPUBatch *batch; /* GPUBatch containing the GPUVertBuf. */ } DRWBatchingBuffer; typedef struct DRWInstancingBuffer { struct DRWShadingGroup *shgroup; /* Link back to the owning shGroup. Also tells if it's used */ - Gwn_VertFormat *format; /* Identifier. */ - Gwn_Batch *instance; /* Identifier. */ - Gwn_VertBuf *vert; /* Gwn_VertBuf contained in the Gwn_Batch. */ - Gwn_Batch *batch; /* Gwn_Batch containing the Gwn_VertBuf. */ + GPUVertFormat *format; /* Identifier. */ + GPUBatch *instance; /* Identifier. */ + GPUVertBuf *vert; /* GPUVertBuf contained in the GPUBatch. */ + GPUBatch *batch; /* GPUBatch containing the GPUVertBuf. */ } DRWInstancingBuffer; typedef struct DRWInstanceChunk { @@ -100,7 +100,7 @@ static ListBase g_idatalists = {NULL, NULL}; * that would be too slow]). **/ -static void instance_batch_free(Gwn_Batch *batch, void *UNUSED(user_data)) +static void instance_batch_free(GPUBatch *batch, void *UNUSED(user_data)) { /* Free all batches that have the same key before they are reused. */ /* TODO: Make it thread safe! Batch freeing can happen from another thread. */ @@ -111,8 +111,8 @@ static void instance_batch_free(Gwn_Batch *batch, void *UNUSED(user_data)) for (int i = 0; i < idatalist->instancing.alloc_size; i++, ibuf++) { if (ibuf->instance == batch) { BLI_assert(ibuf->shgroup == NULL); /* Make sure it has no other users. */ - GWN_VERTBUF_DISCARD_SAFE(ibuf->vert); - GWN_BATCH_DISCARD_SAFE(ibuf->batch); + GPU_VERTBUF_DISCARD_SAFE(ibuf->vert); + GPU_BATCH_DISCARD_SAFE(ibuf->batch); /* Tag as non alloced. */ ibuf->format = NULL; } @@ -121,8 +121,8 @@ static void instance_batch_free(Gwn_Batch *batch, void *UNUSED(user_data)) } void DRW_batching_buffer_request( - DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_PrimType type, struct DRWShadingGroup *shgroup, - Gwn_Batch **r_batch, Gwn_VertBuf **r_vert) + DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUPrimType type, struct DRWShadingGroup *shgroup, + GPUBatch **r_batch, GPUVertBuf **r_vert) { DRWInstanceChunk *chunk = &idatalist->batching; DRWBatchingBuffer *bbuf = idatalist->batching.bbufs; @@ -152,16 +152,16 @@ void DRW_batching_buffer_request( } /* Create the batch. */ bbuf = chunk->bbufs + new_id; - bbuf->vert = *r_vert = GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_DYNAMIC); - bbuf->batch = *r_batch = GWN_batch_create_ex(type, bbuf->vert, NULL, 0); + bbuf->vert = *r_vert = GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_DYNAMIC); + bbuf->batch = *r_batch = GPU_batch_create_ex(type, bbuf->vert, NULL, 0); bbuf->format = format; bbuf->shgroup = shgroup; - GWN_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK); + GPU_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK); } void DRW_instancing_buffer_request( - DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_Batch *instance, struct DRWShadingGroup *shgroup, - Gwn_Batch **r_batch, Gwn_VertBuf **r_vert) + DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUBatch *instance, struct DRWShadingGroup *shgroup, + GPUBatch **r_batch, GPUVertBuf **r_vert) { DRWInstanceChunk *chunk = &idatalist->instancing; DRWInstancingBuffer *ibuf = idatalist->instancing.ibufs; @@ -193,15 +193,15 @@ void DRW_instancing_buffer_request( } /* Create the batch. */ ibuf = chunk->ibufs + new_id; - ibuf->vert = *r_vert = GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_DYNAMIC); - ibuf->batch = *r_batch = GWN_batch_duplicate(instance); + ibuf->vert = *r_vert = GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_DYNAMIC); + ibuf->batch = *r_batch = GPU_batch_duplicate(instance); ibuf->format = format; ibuf->shgroup = shgroup; ibuf->instance = instance; - GWN_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK); - GWN_batch_instbuf_set(ibuf->batch, ibuf->vert, false); + GPU_vertbuf_data_alloc(*r_vert, BUFFER_VERTS_CHUNK); + GPU_batch_instbuf_set(ibuf->batch, ibuf->vert, false); /* Make sure to free this ibuf if the instance batch gets free. */ - GWN_batch_callback_free_set(instance, &instance_batch_free, NULL); + GPU_batch_callback_free_set(instance, &instance_batch_free, NULL); } void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) @@ -218,14 +218,14 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) if (vert_len + BUFFER_VERTS_CHUNK <= bbuf->vert->vertex_len) { uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; - GWN_vertbuf_data_resize(bbuf->vert, size); + GPU_vertbuf_data_resize(bbuf->vert, size); } - GWN_vertbuf_use(bbuf->vert); /* Send data. */ + GPU_vertbuf_use(bbuf->vert); /* Send data. */ bbuf->shgroup = NULL; /* Set as non used for the next round. */ } else { - GWN_VERTBUF_DISCARD_SAFE(bbuf->vert); - GWN_BATCH_DISCARD_SAFE(bbuf->batch); + GPU_VERTBUF_DISCARD_SAFE(bbuf->vert); + GPU_BATCH_DISCARD_SAFE(bbuf->batch); bbuf->format = NULL; /* Tag as non alloced. */ } } @@ -250,14 +250,14 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist) if (vert_len + BUFFER_VERTS_CHUNK <= ibuf->vert->vertex_len) { uint size = vert_len + BUFFER_VERTS_CHUNK - 1; size = size - size % BUFFER_VERTS_CHUNK; - GWN_vertbuf_data_resize(ibuf->vert, size); + GPU_vertbuf_data_resize(ibuf->vert, size); } - GWN_vertbuf_use(ibuf->vert); /* Send data. */ + GPU_vertbuf_use(ibuf->vert); /* Send data. */ ibuf->shgroup = NULL; /* Set as non used for the next round. */ } else { - GWN_VERTBUF_DISCARD_SAFE(ibuf->vert); - GWN_BATCH_DISCARD_SAFE(ibuf->batch); + GPU_VERTBUF_DISCARD_SAFE(ibuf->vert); + GPU_BATCH_DISCARD_SAFE(ibuf->batch); ibuf->format = NULL; /* Tag as non alloced. */ } } @@ -366,15 +366,15 @@ void DRW_instance_data_list_free(DRWInstanceDataList *idatalist) DRWBatchingBuffer *bbuf = idatalist->batching.bbufs; for (int i = 0; i < idatalist->batching.alloc_size; i++, bbuf++) { - GWN_VERTBUF_DISCARD_SAFE(bbuf->vert); - GWN_BATCH_DISCARD_SAFE(bbuf->batch); + GPU_VERTBUF_DISCARD_SAFE(bbuf->vert); + GPU_BATCH_DISCARD_SAFE(bbuf->batch); } MEM_freeN(idatalist->batching.bbufs); DRWInstancingBuffer *ibuf = idatalist->instancing.ibufs; for (int i = 0; i < idatalist->instancing.alloc_size; i++, ibuf++) { - GWN_VERTBUF_DISCARD_SAFE(ibuf->vert); - GWN_BATCH_DISCARD_SAFE(ibuf->batch); + GPU_VERTBUF_DISCARD_SAFE(ibuf->vert); + GPU_BATCH_DISCARD_SAFE(ibuf->batch); } MEM_freeN(idatalist->instancing.ibufs); diff --git a/source/blender/draw/intern/draw_instance_data.h b/source/blender/draw/intern/draw_instance_data.h index 0ea40a50a6b..174f03e3bc7 100644 --- a/source/blender/draw/intern/draw_instance_data.h +++ b/source/blender/draw/intern/draw_instance_data.h @@ -43,11 +43,11 @@ DRWInstanceData *DRW_instance_data_request( DRWInstanceDataList *idatalist, uint attrib_size); void DRW_batching_buffer_request( - DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_PrimType type, struct DRWShadingGroup *shgroup, - Gwn_Batch **r_batch, Gwn_VertBuf **r_vert); + DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUPrimType type, struct DRWShadingGroup *shgroup, + GPUBatch **r_batch, GPUVertBuf **r_vert); void DRW_instancing_buffer_request( - DRWInstanceDataList *idatalist, Gwn_VertFormat *format, Gwn_Batch *instance, struct DRWShadingGroup *shgroup, - Gwn_Batch **r_batch, Gwn_VertBuf **r_vert); + DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUBatch *instance, struct DRWShadingGroup *shgroup, + GPUBatch **r_batch, GPUVertBuf **r_vert); /* Upload all instance data to the GPU as soon as possible. */ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 4c6f8962d82..92603a0ce53 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -228,9 +228,9 @@ void DRW_transform_to_display(GPUTexture *tex) { drw_state_set(DRW_STATE_WRITE_COLOR); - Gwn_VertFormat *vert_format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *vert_format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); const float dither = 1.0f; @@ -262,7 +262,7 @@ void DRW_transform_to_display(GPUTexture *tex) immUniformMatrix4fv("ModelViewProjectionMatrix", mat); /* Full screen triangle */ - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immAttrib2f(texco, 0.0f, 0.0f); immVertex2f(pos, -1.0f, -1.0f); @@ -287,21 +287,21 @@ void DRW_transform_to_display(GPUTexture *tex) void DRW_transform_none(GPUTexture *tex) { /* Draw as texture for final render (without immediate mode). */ - Gwn_Batch *geom = DRW_cache_fullscreen_quad_texcoord_get(); - GWN_batch_program_set_builtin(geom, GPU_SHADER_2D_IMAGE_COLOR); + GPUBatch *geom = DRW_cache_fullscreen_quad_get(); + GPU_batch_program_set_builtin(geom, GPU_SHADER_2D_IMAGE_COLOR); GPU_texture_bind(tex, 0); const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - GWN_batch_uniform_4fv(geom, "color", white); + GPU_batch_uniform_4fv(geom, "color", white); float mat[4][4]; unit_m4(mat); - GWN_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat); + GPU_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat); - GWN_batch_program_use_begin(geom); - GWN_batch_draw_range_ex(geom, 0, 0, false); - GWN_batch_program_use_end(geom); + GPU_batch_program_use_begin(geom); + GPU_batch_draw_range_ex(geom, 0, 0, false); + GPU_batch_program_use_end(geom); GPU_texture_unbind(tex); } @@ -327,7 +327,7 @@ void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color) BLI_assert(samples > 0); BLI_assert(GPU_texture_samples(src_color) == samples); - Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); + GPUBatch *geom = DRW_cache_fullscreen_quad_get(); int builtin; switch (samples) { @@ -341,21 +341,21 @@ void DRW_multisamples_resolve(GPUTexture *src_depth, GPUTexture *src_color) break; } - GWN_batch_program_set_builtin(geom, builtin); + GPU_batch_program_set_builtin(geom, builtin); GPU_texture_bind(src_depth, 0); GPU_texture_bind(src_color, 1); - GWN_batch_uniform_1i(geom, "depthMulti", 0); - GWN_batch_uniform_1i(geom, "colorMulti", 1); + GPU_batch_uniform_1i(geom, "depthMulti", 0); + GPU_batch_uniform_1i(geom, "colorMulti", 1); float mat[4][4]; unit_m4(mat); - GWN_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat); + GPU_batch_uniform_mat4(geom, "ModelViewProjectionMatrix", mat); /* avoid gpuMatrix calls */ - GWN_batch_program_use_begin(geom); - GWN_batch_draw_range_ex(geom, 0, 0, false); - GWN_batch_program_use_end(geom); + GPU_batch_program_use_begin(geom); + GPU_batch_draw_range_ex(geom, 0, 0, false); + GPU_batch_program_use_end(geom); } /** \} */ @@ -1573,14 +1573,14 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) } void *re_gl_context = RE_gl_context_get(render); - void *re_gwn_context = NULL; + void *re_gpu_context = NULL; /* Changing Context */ if (re_gl_context != NULL) { DRW_opengl_render_context_enable(re_gl_context); - /* We need to query gwn context after a gl context has been bound. */ - re_gwn_context = RE_gwn_context_get(render); - DRW_gawain_render_context_enable(re_gwn_context); + /* We need to query gpu context after a gl context has been bound. */ + re_gpu_context = RE_gpu_context_get(render); + DRW_gawain_render_context_enable(re_gpu_context); } else { DRW_opengl_context_enable(); @@ -1659,7 +1659,7 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) /* Changing Context */ if (re_gl_context != NULL) { - DRW_gawain_render_context_disable(re_gwn_context); + DRW_gawain_render_context_disable(re_gpu_context); DRW_opengl_render_context_disable(re_gl_context); } else { @@ -1967,9 +1967,9 @@ static void draw_depth_texture_to_screen(GPUTexture *texture) const float w = (float)GPU_texture_width(texture); const float h = (float)GPU_texture_height(texture); - Gwn_VertFormat *format = immVertexFormat(); - uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_IMAGE_DEPTH_COPY); @@ -1977,7 +1977,7 @@ static void draw_depth_texture_to_screen(GPUTexture *texture) immUniform1i("image", 0); /* default GL_TEXTURE0 unit */ - immBegin(GWN_PRIM_TRI_STRIP, 4); + immBegin(GPU_PRIM_TRI_STRIP, 4); immAttrib2f(texcoord, 0.0f, 0.0f); immVertex2f(pos, 0.0f, 0.0f); @@ -2298,7 +2298,7 @@ void DRW_engines_register(void) } } -extern struct Gwn_VertFormat *g_pos_format; /* draw_shgroup.c */ +extern struct GPUVertFormat *g_pos_format; /* draw_shgroup.c */ extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */ extern struct GPUTexture *globals_ramp; /* draw_common.c */ void DRW_engines_free(void) @@ -2352,7 +2352,7 @@ void DRW_opengl_context_create(void) /* This changes the active context. */ DST.gl_context = WM_opengl_context_create(); /* Be sure to create gawain.context too. */ - DST.gwn_context = GWN_context_create(); + DST.gpu_context = GPU_context_create(); if (!G.background) { immActivate(); } @@ -2367,8 +2367,8 @@ void DRW_opengl_context_destroy(void) BLI_assert(BLI_thread_is_main()); if (DST.gl_context != NULL) { WM_opengl_context_activate(DST.gl_context); - GWN_context_active_set(DST.gwn_context); - GWN_context_discard(DST.gwn_context); + GPU_context_active_set(DST.gpu_context); + GPU_context_discard(DST.gpu_context); WM_opengl_context_dispose(DST.gl_context); BLI_ticket_mutex_free(DST.gl_context_mutex); } @@ -2387,7 +2387,7 @@ void DRW_opengl_context_enable(void) } } WM_opengl_context_activate(DST.gl_context); - GWN_context_active_set(DST.gwn_context); + GPU_context_active_set(DST.gpu_context); if (BLI_thread_is_main()) { if (!G.background) { immActivate(); @@ -2411,7 +2411,7 @@ void DRW_opengl_context_disable(void) } else { WM_opengl_context_release(DST.gl_context); - GWN_context_active_set(NULL); + GPU_context_active_set(NULL); } BLI_ticket_mutex_unlock(DST.gl_context_mutex); @@ -2437,20 +2437,20 @@ void DRW_opengl_render_context_disable(void *re_gl_context) } /* Needs to be called AFTER DRW_opengl_render_context_enable() */ -void DRW_gawain_render_context_enable(void *re_gwn_context) +void DRW_gawain_render_context_enable(void *re_gpu_context) { /* If thread is main you should use DRW_opengl_context_enable(). */ BLI_assert(!BLI_thread_is_main()); - GWN_context_active_set(re_gwn_context); + GPU_context_active_set(re_gpu_context); DRW_shape_cache_reset(); /* XXX fix that too. */ } /* Needs to be called BEFORE DRW_opengl_render_context_disable() */ -void DRW_gawain_render_context_disable(void *UNUSED(re_gwn_context)) +void DRW_gawain_render_context_disable(void *UNUSED(re_gpu_context)) { DRW_shape_cache_reset(); /* XXX fix that too. */ - GWN_context_active_set(NULL); + GPU_context_active_set(NULL); } /** \} */ diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 2d44fb5b6d8..9b01f17649c 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -130,7 +130,7 @@ typedef enum { DRW_CALL_RANGE, /* Like single but only draw a range of vertices/indices. */ DRW_CALL_INSTANCES, /* Draw instances without any instancing attribs. */ DRW_CALL_GENERATE, /* Uses a callback to draw with any number of batches. */ - DRW_CALL_PROCEDURAL, /* Generate a drawcall without any Gwn_Batch. */ + DRW_CALL_PROCEDURAL, /* Generate a drawcall without any GPUBatch. */ } DRWCallType; typedef struct DRWCall { @@ -139,14 +139,14 @@ typedef struct DRWCall { union { struct { /* type == DRW_CALL_SINGLE */ - Gwn_Batch *geometry; + GPUBatch *geometry; } single; struct { /* type == DRW_CALL_RANGE */ - Gwn_Batch *geometry; + GPUBatch *geometry; uint start, count; } range; struct { /* type == DRW_CALL_INSTANCES */ - Gwn_Batch *geometry; + GPUBatch *geometry; /* Count can be adjusted between redraw. If needed, we can add fixed count. */ uint *count; } instances; @@ -156,7 +156,7 @@ typedef struct DRWCall { } generate; struct { /* type == DRW_CALL_PROCEDURAL */ uint vert_count; - Gwn_PrimType prim_type; + GPUPrimType prim_type; } procedural; }; @@ -226,16 +226,16 @@ struct DRWShadingGroup { } calls; struct { /* DRW_SHG_FEEDBACK_TRANSFORM */ DRWCall *first, *last; /* Linked list of DRWCall or DRWCallDynamic depending of type */ - struct Gwn_VertBuf *tfeedback_target; /* Transform Feedback target. */ + struct GPUVertBuf *tfeedback_target; /* Transform Feedback target. */ }; struct { /* DRW_SHG_***_BATCH */ - struct Gwn_Batch *batch_geom; /* Result of call batching */ - struct Gwn_VertBuf *batch_vbo; + struct GPUBatch *batch_geom; /* Result of call batching */ + struct GPUVertBuf *batch_vbo; uint primitive_count; }; struct { /* DRW_SHG_INSTANCE[_EXTERNAL] */ - struct Gwn_Batch *instance_geom; - struct Gwn_VertBuf *instance_vbo; + struct GPUBatch *instance_geom; + struct GPUVertBuf *instance_vbo; uint instance_count; float instance_orcofac[2][3]; /* TODO find a better place. */ }; @@ -264,7 +264,7 @@ struct DRWShadingGroup { #endif #ifdef USE_GPU_SELECT - Gwn_VertBuf *inst_selectid; + GPUVertBuf *inst_selectid; DRWPass *pass_parent; /* backlink to pass we're in */ int override_selectid; /* Override for single object instances. */ #endif @@ -379,7 +379,7 @@ typedef struct DRWManager { /* gl_context serves as the offset for clearing only * the top portion of the struct so DO NOT MOVE IT! */ void *gl_context; /* Unique ghost context used by the draw manager. */ - Gwn_Context *gwn_context; + GPUContext *gpu_context; TicketMutex *gl_context_mutex; /* Mutex to lock the drw manager and avoid concurent context usage. */ /** GPU Resource State: Memory storage between drawing. */ diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index c259633982e..dccb869c133 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -41,7 +41,7 @@ #include "intern/gpu_codegen.h" -struct Gwn_VertFormat *g_pos_format = NULL; +struct GPUVertFormat *g_pos_format = NULL; extern struct GPUUniformBuffer *view_ubo; /* draw_manager_exec.c */ @@ -355,7 +355,7 @@ static DRWCallState *drw_call_state_object(DRWShadingGroup *shgroup, float (*obm return DST.ob_state; } -void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4]) +void DRW_shgroup_call_add(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4]) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -371,7 +371,7 @@ void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obm BLI_LINKS_APPEND(&shgroup->calls, call); } -void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4], uint v_sta, uint v_count) +void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_count) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -391,7 +391,7 @@ void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float } static void drw_shgroup_call_procedural_add_ex( - DRWShadingGroup *shgroup, Gwn_PrimType prim_type, uint vert_count, float (*obmat)[4], Object *ob) + DRWShadingGroup *shgroup, GPUPrimType prim_type, uint vert_count, float (*obmat)[4], Object *ob) { BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -414,28 +414,28 @@ static void drw_shgroup_call_procedural_add_ex( void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint point_len, float (*obmat)[4]) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS, point_len, obmat, NULL); + drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_POINTS, point_len, obmat, NULL); } void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint line_count, float (*obmat)[4]) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_LINES, line_count * 2, obmat, NULL); + drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_LINES, line_count * 2, obmat, NULL); } void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint tria_count, float (*obmat)[4]) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count * 3, obmat, NULL); + drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, obmat, NULL); } /* TODO (fclem): this is a sign that the api is starting to be limiting. * Maybe add special function that general purpose for special cases. */ void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup, uint tria_count, Object *ob) { - drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count * 3, NULL, ob); + drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, NULL, ob); } /* These calls can be culled and are optimized for redraw */ -void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, bool bypass_culling) +void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, bool bypass_culling) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -455,7 +455,7 @@ void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, Gwn_Batch *geom, O } void DRW_shgroup_call_object_add_with_callback( - DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, + DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, DRWCallVisibilityFn *callback, void *user_data) { BLI_assert(geom != NULL); @@ -474,7 +474,7 @@ void DRW_shgroup_call_object_add_with_callback( BLI_LINKS_APPEND(&shgroup->calls, call); } -void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obmat)[4], uint *count) +void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4], uint *count) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -492,7 +492,7 @@ void DRW_shgroup_call_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, f } /* These calls can be culled and are optimized for redraw */ -void DRW_shgroup_call_object_instances_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Object *ob, uint *count) +void DRW_shgroup_call_object_instances_add(DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, uint *count) { BLI_assert(geom != NULL); BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL, DRW_SHG_FEEDBACK_TRANSFORM)); @@ -531,7 +531,7 @@ void DRW_shgroup_call_generate_add( static void sculpt_draw_cb( DRWShadingGroup *shgroup, - void (*draw_fn)(DRWShadingGroup *shgroup, Gwn_Batch *geom), + void (*draw_fn)(DRWShadingGroup *shgroup, GPUBatch *geom), void *user_data) { Object *ob = user_data; @@ -540,7 +540,7 @@ static void sculpt_draw_cb( if (pbvh) { BKE_pbvh_draw_cb( pbvh, NULL, NULL, false, - (void (*)(void *, Gwn_Batch *))draw_fn, shgroup); + (void (*)(void *, GPUBatch *))draw_fn, shgroup); } } @@ -554,9 +554,9 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at #ifdef USE_GPU_SELECT if (G.f & G_PICKSEL) { if (shgroup->instance_count == shgroup->inst_selectid->vertex_len) { - GWN_vertbuf_data_resize(shgroup->inst_selectid, shgroup->instance_count + 32); + GPU_vertbuf_data_resize(shgroup->inst_selectid, shgroup->instance_count + 32); } - GWN_vertbuf_attr_set(shgroup->inst_selectid, 0, shgroup->instance_count, &DST.select_id); + GPU_vertbuf_attr_set(shgroup->inst_selectid, 0, shgroup->instance_count, &DST.select_id); } #endif @@ -565,9 +565,9 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at for (int i = 0; i < attr_len; ++i) { if (shgroup->instance_count == shgroup->instance_vbo->vertex_len) { - GWN_vertbuf_data_resize(shgroup->instance_vbo, shgroup->instance_count + 32); + GPU_vertbuf_data_resize(shgroup->instance_vbo, shgroup->instance_count + 32); } - GWN_vertbuf_attr_set(shgroup->instance_vbo, i, shgroup->instance_count, attr[i]); + GPU_vertbuf_attr_set(shgroup->instance_vbo, i, shgroup->instance_count, attr[i]); } shgroup->instance_count += 1; @@ -601,25 +601,25 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader) } else { /* Only here to support builtin shaders. This should not be used by engines. */ - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEW, DST.view_data.matstate.mat[DRW_MAT_VIEW], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEW_INV, DST.view_data.matstate.mat[DRW_MAT_VIEWINV], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEWPROJECTION, DST.view_data.matstate.mat[DRW_MAT_PERS], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_VIEWPROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_PERSINV], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_PROJECTION, DST.view_data.matstate.mat[DRW_MAT_WIN], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_PROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_WININV], 16, 1); - drw_shgroup_builtin_uniform(shgroup, GWN_UNIFORM_CAMERATEXCO, DST.view_data.viewcamtexcofac, 3, 2); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEW, DST.view_data.matstate.mat[DRW_MAT_VIEW], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEW_INV, DST.view_data.matstate.mat[DRW_MAT_VIEWINV], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEWPROJECTION, DST.view_data.matstate.mat[DRW_MAT_PERS], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEWPROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_PERSINV], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION, DST.view_data.matstate.mat[DRW_MAT_WIN], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION_INV, DST.view_data.matstate.mat[DRW_MAT_WININV], 16, 1); + drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_CAMERATEXCO, DST.view_data.viewcamtexcofac, 3, 2); } - shgroup->model = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODEL); - shgroup->modelinverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODEL_INV); - shgroup->modelview = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODELVIEW); - shgroup->modelviewinverse = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MODELVIEW_INV); - shgroup->modelviewprojection = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_MVP); - shgroup->normalview = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_NORMAL); - shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_WORLDNORMAL); - shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_ORCO); - shgroup->eye = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_EYE); - shgroup->callid = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_CALLID); + shgroup->model = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODEL); + shgroup->modelinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODEL_INV); + shgroup->modelview = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW); + shgroup->modelviewinverse = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW_INV); + shgroup->modelviewprojection = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MVP); + shgroup->normalview = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_NORMAL); + shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_WORLDNORMAL); + shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_ORCO); + shgroup->eye = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_EYE); + shgroup->callid = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_CALLID); shgroup->matflag = 0; if (shgroup->modelinverse > -1) @@ -641,7 +641,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader) } static void drw_shgroup_instance_init( - DRWShadingGroup *shgroup, GPUShader *shader, Gwn_Batch *batch, Gwn_VertFormat *format) + DRWShadingGroup *shgroup, GPUShader *shader, GPUBatch *batch, GPUVertFormat *format) { BLI_assert(shgroup->type == DRW_SHG_INSTANCE); BLI_assert(batch != NULL); @@ -661,20 +661,20 @@ static void drw_shgroup_instance_init( if (G.f & G_PICKSEL) { /* Not actually used for rendering but alloced in one chunk. * Plus we don't have to care about ownership. */ - static Gwn_VertFormat inst_select_format = {0}; + static GPUVertFormat inst_select_format = {0}; if (inst_select_format.attr_len == 0) { - GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT); + GPU_vertformat_attr_add(&inst_select_format, "selectId", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_Batch *batch_dummy; /* Not used */ + GPUBatch *batch_dummy; /* Not used */ DRW_batching_buffer_request(DST.idatalist, &inst_select_format, - GWN_PRIM_POINTS, shgroup, + GPU_PRIM_POINTS, shgroup, &batch_dummy, &shgroup->inst_selectid); } #endif } static void drw_shgroup_batching_init( - DRWShadingGroup *shgroup, GPUShader *shader, Gwn_VertFormat *format) + DRWShadingGroup *shgroup, GPUShader *shader, GPUVertFormat *format) { drw_shgroup_init(shgroup, shader); @@ -683,12 +683,12 @@ static void drw_shgroup_batching_init( #endif BLI_assert(format != NULL); - Gwn_PrimType type; + GPUPrimType type; switch (shgroup->type) { - case DRW_SHG_POINT_BATCH: type = GWN_PRIM_POINTS; break; - case DRW_SHG_LINE_BATCH: type = GWN_PRIM_LINES; break; - case DRW_SHG_TRIANGLE_BATCH: type = GWN_PRIM_TRIS; break; - default: type = GWN_PRIM_NONE; BLI_assert(0); break; + case DRW_SHG_POINT_BATCH: type = GPU_PRIM_POINTS; break; + case DRW_SHG_LINE_BATCH: type = GPU_PRIM_LINES; break; + case DRW_SHG_TRIANGLE_BATCH: type = GPU_PRIM_TRIS; break; + default: type = GPU_PRIM_NONE; BLI_assert(0); break; } DRW_batching_buffer_request(DST.idatalist, format, type, shgroup, @@ -697,13 +697,13 @@ static void drw_shgroup_batching_init( #ifdef USE_GPU_SELECT if (G.f & G_PICKSEL) { /* Not actually used for rendering but alloced in one chunk. */ - static Gwn_VertFormat inst_select_format = {0}; + static GPUVertFormat inst_select_format = {0}; if (inst_select_format.attr_len == 0) { - GWN_vertformat_attr_add(&inst_select_format, "selectId", GWN_COMP_I32, 1, GWN_FETCH_INT); + GPU_vertformat_attr_add(&inst_select_format, "selectId", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_Batch *batch; /* Not used */ + GPUBatch *batch; /* Not used */ DRW_batching_buffer_request(DST.idatalist, &inst_select_format, - GWN_PRIM_POINTS, shgroup, + GPU_PRIM_POINTS, shgroup, &batch, &shgroup->inst_selectid); } #endif @@ -807,15 +807,15 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct return grp; } -Gwn_VertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize) +GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize) { - Gwn_VertFormat *format = MEM_callocN(sizeof(Gwn_VertFormat), "Gwn_VertFormat"); + GPUVertFormat *format = MEM_callocN(sizeof(GPUVertFormat), "GPUVertFormat"); for (int i = 0; i < arraysize; ++i) { - GWN_vertformat_attr_add(format, attribs[i].name, - (attribs[i].type == DRW_ATTRIB_INT) ? GWN_COMP_I32 : GWN_COMP_F32, + GPU_vertformat_attr_add(format, attribs[i].name, + (attribs[i].type == DRW_ATTRIB_INT) ? GPU_COMP_I32 : GPU_COMP_F32, attribs[i].components, - (attribs[i].type == DRW_ATTRIB_INT) ? GWN_FETCH_INT : GWN_FETCH_FLOAT); + (attribs[i].type == DRW_ATTRIB_INT) ? GPU_FETCH_INT : GPU_FETCH_FLOAT); } return format; } @@ -835,7 +835,7 @@ DRWShadingGroup *DRW_shgroup_material_create( } DRWShadingGroup *DRW_shgroup_material_instance_create( - struct GPUMaterial *material, DRWPass *pass, Gwn_Batch *geom, Object *ob, Gwn_VertFormat *format) + struct GPUMaterial *material, DRWPass *pass, GPUBatch *geom, Object *ob, GPUVertFormat *format) { GPUPass *gpupass = GPU_material_get_pass(material); DRWShadingGroup *shgroup = drw_shgroup_material_create_ex(gpupass, pass); @@ -861,7 +861,7 @@ DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create( DRWShadingGroup *shgroup = drw_shgroup_material_create_ex(gpupass, pass); if (shgroup) { - /* Calling drw_shgroup_init will cause it to call GWN_draw_primitive(). */ + /* Calling drw_shgroup_init will cause it to call GPU_draw_primitive(). */ drw_shgroup_init(shgroup, GPU_pass_shader_get(gpupass)); shgroup->type = DRW_SHG_TRIANGLE_BATCH; shgroup->instance_count = tri_count * 3; @@ -879,7 +879,7 @@ DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass) } DRWShadingGroup *DRW_shgroup_instance_create( - struct GPUShader *shader, DRWPass *pass, Gwn_Batch *geom, Gwn_VertFormat *format) + struct GPUShader *shader, DRWPass *pass, GPUBatch *geom, GPUVertFormat *format) { DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass); shgroup->type = DRW_SHG_INSTANCE; @@ -903,7 +903,7 @@ DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPas } DRWShadingGroup *DRW_shgroup_line_batch_create_with_format( - struct GPUShader *shader, DRWPass *pass, Gwn_VertFormat *format) + struct GPUShader *shader, DRWPass *pass, GPUVertFormat *format) { DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass); shgroup->type = DRW_SHG_LINE_BATCH; @@ -930,7 +930,7 @@ DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DR #endif DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass); - /* Calling drw_shgroup_init will cause it to call GWN_draw_primitive(). */ + /* Calling drw_shgroup_init will cause it to call GPU_draw_primitive(). */ drw_shgroup_init(shgroup, shader); shgroup->type = DRW_SHG_TRIANGLE_BATCH; @@ -939,7 +939,7 @@ DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DR return shgroup; } -DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, Gwn_VertBuf *tf_target) +DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, GPUVertBuf *tf_target) { BLI_assert(tf_target != NULL); DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass); @@ -953,7 +953,7 @@ DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader, } /* Specify an external batch instead of adding each attrib one by one. */ -void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batch) +void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch) { BLI_assert(shgroup->type == DRW_SHG_INSTANCE); BLI_assert(shgroup->instance_count == 0); @@ -966,7 +966,7 @@ void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *batc /* Note: This WILL break if batch->verts[0] is destroyed and reallocated * at the same adress. Bindings/VAOs would remain obsolete. */ //if (shgroup->instancing_geom->inst != batch->verts[0]) - GWN_batch_instbuf_set(shgroup->instance_geom, batch->verts[0], false); + GPU_batch_instbuf_set(shgroup->instance_geom, batch->verts[0], false); #ifdef USE_GPU_SELECT shgroup->override_selectid = DST.select_id; diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 5957643d090..1134f421c16 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -827,29 +827,29 @@ static void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWCallState *state) } static void draw_geometry_execute_ex( - DRWShadingGroup *shgroup, Gwn_Batch *geom, uint start, uint count, bool draw_instance) + DRWShadingGroup *shgroup, GPUBatch *geom, uint start, uint count, bool draw_instance) { /* Special case: empty drawcall, placement is done via shader, don't bind anything. */ /* TODO use DRW_CALL_PROCEDURAL instead */ if (geom == NULL) { BLI_assert(shgroup->type == DRW_SHG_TRIANGLE_BATCH); /* Add other type if needed. */ /* Shader is already bound. */ - GWN_draw_primitive(GWN_PRIM_TRIS, count); + GPU_draw_primitive(GPU_PRIM_TRIS, count); return; } /* step 2 : bind vertex array & draw */ - GWN_batch_program_set_no_use( + GPU_batch_program_set_no_use( geom, GPU_shader_get_program(shgroup->shader), GPU_shader_get_interface(shgroup->shader)); /* XXX hacking gawain. we don't want to call glUseProgram! (huge performance loss) */ geom->program_in_use = true; - GWN_batch_draw_range_ex(geom, start, count, draw_instance); + GPU_batch_draw_range_ex(geom, start, count, draw_instance); geom->program_in_use = false; /* XXX hacking gawain */ } -static void draw_geometry_execute(DRWShadingGroup *shgroup, Gwn_Batch *geom) +static void draw_geometry_execute(DRWShadingGroup *shgroup, GPUBatch *geom) { draw_geometry_execute_ex(shgroup, geom, 0, 0, false); } @@ -1055,9 +1055,9 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) if (G.f & G_PICKSEL) { \ if (_shgroup->override_selectid == -1) { \ /* Hack : get vbo data without actually drawing. */ \ - Gwn_VertBufRaw raw; \ - GWN_vertbuf_attr_get_raw_data(_shgroup->inst_selectid, 0, &raw); \ - select_id = GWN_vertbuf_raw_step(&raw); \ + GPUVertBufRaw raw; \ + GPU_vertbuf_attr_get_raw_data(_shgroup->inst_selectid, 0, &raw); \ + select_id = GPU_vertbuf_raw_step(&raw); \ switch (_shgroup->type) { \ case DRW_SHG_TRIANGLE_BATCH: _count = 3; break; \ case DRW_SHG_LINE_BATCH: _count = 2; break; \ @@ -1168,7 +1168,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) call->generate.geometry_fn(shgroup, draw_geometry_execute, call->generate.user_data); break; case DRW_CALL_PROCEDURAL: - GWN_draw_primitive(call->procedural.prim_type, call->procedural.vert_count); + GPU_draw_primitive(call->procedural.prim_type, call->procedural.vert_count); break; default: BLI_assert(0); diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c index e4c0877b907..edeb6c07733 100644 --- a/source/blender/draw/intern/draw_manager_profiling.c +++ b/source/blender/draw/intern/draw_manager_profiling.c @@ -305,7 +305,7 @@ void DRW_stats_draw(rcti *rect) /* Memory Stats */ uint tex_mem = GPU_texture_memory_usage_get(); - uint vbo_mem = GWN_vertbuf_get_memory_usage(); + uint vbo_mem = GPU_vertbuf_get_memory_usage(); sprintf(stat_string, "GPU Memory"); draw_stat(rect, 0, v, stat_string, sizeof(stat_string)); diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 688712a97b6..05aecea1d7a 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -214,9 +214,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** glDepthMask(GL_FALSE); /* disable write in zbuffer */ #endif - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); @@ -253,7 +253,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** if (gridline_len == 0) goto drawgrid_cleanup; /* nothing to draw */ - immBegin(GWN_PRIM_LINES, gridline_len * 2); + immBegin(GPU_PRIM_LINES, gridline_len * 2); } float blend_fac = 1.0f - ((GRID_MIN_PX_F * 2.0f) / (float)dx_scalar); @@ -306,7 +306,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** if (gridline_len == 0) goto drawgrid_cleanup; /* nothing to draw */ - immBegin(GWN_PRIM_LINES, gridline_len * 2); + immBegin(GPU_PRIM_LINES, gridline_len * 2); if (grids_to_draw == 2) { UI_GetThemeColorBlend3ubv(TH_HIGH_GRAD, TH_GRID, dx / (GRID_MIN_PX_D * 6.0), col2); @@ -381,13 +381,13 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) uchar col_bg[3], col_grid_emphasise[3], col_grid_light[3]; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_len); + immBegin(GPU_PRIM_LINES, vertex_len); /* draw normal grid lines */ UI_GetColorPtrShade3ubv(col_grid, col_grid_light, 10); @@ -469,12 +469,12 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) if (show_axis_x || show_axis_y || show_axis_z) { /* draw axis lines -- sometimes grid floor is off, other times we still need to draw the Z axis */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2); + immBegin(GPU_PRIM_LINES, (show_axis_x + show_axis_y + show_axis_z) * 2); if (show_axis_x) { UI_make_axis_color(col_grid, col_axis, 'X'); @@ -582,9 +582,9 @@ void DRW_draw_background(void) /* Gradient background Color */ glDisable(GL_DEPTH_TEST); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); uchar col_hi[3], col_lo[3]; GPU_matrix_push(); @@ -596,7 +596,7 @@ void DRW_draw_background(void) UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo); UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib3ubv(color, col_lo); immVertex2f(pos, -1.0f, -1.0f); immVertex2f(pos, 1.0f, -1.0f); @@ -689,10 +689,10 @@ void DRW_draw_cursor(void) /* Draw lines */ if (is_aligned == false) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor3(TH_VIEW_OVERLAY); - immBegin(GWN_PRIM_LINES, 12); + immBegin(GPU_PRIM_LINES, 12); const float scale = ED_view3d_pixel_size_no_ui_scale(rv3d, cursor->location) * U.widget_unit; @@ -727,11 +727,11 @@ void DRW_draw_cursor(void) GPU_matrix_translate_2f(co[0] + 0.5f, co[1] + 0.5f); GPU_matrix_scale_2f(U.widget_unit, U.widget_unit); - Gwn_Batch *cursor_batch = DRW_cache_cursor_get(is_aligned); + GPUBatch *cursor_batch = DRW_cache_cursor_get(is_aligned); GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR); - GWN_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader)); + GPU_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader)); - GWN_batch_draw(cursor_batch); + GPU_batch_draw(cursor_batch); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c index 50ce29b7b1a..c8b8f678ca6 100644 --- a/source/blender/draw/modes/edit_curve_mode.c +++ b/source/blender/draw/modes/edit_curve_mode.c @@ -244,7 +244,7 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob) { Curve *cu = ob->data; /* Get geometry cache */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; geom = DRW_cache_curve_edge_wire_get(ob); DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat); diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c index 870dd14d677..ca7903c555b 100644 --- a/source/blender/draw/modes/edit_lattice_mode.c +++ b/source/blender/draw/modes/edit_lattice_mode.c @@ -196,7 +196,7 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob) if (ob->type == OB_LATTICE) { if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) { /* Get geometry cache */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; geom = DRW_cache_lattice_wire_get(ob, true); DRW_shgroup_call_add(stl->g_data->wire_shgrp, geom, ob->obmat); diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index b402494dfb5..67a424b8081 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -432,7 +432,7 @@ static void EDIT_MESH_cache_init(void *vedata) DRW_shgroup_uniform_block(stl->g_data->facefill_occluded_shgrp, "globalsBlock", globals_ubo); /* we need a full screen pass to combine the result */ - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); psl->mix_occlude = DRW_pass_create( "Mix Occluded Wires", @@ -450,7 +450,7 @@ static void edit_mesh_add_ob_to_pass( Scene *scene, Object *ob, DRWShadingGroup *face_shgrp, DRWShadingGroup *ledges_shgrp, DRWShadingGroup *lverts_shgrp, DRWShadingGroup *facedot_shgrp, DRWShadingGroup *facefill_shgrp) { - struct Gwn_Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter; + struct GPUBatch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter; ToolSettings *tsettings = scene->toolsettings; DRW_cache_mesh_wire_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts); @@ -477,7 +477,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob) const DRWContextState *draw_ctx = DRW_context_state_get(); View3D *v3d = draw_ctx->v3d; Scene *scene = draw_ctx->scene; - struct Gwn_Batch *geom; + struct GPUBatch *geom; if (ob->type == OB_MESH) { if ((ob == draw_ctx->object_edit) || BKE_object_is_in_editmode(ob)) { @@ -512,7 +512,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob) } if (vnormals_do || lnormals_do) { - struct Gwn_Batch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts; + struct GPUBatch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts; DRW_cache_mesh_normals_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts); if (vnormals_do) { diff --git a/source/blender/draw/modes/edit_surface_mode.c b/source/blender/draw/modes/edit_surface_mode.c index 7074ba3d024..3c5d0dbf5a1 100644 --- a/source/blender/draw/modes/edit_surface_mode.c +++ b/source/blender/draw/modes/edit_surface_mode.c @@ -180,7 +180,7 @@ static void EDIT_SURFACE_cache_populate(void *vedata, Object *ob) if (ob->type == OB_MESH) { /* Get geometry cache */ - struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob); /* Add geom to a shading group */ DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat); diff --git a/source/blender/draw/modes/edit_text_mode.c b/source/blender/draw/modes/edit_text_mode.c index 5750dc8a0b9..f21715ef399 100644 --- a/source/blender/draw/modes/edit_text_mode.c +++ b/source/blender/draw/modes/edit_text_mode.c @@ -197,7 +197,7 @@ static void EDIT_TEXT_cache_populate(void *vedata, Object *ob) if (ob == draw_ctx->object_edit) { const Curve *cu = ob->data; /* Get geometry cache */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; if (cu->flag & CU_FAST) { geom = DRW_cache_text_edge_wire_get(ob); diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 386261b64d7..dc499987c8a 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -255,9 +255,9 @@ typedef struct OBJECT_PrivateData { static struct { /* Instance Data format */ - struct Gwn_VertFormat *particle_format; - struct Gwn_VertFormat *empty_image_format; - struct Gwn_VertFormat *empty_image_wire_format; + struct GPUVertFormat *particle_format; + struct GPUVertFormat *empty_image_format; + struct GPUVertFormat *empty_image_wire_format; /* fullscreen shaders */ GPUShader *outline_prepass_sh; @@ -851,7 +851,7 @@ static void DRW_shgroup_empty_image( {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}, }); - struct Gwn_Batch *geom = DRW_cache_image_plane_get(); + struct GPUBatch *geom = DRW_cache_image_plane_get(); DRWShadingGroup *grp = DRW_shgroup_instance_create( e_data.object_empty_image_sh, psl->non_meshes, geom, e_data.empty_image_format); DRW_shgroup_uniform_texture(grp, "image", tex); @@ -871,7 +871,7 @@ static void DRW_shgroup_empty_image( {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16} }); - struct Gwn_Batch *geom = DRW_cache_image_plane_wire_get(); + struct GPUBatch *geom = DRW_cache_image_plane_wire_get(); DRWShadingGroup *grp = DRW_shgroup_instance_create( e_data.object_empty_image_wire_sh, psl->non_meshes, geom, e_data.empty_image_wire_format); DRW_shgroup_uniform_vec2(grp, "aspect", empty_image_data->image_aspect, 1); @@ -940,8 +940,8 @@ static void OBJECT_cache_init(void *vedata) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_POINT; DRWPass *pass = psl->lightprobes = DRW_pass_create("Object Probe Pass", state); - struct Gwn_Batch *sphere = DRW_cache_sphere_get(); - struct Gwn_Batch *quad = DRW_cache_quad_get(); + struct GPUBatch *sphere = DRW_cache_sphere_get(); + struct GPUBatch *quad = DRW_cache_quad_get(); /* Cubemap */ g_data->lightprobes_cube_select = shgroup_instance_outline(pass, sphere, &g_data->id_ofs_prb_select); @@ -960,7 +960,7 @@ static void OBJECT_cache_init(void *vedata) { DRWState state = DRW_STATE_WRITE_COLOR; - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); /* Don't occlude the "outline" detection pass if in xray mode (too much flickering). */ float alphaOcclu = (xray_enabled) ? 1.0f : 0.35f; /* Reminder : bool uniforms need to be 4 bytes. */ @@ -1000,7 +1000,7 @@ static void OBJECT_cache_init(void *vedata) DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND; psl->outlines_resolve = DRW_pass_create("Outlines Resolve Pass", state); - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); GPUTexture **outline_tx = (do_outline_expand) ? &e_data.outlines_blur_tx : &e_data.outlines_color_tx; DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_aa_sh, psl->outlines_resolve); @@ -1014,7 +1014,7 @@ static void OBJECT_cache_init(void *vedata) DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND; psl->grid = DRW_pass_create("Infinite Grid Pass", state); - struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get(); + struct GPUBatch *quad = DRW_cache_fullscreen_quad_get(); static float mat[4][4]; unit_m4(mat); @@ -1075,7 +1075,7 @@ static void OBJECT_cache_init(void *vedata) { /* Non Meshes Pass (Camera, empties, lamps ...) */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | @@ -1221,7 +1221,7 @@ static void OBJECT_cache_init(void *vedata) /* TODO * for now we create multiple times the same VBO with only lamp center coordinates * but ideally we would only create it once */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; /* start with buflimit because we don't want stipples */ geom = DRW_cache_single_line_get(); @@ -1273,7 +1273,7 @@ static void OBJECT_cache_init(void *vedata) { /* -------- STIPPLES ------- */ - struct Gwn_Batch *geom; + struct GPUBatch *geom; /* Relationship Lines */ stl->g_data->relationship_lines = shgroup_dynlines_dashed_uniform_color(psl->non_meshes, ts.colorWire); @@ -2252,7 +2252,7 @@ static void OBJECT_cache_populate_particles(Object *ob, unit_m4(mat); if (draw_as != PART_DRAW_PATH) { - struct Gwn_Batch *geom = DRW_cache_particles_get_dots(ob, psys); + struct GPUBatch *geom = DRW_cache_particles_get_dots(ob, psys); DRWShadingGroup *shgrp = NULL; static int screen_space[2] = {0, 1}; static float def_prim_col[3] = {0.5f, 0.5f, 0.5f}; @@ -2335,7 +2335,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (do_outlines) { if ((ob != draw_ctx->object_edit) && !((ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_ALL_PAINT))) { - struct Gwn_Batch *geom; + struct GPUBatch *geom; const bool xray_enabled = ((v3d->shading.flag & V3D_SHADING_XRAY) != 0) && (v3d->shading.type < OB_MATERIAL); if (xray_enabled) { @@ -2363,7 +2363,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (ob != draw_ctx->object_edit) { Mesh *me = ob->data; if (me->totedge == 0) { - struct Gwn_Batch *geom = DRW_cache_mesh_verts_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_verts_get(ob); if (geom) { if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); @@ -2374,7 +2374,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) } } else { - struct Gwn_Batch *geom = DRW_cache_mesh_loose_edges_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_loose_edges_get(ob); if (geom) { if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); @@ -2395,7 +2395,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (hide_object_extra) { break; } - struct Gwn_Batch *geom = DRW_cache_lattice_wire_get(ob, false); + struct GPUBatch *geom = DRW_cache_lattice_wire_get(ob, false); if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } @@ -2411,7 +2411,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (hide_object_extra) { break; } - struct Gwn_Batch *geom = DRW_cache_curve_edge_wire_get(ob); + struct GPUBatch *geom = DRW_cache_curve_edge_wire_get(ob); if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c index a67c7ffb131..e3c986bde5a 100644 --- a/source/blender/draw/modes/overlay_mode.c +++ b/source/blender/draw/modes/overlay_mode.c @@ -175,7 +175,7 @@ static void overlay_cache_populate(void *vedata, Object *ob) return; if (stl->g_data->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) { - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { DRW_shgroup_call_add(pd->face_orientation_shgrp, geom, ob->obmat); } diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c index 85cff28b313..8256bb4d0d7 100644 --- a/source/blender/draw/modes/paint_texture_mode.c +++ b/source/blender/draw/modes/paint_texture_mode.c @@ -293,9 +293,9 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) if (use_surface) { if (me->mloopuv != NULL) { if (use_material_slots) { - struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; + struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL; if ((me->totcol == 0) || (geom_array == NULL)) { - struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob); DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat); ok = true; } @@ -312,7 +312,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) } } else { - struct Gwn_Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob); if (geom && stl->g_data->shgroup_image_array[0]) { DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat); ok = true; @@ -321,7 +321,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) } if (!ok) { - struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob); + struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob); DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat); } } @@ -329,7 +329,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob) /* Face Mask */ const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; if (use_face_sel) { - struct Gwn_Batch *geom; + struct GPUBatch *geom; /* Note: ideally selected faces wouldn't show interior wire. */ const bool use_wire = true; geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, use_face_sel); diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c index 9cf6ea52d33..33af72e8616 100644 --- a/source/blender/draw/modes/paint_vertex_mode.c +++ b/source/blender/draw/modes/paint_vertex_mode.c @@ -150,7 +150,7 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob) const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; const bool use_surface = v3d->overlay.vertex_paint_mode_opacity != 0.0f; const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; - struct Gwn_Batch *geom; + struct GPUBatch *geom; if (use_surface) { geom = DRW_cache_mesh_surface_vert_colors_get(ob); diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c index 14fae743d8c..d4fc73e7f88 100644 --- a/source/blender/draw/modes/paint_weight_mode.c +++ b/source/blender/draw/modes/paint_weight_mode.c @@ -190,7 +190,7 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob) const bool use_surface = v3d->overlay.weight_paint_mode_opacity != 0.0f; const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; - struct Gwn_Batch *geom; + struct GPUBatch *geom; if (use_surface) { geom = DRW_cache_mesh_surface_weights_get(ob); diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c index 19c3ddd4b50..f4879483540 100644 --- a/source/blender/draw/modes/particle_mode.c +++ b/source/blender/draw/modes/particle_mode.c @@ -148,17 +148,17 @@ static void particle_edit_cache_populate(void *vedata, const DRWContextState *draw_ctx = DRW_context_state_get(); ParticleEditSettings *pset = PE_settings(draw_ctx->scene); { - struct Gwn_Batch *strands = + struct GPUBatch *strands = DRW_cache_particles_get_edit_strands(object, psys, edit); DRW_shgroup_call_add(stl->g_data->strands_group, strands, NULL); } if (pset->selectmode == SCE_SELECT_POINT) { - struct Gwn_Batch *points = + struct GPUBatch *points = DRW_cache_particles_get_edit_inner_points(object, psys, edit); DRW_shgroup_call_add(stl->g_data->inner_points_group, points, NULL); } if (ELEM(pset->selectmode, SCE_SELECT_POINT, SCE_SELECT_END)) { - struct Gwn_Batch *points = + struct GPUBatch *points = DRW_cache_particles_get_edit_tip_points(object, psys, edit); DRW_shgroup_call_add(stl->g_data->tip_points_group, points, NULL); } diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index 57efc65542c..040195b889b 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -221,7 +221,7 @@ static void POSE_cache_populate(void *vedata, Object *ob) !DRW_state_is_select() && POSE_is_bone_selection_overlay_active()) { - struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob); + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { if (POSE_is_driven_by_active_armature(ob)) { DRW_shgroup_call_object_add(stl->g_data->bone_selection_shgrp, geom, ob); diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index c70790e0550..3c10cda6456 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -146,7 +146,7 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); @@ -235,7 +235,7 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); @@ -3868,7 +3868,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* for F-Curves, draw color-preview of curve behind checkbox */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { FCurve *fcu = (FCurve *)ale->data; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -3924,7 +3924,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* draw red underline if channel is disabled */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -3933,7 +3933,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float GPU_line_width(2.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, (float)offset, yminc); immVertex2f(pos, (float)v2d->cur.xmax, yminc); immEnd(); @@ -3952,7 +3952,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float short draw_sliders = 0; float ymin_ofs = 0.0f; float color[3]; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 129cf07b7c4..780e984f870 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -141,15 +141,15 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) GPU_line_width((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* Draw a light green line to indicate current frame */ immUniformThemeColor(TH_CFRAME); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */ immVertex2f(pos, x, v2d->cur.ymax); immEnd(); @@ -170,8 +170,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_ANIM_ACTIVE, -25, -30); @@ -203,8 +203,8 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -25, -100); @@ -222,7 +222,7 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d) /* thin lines where the actual frames are */ immUniformThemeColorShade(TH_BACK, -60); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, (float)SFRA, v2d->cur.ymin); immVertex2f(pos, (float)SFRA, v2d->cur.ymax); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index f809bff536f..e1f4092c494 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -400,8 +400,8 @@ static void draw_marker( if (flag & DRAW_MARKERS_LINES) #endif { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -418,7 +418,7 @@ static void draw_marker( immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, xpos + 0.5f, 12.0f); immVertex2f(pos, xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale); immEnd(); @@ -486,7 +486,7 @@ void ED_markers_draw(const bContext *C, int flag) v2d = UI_view2d_fromcontext(C); if (flag & DRAW_MARKERS_MARGIN) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); const unsigned char shade[4] = {0, 0, 0, 16}; diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 78ce24db503..30130ce4dac 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -593,12 +593,12 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa } if (block_len > 0) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_TRIS, 6 * block_len); + immBegin(GPU_PRIM_TRIS, 6 * block_len); for (ActKeyBlock *ab = blocks->first; ab; ab = ab->next) { if (actkeyblock_is_valid(ab, keys)) { if (ab->flag & ACTKEYBLOCK_FLAG_MOVING_HOLD) { @@ -633,14 +633,14 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa if (key_len > 0) { /* draw keys */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, key_len); + immBegin(GPU_PRIM_POINTS, key_len); for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) { if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) { diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 927b8b8514d..dd0430f4f65 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -387,9 +387,9 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS float color[3]; UI_GetThemeColor3fv(TH_WIRE, color); - Gwn_Batch *sphere = GPU_batch_preset_sphere(0); - GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); - GWN_batch_uniform_3fv(sphere, "color", color); + GPUBatch *sphere = GPU_batch_preset_sphere(0); + GPU_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); + GPU_batch_uniform_3fv(sphere, "color", color); /* scale to edit-mode space */ GPU_matrix_push(); @@ -407,7 +407,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS GPU_matrix_push(); GPU_matrix_scale_1f(radius); - GWN_batch_draw(sphere); + GPU_batch_draw(sphere); GPU_matrix_pop(); location_prev = selem->location_local; @@ -430,8 +430,8 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS } { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); GPU_depth_test(false); @@ -440,7 +440,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS GPU_line_width(3.0f); imm_cpack(0x0); - immBegin(GWN_PRIM_LINE_STRIP, stroke_len); + immBegin(GPU_PRIM_LINE_STRIP, stroke_len); for (int i = 0; i < stroke_len; i++) { immVertex3fv(pos, coord_array[i]); } @@ -449,7 +449,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS GPU_line_width(1.0f); imm_cpack(0xffffffff); - immBegin(GWN_PRIM_LINE_STRIP, stroke_len); + immBegin(GPU_PRIM_LINE_STRIP, stroke_len); for (int i = 0; i < stroke_len; i++) { immVertex3fv(pos, coord_array[i]); } diff --git a/source/blender/editors/gizmo_library/gizmo_draw_utils.c b/source/blender/editors/gizmo_library/gizmo_draw_utils.c index aaaee182c71..5ccb1fa1f6d 100644 --- a/source/blender/editors/gizmo_library/gizmo_draw_utils.c +++ b/source/blender/editors/gizmo_library/gizmo_draw_utils.c @@ -64,31 +64,31 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(sel /* TODO store the Batches inside the GizmoGeomInfo and updated it when geom changes * So we don't need to re-created and discard it every time */ - Gwn_VertBuf *vbo; - Gwn_IndexBuf *el; - Gwn_Batch *batch; - Gwn_IndexBufBuilder elb = {0}; + GPUVertBuf *vbo; + GPUIndexBuf *el; + GPUBatch *batch; + GPUIndexBufBuilder elb = {0}; - Gwn_VertFormat format = {0}; - uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat format = {0}; + uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); /* Elements */ - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, info->ntris, info->nverts); + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, info->ntris, info->nverts); for (int i = 0; i < info->ntris; ++i) { const unsigned short *idx = &info->indices[i * 3]; - GWN_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]); + GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]); } - el = GWN_indexbuf_build(&elb); + el = GPU_indexbuf_build(&elb); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, info->nverts); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, info->nverts); - GWN_vertbuf_attr_fill(vbo, pos_id, info->verts); + GPU_vertbuf_attr_fill(vbo, pos_id, info->verts); - batch = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, el, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); + batch = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, el, GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); - GWN_batch_uniform_4fv(batch, "color", color); + GPU_batch_uniform_4fv(batch, "color", color); /* We may want to re-visit this, for now disable * since it causes issues leaving the GL state modified. */ @@ -97,7 +97,7 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(sel GPU_depth_test(true); #endif - GWN_batch_draw(batch); + GPU_batch_draw(batch); #if 0 GPU_depth_test(false); @@ -105,7 +105,7 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(sel #endif - GWN_batch_discard(batch); + GPU_batch_discard(batch); } void wm_gizmo_vec_draw( diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c index 673e38e4a1a..cb8e2a90b07 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c @@ -70,7 +70,7 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float const float arrow_length = RNA_float_get(gz->ptr, "length") - size_length; const float arrow_angle = RNA_float_get(gz->ptr, "angle"); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_matrix_push(); GPU_matrix_mul(matrix); @@ -80,12 +80,12 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float immUniformColor4fv(color); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, 0.0f, 0.0f); immVertex2f(pos, 0.0f, arrow_length); immEnd(); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2f(pos, size_breadth, arrow_length); immVertex2f(pos, -size_breadth, arrow_length); immVertex2f(pos, 0.0f, arrow_length + size_length); diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c index da4bce680b8..0f8389af17d 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -90,7 +90,7 @@ static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4] static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const float color[4]) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); bool unbind_shader = true; const int draw_style = RNA_enum_get(arrow->gizmo.ptr, "draw_style"); const int draw_options = RNA_enum_get(arrow->gizmo.ptr, "draw_options"); @@ -100,7 +100,7 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) { immUniformColor4fv(color); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex3f(pos, -1.0f, 0.0f, 0.0f); immVertex3f(pos, 1.0f, 0.0f, 0.0f); immVertex3f(pos, 0.0f, -1.0f, 0.0f); @@ -120,7 +120,7 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const }; GPU_line_width(arrow->gizmo.line_width); - wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP); + wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GPU_PRIM_LINE_LOOP); } else { #ifdef USE_GIZMO_CUSTOM_ARROWS @@ -135,7 +135,7 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) { GPU_line_width(arrow->gizmo.line_width); - wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP); + wm_gizmo_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GPU_PRIM_LINE_STRIP); } else { immUniformColor4fv(color); diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index 13711325038..d976adc06bf 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -72,7 +72,7 @@ typedef struct ButtonGizmo2D { bool is_init; /* Use an icon or shape */ int icon; - Gwn_Batch *shape_batch[2]; + GPUBatch *shape_batch[2]; } ButtonGizmo2D; #define CIRCLE_RESOLUTION 32 @@ -84,8 +84,8 @@ static void button2d_geom_draw_backdrop( { GPU_line_width(gz->line_width); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -137,12 +137,12 @@ static void button2d_draw_intern( if (draw_options & ED_GIZMO_BUTTON_SHOW_HELPLINE) { float matrix_final_no_offset[4][4]; WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); GPU_line_width(gz->line_width); immUniformColor4fv(color); - immBegin(GWN_PRIM_LINE_STRIP, 2); + immBegin(GPU_PRIM_LINE_STRIP, 2); immVertex3fv(pos, matrix_final[3]); immVertex3fv(pos, matrix_final_no_offset[3]); immEnd(); @@ -177,9 +177,9 @@ static void button2d_draw_intern( GPU_line_width(1.0f); for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) { /* Invert line color for wire. */ - GWN_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR); - GWN_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color)); - GWN_batch_draw(button->shape_batch[i]); + GPU_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR); + GPU_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color)); + GPU_batch_draw(button->shape_batch[i]); if (draw_options & ED_GIZMO_BUTTON_SHOW_OUTLINE) { color[0] = 1.0f - color[0]; @@ -270,7 +270,7 @@ static void gizmo_button2d_free(wmGizmo *gz) ButtonGizmo2D *shape = (ButtonGizmo2D *)gz; for (uint i = 0; i < ARRAY_SIZE(shape->shape_batch); i++) { - GWN_BATCH_DISCARD_SAFE(shape->shape_batch[i]); + GPU_BATCH_DISCARD_SAFE(shape->shape_batch[i]); } } diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index 5e3b7bb21c6..2869b93a790 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -136,12 +136,12 @@ static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_con static void cage2d_draw_box_corners( const rctf *r, const float margin[2], const float color[3]) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fv(color); - immBegin(GWN_PRIM_LINES, 16); + immBegin(GPU_PRIM_LINES, 16); immVertex2f(pos, r->xmin, r->ymin + margin[1]); immVertex2f(pos, r->xmin, r->ymin); @@ -176,7 +176,7 @@ static void cage2d_draw_box_interaction( /* 4 verts for translate, otherwise only 3 are used. */ float verts[4][2]; uint verts_len = 0; - Gwn_PrimType prim_type = GWN_PRIM_NONE; + GPUPrimType prim_type = GPU_PRIM_NONE; switch (highlighted) { case ED_GIZMO_CAGE2D_PART_SCALE_MIN_X: @@ -192,10 +192,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin); verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -212,10 +212,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[2], r.xmin, r.ymax); ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -232,10 +232,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymax); ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax); verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -252,10 +252,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[2], r.xmax, r.ymin); ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); verts_len += 2; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -272,10 +272,10 @@ static void cage2d_draw_box_interaction( if (is_solid) { ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymin); verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -292,10 +292,10 @@ static void cage2d_draw_box_interaction( if (is_solid) { ARRAY_SET_ITEMS(verts[3], r.xmin, r.ymax); verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -312,10 +312,10 @@ static void cage2d_draw_box_interaction( if (is_solid) { ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymin); verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -332,10 +332,10 @@ static void cage2d_draw_box_interaction( if (is_solid) { ARRAY_SET_ITEMS(verts[3], r.xmax, r.ymax); verts_len += 1; - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -355,10 +355,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[3], r_rotate.xmax, r_rotate.ymin); verts_len = 4; if (is_solid) { - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } break; } @@ -371,10 +371,10 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[3], margin[0] / 2, -margin[1] / 2); verts_len = 4; if (is_solid) { - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { - prim_type = GWN_PRIM_LINES; + prim_type = GPU_PRIM_LINES; } } else { @@ -385,12 +385,12 @@ static void cage2d_draw_box_interaction( ARRAY_SET_ITEMS(verts[3], size[0], -size[1]); verts_len = 4; if (is_solid) { - prim_type = GWN_PRIM_TRI_FAN; + prim_type = GPU_PRIM_TRI_FAN; } else { /* unreachable */ BLI_assert(0); - prim_type = GWN_PRIM_LINE_STRIP; + prim_type = GPU_PRIM_LINE_STRIP; } } break; @@ -398,20 +398,20 @@ static void cage2d_draw_box_interaction( return; } - BLI_assert(prim_type != GWN_PRIM_NONE); + BLI_assert(prim_type != GPU_PRIM_NONE); - Gwn_VertFormat *format = immVertexFormat(); + GPUVertFormat *format = immVertexFormat(); struct { uint pos, col; } attr_id = { - .pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT), - .col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT), + .pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT), + .col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT), }; immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); { if (is_solid) { - BLI_assert(ELEM(prim_type, GWN_PRIM_TRI_FAN)); + BLI_assert(ELEM(prim_type, GPU_PRIM_TRI_FAN)); immBegin(prim_type, verts_len); immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f); for (uint i = 0; i < verts_len; i++) { @@ -420,7 +420,7 @@ static void cage2d_draw_box_interaction( immEnd(); } else { - BLI_assert(ELEM(prim_type, GWN_PRIM_LINE_STRIP, GWN_PRIM_LINES)); + BLI_assert(ELEM(prim_type, GPU_PRIM_LINE_STRIP, GPU_PRIM_LINES)); GPU_line_width(line_width + 3.0f); immBegin(prim_type, verts_len); @@ -455,7 +455,7 @@ static void cage2d_draw_box_interaction( static void imm_draw_point_aspect_2d( uint pos, float x, float y, float rad_x, float rad_y, bool solid) { - immBegin(solid ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4); + immBegin(solid ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x - rad_x, y - rad_y); immVertex2f(pos, x - rad_x, y + rad_y); immVertex2f(pos, x + rad_x, y + rad_y); @@ -467,12 +467,12 @@ static void cage2d_draw_circle_wire( const rctf *r, const float margin[2], const float color[3], const int transform_flag, const int draw_options) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fv(color); - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, r->xmin, r->ymin); immVertex2f(pos, r->xmax, r->ymin); immVertex2f(pos, r->xmax, r->ymax); @@ -480,7 +480,7 @@ static void cage2d_draw_circle_wire( immEnd(); if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { - immBegin(GWN_PRIM_LINE_LOOP, 2); + immBegin(GPU_PRIM_LINE_LOOP, 2); immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax); immVertex2f(pos, BLI_rctf_cent_x(r), r->ymax + margin[1]); immEnd(); @@ -491,7 +491,7 @@ static void cage2d_draw_circle_wire( const float rad[2] = {margin[0] / 2, margin[1] / 2}; const float center[2] = {BLI_rctf_cent_x(r), BLI_rctf_cent_y(r)}; - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]); immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]); immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]); @@ -508,7 +508,7 @@ static void cage2d_draw_circle_handles( const int transform_flag, bool solid) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); void (*circle_fn)(uint, float, float, float, float, int) = (solid) ? imm_draw_circle_fill_aspect_2d : imm_draw_circle_wire_aspect_2d; const int resolu = 12; @@ -560,7 +560,7 @@ static void gizmo_cage2d_draw_intern( /* Handy for quick testing draw (if it's outside bounds). */ if (false) { GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); float s = 0.5f; diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index 9cad82619ba..0f1d309c927 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -150,7 +150,7 @@ static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_con static void cage3d_draw_box_corners( const float r[3], const float margin[3], const float color[3]) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); UNUSED_VARS(margin); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -185,7 +185,7 @@ static void cage3d_draw_box_interaction( const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3}; { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3fv(color); imm_draw_cube_fill_3d(pos, co, rad); @@ -217,7 +217,7 @@ static void cage3d_draw_circle_wire( const float r[3], const float margin[3], const float color[3], const int transform_flag, const int draw_options) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3fv(color); @@ -230,7 +230,7 @@ static void cage3d_draw_circle_wire( const float rad[2] = {margin[0] / 2, margin[1] / 2}; const float center[2] = {0.0f, 0.0f}; - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]); immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]); immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]); @@ -251,7 +251,7 @@ static void cage3d_draw_circle_handles( const float r[3], const float margin[3], const float color[3], bool solid, float scale) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3}; immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -305,7 +305,7 @@ static void gizmo_cage3d_draw_intern( /* Handy for quick testing draw (if it's outside bounds). */ if (false) { GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); float s = 0.5f; diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c index 300ae222189..8e04703c14e 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -126,8 +126,8 @@ static void dial_geom_draw( GPU_line_width(gz->line_width); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (clip_plane) { immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR); @@ -164,13 +164,13 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[ GPU_matrix_push(); GPU_matrix_rotate_3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); - immBegin(GWN_PRIM_LINE_STRIP, 2); + immBegin(GPU_PRIM_LINE_STRIP, 2); immVertex3f(pos, 0.0f, 0.0f, 0.0f); immVertex3fv(pos, co_outer); immEnd(); @@ -185,8 +185,8 @@ static void dial_ghostarc_draw( { const float width_inner = DIAL_WIDTH - gz->line_width * 0.5f / U.gizmo_size; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); imm_draw_disk_partial_fill_2d( diff --git a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c index 840ea793b89..8d4db81c11f 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c @@ -105,8 +105,8 @@ static void grab_geom_draw( GPU_line_width(gz->line_width); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -121,7 +121,7 @@ static void grab_geom_draw( } } else if (draw_style == ED_GIZMO_GRAB_STYLE_CROSS_2D) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, 1.0f, 1.0f); immVertex2f(pos, -1.0f, -1.0f); diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c index b61c16b8d65..6443a6bf038 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c @@ -77,10 +77,10 @@ static void gizmo_primitive_draw_geom( } if (vert_count > 0) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - wm_gizmo_vec_draw(col_inner, verts, vert_count, pos, GWN_PRIM_TRI_FAN); - wm_gizmo_vec_draw(col_outer, verts, vert_count, pos, GWN_PRIM_LINE_LOOP); + wm_gizmo_vec_draw(col_inner, verts, vert_count, pos, GPU_PRIM_TRI_FAN); + wm_gizmo_vec_draw(col_outer, verts, vert_count, pos, GPU_PRIM_LINE_LOOP); immUnbindProgram(); } } diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index ec4310213ef..29b24886017 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -150,14 +150,14 @@ static void gp_draw_stroke_buffer_fill(const tGPspoint *points, int totpoints, f /* draw triangulation data */ if (tot_triangles > 0) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); /* Draw all triangles for filling the polygon */ - immBegin(GWN_PRIM_TRIS, tot_triangles * 3); + immBegin(GPU_PRIM_TRIS, tot_triangles * 3); /* TODO: use batch instead of immediate mode, to share vertices */ const tGPspoint *pt; @@ -208,9 +208,9 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short return; } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); const tGPspoint *pt = points; @@ -218,7 +218,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short /* if drawing a single point, draw it larger */ GPU_point_size((float)(thickness + 2) * points->pressure); immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); gp_set_tpoint_varying_color(pt, ink, color); immVertex2iv(pos, &pt->x); } @@ -228,7 +228,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short /* draw stroke curve */ GPU_line_width(max_ff(oldpressure * thickness, 1.0)); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints); /* TODO: implement this with a geometry shader to draw one continuous tapered stroke */ @@ -247,7 +247,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short draw_points = 0; GPU_line_width(max_ff(pt->pressure * thickness, 1.0f)); - immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1); /* need to roll-back one point to ensure that there are no gaps in the stroke */ if (i != 0) { @@ -319,14 +319,14 @@ static void gp_draw_stroke_volumetric_buffer(const tGPspoint *points, int totpoi if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) return; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, totpoints); + immBegin(GPU_PRIM_POINTS, totpoints); const tGPspoint *pt = points; for (int i = 0; i < totpoints; i++, pt++) { @@ -346,14 +346,14 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points, int totpoints int offsx, int offsy, int winx, int winy, const float diff_mat[4][4], const float ink[4]) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, totpoints); + immBegin(GPU_PRIM_POINTS, totpoints); const bGPDspoint *pt = points; for (int i = 0; i < totpoints; i++, pt++) { @@ -379,14 +379,14 @@ static void gp_draw_stroke_volumetric_3d( const bGPDspoint *points, int totpoints, short thickness, const float ink[4]) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, totpoints); + immBegin(GPU_PRIM_POINTS, totpoints); const bGPDspoint *pt = points; for (int i = 0; i < totpoints && pt; i++, pt++) { @@ -519,18 +519,18 @@ static void gp_draw_stroke_fill( uint pos; if (gps->flag & GP_STROKE_3DSPACE) { - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); } else { - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); } immUniformColor4fv(color); /* Draw all triangles for filling the polygon (cache must be calculated before) */ - immBegin(GWN_PRIM_TRIS, gps->tot_triangles * 3); + immBegin(GPU_PRIM_TRIS, gps->tot_triangles * 3); /* TODO: use batch instead of immediate mode, to share vertices */ bGPDtriangle *stroke_triangle = gps->triangles; @@ -575,8 +575,8 @@ static void gp_draw_stroke_point( float fpt[3]; mul_v3_m4v3(fpt, diff_mat, &pt->x); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); if (sflag & GP_STROKE_3DSPACE) { immBindBuiltinProgram(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); @@ -594,7 +594,7 @@ static void gp_draw_stroke_point( /* set point thickness (since there's only one of these) */ immUniform1f("size", (float)(thickness + 2) * pt->pressure); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, fpt); immEnd(); @@ -617,9 +617,9 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR); @@ -627,7 +627,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi /* draw stroke curve */ GPU_line_width(max_ff(curpressure * thickness, 1.0f)); - immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints + cyclic_add); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints + cyclic_add); const bGPDspoint *pt = points; for (int i = 0; i < totpoints; i++, pt++) { gp_set_point_varying_color(pt, ink, color); @@ -648,7 +648,7 @@ static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thi curpressure = pt->pressure; GPU_line_width(max_ff(curpressure * thickness, 1.0f)); - immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add); /* need to roll-back one point to ensure that there are no gaps in the stroke */ if (i != 0) { @@ -716,12 +716,12 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, int totpoints, short thi int i; float fpt[3]; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_TRI_STRIP, totpoints * 2 + 4); + immBegin(GPU_PRIM_TRI_STRIP, totpoints * 2 + 4); /* get x and y coordinates from first point */ mul_v3_m4v3(fpt, diff_mat, &points->x); @@ -1150,21 +1150,21 @@ static void gp_draw_strokes_edit( UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, selectColor); selectColor[3] = alpha; - Gwn_VertFormat *format = immVertexFormat(); + GPUVertFormat *format = immVertexFormat(); uint pos; /* specified later */ - uint size = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint size = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); if (gps->flag & GP_STROKE_3DSPACE) { - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR); } else { - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR); } - immBegin(GWN_PRIM_POINTS, gps->totpoints); + immBegin(GPU_PRIM_POINTS, gps->totpoints); /* Draw start and end point differently if enabled stroke direction hint */ bool show_direction_hint = (gpd->flag & GP_DATA_SHOW_DIRECTION) && (gps->totpoints > 1); diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index a8810df35ff..bd9bfcf7025 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -985,8 +985,8 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda GP_EditBrush_Data *brush = gpsculpt_get_brush(CTX_data_scene(C)); if (brush) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_smooth(true); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index ec8a213301f..789e9865ae4 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1875,8 +1875,8 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) tGPsdata *p = (tGPsdata *)p_ptr; if (p->paintmode == GP_PAINTMODE_ERASER) { - Gwn_VertFormat *format = immVertexFormat(); - const uint shdr_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + const uint shdr_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_smooth(true); diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index 9b0b2c970b2..64dee410526 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -109,7 +109,7 @@ typedef enum eKeyframeShapeDrawOpts { } eKeyframeShapeDrawOpts; /* draw simple diamond-shape keyframe */ -/* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, immBegin(GWN_PRIM_POINTS, n), then call this n times */ +/* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, immBegin(GPU_PRIM_POINTS, n), then call this n times */ void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type, short mode, float alpha, unsigned int pos_id, unsigned int size_id, unsigned int color_id, unsigned int outline_color_id); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index b1c3795b1af..6a304a8150e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -130,19 +130,19 @@ void UI_draw_roundbox_aa(bool filled, float minx, float miny, float maxx, float /* WATCH: This is assuming the ModelViewProjectionMatrix is area pixel space. * If it has been scaled, then it's no longer valid. */ - Gwn_Batch *batch = ui_batch_roundbox_get(filled, true); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, true); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); } else { /* plain antialiased unfilled box */ GPU_line_smooth(true); - Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, false); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); GPU_line_smooth(false); } @@ -159,8 +159,8 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float }; int a; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* mult */ for (a = 0; a < 7; a++) { @@ -176,7 +176,7 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(col); - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_len); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_len); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { immVertex2f(pos, maxx - rad, miny); @@ -244,10 +244,10 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float .alpha_discard = 1.0f, }; - Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, false); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); } #if 0 @@ -280,9 +280,9 @@ void UI_draw_roundbox_shade_x( int vert_count = 0; int a; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -304,7 +304,7 @@ void UI_draw_roundbox_shade_x( vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1; vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1; - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_count); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { @@ -404,10 +404,10 @@ void UI_draw_roundbox_shade_x( .alpha_discard = 1.0f, }; - Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, false); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); } #if 0 /* unused */ @@ -432,9 +432,9 @@ void UI_draw_roundbox_shade_y( mul_v2_fl(vec[a], rad); } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -452,7 +452,7 @@ void UI_draw_roundbox_shade_y( vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1; vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1; - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_count); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { @@ -535,8 +535,8 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo { int ofs_y = 4 * U.pixelsize; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); @@ -550,9 +550,9 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo /* based on UI_draw_roundbox_gl_mode, check on making a version which allows us to skip some sides */ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highlight[3], unsigned char highlight_fade[3]) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); /* add a 1px offset, looks nicer */ const int minx = rect->xmin + U.pixelsize, maxx = rect->xmax - U.pixelsize; const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - U.pixelsize; @@ -571,7 +571,7 @@ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highligh } immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBeginAtMost(GWN_PRIM_LINE_STRIP, 25); + immBeginAtMost(GPU_PRIM_LINE_STRIP, 25); immAttrib3ubv(col, highlight); @@ -685,8 +685,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w * * \Note This functionn is to be used with the 2D dashed shader enabled. * - * \param pos is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib - * \param line_origin is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib + * \param pos is a PRIM_FLOAT, 2, GPU_FETCH_FLOAT vertex attrib + * \param line_origin is a PRIM_FLOAT, 2, GPU_FETCH_FLOAT vertex attrib * * The next 4 parameters are the offsets for the view, not the zones. */ @@ -749,7 +749,7 @@ static void histogram_draw_one( /* curve outline */ GPU_line_width(1.5); - immBegin(GWN_PRIM_LINE_STRIP, res); + immBegin(GPU_PRIM_LINE_STRIP, res); for (int i = 0; i < res; i++) { float x2 = x + i * (w / (float)res); immVertex2f(pos_attrib, x2, y + (data[i] * h)); @@ -758,7 +758,7 @@ static void histogram_draw_one( } else { /* under the curve */ - immBegin(GWN_PRIM_TRI_STRIP, res * 2); + immBegin(GPU_PRIM_TRI_STRIP, res * 2); immVertex2f(pos_attrib, x, y); immVertex2f(pos_attrib, x, y + (data[0] * h)); for (int i = 1; i < res; i++) { @@ -772,7 +772,7 @@ static void histogram_draw_one( immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - immBegin(GWN_PRIM_LINE_STRIP, res); + immBegin(GPU_PRIM_LINE_STRIP, res); for (int i = 0; i < res; i++) { float x2 = x + i * (w / (float)res); immVertex2f(pos_attrib, x2, y + (data[i] * h)); @@ -818,8 +818,8 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -833,7 +833,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); } - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rect.xmin, rect.ymin + fac * h); immVertex2f(pos, rect.xmax, rect.ymin + fac * h); @@ -869,21 +869,21 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS static void waveform_draw_one(float *waveform, int nbr, const float col[3]) { - Gwn_VertFormat format = {0}; - uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat format = {0}; + uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, nbr); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, nbr); - GWN_vertbuf_attr_fill(vbo, pos_id, waveform); + GPU_vertbuf_attr_fill(vbo, pos_id, waveform); - /* TODO store the Gwn_Batch inside the scope */ - Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); - GWN_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f); - GWN_batch_draw(batch); + /* TODO store the GPUBatch inside the scope */ + GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); + GPU_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f); + GPU_batch_draw(batch); - GWN_batch_discard(batch); + GPU_batch_discard(batch); } void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti) @@ -957,15 +957,15 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); /* draw grid lines here */ - immBegin(GWN_PRIM_LINES, 12); + immBegin(GPU_PRIM_LINES, 12); for (int i = 0; i < 6; i++) { immVertex2f(pos, rect.xmin + 22, yofs + (i * 0.2f) * h); @@ -976,7 +976,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE /* 3 vertical separation */ if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); for (int i = 1; i < 3; i++) { immVertex2f(pos, rect.xmin + i * w3, rect.ymin); @@ -987,7 +987,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE } /* separate min max zone on the right */ - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmin + w, rect.ymin); immVertex2f(pos, rect.xmin + w, rect.ymax); immEnd(); @@ -995,7 +995,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE /* 16-235-240 level in case of ITU-R BT601/709 */ immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f); if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) { - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(pos, rect.xmin + 22, yofs + h * 16.0f / 255.0f); immVertex2f(pos, rect.xmax + 1, yofs + h * 16.0f / 255.0f); @@ -1013,7 +1013,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE } /* 7.5 IRE black point level for NTSC */ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmin, yofs + h * 0.075f); immVertex2f(pos, rect.xmax + 1, yofs + h * 0.075f); immEnd(); @@ -1042,7 +1042,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE CLAMP(min, rect.ymin, rect.ymax); CLAMP(max, rect.ymin, rect.ymax); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmax - 3, min); immVertex2f(pos, rect.xmax - 3, max); immEnd(); @@ -1096,7 +1096,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE CLAMP(min, rect.ymin, rect.ymax); CLAMP(max, rect.ymin, rect.ymax); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmin + w + 2 + c * 2, min); immVertex2f(pos, rect.xmin + w + 2 + c * 2, max); immEnd(); @@ -1140,7 +1140,7 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente immUniformColor4f(1.0f, 1.0f, 1.0f, 0.12f); dangle = DEG2RADF(2.5f); dampli = 2.5f / 200.0f; - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle)); @@ -1152,22 +1152,22 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente dampli = 0.2f * tampli; dangle2 = DEG2RADF(5.0f); dampli2 = 0.5f * dampli; - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2)); immEnd(); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2)); immEnd(); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2)); immEnd(); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2)); @@ -1215,15 +1215,15 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); /* draw grid elements */ /* cross */ - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, centerx - (diam * 0.5f) - 5, centery); immVertex2f(pos, centerx + (diam * 0.5f) + 5, centery); @@ -1236,7 +1236,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN /* circles */ for (int j = 0; j < 5; j++) { const int increment = 15; - immBegin(GWN_PRIM_LINE_LOOP, (int)(360 / increment)); + immBegin(GPU_PRIM_LINE_LOOP, (int)(360 / increment)); for (int i = 0; i <= 360 - increment; i += increment) { const float a = DEG2RADF((float)i); const float r = (j + 1) * 0.1f; @@ -1247,7 +1247,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN /* skin tone line */ immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5f, skin_rad)); immVertex2f(pos, polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1f, skin_rad)); immEnd(); @@ -1284,7 +1284,7 @@ static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, floa { GPU_line_smooth(true); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, x1 + halfwidth, y1); immVertex2f(pos, x1, y1 + height); immVertex2f(pos, x1 - halfwidth, y1); @@ -1297,7 +1297,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f { glEnable(fill ? GL_POLYGON_SMOOTH : GL_LINE_SMOOTH); - immBegin(fill ? GWN_PRIM_TRIS : GWN_PRIM_LINE_LOOP, 3); + immBegin(fill ? GPU_PRIM_TRIS : GPU_PRIM_LINE_LOOP, 3); immVertex2f(pos, x1 + halfwidth, y1); immVertex2f(pos, x1, y1 + height); immVertex2f(pos, x1 - halfwidth, y1); @@ -1308,7 +1308,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f static void ui_draw_colorband_handle_box(unsigned int pos, float x1, float y1, float x2, float y2, bool fill) { - immBegin(fill ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4); + immBegin(fill ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x1, y2); immVertex2f(pos, x2, y2); @@ -1348,7 +1348,7 @@ static void ui_draw_colorband_handle( immUniformArray4fv("colors", (float *)(float[][4]){{0.8f, 0.8f, 0.8f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); immUniform1f("dash_width", active ? 4.0f : 2.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(shdr_pos, x, y1); immVertex2f(shdr_pos, x, y2); immEnd(); @@ -1419,8 +1419,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti float sizey_solid = sizey * 0.25f; float y1 = rect->ymin; - Gwn_VertFormat *format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); /* Drawing the checkerboard. */ @@ -1432,8 +1432,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti /* New format */ format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - col_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + col_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); /* layer: color ramp */ @@ -1447,7 +1447,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti v1[1] = y1 + sizey_solid; v2[1] = rect->ymax; - immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2); + immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2); for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; BKE_colorband_evaluate(coba, pos, colf); @@ -1466,7 +1466,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti v1[1] = y1; v2[1] = y1 + sizey_solid; - immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2); + immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2); for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; BKE_colorband_evaluate(coba, pos, colf); @@ -1487,7 +1487,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti /* New format */ format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* layer: box outline */ @@ -1498,14 +1498,14 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti GPU_blend(true); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos_id, x1, y1); immVertex2f(pos_id, x1 + sizex, y1); immEnd(); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos_id, x1, y1 - 1); immVertex2f(pos_id, x1 + sizex, y1 - 1); immEnd(); @@ -1558,18 +1558,18 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) GPU_matrix_translate_2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect)); GPU_matrix_scale_1f(size); - Gwn_Batch *sphere = GPU_batch_preset_sphere(2); - GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING); - GWN_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f); - GWN_batch_uniform_3fv(sphere, "light", light); - GWN_batch_draw(sphere); + GPUBatch *sphere = GPU_batch_preset_sphere(2); + GPU_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING); + GPU_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f); + GPU_batch_uniform_3fv(sphere, "light", light); + GPU_batch_draw(sphere); /* restore */ glDisable(GL_CULL_FACE); /* AA circle */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv((unsigned char *)wcol->inner); @@ -1599,7 +1599,7 @@ static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoo floorf((rect->xmax - fx) / dx) + 1.0f + floorf((rect->ymax - fy) / dy) + 1.0f); - immBegin(GWN_PRIM_LINES, (int)line_count * 2); + immBegin(GPU_PRIM_LINES, (int)line_count * 2); while (fx < rect->xmax) { immVertex2f(pos, fx, rect->ymin); immVertex2f(pos, fx, rect->ymax); @@ -1675,8 +1675,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti GPU_line_width(1.0f); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* backdrop */ @@ -1712,7 +1712,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f); /* axes */ gl_shaded_color((unsigned char *)wcol->inner, -50); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rect->xmin, rect->ymin + zoomy * (-offsy)); immVertex2f(pos, rect->xmax, rect->ymin + zoomy * (-offsy)); immVertex2f(pos, rect->xmin + zoomx * (-offsx), rect->ymin); @@ -1725,7 +1725,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti #if 0 if (cumap->flag & CUMA_DRAW_CFRA) { immUniformColor3ub(0x60, 0xc0, 0x40); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin); immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax); immEnd(); @@ -1734,7 +1734,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* sample option */ if (cumap->flag & CUMA_DRAW_SAMPLE) { - immBegin(GWN_PRIM_LINES, 2); /* will draw one of the following 3 lines */ + immBegin(GPU_PRIM_LINES, 2); /* will draw one of the following 3 lines */ if (but->a1 == UI_GRAD_H) { float tsample[3]; float hsv[3]; @@ -1770,7 +1770,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti immUniformColor3ubv((unsigned char *)wcol->item); GPU_line_smooth(true); GPU_blend(true); - immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2); + immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2); if (cuma->table == NULL) curvemapping_changed(cumap, false); @@ -1807,13 +1807,13 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* the points, use aspect to make them visible on edges */ format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); cmp = cuma->curve; GPU_point_size(3.0f); - immBegin(GWN_PRIM_POINTS, cuma->totpoint); + immBegin(GPU_PRIM_POINTS, cuma->totpoint); for (int a = 0; a < cuma->totpoint; a++) { float color[4]; if (cmp[a].flag & CUMA_SELECT) @@ -1833,7 +1833,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* outline */ format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv((unsigned char *)wcol->outline); @@ -1926,16 +1926,16 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U BLI_rctf_size_x(&rect), BLI_rctf_size_y(&rect)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); UI_GetThemeColor4fv(TH_SEL_MARKER, col_sel); UI_GetThemeColor4fv(TH_MARKER_OUTLINE, col_outline); /* Do stipple cross with geometry */ - immBegin(GWN_PRIM_LINES, 7 * 2 * 2); + immBegin(GPU_PRIM_LINES, 7 * 2 * 2); float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f}; for (int axe = 0; axe < 2; ++axe) { for (int i = 0; i < 7; ++i) { @@ -2018,13 +2018,13 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol float x = 0.5f * (recti->xmin + recti->xmax); float y = 0.5f * (recti->ymin + recti->ymax); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(but->col); GPU_blend(true); - immBegin(GWN_PRIM_TRI_FAN, 16); + immBegin(GPU_PRIM_TRI_FAN, 16); for (int a = 0; a < 16; a++) immVertex2f(pos, x + size * si[a], y + size * co[a]); immEnd(); @@ -2032,7 +2032,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol immUniformColor4ub(0, 0, 0, 150); GPU_line_width(1); GPU_line_smooth(true); - immBegin(GWN_PRIM_LINE_LOOP, 16); + immBegin(GPU_PRIM_LINE_LOOP, 16); for (int a = 0; a < 16; a++) immVertex2f(pos, x + size * si[a], y + size * co[a]); immEnd(); @@ -2115,13 +2115,13 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, { GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(GWN_PRIM_TRIS, 54); + immBegin(GPU_PRIM_TRIS, 54); /* accumulated outline boxes to make shade not linear, is more pleasant */ ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8); @@ -2186,11 +2186,11 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha .alpha_discard = 1.0f, }; - Gwn_Batch *batch = ui_batch_roundbox_shadow_get(); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW); - GWN_batch_uniform_4fv_array(batch, "parameters", 4, (float *)&widget_params); - GWN_batch_uniform_1f(batch, "alpha", 1.0f - visibility); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_shadow_get(); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW); + GPU_batch_uniform_4fv_array(batch, "parameters", 4, (float *)&widget_params); + GPU_batch_uniform_1f(batch, "alpha", 1.0f - visibility); + GPU_batch_draw(batch); /* outline emphasis */ GPU_line_smooth(true); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index b9183461b4c..22b82898288 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -250,11 +250,11 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float viconutil_set_point(pts[1], cx - d2, cy - d); viconutil_set_point(pts[2], cx + d2, cy); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.2f, 0.2f, 0.2f, alpha); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2iv(pos, pts[0]); immVertex2iv(pos, pts[1]); immVertex2iv(pos, pts[2]); @@ -280,15 +280,15 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, int xco = x + w / 2; int yco = y + h / 2; - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); /* draw keyframe * - size: 0.6 * h (found out experimentally... dunno why!) @@ -343,7 +343,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU const int b = x + w / 3 * 2; const int c = x + w; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* XXX: Include alpha into this... */ @@ -1262,7 +1262,7 @@ static void icon_draw_cache_flush_ex(void) glUniform1i(img_loc, 0); glUniform4fv(data_loc, ICON_DRAW_CACHE_SIZE * 3, (float *)g_icon_draw_cache.drawcall_cache); - GWN_draw_primitive(GWN_PRIM_TRIS, 6 * g_icon_draw_cache.calls); + GPU_draw_primitive(GPU_PRIM_TRIS, 6 * g_icon_draw_cache.calls); glBindTexture(GL_TEXTURE_2D, 0); @@ -1342,14 +1342,14 @@ static void icon_draw_texture( GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR); GPU_shader_bind(shader); - if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha); - else glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha); + if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha); + else glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha); glUniform1i(GPU_shader_get_uniform(shader, "image"), 0); glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), x1, y1, x2, y2); glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x, y, x + w, y + h); - GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4); + GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); glBindTexture(GL_TEXTURE_2D, 0); } diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c index dc444b98b2c..fabf5f9bf48 100644 --- a/source/blender/editors/interface/interface_icons_event.c +++ b/source/blender/editors/interface/interface_icons_event.c @@ -136,8 +136,8 @@ static void icon_draw_rect_input_line_prim( { glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - BLI_assert(ELEM(prim, GWN_PRIM_LINE_LOOP, GWN_PRIM_LINE_STRIP)); - const uint pos_id = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + BLI_assert(ELEM(prim, GPU_PRIM_LINE_LOOP, GPU_PRIM_LINE_STRIP)); + const uint pos_id = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); immBegin(prim, lines_len); @@ -289,7 +289,7 @@ void icon_draw_rect_input( else if (event_type == SPACEKEY) { const uchar lines[] = {60, 118, 60, 60, 195, 60, 195, 118}; icon_draw_rect_input_line_prim( - &rect, color, GWN_PRIM_LINE_STRIP, + &rect, color, GPU_PRIM_LINE_STRIP, (const void *)lines, ARRAY_SIZE(lines) / 2); } } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index ffc389c6dfd..f0060cd5758 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -752,9 +752,9 @@ enum { ROUNDBOX_TRIA_MAX, /* don't use */ }; -struct Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased); -struct Gwn_Batch *ui_batch_roundbox_widget_get(int tria); -struct Gwn_Batch *ui_batch_roundbox_shadow_get(void); +struct GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased); +struct GPUBatch *ui_batch_roundbox_widget_get(int tria); +struct GPUBatch *ui_batch_roundbox_shadow_get(void); void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4]); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 79d92eedfa3..59fdf7e672d 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -478,7 +478,7 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y2); @@ -519,7 +519,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect) GPU_blend(true); immUniformColor4ub(255, 255, 255, 50); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, xmin, ymin); immVertex2f(pos, xmax, ymax); @@ -531,7 +531,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect) immUniformColor4ub(0, 0, 0, 50); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, xmin, ymin + 1); immVertex2f(pos, xmax, ymax + 1); @@ -584,7 +584,7 @@ static void ui_draw_panel_dragwidget(unsigned int pos, unsigned int col, const r UI_GetThemeColorShade4fv(TH_PANEL_BACK, -col_tint, col_dark); /* draw multiple boxes */ - immBegin(GWN_PRIM_TRIS, 4 * 2 * (6 * 2)); + immBegin(GPU_PRIM_TRIS, 4 * 2 * (6 * 2)); for (i_x = 0; i_x < 4; i_x++) { for (i_y = 0; i_y < 2; i_y++) { const int x_co = (x_min + x_ofs) + (i_x * (box_size + box_margin)); @@ -677,7 +677,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con titlerect.xmin += 5.0f / block->aspect; } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); if (!is_subpanel) { @@ -691,7 +691,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con immUniformThemeColor(TH_PANEL_HEADER); immRectf(pos, minx, headrect.ymin, maxx, y); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, minx, y); immVertex2f(pos, maxx, y); @@ -729,9 +729,9 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con if (show_drag) { uint col; - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); /* itemrect smaller */ itemrect.xmax = headrect.xmax - 5.0f / block->aspect; @@ -745,7 +745,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con immUnbindProgram(); /* Restore format for the following draws. */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } } @@ -758,7 +758,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con else if (is_closed_x) { /* draw vertical title */ ui_draw_aligned_panel_header(style, block, &headrect, 'v'); - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } /* an open panel */ else { @@ -1700,9 +1700,9 @@ static void ui_panel_category_draw_tab( {0.98, 0.805}}; int a; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); /* mult */ for (a = 0; a < 4; a++) { @@ -1724,7 +1724,7 @@ static void ui_panel_category_draw_tab( immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_STRIP, vert_len); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_STRIP, vert_len); /* start with corner right-top */ if (use_highlight) { @@ -1929,7 +1929,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* begin drawing */ GPU_line_smooth(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw the background */ @@ -1991,7 +1991,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* tab blackline */ if (!is_active) { - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(theme_col_tab_divider); @@ -2022,7 +2022,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) GPU_blend(false); /* tab blackline remaining (last tab) */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); if (pc_dyn->prev == NULL) { immUniformColor3ubv(theme_col_tab_divider); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index aa3106b135b..52e6e237a58 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -247,22 +247,22 @@ static const int tria_vcount[ROUNDBOX_TRIA_MAX] = { }; static struct { - Gwn_Batch *roundbox_widget[ROUNDBOX_TRIA_MAX]; + GPUBatch *roundbox_widget[ROUNDBOX_TRIA_MAX]; - Gwn_Batch *roundbox_simple; - Gwn_Batch *roundbox_simple_aa; - Gwn_Batch *roundbox_simple_outline; - Gwn_Batch *roundbox_shadow; + GPUBatch *roundbox_simple; + GPUBatch *roundbox_simple_aa; + GPUBatch *roundbox_simple_outline; + GPUBatch *roundbox_shadow; - Gwn_VertFormat format; + GPUVertFormat format; uint vflag_id; } g_ui_batch_cache = {{0}}; -static Gwn_VertFormat *vflag_format(void) +static GPUVertFormat *vflag_format(void) { if (g_ui_batch_cache.format.attr_len == 0) { - Gwn_VertFormat *format = &g_ui_batch_cache.format; - g_ui_batch_cache.vflag_id = GWN_vertformat_attr_add(format, "vflag", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = &g_ui_batch_cache.format; + g_ui_batch_cache.vflag_id = GPU_vertformat_attr_add(format, "vflag", GPU_COMP_U32, 1, GPU_FETCH_INT); } return &g_ui_batch_cache.format; } @@ -273,17 +273,17 @@ static Gwn_VertFormat *vflag_format(void) #define NO_AA WIDGET_AA_JITTER static void set_roundbox_vertex_data( - Gwn_VertBufRaw *vflag_step, uint32_t d) + GPUVertBufRaw *vflag_step, uint32_t d) { - uint32_t *data = GWN_vertbuf_raw_step(vflag_step); + uint32_t *data = GPU_vertbuf_raw_step(vflag_step); *data = d; } static uint32_t set_roundbox_vertex( - Gwn_VertBufRaw *vflag_step, + GPUVertBufRaw *vflag_step, int corner_id, int corner_v, int jit_v, bool inner, bool emboss, int color) { - uint32_t *data = GWN_vertbuf_raw_step(vflag_step); + uint32_t *data = GPU_vertbuf_raw_step(vflag_step); *data = corner_id; *data |= corner_v << 2; *data |= jit_v << 6; @@ -294,10 +294,10 @@ static uint32_t set_roundbox_vertex( } static uint32_t set_tria_vertex( - Gwn_VertBufRaw *vflag_step, + GPUVertBufRaw *vflag_step, int tria_type, int tria_v, int tria_id, int jit_v) { - uint32_t *data = GWN_vertbuf_raw_step(vflag_step); + uint32_t *data = GPU_vertbuf_raw_step(vflag_step); if (ELEM(tria_type, ROUNDBOX_TRIA_ARROWS)) { tria_v += tria_id * tria_vcount[ROUNDBOX_TRIA_ARROWS]; } @@ -308,7 +308,7 @@ static uint32_t set_tria_vertex( return *data; } -static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32_t last_data) +static void roundbox_batch_add_tria(GPUVertBufRaw *vflag_step, int tria, uint32_t last_data) { const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW, ROUNDBOX_TRIA_MENU) ? 1 : 2; /* for each tria */ @@ -324,12 +324,12 @@ static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32 } } -Gwn_Batch *ui_batch_roundbox_widget_get(int tria) +GPUBatch *ui_batch_roundbox_widget_get(int tria) { if (g_ui_batch_cache.roundbox_widget[tria] == NULL) { uint32_t last_data; - Gwn_VertBufRaw vflag_step; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format()); + GPUVertBufRaw vflag_step; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); int vcount = WIDGET_SIZE_MAX; /* inner */ vcount += 2; /* restart */ vcount += ((WIDGET_SIZE_MAX + 1) * 2) * WIDGET_AA_JITTER; /* outline (edges) */ @@ -341,8 +341,8 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria) vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria2 */ } } - GWN_vertbuf_data_alloc(vbo, vcount); - GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); + GPU_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); /* Inner */ for (int c1 = 0, c2 = 3; c1 < 2; c1++, c2--) { for (int a1 = 0, a2 = WIDGET_CURVE_RESOLU -1; a2 >= 0; a1++, a2--) { @@ -383,15 +383,15 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria) if (tria) { roundbox_batch_add_tria(&vflag_step, tria, last_data); } - g_ui_batch_cache.roundbox_widget[tria] = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + g_ui_batch_cache.roundbox_widget[tria] = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); gpu_batch_presets_register(g_ui_batch_cache.roundbox_widget[tria]); } return g_ui_batch_cache.roundbox_widget[tria]; } -Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) +GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased) { - Gwn_Batch **batch = NULL; + GPUBatch **batch = NULL; if (filled) { if (antialiased) @@ -408,13 +408,13 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) if (*batch == NULL) { uint32_t last_data; - Gwn_VertBufRaw vflag_step; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format()); + GPUVertBufRaw vflag_step; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); int vcount = WIDGET_SIZE_MAX; vcount += (filled) ? 2 : 0; vcount *= (antialiased) ? WIDGET_AA_JITTER : 1; - GWN_vertbuf_data_alloc(vbo, vcount); - GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); + GPU_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); if (filled) { for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -435,7 +435,7 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) break; } } - *batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + *batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); } else { for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -451,7 +451,7 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) break; } } - *batch = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); + *batch = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO); } gpu_batch_presets_register(*batch); @@ -459,15 +459,15 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) return *batch; } -Gwn_Batch *ui_batch_roundbox_shadow_get(void) +GPUBatch *ui_batch_roundbox_shadow_get(void) { if (g_ui_batch_cache.roundbox_shadow == NULL) { uint32_t last_data; - Gwn_VertBufRaw vflag_step; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format()); + GPUVertBufRaw vflag_step; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); int vcount = (WIDGET_SIZE_MAX + 1) * 2 + 2 + WIDGET_SIZE_MAX; - GWN_vertbuf_data_alloc(vbo, vcount); - GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); + GPU_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); for (int c = 0; c < 4; c++) { for (int a = 0; a < WIDGET_CURVE_RESOLU; a++) { @@ -488,7 +488,7 @@ Gwn_Batch *ui_batch_roundbox_shadow_get(void) set_roundbox_vertex(&vflag_step, c2, a2, NO_AA, true, false, INNER); } } - g_ui_batch_cache.roundbox_shadow = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + g_ui_batch_cache.roundbox_shadow = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); gpu_batch_presets_register(g_ui_batch_cache.roundbox_shadow); } return g_ui_batch_cache.roundbox_shadow; @@ -513,11 +513,11 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(draw_color); - immBegin(GWN_PRIM_TRIS, 3 * WIDGET_AA_JITTER); + immBegin(GPU_PRIM_TRIS, 3 * WIDGET_AA_JITTER); /* for each AA step */ for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -556,14 +556,14 @@ void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float col GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(draw_color); /* for each AA step */ for (int j = 0; j < WIDGET_AA_JITTER; j++) { - immBegin(GWN_PRIM_TRI_FAN, length); + immBegin(GPU_PRIM_TRI_FAN, length); immVertex2f(pos, tri_array[0][0], tri_array[0][1]); immVertex2f(pos, tri_array[1][0], tri_array[1][1]); @@ -1084,7 +1084,7 @@ static void widgetbase_set_uniform_colors_ubv( #define MAX_WIDGET_PARAMETERS 11 struct { - Gwn_Batch *batch; /* Batch type */ + GPUBatch *batch; /* Batch type */ uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]; int count; bool enabled; @@ -1097,22 +1097,22 @@ void UI_widgetbase_draw_cache_flush(void) if (g_widget_base_batch.count == 0) return; - Gwn_Batch *batch = g_widget_base_batch.batch; + GPUBatch *batch = g_widget_base_batch.batch; if (g_widget_base_batch.count == 1) { /* draw single */ - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params); - GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params); + GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); + GPU_batch_draw(batch); } else { - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST); - GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST); + GPU_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, (float *)g_widget_base_batch.params); - GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); + GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); GPU_matrix_bind(batch->interface); - GWN_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true); - GWN_batch_program_use_end(batch); + GPU_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true); + GPU_batch_program_use_end(batch); } g_widget_base_batch.count = 0; } @@ -1135,7 +1135,7 @@ void UI_widgetbase_draw_cache_end(void) GPU_blend(false); } -static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb) +static void draw_widgetbase_batch(GPUBatch *batch, uiWidgetBase *wtb) { wtb->uniform_params.tria1_size = wtb->tria1.size; wtb->uniform_params.tria2_size = wtb->tria2.size; @@ -1171,10 +1171,10 @@ static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb) else { float checker_params[3] = {UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 8.0f}; /* draw single */ - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&wtb->uniform_params); - GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&wtb->uniform_params); + GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); + GPU_batch_draw(batch); } } @@ -1228,7 +1228,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol) if (inner_col1[3] || inner_col2[3] || outline_col[3] || emboss_col[3] || tria_col[3] || alpha_check) { widgetbase_set_uniform_colors_ubv(wtb, inner_col1, inner_col2, outline_col, emboss_col, tria_col, alpha_check); - Gwn_Batch *roundbox_batch = ui_batch_roundbox_widget_get(wtb->tria1.type); + GPUBatch *roundbox_batch = ui_batch_roundbox_widget_get(wtb->tria1.type); draw_widgetbase_batch(roundbox_batch, wtb); } @@ -1836,7 +1836,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selend - but->ofs); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)wcol->item); @@ -1872,7 +1872,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b UI_widgetbase_draw_cache_flush(); GPU_blend(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(0.2f, 0.6f, 0.9f); @@ -2423,7 +2423,7 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r /* we draw a number of increasing size alpha quad strips */ alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2475,7 +2475,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir static void ui_hsv_cursor(float x, float y) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2571,13 +2571,13 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * ui_color_picker_to_rgb(0.0f, 0.0f, hsv[2], colcent, colcent + 1, colcent + 2); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(GWN_PRIM_TRI_FAN, tot + 2); + immBegin(GPU_PRIM_TRI_FAN, tot + 2); immAttrib3fv(color, colcent); immVertex2f(pos, centx, centy); @@ -2598,7 +2598,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * /* fully rounded outline */ format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2682,12 +2682,12 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons } /* old below */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(GWN_PRIM_TRIS, steps * 3 * 6); + immBegin(GPU_PRIM_TRIS, steps * 3 * 6); for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */ const float dx_next = dx + color_step; @@ -2843,7 +2843,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) ui_hsv_cursor(x, y); /* outline */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ub(0, 0, 0); imm_draw_box_wire_2d(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax)); @@ -2940,14 +2940,14 @@ static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol) 30 }; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_blend(true); immUniformColor4ubv(col); GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect->xmin, y); immVertex2f(pos, rect->xmax, y); immEnd(); @@ -3402,11 +3402,11 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat UI_widgetbase_draw_cache_flush(); GPU_blend(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(bw, bw, bw); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.9f * height); immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.5f * height); immVertex2f(pos, rect->xmin + 0.5f * width, rect->ymin + 0.9f * height); @@ -3783,7 +3783,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * /* note: drawextra can change rect +1 or -1, to match round errors of existing previews */ but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* make mask to draw over image */ @@ -4420,11 +4420,11 @@ static void ui_draw_popover_back_impl( /* Draw popover arrow (top/bottom) */ if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)wcol->inner); GPU_blend(true); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); if (direction == UI_DIR_DOWN) { const float y = rect->ymax; immVertex2f(pos, cent_x - unit_half, y); @@ -4476,10 +4476,10 @@ static void draw_disk_shaded( unsigned char r_col[4]; unsigned int pos, col; - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (shaded) { - col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); } else { @@ -4487,7 +4487,7 @@ static void draw_disk_shaded( immUniformColor4ubv((unsigned char *)col1); } - immBegin(GWN_PRIM_TRI_STRIP, subd * 2); + immBegin(GPU_PRIM_TRI_STRIP, subd * 2); for (i = 0; i < subd; i++) { float a; @@ -4556,8 +4556,8 @@ void ui_draw_pie_center(uiBlock *block) } } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)btheme->tui.wcol_pie_menu.outline); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 7d9eb1181ed..3a527712367 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1338,12 +1338,12 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) if (vertex_count == 0) return; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_count); + immBegin(GPU_PRIM_LINES, vertex_count); /* vertical lines */ if (flag & V2D_VERTICAL_LINES) { @@ -1480,15 +1480,15 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) count_y = (v2d->cur.ymax - start_y) / step + 1; if (count_x > 0 || count_y > 0) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); float theme_color[3]; UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, count_x * 2 + count_y * 2 + 4); + immBegin(GPU_PRIM_LINES, count_x * 2 + count_y * 2 + 4); immAttrib3fv(color, theme_color); for (int i = 0; i < count_x ; start_x += step, i++) { @@ -1531,14 +1531,14 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s vertex_count += 2 * ((int)((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1); vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); GPU_line_width(1.0f); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBeginAtMost(GWN_PRIM_LINES, vertex_count); + immBeginAtMost(GPU_PRIM_LINES, vertex_count); for (int level = 0; level < totlevels; ++level) { UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 14cec724168..506dec2aa3e 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -124,8 +124,8 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin return; } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff}; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -134,7 +134,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin /* this could be split into its own loop */ if (draw_type == MASK_DT_OUTLINE) { GPU_line_width(3.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(pos, point_pos); immVertex2fv(pos, handle_pos); immEnd(); @@ -154,7 +154,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin } GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(pos, point_pos); immVertex2fv(pos, handle_pos); immEnd(); @@ -178,7 +178,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const MaskSplinePoin immUniform4fv("outlineColor", point_color); immUniformColor3fvAlpha(point_color, 0.25f); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2fv(pos, handle_pos); immEnd(); @@ -212,8 +212,8 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline mask_spline_color_get(masklay, spline, is_spline_sel, rgb_spline); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA); immUniform1f("size", 0.7f * handle_size); @@ -251,7 +251,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline immUniformThemeColor(TH_HANDLE_VERTEX); } - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2fv(pos, feather_point); immEnd(); @@ -320,7 +320,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline else immUniformThemeColor(TH_HANDLE_VERTEX); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2fv(pos, vert); immEnd(); @@ -350,7 +350,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 1.0f); immUniform1f("size", 12.0f); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(pos, x, y); immEnd(); @@ -371,7 +371,7 @@ static void mask_color_active_tint(unsigned char r_rgb[4], const unsigned char r } } -static void mask_draw_array(unsigned int pos, Gwn_PrimType prim_type, const float (*points)[2], unsigned int vertex_len) +static void mask_draw_array(unsigned int pos, GPUPrimType prim_type, const float (*points)[2], unsigned int vertex_len) { immBegin(prim_type, vertex_len); for (unsigned int i = 0; i < vertex_len; ++i) { @@ -384,7 +384,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (* const bool is_feather, const bool is_active, const unsigned char rgb_spline[4], const char draw_type) { - const Gwn_PrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GWN_PRIM_LINE_LOOP : GWN_PRIM_LINE_STRIP; + const GPUPrimType draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GPU_PRIM_LINE_LOOP : GPU_PRIM_LINE_STRIP; const unsigned char rgb_black[4] = {0x00, 0x00, 0x00, 0xff}; unsigned char rgb_tmp[4]; SpaceClip *sc = CTX_wm_space_clip(C); @@ -402,8 +402,8 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (* } } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); switch (draw_type) { @@ -747,12 +747,12 @@ void ED_mask_draw_frames(Mask *mask, ARegion *ar, const int cfra, const int sfra unsigned int num_lines = BLI_listbase_count(&masklay->splines_shapes); if (num_lines > 0) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(255, 175, 0, 255); - immBegin(GWN_PRIM_LINES, 2 * num_lines); + immBegin(GPU_PRIM_LINES, 2 * num_lines); for (MaskLayerShape *masklay_shape = masklay->splines_shapes.first; masklay_shape; diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index a2717e53358..99756269c1f 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1007,13 +1007,13 @@ static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd) copy_v3_v3(v2, ray_hit_best[1]); } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor(TH_TRANSFORM); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, v1); immVertex3fv(pos, v2); immEnd(); @@ -1048,7 +1048,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void GPU_matrix_push(); GPU_matrix_mul(kcd->ob->obmat); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -1059,7 +1059,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.line); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, kcd->prev.cage); immVertex3fv(pos, kcd->curr.cage); immEnd(); @@ -1069,7 +1069,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.point); GPU_point_size(11); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->prev.cage); immEnd(); } @@ -1078,7 +1078,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.curpoint); GPU_point_size(9); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->prev.cage); immEnd(); } @@ -1087,7 +1087,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.edge); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, kcd->curr.edge->v1->cageco); immVertex3fv(pos, kcd->curr.edge->v2->cageco); immEnd(); @@ -1096,7 +1096,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.point); GPU_point_size(11); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->curr.cage); immEnd(); } @@ -1105,7 +1105,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.curpoint); GPU_point_size(9); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(pos, kcd->curr.cage); immEnd(); } @@ -1121,7 +1121,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor4ubv(kcd->colors.point_a); GPU_point_size(11); - immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit); + immBeginAtMost(GPU_PRIM_POINTS, kcd->totlinehit); lh = kcd->linehits; for (i = 0; i < kcd->totlinehit; i++, lh++) { @@ -1136,7 +1136,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor4ubv(kcd->colors.curpoint_a); GPU_point_size(7); - immBeginAtMost(GWN_PRIM_POINTS, kcd->totlinehit); + immBeginAtMost(GPU_PRIM_POINTS, kcd->totlinehit); lh = kcd->linehits; for (i = 0; i < kcd->totlinehit; i++, lh++) { @@ -1157,7 +1157,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.line); GPU_line_width(1.0); - immBeginAtMost(GWN_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2); + immBeginAtMost(GPU_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2); BLI_mempool_iternew(kcd->kedges, &iter); for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) { @@ -1178,7 +1178,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void immUniformColor3ubv(kcd->colors.point); GPU_point_size(5.0); - immBeginAtMost(GWN_PRIM_POINTS, BLI_mempool_len(kcd->kverts)); + immBeginAtMost(GPU_PRIM_POINTS, BLI_mempool_len(kcd->kverts)); BLI_mempool_iternew(kcd->kverts, &iter); for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) { diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 9a58f1dcd08..95c94c146e4 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -116,13 +116,13 @@ static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *a GPU_matrix_push(); GPU_matrix_mul(lcd->ob->obmat); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3ub(255, 0, 255); if (lcd->totedge > 0) { - immBegin(GWN_PRIM_LINES, lcd->totedge * 2); + immBegin(GPU_PRIM_LINES, lcd->totedge * 2); for (int i = 0; i < lcd->totedge; i++) { immVertex3fv(pos, lcd->edges[i][0]); @@ -135,7 +135,7 @@ static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *a if (lcd->totpoint > 0) { GPU_point_size(3.0f); - immBegin(GWN_PRIM_POINTS, lcd->totpoint); + immBegin(GPU_PRIM_POINTS, lcd->totpoint); for (int i = 0; i < lcd->totpoint; i++) { immVertex3fv(pos, lcd->points[i]); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 10d9c90aeb3..1b82e60b986 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2892,7 +2892,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) brush = &pset->brush[pset->brushtype]; if (brush) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(255, 255, 255, 128); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index cb8fdba0ae1..1a63bc1cd53 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -105,12 +105,12 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides) float color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); - immBeginAtMost(GWN_PRIM_LINES, 8); + immBeginAtMost(GPU_PRIM_LINES, 8); /* right */ if (sides & REGION_EMBOSS_RIGHT) { @@ -262,8 +262,8 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f BLI_rcti_init(&click_rect, x, x + icon_size, y, y + icon_size); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -271,7 +271,7 @@ static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, f imm_draw_box_wire_2d(pos, click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax); immUniformColor4f(0.0f, 1.0f, 1.0f, alpha); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, click_rect.xmin, click_rect.ymin); immVertex2f(pos, click_rect.xmax, click_rect.ymax); immVertex2f(pos, click_rect.xmin, click_rect.ymax); @@ -295,8 +295,8 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2) float width = 0.1f * U.widget_unit; float pad = 0.2f * U.widget_unit; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_blend(true); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -500,8 +500,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar) /* for debugging unneeded area redraws and partial redraw */ #if 0 GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(drand48(), drand48(), drand48(), 0.1f); immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin, @@ -2472,8 +2472,8 @@ void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(fill_color); immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1); @@ -2691,8 +2691,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, /* set up rect */ BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y); /* draw top box */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_METADATA_BG); immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -2716,8 +2716,8 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, /* set up box rect */ BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin); /* draw top box */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_METADATA_BG); immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -2745,8 +2745,8 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x1, &y1); UI_view2d_view_to_region(&ar->v2d, 1.0f, 1.0f, &x2, &y2); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(TH_BACK, 20); @@ -2778,12 +2778,12 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) int count_large = 1.0f / (4.0f * gridstep); if (count_fine > 0) { - GWN_vertformat_clear(format); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPU_vertformat_clear(format); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + unsigned color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, 4 * count_fine + 4 * count_large); + immBegin(GPU_PRIM_LINES, 4 * count_fine + 4 * count_large); float theme_color[3]; UI_GetThemeColorShade3fv(TH_BACK, (int)(20.0f * (1.0f - blendfac)), theme_color); @@ -2877,7 +2877,7 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect) void ED_region_cache_draw_background(const ARegion *ar) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(128, 128, 255, 64); immRecti(pos, 0, 0, ar->winx, 8 * UI_DPI_FAC); @@ -2897,7 +2897,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_CFRAME); immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); @@ -2911,7 +2911,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f void ED_region_cache_draw_cached_segments(const ARegion *ar, const int num_segments, const int *points, const int sfra, const int efra) { if (num_segments) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(128, 128, 255, 128); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 41404aee9c9..7fa093106df 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -140,9 +140,9 @@ static int get_cached_work_texture(int *r_w, int *r_h) static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state) { - Gwn_VertFormat *vert_format = immVertexFormat(); - state->pos = GWN_vertformat_attr_add(vert_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - state->texco = GWN_vertformat_attr_add(vert_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *vert_format = immVertexFormat(); + state->pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + state->texco = GPU_vertformat_attr_add(vert_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } /* To be used before calling immDrawPixelsTex @@ -297,7 +297,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, format, GL_UNSIGNED_BYTE, &uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]); } - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texco, (float)(0 + offset_left) / tex_w, (float)(0 + offset_bot) / tex_h); immVertex2f(pos, rast_x + (float)offset_left * xzoom, rast_y + (float)offset_bot * yzoom); @@ -551,28 +551,28 @@ void immDrawBorderCorners(unsigned int pos, const rcti *border, float zoomx, flo delta_y = min_ff(delta_y, border->ymax - border->ymin); /* left bottom corner */ - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, border->xmin, border->ymin + delta_y); immVertex2f(pos, border->xmin, border->ymin); immVertex2f(pos, border->xmin + delta_x, border->ymin); immEnd(); /* left top corner */ - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, border->xmin, border->ymax - delta_y); immVertex2f(pos, border->xmin, border->ymax); immVertex2f(pos, border->xmin + delta_x, border->ymax); immEnd(); /* right bottom corner */ - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, border->xmax - delta_x, border->ymin); immVertex2f(pos, border->xmax, border->ymin); immVertex2f(pos, border->xmax, border->ymin + delta_y); immEnd(); /* right top corner */ - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, border->xmax - delta_x, border->ymax); immVertex2f(pos, border->xmax, border->ymax); immVertex2f(pos, border->xmax, border->ymax - delta_y); diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index 6e512d6d4df..10d72d74b22 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -99,7 +99,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) } } - immBegin(GWN_PRIM_TRI_FAN, 5); + immBegin(GPU_PRIM_TRI_FAN, 5); for (i = 0; i < 5; i++) { immVertex2f(pos, points[i].x, points[i].y); @@ -107,7 +107,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir, unsigned int pos) immEnd(); - immBegin(GWN_PRIM_TRI_FAN, 5); + immBegin(GPU_PRIM_TRI_FAN, 5); for (i = 4; i < 8; i++) { immVertex2f(pos, points[i].x, points[i].y); @@ -180,7 +180,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos) } } - immBegin(GWN_PRIM_TRI_FAN, 5); + immBegin(GPU_PRIM_TRI_FAN, 5); for (i = 0; i < 5; i++) { immVertex2f(pos, points[i].x, points[i].y); @@ -188,7 +188,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir, unsigned int pos) immEnd(); - immBegin(GWN_PRIM_TRI_FAN, 5); + immBegin(GPU_PRIM_TRI_FAN, 5); for (i = 4; i < 8; i++) { immVertex2f(pos, points[i].x, points[i].y); @@ -323,11 +323,11 @@ static void drawscredge_corner(ScrArea *sa, int sizex, int sizey) /* Wrap up the corners with a nice embossing. */ rcti rect = sa->totrct; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); - immBeginAtMost(GWN_PRIM_LINES, 8); + immBeginAtMost(GPU_PRIM_LINES, 8); /* Right. */ immVertex2f(pos, rect.xmax, rect.ymax); @@ -386,7 +386,7 @@ static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, shor return; } - immBegin(GWN_PRIM_LINES, count); + immBegin(GPU_PRIM_LINES, count); /* right border area */ if (x2 < sizex - 1) { @@ -439,7 +439,7 @@ void ED_screen_draw_edges(wmWindow *win) ScrArea *sa; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* Note: first loop only draws if U.pixelsize > 1, skip otherwise */ @@ -477,7 +477,7 @@ void ED_screen_draw_edges(wmWindow *win) */ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_width(1); @@ -518,14 +518,14 @@ void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2) void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* splitpoint */ GPU_blend(true); immUniformColor4ub(255, 255, 255, 100); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); if (dir == 'h') { const float y = (1 - fac) * sa->totrct.ymin + fac * sa->totrct.ymax; @@ -537,7 +537,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) immUniformColor4ub(0, 0, 0, 100); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, sa->totrct.xmin, y + 1); immVertex2f(pos, sa->totrct.xmax, y + 1); @@ -555,7 +555,7 @@ void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac) immUniformColor4ub(0, 0, 0, 100); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, x + 1, sa->totrct.ymin); immVertex2f(pos, x + 1, sa->totrct.ymax); @@ -594,7 +594,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2 const float ofs_between_areas) { const float ofs_h = ofs_between_areas * 0.5f; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(col); @@ -607,7 +607,7 @@ static void screen_preview_draw_areas(const bScreen *screen, const float scale[2 .ymax = sa->totrct.ymax * scale[1] - ofs_h }; - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immVertex2f(pos, rect.xmin, rect.ymin); immVertex2f(pos, rect.xmax, rect.ymin); immVertex2f(pos, rect.xmax, rect.ymax); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index e1de86910ff..997fe1282f9 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -680,9 +680,9 @@ static void paint_draw_tex_overlay( } /* set quad color. Colored overlay does not get blending */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (col) { immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); @@ -696,7 +696,7 @@ static void paint_draw_tex_overlay( /* draw textured quad */ immUniform1i("image", GL_TEXTURE0); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texCoord, 0.0f, 0.0f); immVertex2f(pos, quad.xmin, quad.ymin); immAttrib2f(texCoord, 1.0f, 0.0f); @@ -769,9 +769,9 @@ static void paint_draw_cursor_overlay( GPU_matrix_translate_2f(-center[0], -center[1]); } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); @@ -782,7 +782,7 @@ static void paint_draw_cursor_overlay( /* draw textured quad */ immUniform1i("image", 0); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texCoord, 0.0f, 0.0f); immVertex2f(pos, quad.xmin, quad.ymin); immAttrib2f(texCoord, 1.0f, 0.0f); @@ -844,7 +844,7 @@ BLI_INLINE void draw_tri_point( {co[0] + w, co[1] - w}, }; - immBegin(GWN_PRIM_LINE_LOOP, 3); + immBegin(GPU_PRIM_LINE_LOOP, 3); immVertex2fv(pos, tri[0]); immVertex2fv(pos, tri[1]); immVertex2fv(pos, tri[2]); @@ -853,7 +853,7 @@ BLI_INLINE void draw_tri_point( immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINE_LOOP, 3); + immBegin(GPU_PRIM_LINE_LOOP, 3); immVertex2fv(pos, tri[0]); immVertex2fv(pos, tri[1]); immVertex2fv(pos, tri[2]); @@ -888,7 +888,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); GPU_line_width(3.0f); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2fv(pos, bez->vec[0]); immVertex2fv(pos, bez->vec[1]); immVertex2fv(pos, bez->vec[2]); @@ -902,7 +902,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez else { immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); } - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(pos, bez->vec[0]); immVertex2fv(pos, bez->vec[1]); immEnd(); @@ -913,7 +913,7 @@ BLI_INLINE void draw_bezier_handle_lines(unsigned int pos, float sel_col[4], Bez else { immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); } - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(pos, bez->vec[1]); immVertex2fv(pos, bez->vec[2]); immEnd(); @@ -930,7 +930,7 @@ static void paint_draw_curve_cursor(Brush *brush) GPU_blend(true); /* draw the bezier handles and the curve segment between the current and next point */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -961,7 +961,7 @@ static void paint_draw_curve_cursor(Brush *brush) immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); GPU_line_width(3.0f); - immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); + immBegin(GPU_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) { immVertex2fv(pos, v[j]); } @@ -969,7 +969,7 @@ static void paint_draw_curve_cursor(Brush *brush) immUniformColor4f(0.9f, 0.9f, 1.0f, 0.5f); GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); + immBegin(GPU_PRIM_LINE_STRIP, PAINT_CURVE_NUM_SEGMENTS + 1); for (j = 0; j <= PAINT_CURVE_NUM_SEGMENTS; j++) { immVertex2fv(pos, v[j]); } @@ -1118,7 +1118,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) GPU_blend(true); /* TODO: also set blend mode? */ GPU_line_smooth(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* set brush color */ diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 6276a2838f5..897a74eb497 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -419,15 +419,15 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda GPU_line_smooth(true); GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_line_width(4.0); immUniformColor4ub(0, 0, 0, 255); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2i(pos, x, y); immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]); immEnd(); @@ -435,7 +435,7 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda GPU_line_width(2.0); immUniformColor4ub(255, 255, 255, 255); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2i(pos, x, y); immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]); immEnd(); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 0ef25eb63a1..fc008213ae0 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -155,11 +155,11 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata ARegion *ar = stroke->vc.ar; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(paint->paint_cursor_col); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, x, y); immVertex2f(pos, stroke->last_mouse_position[0] + ar->winrct.xmin, @@ -181,7 +181,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) GPU_line_smooth(true); - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -194,7 +194,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) immUniformArray4fv("colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); ARegion *ar = stroke->vc.ar; diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index a0ef753e200..8fafc545fa9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -215,7 +215,7 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN); } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fvAlpha(brush->add_col, alpha); diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 6ebb04fafc4..e679688f887 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -211,8 +211,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* first backdrop strips */ y = (float)(-ACHANNEL_HEIGHT(ac)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -326,7 +326,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if (saction->flag & SACTION_MOVING) { immUniformColor3f(0.0f, 0.0f, 0.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD); immVertex2f(pos, saction->timeslide, v2d->cur.ymax); immEnd(); @@ -404,7 +404,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* iterate over pointcaches on the active object, and draw each one's range */ @@ -492,7 +492,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene) immUniformColor4fv(col); if (len > 0) { - immBeginAtMost(GWN_PRIM_TRIS, len); + immBeginAtMost(GPU_PRIM_TRIS, len); /* draw a quad for each cached frame */ for (int i = sta; i <= end; i++) { diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 76450cba3cb..2aa0a3e2b9a 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -130,8 +130,8 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) uint keyframe_len = 0; - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* don't use totrect set, as the width stays the same @@ -215,14 +215,14 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) if (keyframe_len > 0) { /* draw keyframe markers */ format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); - uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); + uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, keyframe_len); + immBegin(GPU_PRIM_POINTS, keyframe_len); /* all same size with black outline */ immAttrib1f(size_id, 2.0f * STRIP_HEIGHT_HALF); @@ -315,8 +315,8 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) */ float y = (float) CHANNEL_FIRST; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 29bc0543426..ebdf5342172 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -80,7 +80,7 @@ static void draw_keyframe(int frame, int cfra, int sfra, float framelen, int wid int x = (frame - sfra) * framelen; if (width == 1) { - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2i(pos, x, 0); immVertex2i(pos, x, height * UI_DPI_FAC); immEnd(); @@ -167,7 +167,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points); ED_region_cache_draw_cached_segments(ar, totseg, points, sfra, efra); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* track */ @@ -248,7 +248,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc ED_region_cache_draw_curfra_label(sc->user.framenr, x, 8.0f * UI_DPI_FAC); - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* solver keyframes */ @@ -290,7 +290,7 @@ static void draw_movieclip_muted(ARegion *ar, int width, int height, float zoomx { int x, y; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* find window pixel coordinates of origin */ @@ -349,7 +349,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int /* draw boundary border for frame if stabilization is enabled */ if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) { - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* Exclusive OR allows to get orig value when second operand is 0, * and negative of orig value when second operand is 1. */ @@ -452,7 +452,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin i++; } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -463,7 +463,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((b - a - 1) >= 1) { GPU_point_size(5.0f); - immBegin(GWN_PRIM_POINTS, b - a - 1); + immBegin(GPU_PRIM_POINTS, b - a - 1); for (i = a; i < b; i++) { if (i != curindex) { @@ -478,7 +478,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((b - a) >= 2) { GPU_line_width(3.0f); - immBegin(GWN_PRIM_LINE_STRIP, b - a); + immBegin(GPU_PRIM_LINE_STRIP, b - a); for (i = a; i < b; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -494,7 +494,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((curindex - a) >= 1) { immUniformThemeColor(TH_PATH_BEFORE); - immBegin(GWN_PRIM_POINTS, curindex - a); + immBegin(GPU_PRIM_POINTS, curindex - a); for (i = a; i < curindex; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -506,7 +506,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((b - curindex - 1) >= 1) { immUniformThemeColor(TH_PATH_AFTER); - immBegin(GWN_PRIM_POINTS, b - curindex - 1); + immBegin(GPU_PRIM_POINTS, b - curindex - 1); for (i = curindex + 1; i < b; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -521,7 +521,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((curindex - a + 1) >= 2) { immUniformThemeColor(TH_PATH_BEFORE); - immBegin(GWN_PRIM_LINE_STRIP, curindex - a + 1); + immBegin(GPU_PRIM_LINE_STRIP, curindex - a + 1); for (i = a; i <= curindex; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -533,7 +533,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if ((b - curindex) >= 2) { immUniformThemeColor(TH_PATH_AFTER); - immBegin(GWN_PRIM_LINE_STRIP, b - curindex); + immBegin(GPU_PRIM_LINE_STRIP, b - curindex); for (i = curindex; i < b; i++) { immVertex2f(pos, path[i][0], path[i][1]); @@ -579,12 +579,12 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT { GPU_point_size(tiny ? 3.0f : 4.0f); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(position, pos[0], pos[1]); immEnd(); } else { - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(position, pos[0] + px[0] * 2, pos[1]); immVertex2f(position, pos[0] + px[0] * 8, pos[1]); @@ -607,7 +607,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT GPU_matrix_translate_2fv(marker_pos); if (sc->flag & SC_SHOW_MARKER_PATTERN) { - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2fv(position, marker->pattern_corners[0]); immVertex2fv(position, marker->pattern_corners[1]); immVertex2fv(position, marker->pattern_corners[2]); @@ -705,14 +705,14 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra immUniform1f("dash_factor", 2.0f); /* Solid "line" */ - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(shdr_pos, pos[0], pos[1]); immEnd(); } else { immUniform1f("dash_factor", 2.0f); /* Solid line */ - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(shdr_pos, pos[0] + px[0] * 3, pos[1]); immVertex2f(shdr_pos, pos[0] + px[0] * 7, pos[1]); @@ -735,7 +735,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_pos, pos); immVertex2fv(shdr_pos, marker_pos); immEnd(); @@ -783,7 +783,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra } if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) { - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2fv(shdr_pos, marker->pattern_corners[0]); immVertex2fv(shdr_pos, marker->pattern_corners[1]); immVertex2fv(shdr_pos, marker->pattern_corners[2]); @@ -805,7 +805,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra /* Restore default shader */ immUnbindProgram(); - const uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); BLI_assert(pos == shdr_pos); UNUSED_VARS_NDEBUG(pos); @@ -857,7 +857,7 @@ static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int tdy += px[1]; } - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2f(pos, x, y); immVertex2f(pos, x - tdx, y); immVertex2f(pos, x, y + tdy); @@ -935,7 +935,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo GPU_line_width(outline ? 3.0f : 1.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, 0.0f, 0.0f); immVertex2fv(pos, tilt_ctrl); immEnd(); @@ -1144,15 +1144,15 @@ static void draw_plane_marker_image(Scene *scene, GPU_matrix_push(); GPU_matrix_mul(gl_matrix); - Gwn_VertFormat *imm_format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *imm_format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, plane_track->image_opacity); immUniform1i("image", 0); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texCoord, 0.0f, 0.0f); immVertex2f(pos, 0.0f, 0.0f); @@ -1206,7 +1206,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane } if (draw_plane_quad || is_selected_track) { - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -1239,7 +1239,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane } /* Draw rectangle itself. */ - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2fv(shdr_pos, plane_marker->corners[0]); immVertex2fv(shdr_pos, plane_marker->corners[1]); immVertex2fv(shdr_pos, plane_marker->corners[2]); @@ -1252,7 +1252,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane immUniformColor3f(1.0f, 0.0f, 0.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point); immVertex2fv(shdr_pos, plane_marker->corners[0]); @@ -1262,7 +1262,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane immUniformColor3f(0.0f, 1.0f, 0.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point); immVertex2fv(shdr_pos, plane_marker->corners[0]); @@ -1414,7 +1414,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie } } - uint position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint position = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1519,7 +1519,7 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie immUniformColor3f(1.0f, 0.0f, 0.0f); } - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); if (undistort) { immVertex2f(position, pos[0] / width, pos[1] / (height * aspy)); @@ -1598,7 +1598,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, GPU_matrix_mul(sc->stabmat); GPU_matrix_scale_2f(width, height); - uint position = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint position = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1675,7 +1675,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, immUniformColor3f(1.0f, 0.0f, 0.0f); for (i = 0; i <= n; i++) { - immBegin(GWN_PRIM_LINE_STRIP, n + 1); + immBegin(GPU_PRIM_LINE_STRIP, n + 1); for (j = 0; j <= n; j++) { immVertex2fv(position, grid[i][j]); @@ -1685,7 +1685,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, } for (j = 0; j <= n; j++) { - immBegin(GWN_PRIM_LINE_STRIP, n + 1); + immBegin(GPU_PRIM_LINE_STRIP, n + 1); for (i = 0; i <= n; i++) { immVertex2fv(position, grid[i][j]); @@ -1743,7 +1743,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, sub_v2_v2v2(dpos, npos, pos); mul_v2_fl(dpos, 1.0f / steps); - immBegin(GWN_PRIM_LINE_STRIP, steps + 1); + immBegin(GPU_PRIM_LINE_STRIP, steps + 1); for (j = 0; j <= steps; j++) { BKE_tracking_distort_v2(tracking, pos, tpos); @@ -1756,7 +1756,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, } } else if (stroke->totpoints == 1) { - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(position, stroke->points[0].x + offsx, stroke->points[0].y + offsy); immEnd(); } diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 0bc9c74cd8c..cc8541d9fd7 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -91,11 +91,11 @@ static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, immUniformColor4fv(col); if (is_point) { - immBeginAtMost(GWN_PRIM_POINTS, 1); + immBeginAtMost(GPU_PRIM_POINTS, 1); } else { /* Graph can be composed of smaller segments, if any marker is disabled */ - immBeginAtMost(GWN_PRIM_LINE_STRIP, track->markersnr); + immBeginAtMost(GPU_PRIM_LINE_STRIP, track->markersnr); } } @@ -237,11 +237,11 @@ static void tracking_error_segment_start_cb(void *userdata, MovieTrackingTrack * immUniformColor4fv(col); if (is_point) { /* This probably never happens here, but just in case... */ - immBeginAtMost(GWN_PRIM_POINTS, 1); + immBeginAtMost(GPU_PRIM_POINTS, 1); } else { /* Graph can be composed of smaller segments, if any marker is disabled */ - immBeginAtMost(GWN_PRIM_LINE_STRIP, track->markersnr); + immBeginAtMost(GPU_PRIM_LINE_STRIP, track->markersnr); } } } @@ -300,7 +300,7 @@ static void draw_frame_curves(SpaceClip *sc, unsigned int pos) } if (!lines) { - immBeginAtMost(GWN_PRIM_LINE_STRIP, reconstruction->camnr); + immBeginAtMost(GPU_PRIM_LINE_STRIP, reconstruction->camnr); lines = 1; } @@ -328,7 +328,7 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) UI_view2d_grid_free(grid); if (clip) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_point_size(3.0f); diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index c94853d4233..19d321a53bf 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -273,7 +273,7 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); @@ -287,7 +287,7 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene) /* thin lines where the actual frames are */ GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, (float)SFRA, v2d->cur.ymin); immVertex2f(pos, (float)SFRA, v2d->cur.ymax); immVertex2f(pos, (float)EFRA, v2d->cur.ymin); diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 0ffbe451042..789194c21b9 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -158,8 +158,8 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha int offl = 0, offc = 0; int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN}; int pen[2]; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); xy[1] += tvc->lheight / 6; console_cursor_wrap_offset(sc->prompt, tvc->console_width, &offl, &offc, NULL); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 42ad34b659b..4a71afbcf4a 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -402,8 +402,8 @@ static void file_draw_preview( /* border */ if (use_dropshadow) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f); @@ -466,7 +466,7 @@ static void draw_background(FileLayout *layout, View2D *v2d) int i; int sy; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(TH_BACK, -7); @@ -503,12 +503,12 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) v1[1] = v2d->cur.ymax - layout->tile_border_y; v2[1] = v2d->cur.ymin; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_len); + immBegin(GPU_PRIM_LINES, vertex_len); sx = (int)v2d->tot.xmin; while (sx < v2d->cur.xmax) { diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 2b2d404168f..ad9af8cb948 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -86,7 +86,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur); int i; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_line_width(1.0f); @@ -103,7 +103,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) /* draw two black lines showing the standard reference levels */ - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(shdr_pos, v2d->cur.xmin, env->midval + env->min); immVertex2f(shdr_pos, v2d->cur.xmax, env->midval + env->min); @@ -122,7 +122,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) /* for now, point color is fixed, and is white */ immUniformColor3f(1.0f, 1.0f, 1.0f); - immBeginAtMost(GWN_PRIM_POINTS, env->totvert * 2); + immBeginAtMost(GPU_PRIM_POINTS, env->totvert * 2); for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* only draw if visible @@ -178,7 +178,7 @@ static void draw_fcurve_selected_keyframe_vertices(FCurve *fcu, View2D *v2d, boo set_fcurve_vertex_color(fcu, sel); - immBeginAtMost(GWN_PRIM_POINTS, fcu->totvert); + immBeginAtMost(GPU_PRIM_POINTS, fcu->totvert); BezTriple *bezt = fcu->bezt; for (int i = 0; i < fcu->totvert; i++, bezt++) { @@ -230,7 +230,7 @@ static void draw_fcurve_selected_handle_vertices(FCurve *fcu, View2D *v2d, bool immUniform4f("outlineColor", hcolor[0], hcolor[1], hcolor[2], 1.0f); immUniformColor3fvAlpha(hcolor, 0.01f); /* almost invisible - only keep for smoothness */ - immBeginAtMost(GWN_PRIM_POINTS, fcu->totvert * 2); + immBeginAtMost(GPU_PRIM_POINTS, fcu->totvert * 2); BezTriple *bezt = fcu->bezt; BezTriple *prevbezt = NULL; @@ -286,7 +286,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool * - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users) */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_blend(true); GPU_enable_program_point_size(); @@ -330,12 +330,12 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) { int sel, b; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBeginAtMost(GWN_PRIM_LINES, 4 * 2 * fcu->totvert); + immBeginAtMost(GPU_PRIM_LINES, 4 * 2 * fcu->totvert); /* slightly hacky, but we want to draw unselected points before selected ones * so that selected points are clearly visible @@ -427,7 +427,7 @@ static void draw_fcurve_sample_control(float x, float y, float xscale, float ysc GPU_matrix_scale_2f(1.0f / xscale * hsize, 1.0f / yscale * hsize); /* draw X shape */ - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, -0.7f, -0.7f); immVertex2f(pos, +0.7f, +0.7f); @@ -459,7 +459,7 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu) if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) GPU_line_smooth(true); GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor((fcu->flag & FCURVE_SELECTED) ? TH_TEXT_HI : TH_TEXT); @@ -551,7 +551,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d n = (etime - stime) / samplefreq + 0.5f; if (n > 0) { - immBegin(GWN_PRIM_LINE_STRIP, (n + 1)); + immBegin(GPU_PRIM_LINE_STRIP, (n + 1)); for (i = 0; i <= n; i++) { float ctime = stime + i * samplefreq; @@ -590,7 +590,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie GPU_matrix_scale_2f(1.0f, unit_scale); GPU_matrix_translate_2f(0.0f, offset); - immBegin(GWN_PRIM_LINE_STRIP, count); + immBegin(GPU_PRIM_LINE_STRIP, count); /* extrapolate to left? - left-side of view comes before first keyframe? */ if (prevfpt->vec[0] > v2d->cur.xmin) { @@ -687,7 +687,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 /* For now, this assumes the worst case scenario, where all the keyframes have * bezier interpolation, and are drawn at full res. * This is tricky to optimize, but maybe can be improved at some point... */ - immBeginAtMost(GWN_PRIM_LINE_STRIP, (b * 32 + 3)); + immBeginAtMost(GPU_PRIM_LINE_STRIP, (b * 32 + 3)); /* extrapolate to left? */ if (prevbezt->vec[1][0] > v2d->cur.xmin) { @@ -849,7 +849,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) //if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0) // return; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; @@ -874,7 +874,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) /* draw 1-1 line, stretching just past the screen limits * NOTE: we need to scale the y-values to be valid for the units */ - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); t = v2d->cur.xmin; immVertex2f(shdr_pos, t, (t + offset) * unitfac); @@ -900,7 +900,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUniform1f("dash_width", 10.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, (y >= v2d->cur.ymin) ? 4 : 2); + immBegin(GPU_PRIM_LINES, (y >= v2d->cur.ymin) ? 4 : 2); /* x-axis lookup */ co[0] = x; @@ -926,7 +926,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUnbindProgram(); - /* GWN_PRIM_POINTS do not survive dashed line geometry shader... */ + /* GPU_PRIM_POINTS do not survive dashed line geometry shader... */ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* x marks the spot .................................................... */ @@ -934,7 +934,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUniformColor3f(0.9f, 0.9f, 0.9f); GPU_point_size(7.0); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(shdr_pos, x, y); immEnd(); @@ -942,7 +942,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) immUniformColor3f(0.9f, 0.0f, 0.0f); GPU_point_size(3.0); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex2f(shdr_pos, x, y); immEnd(); } @@ -969,7 +969,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) } GPU_blend(true); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -1055,7 +1055,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid } GPU_blend(true); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 699dc29ff47..fa57df0393a 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -279,7 +279,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_grid_free(grid); if (((sipo->flag & SIPO_NODRAWCURSOR) == 0) || (sipo->mode == SIPO_MODE_DRIVERS)) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -292,7 +292,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) GPU_blend(true); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, v2d->cur.xmin, y); immVertex2f(pos, v2d->cur.xmax, y); immEnd(); @@ -310,7 +310,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) GPU_blend(true); GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, x, v2d->cur.ymin); immVertex2f(pos, x, v2d->cur.ymax); immEnd(); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index ff90e59540e..4cbe25462af 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -127,7 +127,7 @@ static void draw_render_info(const bContext *C, (int)(-rd->border.ymin * rd->ysch * rd->size * 0.01f)); } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_FACE_SELECT); @@ -174,7 +174,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* noisy, high contrast make impossible to read if lower alpha is used. */ @@ -330,7 +330,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLI_rcti_init(&color_rect, dx, dx + (1.5f * UI_UNIT_X), 0.15f * UI_UNIT_Y, 0.85f * UI_UNIT_Y); /* BLF uses immediate mode too, so we must reset our vertex format */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); if (channels == 4) { @@ -367,7 +367,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d immUnbindProgram(); /* draw outline */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ub(128, 128, 128); imm_draw_box_wire_2d(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); @@ -573,8 +573,8 @@ void draw_image_sample_line(SpaceImage *sima) if (sima->sample_line_hist.flag & HISTO_FLAG_SAMPLELINE) { Histogram *hist = &sima->sample_line_hist; - Gwn_VertFormat *format = immVertexFormat(); - uint shdr_dashed_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint shdr_dashed_pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -586,7 +586,7 @@ void draw_image_sample_line(SpaceImage *sima) immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); immUniform1f("dash_width", 2.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_dashed_pos, hist->co[0]); immVertex2fv(shdr_dashed_pos, hist->co[1]); immEnd(); @@ -779,7 +779,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) /* Draw current frame. */ x = (cfra - sfra) / (efra - sfra + 1) * ar->winx; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_CFRAME); immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC); diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 5c1b23e140c..c94aaf6e861 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -85,8 +85,8 @@ static void console_draw_sel(const char *str, const int sel[2], const int xy[2], GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(bg_sel); @@ -191,8 +191,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str cdc->sel[1] = str_len - sel_orig[0]; if (bg) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(bg); @@ -242,8 +242,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str else { /* simple, no wrap */ if (bg) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(bg); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 5b68c7b6bb7..7dd8c7f2eed 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -120,8 +120,8 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa nla_action_get_color(adt, act, color); color[3] *= 2.5f; - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -142,13 +142,13 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa if (key_len > 0) { format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, key_len); + immBegin(GPU_PRIM_POINTS, key_len); /* - disregard the selection status of keyframes so they draw a certain way * - size is 6.0f which is smaller than the editable keyframes, so that there is a distinction @@ -177,7 +177,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax if (ELEM(NULL, act, act->markers.first)) return; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (dashed) { immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -194,7 +194,7 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax } immUniformThemeColorShade(TH_STRIP_SELECT, shade); - immBeginAtMost(GWN_PRIM_LINES, BLI_listbase_count(&act->markers) * 2); + immBeginAtMost(GPU_PRIM_LINES, BLI_listbase_count(&act->markers) * 2); for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) { float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP); @@ -318,7 +318,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns /* plot the curve (over the strip's main region) */ if (fcu) { - immBegin(GWN_PRIM_LINE_STRIP, abs((int)(strip->end - strip->start) + 1)); + immBegin(GPU_PRIM_LINE_STRIP, abs((int)(strip->end - strip->start) + 1)); /* sample at 1 frame intervals, and draw * - min y-val is yminc, max is y-maxc, so clamp in those regions @@ -335,7 +335,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns else { /* use blend in/out values only if both aren't zero */ if ((IS_EQF(strip->blendin, 0.0f) && IS_EQF(strip->blendout, 0.0f)) == 0) { - immBeginAtMost(GWN_PRIM_LINE_STRIP, 4); + immBeginAtMost(GPU_PRIM_LINE_STRIP, 4); /* start of strip - if no blendin, start straight at 1, otherwise from 0 to 1 over blendin frames */ if (IS_EQF(strip->blendin, 0.0f) == 0) { @@ -366,7 +366,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns static uint nla_draw_use_dashed_outlines(float color[4], bool muted) { /* Note that we use dashed shader here, and make it draw solid lines if not muted... */ - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; @@ -403,7 +403,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri /* get color of strip */ nla_strip_get_color_inside(adt, strip, color); - shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw extrapolation info first (as backdrop) @@ -456,7 +456,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri UI_draw_roundbox_shade_x(true, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1, color); /* restore current vertex format & program (roundbox trashes it) */ - shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); } else { @@ -518,7 +518,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri /* only draw lines for whole-numbered repeats, starting from the first full-repeat * up to the last full repeat (but not if it lies on the end of the strip) */ - immBeginAtMost(GWN_PRIM_LINES, 2 * floorf(strip->repeat)); + immBeginAtMost(GPU_PRIM_LINES, 2 * floorf(strip->repeat)); for (int i = 1; i < strip->repeat; i++) { float repeatPos = strip->start + (repeatLen * i); @@ -534,7 +534,7 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri else if ((strip->type == NLASTRIP_TYPE_META) && (strip->strips.first != strip->strips.last)) { const float y = (ymaxc - yminc) * 0.5f + yminc; - immBeginAtMost(GWN_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips)); /* up to 2 lines per strip */ + immBeginAtMost(GPU_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips)); /* up to 2 lines per strip */ /* only draw first-level of child-strips, but don't draw any lines on the endpoints */ for (NlaStrip *cs = strip->strips.first; cs; cs = cs->next) { @@ -706,7 +706,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) { AnimData *adt = ale->adt; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, @@ -729,7 +729,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* white base-lines */ GPU_line_width(2.0f); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.3f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP); immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP); @@ -739,7 +739,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* black top-lines */ GPU_line_width(1.0f); immUniformColor3f(0.0f, 0.0f, 0.0f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, v2d->cur.xmin, yminc + NLACHANNEL_SKIP); immVertex2f(pos, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); immVertex2f(pos, v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index dfb85d3c8a4..10532f3ac7d 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2184,14 +2184,14 @@ static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNo const float cy = y + snode->zoom * backdropHeight * node->custom4; const float cross_size = 12 * U.pixelsize; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(1.0f, 1.0f, 1.0f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, cx - cross_size, cy - cross_size); immVertex2f(pos, cx + cross_size, cy + cross_size); immVertex2f(pos, cx + cross_size, cy - cross_size); @@ -2229,14 +2229,14 @@ static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bN y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(1.0f, 1.0f, 1.0f); - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y2); immVertex2f(pos, x3, y3); @@ -2273,14 +2273,14 @@ static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(1.0f, 1.0f, 1.0f); - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y2); immVertex2f(pos, x3, y3); @@ -3267,7 +3267,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b y + snode->zoom * viewer_border->ymin * ibuf->y, y + snode->zoom * viewer_border->ymax * ibuf->y); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_ACTIVE); @@ -3392,50 +3392,50 @@ static float arrow_verts[3][2] = {{-1.0f, 1.0f}, {0.0f, 0.0f}, {-1.0f, -1.0f}}; static float arrow_expand_axis[3][2] = {{0.7071f, 0.7071f}, {M_SQRT2, 0.0f}, {0.7071f, -0.7071f}}; struct { - Gwn_Batch *batch; /* for batching line together */ - Gwn_Batch *batch_single; /* for single line */ - Gwn_VertBuf *inst_vbo; + GPUBatch *batch; /* for batching line together */ + GPUBatch *batch_single; /* for single line */ + GPUVertBuf *inst_vbo; unsigned int p0_id, p1_id, p2_id, p3_id; unsigned int colid_id; - Gwn_VertBufRaw p0_step, p1_step, p2_step, p3_step; - Gwn_VertBufRaw colid_step; + GPUVertBufRaw p0_step, p1_step, p2_step, p3_step; + GPUVertBufRaw colid_step; unsigned int count; bool enabled; } g_batch_link = {0}; static void nodelink_batch_reset(void) { - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p0_id, &g_batch_link.p0_step); - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p1_id, &g_batch_link.p1_step); - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p2_id, &g_batch_link.p2_step); - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p3_id, &g_batch_link.p3_step); - GWN_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p0_id, &g_batch_link.p0_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p1_id, &g_batch_link.p1_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p2_id, &g_batch_link.p2_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.p3_id, &g_batch_link.p3_step); + GPU_vertbuf_attr_get_raw_data(g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step); g_batch_link.count = 0; } static void set_nodelink_vertex( - Gwn_VertBuf *vbo, + GPUVertBuf *vbo, unsigned int uv_id, unsigned int pos_id, unsigned int exp_id, unsigned int v, const unsigned char uv[2], const float pos[2], const float exp[2]) { - GWN_vertbuf_attr_set(vbo, uv_id, v, uv); - GWN_vertbuf_attr_set(vbo, pos_id, v, pos); - GWN_vertbuf_attr_set(vbo, exp_id, v, exp); + GPU_vertbuf_attr_set(vbo, uv_id, v, uv); + GPU_vertbuf_attr_set(vbo, pos_id, v, pos); + GPU_vertbuf_attr_set(vbo, exp_id, v, exp); } static void nodelink_batch_init(void) { - Gwn_VertFormat format = {0}; - uint uv_id = GWN_vertformat_attr_add(&format, "uv", GWN_COMP_U8, 2, GWN_FETCH_INT_TO_FLOAT_UNIT); - uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint expand_id = GWN_vertformat_attr_add(&format, "expand", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC); + GPUVertFormat format = {0}; + uint uv_id = GPU_vertformat_attr_add(&format, "uv", GPU_COMP_U8, 2, GPU_FETCH_INT_TO_FLOAT_UNIT); + uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint expand_id = GPU_vertformat_attr_add(&format, "expand", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STATIC); int vcount = LINK_RESOL * 2; /* curve */ vcount += 2; /* restart strip */ vcount += 3 * 2; /* arrow */ vcount *= 2; /* shadow */ vcount += 2; /* restart strip */ - GWN_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_data_alloc(vbo, vcount); int v = 0; for (int k = 0; k < 2; ++k) { @@ -3479,23 +3479,23 @@ static void nodelink_batch_init(void) set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp); } - g_batch_link.batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + g_batch_link.batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); gpu_batch_presets_register(g_batch_link.batch); - g_batch_link.batch_single = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, 0); + g_batch_link.batch_single = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, 0); gpu_batch_presets_register(g_batch_link.batch_single); /* Instances data */ - Gwn_VertFormat format_inst = {0}; - g_batch_link.p0_id = GWN_vertformat_attr_add(&format_inst, "P0", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - g_batch_link.p1_id = GWN_vertformat_attr_add(&format_inst, "P1", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - g_batch_link.p2_id = GWN_vertformat_attr_add(&format_inst, "P2", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - g_batch_link.p3_id = GWN_vertformat_attr_add(&format_inst, "P3", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - g_batch_link.colid_id = GWN_vertformat_attr_add(&format_inst, "colid_doarrow", GWN_COMP_U8, 4, GWN_FETCH_INT); - g_batch_link.inst_vbo = GWN_vertbuf_create_with_format_ex(&format_inst, GWN_USAGE_STREAM); - GWN_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); /* Alloc max count but only draw the range we need. */ + GPUVertFormat format_inst = {0}; + g_batch_link.p0_id = GPU_vertformat_attr_add(&format_inst, "P0", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + g_batch_link.p1_id = GPU_vertformat_attr_add(&format_inst, "P1", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + g_batch_link.p2_id = GPU_vertformat_attr_add(&format_inst, "P2", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + g_batch_link.p3_id = GPU_vertformat_attr_add(&format_inst, "P3", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + g_batch_link.colid_id = GPU_vertformat_attr_add(&format_inst, "colid_doarrow", GPU_COMP_U8, 4, GPU_FETCH_INT); + g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM); + GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE); /* Alloc max count but only draw the range we need. */ - GWN_batch_instbuf_set(g_batch_link.batch, g_batch_link.inst_vbo, true); + GPU_batch_instbuf_set(g_batch_link.batch, g_batch_link.inst_vbo, true); nodelink_batch_reset(); } @@ -3526,14 +3526,14 @@ static void nodelink_batch_draw(SpaceNode *snode) UI_GetThemeColor4fv(TH_EDGE_SELECT, colors[nodelink_get_color_id(TH_EDGE_SELECT)]); UI_GetThemeColor4fv(TH_REDALERT, colors[nodelink_get_color_id(TH_REDALERT)]); - GWN_vertbuf_vertex_count_set(g_batch_link.inst_vbo, g_batch_link.count); - GWN_vertbuf_use(g_batch_link.inst_vbo); /* force update. */ + GPU_vertbuf_vertex_count_set(g_batch_link.inst_vbo, g_batch_link.count); + GPU_vertbuf_use(g_batch_link.inst_vbo); /* force update. */ - GWN_batch_program_set_builtin(g_batch_link.batch, GPU_SHADER_2D_NODELINK_INST); - GWN_batch_uniform_4fv_array(g_batch_link.batch, "colors", 6, (float *)colors); - GWN_batch_uniform_1f(g_batch_link.batch, "expandSize", snode->aspect * LINK_WIDTH); - GWN_batch_uniform_1f(g_batch_link.batch, "arrowSize", ARROW_SIZE); - GWN_batch_draw(g_batch_link.batch); + GPU_batch_program_set_builtin(g_batch_link.batch, GPU_SHADER_2D_NODELINK_INST); + GPU_batch_uniform_4fv_array(g_batch_link.batch, "colors", 6, (float *)colors); + GPU_batch_uniform_1f(g_batch_link.batch, "expandSize", snode->aspect * LINK_WIDTH); + GPU_batch_uniform_1f(g_batch_link.batch, "arrowSize", ARROW_SIZE); + GPU_batch_draw(g_batch_link.batch); nodelink_batch_reset(); @@ -3562,11 +3562,11 @@ static void nodelink_batch_add_link( BLI_assert(ELEM(th_col3, TH_WIRE, -1)); g_batch_link.count++; - copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p0_step), p0); - copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p1_step), p1); - copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p2_step), p2); - copy_v2_v2(GWN_vertbuf_raw_step(&g_batch_link.p3_step), p3); - char *colid = GWN_vertbuf_raw_step(&g_batch_link.colid_step); + copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p0_step), p0); + copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p1_step), p1); + copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p2_step), p2); + copy_v2_v2(GPU_vertbuf_raw_step(&g_batch_link.p3_step), p3); + char *colid = GPU_vertbuf_raw_step(&g_batch_link.colid_step); colid[0] = nodelink_get_color_id(th_col1); colid[1] = nodelink_get_color_id(th_col2); colid[2] = nodelink_get_color_id(th_col3); @@ -3604,14 +3604,14 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, UI_GetThemeColor4fv(th_col1, colors[1]); UI_GetThemeColor4fv(th_col2, colors[2]); - Gwn_Batch *batch = g_batch_link.batch_single; - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK); - GWN_batch_uniform_2fv_array(batch, "bezierPts", 4, (float *)vec); - GWN_batch_uniform_4fv_array(batch, "colors", 3, (float *)colors); - GWN_batch_uniform_1f(batch, "expandSize", snode->aspect * LINK_WIDTH); - GWN_batch_uniform_1f(batch, "arrowSize", ARROW_SIZE); - GWN_batch_uniform_1i(batch, "doArrow", drawarrow); - GWN_batch_draw(batch); + GPUBatch *batch = g_batch_link.batch_single; + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK); + GPU_batch_uniform_2fv_array(batch, "bezierPts", 4, (float *)vec); + GPU_batch_uniform_4fv_array(batch, "colors", 3, (float *)colors); + GPU_batch_uniform_1f(batch, "expandSize", snode->aspect * LINK_WIDTH); + GPU_batch_uniform_1f(batch, "arrowSize", ARROW_SIZE); + GPU_batch_uniform_1i(batch, "doArrow", drawarrow); + GPU_batch_draw(batch); } } } @@ -3660,7 +3660,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border, unsigned pos) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); if (border & (NODE_LEFT | NODE_RIGHT)) { immVertex2f(pos, cent[0], v2d->cur.ymin); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 6976edce563..4b3a3abc642 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -648,8 +648,8 @@ static void node_draw_preview_background(float tile, rctf *rect) { float x, y; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -721,7 +721,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) GPU_blend(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, +100); imm_draw_box_wire_2d(pos, draw_rect.xmin, draw_rect.ymin, draw_rect.xmax, draw_rect.ymax); @@ -771,9 +771,9 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * float scale; UI_view2d_scale_get(v2d, &scale, NULL); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); GPU_blend(true); GPU_enable_program_point_size(); @@ -788,7 +788,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * immUniform1f("outlineWidth", 1.0f); immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, 0.6f); - immBeginAtMost(GWN_PRIM_POINTS, total_input_len + total_output_len); + immBeginAtMost(GPU_PRIM_POINTS, total_input_len + total_output_len); } /* socket inputs */ @@ -832,7 +832,7 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * immUniform4f("outlineColor", c[0], c[1], c[2], 1.0f); immUniform1f("outlineWidth", 1.5f); - immBegin(GWN_PRIM_POINTS, selected_input_len + selected_output_len); + immBegin(GPU_PRIM_POINTS, selected_input_len + selected_output_len); if (selected_input_len) { /* socket inputs */ @@ -1102,13 +1102,13 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b } /* scale widget thing */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(color_id, -10); dx = 10.0f; - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rct->xmax - dx, centy - 4.0f); immVertex2f(pos, rct->xmax - dx, centy + 4.0f); @@ -1119,7 +1119,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b immUniformThemeColorShade(color_id, 30); dx -= snode->aspect; - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rct->xmax - dx, centy - 4.0f); immVertex2f(pos, rct->xmax - dx, centy + 4.0f); diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 8a8f4715ea3..783a03f3993 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -742,11 +742,11 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex) GPU_line_width(1.0f); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, -200); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, sizex, v2d->cur.ymax); immVertex2f(pos, sizex, miny); @@ -1739,8 +1739,8 @@ static void outliner_draw_tree_element( /* divider */ { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); unsigned char col[4]; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1797,7 +1797,7 @@ static void outliner_draw_tree_element_floating( const TreeElement *te_insert = te_floating->drag_data->insert_handle; const int line_width = 2; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); int coord_y = te_insert->ys; int coord_x = te_insert->xs; float col[4]; @@ -1818,7 +1818,7 @@ static void outliner_draw_tree_element_floating( immUniformColor4fv(col); GPU_line_width(line_width); - immBegin(GWN_PRIM_LINE_STRIP, 2); + immBegin(GPU_PRIM_LINE_STRIP, 2); immVertex2f(pos, coord_x, coord_y); immVertex2f(pos, ar->v2d.cur.xmax, coord_y); immEnd(); @@ -1827,7 +1827,7 @@ static void outliner_draw_tree_element_floating( BLI_assert(te_floating->drag_data->insert_type == TE_INSERT_INTO); immUniformColor3fvAlpha(col, col[3] * 0.5f); - immBegin(GWN_PRIM_TRI_STRIP, 4); + immBegin(GPU_PRIM_TRI_STRIP, 4); immVertex2f(pos, coord_x, coord_y + UI_UNIT_Y); immVertex2f(pos, coord_x, coord_y); immVertex2f(pos, ar->v2d.cur.xmax, coord_y + UI_UNIT_Y); @@ -1901,8 +1901,8 @@ static void outliner_draw_hierarchy_lines_recursive( static void outliner_draw_hierarchy_lines(SpaceOops *soops, ListBase *lb, int startx, int *starty) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); unsigned char col[4]; immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1924,8 +1924,8 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * /* selection status */ if (TSELEM_OPEN(tselem, soops)) { if (tselem->type == TSE_RNA_STRUCT) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immThemeColorShadeAlpha(TH_BACK, -15, -200); immRecti(pos, 0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); @@ -1937,12 +1937,12 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * if (TSELEM_OPEN(tselem, soops)) { outliner_draw_struct_marks(ar, soops, &te->subtree, starty); if (tselem->type == TSE_RNA_STRUCT) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immThemeColorShadeAlpha(TH_BACK, -15, -200); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, 0, (float)*starty + UI_UNIT_Y); immVertex2f(pos, ar->v2d.cur.xmax, (float)*starty + UI_UNIT_Y); immEnd(); @@ -2007,8 +2007,8 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx, col_searchmatch[3] = 0.5f; GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); outliner_draw_highlights_recursive( pos, ar, soops, &soops->tree, col_selection, col_highlight, col_searchmatch, @@ -2082,8 +2082,8 @@ static void outliner_back(ARegion *ar) ystart = (int)ar->v2d.tot.ymax; ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShade(TH_BACK, 6); @@ -2093,7 +2093,7 @@ static void outliner_back(ARegion *ar) int tot = (int)floor(ystart - ar->v2d.cur.ymin + 2 * UI_UNIT_Y) / (2 * UI_UNIT_Y); if (tot > 0) { - immBegin(GWN_PRIM_TRIS, 6 * tot); + immBegin(GPU_PRIM_TRIS, 6 * tot); while (tot--) { y1 -= 2 * UI_UNIT_Y; y2 = y1 + UI_UNIT_Y; @@ -2114,10 +2114,10 @@ static void outliner_draw_restrictcols(ARegion *ar) { GPU_line_width(1.0f); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, -200); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymax); immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymin); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 204559ebf4f..47059d65945 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -267,7 +267,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s GPU_blend(true); - immBegin(GWN_PRIM_TRI_STRIP, length * 2); + immBegin(GPU_PRIM_TRI_STRIP, length * 2); for (i = 0; i < length; i++) { float sampleoffset = startsample + ((x1_offset - x1) / stepsize + i) * samplestep; @@ -343,7 +343,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, col[3] = 196; /* alpha, used for all meta children */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -457,7 +457,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla immUniformColor4ub(0, 0, 0, 50); } - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2fv(pos, v1); immVertex2fv(pos, v2); immVertex2fv(pos, v3); @@ -719,7 +719,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp; y2 = seq->machine + SEQ_STRIP_OFSTOP; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -781,7 +781,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg if (seq->flag & SEQ_LOCK) { GPU_blend(true); - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES); immUniform4f("color1", 1.0f, 1.0f, 1.0f, 0.125f); @@ -799,7 +799,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg if (!BKE_sequence_is_valid_check(seq)) { GPU_blend(true); - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_DIAG_STRIPES); immUniform4f("color1", 1.0f, 0.0f, 0.0f, 1.0f); @@ -834,7 +834,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg drawmeta_contents(scene, seq, x1, y1, x2, y2); } - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* TODO: add back stippled line for muted strips? */ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -1040,7 +1040,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons GPU_line_width(1.0f); /* border */ - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -1230,9 +1230,9 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq /* Format needs to be created prior to any immBindProgram call. * Do it here because OCIO binds it's own shader. */ - Gwn_VertFormat *imm_format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(imm_format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint texCoord = GWN_vertformat_attr_add(imm_format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *imm_format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(imm_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(imm_format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (scope) { IMB_freeImBuf(ibuf); @@ -1331,7 +1331,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq immUniform1i("image", 0); } - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); if (draw_overlay) { if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) { @@ -1514,7 +1514,7 @@ static void draw_seq_backdrop(View2D *v2d) { int i; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* darker gray overlay over the view backdrop */ @@ -1541,7 +1541,7 @@ static void draw_seq_backdrop(View2D *v2d) i = max_ii(1, ((int)v2d->cur.ymin) - 1); int line_len = (int)v2d->cur.ymax - i + 1; immUniformThemeColor(TH_GRID); - immBegin(GWN_PRIM_LINES, line_len * 2); + immBegin(GPU_PRIM_LINES, line_len * 2); while (line_len--) { immVertex2f(pos, v2d->cur.xmax, i); immVertex2f(pos, v2d->cur.xmin, i); @@ -1593,7 +1593,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) const Sequence *seq = special_seq_update; GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ub(255, 255, 255, 48); @@ -1613,7 +1613,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw darkened area outside of active timeline @@ -1631,7 +1631,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) immUniformThemeColorShade(TH_BACK, -60); /* thin lines where the actual frames are */ - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, frame_sta, v2d->cur.ymin); immVertex2f(pos, frame_sta, v2d->cur.ymax); @@ -1649,7 +1649,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) immUniformThemeColorShade(TH_BACK, -40); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, ms->disp_range[0], v2d->cur.ymin); immVertex2f(pos, ms->disp_range[0], v2d->cur.ymax); @@ -1735,12 +1735,12 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) { int cfra_over = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(0.2f, 0.2f, 0.2f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, cfra_over, v2d->cur.ymin); immVertex2f(pos, cfra_over, v2d->cur.ymax); immEnd(); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 748a5c05ef1..aa499d52589 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -913,7 +913,7 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back) float rad; /* background so highlights don't go behind the scrollbar */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_BACK); immRecti(pos, back->xmin, back->ymin, back->xmax, back->ymax); @@ -967,24 +967,24 @@ static void draw_documentation(const SpaceText *st, ARegion *ar) boxh = (DOC_HEIGHT + 1) * (st->lheight_dpi + TXT_LINE_SPACING); /* Draw panel */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_BACK); immRecti(pos, x, y, x + boxw, y - boxh); immUniformThemeColor(TH_SHADE1); - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2i(pos, x, y); immVertex2i(pos, x + boxw, y); immVertex2i(pos, x + boxw, y - boxh); immVertex2i(pos, x, y - boxh); immEnd(); - immBegin(GWN_PRIM_LINE_LOOP, 3); + immBegin(GPU_PRIM_LINE_LOOP, 3); immVertex2i(pos, x + boxw - 10, y - 7); immVertex2i(pos, x + boxw - 4, y - 7); immVertex2i(pos, x + boxw - 7, y - 2); immEnd(); - immBegin(GWN_PRIM_LINE_LOOP, 3); + immBegin(GPU_PRIM_LINE_LOOP, 3); immVertex2i(pos, x + boxw - 10, y - boxh + 7); immVertex2i(pos, x + boxw - 4, y - boxh + 7); immVertex2i(pos, x + boxw - 7, y - boxh + 2); @@ -1066,7 +1066,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc /* not needed but stands out nicer */ UI_draw_box_shadow(220, x, y - boxh, x + boxw, y); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_SHADE1); @@ -1089,7 +1089,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc w = st->cwidth * text_get_char_pos(st, str, len); if (item == sel) { - uint posi = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint posi = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_SHADE2); @@ -1130,7 +1130,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar) return; } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* Draw the selection */ @@ -1443,7 +1443,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) if (st->showlinenrs) { x = TXT_OFFSET + TEXTXLOC; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_GRID); immRecti(pos, (TXT_OFFSET - 12), 0, (TXT_OFFSET - 5) + TEXTXLOC, ar->winy - 2); @@ -1502,7 +1502,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) margin_column_x = x + st->cwidth * (st->margin_column - st->left); if (margin_column_x >= x) { - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -1515,7 +1515,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) immUniform1f("dash_width", 2.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2i(shdr_pos, margin_column_x, 0); immVertex2i(shdr_pos, margin_column_x, ar->winy - 2); immEnd(); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index a6714927249..c0abbe636c3 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -244,7 +244,7 @@ void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], un circball_array_fill(verts, cent, rad, tmat); - immBegin(GWN_PRIM_LINE_LOOP, CIRCLE_RESOL); + immBegin(GPU_PRIM_LINE_LOOP, CIRCLE_RESOL); for (int i = 0; i < CIRCLE_RESOL; ++i) { immVertex3fv(pos, verts[i]); } @@ -285,15 +285,15 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset) if (imm_len == 0) return; - Gwn_VertFormat *format = immVertexFormat(); - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = immVertexFormat(); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE)); - immBeginAtMost(GWN_PRIM_POINTS, imm_len); + immBeginAtMost(GPU_PRIM_POINTS, imm_len); dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data, DM_FOREACH_NOP); immEnd(); @@ -303,9 +303,9 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset) static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *UNUSED(dm), int offset) { Mesh *me = ob->data; - Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPUBatch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } #endif @@ -328,15 +328,15 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset) drawBMOffset_userData data; data.bm = em->bm; data.offset = offset; - Gwn_VertFormat *format = immVertexFormat(); - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = immVertexFormat(); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE)); - immBeginAtMost(GWN_PRIM_POINTS, em->bm->totvert); + immBeginAtMost(GPU_PRIM_POINTS, em->bm->totvert); dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, &data, DM_FOREACH_NOP); immEnd(); @@ -348,9 +348,9 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset) GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE)); Mesh *me = em->ob->data; - Gwn_Batch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPUBatch *batch = DRW_mesh_batch_cache_get_verts_with_select_id(me, offset); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } #endif @@ -375,20 +375,20 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) data.bm = em->bm; data.offset = offset; - Gwn_VertFormat *format = immVertexFormat(); + GPUVertFormat *format = immVertexFormat(); const int imm_len = dm->getNumEdges(dm) * 2; if (imm_len == 0) return; - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); GPU_line_width(1.0f); - immBeginAtMost(GWN_PRIM_LINES, imm_len); + immBeginAtMost(GPU_PRIM_LINES, imm_len); dm->foreachMappedEdge(dm, bbs_mesh_wire__mapFunc, &data); immEnd(); @@ -400,9 +400,9 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *UNUSED(dm), int offset) GPU_line_width(1.0f); Mesh *me = em->ob->data; - Gwn_Batch *batch = DRW_mesh_batch_cache_get_edges_with_select_id(me, offset); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPUBatch *batch = DRW_mesh_batch_cache_get_edges_with_select_id(me, offset); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } #endif @@ -420,13 +420,13 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select if (imm_len == 0) return; - Gwn_VertFormat *format = immVertexFormat(); - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = immVertexFormat(); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); - immBeginAtMost(GWN_PRIM_TRIS, imm_len); + immBeginAtMost(GPU_PRIM_TRIS, imm_len); if (use_select == false) { int selcol; @@ -463,20 +463,20 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *UNUSED(dm), const bool use_select) { Mesh *me = em->ob->data; - Gwn_Batch *batch; + GPUBatch *batch; if (use_select) { batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } else { int selcol; GPU_select_index_get(0, &selcol); batch = DRW_mesh_batch_cache_get_triangles_with_select_mask(me, true); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32); - GWN_batch_uniform_1ui(batch, "color", selcol); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32); + GPU_batch_uniform_1ui(batch, "color", selcol); + GPU_batch_draw(batch); } } #endif @@ -499,15 +499,15 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm) { drawBMOffset_userData data; /* don't use offset */ data.bm = em->bm; - Gwn_VertFormat *format = immVertexFormat(); - data.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - data.col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = immVertexFormat(); + data.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + data.col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U32, 1, GPU_FETCH_INT); immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32); GPU_point_size(UI_GetThemeValuef(TH_FACEDOT_SIZE)); - immBeginAtMost(GWN_PRIM_POINTS, em->bm->totface); + immBeginAtMost(GPU_PRIM_POINTS, em->bm->totface); dm->foreachMappedFaceCenter(dm, bbs_mesh_solid__drawCenter, &data, DM_FOREACH_NOP); immEnd(); @@ -517,9 +517,9 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm) static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *UNUSED(dm)) { Mesh *me = em->ob->data; - Gwn_Batch *batch = DRW_mesh_batch_cache_get_facedots_with_select_id(me, 1); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPUBatch *batch = DRW_mesh_batch_cache_get_facedots_with_select_id(me, 1); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } #endif @@ -583,12 +583,12 @@ static void bbs_mesh_solid_verts(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(sce { int selcol; - Gwn_Batch *batch; + GPUBatch *batch; GPU_select_index_get(0, &selcol); batch = DRW_mesh_batch_cache_get_triangles_with_select_mask(me, true); - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32); - GWN_batch_uniform_1ui(batch, "color", selcol); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR_U32); + GPU_batch_uniform_1ui(batch, "color", selcol); + GPU_batch_draw(batch); } G.f |= (G_f_orig & G_BACKBUFSEL); @@ -601,15 +601,15 @@ static void bbs_mesh_solid_verts(Depsgraph *UNUSED(depsgraph), Scene *UNUSED(sce static void bbs_mesh_solid_faces(Scene *UNUSED(scene), Object *ob) { Mesh *me = ob->data; - Gwn_Batch *batch; + GPUBatch *batch; if ((me->editflag & ME_EDIT_PAINT_FACE_SEL)) { batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, true, 1); } else { batch = DRW_mesh_batch_cache_get_triangles_with_select_id(me, false, 1); } - GWN_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR_U32); + GPU_batch_draw(batch); } void draw_object_backbufsel( @@ -747,8 +747,8 @@ void ED_draw_object_facemap( Mesh *me = ob->data; const int *facemap_data = CustomData_get_layer(&me->pdata, CD_FACEMAP); if (facemap_data) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(col); @@ -788,7 +788,7 @@ void ED_draw_object_facemap( /* use gawain immediate mode fore now */ const int looptris_len = poly_to_tri_count(mpoly_len, mloop_len); - immBeginAtMost(GWN_PRIM_TRIS, looptris_len * 3); + immBeginAtMost(GPU_PRIM_TRIS, looptris_len * 3); MPoly *mp; int i; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index e03fe149af6..552d84ebb39 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -365,7 +365,7 @@ static void drawviewborder_grid3(uint shdr_pos, float x1, float x2, float y1, fl x4 = x1 + (1.0f - fac) * (x2 - x1); y4 = y1 + (1.0f - fac) * (y2 - y1); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(shdr_pos, x1, y3); immVertex2f(shdr_pos, x2, y3); @@ -390,7 +390,7 @@ static void drawviewborder_triangle( float w = x2 - x1; float h = y2 - y1; - immBegin(GWN_PRIM_LINES, 6); + immBegin(GPU_PRIM_LINES, 6); if (w > h) { if (golden) { @@ -467,7 +467,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View x2i = (int)(x2 + (1.0f - 0.0001f)); y2i = (int)(y2 + (1.0f - 0.0001f)); - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* First, solid lines. */ { @@ -559,7 +559,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View x3 = x1 + 0.5f * (x2 - x1); y3 = y1 + 0.5f * (y2 - y1); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(shdr_pos, x1, y3); immVertex2f(shdr_pos, x2, y3); @@ -571,7 +571,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View } if (ca->dtx & CAM_DTX_CENTER_DIAG) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(shdr_pos, x1, y1); immVertex2f(shdr_pos, x2, y2); @@ -674,7 +674,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View static void drawrenderborder(ARegion *ar, View3D *v3d) { /* use the same program for everything */ - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); GPU_line_width(1.0f); @@ -814,12 +814,12 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, 6); + immBegin(GPU_PRIM_LINES, 6); for (int axis_i = 0; axis_i < 3; axis_i++) { int i = axis_order[axis_i]; @@ -859,9 +859,9 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); glDepthMask(GL_FALSE); /* don't overwrite zbuf */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR); @@ -872,7 +872,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) mul_v3_v3fl(scaled_axis, rv3d->rot_axis, scale); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); color[3] = 0; /* more transparent toward the ends */ immAttrib4ubv(col, color); add_v3_v3v3(end, o, scaled_axis); @@ -911,7 +911,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) axis_angle_to_quat(q, vis_axis, vis_angle); } - immBegin(GWN_PRIM_LINE_LOOP, ROT_AXIS_DETAIL); + immBegin(GPU_PRIM_LINE_LOOP, ROT_AXIS_DETAIL); color[3] = 63; /* somewhat faint */ immAttrib4ubv(col, color); float angle = 0.0f; @@ -940,7 +940,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) /* -- draw rotation center -- */ immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR); GPU_point_size(5.0f); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immAttrib4ubv(col, color); immVertex3fv(pos, o); immEnd(); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index d1b9f95ca2a..3cf036e1ce1 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -263,14 +263,14 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), x2 = xoff + 0.55f * fly->width; y2 = yoff + 0.55f * fly->height; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_VIEW_OVERLAY); - immBegin(GWN_PRIM_LINES, 16); + immBegin(GPU_PRIM_LINES, 16); /* bottom left */ immVertex2f(pos, x1, y1); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index 6040e21aacb..238a956cf26 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -84,7 +84,7 @@ static void draw_xyz_wire( switch (axis) { case 0: /* x axis */ - line_type = GWN_PRIM_LINES; + line_type = GPU_PRIM_LINES; /* bottom left to top right */ negate_v3_v3(v1, dx); @@ -105,7 +105,7 @@ static void draw_xyz_wire( break; case 1: /* y axis */ - line_type = GWN_PRIM_LINES; + line_type = GPU_PRIM_LINES; /* bottom left to top right */ mul_v3_fl(dx, 0.75f); @@ -127,7 +127,7 @@ static void draw_xyz_wire( break; case 2: /* z axis */ - line_type = GWN_PRIM_LINE_STRIP; + line_type = GPU_PRIM_LINE_STRIP; /* start at top left */ negate_v3_v3(v1, dx); @@ -172,8 +172,8 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U { GPU_line_width(gz->line_width); - Gwn_VertFormat *format = immVertexFormat(); - const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); struct { @@ -257,7 +257,7 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U float v_start[3]; GPU_line_width(2.0f); immUniformColor4fv(color_current); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); if (axis_align == -1) { zero_v3(v_start); } @@ -280,10 +280,10 @@ static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool U GPU_matrix_translate_3fv(v_final); GPU_matrix_scale_1f(is_pos ? 0.22f : 0.18f); - Gwn_Batch *sphere = GPU_batch_preset_sphere(0); - GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); - GWN_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade); - GWN_batch_draw(sphere); + GPUBatch *sphere = GPU_batch_preset_sphere(0); + GPU_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); + GPU_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade); + GPU_batch_draw(sphere); GPU_matrix_pop(); } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index e9a8dd5ee08..c716692eb9b 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -548,7 +548,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) GPU_blend(true); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (ruler_item->flag & RULERITEM_USE_ANGLE) { immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -562,7 +562,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2fv(shdr_pos, co_ss[0]); immVertex2fv(shdr_pos, co_ss[1]); @@ -604,7 +604,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINE_STRIP, arc_steps + 1); + immBegin(GPU_PRIM_LINE_STRIP, arc_steps + 1); for (j = 0; j <= arc_steps; j++) { madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale); @@ -637,7 +637,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size); immVertex2fv(shdr_pos, cap); @@ -702,7 +702,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_pos, co_ss[0]); immVertex2fv(shdr_pos, co_ss[2]); @@ -726,7 +726,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size); immVertex2fv(shdr_pos, cap); @@ -793,7 +793,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) float co_ss_snap[3]; ED_view3d_project_float_global(ar, ruler_item->co[inter->co_index], co_ss_snap, V3D_PROJ_TEST_NOP); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color_act); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 5796014571a..855ee7bb9fc 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -39,7 +39,7 @@ struct ARegion; struct ARegionType; struct Base; struct BoundBox; -struct Gwn_Batch; +struct GPUBatch; struct Depsgraph; struct Object; struct SmokeDomainSettings; diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 133af8e6da7..690fc5e3bdb 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -461,7 +461,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a GPU_blend(true); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (ruler_item->flag & RULERITEM_USE_ANGLE) { immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -475,7 +475,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2fv(shdr_pos, co_ss[0]); immVertex2fv(shdr_pos, co_ss[1]); @@ -517,7 +517,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINE_STRIP, arc_steps + 1); + immBegin(GPU_PRIM_LINE_STRIP, arc_steps + 1); for (j = 0; j <= arc_steps; j++) { madd_v3_v3v3fl(co_tmp, ruler_item->co[1], dir_tmp, px_scale); @@ -550,7 +550,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec_a, cap_size); immVertex2fv(shdr_pos, cap); @@ -614,7 +614,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformArray4fv("colors", (float *)(float[][4]){{0.67f, 0.67f, 0.67f, 1.0f}, {col[0], col[1], col[2], col[3]}}, 2); immUniform1f("dash_width", 6.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_pos, co_ss[0]); immVertex2fv(shdr_pos, co_ss[2]); @@ -638,7 +638,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a immUniformColor3ubv(color_wire); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); madd_v2_v2v2fl(cap, co_ss[0], rot_90_vec, cap_size); immVertex2fv(shdr_pos, cap); @@ -703,7 +703,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a float co_ss[3]; ED_view3d_project_float_global(ar, ruler_item->co[ruler_item->co_index], co_ss, V3D_PROJ_TEST_NOP); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color_act); diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 4c5150fabdd..e4e12cc3686 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -343,14 +343,14 @@ static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *a yoff = walk->ar->winy / 2; } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColor(TH_VIEW_OVERLAY); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); /* North */ immVertex2i(pos, xoff, yoff + inner_length); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e9abdd80d20..dab53c04806 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1689,13 +1689,13 @@ typedef enum { } ArrowDirection; #define POS_INDEX 0 -/* NOTE: this --^ is a bit hackish, but simplifies Gwn_VertFormat usage among functions +/* NOTE: this --^ is a bit hackish, but simplifies GPUVertFormat usage among functions * private to this file - merwin */ static void drawArrow(ArrowDirection d, short offset, short length, short size) { - immBegin(GWN_PRIM_LINES, 6); + immBegin(GPU_PRIM_LINES, 6); switch (d) { case LEFT: @@ -1732,7 +1732,7 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size) static void drawArrowHead(ArrowDirection d, short size) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); switch (d) { case LEFT: @@ -1765,7 +1765,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments float angle; int a; - immBegin(GWN_PRIM_LINE_STRIP, segments + 1); + immBegin(GPU_PRIM_LINE_STRIP, segments + 1); for (angle = angle_start, a = 0; a < segments; angle += delta, a++) { immVertex2f(POS_INDEX, cosf(angle) * size, sinf(angle) * size); @@ -1817,7 +1817,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) /* Dashed lines first. */ if (ELEM(t->helpline, HLP_SPRING, HLP_ANGLE)) { - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); UNUSED_VARS_NDEBUG(shdr_pos); /* silence warning */ BLI_assert(shdr_pos == POS_INDEX); @@ -1835,7 +1835,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(POS_INDEX, cent); immVertex2f(POS_INDEX, tmval[0], tmval[1]); immEnd(); @@ -1844,7 +1844,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) } /* And now, solid lines. */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); UNUSED_VARS_NDEBUG(pos); /* silence warning */ BLI_assert(pos == POS_INDEX); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -7052,7 +7052,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_matrix_push(); GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -7069,7 +7069,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_line_width(line_size); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); - immBeginAtMost(GWN_PRIM_LINES, 4); + immBeginAtMost(GPU_PRIM_LINES, 4); if (curr_sv->v_side[0]) { immVertex3fv(pos, curr_sv->v_side[0]->co); immVertex3fv(pos, curr_sv->v_co_orig); @@ -7082,7 +7082,7 @@ static void drawEdgeSlide(TransInfo *t) immUniformThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade); GPU_point_size(ctrl_size); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); if (slp->flipped) { if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co); } @@ -7093,7 +7093,7 @@ static void drawEdgeSlide(TransInfo *t) immUniformThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade); GPU_point_size(guide_size); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac); immVertex3fv(pos, co_mark); immEnd(); @@ -7107,7 +7107,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_line_width(line_size); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); - immBegin(GWN_PRIM_LINES, sld->totsv * 2); + immBegin(GPU_PRIM_LINES, sld->totsv * 2); /* TODO(campbell): Loop over all verts */ sv = sld->sv; @@ -7687,12 +7687,12 @@ static void drawVertSlide(TransInfo *t) GPU_line_width(line_size); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); - immBegin(GWN_PRIM_LINES, sld->totsv * 2); + immBegin(GPU_PRIM_LINES, sld->totsv * 2); if (is_clamp) { sv = sld->sv; for (i = 0; i < sld->totsv; i++, sv++) { @@ -7718,7 +7718,7 @@ static void drawVertSlide(TransInfo *t) GPU_point_size(ctrl_size); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); immVertex3fv(shdr_pos, (slp->flipped && slp->use_even) ? curr_sv->co_link_orig_3d[curr_sv->co_link_curr] : curr_sv->co_orig_3d); @@ -7761,7 +7761,7 @@ static void drawVertSlide(TransInfo *t) immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(shdr_pos, curr_sv->co_orig_3d); immVertex3fv(shdr_pos, co_dest_3d); immEnd(); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index a02948a9951..c8f74cbcd4f 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -747,7 +747,7 @@ void drawConstraint(TransInfo *t) if (depth_test_enabled) GPU_depth_test(false); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); @@ -760,7 +760,7 @@ void drawConstraint(TransInfo *t) immUniform1f("dash_width", 2.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(shdr_pos, t->center_global); immVertex3fv(shdr_pos, vec); immEnd(); @@ -823,7 +823,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) if (depth_test_enabled) GPU_depth_test(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformThemeColor(TH_GRID); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index c1aa0263ef8..3618d57b3ed 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1132,12 +1132,12 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis } UI_make_axis_color(col, col2, axis); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3ubv(col2); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3fv(pos, v1); immVertex3fv(pos, v2); immEnd(); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index dc922b5c9ba..b67fd22dbff 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -165,7 +165,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) invert_m4_m4(imat, rv3d->viewmat); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); @@ -190,7 +190,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) if (usingSnappingNormal(t) && validSnappingNormal(t)) { immUniformColor4ubv(activeCol); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex3f(pos, t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]); immVertex3f(pos, t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0], t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1], @@ -219,7 +219,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 65147d53b5d..35a77fcd4c0 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -342,7 +342,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info const float mval_dst[2] = {win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin}; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -355,7 +355,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info immUniform1f("dash_width", 6.0f); immUniform1f("dash_factor", 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2fv(shdr_pos, mval_src); immVertex2fv(shdr_pos, mval_dst); immEnd(); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 5ff008e1de2..616f4eac2ad 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -92,7 +92,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) GPU_matrix_translate_2fv(cursor); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -104,7 +104,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 0.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2); immUniform1f("dash_width", 8.0f); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(shdr_pos, -0.05f * x_fac, 0.0f); immVertex2f(shdr_pos, 0.0f, 0.05f * y_fac); @@ -123,7 +123,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); immUniform1f("dash_width", 2.0f); - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(shdr_pos, -0.020f * x_fac, 0.0f); immVertex2f(shdr_pos, -0.1f * x_fac, 0.0f); @@ -168,7 +168,7 @@ static void draw_uvs_shadow(Object *obedit) const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -229,7 +229,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME } } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -241,7 +241,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { - immBegin(GWN_PRIM_TRI_FAN, efa->len); + immBegin(GPU_PRIM_TRI_FAN, efa->len); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -281,7 +281,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME immUniformColor3fv(col); /* TODO: use editmesh tessface */ - immBegin(GWN_PRIM_TRI_FAN, efa->len); + immBegin(GPU_PRIM_TRI_FAN, efa->len); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -308,9 +308,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME col[3] = 0.5f; /* hard coded alpha, not that nice */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -353,7 +353,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, Object *obedit, BME } /* TODO: use editmesh tessface */ - immBegin(GWN_PRIM_TRI_FAN, efa->len); + immBegin(GPU_PRIM_TRI_FAN, efa->len); BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); a = fabsf(uvang[i] - ang[i]) / (float)M_PI; @@ -393,7 +393,7 @@ static void draw_uvs_lineloop_bmfaces(BMesh *bm, const int cd_loop_uv_offset, co MLoopUV *luv; /* For more efficiency first transfer the entire buffer to vram. */ - Gwn_Batch *loop_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop); + GPUBatch *loop_batch = immBeginBatchAtMost(GPU_PRIM_LINE_LOOP, bm->totloop); BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -407,17 +407,17 @@ static void draw_uvs_lineloop_bmfaces(BMesh *bm, const int cd_loop_uv_offset, co immEnd(); /* Then draw each face contour separately. */ - GWN_batch_program_use_begin(loop_batch); + GPU_batch_program_use_begin(loop_batch); unsigned int index = 0; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - GWN_batch_draw_range_ex(loop_batch, index, efa->len, false); + GPU_batch_draw_range_ex(loop_batch, index, efa->len, false); index += efa->len; } - GWN_batch_program_use_end(loop_batch); - GWN_batch_discard(loop_batch); + GPU_batch_program_use_end(loop_batch); + GPU_batch_discard(loop_batch); } static void draw_uvs_lineloop_mpoly(Mesh *me, MPoly *mpoly, unsigned int pos) @@ -425,7 +425,7 @@ static void draw_uvs_lineloop_mpoly(Mesh *me, MPoly *mpoly, unsigned int pos) MLoopUV *mloopuv; int i; - immBegin(GWN_PRIM_LINE_LOOP, mpoly->totloop); + immBegin(GPU_PRIM_LINE_LOOP, mpoly->totloop); mloopuv = &me->mloopuv[mpoly->loopstart]; for (i = mpoly->totloop; i != 0; i--, mloopuv++) { @@ -495,7 +495,7 @@ static void draw_uvs_other_mesh(Object *ob, const Image *curimage, static void draw_uvs_other(ViewLayer *view_layer, Object *obedit, const Image *curimage, const int other_uv_filter) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -536,7 +536,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, ViewLayer *view_la mloopuv = me->mloopuv; } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -548,7 +548,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, ViewLayer *view_la if ((scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE) && mpoly->mat_nr != ob->actcol - 1) continue; - immBegin(GWN_PRIM_LINE_LOOP, mpoly->totloop); + immBegin(GPU_PRIM_LINE_LOOP, mpoly->totloop); mloopuv = mloopuv_base + mpoly->loopstart; for (b = 0; b < mpoly->totloop; b++, mloopuv++) { @@ -658,13 +658,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - Gwn_Batch *face_batch = immBeginBatch(GWN_PRIM_TRIS, tri_count * 3); + GPUBatch *face_batch = immBeginBatch(GPU_PRIM_TRIS, tri_count * 3); for (unsigned int i = 0; i < em->tottri; i++) { efa = em->looptris[i][0]->f; if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { @@ -686,9 +686,9 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immEnd(); /* XXX performance: we should not create and throw away result. */ - GWN_batch_draw(face_batch); - GWN_batch_program_use_end(face_batch); - GWN_batch_discard(face_batch); + GPU_batch_draw(face_batch); + GPU_batch_program_use_end(face_batch); + GPU_batch_discard(face_batch); immUnbindProgram(); @@ -712,7 +712,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); switch (sima->dt_uv) { case SI_UVDT_DASH: @@ -751,8 +751,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } /* For more efficiency first transfer the entire buffer to vram. */ - Gwn_Batch *loop_batch = immBeginBatchAtMost(GWN_PRIM_LINE_LOOP, bm->totloop); - Gwn_VertBuf *loop_vbo = loop_batch->verts[0]; + GPUBatch *loop_batch = immBeginBatchAtMost(GPU_PRIM_LINE_LOOP, bm->totloop); + GPUVertBuf *loop_vbo = loop_batch->verts[0]; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; @@ -766,17 +766,17 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* Then draw each face contour separately. */ if (loop_vbo->vertex_len != 0) { - GWN_batch_program_use_begin(loop_batch); + GPU_batch_program_use_begin(loop_batch); unsigned int index = 0, loop_vbo_count; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - GWN_batch_draw_range_ex(loop_batch, index, efa->len, false); + GPU_batch_draw_range_ex(loop_batch, index, efa->len, false); index += efa->len; } loop_vbo_count = index; - GWN_batch_program_use_end(loop_batch); + GPU_batch_program_use_end(loop_batch); immUnbindProgram(); @@ -790,14 +790,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje if (interpedges) { /* Create a color buffer. */ - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static uint shdr_col; if (format.attr_len == 0) { - shdr_col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + shdr_col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo_col = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo_col, loop_vbo_count); + GPUVertBuf *vbo_col = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo_col, loop_vbo_count); index = 0; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { @@ -806,36 +806,36 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje BM_ITER_ELEM(l, &liter, efa, BM_LOOPS_OF_FACE) { sel = uvedit_uv_select_test(scene, l, cd_loop_uv_offset); - GWN_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2); + GPU_vertbuf_attr_set(vbo_col, shdr_col, index++, sel ? col1 : col2); } } /* Reuse the UV buffer and add the color buffer. */ - GWN_batch_vertbuf_add_ex(loop_batch, vbo_col, true); + GPU_batch_vertbuf_add_ex(loop_batch, vbo_col, true); /* Now draw each face contour separately with another builtin program. */ - GWN_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR); + GPU_batch_program_set_builtin(loop_batch, GPU_SHADER_2D_SMOOTH_COLOR); GPU_matrix_bind(loop_batch->interface); - GWN_batch_program_use_begin(loop_batch); + GPU_batch_program_use_begin(loop_batch); index = 0; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - GWN_batch_draw_range_ex(loop_batch, index, efa->len, false); + GPU_batch_draw_range_ex(loop_batch, index, efa->len, false); index += efa->len; } - GWN_batch_program_use_end(loop_batch); + GPU_batch_program_use_end(loop_batch); } else { - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); /* Use batch here to avoid problems with `IMM_BUFFER_SIZE`. */ - Gwn_Batch *flat_edges_batch = immBeginBatchAtMost(GWN_PRIM_LINES, loop_vbo_count * 2); + GPUBatch *flat_edges_batch = immBeginBatchAtMost(GPU_PRIM_LINES, loop_vbo_count * 2); BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; @@ -852,27 +852,27 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje } immEnd(); - GWN_batch_draw(flat_edges_batch); - GWN_batch_discard(flat_edges_batch); + GPU_batch_draw(flat_edges_batch); + GPU_batch_discard(flat_edges_batch); immUnbindProgram(); } } else { - GWN_batch_uniform_4fv(loop_batch, "color", col2); + GPU_batch_uniform_4fv(loop_batch, "color", col2); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* no nice edges */ - GWN_batch_program_use_begin(loop_batch); + GPU_batch_program_use_begin(loop_batch); index = 0; BM_ITER_MESH(efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - GWN_batch_draw_range_ex(loop_batch, index, efa->len, false); + GPU_batch_draw_range_ex(loop_batch, index, efa->len, false); index += efa->len; } - GWN_batch_program_use_end(loop_batch); + GPU_batch_program_use_end(loop_batch); immUnbindProgram(); } } @@ -881,7 +881,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immUnbindProgram(); } - GWN_batch_discard(loop_batch); + GPU_batch_discard(loop_batch); if (sima->flag & SI_SMOOTH_UV) { GPU_line_smooth(false); @@ -894,16 +894,16 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje float cent[2]; bool col_set = false; - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE); GPU_point_size(pointsize); - immBeginAtMost(GWN_PRIM_POINTS, bm->totface); + immBeginAtMost(GPU_PRIM_POINTS, bm->totface); /* unselected faces */ @@ -955,7 +955,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje /* 6. draw uv vertices */ if (drawfaces != 2) { /* 2 means Mesh Face Mode */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -964,7 +964,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE); GPU_point_size(pointsize); - immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); + immBeginAtMost(GPU_PRIM_POINTS, bm->totloop); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -984,7 +984,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje GPU_point_size(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0)); imm_cpack(0xFF); - immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); + immBeginAtMost(GPU_PRIM_POINTS, bm->totloop); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -1004,7 +1004,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, ViewLayer *view_layer, Obje immUniformThemeColor(TH_VERTEX_SELECT); GPU_point_size(pointsize); - immBeginAtMost(GWN_PRIM_POINTS, bm->totloop); + immBeginAtMost(GPU_PRIM_POINTS, bm->totloop); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 9265bc05154..18f1bc872c0 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1547,13 +1547,13 @@ static void stitch_calculate_edge_normal(BMEditMesh *em, UvEdge *edge, float *no /** */ -static void stitch_draw_vbo(Gwn_VertBuf *vbo, Gwn_PrimType prim_type, const float col[4]) +static void stitch_draw_vbo(GPUVertBuf *vbo, GPUPrimType prim_type, const float col[4]) { - Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); - GWN_batch_uniform_4fv(batch, "color", col); - GWN_batch_draw(batch); - GWN_batch_discard(batch); + GPUBatch *batch = GPU_batch_create_ex(prim_type, vbo, NULL, GPU_BATCH_OWNS_VBO); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); + GPU_batch_uniform_4fv(batch, "color", col); + GPU_batch_draw(batch); + GPU_batch_discard(batch); } /* TODO make things pretier : store batches inside StitchPreviewer instead of the bare verts pos */ @@ -1563,25 +1563,25 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar unsigned int num_line = 0, num_tri, tri_idx = 0, line_idx = 0; StitchState *state = (StitchState *)arg; StitchPreviewer *stitch_preview = state->stitch_preview; - Gwn_VertBuf *vbo, *vbo_line; + GPUVertBuf *vbo, *vbo_line; float col[4]; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static unsigned int pos_id; if (format.attr_len == 0) { - pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } GPU_blend(true); /* Static Tris */ UI_GetThemeColor4fv(TH_STITCH_PREVIEW_ACTIVE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_static_tris * 3); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_static_tris * 3); for (int i = 0; i < stitch_preview->num_static_tris * 3; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->static_tris[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->static_tris[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_TRIS, col); + stitch_draw_vbo(vbo, GPU_PRIM_TRIS, col); /* Preview Polys */ @@ -1591,39 +1591,39 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar num_tri = num_line - 2 * stitch_preview->num_polys; /* we need to convert the polys into triangles / lines */ - vbo = GWN_vertbuf_create_with_format(&format); - vbo_line = GWN_vertbuf_create_with_format(&format); + vbo = GPU_vertbuf_create_with_format(&format); + vbo_line = GPU_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, num_tri * 3); - GWN_vertbuf_data_alloc(vbo_line, num_line * 2); + GPU_vertbuf_data_alloc(vbo, num_tri * 3); + GPU_vertbuf_data_alloc(vbo_line, num_line * 2); for (int i = 0; i < stitch_preview->num_polys; i++) { BLI_assert(stitch_preview->uvs_per_polygon[i] >= 3); /* Start line */ - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]); - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + 2]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + 2]); for (j = 1; j < stitch_preview->uvs_per_polygon[i] - 1; ++j) { - GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index]); - GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]); - GWN_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index]); + GPU_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, tri_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]); - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]); - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 0) * 2]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + (j + 1) * 2]); } /* Closing line */ - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index]); /* j = uvs_per_polygon[i] - 1*/ - GWN_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + j * 2]); + GPU_vertbuf_attr_set(vbo_line, pos_id, line_idx++, &stitch_preview->preview_polys[index + j * 2]); index += stitch_preview->uvs_per_polygon[i] * 2; } UI_GetThemeColor4fv(TH_STITCH_PREVIEW_FACE, col); - stitch_draw_vbo(vbo, GWN_PRIM_TRIS, col); + stitch_draw_vbo(vbo, GPU_PRIM_TRIS, col); UI_GetThemeColor4fv(TH_STITCH_PREVIEW_EDGE, col); - stitch_draw_vbo(vbo_line, GWN_PRIM_LINES, col); + stitch_draw_vbo(vbo_line, GPU_PRIM_LINES, col); GPU_blend(false); @@ -1633,37 +1633,37 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar GPU_point_size(UI_GetThemeValuef(TH_VERTEX_SIZE) * 2.0f); UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable); for (int i = 0; i < stitch_preview->num_stitchable; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_POINTS, col); + stitch_draw_vbo(vbo, GPU_PRIM_POINTS, col); UI_GetThemeColor4fv(TH_STITCH_PREVIEW_UNSTITCHABLE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable); for (int i = 0; i < stitch_preview->num_unstitchable; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_POINTS, col); + stitch_draw_vbo(vbo, GPU_PRIM_POINTS, col); } else { UI_GetThemeColor4fv(TH_STITCH_PREVIEW_STITCHABLE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable * 2); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_stitchable * 2); for (int i = 0; i < stitch_preview->num_stitchable * 2; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_stitchable[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_LINES, col); + stitch_draw_vbo(vbo, GPU_PRIM_LINES, col); UI_GetThemeColor4fv(TH_STITCH_PREVIEW_UNSTITCHABLE, col); - vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable * 2); + vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, stitch_preview->num_unstitchable * 2); for (int i = 0; i < stitch_preview->num_unstitchable * 2; i++) { - GWN_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]); + GPU_vertbuf_attr_set(vbo, pos_id, i, &stitch_preview->preview_unstitchable[i * 2]); } - stitch_draw_vbo(vbo, GWN_PRIM_LINES, col); + stitch_draw_vbo(vbo, GPU_PRIM_LINES, col); } } diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 3d207b85760..58295ae9329 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -23,7 +23,7 @@ # # ***** END GPL LICENSE BLOCK ***** -# WITH_OPENGL limits the visibility of the opengl headers to just gawain and bg_gpu, +# WITH_OPENGL limits the visibility of the opengl headers to just GPU and bg_gpu, # to more easily highlight codepadths in other libraries that need to be refactored, # bf_gpu is allowed to have opengl regardless of this option. diff --git a/source/blender/gpu/GPU_attr_binding.h b/source/blender/gpu/GPU_attr_binding.h index 41050a095cd..186acacb71d 100644 --- a/source/blender/gpu/GPU_attr_binding.h +++ b/source/blender/gpu/GPU_attr_binding.h @@ -23,20 +23,20 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_attr_binding.h +/** \file blender/gpu/GPU_attr_binding.h * \ingroup gpu * - * Gawain vertex attribute binding + * GPU vertex attribute binding */ -#ifndef __GWN_ATTR_BINDING_H__ -#define __GWN_ATTR_BINDING_H__ +#ifndef __GPU_ATTR_BINDING_H__ +#define __GPU_ATTR_BINDING_H__ #include "GPU_common.h" -typedef struct Gwn_AttrBinding { +typedef struct GPUAttrBinding { uint64_t loc_bits; /* store 4 bits for each of the 16 attribs */ uint16_t enabled_bits; /* 1 bit for each attrib */ -} Gwn_AttrBinding; +} GPUAttrBinding; -#endif /* __GWN_ATTR_BINDING_H__ */ +#endif /* __GPU_ATTR_BINDING_H__ */ diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h index 4c98eb8f537..bd0e3b43e6c 100644 --- a/source/blender/gpu/GPU_batch.h +++ b/source/blender/gpu/GPU_batch.h @@ -23,15 +23,15 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_batch.h +/** \file blender/gpu/GPU_batch.h * \ingroup gpu * - * Gawain geometry batch + * GPU geometry batch * Contains VAOs + VBOs + Shader representing a drawable entity. */ -#ifndef __GWN_BATCH_H__ -#define __GWN_BATCH_H__ +#ifndef __GPU_BATCH_H__ +#define __GPU_BATCH_H__ #include "GPU_vertex_buffer.h" #include "GPU_element.h" @@ -39,32 +39,32 @@ #include "GPU_shader.h" typedef enum { - GWN_BATCH_READY_TO_FORMAT, - GWN_BATCH_READY_TO_BUILD, - GWN_BATCH_BUILDING, - GWN_BATCH_READY_TO_DRAW -} Gwn_BatchPhase; + GPU_BATCH_READY_TO_FORMAT, + GPU_BATCH_READY_TO_BUILD, + GPU_BATCH_BUILDING, + GPU_BATCH_READY_TO_DRAW +} GPUBatchPhase; -#define GWN_BATCH_VBO_MAX_LEN 3 -#define GWN_BATCH_VAO_STATIC_LEN 3 -#define GWN_BATCH_VAO_DYN_ALLOC_COUNT 16 +#define GPU_BATCH_VBO_MAX_LEN 3 +#define GPU_BATCH_VAO_STATIC_LEN 3 +#define GPU_BATCH_VAO_DYN_ALLOC_COUNT 16 -typedef struct Gwn_Batch { +typedef struct GPUBatch { /* geometry */ - Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */ - Gwn_VertBuf* inst; /* instance attribs */ - Gwn_IndexBuf* elem; /* NULL if element list not needed */ + GPUVertBuf* verts[GPU_BATCH_VBO_MAX_LEN]; /* verts[0] is required, others can be NULL */ + GPUVertBuf* inst; /* instance attribs */ + GPUIndexBuf* elem; /* NULL if element list not needed */ uint32_t gl_prim_type; /* cached values (avoid dereferencing later) */ uint32_t vao_id; uint32_t program; - const struct Gwn_ShaderInterface* interface; + const struct GPUShaderInterface* interface; /* book-keeping */ uint owns_flag; - struct Gwn_Context *context; /* used to free all vaos. this implies all vaos were created under the same context. */ - Gwn_BatchPhase phase; + struct GPUContext *context; /* used to free all vaos. this implies all vaos were created under the same context. */ + GPUBatchPhase phase; bool program_in_use; /* Vao management: remembers all geometry state (vertex attrib bindings & element buffer) @@ -74,113 +74,113 @@ typedef struct Gwn_Batch { union { /* Static handle count */ struct { - const struct Gwn_ShaderInterface* interfaces[GWN_BATCH_VAO_STATIC_LEN]; - uint32_t vao_ids[GWN_BATCH_VAO_STATIC_LEN]; + const struct GPUShaderInterface* interfaces[GPU_BATCH_VAO_STATIC_LEN]; + uint32_t vao_ids[GPU_BATCH_VAO_STATIC_LEN]; } static_vaos; /* Dynamic handle count */ struct { uint count; - const struct Gwn_ShaderInterface** interfaces; + const struct GPUShaderInterface** interfaces; uint32_t* vao_ids; } dynamic_vaos; }; /* XXX This is the only solution if we want to have some data structure using * batches as key to identify nodes. We must destroy these nodes with this callback. */ - void (*free_callback)(struct Gwn_Batch*, void*); + void (*free_callback)(struct GPUBatch*, void*); void* callback_data; -} Gwn_Batch; +} GPUBatch; enum { - GWN_BATCH_OWNS_VBO = (1 << 0), + GPU_BATCH_OWNS_VBO = (1 << 0), /* each vbo index gets bit-shifted */ - GWN_BATCH_OWNS_INSTANCES = (1 << 30), - GWN_BATCH_OWNS_INDEX = (1 << 31), + GPU_BATCH_OWNS_INSTANCES = (1 << 30), + GPU_BATCH_OWNS_INDEX = (1 << 31), }; -Gwn_Batch* GWN_batch_create_ex(Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); -void GWN_batch_init_ex(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, uint owns_flag); -Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src); +GPUBatch* GPU_batch_create_ex(GPUPrimType, GPUVertBuf*, GPUIndexBuf*, uint owns_flag); +void GPU_batch_init_ex(GPUBatch*, GPUPrimType, GPUVertBuf*, GPUIndexBuf*, uint owns_flag); +GPUBatch* GPU_batch_duplicate(GPUBatch* batch_src); -#define GWN_batch_create(prim, verts, elem) \ - GWN_batch_create_ex(prim, verts, elem, 0) -#define GWN_batch_init(batch, prim, verts, elem) \ - GWN_batch_init_ex(batch, prim, verts, elem, 0) +#define GPU_batch_create(prim, verts, elem) \ + GPU_batch_create_ex(prim, verts, elem, 0) +#define GPU_batch_init(batch, prim, verts, elem) \ + GPU_batch_init_ex(batch, prim, verts, elem, 0) -void GWN_batch_discard(Gwn_Batch*); /* verts & elem are not discarded */ +void GPU_batch_discard(GPUBatch*); /* verts & elem are not discarded */ -void gwn_batch_vao_cache_clear(Gwn_Batch*); +void GPU_batch_vao_cache_clear(GPUBatch*); -void GWN_batch_callback_free_set(Gwn_Batch*, void (*callback)(Gwn_Batch*, void*), void*); +void GPU_batch_callback_free_set(GPUBatch*, void (*callback)(GPUBatch*, void*), void*); -void GWN_batch_instbuf_set(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); /* Instancing */ +void GPU_batch_instbuf_set(GPUBatch*, GPUVertBuf*, bool own_vbo); /* Instancing */ -int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); +int GPU_batch_vertbuf_add_ex(GPUBatch*, GPUVertBuf*, bool own_vbo); -#define GWN_batch_vertbuf_add(batch, verts) \ - GWN_batch_vertbuf_add_ex(batch, verts, false) +#define GPU_batch_vertbuf_add(batch, verts) \ + GPU_batch_vertbuf_add_ex(batch, verts, false) -void GWN_batch_program_set_no_use(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); -void GWN_batch_program_set(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*); -void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id); +void GPU_batch_program_set_no_use(GPUBatch*, uint32_t program, const GPUShaderInterface*); +void GPU_batch_program_set(GPUBatch*, uint32_t program, const GPUShaderInterface*); +void GPU_batch_program_set_builtin(GPUBatch *batch, GPUBuiltinShader shader_id); /* Entire batch draws with one shader program, but can be redrawn later with another program. */ /* Vertex shader's inputs must be compatible with the batch's vertex format. */ -void GWN_batch_program_use_begin(Gwn_Batch*); /* call before Batch_Uniform (temp hack?) */ -void GWN_batch_program_use_end(Gwn_Batch*); - -void GWN_batch_uniform_1ui(Gwn_Batch*, const char* name, int value); -void GWN_batch_uniform_1i(Gwn_Batch*, const char* name, int value); -void GWN_batch_uniform_1b(Gwn_Batch*, const char* name, bool value); -void GWN_batch_uniform_1f(Gwn_Batch*, const char* name, float value); -void GWN_batch_uniform_2f(Gwn_Batch*, const char* name, float x, float y); -void GWN_batch_uniform_3f(Gwn_Batch*, const char* name, float x, float y, float z); -void GWN_batch_uniform_4f(Gwn_Batch*, const char* name, float x, float y, float z, float w); -void GWN_batch_uniform_2fv(Gwn_Batch*, const char* name, const float data[2]); -void GWN_batch_uniform_3fv(Gwn_Batch*, const char* name, const float data[3]); -void GWN_batch_uniform_4fv(Gwn_Batch*, const char* name, const float data[4]); -void GWN_batch_uniform_2fv_array(Gwn_Batch*, const char* name, int len, const float *data); -void GWN_batch_uniform_4fv_array(Gwn_Batch*, const char* name, int len, const float *data); -void GWN_batch_uniform_mat4(Gwn_Batch*, const char* name, const float data[4][4]); - -void GWN_batch_draw(Gwn_Batch*); +void GPU_batch_program_use_begin(GPUBatch*); /* call before Batch_Uniform (temp hack?) */ +void GPU_batch_program_use_end(GPUBatch*); + +void GPU_batch_uniform_1ui(GPUBatch*, const char* name, int value); +void GPU_batch_uniform_1i(GPUBatch*, const char* name, int value); +void GPU_batch_uniform_1b(GPUBatch*, const char* name, bool value); +void GPU_batch_uniform_1f(GPUBatch*, const char* name, float value); +void GPU_batch_uniform_2f(GPUBatch*, const char* name, float x, float y); +void GPU_batch_uniform_3f(GPUBatch*, const char* name, float x, float y, float z); +void GPU_batch_uniform_4f(GPUBatch*, const char* name, float x, float y, float z, float w); +void GPU_batch_uniform_2fv(GPUBatch*, const char* name, const float data[2]); +void GPU_batch_uniform_3fv(GPUBatch*, const char* name, const float data[3]); +void GPU_batch_uniform_4fv(GPUBatch*, const char* name, const float data[4]); +void GPU_batch_uniform_2fv_array(GPUBatch*, const char* name, int len, const float *data); +void GPU_batch_uniform_4fv_array(GPUBatch*, const char* name, int len, const float *data); +void GPU_batch_uniform_mat4(GPUBatch*, const char* name, const float data[4][4]); + +void GPU_batch_draw(GPUBatch*); /* This does not bind/unbind shader and does not call GPU_matrix_bind() */ -void GWN_batch_draw_range_ex(Gwn_Batch*, int v_first, int v_count, bool force_instance); +void GPU_batch_draw_range_ex(GPUBatch*, int v_first, int v_count, bool force_instance); /* Does not even need batch */ -void GWN_draw_primitive(Gwn_PrimType, int v_count); +void GPU_draw_primitive(GPUPrimType, int v_count); #if 0 /* future plans */ -/* Can multiple batches share a Gwn_VertBuf? Use ref count? */ +/* Can multiple batches share a GPUVertBuf? Use ref count? */ /* We often need a batch with its own data, to be created and discarded together. */ /* WithOwn variants reduce number of system allocations. */ typedef struct BatchWithOwnVertexBuffer { - Gwn_Batch batch; - Gwn_VertBuf verts; /* link batch.verts to this */ + GPUBatch batch; + GPUVertBuf verts; /* link batch.verts to this */ } BatchWithOwnVertexBuffer; typedef struct BatchWithOwnElementList { - Gwn_Batch batch; - Gwn_IndexBuf elem; /* link batch.elem to this */ + GPUBatch batch; + GPUIndexBuf elem; /* link batch.elem to this */ } BatchWithOwnElementList; typedef struct BatchWithOwnVertexBufferAndElementList { - Gwn_Batch batch; - Gwn_IndexBuf elem; /* link batch.elem to this */ - Gwn_VertBuf verts; /* link batch.verts to this */ + GPUBatch batch; + GPUIndexBuf elem; /* link batch.elem to this */ + GPUVertBuf verts; /* link batch.verts to this */ } BatchWithOwnVertexBufferAndElementList; -Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, uint v_len, Gwn_IndexBuf*); -Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, uint prim_len); -Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, uint v_len, uint prim_len); +GPUBatch* create_BatchWithOwnVertexBuffer(GPUPrimType, GPUVertFormat*, uint v_len, GPUIndexBuf*); +GPUBatch* create_BatchWithOwnElementList(GPUPrimType, GPUVertBuf*, uint prim_len); +GPUBatch* create_BatchWithOwnVertexBufferAndElementList(GPUPrimType, GPUVertFormat*, uint v_len, uint prim_len); /* verts: shared, own */ /* elem: none, shared, own */ -Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStuff); +GPUBatch* create_BatchInGeneral(GPUPrimType, VertexBufferStuff, ElementListStuff); #endif /* future plans */ @@ -189,11 +189,11 @@ void gpu_batch_exit(void); /* Macros */ -#define GWN_BATCH_DISCARD_SAFE(batch) do { \ +#define GPU_BATCH_DISCARD_SAFE(batch) do { \ if (batch != NULL) { \ - GWN_batch_discard(batch); \ + GPU_batch_discard(batch); \ batch = NULL; \ } \ } while (0) -#endif /* __GWN_BATCH_H__ */ +#endif /* __GPU_BATCH_H__ */ diff --git a/source/blender/gpu/GPU_batch_presets.h b/source/blender/gpu/GPU_batch_presets.h index 2450a1760c3..a33b864c5b9 100644 --- a/source/blender/gpu/GPU_batch_presets.h +++ b/source/blender/gpu/GPU_batch_presets.h @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/* Batched geometry rendering is powered by the Gawain library. +/* Batched geometry rendering is powered by the GPU library. * This file contains any additions or modifications specific to Blender. */ @@ -32,20 +32,20 @@ #define __GPU_BATCH_PRESETS_H__ struct rctf; -struct Gwn_VertFormat; +struct GPUVertFormat; #include "BLI_compiler_attrs.h" #include "BLI_sys_types.h" /* gpu_batch_presets.c */ -struct Gwn_VertFormat *GPU_batch_preset_format_3d(void); +struct GPUVertFormat *GPU_batch_preset_format_3d(void); /* Replacement for gluSphere */ -struct Gwn_Batch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT; -struct Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT; +struct GPUBatch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT; +struct GPUBatch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT; void gpu_batch_presets_init(void); -void gpu_batch_presets_register(struct Gwn_Batch *preset_batch); +void gpu_batch_presets_register(struct GPUBatch *preset_batch); void gpu_batch_presets_reset(void); void gpu_batch_presets_exit(void); diff --git a/source/blender/gpu/GPU_batch_utils.h b/source/blender/gpu/GPU_batch_utils.h index b23b7723dc0..d558b7a1097 100644 --- a/source/blender/gpu/GPU_batch_utils.h +++ b/source/blender/gpu/GPU_batch_utils.h @@ -27,14 +27,14 @@ struct rctf; #include "BLI_sys_types.h" /* gpu_batch_utils.c */ -struct Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( +struct GPUBatch *GPU_batch_tris_from_poly_2d_encoded( const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); -struct Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( +struct GPUBatch *GPU_batch_wire_from_poly_2d_encoded( const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /* Only use by draw manager. Use the presets function instead for interface. */ -struct Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT; +struct GPUBatch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT; #endif /* __GPU_BATCH_UTILS_H__ */ diff --git a/source/blender/gpu/GPU_buffer_id.h b/source/blender/gpu/GPU_buffer_id.h index fd680ff31f5..4615e9e2c66 100644 --- a/source/blender/gpu/GPU_buffer_id.h +++ b/source/blender/gpu/GPU_buffer_id.h @@ -23,14 +23,14 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_buffer_id.h +/** \file blender/gpu/GPU_buffer_id.h * \ingroup gpu * - * Gawain buffer IDs + * GPU buffer IDs */ -#ifndef __GWN_BUFFER_ID_H__ -#define __GWN_BUFFER_ID_H__ +#ifndef __GPU_BUFFER_ID_H__ +#define __GPU_BUFFER_ID_H__ /* Manage GL buffer IDs in a thread-safe way * Use these instead of glGenBuffers & its friends @@ -43,11 +43,11 @@ extern "C" { #include "GPU_common.h" -GLuint GWN_buf_id_alloc(void); -void GWN_buf_id_free(GLuint buffer_id); +GLuint GPU_buf_id_alloc(void); +void GPU_buf_id_free(GLuint buffer_id); #ifdef __cplusplus } #endif -#endif /* __GWN_BUFFER_ID_H__ */ +#endif /* __GPU_BUFFER_ID_H__ */ diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index f496c92f283..77801256463 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -91,7 +91,7 @@ void GPU_pbvh_grid_buffers_update( const int update_flags); /* draw */ -struct Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast); +struct GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast); /* debug PBVH draw */ void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos); diff --git a/source/blender/gpu/GPU_common.h b/source/blender/gpu/GPU_common.h index 2587e8670a9..cb506c6b0bc 100644 --- a/source/blender/gpu/GPU_common.h +++ b/source/blender/gpu/GPU_common.h @@ -23,12 +23,12 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_common.h +/** \file blender/gpu/GPU_common.h * \ingroup gpu */ -#ifndef __GWN_COMMON_H__ -#define __GWN_COMMON_H__ +#ifndef __GPU_COMMON_H__ +#define __GPU_COMMON_H__ #define PROGRAM_NO_OPTI 0 @@ -51,11 +51,11 @@ #include #endif -/* GWN_INLINE */ +/* GPU_INLINE */ #if defined(_MSC_VER) -# define GWN_INLINE static __forceinline +# define GPU_INLINE static __forceinline #else -# define GWN_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) +# define GPU_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) #endif -#endif /* __GWN_COMMON_H__ */ +#endif /* __GPU_COMMON_H__ */ diff --git a/source/blender/gpu/GPU_context.h b/source/blender/gpu/GPU_context.h index 0cedc109645..5f63c408801 100644 --- a/source/blender/gpu/GPU_context.h +++ b/source/blender/gpu/GPU_context.h @@ -23,14 +23,14 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_context.h +/** \file blender/gpu/GPU_context.h * \ingroup gpu * - * This interface allow Gawain to manage VAOs for mutiple context and threads. + * This interface allow GPU to manage VAOs for mutiple context and threads. */ -#ifndef __GWN_CONTEXT_H__ -#define __GWN_CONTEXT_H__ +#ifndef __GPU_CONTEXT_H__ +#define __GPU_CONTEXT_H__ #ifdef __cplusplus extern "C" { @@ -40,16 +40,16 @@ extern "C" { #include "GPU_batch.h" #include "GPU_shader_interface.h" -typedef struct Gwn_Context Gwn_Context; +typedef struct GPUContext GPUContext; -Gwn_Context* GWN_context_create(void); -void GWN_context_discard(Gwn_Context*); +GPUContext* GPU_context_create(void); +void GPU_context_discard(GPUContext*); -void GWN_context_active_set(Gwn_Context*); -Gwn_Context* GWN_context_active_get(void); +void GPU_context_active_set(GPUContext*); +GPUContext* GPU_context_active_get(void); #ifdef __cplusplus } #endif -#endif /* __GWN_CONTEXT_H__ */ +#endif /* __GPU_CONTEXT_H__ */ diff --git a/source/blender/gpu/GPU_element.h b/source/blender/gpu/GPU_element.h index 0c23e90569b..508c079fcd3 100644 --- a/source/blender/gpu/GPU_element.h +++ b/source/blender/gpu/GPU_element.h @@ -23,31 +23,31 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_element.h +/** \file blender/gpu/GPU_element.h * \ingroup gpu * - * Gawain element list (AKA index buffer) + * GPU element list (AKA index buffer) */ -#ifndef __GWN_ELEMENT_H__ -#define __GWN_ELEMENT_H__ +#ifndef __GPU_ELEMENT_H__ +#define __GPU_ELEMENT_H__ #include "GPU_primitive.h" -#define GWN_TRACK_INDEX_RANGE 1 +#define GPU_TRACK_INDEX_RANGE 1 -#define GWN_PRIM_RESTART 0xFFFFFFFF +#define GPU_PRIM_RESTART 0xFFFFFFFF typedef enum { - GWN_INDEX_U8, /* GL has this, Vulkan does not */ - GWN_INDEX_U16, - GWN_INDEX_U32 -} Gwn_IndexBufType; + GPU_INDEX_U8, /* GL has this, Vulkan does not */ + GPU_INDEX_U16, + GPU_INDEX_U32 +} GPUIndexBufType; -typedef struct Gwn_IndexBuf { +typedef struct GPUIndexBuf { uint index_len; -#if GWN_TRACK_INDEX_RANGE - Gwn_IndexBufType index_type; +#if GPU_TRACK_INDEX_RANGE + GPUIndexBufType index_type; uint32_t gl_index_type; uint min_index; uint max_index; @@ -55,48 +55,48 @@ typedef struct Gwn_IndexBuf { #endif uint32_t vbo_id; /* 0 indicates not yet sent to VRAM */ bool use_prim_restart; -} Gwn_IndexBuf; +} GPUIndexBuf; -void GWN_indexbuf_use(Gwn_IndexBuf*); -uint GWN_indexbuf_size_get(const Gwn_IndexBuf*); +void GPU_indexbuf_use(GPUIndexBuf*); +uint GPU_indexbuf_size_get(const GPUIndexBuf*); -typedef struct Gwn_IndexBufBuilder { +typedef struct GPUIndexBufBuilder { uint max_allowed_index; uint max_index_len; uint index_len; - Gwn_PrimType prim_type; + GPUPrimType prim_type; uint* data; bool use_prim_restart; -} Gwn_IndexBufBuilder; +} GPUIndexBufBuilder; /* supports all primitive types. */ -void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, uint index_len, uint vertex_len, bool use_prim_restart); +void GPU_indexbuf_init_ex(GPUIndexBufBuilder*, GPUPrimType, uint index_len, uint vertex_len, bool use_prim_restart); -/* supports only GWN_PRIM_POINTS, GWN_PRIM_LINES and GWN_PRIM_TRIS. */ -void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, uint prim_len, uint vertex_len); +/* supports only GPU_PRIM_POINTS, GPU_PRIM_LINES and GPU_PRIM_TRIS. */ +void GPU_indexbuf_init(GPUIndexBufBuilder*, GPUPrimType, uint prim_len, uint vertex_len); -void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, uint v); -void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder*); +void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder*, uint v); +void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder*); -void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder*, uint v); -void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder*, uint v1, uint v2); -void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3); -void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder*, uint v1, uint v2, uint v3, uint v4); +void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder*, uint v); +void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder*, uint v1, uint v2); +void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder*, uint v1, uint v2, uint v3); +void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder*, uint v1, uint v2, uint v3, uint v4); -Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder*); -void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder*, Gwn_IndexBuf*); +GPUIndexBuf* GPU_indexbuf_build(GPUIndexBufBuilder*); +void GPU_indexbuf_build_in_place(GPUIndexBufBuilder*, GPUIndexBuf*); -void GWN_indexbuf_discard(Gwn_IndexBuf*); +void GPU_indexbuf_discard(GPUIndexBuf*); /* Macros */ -#define GWN_INDEXBUF_DISCARD_SAFE(elem) do { \ +#define GPU_INDEXBUF_DISCARD_SAFE(elem) do { \ if (elem != NULL) { \ - GWN_indexbuf_discard(elem); \ + GPU_indexbuf_discard(elem); \ elem = NULL; \ } \ } while (0) -#endif /* __GWN_ELEMENT_H__ */ +#endif /* __GPU_ELEMENT_H__ */ diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h index c5892886825..a756687b557 100644 --- a/source/blender/gpu/GPU_immediate.h +++ b/source/blender/gpu/GPU_immediate.h @@ -27,7 +27,7 @@ /** \file blender/gpu/GPU_immediate.h * \ingroup gpu * - * Gawain immediate mode work-alike + * GPU immediate mode work-alike */ #ifndef __GPU_IMMEDIATE_H__ @@ -40,20 +40,20 @@ #include "GPU_immediate_util.h" #include "GPU_shader.h" -Gwn_VertFormat* immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */ +GPUVertFormat* immVertexFormat(void); /* returns a cleared vertex format, ready for add_attrib. */ -void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); /* every immBegin must have a program bound first. */ +void immBindProgram(uint32_t program, const GPUShaderInterface*); /* every immBegin must have a program bound first. */ void immUnbindProgram(void); /* call after your last immEnd, or before binding another program. */ -void immBegin(Gwn_PrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */ -void immBeginAtMost(Gwn_PrimType, uint max_vertex_len); /* can supply fewer vertices. */ +void immBegin(GPUPrimType, uint vertex_len); /* must supply exactly vertex_len vertices. */ +void immBeginAtMost(GPUPrimType, uint max_vertex_len); /* can supply fewer vertices. */ void immEnd(void); /* finishes and draws. */ /* ImmBegin a batch, then use standard immFunctions as usual. */ /* ImmEnd will finalize the batch instead of drawing. */ /* Then you can draw it as many times as you like! Partially replaces the need for display lists. */ -Gwn_Batch* immBeginBatch(Gwn_PrimType, uint vertex_len); -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, uint vertex_len); +GPUBatch* immBeginBatch(GPUPrimType, uint vertex_len); +GPUBatch* immBeginBatchAtMost(GPUPrimType, uint vertex_len); /* Provide attribute values that can change per vertex. */ /* First vertex after immBegin must have all its attributes specified. */ diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h index 0a5c9805509..58555e287b0 100644 --- a/source/blender/gpu/GPU_immediate_util.h +++ b/source/blender/gpu/GPU_immediate_util.h @@ -32,7 +32,7 @@ void immRectf(uint pos, float x1, float y1, float x2, float y2); void immRecti(uint pos, int x1, int y1, int x2, int y2); -/* Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GWN_PRIM_TRIS. */ +/* Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GPU_PRIM_TRIS. */ void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4]); void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4]); @@ -44,7 +44,7 @@ void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments); void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments); -/* use this version when Gwn_VertFormat has a vec3 position */ +/* use this version when GPUVertFormat has a vec3 position */ void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments); void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments); diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h index f5e34bd4c90..23f19ed19cd 100644 --- a/source/blender/gpu/GPU_matrix.h +++ b/source/blender/gpu/GPU_matrix.h @@ -38,7 +38,7 @@ extern "C" { #endif -struct Gwn_ShaderInterface; +struct GPUShaderInterface; void GPU_matrix_reset(void); /* to Identity transform & empty stack */ @@ -111,7 +111,7 @@ const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]; /* set uniform values for currently bound shader */ -void GPU_matrix_bind(const struct Gwn_ShaderInterface *); +void GPU_matrix_bind(const struct GPUShaderInterface *); bool GPU_matrix_dirty_get(void); /* since last bind */ diff --git a/source/blender/gpu/GPU_primitive.h b/source/blender/gpu/GPU_primitive.h index 44348b9b593..bcedfa56ab1 100644 --- a/source/blender/gpu/GPU_primitive.h +++ b/source/blender/gpu/GPU_primitive.h @@ -23,43 +23,43 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_primitive.h +/** \file blender/gpu/GPU_primitive.h * \ingroup gpu * - * Gawain geometric primitives + * GPU geometric primitives */ -#ifndef __GWN_PRIMITIVE_H__ -#define __GWN_PRIMITIVE_H__ +#ifndef __GPU_PRIMITIVE_H__ +#define __GPU_PRIMITIVE_H__ #include "GPU_common.h" typedef enum { - GWN_PRIM_POINTS, - GWN_PRIM_LINES, - GWN_PRIM_TRIS, - GWN_PRIM_LINE_STRIP, - GWN_PRIM_LINE_LOOP, /* GL has this, Vulkan does not */ - GWN_PRIM_TRI_STRIP, - GWN_PRIM_TRI_FAN, + GPU_PRIM_POINTS, + GPU_PRIM_LINES, + GPU_PRIM_TRIS, + GPU_PRIM_LINE_STRIP, + GPU_PRIM_LINE_LOOP, /* GL has this, Vulkan does not */ + GPU_PRIM_TRI_STRIP, + GPU_PRIM_TRI_FAN, - GWN_PRIM_LINES_ADJ, - GWN_PRIM_TRIS_ADJ, - GWN_PRIM_LINE_STRIP_ADJ, + GPU_PRIM_LINES_ADJ, + GPU_PRIM_TRIS_ADJ, + GPU_PRIM_LINE_STRIP_ADJ, - GWN_PRIM_NONE -} Gwn_PrimType; + GPU_PRIM_NONE +} GPUPrimType; /* what types of primitives does each shader expect? */ typedef enum { - GWN_PRIM_CLASS_NONE = 0, - GWN_PRIM_CLASS_POINT = (1 << 0), - GWN_PRIM_CLASS_LINE = (1 << 1), - GWN_PRIM_CLASS_SURFACE = (1 << 2), - GWN_PRIM_CLASS_ANY = GWN_PRIM_CLASS_POINT | GWN_PRIM_CLASS_LINE | GWN_PRIM_CLASS_SURFACE -} Gwn_PrimClass; + GPU_PRIM_CLASS_NONE = 0, + GPU_PRIM_CLASS_POINT = (1 << 0), + GPU_PRIM_CLASS_LINE = (1 << 1), + GPU_PRIM_CLASS_SURFACE = (1 << 2), + GPU_PRIM_CLASS_ANY = GPU_PRIM_CLASS_POINT | GPU_PRIM_CLASS_LINE | GPU_PRIM_CLASS_SURFACE +} GPUPrimClass; -Gwn_PrimClass GWN_primtype_class(Gwn_PrimType); -bool GWN_primtype_belongs_to_class(Gwn_PrimType, Gwn_PrimClass); +GPUPrimClass GPU_primtype_class(GPUPrimType); +bool GPU_primtype_belongs_to_class(GPUPrimType, GPUPrimClass); -#endif /* __GWN_PRIMITIVE_H__ */ +#endif /* __GPU_PRIMITIVE_H__ */ diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index 36842e9847a..c80cc1021ec 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -23,82 +23,82 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_shader_interface.h +/** \file blender/gpu/GPU_shader_interface.h * \ingroup gpu * - * Gawain shader interface (C --> GLSL) + * GPU shader interface (C --> GLSL) */ -#ifndef __GWN_SHADER_INTERFACE_H__ -#define __GWN_SHADER_INTERFACE_H__ +#ifndef __GPU_SHADER_INTERFACE_H__ +#define __GPU_SHADER_INTERFACE_H__ #include "GPU_common.h" typedef enum { - GWN_UNIFORM_NONE = 0, /* uninitialized/unknown */ + GPU_UNIFORM_NONE = 0, /* uninitialized/unknown */ - GWN_UNIFORM_MODEL, /* mat4 ModelMatrix */ - GWN_UNIFORM_VIEW, /* mat4 ViewMatrix */ - GWN_UNIFORM_MODELVIEW, /* mat4 ModelViewMatrix */ - GWN_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */ - GWN_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */ - GWN_UNIFORM_MVP, /* mat4 ModelViewProjectionMatrix */ + GPU_UNIFORM_MODEL, /* mat4 ModelMatrix */ + GPU_UNIFORM_VIEW, /* mat4 ViewMatrix */ + GPU_UNIFORM_MODELVIEW, /* mat4 ModelViewMatrix */ + GPU_UNIFORM_PROJECTION, /* mat4 ProjectionMatrix */ + GPU_UNIFORM_VIEWPROJECTION, /* mat4 ViewProjectionMatrix */ + GPU_UNIFORM_MVP, /* mat4 ModelViewProjectionMatrix */ - GWN_UNIFORM_MODEL_INV, /* mat4 ModelMatrixInverse */ - GWN_UNIFORM_VIEW_INV, /* mat4 ViewMatrixInverse */ - GWN_UNIFORM_MODELVIEW_INV, /* mat4 ModelViewMatrixInverse */ - GWN_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */ - GWN_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */ + GPU_UNIFORM_MODEL_INV, /* mat4 ModelMatrixInverse */ + GPU_UNIFORM_VIEW_INV, /* mat4 ViewMatrixInverse */ + GPU_UNIFORM_MODELVIEW_INV, /* mat4 ModelViewMatrixInverse */ + GPU_UNIFORM_PROJECTION_INV, /* mat4 ProjectionMatrixInverse */ + GPU_UNIFORM_VIEWPROJECTION_INV, /* mat4 ViewProjectionMatrixInverse */ - GWN_UNIFORM_NORMAL, /* mat3 NormalMatrix */ - GWN_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */ - GWN_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */ - GWN_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ + GPU_UNIFORM_NORMAL, /* mat3 NormalMatrix */ + GPU_UNIFORM_WORLDNORMAL, /* mat3 WorldNormalMatrix */ + GPU_UNIFORM_CAMERATEXCO, /* vec4 CameraTexCoFactors */ + GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ - GWN_UNIFORM_COLOR, /* vec4 color */ - GWN_UNIFORM_EYE, /* vec3 eye */ - GWN_UNIFORM_CALLID, /* int callId */ + GPU_UNIFORM_COLOR, /* vec4 color */ + GPU_UNIFORM_EYE, /* vec3 eye */ + GPU_UNIFORM_CALLID, /* int callId */ - GWN_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ + GPU_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ - GWN_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ -} Gwn_UniformBuiltin; + GPU_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ +} GPUUniformBuiltin; -typedef struct Gwn_ShaderInput { - struct Gwn_ShaderInput* next; +typedef struct GPUShaderInput { + struct GPUShaderInput* next; uint32_t name_offset; uint name_hash; - Gwn_UniformBuiltin builtin_type; /* only for uniform inputs */ + GPUUniformBuiltin builtin_type; /* only for uniform inputs */ uint32_t gl_type; /* only for attrib inputs */ int32_t size; /* only for attrib inputs */ int32_t location; -} Gwn_ShaderInput; +} GPUShaderInput; -#define GWN_NUM_SHADERINTERFACE_BUCKETS 257 -#define GWN_SHADERINTERFACE_REF_ALLOC_COUNT 16 +#define GPU_NUM_SHADERINTERFACE_BUCKETS 257 +#define GPU_SHADERINTERFACE_REF_ALLOC_COUNT 16 -typedef struct Gwn_ShaderInterface { +typedef struct GPUShaderInterface { int32_t program; uint32_t name_buffer_offset; - Gwn_ShaderInput* attrib_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; - Gwn_ShaderInput* uniform_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; - Gwn_ShaderInput* ubo_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]; - Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS]; + GPUShaderInput* attrib_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; + GPUShaderInput* uniform_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; + GPUShaderInput* ubo_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; + GPUShaderInput* builtin_uniforms[GPU_NUM_UNIFORMS]; char* name_buffer; - struct Gwn_Batch** batches; /* references to batches using this interface */ + struct GPUBatch** batches; /* references to batches using this interface */ uint batches_len; -} Gwn_ShaderInterface; +} GPUShaderInterface; -Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id); -void GWN_shaderinterface_discard(Gwn_ShaderInterface*); +GPUShaderInterface* GPU_shaderinterface_create(int32_t program_id); +void GPU_shaderinterface_discard(GPUShaderInterface*); -const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name); -const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin(const Gwn_ShaderInterface*, Gwn_UniformBuiltin); -const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface*, const char* name); -const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface*, const char* name); +const GPUShaderInput* GPU_shaderinterface_uniform(const GPUShaderInterface*, const char* name); +const GPUShaderInput* GPU_shaderinterface_uniform_builtin(const GPUShaderInterface*, GPUUniformBuiltin); +const GPUShaderInput* GPU_shaderinterface_ubo(const GPUShaderInterface*, const char* name); +const GPUShaderInput* GPU_shaderinterface_attr(const GPUShaderInterface*, const char* name); /* keep track of batches using this interface */ -void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); -void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface*, struct Gwn_Batch*); +void GPU_shaderinterface_add_batch_ref(GPUShaderInterface*, struct GPUBatch*); +void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface*, struct GPUBatch*); -#endif /* __GWN_SHADER_INTERFACE_H__ */ +#endif /* __GPU_SHADER_INTERFACE_H__ */ diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 3ed9014d431..e3db18f1358 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -41,7 +41,7 @@ extern "C" { struct Image; struct ImageUser; struct PreviewImage; -struct Gwn_VertBuf; +struct GPUVertBuf; struct GPUFrameBuffer; typedef struct GPUTexture GPUTexture; @@ -174,7 +174,7 @@ GPUTexture *GPU_texture_create_3D( GPUTexture *GPU_texture_create_cube( int w, GPUTextureFormat data_type, const float *pixels, char err_out[256]); GPUTexture *GPU_texture_create_from_vertbuf( - struct Gwn_VertBuf *vert); + struct GPUVertBuf *vert); GPUTexture *GPU_texture_create_buffer( GPUTextureFormat data_type, const uint buffer); diff --git a/source/blender/gpu/GPU_vertex_array_id.h b/source/blender/gpu/GPU_vertex_array_id.h index 925cd74511d..3b3fdc1709d 100644 --- a/source/blender/gpu/GPU_vertex_array_id.h +++ b/source/blender/gpu/GPU_vertex_array_id.h @@ -23,7 +23,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_array_id.h +/** \file blender/gpu/GPU_vertex_array_id.h * \ingroup gpu * * Manage GL vertex array IDs in a thread-safe way @@ -34,8 +34,8 @@ * - free can be called from any thread */ -#ifndef __GWN_VERTEX_ARRAY_ID_H__ -#define __GWN_VERTEX_ARRAY_ID_H__ +#ifndef __GPU_VERTEX_ARRAY_ID_H__ +#define __GPU_VERTEX_ARRAY_ID_H__ #ifdef __cplusplus extern "C" { @@ -44,12 +44,12 @@ extern "C" { #include "GPU_common.h" #include "GPU_context.h" -GLuint GWN_vao_default(void); -GLuint GWN_vao_alloc(void); -void GWN_vao_free(GLuint vao_id, Gwn_Context*); +GLuint GPU_vao_default(void); +GLuint GPU_vao_alloc(void); +void GPU_vao_free(GLuint vao_id, GPUContext*); #ifdef __cplusplus } #endif -#endif /* __GWN_VERTEX_ARRAY_ID_H__ */ +#endif /* __GPU_VERTEX_ARRAY_ID_H__ */ diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h index 7e4aa24ff2c..896de387065 100644 --- a/source/blender/gpu/GPU_vertex_buffer.h +++ b/source/blender/gpu/GPU_vertex_buffer.h @@ -23,73 +23,73 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_buffer.h +/** \file blender/gpu/GPU_vertex_buffer.h * \ingroup gpu * - * Gawain vertex buffer + * GPU vertex buffer */ -#ifndef __GWN_VERTEX_BUFFER_H__ -#define __GWN_VERTEX_BUFFER_H__ +#ifndef __GPU_VERTEX_BUFFER_H__ +#define __GPU_VERTEX_BUFFER_H__ #include "GPU_vertex_format.h" #define VRAM_USAGE 1 -/* How to create a Gwn_VertBuf: */ -/* 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts) */ -/* 2) GWN_vertformat_attr_add(verts->format, ...) */ -/* 3) GWN_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format */ -/* 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer) */ +/* How to create a GPUVertBuf: */ +/* 1) verts = GPU_vertbuf_create() or GPU_vertbuf_init(verts) */ +/* 2) GPU_vertformat_attr_add(verts->format, ...) */ +/* 3) GPU_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format */ +/* 4) GPU_vertbuf_attr_fill(verts, pos, application_pos_buffer) */ -/* Is Gwn_VertBuf always used as part of a Gwn_Batch? */ +/* Is GPUVertBuf always used as part of a GPUBatch? */ typedef enum { /* can be extended to support more types */ - GWN_USAGE_STREAM, - GWN_USAGE_STATIC, /* do not keep data in memory */ - GWN_USAGE_DYNAMIC -} Gwn_UsageType; + GPU_USAGE_STREAM, + GPU_USAGE_STATIC, /* do not keep data in memory */ + GPU_USAGE_DYNAMIC +} GPUUsageType; -typedef struct Gwn_VertBuf { - Gwn_VertFormat format; +typedef struct GPUVertBuf { + GPUVertFormat format; uint vertex_len; /* number of verts we want to draw */ uint vertex_alloc; /* number of verts data */ bool dirty; unsigned char* data; /* NULL indicates data in VRAM (unmapped) */ uint32_t vbo_id; /* 0 indicates not yet allocated */ - Gwn_UsageType usage; /* usage hint for GL optimisation */ -} Gwn_VertBuf; + GPUUsageType usage; /* usage hint for GL optimisation */ +} GPUVertBuf; -Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType); -Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat*, Gwn_UsageType); +GPUVertBuf* GPU_vertbuf_create(GPUUsageType); +GPUVertBuf* GPU_vertbuf_create_with_format_ex(const GPUVertFormat*, GPUUsageType); -#define GWN_vertbuf_create_with_format(format) \ - GWN_vertbuf_create_with_format_ex(format, GWN_USAGE_STATIC) +#define GPU_vertbuf_create_with_format(format) \ + GPU_vertbuf_create_with_format_ex(format, GPU_USAGE_STATIC) -void GWN_vertbuf_discard(Gwn_VertBuf*); +void GPU_vertbuf_discard(GPUVertBuf*); -void GWN_vertbuf_init(Gwn_VertBuf*, Gwn_UsageType); -void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf*, const Gwn_VertFormat*, Gwn_UsageType); +void GPU_vertbuf_init(GPUVertBuf*, GPUUsageType); +void GPU_vertbuf_init_with_format_ex(GPUVertBuf*, const GPUVertFormat*, GPUUsageType); -#define GWN_vertbuf_init_with_format(verts, format) \ - GWN_vertbuf_init_with_format_ex(verts, format, GWN_USAGE_STATIC) +#define GPU_vertbuf_init_with_format(verts, format) \ + GPU_vertbuf_init_with_format_ex(verts, format, GPU_USAGE_STATIC) -uint GWN_vertbuf_size_get(const Gwn_VertBuf*); -void GWN_vertbuf_data_alloc(Gwn_VertBuf*, uint v_len); -void GWN_vertbuf_data_resize(Gwn_VertBuf*, uint v_len); -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, uint v_len); +uint GPU_vertbuf_size_get(const GPUVertBuf*); +void GPU_vertbuf_data_alloc(GPUVertBuf*, uint v_len); +void GPU_vertbuf_data_resize(GPUVertBuf*, uint v_len); +void GPU_vertbuf_vertex_count_set(GPUVertBuf*, uint v_len); /* The most important set_attrib variant is the untyped one. Get it right first. */ /* It takes a void* so the app developer is responsible for matching their app data types */ /* to the vertex attribute's type and component count. They're in control of both, so this */ /* should not be a problem. */ -void GWN_vertbuf_attr_set(Gwn_VertBuf*, uint a_idx, uint v_idx, const void* data); -void GWN_vertbuf_attr_fill(Gwn_VertBuf*, uint a_idx, const void* data); /* tightly packed, non interleaved input data */ -void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, uint a_idx, uint stride, const void* data); +void GPU_vertbuf_attr_set(GPUVertBuf*, uint a_idx, uint v_idx, const void* data); +void GPU_vertbuf_attr_fill(GPUVertBuf*, uint a_idx, const void* data); /* tightly packed, non interleaved input data */ +void GPU_vertbuf_attr_fill_stride(GPUVertBuf*, uint a_idx, uint stride, const void* data); /* For low level access only */ -typedef struct Gwn_VertBufRaw { +typedef struct GPUVertBufRaw { uint size; uint stride; unsigned char* data; @@ -98,9 +98,9 @@ typedef struct Gwn_VertBufRaw { /* Only for overflow check */ unsigned char* _data_end; #endif -} Gwn_VertBufRaw; +} GPUVertBufRaw; -GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a) +GPU_INLINE void *GPU_vertbuf_raw_step(GPUVertBufRaw *a) { unsigned char* data = a->data; a->data += a->stride; @@ -110,12 +110,12 @@ GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a) return (void *)data; } -GWN_INLINE uint GWN_vertbuf_raw_used(Gwn_VertBufRaw *a) +GPU_INLINE uint GPU_vertbuf_raw_used(GPUVertBufRaw *a) { return ((a->data - a->data_init) / a->stride); } -void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, uint a_idx, Gwn_VertBufRaw *access); +void GPU_vertbuf_attr_get_raw_data(GPUVertBuf*, uint a_idx, GPUVertBufRaw *access); /* TODO: decide whether to keep the functions below */ /* doesn't immediate mode satisfy these needs? */ @@ -128,17 +128,17 @@ void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf*, uint a_idx, Gwn_VertBufRaw *acc /* void setAttrib3ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b); */ /* void setAttrib4ub(unsigned a_idx, unsigned v_idx, unsigned char r, unsigned char g, unsigned char b, unsigned char a); */ -void GWN_vertbuf_use(Gwn_VertBuf*); +void GPU_vertbuf_use(GPUVertBuf*); /* Metrics */ -uint GWN_vertbuf_get_memory_usage(void); +uint GPU_vertbuf_get_memory_usage(void); /* Macros */ -#define GWN_VERTBUF_DISCARD_SAFE(verts) do { \ +#define GPU_VERTBUF_DISCARD_SAFE(verts) do { \ if (verts != NULL) { \ - GWN_vertbuf_discard(verts); \ + GPU_vertbuf_discard(verts); \ verts = NULL; \ } \ } while (0) -#endif /* __GWN_VERTEX_BUFFER_H__ */ +#endif /* __GPU_VERTEX_BUFFER_H__ */ diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 91e31b5ece4..7ae8118a928 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -23,79 +23,79 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_format.h +/** \file blender/gpu/GPU_vertex_format.h * \ingroup gpu * - * Gawain vertex format + * GPU vertex format */ -#ifndef __GWN_VERTEX_FORMAT_H__ -#define __GWN_VERTEX_FORMAT_H__ +#ifndef __GPU_VERTEX_FORMAT_H__ +#define __GPU_VERTEX_FORMAT_H__ #include "GPU_common.h" -#define GWN_VERT_ATTR_MAX_LEN 16 -#define GWN_VERT_ATTR_MAX_NAMES 3 -#define GWN_VERT_ATTR_NAME_AVERAGE_LEN 11 -#define GWN_VERT_ATTR_NAMES_BUF_LEN ((GWN_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GWN_VERT_ATTR_MAX_LEN) +#define GPU_VERT_ATTR_MAX_LEN 16 +#define GPU_VERT_ATTR_MAX_NAMES 3 +#define GPU_VERT_ATTR_NAME_AVERAGE_LEN 11 +#define GPU_VERT_ATTR_NAMES_BUF_LEN ((GPU_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GPU_VERT_ATTR_MAX_LEN) typedef enum { - GWN_COMP_I8, - GWN_COMP_U8, - GWN_COMP_I16, - GWN_COMP_U16, - GWN_COMP_I32, - GWN_COMP_U32, + GPU_COMP_I8, + GPU_COMP_U8, + GPU_COMP_I16, + GPU_COMP_U16, + GPU_COMP_I32, + GPU_COMP_U32, - GWN_COMP_F32, + GPU_COMP_F32, - GWN_COMP_I10 -} Gwn_VertCompType; + GPU_COMP_I10 +} GPUVertCompType; typedef enum { - GWN_FETCH_FLOAT, - GWN_FETCH_INT, - GWN_FETCH_INT_TO_FLOAT_UNIT, /* 127 (ubyte) -> 0.5 (and so on for other int types) */ - GWN_FETCH_INT_TO_FLOAT /* 127 (any int type) -> 127.0 */ -} Gwn_VertFetchMode; - -typedef struct Gwn_VertAttr { - Gwn_VertFetchMode fetch_mode; - Gwn_VertCompType comp_type; + GPU_FETCH_FLOAT, + GPU_FETCH_INT, + GPU_FETCH_INT_TO_FLOAT_UNIT, /* 127 (ubyte) -> 0.5 (and so on for other int types) */ + GPU_FETCH_INT_TO_FLOAT /* 127 (any int type) -> 127.0 */ +} GPUVertFetchMode; + +typedef struct GPUVertAttr { + GPUVertFetchMode fetch_mode; + GPUVertCompType comp_type; uint gl_comp_type; uint comp_len; /* 1 to 4 or 8 or 12 or 16 */ uint sz; /* size in bytes, 1 to 64 */ uint offset; /* from beginning of vertex, in bytes */ - uint name_len; /* up to GWN_VERT_ATTR_MAX_NAMES */ - const char* name[GWN_VERT_ATTR_MAX_NAMES]; -} Gwn_VertAttr; + uint name_len; /* up to GPU_VERT_ATTR_MAX_NAMES */ + const char* name[GPU_VERT_ATTR_MAX_NAMES]; +} GPUVertAttr; -typedef struct Gwn_VertFormat { - uint attr_len; /* 0 to 16 (GWN_VERT_ATTR_MAX_LEN) */ +typedef struct GPUVertFormat { + uint attr_len; /* 0 to 16 (GPU_VERT_ATTR_MAX_LEN) */ uint name_len; /* total count of active vertex attrib */ uint stride; /* stride in bytes, 1 to 256 */ uint name_offset; bool packed; - char names[GWN_VERT_ATTR_NAMES_BUF_LEN]; - Gwn_VertAttr attribs[GWN_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */ -} Gwn_VertFormat; + char names[GPU_VERT_ATTR_NAMES_BUF_LEN]; + GPUVertAttr attribs[GPU_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */ +} GPUVertFormat; -void GWN_vertformat_clear(Gwn_VertFormat*); -void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src); +void GPU_vertformat_clear(GPUVertFormat*); +void GPU_vertformat_copy(GPUVertFormat* dest, const GPUVertFormat* src); -uint GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, uint comp_len, Gwn_VertFetchMode); -void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias); +uint GPU_vertformat_attr_add(GPUVertFormat*, const char* name, GPUVertCompType, uint comp_len, GPUVertFetchMode); +void GPU_vertformat_alias_add(GPUVertFormat*, const char* alias); /* format conversion */ -typedef struct Gwn_PackedNormal { +typedef struct GPUPackedNormal { int x : 10; int y : 10; int z : 10; int w : 2; /* 0 by default, can manually set to { -2, -1, 0, 1 } */ -} Gwn_PackedNormal; +} GPUPackedNormal; -Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]); -Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]); +GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3]); +GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3]); -#endif /* __GWN_VERTEX_FORMAT_H__ */ +#endif /* __GPU_VERTEX_FORMAT_H__ */ diff --git a/source/blender/gpu/intern/gpu_attr_binding.c b/source/blender/gpu/intern/gpu_attr_binding.c index e7eba369335..9ac38578792 100644 --- a/source/blender/gpu/intern/gpu_attr_binding.c +++ b/source/blender/gpu/intern/gpu_attr_binding.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_attr_binding.c +/** \file blender/gpu/intern/gpu_attr_binding.c * \ingroup gpu * - * Gawain vertex attribute binding + * GPU vertex attribute binding */ #include "GPU_attr_binding.h" @@ -34,30 +34,30 @@ #include #include -#if GWN_VERT_ATTR_MAX_LEN != 16 - #error "attrib binding code assumes GWN_VERT_ATTR_MAX_LEN = 16" +#if GPU_VERT_ATTR_MAX_LEN != 16 + #error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16" #endif -void AttribBinding_clear(Gwn_AttrBinding* binding) +void AttribBinding_clear(GPUAttrBinding* binding) { binding->loc_bits = 0; binding->enabled_bits = 0; } -uint read_attrib_location(const Gwn_AttrBinding* binding, uint a_idx) +uint read_attrib_location(const GPUAttrBinding* binding, uint a_idx) { #if TRUST_NO_ONE - assert(a_idx < GWN_VERT_ATTR_MAX_LEN); + assert(a_idx < GPU_VERT_ATTR_MAX_LEN); assert(binding->enabled_bits & (1 << a_idx)); #endif return (binding->loc_bits >> (4 * a_idx)) & 0xF; } -static void write_attrib_location(Gwn_AttrBinding* binding, uint a_idx, uint location) +static void write_attrib_location(GPUAttrBinding* binding, uint a_idx, uint location) { #if TRUST_NO_ONE - assert(a_idx < GWN_VERT_ATTR_MAX_LEN); - assert(location < GWN_VERT_ATTR_MAX_LEN); + assert(a_idx < GPU_VERT_ATTR_MAX_LEN); + assert(location < GPU_VERT_ATTR_MAX_LEN); #endif const uint shift = 4 * a_idx; const uint64_t mask = ((uint64_t)0xF) << shift; @@ -67,14 +67,14 @@ static void write_attrib_location(Gwn_AttrBinding* binding, uint a_idx, uint loc binding->enabled_bits |= 1 << a_idx; } -void get_attrib_locations(const Gwn_VertFormat* format, Gwn_AttrBinding* binding, const Gwn_ShaderInterface* shaderface) +void get_attrib_locations(const GPUVertFormat* format, GPUAttrBinding* binding, const GPUShaderInterface* shaderface) { AttribBinding_clear(binding); for (uint a_idx = 0; a_idx < format->attr_len; ++a_idx) { - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertAttr* a = format->attribs + a_idx; for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { - const Gwn_ShaderInput* input = GWN_shaderinterface_attr(shaderface, a->name[n_idx]); + const GPUShaderInput* input = GPU_shaderinterface_attr(shaderface, a->name[n_idx]); #if TRUST_NO_ONE assert(input != NULL); /* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */ diff --git a/source/blender/gpu/intern/gpu_attr_binding_private.h b/source/blender/gpu/intern/gpu_attr_binding_private.h index 0e0bf89178a..240509de0d4 100644 --- a/source/blender/gpu/intern/gpu_attr_binding_private.h +++ b/source/blender/gpu/intern/gpu_attr_binding_private.h @@ -23,21 +23,21 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_attr_binding_private.h +/** \file blender/gpu/intern/gpu_attr_binding_private.h * \ingroup gpu * - * Gawain vertex attribute binding + * GPU vertex attribute binding */ -#ifndef __GWN_ATTR_BINDING_PRIVATE_H__ -#define __GWN_ATTR_BINDING_PRIVATE_H__ +#ifndef __GPU_ATTR_BINDING_PRIVATE_H__ +#define __GPU_ATTR_BINDING_PRIVATE_H__ #include "GPU_vertex_format.h" #include "GPU_shader_interface.h" -void AttribBinding_clear(Gwn_AttrBinding*); +void AttribBinding_clear(GPUAttrBinding*); -void get_attrib_locations(const Gwn_VertFormat*, Gwn_AttrBinding*, const Gwn_ShaderInterface*); -unsigned read_attrib_location(const Gwn_AttrBinding*, unsigned a_idx); +void get_attrib_locations(const GPUVertFormat*, GPUAttrBinding*, const GPUShaderInterface*); +unsigned read_attrib_location(const GPUAttrBinding*, unsigned a_idx); -#endif /* __GWN_ATTR_BINDING_PRIVATE_H__ */ +#endif /* __GPU_ATTR_BINDING_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 90f30930884..4d455f6f464 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_batch.c +/** \file blender/gpu/intern/gpu_batch.c * \ingroup gpu * - * Gawain geometry batch + * GPU geometry batch * Contains VAOs + VBOs + Shader representing a drawable entity. */ @@ -44,9 +44,9 @@ #include #include -static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first); +static void batch_update_program_bindings(GPUBatch* batch, uint v_first); -void gwn_batch_vao_cache_clear(Gwn_Batch* batch) +void GPU_batch_vao_cache_clear(GPUBatch* batch) { if (batch->context == NULL) { return; @@ -54,45 +54,45 @@ void gwn_batch_vao_cache_clear(Gwn_Batch* batch) if (batch->is_dynamic_vao_count) { for (int i = 0; i < batch->dynamic_vaos.count; ++i) { if (batch->dynamic_vaos.vao_ids[i]) { - GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); + GPU_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); } if (batch->dynamic_vaos.interfaces[i]) { - GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->dynamic_vaos.interfaces[i], batch); + GPU_shaderinterface_remove_batch_ref((GPUShaderInterface *)batch->dynamic_vaos.interfaces[i], batch); } } free(batch->dynamic_vaos.interfaces); free(batch->dynamic_vaos.vao_ids); } else { - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) { if (batch->static_vaos.vao_ids[i]) { - GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); + GPU_vao_free(batch->static_vaos.vao_ids[i], batch->context); } if (batch->static_vaos.interfaces[i]) { - GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface *)batch->static_vaos.interfaces[i], batch); + GPU_shaderinterface_remove_batch_ref((GPUShaderInterface *)batch->static_vaos.interfaces[i], batch); } } } batch->is_dynamic_vao_count = false; - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) { batch->static_vaos.vao_ids[i] = 0; batch->static_vaos.interfaces[i] = NULL; } - gwn_context_remove_batch(batch->context, batch); + gpu_context_remove_batch(batch->context, batch); batch->context = NULL; } -Gwn_Batch* GWN_batch_create_ex( - Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, +GPUBatch* GPU_batch_create_ex( + GPUPrimType prim_type, GPUVertBuf* verts, GPUIndexBuf* elem, uint owns_flag) { - Gwn_Batch* batch = calloc(1, sizeof(Gwn_Batch)); - GWN_batch_init_ex(batch, prim_type, verts, elem, owns_flag); + GPUBatch* batch = calloc(1, sizeof(GPUBatch)); + GPU_batch_init_ex(batch, prim_type, verts, elem, owns_flag); return batch; } -void GWN_batch_init_ex( - Gwn_Batch* batch, Gwn_PrimType prim_type, Gwn_VertBuf* verts, Gwn_IndexBuf* elem, +void GPU_batch_init_ex( + GPUBatch* batch, GPUPrimType prim_type, GPUVertBuf* verts, GPUIndexBuf* elem, uint owns_flag) { #if TRUST_NO_ONE @@ -100,49 +100,49 @@ void GWN_batch_init_ex( #endif batch->verts[0] = verts; - for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; ++v) { batch->verts[v] = NULL; } batch->inst = NULL; batch->elem = elem; batch->gl_prim_type = convert_prim_type_to_gl(prim_type); - batch->phase = GWN_BATCH_READY_TO_DRAW; + batch->phase = GPU_BATCH_READY_TO_DRAW; batch->is_dynamic_vao_count = false; batch->owns_flag = owns_flag; batch->free_callback = NULL; } /* This will share the VBOs with the new batch. */ -Gwn_Batch* GWN_batch_duplicate(Gwn_Batch* batch_src) +GPUBatch* GPU_batch_duplicate(GPUBatch* batch_src) { - Gwn_Batch* batch = GWN_batch_create_ex(GWN_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); + GPUBatch* batch = GPU_batch_create_ex(GPU_PRIM_POINTS, batch_src->verts[0], batch_src->elem, 0); batch->gl_prim_type = batch_src->gl_prim_type; - for (int v = 1; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; ++v) { batch->verts[v] = batch_src->verts[v]; } return batch; } -void GWN_batch_discard(Gwn_Batch* batch) +void GPU_batch_discard(GPUBatch* batch) { - if (batch->owns_flag & GWN_BATCH_OWNS_INDEX) { - GWN_indexbuf_discard(batch->elem); + if (batch->owns_flag & GPU_BATCH_OWNS_INDEX) { + GPU_indexbuf_discard(batch->elem); } - if (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES) { - GWN_vertbuf_discard(batch->inst); + if (batch->owns_flag & GPU_BATCH_OWNS_INSTANCES) { + GPU_vertbuf_discard(batch->inst); } - if ((batch->owns_flag & ~GWN_BATCH_OWNS_INDEX) != 0) { - for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + if ((batch->owns_flag & ~GPU_BATCH_OWNS_INDEX) != 0) { + for (int v = 0; v < GPU_BATCH_VBO_MAX_LEN; ++v) { if (batch->verts[v] == NULL) { break; } if (batch->owns_flag & (1 << v)) { - GWN_vertbuf_discard(batch->verts[v]); + GPU_vertbuf_discard(batch->verts[v]); } } } - gwn_batch_vao_cache_clear(batch); + GPU_batch_vao_cache_clear(batch); if (batch->free_callback) { batch->free_callback(batch, batch->callback_data); @@ -150,42 +150,42 @@ void GWN_batch_discard(Gwn_Batch* batch) free(batch); } -void GWN_batch_callback_free_set(Gwn_Batch* batch, void (*callback)(Gwn_Batch*, void*), void* user_data) +void GPU_batch_callback_free_set(GPUBatch* batch, void (*callback)(GPUBatch*, void*), void* user_data) { batch->free_callback = callback; batch->callback_data = user_data; } -void GWN_batch_instbuf_set(Gwn_Batch* batch, Gwn_VertBuf* inst, bool own_vbo) +void GPU_batch_instbuf_set(GPUBatch* batch, GPUVertBuf* inst, bool own_vbo) { #if TRUST_NO_ONE assert(inst != NULL); #endif /* redo the bindings */ - gwn_batch_vao_cache_clear(batch); + GPU_batch_vao_cache_clear(batch); - if (batch->inst != NULL && (batch->owns_flag & GWN_BATCH_OWNS_INSTANCES)) { - GWN_vertbuf_discard(batch->inst); + if (batch->inst != NULL && (batch->owns_flag & GPU_BATCH_OWNS_INSTANCES)) { + GPU_vertbuf_discard(batch->inst); } batch->inst = inst; if (own_vbo) { - batch->owns_flag |= GWN_BATCH_OWNS_INSTANCES; + batch->owns_flag |= GPU_BATCH_OWNS_INSTANCES; } else { - batch->owns_flag &= ~GWN_BATCH_OWNS_INSTANCES; + batch->owns_flag &= ~GPU_BATCH_OWNS_INSTANCES; } } /* Returns the index of verts in the batch. */ -int GWN_batch_vertbuf_add_ex( - Gwn_Batch* batch, Gwn_VertBuf* verts, +int GPU_batch_vertbuf_add_ex( + GPUBatch* batch, GPUVertBuf* verts, bool own_vbo) { /* redo the bindings */ - gwn_batch_vao_cache_clear(batch); + GPU_batch_vao_cache_clear(batch); - for (uint v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) { + for (uint v = 0; v < GPU_BATCH_VBO_MAX_LEN; ++v) { if (batch->verts[v] == NULL) { #if TRUST_NO_ONE /* for now all VertexBuffers must have same vertex_len */ @@ -199,14 +199,14 @@ int GWN_batch_vertbuf_add_ex( } } - /* we only make it this far if there is no room for another Gwn_VertBuf */ + /* we only make it this far if there is no room for another GPUVertBuf */ #if TRUST_NO_ONE assert(false); #endif return -1; } -static GLuint batch_vao_get(Gwn_Batch *batch) +static GLuint batch_vao_get(GPUBatch *batch) { /* Search through cache */ if (batch->is_dynamic_vao_count) { @@ -215,22 +215,22 @@ static GLuint batch_vao_get(Gwn_Batch *batch) return batch->dynamic_vaos.vao_ids[i]; } else { - for (int i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) + for (int i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) if (batch->static_vaos.interfaces[i] == batch->interface) return batch->static_vaos.vao_ids[i]; } /* Set context of this batch. - * It will be bound to it until gwn_batch_vao_cache_clear is called. + * It will be bound to it until GPU_batch_vao_cache_clear is called. * Until then it can only be drawn with this context. */ if (batch->context == NULL) { - batch->context = GWN_context_active_get(); - gwn_context_add_batch(batch->context, batch); + batch->context = GPU_context_active_get(); + gpu_context_add_batch(batch->context, batch); } #if TRUST_NO_ONE else { /* Make sure you are not trying to draw this batch in another context. */ - assert(batch->context == GWN_context_active_get()); + assert(batch->context == GPU_context_active_get()); } #endif @@ -238,25 +238,25 @@ static GLuint batch_vao_get(Gwn_Batch *batch) GLuint new_vao = 0; if (!batch->is_dynamic_vao_count) { int i; /* find first unused slot */ - for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) + for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) if (batch->static_vaos.vao_ids[i] == 0) break; - if (i < GWN_BATCH_VAO_STATIC_LEN) { + if (i < GPU_BATCH_VAO_STATIC_LEN) { batch->static_vaos.interfaces[i] = batch->interface; - batch->static_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); + batch->static_vaos.vao_ids[i] = new_vao = GPU_vao_alloc(); } else { /* Not enough place switch to dynamic. */ batch->is_dynamic_vao_count = true; /* Erase previous entries, they will be added back if drawn again. */ - for (int j = 0; j < GWN_BATCH_VAO_STATIC_LEN; ++j) { - GWN_shaderinterface_remove_batch_ref((Gwn_ShaderInterface*)batch->static_vaos.interfaces[j], batch); - GWN_vao_free(batch->static_vaos.vao_ids[j], batch->context); + for (int j = 0; j < GPU_BATCH_VAO_STATIC_LEN; ++j) { + GPU_shaderinterface_remove_batch_ref((GPUShaderInterface*)batch->static_vaos.interfaces[j], batch); + GPU_vao_free(batch->static_vaos.vao_ids[j], batch->context); } /* Init dynamic arrays and let the branch below set the values. */ - batch->dynamic_vaos.count = GWN_BATCH_VAO_DYN_ALLOC_COUNT; - batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(Gwn_ShaderInterface*)); + batch->dynamic_vaos.count = GPU_BATCH_VAO_DYN_ALLOC_COUNT; + batch->dynamic_vaos.interfaces = calloc(batch->dynamic_vaos.count, sizeof(GPUShaderInterface*)); batch->dynamic_vaos.vao_ids = calloc(batch->dynamic_vaos.count, sizeof(GLuint)); } } @@ -270,17 +270,17 @@ static GLuint batch_vao_get(Gwn_Batch *batch) if (i == batch->dynamic_vaos.count) { /* Not enough place, realloc the array. */ i = batch->dynamic_vaos.count; - batch->dynamic_vaos.count += GWN_BATCH_VAO_DYN_ALLOC_COUNT; - batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(Gwn_ShaderInterface*) * batch->dynamic_vaos.count); + batch->dynamic_vaos.count += GPU_BATCH_VAO_DYN_ALLOC_COUNT; + batch->dynamic_vaos.interfaces = realloc(batch->dynamic_vaos.interfaces, sizeof(GPUShaderInterface*) * batch->dynamic_vaos.count); batch->dynamic_vaos.vao_ids = realloc(batch->dynamic_vaos.vao_ids, sizeof(GLuint) * batch->dynamic_vaos.count); - memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(Gwn_ShaderInterface*) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); - memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GWN_BATCH_VAO_DYN_ALLOC_COUNT); + memset(batch->dynamic_vaos.interfaces + i, 0, sizeof(GPUShaderInterface*) * GPU_BATCH_VAO_DYN_ALLOC_COUNT); + memset(batch->dynamic_vaos.vao_ids + i, 0, sizeof(GLuint) * GPU_BATCH_VAO_DYN_ALLOC_COUNT); } batch->dynamic_vaos.interfaces[i] = batch->interface; - batch->dynamic_vaos.vao_ids[i] = new_vao = GWN_vao_alloc(); + batch->dynamic_vaos.vao_ids[i] = new_vao = GPU_vao_alloc(); } - GWN_shaderinterface_add_batch_ref((Gwn_ShaderInterface*)batch->interface, batch); + GPU_shaderinterface_add_batch_ref((GPUShaderInterface*)batch->interface, batch); #if TRUST_NO_ONE assert(new_vao != 0); @@ -294,7 +294,7 @@ static GLuint batch_vao_get(Gwn_Batch *batch) return new_vao; } -void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) +void GPU_batch_program_set_no_use(GPUBatch* batch, uint32_t program, const GPUShaderInterface* shaderface) { #if TRUST_NO_ONE assert(glIsProgram(shaderface->program)); @@ -305,18 +305,18 @@ void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ batch->vao_id = batch_vao_get(batch); } -void GWN_batch_program_set(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface) +void GPU_batch_program_set(GPUBatch* batch, uint32_t program, const GPUShaderInterface* shaderface) { - GWN_batch_program_set_no_use(batch, program, shaderface); - GWN_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */ + GPU_batch_program_set_no_use(batch, program, shaderface); + GPU_batch_program_use_begin(batch); /* hack! to make Batch_Uniform* simpler */ } -void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* interface) +void gpu_batch_remove_interface_ref(GPUBatch* batch, const GPUShaderInterface* interface) { if (batch->is_dynamic_vao_count) { for (int i = 0; i < batch->dynamic_vaos.count; ++i) { if (batch->dynamic_vaos.interfaces[i] == interface) { - GWN_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); + GPU_vao_free(batch->dynamic_vaos.vao_ids[i], batch->context); batch->dynamic_vaos.vao_ids[i] = 0; batch->dynamic_vaos.interfaces[i] = NULL; break; /* cannot have duplicates */ @@ -325,9 +325,9 @@ void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* } else { int i; - for (i = 0; i < GWN_BATCH_VAO_STATIC_LEN; ++i) { + for (i = 0; i < GPU_BATCH_VAO_STATIC_LEN; ++i) { if (batch->static_vaos.interfaces[i] == interface) { - GWN_vao_free(batch->static_vaos.vao_ids[i], batch->context); + GPU_vao_free(batch->static_vaos.vao_ids[i], batch->context); batch->static_vaos.vao_ids[i] = 0; batch->static_vaos.interfaces[i] = NULL; break; /* cannot have duplicates */ @@ -337,28 +337,28 @@ void gwn_batch_remove_interface_ref(Gwn_Batch* batch, const Gwn_ShaderInterface* } static void create_bindings( - Gwn_VertBuf* verts, const Gwn_ShaderInterface* interface, + GPUVertBuf* verts, const GPUShaderInterface* interface, uint v_first, const bool use_instancing) { - const Gwn_VertFormat* format = &verts->format; + const GPUVertFormat* format = &verts->format; const uint attr_len = format->attr_len; const uint stride = format->stride; - GWN_vertbuf_use(verts); + GPU_vertbuf_use(verts); for (uint a_idx = 0; a_idx < attr_len; ++a_idx) { - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertAttr* a = format->attribs + a_idx; const GLvoid* pointer = (const GLubyte*)0 + a->offset + v_first * stride; for (uint n_idx = 0; n_idx < a->name_len; ++n_idx) { - const Gwn_ShaderInput* input = GWN_shaderinterface_attr(interface, a->name[n_idx]); + const GPUShaderInput* input = GPU_shaderinterface_attr(interface, a->name[n_idx]); if (input == NULL) continue; if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) { #if TRUST_NO_ONE - assert(a->fetch_mode == GWN_FETCH_FLOAT); + assert(a->fetch_mode == GPU_FETCH_FLOAT); assert(a->gl_comp_type == GL_FLOAT); #endif for (int i = 0; i < a->comp_len / 4; ++i) { @@ -374,14 +374,14 @@ static void create_bindings( glVertexAttribDivisor(input->location, (use_instancing) ? 1 : 0); switch (a->fetch_mode) { - case GWN_FETCH_FLOAT: - case GWN_FETCH_INT_TO_FLOAT: + case GPU_FETCH_FLOAT: + case GPU_FETCH_INT_TO_FLOAT: glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); break; - case GWN_FETCH_INT_TO_FLOAT_UNIT: + case GPU_FETCH_INT_TO_FLOAT_UNIT: glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); break; - case GWN_FETCH_INT: + case GPU_FETCH_INT: glVertexAttribIPointer(input->location, a->comp_len, a->gl_comp_type, stride, pointer); break; } @@ -390,20 +390,20 @@ static void create_bindings( } } -static void batch_update_program_bindings(Gwn_Batch* batch, uint v_first) +static void batch_update_program_bindings(GPUBatch* batch, uint v_first) { - for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) { + for (int v = 0; v < GPU_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) { create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false); } if (batch->inst) { create_bindings(batch->inst, batch->interface, v_first, true); } if (batch->elem) { - GWN_indexbuf_use(batch->elem); + GPU_indexbuf_use(batch->elem); } } -void GWN_batch_program_use_begin(Gwn_Batch* batch) +void GPU_batch_program_use_begin(GPUBatch* batch) { /* NOTE: use_program & done_using_program are fragile, depend on staying in sync with * the GL context's active program. use_program doesn't mark other programs as "not used". */ @@ -415,7 +415,7 @@ void GWN_batch_program_use_begin(Gwn_Batch* batch) } } -void GWN_batch_program_use_end(Gwn_Batch* batch) +void GPU_batch_program_use_end(GPUBatch* batch) { if (batch->program_in_use) { #if PROGRAM_NO_OPTI @@ -426,99 +426,99 @@ void GWN_batch_program_use_end(Gwn_Batch* batch) } #if TRUST_NO_ONE - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); assert(uniform); + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(batch->interface, name); assert(uniform); #else - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(batch->interface, name); + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(batch->interface, name); #endif -void GWN_batch_uniform_1ui(Gwn_Batch* batch, const char* name, int value) +void GPU_batch_uniform_1ui(GPUBatch* batch, const char* name, int value) { GET_UNIFORM glUniform1ui(uniform->location, value); } -void GWN_batch_uniform_1i(Gwn_Batch* batch, const char* name, int value) +void GPU_batch_uniform_1i(GPUBatch* batch, const char* name, int value) { GET_UNIFORM glUniform1i(uniform->location, value); } -void GWN_batch_uniform_1b(Gwn_Batch* batch, const char* name, bool value) +void GPU_batch_uniform_1b(GPUBatch* batch, const char* name, bool value) { GET_UNIFORM glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE); } -void GWN_batch_uniform_2f(Gwn_Batch* batch, const char* name, float x, float y) +void GPU_batch_uniform_2f(GPUBatch* batch, const char* name, float x, float y) { GET_UNIFORM glUniform2f(uniform->location, x, y); } -void GWN_batch_uniform_3f(Gwn_Batch* batch, const char* name, float x, float y, float z) +void GPU_batch_uniform_3f(GPUBatch* batch, const char* name, float x, float y, float z) { GET_UNIFORM glUniform3f(uniform->location, x, y, z); } -void GWN_batch_uniform_4f(Gwn_Batch* batch, const char* name, float x, float y, float z, float w) +void GPU_batch_uniform_4f(GPUBatch* batch, const char* name, float x, float y, float z, float w) { GET_UNIFORM glUniform4f(uniform->location, x, y, z, w); } -void GWN_batch_uniform_1f(Gwn_Batch* batch, const char* name, float x) +void GPU_batch_uniform_1f(GPUBatch* batch, const char* name, float x) { GET_UNIFORM glUniform1f(uniform->location, x); } -void GWN_batch_uniform_2fv(Gwn_Batch* batch, const char* name, const float data[2]) +void GPU_batch_uniform_2fv(GPUBatch* batch, const char* name, const float data[2]) { GET_UNIFORM glUniform2fv(uniform->location, 1, data); } -void GWN_batch_uniform_3fv(Gwn_Batch* batch, const char* name, const float data[3]) +void GPU_batch_uniform_3fv(GPUBatch* batch, const char* name, const float data[3]) { GET_UNIFORM glUniform3fv(uniform->location, 1, data); } -void GWN_batch_uniform_4fv(Gwn_Batch* batch, const char* name, const float data[4]) +void GPU_batch_uniform_4fv(GPUBatch* batch, const char* name, const float data[4]) { GET_UNIFORM glUniform4fv(uniform->location, 1, data); } -void GWN_batch_uniform_2fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) +void GPU_batch_uniform_2fv_array(GPUBatch* batch, const char* name, const int len, const float *data) { GET_UNIFORM glUniform2fv(uniform->location, len, data); } -void GWN_batch_uniform_4fv_array(Gwn_Batch* batch, const char* name, const int len, const float *data) +void GPU_batch_uniform_4fv_array(GPUBatch* batch, const char* name, const int len, const float *data) { GET_UNIFORM glUniform4fv(uniform->location, len, data); } -void GWN_batch_uniform_mat4(Gwn_Batch* batch, const char* name, const float data[4][4]) +void GPU_batch_uniform_mat4(GPUBatch* batch, const char* name, const float data[4][4]) { GET_UNIFORM glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (const float *)data); } -static void primitive_restart_enable(const Gwn_IndexBuf *el) +static void primitive_restart_enable(const GPUIndexBuf *el) { // TODO(fclem) Replace by GL_PRIMITIVE_RESTART_FIXED_INDEX when we have ogl 4.3 glEnable(GL_PRIMITIVE_RESTART); GLuint restart_index = (GLuint)0xFFFFFFFF; -#if GWN_TRACK_INDEX_RANGE - if (el->index_type == GWN_INDEX_U8) +#if GPU_TRACK_INDEX_RANGE + if (el->index_type == GPU_INDEX_U8) restart_index = (GLuint)0xFF; - else if (el->index_type == GWN_INDEX_U16) + else if (el->index_type == GPU_INDEX_U16) restart_index = (GLuint)0xFFFF; #endif @@ -530,21 +530,21 @@ static void primitive_restart_disable(void) glDisable(GL_PRIMITIVE_RESTART); } -void GWN_batch_draw(Gwn_Batch* batch) +void GPU_batch_draw(GPUBatch* batch) { #if TRUST_NO_ONE - assert(batch->phase == GWN_BATCH_READY_TO_DRAW); + assert(batch->phase == GPU_BATCH_READY_TO_DRAW); assert(batch->verts[0]->vbo_id != 0); #endif - GWN_batch_program_use_begin(batch); + GPU_batch_program_use_begin(batch); GPU_matrix_bind(batch->interface); // external call. - GWN_batch_draw_range_ex(batch, 0, 0, false); + GPU_batch_draw_range_ex(batch, 0, 0, false); - GWN_batch_program_use_end(batch); + GPU_batch_program_use_end(batch); } -void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool force_instance) +void GPU_batch_draw_range_ex(GPUBatch* batch, int v_first, int v_count, bool force_instance) { #if TRUST_NO_ONE assert(!(force_instance && (batch->inst == NULL)) || v_count > 0); // we cannot infer length if force_instance @@ -553,7 +553,7 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo // If using offset drawing, use the default VAO and redo bindings. if (v_first != 0 && (do_instance || batch->elem)) { - glBindVertexArray(GWN_vao_default()); + glBindVertexArray(GPU_vao_default()); batch_update_program_bindings(batch, v_first); } else { @@ -567,12 +567,12 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo } if (batch->elem) { - const Gwn_IndexBuf* el = batch->elem; + const GPUIndexBuf* el = batch->elem; if (el->use_prim_restart) { primitive_restart_enable(el); } -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE glDrawElementsInstancedBaseVertex(batch->gl_prim_type, el->index_len, el->gl_index_type, @@ -597,13 +597,13 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo } if (batch->elem) { - const Gwn_IndexBuf* el = batch->elem; + const GPUIndexBuf* el = batch->elem; if (el->use_prim_restart) { primitive_restart_enable(el); } -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE if (el->base_index) { glDrawRangeElementsBaseVertex(batch->gl_prim_type, el->min_index, @@ -634,10 +634,10 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo } /* just draw some vertices and let shader place them where we want. */ -void GWN_draw_primitive(Gwn_PrimType prim_type, int v_count) +void GPU_draw_primitive(GPUPrimType prim_type, int v_count) { /* we cannot draw without vao ... annoying ... */ - glBindVertexArray(GWN_vao_default()); + glBindVertexArray(GPU_vao_default()); GLenum type = convert_prim_type_to_gl(prim_type); glDrawArrays(type, 0, v_count); @@ -652,10 +652,10 @@ void GWN_draw_primitive(Gwn_PrimType prim_type, int v_count) /** \name Utilities * \{ */ -void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id) +void GPU_batch_program_set_builtin(GPUBatch *batch, GPUBuiltinShader shader_id) { GPUShader *shader = GPU_shader_get_builtin_shader(shader_id); - GWN_batch_program_set(batch, shader->program, shader->interface); + GPU_batch_program_set(batch, shader->program, shader->interface); } /** \} */ diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c index fb696fd09a5..83287c57441 100644 --- a/source/blender/gpu/intern/gpu_batch_presets.c +++ b/source/blender/gpu/intern/gpu_batch_presets.c @@ -45,14 +45,14 @@ /* Struct to store 3D Batches and their format */ static struct { struct { - Gwn_Batch *sphere_high; - Gwn_Batch *sphere_med; - Gwn_Batch *sphere_low; - Gwn_Batch *sphere_wire_low; - Gwn_Batch *sphere_wire_med; + GPUBatch *sphere_high; + GPUBatch *sphere_med; + GPUBatch *sphere_low; + GPUBatch *sphere_wire_low; + GPUBatch *sphere_wire_med; } batch; - Gwn_VertFormat format; + GPUVertFormat format; struct { uint pos, nor; @@ -66,28 +66,28 @@ static ListBase presets_list = {NULL, NULL}; /** \name 3D Primitives * \{ */ -static Gwn_VertFormat *preset_3d_format(void) +static GPUVertFormat *preset_3d_format(void) { if (g_presets_3d.format.attr_len == 0) { - Gwn_VertFormat *format = &g_presets_3d.format; - g_presets_3d.attr_id.pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - g_presets_3d.attr_id.nor = GWN_vertformat_attr_add(format, "nor", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = &g_presets_3d.format; + g_presets_3d.attr_id.pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + g_presets_3d.attr_id.nor = GPU_vertformat_attr_add(format, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } return &g_presets_3d.format; } static void batch_sphere_lat_lon_vert( - Gwn_VertBufRaw *pos_step, Gwn_VertBufRaw *nor_step, + GPUVertBufRaw *pos_step, GPUVertBufRaw *nor_step, float lat, float lon) { float pos[3]; pos[0] = sinf(lat) * cosf(lon); pos[1] = cosf(lat); pos[2] = sinf(lat) * sinf(lon); - copy_v3_v3(GWN_vertbuf_raw_step(pos_step), pos); - copy_v3_v3(GWN_vertbuf_raw_step(nor_step), pos); + copy_v3_v3(GPU_vertbuf_raw_step(pos_step), pos); + copy_v3_v3(GPU_vertbuf_raw_step(nor_step), pos); } -Gwn_Batch *GPU_batch_preset_sphere(int lod) +GPUBatch *GPU_batch_preset_sphere(int lod) { BLI_assert(lod >= 0 && lod <= 2); BLI_assert(BLI_thread_is_main()); @@ -103,7 +103,7 @@ Gwn_Batch *GPU_batch_preset_sphere(int lod) } } -Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) +GPUBatch *GPU_batch_preset_sphere_wire(int lod) { BLI_assert(lod >= 0 && lod <= 1); BLI_assert(BLI_thread_is_main()); @@ -123,19 +123,19 @@ Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) * \{ */ /* Replacement for gluSphere */ -Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) +GPUBatch *gpu_batch_sphere(int lat_res, int lon_res) { const float lon_inc = 2 * M_PI / lon_res; const float lat_inc = M_PI / lat_res; float lon, lat; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3d_format()); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(preset_3d_format()); const uint vbo_len = (lat_res - 1) * lon_res * 6; - GWN_vertbuf_data_alloc(vbo, vbo_len); + GPU_vertbuf_data_alloc(vbo, vbo_len); - Gwn_VertBufRaw pos_step, nor_step; - GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step); - GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step); + GPUVertBufRaw pos_step, nor_step; + GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step); + GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step); lon = 0.0f; for (int i = 0; i < lon_res; i++, lon += lon_inc) { @@ -155,25 +155,25 @@ Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) } } - BLI_assert(vbo_len == GWN_vertbuf_raw_used(&pos_step)); - BLI_assert(vbo_len == GWN_vertbuf_raw_used(&nor_step)); + BLI_assert(vbo_len == GPU_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len == GPU_vertbuf_raw_used(&nor_step)); - return GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); + return GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, NULL, GPU_BATCH_OWNS_VBO); } -static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res) +static GPUBatch *batch_sphere_wire(int lat_res, int lon_res) { const float lon_inc = 2 * M_PI / lon_res; const float lat_inc = M_PI / lat_res; float lon, lat; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(preset_3d_format()); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(preset_3d_format()); const uint vbo_len = (lat_res * lon_res * 2) + ((lat_res - 1) * lon_res * 2); - GWN_vertbuf_data_alloc(vbo, vbo_len); + GPU_vertbuf_data_alloc(vbo, vbo_len); - Gwn_VertBufRaw pos_step, nor_step; - GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step); - GWN_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step); + GPUVertBufRaw pos_step, nor_step; + GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.pos, &pos_step); + GPU_vertbuf_attr_get_raw_data(vbo, g_presets_3d.attr_id.nor, &nor_step); lon = 0.0f; for (int i = 0; i < lon_res; i++, lon += lon_inc) { @@ -189,10 +189,10 @@ static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res) } } - BLI_assert(vbo_len == GWN_vertbuf_raw_used(&pos_step)); - BLI_assert(vbo_len == GWN_vertbuf_raw_used(&nor_step)); + BLI_assert(vbo_len == GPU_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len == GPU_vertbuf_raw_used(&nor_step)); - return GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); + return GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } /** \} */ @@ -216,7 +216,7 @@ void gpu_batch_presets_init(void) gpu_batch_presets_register(g_presets_3d.batch.sphere_wire_med); } -void gpu_batch_presets_register(Gwn_Batch *preset_batch) +void gpu_batch_presets_register(GPUBatch *preset_batch) { BLI_addtail(&presets_list, BLI_genericNodeN(preset_batch)); } @@ -227,8 +227,8 @@ void gpu_batch_presets_reset(void) * This way they will draw correctly for each window. */ LinkData *link = presets_list.first; for (link = presets_list.first; link; link = link->next) { - Gwn_Batch *preset = link->data; - gwn_batch_vao_cache_clear(preset); + GPUBatch *preset = link->data; + GPU_batch_vao_cache_clear(preset); } } @@ -236,8 +236,8 @@ void gpu_batch_presets_exit(void) { LinkData *link; while ((link = BLI_pophead(&presets_list))) { - Gwn_Batch *preset = link->data; - GWN_batch_discard(preset); + GPUBatch *preset = link->data; + GPU_batch_discard(preset); MEM_freeN(link); } } diff --git a/source/blender/gpu/intern/gpu_batch_private.h b/source/blender/gpu/intern/gpu_batch_private.h index 1e72bae503f..0b25c0aef05 100644 --- a/source/blender/gpu/intern/gpu_batch_private.h +++ b/source/blender/gpu/intern/gpu_batch_private.h @@ -23,15 +23,15 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_batch_private.h +/** \file blender/gpu/intern/gpu_batch_private.h * \ingroup gpu * - * Gawain geometry batch + * GPU geometry batch * Contains VAOs + VBOs + Shader representing a drawable entity. */ -#ifndef __GWN_BATCH_PRIVATE_H__ -#define __GWN_BATCH_PRIVATE_H__ +#ifndef __GPU_BATCH_PRIVATE_H__ +#define __GPU_BATCH_PRIVATE_H__ #ifdef __cplusplus extern "C" { @@ -41,13 +41,13 @@ extern "C" { #include "GPU_context.h" #include "GPU_shader_interface.h" -void gwn_batch_remove_interface_ref(Gwn_Batch*, const Gwn_ShaderInterface*); +void gpu_batch_remove_interface_ref(GPUBatch*, const GPUShaderInterface*); -void gwn_context_add_batch(Gwn_Context*, Gwn_Batch*); -void gwn_context_remove_batch(Gwn_Context*, Gwn_Batch*); +void gpu_context_add_batch(GPUContext*, GPUBatch*); +void gpu_context_remove_batch(GPUContext*, GPUBatch*); #ifdef __cplusplus } #endif -#endif /* __GWN_BATCH_PRIVATE_H__ */ +#endif /* __GPU_BATCH_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_batch_utils.c b/source/blender/gpu/intern/gpu_batch_utils.c index d6d82ac18b6..0a7f1ca901d 100644 --- a/source/blender/gpu/intern/gpu_batch_utils.c +++ b/source/blender/gpu/intern/gpu_batch_utils.c @@ -47,7 +47,7 @@ * \param polys_flat_len: Length of the array (must be an even number). * \param rect: Optional region to map the byte 0..255 coords to. When not set use -1..1. */ -Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( +GPUBatch *GPU_batch_tris_from_poly_2d_encoded( const uchar *polys_flat, uint polys_flat_len, const rctf *rect) { const uchar (*polys)[2] = (const void *)polys_flat; @@ -103,41 +103,41 @@ Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded( } /* We have vertices and tris, make a batch from this. */ - static Gwn_VertFormat format = {0}; + static GPUVertFormat format = {0}; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } const uint verts_len = (verts_step - verts); const uint tris_len = (tris_step - tris); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, verts_len); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, verts_len); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); for (uint i = 0; i < verts_len; i++) { - copy_v2_v2(GWN_vertbuf_raw_step(&pos_step), verts[i]); + copy_v2_v2(GPU_vertbuf_raw_step(&pos_step), verts[i]); } - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tris_len, verts_len); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tris_len, verts_len); for (uint i = 0; i < tris_len; i++) { - GWN_indexbuf_add_tri_verts(&elb, UNPACK3(tris[i])); + GPU_indexbuf_add_tri_verts(&elb, UNPACK3(tris[i])); } - Gwn_IndexBuf *indexbuf = GWN_indexbuf_build(&elb); + GPUIndexBuf *indexbuf = GPU_indexbuf_build(&elb); MEM_freeN(tris); MEM_freeN(verts); - return GWN_batch_create_ex( - GWN_PRIM_TRIS, vbo, + return GPU_batch_create_ex( + GPU_PRIM_TRIS, vbo, indexbuf, - GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); + GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); } -Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( +GPUBatch *GPU_batch_wire_from_poly_2d_encoded( const uchar *polys_flat, uint polys_flat_len, const rctf *rect) { const uchar (*polys)[2] = (const void *)polys_flat; @@ -206,18 +206,18 @@ Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( } /* We have vertices and tris, make a batch from this. */ - static Gwn_VertFormat format = {0}; + static GPUVertFormat format = {0}; static struct { uint pos; } attr_id; if (format.attr_len == 0) { - attr_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); const uint vbo_len_capacity = lines_len * 2; - GWN_vertbuf_data_alloc(vbo, vbo_len_capacity); + GPU_vertbuf_data_alloc(vbo, vbo_len_capacity); - Gwn_VertBufRaw pos_step; - GWN_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); + GPUVertBufRaw pos_step; + GPU_vertbuf_attr_get_raw_data(vbo, attr_id.pos, &pos_step); for (uint i = 0; i < lines_len; i++) { union { @@ -226,18 +226,18 @@ Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded( } data; data.as_u32 = lines[i]; for (uint k = 0; k < 2; k++) { - float *pos_v2 = GWN_vertbuf_raw_step(&pos_step); + float *pos_v2 = GPU_vertbuf_raw_step(&pos_step); for (uint j = 0; j < 2; j++) { pos_v2[j] = min_uchar[j] + ((float)data.as_u8_pair[k][j] * range_uchar[j]); } } } - BLI_assert(vbo_len_capacity == GWN_vertbuf_raw_used(&pos_step)); + BLI_assert(vbo_len_capacity == GPU_vertbuf_raw_used(&pos_step)); MEM_freeN(lines); - return GWN_batch_create_ex( - GWN_PRIM_LINES, vbo, + return GPU_batch_create_ex( + GPU_PRIM_LINES, vbo, NULL, - GWN_BATCH_OWNS_VBO); + GPU_BATCH_OWNS_VBO); } /** \} */ diff --git a/source/blender/gpu/intern/gpu_buffer_id.cpp b/source/blender/gpu/intern/gpu_buffer_id.cpp index 0c442f687a0..c1aaf1945aa 100644 --- a/source/blender/gpu/intern/gpu_buffer_id.cpp +++ b/source/blender/gpu/intern/gpu_buffer_id.cpp @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_buffer_id.cpp +/** \file blender/gpu/intern/gpu_buffer_id.cpp * \ingroup gpu * - * Gawain buffer IDs + * GPU buffer IDs */ #include "GPU_buffer_id.h" @@ -54,7 +54,7 @@ static bool thread_is_main() return BLI_thread_is_main(); } -GLuint GWN_buf_id_alloc() +GLuint GPU_buf_id_alloc() { /* delete orphaned IDs */ orphan_mutex.lock(); @@ -73,7 +73,7 @@ GLuint GWN_buf_id_alloc() return new_buffer_id; } -void GWN_buf_id_free(GLuint buffer_id) +void GPU_buf_id_free(GLuint buffer_id) { if (thread_is_main()) { glDeleteBuffers(1, &buffer_id); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 1a4750652cc..d466fa87388 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -62,7 +62,7 @@ static ThreadMutex buffer_mutex = BLI_MUTEX_INITIALIZER; /* multires global buffer, can be used for many grids having the same grid size */ typedef struct GridCommonGPUBuffer { - Gwn_IndexBuf *mres_buffer; + GPUIndexBuf *mres_buffer; int mres_prev_gridsize; unsigned mres_prev_totquad; } GridCommonGPUBuffer; @@ -71,11 +71,11 @@ typedef struct GridCommonGPUBuffer { * drawing and doesn't interact at all with the buffer code above */ struct GPU_PBVH_Buffers { - Gwn_IndexBuf *index_buf, *index_buf_fast; - Gwn_VertBuf *vert_buf; + GPUIndexBuf *index_buf, *index_buf_fast; + GPUVertBuf *vert_buf; - Gwn_Batch *triangles; - Gwn_Batch *triangles_fast; + GPUBatch *triangles; + GPUBatch *triangles_fast; /* mesh pointers in case buffer allocation fails */ const MPoly *mpoly; @@ -132,23 +132,23 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, unsigned int v /* Initialize vertex buffer */ /* match 'VertexBufferFormat' */ - static Gwn_VertFormat format = {0}; + static GPUVertFormat format = {0}; if (format.attr_len == 0) { - g_vbo_id.pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); - g_vbo_id.nor = GWN_vertformat_attr_add(&format, "nor", GWN_COMP_I16, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); - g_vbo_id.col = GWN_vertformat_attr_add(&format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + g_vbo_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + g_vbo_id.nor = GPU_vertformat_attr_add(&format, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); + g_vbo_id.col = GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); } #if 0 - buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_DYNAMIC); - GWN_vertbuf_data_alloc(buffers->vert_buf, vert_len); + buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_DYNAMIC); + GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len); } else if (vert_len != buffers->vert_buf->vertex_len) { - GWN_vertbuf_data_resize(buffers->vert_buf, vert_len); + GPU_vertbuf_data_resize(buffers->vert_buf, vert_len); } #else - buffers->vert_buf = GWN_vertbuf_create_with_format_ex(&format, GWN_USAGE_STATIC); + buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STATIC); } - GWN_vertbuf_data_alloc(buffers->vert_buf, vert_len); + GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len); #endif return buffers->vert_buf->data != NULL; } @@ -157,19 +157,19 @@ static void gpu_pbvh_batch_init(GPU_PBVH_Buffers *buffers) { /* force flushing to the GPU */ if (buffers->vert_buf->data) { - GWN_vertbuf_use(buffers->vert_buf); + GPU_vertbuf_use(buffers->vert_buf); } if (buffers->triangles == NULL) { - buffers->triangles = GWN_batch_create( - GWN_PRIM_TRIS, buffers->vert_buf, + buffers->triangles = GPU_batch_create( + GPU_PRIM_TRIS, buffers->vert_buf, /* can be NULL */ buffers->index_buf); } if ((buffers->triangles_fast == NULL) && buffers->index_buf_fast) { - buffers->triangles_fast = GWN_batch_create( - GWN_PRIM_TRIS, buffers->vert_buf, + buffers->triangles_fast = GPU_batch_create( + GPU_PRIM_TRIS, buffers->vert_buf, /* can be NULL */ buffers->index_buf_fast); } @@ -245,8 +245,8 @@ void GPU_pbvh_mesh_buffers_update( if (buffers->smooth) { for (uint i = 0; i < totvert; ++i) { const MVert *v = &mvert[vert_indices[i]]; - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, i, v->co); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, i, v->no); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, i, v->co); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, i, v->no); } for (uint i = 0; i < buffers->face_indices_len; i++) { @@ -257,10 +257,10 @@ void GPU_pbvh_mesh_buffers_update( int v_index = buffers->mloop[lt->tri[j]].v; uchar color_ub[3]; gpu_color_from_mask_copy(vmask[v_index], diffuse_color, color_ub); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, color_ub); } else { - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, diffuse_color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vidx, diffuse_color_ub); } } } @@ -303,9 +303,9 @@ void GPU_pbvh_mesh_buffers_update( for (uint j = 0; j < 3; j++) { const MVert *v = &mvert[vtri[j]]; - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, v->co); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, v->co); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); vbo_index++; } @@ -367,8 +367,8 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build( if (buffers->smooth) { /* Fill the triangle buffer */ buffers->index_buf = NULL; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tottri, INT_MAX); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, INT_MAX); for (i = 0; i < face_indices_len; ++i) { const MLoopTri *lt = &looptri[face_indices[i]]; @@ -377,13 +377,13 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build( if (paint_is_face_hidden(lt, mvert, mloop)) continue; - GWN_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i])); + GPU_indexbuf_add_tri_verts(&elb, UNPACK3(face_vert_indices[i])); } - buffers->index_buf = GWN_indexbuf_build(&elb); + buffers->index_buf = GPU_indexbuf_build(&elb); } else { if (!buffers->is_index_buf_global) { - GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf); + GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf); } buffers->index_buf = NULL; buffers->is_index_buf_global = false; @@ -438,12 +438,12 @@ void GPU_pbvh_grid_buffers_update( for (y = 0; y < key->grid_size; y++) { for (x = 0; x < key->grid_size; x++) { CCGElem *elem = CCG_grid_elem(key, grid, x, y); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem)); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.pos, vbo_index, CCG_elem_co(key, elem)); if (buffers->smooth) { short no_short[3]; normal_float_to_short_v3(no_short, CCG_elem_no(key, elem)); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); if (has_mask) { uchar color_ub[3]; @@ -454,7 +454,7 @@ void GPU_pbvh_grid_buffers_update( else { unit_float_to_uchar_clamp_v3(color_ub, diffuse_color); } - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); } } vbo_index += 1; @@ -481,7 +481,7 @@ void GPU_pbvh_grid_buffers_update( vbo_index = vbo_index_offset + ((j + 1) * key->grid_size + k); short no_short[3]; normal_float_to_short_v3(no_short, fno); - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.nor, vbo_index, no_short); if (has_mask) { uchar color_ub[3]; @@ -497,7 +497,7 @@ void GPU_pbvh_grid_buffers_update( else { unit_float_to_uchar_clamp_v3(color_ub, diffuse_color); } - GWN_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); + GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, color_ub); } } } @@ -526,9 +526,9 @@ void GPU_pbvh_grid_buffers_update( int offset = 0; \ int i, j, k; \ \ - Gwn_IndexBufBuilder elb; \ - GWN_indexbuf_init( \ - &elb, GWN_PRIM_TRIS, tot_quad_ * 2, max_vert_); \ + GPUIndexBufBuilder elb; \ + GPU_indexbuf_init( \ + &elb, GPU_PRIM_TRIS, tot_quad_ * 2, max_vert_); \ \ /* Fill the buffer */ \ for (i = 0; i < totgrid; ++i) { \ @@ -544,25 +544,25 @@ void GPU_pbvh_grid_buffers_update( { \ continue; \ } \ - GWN_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ - GWN_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k); \ - GWN_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ + GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ + GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k); \ + GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ \ - GWN_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k + 1); \ - GWN_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ - GWN_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ + GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k + 1); \ + GPU_indexbuf_add_generic_vert(&elb, offset + j * gridsize + k + 1); \ + GPU_indexbuf_add_generic_vert(&elb, offset + (j + 1) * gridsize + k); \ } \ } \ \ offset += gridsize * gridsize; \ } \ - buffer_ = GWN_indexbuf_build(&elb); \ + buffer_ = GPU_indexbuf_build(&elb); \ } (void)0 /* end FILL_QUAD_BUFFER */ -static Gwn_IndexBuf *gpu_get_grid_buffer( +static GPUIndexBuf *gpu_get_grid_buffer( int gridsize, unsigned *totquad, GridCommonGPUBuffer **grid_common_gpu_buffer, - /* remove this arg when gawain gets base-vertex support! */ + /* remove this arg when GPU gets base-vertex support! */ int totgrid) { /* used in the FILL_QUAD_BUFFER macro */ @@ -586,7 +586,7 @@ static Gwn_IndexBuf *gpu_get_grid_buffer( } /* we can't reuse old, delete the existing buffer */ else if (gridbuff->mres_buffer) { - GWN_indexbuf_discard(gridbuff->mres_buffer); + GPU_indexbuf_discard(gridbuff->mres_buffer); gridbuff->mres_buffer = NULL; } @@ -603,17 +603,17 @@ static Gwn_IndexBuf *gpu_get_grid_buffer( #define FILL_FAST_BUFFER() \ { \ - Gwn_IndexBufBuilder elb; \ - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, 6 * totgrid, INT_MAX); \ + GPUIndexBufBuilder elb; \ + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, 6 * totgrid, INT_MAX); \ for (int i = 0; i < totgrid; i++) { \ - GWN_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \ - GWN_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize); \ - GWN_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \ - GWN_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - 1); \ - GWN_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \ - GWN_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \ + GPU_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \ + GPU_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize); \ + GPU_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \ + GPU_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - 1); \ + GPU_indexbuf_add_generic_vert(&elb, i * gridsize * gridsize + gridsize - 1); \ + GPU_indexbuf_add_generic_vert(&elb, (i + 1) * gridsize * gridsize - gridsize); \ } \ - buffers->index_buf_fast = GWN_indexbuf_build(&elb); \ + buffers->index_buf_fast = GPU_indexbuf_build(&elb); \ } (void)0 GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build( @@ -684,7 +684,7 @@ GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build( */ static void gpu_bmesh_vert_to_buffer_copy__gwn( BMVert *v, - Gwn_VertBuf *vert_buf, + GPUVertBuf *vert_buf, int *v_index, const float fno[3], const float *fmask, @@ -695,12 +695,12 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn( if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) { /* Set coord, normal, and mask */ - GWN_vertbuf_attr_set(vert_buf, g_vbo_id.pos, *v_index, v->co); + GPU_vertbuf_attr_set(vert_buf, g_vbo_id.pos, *v_index, v->co); { short no_short[3]; normal_float_to_short_v3(no_short, fno ? fno : v->no); - GWN_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short); + GPU_vertbuf_attr_set(vert_buf, g_vbo_id.nor, *v_index, no_short); } { @@ -718,7 +718,7 @@ static void gpu_bmesh_vert_to_buffer_copy__gwn( effective_mask, diffuse_color, color_ub); - GWN_vertbuf_attr_set(vert_buf, g_vbo_id.col, *v_index, color_ub); + GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col, *v_index, color_ub); } /* Assign index for use in the triangle index buffer */ @@ -792,7 +792,7 @@ void GPU_pbvh_bmesh_buffers_update( if (buffers->smooth) { /* Smooth needs to recreate index buffer, so we have to invalidate the batch. */ - GWN_BATCH_DISCARD_SAFE(buffers->triangles); + GPU_BATCH_DISCARD_SAFE(buffers->triangles); /* Count visible vertices */ totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts); } @@ -893,8 +893,8 @@ void GPU_pbvh_bmesh_buffers_update( if (buffers->smooth) { /* Fill the triangle buffer */ buffers->index_buf = NULL; - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init(&elb, GWN_PRIM_TRIS, tottri, maxvert); + GPUIndexBufBuilder elb; + GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tottri, maxvert); /* Initialize triangle index buffer */ buffers->is_index_buf_global = false; @@ -911,7 +911,7 @@ void GPU_pbvh_bmesh_buffers_update( BMVert *v[3]; BM_face_as_array_vert_tri(f, v); - GWN_indexbuf_add_tri_verts( + GPU_indexbuf_add_tri_verts( &elb, BM_elem_index_get(v[0]), BM_elem_index_get(v[1]), BM_elem_index_get(v[2])); } } @@ -919,16 +919,16 @@ void GPU_pbvh_bmesh_buffers_update( buffers->tot_tri = tottri; if (buffers->index_buf == NULL) { - buffers->index_buf = GWN_indexbuf_build(&elb); + buffers->index_buf = GPU_indexbuf_build(&elb); } else { - GWN_indexbuf_build_in_place(&elb, buffers->index_buf); + GPU_indexbuf_build_in_place(&elb, buffers->index_buf); } } } else if (buffers->index_buf) { if (!buffers->is_index_buf_global) { - GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf); + GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf); } buffers->index_buf = NULL; buffers->is_index_buf_global = false; @@ -950,7 +950,7 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading) return buffers; } -Gwn_Batch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast) +GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast) { return (fast && buffers->triangles_fast) ? buffers->triangles_fast : buffers->triangles; @@ -1003,13 +1003,13 @@ bool GPU_pbvh_buffers_mask_changed(GPU_PBVH_Buffers *buffers, bool show_mask) void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers) { if (buffers) { - GWN_BATCH_DISCARD_SAFE(buffers->triangles); - GWN_BATCH_DISCARD_SAFE(buffers->triangles_fast); + GPU_BATCH_DISCARD_SAFE(buffers->triangles); + GPU_BATCH_DISCARD_SAFE(buffers->triangles_fast); if (!buffers->is_index_buf_global) { - GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf); + GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf); } - GWN_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast); - GWN_VERTBUF_DISCARD_SAFE(buffers->vert_buf); + GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf_fast); + GPU_VERTBUF_DISCARD_SAFE(buffers->vert_buf); #ifdef USE_BASE_ELEM if (buffers->baseelemarray) @@ -1029,7 +1029,7 @@ void GPU_pbvh_multires_buffers_free(GridCommonGPUBuffer **grid_common_gpu_buffer if (gridbuff) { if (gridbuff->mres_buffer) { BLI_mutex_lock(&buffer_mutex); - GWN_INDEXBUF_DISCARD_SAFE(gridbuff->mres_buffer); + GPU_INDEXBUF_DISCARD_SAFE(gridbuff->mres_buffer); BLI_mutex_unlock(&buffer_mutex); } MEM_freeN(gridbuff); @@ -1049,7 +1049,7 @@ void GPU_pbvh_BB_draw(float min[3], float max[3], bool leaf, unsigned int pos) * could keep a static batch & index buffer, change the VBO contents per draw */ - immBegin(GWN_PRIM_LINES, 24); + immBegin(GPU_PRIM_LINES, 24); /* top */ immVertex3f(pos, min[0], min[1], max[2]); diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index a450b551d4a..51f21d01a9f 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -917,7 +917,7 @@ static const char *attrib_prefix_get(CustomDataType type) case CD_TANGENT: return "t"; case CD_MCOL: return "c"; case CD_AUTO_FROM_NAME: return "a"; - default: BLI_assert(false && "Gwn_VertAttr Prefix type not found : This should not happen!"); return ""; + default: BLI_assert(false && "GPUVertAttr Prefix type not found : This should not happen!"); return ""; } } diff --git a/source/blender/gpu/intern/gpu_element.c b/source/blender/gpu/intern/gpu_element.c index 596530a6ff4..1b5a08ac35c 100644 --- a/source/blender/gpu/intern/gpu_element.c +++ b/source/blender/gpu/intern/gpu_element.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_element.c +/** \file blender/gpu/intern/gpu_element.c * \ingroup gpu * - * Gawain element list (AKA index buffer) + * GPU element list (AKA index buffer) */ #include "GPU_element.h" @@ -36,23 +36,23 @@ #define KEEP_SINGLE_COPY 1 -static GLenum convert_index_type_to_gl(Gwn_IndexBufType type) +static GLenum convert_index_type_to_gl(GPUIndexBufType type) { static const GLenum table[] = { - [GWN_INDEX_U8] = GL_UNSIGNED_BYTE, /* GL has this, Vulkan does not */ - [GWN_INDEX_U16] = GL_UNSIGNED_SHORT, - [GWN_INDEX_U32] = GL_UNSIGNED_INT + [GPU_INDEX_U8] = GL_UNSIGNED_BYTE, /* GL has this, Vulkan does not */ + [GPU_INDEX_U16] = GL_UNSIGNED_SHORT, + [GPU_INDEX_U32] = GL_UNSIGNED_INT }; return table[type]; } -uint GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) +uint GPU_indexbuf_size_get(const GPUIndexBuf* elem) { -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE static const uint table[] = { - [GWN_INDEX_U8] = sizeof(GLubyte), /* GL has this, Vulkan does not */ - [GWN_INDEX_U16] = sizeof(GLushort), - [GWN_INDEX_U32] = sizeof(GLuint) + [GPU_INDEX_U8] = sizeof(GLubyte), /* GL has this, Vulkan does not */ + [GPU_INDEX_U16] = sizeof(GLushort), + [GPU_INDEX_U32] = sizeof(GLuint) }; return elem->index_len * table[elem->index_type]; #else @@ -60,8 +60,8 @@ uint GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) #endif } -void GWN_indexbuf_init_ex( - Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, +void GPU_indexbuf_init_ex( + GPUIndexBufBuilder* builder, GPUPrimType prim_type, uint index_len, uint vertex_len, bool use_prim_restart) { builder->use_prim_restart = use_prim_restart; @@ -72,20 +72,20 @@ void GWN_indexbuf_init_ex( builder->data = calloc(builder->max_index_len, sizeof(uint)); } -void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uint prim_len, uint vertex_len) +void GPU_indexbuf_init(GPUIndexBufBuilder* builder, GPUPrimType prim_type, uint prim_len, uint vertex_len) { uint verts_per_prim = 0; switch (prim_type) { - case GWN_PRIM_POINTS: + case GPU_PRIM_POINTS: verts_per_prim = 1; break; - case GWN_PRIM_LINES: + case GPU_PRIM_LINES: verts_per_prim = 2; break; - case GWN_PRIM_TRIS: + case GPU_PRIM_TRIS: verts_per_prim = 3; break; - case GWN_PRIM_LINES_ADJ: + case GPU_PRIM_LINES_ADJ: verts_per_prim = 4; break; default: @@ -95,10 +95,10 @@ void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uin return; } - GWN_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); + GPU_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); } -void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, uint v) +void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder* builder, uint v) { #if TRUST_NO_ONE assert(builder->data != NULL); @@ -108,58 +108,58 @@ void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, uint v) builder->data[builder->index_len++] = v; } -void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder* builder) +void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder* builder) { #if TRUST_NO_ONE assert(builder->data != NULL); assert(builder->index_len < builder->max_index_len); assert(builder->use_prim_restart); #endif - builder->data[builder->index_len++] = GWN_PRIM_RESTART; + builder->data[builder->index_len++] = GPU_PRIM_RESTART; } -void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, uint v) +void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder* builder, uint v) { #if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_POINTS); + assert(builder->prim_type == GPU_PRIM_POINTS); #endif - GWN_indexbuf_add_generic_vert(builder, v); + GPU_indexbuf_add_generic_vert(builder, v); } -void GWN_indexbuf_add_line_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2) +void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder* builder, uint v1, uint v2) { #if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_LINES); + assert(builder->prim_type == GPU_PRIM_LINES); assert(v1 != v2); #endif - GWN_indexbuf_add_generic_vert(builder, v1); - GWN_indexbuf_add_generic_vert(builder, v2); + GPU_indexbuf_add_generic_vert(builder, v1); + GPU_indexbuf_add_generic_vert(builder, v2); } -void GWN_indexbuf_add_tri_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3) +void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder* builder, uint v1, uint v2, uint v3) { #if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_TRIS); + assert(builder->prim_type == GPU_PRIM_TRIS); assert(v1 != v2 && v2 != v3 && v3 != v1); #endif - GWN_indexbuf_add_generic_vert(builder, v1); - GWN_indexbuf_add_generic_vert(builder, v2); - GWN_indexbuf_add_generic_vert(builder, v3); + GPU_indexbuf_add_generic_vert(builder, v1); + GPU_indexbuf_add_generic_vert(builder, v2); + GPU_indexbuf_add_generic_vert(builder, v3); } -void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, uint v1, uint v2, uint v3, uint v4) +void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder* builder, uint v1, uint v2, uint v3, uint v4) { #if TRUST_NO_ONE - assert(builder->prim_type == GWN_PRIM_LINES_ADJ); + assert(builder->prim_type == GPU_PRIM_LINES_ADJ); assert(v2 != v3); /* only the line need diff indices */ #endif - GWN_indexbuf_add_generic_vert(builder, v1); - GWN_indexbuf_add_generic_vert(builder, v2); - GWN_indexbuf_add_generic_vert(builder, v3); - GWN_indexbuf_add_generic_vert(builder, v4); + GPU_indexbuf_add_generic_vert(builder, v1); + GPU_indexbuf_add_generic_vert(builder, v2); + GPU_indexbuf_add_generic_vert(builder, v3); + GPU_indexbuf_add_generic_vert(builder, v4); } -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE /* Everything remains 32 bit while building to keep things simple. * Find min/max after, then convert to smallest index type possible. */ @@ -174,7 +174,7 @@ static uint index_range(const uint values[], uint value_len, uint* min_out, uint uint max_value = values[0]; for (uint i = 1; i < value_len; ++i) { const uint value = values[i]; - if (value == GWN_PRIM_RESTART) + if (value == GPU_PRIM_RESTART) continue; else if (value < min_value) min_value = value; @@ -186,7 +186,7 @@ static uint index_range(const uint values[], uint value_len, uint* min_out, uint return max_value - min_value; } -static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) +static void squeeze_indices_byte(GPUIndexBufBuilder *builder, GPUIndexBuf* elem) { const uint *values = builder->data; const uint index_len = elem->index_len; @@ -201,7 +201,7 @@ static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* ele elem->min_index = 0; elem->max_index -= base; for (uint i = 0; i < index_len; ++i) { - data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base); + data[i] = (values[i] == GPU_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base); } } else { @@ -212,7 +212,7 @@ static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* ele } } -static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) +static void squeeze_indices_short(GPUIndexBufBuilder *builder, GPUIndexBuf* elem) { const uint *values = builder->data; const uint index_len = elem->index_len; @@ -227,7 +227,7 @@ static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* el elem->min_index = 0; elem->max_index -= base; for (uint i = 0; i < index_len; ++i) { - data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base); + data[i] = (values[i] == GPU_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base); } } else { @@ -238,16 +238,16 @@ static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* el } } -#endif /* GWN_TRACK_INDEX_RANGE */ +#endif /* GPU_TRACK_INDEX_RANGE */ -Gwn_IndexBuf* GWN_indexbuf_build(Gwn_IndexBufBuilder* builder) +GPUIndexBuf* GPU_indexbuf_build(GPUIndexBufBuilder* builder) { - Gwn_IndexBuf* elem = calloc(1, sizeof(Gwn_IndexBuf)); - GWN_indexbuf_build_in_place(builder, elem); + GPUIndexBuf* elem = calloc(1, sizeof(GPUIndexBuf)); + GPU_indexbuf_build_in_place(builder, elem); return elem; } -void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* elem) +void GPU_indexbuf_build_in_place(GPUIndexBufBuilder* builder, GPUIndexBuf* elem) { #if TRUST_NO_ONE assert(builder->data != NULL); @@ -255,7 +255,7 @@ void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* ele elem->index_len = builder->index_len; elem->use_prim_restart = builder->use_prim_restart; -#if GWN_TRACK_INDEX_RANGE +#if GPU_TRACK_INDEX_RANGE uint range = index_range(builder->data, builder->index_len, &elem->min_index, &elem->max_index); /* count the primitive restart index. */ @@ -264,29 +264,29 @@ void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* ele } if (range <= 0xFF) { - elem->index_type = GWN_INDEX_U8; + elem->index_type = GPU_INDEX_U8; squeeze_indices_byte(builder, elem); } else if (range <= 0xFFFF) { - elem->index_type = GWN_INDEX_U16; + elem->index_type = GPU_INDEX_U16; squeeze_indices_short(builder, elem); } else { - elem->index_type = GWN_INDEX_U32; + elem->index_type = GPU_INDEX_U32; elem->base_index = 0; } elem->gl_index_type = convert_index_type_to_gl(elem->index_type); #endif if (elem->vbo_id == 0) { - elem->vbo_id = GWN_buf_id_alloc(); + elem->vbo_id = GPU_buf_id_alloc(); } /* send data to GPU */ /* GL_ELEMENT_ARRAY_BUFFER changes the state of the last VAO bound, * so we use the GL_ARRAY_BUFFER here to create a buffer without * interfering in the VAO state. */ glBindBuffer(GL_ARRAY_BUFFER, elem->vbo_id); - glBufferData(GL_ARRAY_BUFFER, GWN_indexbuf_size_get(elem), builder->data, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, GPU_indexbuf_size_get(elem), builder->data, GL_STATIC_DRAW); /* discard builder (one-time use) */ free(builder->data); @@ -294,15 +294,15 @@ void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* ele /* other fields are safe to leave */ } -void GWN_indexbuf_use(Gwn_IndexBuf* elem) +void GPU_indexbuf_use(GPUIndexBuf* elem) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem->vbo_id); } -void GWN_indexbuf_discard(Gwn_IndexBuf* elem) +void GPU_indexbuf_discard(GPUIndexBuf* elem) { if (elem->vbo_id) { - GWN_buf_id_free(elem->vbo_id); + GPU_buf_id_free(elem->vbo_id); } free(elem); } diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index 661594faf39..a320935919a 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_immediate.c +/** \file blender/gpu/intern/gpu_immediate.c * \ingroup gpu * - * Gawain immediate mode work-alike + * GPU immediate mode work-alike */ #include "UI_resources.h" @@ -45,14 +45,14 @@ #include /* necessary functions from matrix API */ -extern void GPU_matrix_bind(const Gwn_ShaderInterface*); +extern void GPU_matrix_bind(const GPUShaderInterface*); extern bool GPU_matrix_dirty_get(void); typedef struct { /* TODO: organize this struct by frequency of change (run-time) */ - Gwn_Batch* batch; - Gwn_Context* context; + GPUBatch* batch; + GPUContext* context; /* current draw call */ GLubyte* buffer_data; @@ -60,9 +60,9 @@ typedef struct { uint buffer_bytes_mapped; uint vertex_len; bool strict_vertex_len; - Gwn_PrimType prim_type; + GPUPrimType prim_type; - Gwn_VertFormat vertex_format; + GPUVertFormat vertex_format; /* current vertex */ uint vertex_idx; @@ -73,8 +73,8 @@ typedef struct { GLuint vao_id; GLuint bound_program; - const Gwn_ShaderInterface* shader_interface; - Gwn_AttrBinding attrib_binding; + const GPUShaderInterface* shader_interface; + GPUAttrBinding attrib_binding; uint16_t prev_enabled_attrib_bits; /* <-- only affects this VAO, so we're ok */ } Immediate; @@ -91,11 +91,11 @@ void immInit(void) #endif memset(&imm, 0, sizeof(Immediate)); - imm.vbo_id = GWN_buf_id_alloc(); + imm.vbo_id = GPU_buf_id_alloc(); glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id); glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); - imm.prim_type = GWN_PRIM_NONE; + imm.prim_type = GPU_PRIM_NONE; imm.strict_vertex_len = true; glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -106,38 +106,38 @@ void immActivate(void) { #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ + assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we're not between a Begin/End pair */ assert(imm.vao_id == 0); #endif - imm.vao_id = GWN_vao_alloc(); - imm.context = GWN_context_active_get(); + imm.vao_id = GPU_vao_alloc(); + imm.context = GPU_context_active_get(); } void immDeactivate(void) { #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we're not between a Begin/End pair */ + assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we're not between a Begin/End pair */ assert(imm.vao_id != 0); #endif - GWN_vao_free(imm.vao_id, imm.context); + GPU_vao_free(imm.vao_id, imm.context); imm.vao_id = 0; imm.prev_enabled_attrib_bits = 0; } void immDestroy(void) { - GWN_buf_id_free(imm.vbo_id); + GPU_buf_id_free(imm.vbo_id); initialized = false; } -Gwn_VertFormat* immVertexFormat(void) +GPUVertFormat* immVertexFormat(void) { - GWN_vertformat_clear(&imm.vertex_format); + GPU_vertformat_clear(&imm.vertex_format); return &imm.vertex_format; } -void immBindProgram(GLuint program, const Gwn_ShaderInterface* shaderface) +void immBindProgram(GLuint program, const GPUShaderInterface* shaderface) { #if TRUST_NO_ONE assert(imm.bound_program == 0); @@ -173,7 +173,7 @@ void immUnbindProgram(void) } #if TRUST_NO_ONE -static bool vertex_count_makes_sense_for_primitive(uint vertex_len, Gwn_PrimType prim_type) +static bool vertex_count_makes_sense_for_primitive(uint vertex_len, GPUPrimType prim_type) { /* does vertex_len make sense for this primitive type? */ if (vertex_len == 0) { @@ -181,19 +181,19 @@ static bool vertex_count_makes_sense_for_primitive(uint vertex_len, Gwn_PrimType } switch (prim_type) { - case GWN_PRIM_POINTS: + case GPU_PRIM_POINTS: return true; - case GWN_PRIM_LINES: + case GPU_PRIM_LINES: return vertex_len % 2 == 0; - case GWN_PRIM_LINE_STRIP: - case GWN_PRIM_LINE_LOOP: + case GPU_PRIM_LINE_STRIP: + case GPU_PRIM_LINE_LOOP: return vertex_len >= 2; - case GWN_PRIM_LINE_STRIP_ADJ: + case GPU_PRIM_LINE_STRIP_ADJ: return vertex_len >= 4; - case GWN_PRIM_TRIS: + case GPU_PRIM_TRIS: return vertex_len % 3 == 0; - case GWN_PRIM_TRI_STRIP: - case GWN_PRIM_TRI_FAN: + case GPU_PRIM_TRI_STRIP: + case GPU_PRIM_TRI_FAN: return vertex_len >= 3; default: return false; @@ -201,11 +201,11 @@ static bool vertex_count_makes_sense_for_primitive(uint vertex_len, Gwn_PrimType } #endif -void immBegin(Gwn_PrimType prim_type, uint vertex_len) +void immBegin(GPUPrimType prim_type, uint vertex_len) { #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ + assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we haven't already begun */ assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif imm.prim_type = prim_type; @@ -250,7 +250,7 @@ void immBegin(Gwn_PrimType prim_type, uint vertex_len) imm.vertex_data = imm.buffer_data; } -void immBeginAtMost(Gwn_PrimType prim_type, uint vertex_len) +void immBeginAtMost(GPUPrimType prim_type, uint vertex_len) { #if TRUST_NO_ONE assert(vertex_len > 0); @@ -261,11 +261,11 @@ void immBeginAtMost(Gwn_PrimType prim_type, uint vertex_len) } -Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, uint vertex_len) +GPUBatch* immBeginBatch(GPUPrimType prim_type, uint vertex_len) { #if TRUST_NO_ONE assert(initialized); - assert(imm.prim_type == GWN_PRIM_NONE); /* make sure we haven't already begun */ + assert(imm.prim_type == GPU_PRIM_NONE); /* make sure we haven't already begun */ assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif imm.prim_type = prim_type; @@ -273,19 +273,19 @@ Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, uint vertex_len) imm.vertex_idx = 0; imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; - Gwn_VertBuf* verts = GWN_vertbuf_create_with_format(&imm.vertex_format); - GWN_vertbuf_data_alloc(verts, vertex_len); + GPUVertBuf* verts = GPU_vertbuf_create_with_format(&imm.vertex_format); + GPU_vertbuf_data_alloc(verts, vertex_len); - imm.buffer_bytes_mapped = GWN_vertbuf_size_get(verts); + imm.buffer_bytes_mapped = GPU_vertbuf_size_get(verts); imm.vertex_data = verts->data; - imm.batch = GWN_batch_create_ex(prim_type, verts, NULL, GWN_BATCH_OWNS_VBO); - imm.batch->phase = GWN_BATCH_BUILDING; + imm.batch = GPU_batch_create_ex(prim_type, verts, NULL, GPU_BATCH_OWNS_VBO); + imm.batch->phase = GPU_BATCH_BUILDING; return imm.batch; } -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, uint vertex_len) +GPUBatch* immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len) { imm.strict_vertex_len = false; return immBeginBatch(prim_type, vertex_len); @@ -298,7 +298,7 @@ static void immDrawSetup(void) /* enable/disable vertex attribs as needed */ if (imm.attrib_binding.enabled_bits != imm.prev_enabled_attrib_bits) { - for (uint loc = 0; loc < GWN_VERT_ATTR_MAX_LEN; ++loc) { + for (uint loc = 0; loc < GPU_VERT_ATTR_MAX_LEN; ++loc) { bool is_enabled = imm.attrib_binding.enabled_bits & (1 << loc); bool was_enabled = imm.prev_enabled_attrib_bits & (1 << loc); @@ -316,7 +316,7 @@ static void immDrawSetup(void) const uint stride = imm.vertex_format.stride; for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { - const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; + const GPUVertAttr* a = imm.vertex_format.attribs + a_idx; const uint offset = imm.buffer_offset + a->offset; const GLvoid* pointer = (const GLubyte*)0 + offset; @@ -324,14 +324,14 @@ static void immDrawSetup(void) const uint loc = read_attrib_location(&imm.attrib_binding, a_idx); switch (a->fetch_mode) { - case GWN_FETCH_FLOAT: - case GWN_FETCH_INT_TO_FLOAT: + case GPU_FETCH_FLOAT: + case GPU_FETCH_INT_TO_FLOAT: glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); break; - case GWN_FETCH_INT_TO_FLOAT_UNIT: + case GPU_FETCH_INT_TO_FLOAT_UNIT: glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); break; - case GWN_FETCH_INT: + case GPU_FETCH_INT: glVertexAttribIPointer(loc, a->comp_len, a->gl_comp_type, stride, pointer); } } @@ -344,7 +344,7 @@ static void immDrawSetup(void) void immEnd(void) { #if TRUST_NO_ONE - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif uint buffer_bytes_used; @@ -375,11 +375,11 @@ void immEnd(void) if (imm.batch) { if (buffer_bytes_used != imm.buffer_bytes_mapped) { - GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len); + GPU_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len); /* TODO: resize only if vertex count is much smaller */ } - GWN_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface); - imm.batch->phase = GWN_BATCH_READY_TO_DRAW; + GPU_batch_program_set(imm.batch, imm.bound_program, imm.shader_interface); + imm.batch->phase = GPU_BATCH_READY_TO_DRAW; imm.batch = NULL; /* don't free, batch belongs to caller */ } else { @@ -395,7 +395,7 @@ void immEnd(void) } /* prep for next immBegin */ - imm.prim_type = GWN_PRIM_NONE; + imm.prim_type = GPU_PRIM_NONE; imm.strict_vertex_len = true; } @@ -413,13 +413,13 @@ static void setAttribValueBit(uint attrib_id) void immAttrib1f(uint attrib_id, float x) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_type == GPU_COMP_F32); assert(attrib->comp_len == 1); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -431,13 +431,13 @@ void immAttrib1f(uint attrib_id, float x) void immAttrib2f(uint attrib_id, float x, float y) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_type == GPU_COMP_F32); assert(attrib->comp_len == 2); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -450,13 +450,13 @@ void immAttrib2f(uint attrib_id, float x, float y) void immAttrib3f(uint attrib_id, float x, float y, float z) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_type == GPU_COMP_F32); assert(attrib->comp_len == 3); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -470,13 +470,13 @@ void immAttrib3f(uint attrib_id, float x, float y, float z) void immAttrib4f(uint attrib_id, float x, float y, float z, float w) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_F32); + assert(attrib->comp_type == GPU_COMP_F32); assert(attrib->comp_len == 4); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -491,13 +491,13 @@ void immAttrib4f(uint attrib_id, float x, float y, float z, float w) void immAttrib1u(uint attrib_id, uint x) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_U32); + assert(attrib->comp_type == GPU_COMP_U32); assert(attrib->comp_len == 1); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -508,13 +508,13 @@ void immAttrib1u(uint attrib_id, uint x) void immAttrib2i(uint attrib_id, int x, int y) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_I32); + assert(attrib->comp_type == GPU_COMP_I32); assert(attrib->comp_len == 2); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -526,13 +526,13 @@ void immAttrib2i(uint attrib_id, int x, int y) void immAttrib2s(uint attrib_id, short x, short y) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_I16); + assert(attrib->comp_type == GPU_COMP_I16); assert(attrib->comp_len == 2); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -559,13 +559,13 @@ void immAttrib4fv(uint attrib_id, const float data[4]) void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_U8); + assert(attrib->comp_type == GPU_COMP_U8); assert(attrib->comp_len == 3); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -579,13 +579,13 @@ void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned cha void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a) { - Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; + GPUVertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); - assert(attrib->comp_type == GWN_COMP_U8); + assert(attrib->comp_type == GPU_COMP_U8); assert(attrib->comp_len == 4); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); @@ -613,7 +613,7 @@ void immSkipAttrib(uint attrib_id) #if TRUST_NO_ONE assert(attrib_id < imm.vertex_format.attr_len); assert(imm.vertex_idx < imm.vertex_len); - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ #endif setAttribValueBit(attrib_id); } @@ -621,7 +621,7 @@ void immSkipAttrib(uint attrib_id) static void immEndVertex(void) /* and move on to the next vertex */ { #if TRUST_NO_ONE - assert(imm.prim_type != GWN_PRIM_NONE); /* make sure we're between a Begin/End pair */ + assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */ assert(imm.vertex_idx < imm.vertex_len); #endif @@ -633,7 +633,7 @@ static void immEndVertex(void) /* and move on to the next vertex */ #endif for (uint a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { if ((imm.unassigned_attrib_bits >> a_idx) & 1) { - const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; + const GPUVertAttr* a = imm.vertex_format.attribs + a_idx; /* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */ @@ -702,16 +702,16 @@ void immVertex2iv(uint attrib_id, const int data[2]) #if 0 #if TRUST_NO_ONE - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); assert(uniform); + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); assert(uniform); #else - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); #endif #else /* NOTE: It is possible to have uniform fully optimized out from the shader. * In this case we can't assert failure or allow NULL-pointer dereference. * TODO(sergey): How can we detect existing-but-optimized-out uniform but still * catch typos in uniform names passed to immUniform*() functions? */ - #define GET_UNIFORM const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; + #define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return; #endif void immUniform1f(const char* name, float x) @@ -817,7 +817,7 @@ void immUniform4iv(const char* name, const int data[4]) void immUniformColor4f(float r, float g, float b, float a) { - const Gwn_ShaderInput* uniform = GWN_shaderinterface_uniform_builtin(imm.shader_interface, GWN_UNIFORM_COLOR); + const GPUShaderInput* uniform = GPU_shaderinterface_uniform_builtin(imm.shader_interface, GPU_UNIFORM_COLOR); #if TRUST_NO_ONE assert(uniform != NULL); #endif diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c index 4b2fb1b8e8a..b794048087a 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -18,10 +18,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_imm_util.c +/** \file blender/gpu/intern/gpu_imm_util.c * \ingroup gpu * - * Gawain immediate mode drawing utilities + * GPU immediate mode drawing utilities */ #include @@ -70,7 +70,7 @@ static const int cube_line_index[12][2] = { void immRectf(uint pos, float x1, float y1, float x2, float y2) { - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y1); immVertex2f(pos, x2, y2); @@ -80,7 +80,7 @@ void immRectf(uint pos, float x1, float y1, float x2, float y2) void immRecti(uint pos, int x1, int y1, int x2, int y2) { - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immVertex2i(pos, x1, y1); immVertex2i(pos, x2, y1); immVertex2i(pos, x2, y2); @@ -125,8 +125,8 @@ void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2 #if 0 /* more complete version in case we want that */ void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4]) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = add_attrib(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = add_attrib(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); immRecti(pos, x1, y1, x2, y2); @@ -153,7 +153,7 @@ void imm_cpack(unsigned int x) } static void imm_draw_circle( - Gwn_PrimType prim_type, const uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments) + GPUPrimType prim_type, const uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments) { immBegin(prim_type, nsegments); for (int i = 0; i < nsegments; ++i) { @@ -175,7 +175,7 @@ static void imm_draw_circle( */ void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float rad, int nsegments) { - imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad, rad, nsegments); + imm_draw_circle(GPU_PRIM_LINE_LOOP, shdr_pos, x, y, rad, rad, nsegments); } /** @@ -190,23 +190,23 @@ void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float rad, int nse */ void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float rad, int nsegments) { - imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad, rad, nsegments); + imm_draw_circle(GPU_PRIM_TRI_FAN, shdr_pos, x, y, rad, rad, nsegments); } void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments) { - imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad_x, rad_y, nsegments); + imm_draw_circle(GPU_PRIM_LINE_LOOP, shdr_pos, x, y, rad_x, rad_y, nsegments); } void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments) { - imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad_x, rad_y, nsegments); + imm_draw_circle(GPU_PRIM_TRI_FAN, shdr_pos, x, y, rad_x, rad_y, nsegments); } /** * \note We could have `imm_draw_lined_disk_partial` but currently there is no need. */ static void imm_draw_disk_partial( - Gwn_PrimType prim_type, unsigned pos, float x, float y, + GPUPrimType prim_type, unsigned pos, float x, float y, float rad_inner, float rad_outer, int nsegments, float start, float sweep) { /* shift & reverse angle, increase 'nsegments' to match gluPartialDisk */ @@ -243,11 +243,11 @@ void imm_draw_disk_partial_fill_2d( unsigned pos, float x, float y, float rad_inner, float rad_outer, int nsegments, float start, float sweep) { - imm_draw_disk_partial(GWN_PRIM_TRI_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep); + imm_draw_disk_partial(GPU_PRIM_TRI_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep); } static void imm_draw_circle_3D( - Gwn_PrimType prim_type, unsigned pos, float x, float y, + GPUPrimType prim_type, unsigned pos, float x, float y, float rad, int nsegments) { immBegin(prim_type, nsegments); @@ -260,12 +260,12 @@ static void imm_draw_circle_3D( void imm_draw_circle_wire_3d(unsigned pos, float x, float y, float rad, int nsegments) { - imm_draw_circle_3D(GWN_PRIM_LINE_LOOP, pos, x, y, rad, nsegments); + imm_draw_circle_3D(GPU_PRIM_LINE_LOOP, pos, x, y, rad, nsegments); } void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nsegments) { - imm_draw_circle_3D(GWN_PRIM_TRI_FAN, pos, x, y, rad, nsegments); + imm_draw_circle_3D(GPU_PRIM_TRI_FAN, pos, x, y, rad, nsegments); } /** @@ -279,7 +279,7 @@ void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nseg */ void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2) { - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x1, y2); immVertex2f(pos, x2, y2); @@ -289,8 +289,8 @@ void imm_draw_box_wire_2d(unsigned pos, float x1, float y1, float x2, float y2) void imm_draw_box_wire_3d(unsigned pos, float x1, float y1, float x2, float y2) { - /* use this version when Gwn_VertFormat has a vec3 position */ - immBegin(GWN_PRIM_LINE_LOOP, 4); + /* use this version when GPUVertFormat has a vec3 position */ + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex3f(pos, x1, y1, 0.0f); immVertex3f(pos, x1, y2, 0.0f); immVertex3f(pos, x2, y2, 0.0f); @@ -303,7 +303,7 @@ void imm_draw_box_wire_3d(unsigned pos, float x1, float y1, float x2, float y2) */ void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); immUniform4f("color1", 0.15f, 0.15f, 0.15f, 1.0f); @@ -323,7 +323,7 @@ void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3]) madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect); } - immBegin(GWN_PRIM_TRIS, ARRAY_SIZE(cube_quad_index) * 3 * 2); + immBegin(GPU_PRIM_TRIS, ARRAY_SIZE(cube_quad_index) * 3 * 2); for (int i = 0; i < ARRAY_SIZE(cube_quad_index); i++) { immVertex3fv(pos, coords[cube_quad_index[i][0]]); immVertex3fv(pos, coords[cube_quad_index[i][1]]); @@ -344,7 +344,7 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3]) madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect); } - immBegin(GWN_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 2); + immBegin(GPU_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 2); for (int i = 0; i < ARRAY_SIZE(cube_line_index); i++) { immVertex3fv(pos, coords[cube_line_index[i][0]]); immVertex3fv(pos, coords[cube_line_index[i][1]]); @@ -367,7 +367,7 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3]) void imm_draw_cylinder_fill_normal_3d( unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks) { - immBegin(GWN_PRIM_TRIS, 6 * slices * stacks); + immBegin(GPU_PRIM_TRIS, 6 * slices * stacks); for (int i = 0; i < slices; ++i) { const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices); const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices); @@ -418,7 +418,7 @@ void imm_draw_cylinder_fill_normal_3d( void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float height, int slices, int stacks) { - immBegin(GWN_PRIM_LINES, 6 * slices * stacks); + immBegin(GPU_PRIM_LINES, 6 * slices * stacks); for (int i = 0; i < slices; ++i) { const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices); const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices); @@ -455,7 +455,7 @@ void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float he void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float height, int slices, int stacks) { - immBegin(GWN_PRIM_TRIS, 6 * slices * stacks); + immBegin(GPU_PRIM_TRIS, 6 * slices * stacks); for (int i = 0; i < slices; ++i) { const float angle1 = (float)(2 * M_PI) * ((float)i / (float)slices); const float angle2 = (float)(2 * M_PI) * ((float)(i + 1) / (float)slices); diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c index 13c6fbea1c6..87fcc5f25a3 100644 --- a/source/blender/gpu/intern/gpu_matrix.c +++ b/source/blender/gpu/intern/gpu_matrix.c @@ -558,20 +558,20 @@ const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3] return m; } -void GPU_matrix_bind(const Gwn_ShaderInterface *shaderface) +void GPU_matrix_bind(const GPUShaderInterface *shaderface) { /* set uniform values to matrix stack values * call this before a draw call if desired matrices are dirty * call glUseProgram before this, as glUniform expects program to be bound */ - const Gwn_ShaderInput *MV = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_MODELVIEW); - const Gwn_ShaderInput *P = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_PROJECTION); - const Gwn_ShaderInput *MVP = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_MVP); + const GPUShaderInput *MV = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MODELVIEW); + const GPUShaderInput *P = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_PROJECTION); + const GPUShaderInput *MVP = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MVP); - const Gwn_ShaderInput *N = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_NORMAL); - const Gwn_ShaderInput *MV_inv = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_MODELVIEW_INV); - const Gwn_ShaderInput *P_inv = GWN_shaderinterface_uniform_builtin(shaderface, GWN_UNIFORM_PROJECTION_INV); + const GPUShaderInput *N = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_NORMAL); + const GPUShaderInput *MV_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_MODELVIEW_INV); + const GPUShaderInput *P_inv = GPU_shaderinterface_uniform_builtin(shaderface, GPU_UNIFORM_PROJECTION_INV); if (MV) { #if DEBUG_MATRIX_BIND diff --git a/source/blender/gpu/intern/gpu_primitive.c b/source/blender/gpu/intern/gpu_primitive.c index 0f0c28c05dc..189d17f2dd2 100644 --- a/source/blender/gpu/intern/gpu_primitive.c +++ b/source/blender/gpu/intern/gpu_primitive.c @@ -23,61 +23,61 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_primitive.c +/** \file blender/gpu/intern/gpu_primitive.c * \ingroup gpu * - * Gawain geometric primitives + * GPU geometric primitives */ #include "GPU_primitive.h" #include "gpu_primitive_private.h" -Gwn_PrimClass GWN_primtype_class(Gwn_PrimType prim_type) +GPUPrimClass GPU_primtype_class(GPUPrimType prim_type) { - static const Gwn_PrimClass classes[] = { - [GWN_PRIM_POINTS] = GWN_PRIM_CLASS_POINT, - [GWN_PRIM_LINES] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_LINE_STRIP] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_LINE_LOOP] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_TRIS] = GWN_PRIM_CLASS_SURFACE, - [GWN_PRIM_TRI_STRIP] = GWN_PRIM_CLASS_SURFACE, - [GWN_PRIM_TRI_FAN] = GWN_PRIM_CLASS_SURFACE, + static const GPUPrimClass classes[] = { + [GPU_PRIM_POINTS] = GPU_PRIM_CLASS_POINT, + [GPU_PRIM_LINES] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_LINE_STRIP] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_LINE_LOOP] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_TRIS] = GPU_PRIM_CLASS_SURFACE, + [GPU_PRIM_TRI_STRIP] = GPU_PRIM_CLASS_SURFACE, + [GPU_PRIM_TRI_FAN] = GPU_PRIM_CLASS_SURFACE, - [GWN_PRIM_LINES_ADJ] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_LINE_STRIP_ADJ] = GWN_PRIM_CLASS_LINE, - [GWN_PRIM_TRIS_ADJ] = GWN_PRIM_CLASS_SURFACE, + [GPU_PRIM_LINES_ADJ] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_LINE_STRIP_ADJ] = GPU_PRIM_CLASS_LINE, + [GPU_PRIM_TRIS_ADJ] = GPU_PRIM_CLASS_SURFACE, - [GWN_PRIM_NONE] = GWN_PRIM_CLASS_NONE + [GPU_PRIM_NONE] = GPU_PRIM_CLASS_NONE }; return classes[prim_type]; } -bool GWN_primtype_belongs_to_class(Gwn_PrimType prim_type, Gwn_PrimClass prim_class) +bool GPU_primtype_belongs_to_class(GPUPrimType prim_type, GPUPrimClass prim_class) { - if (prim_class == GWN_PRIM_CLASS_NONE && prim_type == GWN_PRIM_NONE) { + if (prim_class == GPU_PRIM_CLASS_NONE && prim_type == GPU_PRIM_NONE) { return true; } - return prim_class & GWN_primtype_class(prim_type); + return prim_class & GPU_primtype_class(prim_type); } -GLenum convert_prim_type_to_gl(Gwn_PrimType prim_type) +GLenum convert_prim_type_to_gl(GPUPrimType prim_type) { #if TRUST_NO_ONE - assert(prim_type != GWN_PRIM_NONE); + assert(prim_type != GPU_PRIM_NONE); #endif static const GLenum table[] = { - [GWN_PRIM_POINTS] = GL_POINTS, - [GWN_PRIM_LINES] = GL_LINES, - [GWN_PRIM_LINE_STRIP] = GL_LINE_STRIP, - [GWN_PRIM_LINE_LOOP] = GL_LINE_LOOP, - [GWN_PRIM_TRIS] = GL_TRIANGLES, - [GWN_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP, - [GWN_PRIM_TRI_FAN] = GL_TRIANGLE_FAN, + [GPU_PRIM_POINTS] = GL_POINTS, + [GPU_PRIM_LINES] = GL_LINES, + [GPU_PRIM_LINE_STRIP] = GL_LINE_STRIP, + [GPU_PRIM_LINE_LOOP] = GL_LINE_LOOP, + [GPU_PRIM_TRIS] = GL_TRIANGLES, + [GPU_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP, + [GPU_PRIM_TRI_FAN] = GL_TRIANGLE_FAN, - [GWN_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY, - [GWN_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY, - [GWN_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY, + [GPU_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY, + [GPU_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY, + [GPU_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY, }; return table[prim_type]; diff --git a/source/blender/gpu/intern/gpu_primitive_private.h b/source/blender/gpu/intern/gpu_primitive_private.h index 6d3f1e20da7..d057f29fdc5 100644 --- a/source/blender/gpu/intern/gpu_primitive_private.h +++ b/source/blender/gpu/intern/gpu_primitive_private.h @@ -23,15 +23,15 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_primitive_private.h +/** \file blender/gpu/intern/gpu_primitive_private.h * \ingroup gpu * - * Gawain geometric primitives + * GPU geometric primitives */ -#ifndef __GWN_PRIMITIVE_PRIVATE_H__ -#define __GWN_PRIMITIVE_PRIVATE_H__ +#ifndef __GPU_PRIMITIVE_PRIVATE_H__ +#define __GPU_PRIMITIVE_PRIVATE_H__ -GLenum convert_prim_type_to_gl(Gwn_PrimType); +GLenum convert_prim_type_to_gl(GPUPrimType); -#endif /* __GWN_PRIMITIVE_PRIVATE_H__ */ +#endif /* __GPU_PRIMITIVE_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 99baaa1164f..c5325b6ff21 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -496,24 +496,24 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode, return NULL; } - shader->interface = GWN_shaderinterface_create(shader->program); + shader->interface = GPU_shaderinterface_create(shader->program); #ifdef WITH_OPENSUBDIV /* TODO(sergey): Find a better place for this. */ if (use_opensubdiv) { if (GLEW_VERSION_4_1) { glProgramUniform1i(shader->program, - GWN_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, + GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30); /* GL_TEXTURE30 */ glProgramUniform1i(shader->program, - GWN_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, + GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, 31); /* GL_TEXTURE31 */ } else { glUseProgram(shader->program); - glUniform1i(GWN_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30); - glUniform1i(GWN_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, 31); + glUniform1i(GPU_shaderinterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30); + glUniform1i(GPU_shaderinterface_uniform(shader->interface, "FVarDataBuffer")->location, 31); glUseProgram(0); } } @@ -575,7 +575,7 @@ void GPU_shader_free(GPUShader *shader) glDeleteProgram(shader->program); if (shader->interface) - GWN_shaderinterface_discard(shader->interface); + GPU_shaderinterface_discard(shader->interface); MEM_freeN(shader); } @@ -583,14 +583,14 @@ void GPU_shader_free(GPUShader *shader) int GPU_shader_get_uniform(GPUShader *shader, const char *name) { BLI_assert(shader && shader->program); - const Gwn_ShaderInput *uniform = GWN_shaderinterface_uniform(shader->interface, name); + const GPUShaderInput *uniform = GPU_shaderinterface_uniform(shader->interface, name); return uniform ? uniform->location : -1; } int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin) { BLI_assert(shader && shader->program); - const Gwn_ShaderInput *uniform = GWN_shaderinterface_uniform_builtin(shader->interface, builtin); + const GPUShaderInput *uniform = GPU_shaderinterface_uniform_builtin(shader->interface, builtin); return uniform ? uniform->location : -1; } @@ -598,7 +598,7 @@ int GPU_shader_get_uniform_block(GPUShader *shader, const char *name) { BLI_assert(shader && shader->program); - const Gwn_ShaderInput *ubo = GWN_shaderinterface_ubo(shader->interface, name); + const GPUShaderInput *ubo = GPU_shaderinterface_ubo(shader->interface, name); return ubo ? ubo->location : -1; } @@ -675,7 +675,7 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText int GPU_shader_get_attribute(GPUShader *shader, const char *name) { BLI_assert(shader && shader->program); - const Gwn_ShaderInput *attrib = GWN_shaderinterface_attr(shader->interface, name); + const GPUShaderInput *attrib = GPU_shaderinterface_attr(shader->interface, name); return attrib ? attrib->location : -1; } diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index 56b25726a84..ec2f52a2a2d 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_shader_interface.c +/** \file blender/gpu/intern/gpu_shader_interface.c * \ingroup gpu * - * Gawain shader interface (C --> GLSL) + * GPU shader interface (C --> GLSL) */ #include "gpu_batch_private.h" @@ -42,46 +42,46 @@ #include #endif -static const char* BuiltinUniform_name(Gwn_UniformBuiltin u) +static const char* BuiltinUniform_name(GPUUniformBuiltin u) { static const char* names[] = { - [GWN_UNIFORM_NONE] = NULL, - - [GWN_UNIFORM_MODEL] = "ModelMatrix", - [GWN_UNIFORM_VIEW] = "ViewMatrix", - [GWN_UNIFORM_MODELVIEW] = "ModelViewMatrix", - [GWN_UNIFORM_PROJECTION] = "ProjectionMatrix", - [GWN_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix", - [GWN_UNIFORM_MVP] = "ModelViewProjectionMatrix", - - [GWN_UNIFORM_MODEL_INV] = "ModelMatrixInverse", - [GWN_UNIFORM_VIEW_INV] = "ViewMatrixInverse", - [GWN_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse", - [GWN_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse", - [GWN_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse", - - [GWN_UNIFORM_NORMAL] = "NormalMatrix", - [GWN_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix", - [GWN_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors", - [GWN_UNIFORM_ORCO] = "OrcoTexCoFactors", - - [GWN_UNIFORM_COLOR] = "color", - [GWN_UNIFORM_EYE] = "eye", - [GWN_UNIFORM_CALLID] = "callId", - - [GWN_UNIFORM_CUSTOM] = NULL, - [GWN_NUM_UNIFORMS] = NULL, + [GPU_UNIFORM_NONE] = NULL, + + [GPU_UNIFORM_MODEL] = "ModelMatrix", + [GPU_UNIFORM_VIEW] = "ViewMatrix", + [GPU_UNIFORM_MODELVIEW] = "ModelViewMatrix", + [GPU_UNIFORM_PROJECTION] = "ProjectionMatrix", + [GPU_UNIFORM_VIEWPROJECTION] = "ViewProjectionMatrix", + [GPU_UNIFORM_MVP] = "ModelViewProjectionMatrix", + + [GPU_UNIFORM_MODEL_INV] = "ModelMatrixInverse", + [GPU_UNIFORM_VIEW_INV] = "ViewMatrixInverse", + [GPU_UNIFORM_MODELVIEW_INV] = "ModelViewMatrixInverse", + [GPU_UNIFORM_PROJECTION_INV] = "ProjectionMatrixInverse", + [GPU_UNIFORM_VIEWPROJECTION_INV] = "ViewProjectionMatrixInverse", + + [GPU_UNIFORM_NORMAL] = "NormalMatrix", + [GPU_UNIFORM_WORLDNORMAL] = "WorldNormalMatrix", + [GPU_UNIFORM_CAMERATEXCO] = "CameraTexCoFactors", + [GPU_UNIFORM_ORCO] = "OrcoTexCoFactors", + + [GPU_UNIFORM_COLOR] = "color", + [GPU_UNIFORM_EYE] = "eye", + [GPU_UNIFORM_CALLID] = "callId", + + [GPU_UNIFORM_CUSTOM] = NULL, + [GPU_NUM_UNIFORMS] = NULL, }; return names[u]; } -GWN_INLINE bool match(const char* a, const char* b) +GPU_INLINE bool match(const char* a, const char* b) { return strcmp(a, b) == 0; } -GWN_INLINE uint hash_string(const char *str) +GPU_INLINE uint hash_string(const char *str) { uint i = 0, c; while ((c = *str++)) { @@ -90,7 +90,7 @@ GWN_INLINE uint hash_string(const char *str) return i; } -GWN_INLINE void set_input_name(Gwn_ShaderInterface* shaderface, Gwn_ShaderInput* input, +GPU_INLINE void set_input_name(GPUShaderInterface* shaderface, GPUShaderInput* input, const char* name, uint32_t name_len) { input->name_offset = shaderface->name_buffer_offset; @@ -98,20 +98,20 @@ GWN_INLINE void set_input_name(Gwn_ShaderInterface* shaderface, Gwn_ShaderInput* shaderface->name_buffer_offset += name_len + 1; /* include NULL terminator */ } -GWN_INLINE void shader_input_to_bucket(Gwn_ShaderInput* input, - Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) +GPU_INLINE void shader_input_to_bucket(GPUShaderInput* input, + GPUShaderInput* buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]) { - const uint bucket_index = input->name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; + const uint bucket_index = input->name_hash % GPU_NUM_SHADERINTERFACE_BUCKETS; input->next = buckets[bucket_index]; buckets[bucket_index] = input; } -GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[GWN_NUM_SHADERINTERFACE_BUCKETS], +GPU_INLINE const GPUShaderInput* buckets_lookup(GPUShaderInput* const buckets[GPU_NUM_SHADERINTERFACE_BUCKETS], const char *name_buffer, const char *name) { const uint name_hash = hash_string(name); - const uint bucket_index = name_hash % GWN_NUM_SHADERINTERFACE_BUCKETS; - const Gwn_ShaderInput* input = buckets[bucket_index]; + const uint bucket_index = name_hash % GPU_NUM_SHADERINTERFACE_BUCKETS; + const GPUShaderInput* input = buckets[bucket_index]; if (input == NULL) { /* Requested uniform is not found at all. */ return NULL; @@ -129,7 +129,7 @@ GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[ return NULL; } /* Work through possible collisions. */ - const Gwn_ShaderInput* next = input; + const GPUShaderInput* next = input; while (next != NULL) { input = next; next = input->next; @@ -143,37 +143,37 @@ GWN_INLINE const Gwn_ShaderInput* buckets_lookup(Gwn_ShaderInput* const buckets[ return NULL; /* not found */ } -GWN_INLINE void buckets_free(Gwn_ShaderInput* buckets[GWN_NUM_SHADERINTERFACE_BUCKETS]) +GPU_INLINE void buckets_free(GPUShaderInput* buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]) { - for (uint bucket_index = 0; bucket_index < GWN_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) { - Gwn_ShaderInput *input = buckets[bucket_index]; + for (uint bucket_index = 0; bucket_index < GPU_NUM_SHADERINTERFACE_BUCKETS; ++bucket_index) { + GPUShaderInput *input = buckets[bucket_index]; while (input != NULL) { - Gwn_ShaderInput *input_next = input->next; + GPUShaderInput *input_next = input->next; free(input); input = input_next; } } } -static bool setup_builtin_uniform(Gwn_ShaderInput* input, const char* name) +static bool setup_builtin_uniform(GPUShaderInput* input, const char* name) { /* TODO: reject DOUBLE, IMAGE, ATOMIC_COUNTER gl_types */ /* detect built-in uniforms (name must match) */ - for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { + for (GPUUniformBuiltin u = GPU_UNIFORM_NONE + 1; u < GPU_UNIFORM_CUSTOM; ++u) { const char* builtin_name = BuiltinUniform_name(u); if (match(name, builtin_name)) { input->builtin_type = u; return true; } } - input->builtin_type = GWN_UNIFORM_CUSTOM; + input->builtin_type = GPU_UNIFORM_CUSTOM; return false; } -static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const char* name) +static const GPUShaderInput* add_uniform(GPUShaderInterface* shaderface, const char* name) { - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); + GPUShaderInput* input = malloc(sizeof(GPUShaderInput)); input->location = glGetUniformLocation(shaderface->program, name); @@ -186,13 +186,13 @@ static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const setup_builtin_uniform(input, name); shader_input_to_bucket(input, shaderface->uniform_buckets); - if (input->builtin_type != GWN_UNIFORM_NONE && - input->builtin_type != GWN_UNIFORM_CUSTOM) + if (input->builtin_type != GPU_UNIFORM_NONE && + input->builtin_type != GPU_UNIFORM_CUSTOM) { shaderface->builtin_uniforms[input->builtin_type] = input; } #if DEBUG_SHADER_INTERFACE - printf("Gwn_ShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, + printf("GPUShaderInterface %p, program %d, uniform[] '%s' at location %d\n", shaderface, shaderface->program, name, input->location); @@ -200,14 +200,14 @@ static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const return input; } -Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) +GPUShaderInterface* GPU_shaderinterface_create(int32_t program) { - Gwn_ShaderInterface* shaderface = calloc(1, sizeof(Gwn_ShaderInterface)); + GPUShaderInterface* shaderface = calloc(1, sizeof(GPUShaderInterface)); shaderface->program = program; #if DEBUG_SHADER_INTERFACE printf("%s {\n", __func__); /* enter function */ - printf("Gwn_ShaderInterface %p, program %d\n", shaderface, program); + printf("GPUShaderInterface %p, program %d\n", shaderface, program); #endif GLint max_attrib_name_len, attr_len; @@ -223,7 +223,7 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) /* Attributes */ for (uint32_t i = 0; i < attr_len; ++i) { - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); + GPUShaderInput* input = malloc(sizeof(GPUShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; char* name = shaderface->name_buffer + shaderface->name_buffer_offset; GLsizei name_len = 0; @@ -250,7 +250,7 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) } /* Uniform Blocks */ for (uint32_t i = 0; i < ubo_len; ++i) { - Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); + GPUShaderInput* input = malloc(sizeof(GPUShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; char* name = shaderface->name_buffer + shaderface->name_buffer_offset; GLsizei name_len = 0; @@ -268,20 +268,20 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) #endif } /* Builtin Uniforms */ - for (Gwn_UniformBuiltin u = GWN_UNIFORM_NONE + 1; u < GWN_UNIFORM_CUSTOM; ++u) { + for (GPUUniformBuiltin u = GPU_UNIFORM_NONE + 1; u < GPU_UNIFORM_CUSTOM; ++u) { const char* builtin_name = BuiltinUniform_name(u); if (glGetUniformLocation(program, builtin_name) != -1) { - add_uniform((Gwn_ShaderInterface*)shaderface, builtin_name); + add_uniform((GPUShaderInterface*)shaderface, builtin_name); } } /* Batches ref buffer */ - shaderface->batches_len = GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = calloc(shaderface->batches_len, sizeof(Gwn_Batch*)); + shaderface->batches_len = GPU_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = calloc(shaderface->batches_len, sizeof(GPUBatch*)); return shaderface; } -void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) +void GPU_shaderinterface_discard(GPUShaderInterface* shaderface) { /* Free memory used by buckets and has entries. */ buckets_free(shaderface->uniform_buckets); @@ -292,7 +292,7 @@ void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) /* Remove this interface from all linked Batches vao cache. */ for (int i = 0; i < shaderface->batches_len; ++i) { if (shaderface->batches[i] != NULL) { - gwn_batch_remove_interface_ref(shaderface->batches[i], shaderface); + gpu_batch_remove_interface_ref(shaderface->batches[i], shaderface); } } free(shaderface->batches); @@ -300,39 +300,39 @@ void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) free(shaderface); } -const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface* shaderface, const char* name) +const GPUShaderInput* GPU_shaderinterface_uniform(const GPUShaderInterface* shaderface, const char* name) { /* TODO: Warn if we find a matching builtin, since these can be looked up much quicker. */ - const Gwn_ShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name); + const GPUShaderInput* input = buckets_lookup(shaderface->uniform_buckets, shaderface->name_buffer, name); /* If input is not found add it so it's found next time. */ if (input == NULL) { - input = add_uniform((Gwn_ShaderInterface*)shaderface, name); + input = add_uniform((GPUShaderInterface*)shaderface, name); } return (input->location != -1) ? input : NULL; } -const Gwn_ShaderInput* GWN_shaderinterface_uniform_builtin( - const Gwn_ShaderInterface* shaderface, Gwn_UniformBuiltin builtin) +const GPUShaderInput* GPU_shaderinterface_uniform_builtin( + const GPUShaderInterface* shaderface, GPUUniformBuiltin builtin) { #if TRUST_NO_ONE - assert(builtin != GWN_UNIFORM_NONE); - assert(builtin != GWN_UNIFORM_CUSTOM); - assert(builtin != GWN_NUM_UNIFORMS); + assert(builtin != GPU_UNIFORM_NONE); + assert(builtin != GPU_UNIFORM_CUSTOM); + assert(builtin != GPU_NUM_UNIFORMS); #endif return shaderface->builtin_uniforms[builtin]; } -const Gwn_ShaderInput* GWN_shaderinterface_ubo(const Gwn_ShaderInterface* shaderface, const char* name) +const GPUShaderInput* GPU_shaderinterface_ubo(const GPUShaderInterface* shaderface, const char* name) { return buckets_lookup(shaderface->ubo_buckets, shaderface->name_buffer, name); } -const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shaderface, const char* name) +const GPUShaderInput* GPU_shaderinterface_attr(const GPUShaderInterface* shaderface, const char* name) { return buckets_lookup(shaderface->attrib_buckets, shaderface->name_buffer, name); } -void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) +void GPU_shaderinterface_add_batch_ref(GPUShaderInterface* shaderface, GPUBatch* batch) { int i; /* find first unused slot */ for (i = 0; i < shaderface->batches_len; ++i) { @@ -343,14 +343,14 @@ void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batc if (i == shaderface->batches_len) { /* Not enough place, realloc the array. */ i = shaderface->batches_len; - shaderface->batches_len += GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_len); - memset(shaderface->batches + i, 0, sizeof(Gwn_Batch*) * GWN_SHADERINTERFACE_REF_ALLOC_COUNT); + shaderface->batches_len += GPU_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = realloc(shaderface->batches, sizeof(GPUBatch*) * shaderface->batches_len); + memset(shaderface->batches + i, 0, sizeof(GPUBatch*) * GPU_SHADERINTERFACE_REF_ALLOC_COUNT); } shaderface->batches[i] = batch; } -void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) +void GPU_shaderinterface_remove_batch_ref(GPUShaderInterface* shaderface, GPUBatch* batch) { for (int i = 0; i < shaderface->batches_len; ++i) { if (shaderface->batches[i] == batch) { diff --git a/source/blender/gpu/intern/gpu_shader_private.h b/source/blender/gpu/intern/gpu_shader_private.h index bf54d269fb5..d16aae79aae 100644 --- a/source/blender/gpu/intern/gpu_shader_private.h +++ b/source/blender/gpu/intern/gpu_shader_private.h @@ -35,7 +35,7 @@ struct GPUShader { GLuint geometry; /* handle for geometry shader */ GLuint fragment; /* handle for fragment shader */ - Gwn_ShaderInterface *interface; /* cached uniform & attrib interface for shader */ + GPUShaderInterface *interface; /* cached uniform & attrib interface for shader */ int feedback_transform_type; }; diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index d9248e06dfb..52afe17d885 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -911,28 +911,28 @@ GPUTexture *GPU_texture_create_cube( tex_format, GPU_DATA_FLOAT, err_out); } -GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) +GPUTexture *GPU_texture_create_from_vertbuf(GPUVertBuf *vert) { - Gwn_VertFormat *format = &vert->format; - Gwn_VertAttr *attr = &format->attribs[0]; + GPUVertFormat *format = &vert->format; + GPUVertAttr *attr = &format->attribs[0]; /* Detect incompatible cases (not supported by texture buffers) */ BLI_assert(format->attr_len == 1 && vert->vbo_id != 0); BLI_assert(attr->comp_len != 3); /* Not until OGL 4.0 */ - BLI_assert(attr->comp_type != GWN_COMP_I10); - BLI_assert(attr->fetch_mode != GWN_FETCH_INT_TO_FLOAT); + BLI_assert(attr->comp_type != GPU_COMP_I10); + BLI_assert(attr->fetch_mode != GPU_FETCH_INT_TO_FLOAT); unsigned int byte_per_comp = attr->sz / attr->comp_len; - bool is_uint = ELEM(attr->comp_type, GWN_COMP_U8, GWN_COMP_U16, GWN_COMP_U32); + bool is_uint = ELEM(attr->comp_type, GPU_COMP_U8, GPU_COMP_U16, GPU_COMP_U32); /* Cannot fetch signed int or 32bit ints as normalized float. */ - if (attr->fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT) { + if (attr->fetch_mode == GPU_FETCH_INT_TO_FLOAT_UNIT) { BLI_assert(is_uint || byte_per_comp <= 2); } GPUTextureFormat data_type; switch (attr->fetch_mode) { - case GWN_FETCH_FLOAT: + case GPU_FETCH_FLOAT: switch (attr->comp_len) { case 1: data_type = GPU_R32F; break; case 2: data_type = GPU_RG32F; break; @@ -940,7 +940,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) default: data_type = GPU_RGBA32F; break; } break; - case GWN_FETCH_INT: + case GPU_FETCH_INT: switch (attr->comp_len) { case 1: switch (byte_per_comp) { @@ -965,7 +965,7 @@ GPUTexture *GPU_texture_create_from_vertbuf(Gwn_VertBuf *vert) break; } break; - case GWN_FETCH_INT_TO_FLOAT_UNIT: + case GPU_FETCH_INT_TO_FLOAT_UNIT: switch (attr->comp_len) { case 1: data_type = (byte_per_comp == 1) ? GPU_R8 : GPU_R16; break; case 2: data_type = (byte_per_comp == 1) ? GPU_RG8 : GPU_RG16; break; diff --git a/source/blender/gpu/intern/gpu_vertex_array_id.cpp b/source/blender/gpu/intern/gpu_vertex_array_id.cpp index de5be15ec19..2f29bbfbc33 100644 --- a/source/blender/gpu/intern/gpu_vertex_array_id.cpp +++ b/source/blender/gpu/intern/gpu_vertex_array_id.cpp @@ -23,7 +23,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_array_id.cpp +/** \file blender/gpu/gpu_vertex_array_id.cpp * \ingroup gpu * * Manage GL vertex array IDs in a thread-safe way @@ -56,16 +56,16 @@ static bool thread_is_main() { #endif #endif -struct Gwn_Context { +struct GPUContext { GLuint default_vao; - std::unordered_set batches; /* Batches that have VAOs from this context */ + std::unordered_set batches; /* Batches that have VAOs from this context */ std::vector orphaned_vertarray_ids; std::mutex orphans_mutex; /* todo: try spinlock instead */ #if TRUST_NO_ONE pthread_t thread; /* Thread on which this context is active. */ bool thread_is_used; - Gwn_Context() { + GPUContext() { thread_is_used = false; } #endif @@ -73,12 +73,12 @@ struct Gwn_Context { #if defined(_MSC_VER) && (_MSC_VER == 1800) #define thread_local __declspec(thread) -thread_local Gwn_Context* active_ctx = NULL; +thread_local GPUContext* active_ctx = NULL; #else -static thread_local Gwn_Context* active_ctx = NULL; +static thread_local GPUContext* active_ctx = NULL; #endif -static void clear_orphans(Gwn_Context* ctx) +static void clear_orphans(GPUContext* ctx) { ctx->orphans_mutex.lock(); if (!ctx->orphaned_vertarray_ids.empty()) { @@ -89,19 +89,19 @@ static void clear_orphans(Gwn_Context* ctx) ctx->orphans_mutex.unlock(); } -Gwn_Context* GWN_context_create(void) +GPUContext* GPU_context_create(void) { #if TRUST_NO_ONE /* assert(thread_is_main()); */ #endif - Gwn_Context* ctx = new Gwn_Context; + GPUContext* ctx = new GPUContext; glGenVertexArrays(1, &ctx->default_vao); - GWN_context_active_set(ctx); + GPU_context_active_set(ctx); return ctx; } -/* to be called after GWN_context_active_set(ctx_to_destroy) */ -void GWN_context_discard(Gwn_Context* ctx) +/* to be called after GPU_context_active_set(ctx_to_destroy) */ +void GPU_context_discard(GPUContext* ctx) { #if TRUST_NO_ONE /* Make sure no other thread has locked it. */ @@ -112,7 +112,7 @@ void GWN_context_discard(Gwn_Context* ctx) /* delete remaining vaos */ while (!ctx->batches.empty()) { /* this removes the array entry */ - gwn_batch_vao_cache_clear(*ctx->batches.begin()); + GPU_batch_vao_cache_clear(*ctx->batches.begin()); } glDeleteVertexArrays(1, &ctx->default_vao); delete ctx; @@ -120,7 +120,7 @@ void GWN_context_discard(Gwn_Context* ctx) } /* ctx can be NULL */ -void GWN_context_active_set(Gwn_Context* ctx) +void GPU_context_active_set(GPUContext* ctx) { #if TRUST_NO_ONE if (active_ctx) { @@ -140,12 +140,12 @@ void GWN_context_active_set(Gwn_Context* ctx) active_ctx = ctx; } -Gwn_Context* GWN_context_active_get(void) +GPUContext* GPU_context_active_get(void) { return active_ctx; } -GLuint GWN_vao_default(void) +GLuint GPU_vao_default(void) { #if TRUST_NO_ONE assert(active_ctx); /* need at least an active context */ @@ -154,7 +154,7 @@ GLuint GWN_vao_default(void) return active_ctx->default_vao; } -GLuint GWN_vao_alloc(void) +GLuint GPU_vao_alloc(void) { #if TRUST_NO_ONE assert(active_ctx); /* need at least an active context */ @@ -168,7 +168,7 @@ GLuint GWN_vao_alloc(void) } /* this can be called from multiple thread */ -void GWN_vao_free(GLuint vao_id, Gwn_Context* ctx) +void GPU_vao_free(GLuint vao_id, GPUContext* ctx) { #if TRUST_NO_ONE assert(ctx); @@ -183,12 +183,12 @@ void GWN_vao_free(GLuint vao_id, Gwn_Context* ctx) } } -void gwn_context_add_batch(Gwn_Context* ctx, Gwn_Batch* batch) +void gpu_context_add_batch(GPUContext* ctx, GPUBatch* batch) { ctx->batches.emplace(batch); } -void gwn_context_remove_batch(Gwn_Context* ctx, Gwn_Batch* batch) +void gpu_context_remove_batch(GPUContext* ctx, GPUBatch* batch) { ctx->orphans_mutex.lock(); ctx->batches.erase(batch); diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c index 32f3d494015..5b29913800d 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer.c +++ b/source/blender/gpu/intern/gpu_vertex_buffer.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_vertex_buffer.c +/** \file blender/gpu/intern/gpu_vertex_buffer.c * \ingroup gpu * - * Gawain vertex buffer + * GPU vertex buffer */ #include "GPU_vertex_buffer.h" @@ -39,27 +39,27 @@ static uint vbo_memory_usage; -static GLenum convert_usage_type_to_gl(Gwn_UsageType type) +static GLenum convert_usage_type_to_gl(GPUUsageType type) { static const GLenum table[] = { - [GWN_USAGE_STREAM] = GL_STREAM_DRAW, - [GWN_USAGE_STATIC] = GL_STATIC_DRAW, - [GWN_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW + [GPU_USAGE_STREAM] = GL_STREAM_DRAW, + [GPU_USAGE_STATIC] = GL_STATIC_DRAW, + [GPU_USAGE_DYNAMIC] = GL_DYNAMIC_DRAW }; return table[type]; } -Gwn_VertBuf* GWN_vertbuf_create(Gwn_UsageType usage) +GPUVertBuf* GPU_vertbuf_create(GPUUsageType usage) { - Gwn_VertBuf* verts = malloc(sizeof(Gwn_VertBuf)); - GWN_vertbuf_init(verts, usage); + GPUVertBuf* verts = malloc(sizeof(GPUVertBuf)); + GPU_vertbuf_init(verts, usage); return verts; } -Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat* format, Gwn_UsageType usage) +GPUVertBuf* GPU_vertbuf_create_with_format_ex(const GPUVertFormat* format, GPUUsageType usage) { - Gwn_VertBuf* verts = GWN_vertbuf_create(usage); - GWN_vertformat_copy(&verts->format, format); + GPUVertBuf* verts = GPU_vertbuf_create(usage); + GPU_vertformat_copy(&verts->format, format); if (!format->packed) { VertexFormat_pack(&verts->format); } @@ -69,28 +69,28 @@ Gwn_VertBuf* GWN_vertbuf_create_with_format_ex(const Gwn_VertFormat* format, Gwn /* TODO: implement those memory savings */ } -void GWN_vertbuf_init(Gwn_VertBuf* verts, Gwn_UsageType usage) +void GPU_vertbuf_init(GPUVertBuf* verts, GPUUsageType usage) { - memset(verts, 0, sizeof(Gwn_VertBuf)); + memset(verts, 0, sizeof(GPUVertBuf)); verts->usage = usage; verts->dirty = true; } -void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf* verts, const Gwn_VertFormat* format, Gwn_UsageType usage) +void GPU_vertbuf_init_with_format_ex(GPUVertBuf* verts, const GPUVertFormat* format, GPUUsageType usage) { - GWN_vertbuf_init(verts, usage); - GWN_vertformat_copy(&verts->format, format); + GPU_vertbuf_init(verts, usage); + GPU_vertformat_copy(&verts->format, format); if (!format->packed) { VertexFormat_pack(&verts->format); } } -void GWN_vertbuf_discard(Gwn_VertBuf* verts) +void GPU_vertbuf_discard(GPUVertBuf* verts) { if (verts->vbo_id) { - GWN_buf_id_free(verts->vbo_id); + GPU_buf_id_free(verts->vbo_id); #if VRAM_USAGE - vbo_memory_usage -= GWN_vertbuf_size_get(verts); + vbo_memory_usage -= GPU_vertbuf_size_get(verts); #endif } if (verts->data) { @@ -99,15 +99,15 @@ void GWN_vertbuf_discard(Gwn_VertBuf* verts) free(verts); } -uint GWN_vertbuf_size_get(const Gwn_VertBuf* verts) +uint GPU_vertbuf_size_get(const GPUVertBuf* verts) { return vertex_buffer_size(&verts->format, verts->vertex_len); } /* create a new allocation, discarding any existing data */ -void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, uint v_len) +void GPU_vertbuf_data_alloc(GPUVertBuf* verts, uint v_len) { - Gwn_VertFormat* format = &verts->format; + GPUVertFormat* format = &verts->format; if (!format->packed) { VertexFormat_pack(format); } @@ -117,7 +117,7 @@ void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, uint v_len) #endif /* only create the buffer the 1st time */ if (verts->vbo_id == 0) { - verts->vbo_id = GWN_buf_id_alloc(); + verts->vbo_id = GPU_buf_id_alloc(); } /* discard previous data if any */ if (verts->data) { @@ -125,15 +125,15 @@ void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, uint v_len) } #if VRAM_USAGE uint new_size = vertex_buffer_size(&verts->format, v_len); - vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); + vbo_memory_usage += new_size - GPU_vertbuf_size_get(verts); #endif verts->dirty = true; verts->vertex_len = verts->vertex_alloc = v_len; - verts->data = malloc(sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); + verts->data = malloc(sizeof(GLubyte) * GPU_vertbuf_size_get(verts)); } /* resize buffer keeping existing data */ -void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, uint v_len) +void GPU_vertbuf_data_resize(GPUVertBuf* verts, uint v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); @@ -142,17 +142,17 @@ void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, uint v_len) #if VRAM_USAGE uint new_size = vertex_buffer_size(&verts->format, v_len); - vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); + vbo_memory_usage += new_size - GPU_vertbuf_size_get(verts); #endif verts->dirty = true; verts->vertex_len = verts->vertex_alloc = v_len; - verts->data = realloc(verts->data, sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); + verts->data = realloc(verts->data, sizeof(GLubyte) * GPU_vertbuf_size_get(verts)); } /* Set vertex count but does not change allocation. * Only this many verts will be uploaded to the GPU and rendered. * This is usefull for streaming data. */ -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, uint v_len) +void GPU_vertbuf_vertex_count_set(GPUVertBuf* verts, uint v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); /* only for dynamic data */ @@ -161,15 +161,15 @@ void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, uint v_len) #if VRAM_USAGE uint new_size = vertex_buffer_size(&verts->format, v_len); - vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); + vbo_memory_usage += new_size - GPU_vertbuf_size_get(verts); #endif verts->vertex_len = v_len; } -void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, uint a_idx, uint v_idx, const void* data) +void GPU_vertbuf_attr_set(GPUVertBuf* verts, uint a_idx, uint v_idx, const void* data) { - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertFormat* format = &verts->format; + const GPUVertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -180,23 +180,23 @@ void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, uint a_idx, uint v_idx, const void memcpy((GLubyte*)verts->data + a->offset + v_idx * format->stride, data, a->sz); } -void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, uint a_idx, const void* data) +void GPU_vertbuf_attr_fill(GPUVertBuf* verts, uint a_idx, const void* data) { - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertFormat* format = &verts->format; + const GPUVertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); #endif const uint stride = a->sz; /* tightly packed input data */ - GWN_vertbuf_attr_fill_stride(verts, a_idx, stride, data); + GPU_vertbuf_attr_fill_stride(verts, a_idx, stride, data); } -void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, uint a_idx, uint stride, const void* data) +void GPU_vertbuf_attr_fill_stride(GPUVertBuf* verts, uint a_idx, uint stride, const void* data) { - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertFormat* format = &verts->format; + const GPUVertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -217,10 +217,10 @@ void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, uint a_idx, uint stride, c } } -void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, uint a_idx, Gwn_VertBufRaw *access) +void GPU_vertbuf_attr_get_raw_data(GPUVertBuf* verts, uint a_idx, GPUVertBufRaw *access) { - const Gwn_VertFormat* format = &verts->format; - const Gwn_VertAttr* a = format->attribs + a_idx; + const GPUVertFormat* format = &verts->format; + const GPUVertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE assert(a_idx < format->attr_len); @@ -238,23 +238,23 @@ void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, uint a_idx, Gwn_VertBufRa #endif } -static void VertBuffer_upload_data(Gwn_VertBuf* verts) +static void VertBuffer_upload_data(GPUVertBuf* verts) { - uint buffer_sz = GWN_vertbuf_size_get(verts); + uint buffer_sz = GPU_vertbuf_size_get(verts); /* orphan the vbo to avoid sync */ glBufferData(GL_ARRAY_BUFFER, buffer_sz, NULL, convert_usage_type_to_gl(verts->usage)); /* upload data */ glBufferSubData(GL_ARRAY_BUFFER, 0, buffer_sz, verts->data); - if (verts->usage == GWN_USAGE_STATIC) { + if (verts->usage == GPU_USAGE_STATIC) { free(verts->data); verts->data = NULL; } verts->dirty = false; } -void GWN_vertbuf_use(Gwn_VertBuf* verts) +void GPU_vertbuf_use(GPUVertBuf* verts) { glBindBuffer(GL_ARRAY_BUFFER, verts->vbo_id); if (verts->dirty) { @@ -262,7 +262,7 @@ void GWN_vertbuf_use(Gwn_VertBuf* verts) } } -uint GWN_vertbuf_get_memory_usage(void) +uint GPU_vertbuf_get_memory_usage(void) { return vbo_memory_usage; } diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index bd9f9250564..d0a907bcd0d 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -23,10 +23,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/intern/gwn_vertex_format.c +/** \file blender/gpu/intern/gpu_vertex_format.c * \ingroup gpu * - * Gawain vertex format + * GPU vertex format */ #include "GPU_vertex_format.h" @@ -40,26 +40,26 @@ #include #endif -void GWN_vertformat_clear(Gwn_VertFormat* format) +void GPU_vertformat_clear(GPUVertFormat* format) { #if TRUST_NO_ONE - memset(format, 0, sizeof(Gwn_VertFormat)); + memset(format, 0, sizeof(GPUVertFormat)); #else format->attr_len = 0; format->packed = false; format->name_offset = 0; format->name_len = 0; - for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++) { + for (unsigned i = 0; i < GPU_VERT_ATTR_MAX_LEN; i++) { format->attribs[i].name_len = 0; } #endif } -void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src) +void GPU_vertformat_copy(GPUVertFormat* dest, const GPUVertFormat* src) { /* copy regular struct fields */ - memcpy(dest, src, sizeof(Gwn_VertFormat)); + memcpy(dest, src, sizeof(GPUVertFormat)); for (unsigned i = 0; i < dest->attr_len; i++) { for (unsigned j = 0; j < dest->attribs[i].name_len; j++) { @@ -68,43 +68,43 @@ void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src) } } -static GLenum convert_comp_type_to_gl(Gwn_VertCompType type) +static GLenum convert_comp_type_to_gl(GPUVertCompType type) { static const GLenum table[] = { - [GWN_COMP_I8] = GL_BYTE, - [GWN_COMP_U8] = GL_UNSIGNED_BYTE, - [GWN_COMP_I16] = GL_SHORT, - [GWN_COMP_U16] = GL_UNSIGNED_SHORT, - [GWN_COMP_I32] = GL_INT, - [GWN_COMP_U32] = GL_UNSIGNED_INT, + [GPU_COMP_I8] = GL_BYTE, + [GPU_COMP_U8] = GL_UNSIGNED_BYTE, + [GPU_COMP_I16] = GL_SHORT, + [GPU_COMP_U16] = GL_UNSIGNED_SHORT, + [GPU_COMP_I32] = GL_INT, + [GPU_COMP_U32] = GL_UNSIGNED_INT, - [GWN_COMP_F32] = GL_FLOAT, + [GPU_COMP_F32] = GL_FLOAT, - [GWN_COMP_I10] = GL_INT_2_10_10_10_REV + [GPU_COMP_I10] = GL_INT_2_10_10_10_REV }; return table[type]; } -static unsigned comp_sz(Gwn_VertCompType type) +static unsigned comp_sz(GPUVertCompType type) { #if TRUST_NO_ONE - assert(type <= GWN_COMP_F32); /* other types have irregular sizes (not bytes) */ + assert(type <= GPU_COMP_F32); /* other types have irregular sizes (not bytes) */ #endif const GLubyte sizes[] = {1,1,2,2,4,4,4}; return sizes[type]; } -static unsigned attrib_sz(const Gwn_VertAttr *a) +static unsigned attrib_sz(const GPUVertAttr *a) { - if (a->comp_type == GWN_COMP_I10) { + if (a->comp_type == GPU_COMP_I10) { return 4; /* always packed as 10_10_10_2 */ } return a->comp_len * comp_sz(a->comp_type); } -static unsigned attrib_align(const Gwn_VertAttr *a) +static unsigned attrib_align(const GPUVertAttr *a) { - if (a->comp_type == GWN_COMP_I10) { + if (a->comp_type == GPU_COMP_I10) { return 4; /* always packed as 10_10_10_2 */ } unsigned c = comp_sz(a->comp_type); @@ -116,7 +116,7 @@ static unsigned attrib_align(const Gwn_VertAttr *a) } } -unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_len) +unsigned vertex_buffer_size(const GPUVertFormat* format, unsigned vertex_len) { #if TRUST_NO_ONE assert(format->packed && format->stride > 0); @@ -124,11 +124,11 @@ unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_len) return format->stride * vertex_len; } -static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) +static const char* copy_attrib_name(GPUVertFormat* format, const char* name) { /* strncpy does 110% of what we need; let's do exactly 100% */ char* name_copy = format->names + format->name_offset; - unsigned available = GWN_VERT_ATTR_NAMES_BUF_LEN - format->name_offset; + unsigned available = GPU_VERT_ATTR_NAMES_BUF_LEN - format->name_offset; bool terminated = false; for (unsigned i = 0; i < available; ++i) { @@ -142,35 +142,35 @@ static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) } #if TRUST_NO_ONE assert(terminated); - assert(format->name_offset <= GWN_VERT_ATTR_NAMES_BUF_LEN); + assert(format->name_offset <= GPU_VERT_ATTR_NAMES_BUF_LEN); #else (void)terminated; #endif return name_copy; } -unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_len, Gwn_VertFetchMode fetch_mode) +unsigned GPU_vertformat_attr_add(GPUVertFormat* format, const char* name, GPUVertCompType comp_type, unsigned comp_len, GPUVertFetchMode fetch_mode) { #if TRUST_NO_ONE - assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ - assert(format->attr_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(format->attr_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */ assert(!format->packed); /* packed means frozen/locked */ assert((comp_len >= 1 && comp_len <= 4) || comp_len == 8 || comp_len == 12 || comp_len == 16); switch (comp_type) { - case GWN_COMP_F32: + case GPU_COMP_F32: /* float type can only kept as float */ - assert(fetch_mode == GWN_FETCH_FLOAT); + assert(fetch_mode == GPU_FETCH_FLOAT); break; - case GWN_COMP_I10: + case GPU_COMP_I10: /* 10_10_10 format intended for normals (xyz) or colors (rgb) * extra component packed.w can be manually set to { -2, -1, 0, 1 } */ assert(comp_len == 3 || comp_len == 4); - assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); /* not strictly required, may relax later */ + assert(fetch_mode == GPU_FETCH_INT_TO_FLOAT_UNIT); /* not strictly required, may relax later */ break; default: /* integer types can be kept as int or converted/normalized to float */ - assert(fetch_mode != GWN_FETCH_FLOAT); + assert(fetch_mode != GPU_FETCH_FLOAT); /* only support float matrices (see Batch_update_program_bindings) */ assert(comp_len != 8 && comp_len != 12 && comp_len != 16); } @@ -178,12 +178,12 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V format->name_len++; /* multiname support */ const unsigned attrib_id = format->attr_len++; - Gwn_VertAttr* attrib = format->attribs + attrib_id; + GPUVertAttr* attrib = format->attribs + attrib_id; attrib->name[attrib->name_len++] = copy_attrib_name(format, name); attrib->comp_type = comp_type; attrib->gl_comp_type = convert_comp_type_to_gl(comp_type); - attrib->comp_len = (comp_type == GWN_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */ + attrib->comp_len = (comp_type == GPU_COMP_I10) ? 4 : comp_len; /* system needs 10_10_10_2 to be 4 or BGRA */ attrib->sz = attrib_sz(attrib); attrib->offset = 0; /* offsets & stride are calculated later (during pack) */ attrib->fetch_mode = fetch_mode; @@ -191,12 +191,12 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V return attrib_id; } -void GWN_vertformat_alias_add(Gwn_VertFormat* format, const char* alias) +void GPU_vertformat_alias_add(GPUVertFormat* format, const char* alias) { - Gwn_VertAttr* attrib = format->attribs + (format->attr_len - 1); + GPUVertAttr* attrib = format->attribs + (format->attr_len - 1); #if TRUST_NO_ONE - assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); /* there's room for more */ - assert(attrib->name_len < GWN_VERT_ATTR_MAX_NAMES); + assert(format->name_len < GPU_VERT_ATTR_MAX_LEN); /* there's room for more */ + assert(attrib->name_len < GPU_VERT_ATTR_MAX_NAMES); #endif format->name_len++; /* multiname support */ attrib->name[attrib->name_len++] = copy_attrib_name(format, alias); @@ -221,7 +221,7 @@ static void show_pack(unsigned a_idx, unsigned sz, unsigned pad) } #endif -void VertexFormat_pack(Gwn_VertFormat* format) +void VertexFormat_pack(GPUVertFormat* format) { /* For now, attributes are packed in the order they were added, * making sure each attrib is naturally aligned (add padding where necessary) @@ -231,7 +231,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) /* TODO: realloc just enough to hold the final combo string. And just enough to * hold used attribs, not all 16. */ - Gwn_VertAttr* a0 = format->attribs + 0; + GPUVertAttr* a0 = format->attribs + 0; a0->offset = 0; unsigned offset = a0->sz; @@ -240,7 +240,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) #endif for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) { - Gwn_VertAttr* a = format->attribs + a_idx; + GPUVertAttr* a = format->attribs + a_idx; unsigned mid_padding = padding(offset, attrib_align(a)); offset += mid_padding; a->offset = offset; @@ -263,7 +263,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) /* OpenGL ES packs in a different order as desktop GL but component conversion is the same. - * Of the code here, only struct Gwn_PackedNormal needs to change. */ + * Of the code here, only struct GPUPackedNormal needs to change. */ #define SIGNED_INT_10_MAX 511 #define SIGNED_INT_10_MIN -512 @@ -297,14 +297,14 @@ static int convert_i16(short x) return x >> 6; } -Gwn_PackedNormal GWN_normal_convert_i10_v3(const float data[3]) +GPUPackedNormal GPU_normal_convert_i10_v3(const float data[3]) { - Gwn_PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) }; + GPUPackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = quantize(data[2]) }; return n; } -Gwn_PackedNormal GWN_normal_convert_i10_s3(const short data[3]) +GPUPackedNormal GPU_normal_convert_i10_s3(const short data[3]) { - Gwn_PackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) }; + GPUPackedNormal n = { .x = convert_i16(data[0]), .y = convert_i16(data[1]), .z = convert_i16(data[2]) }; return n; } diff --git a/source/blender/gpu/intern/gpu_vertex_format_private.h b/source/blender/gpu/intern/gpu_vertex_format_private.h index 3cae9969fd8..4ce3ebba714 100644 --- a/source/blender/gpu/intern/gpu_vertex_format_private.h +++ b/source/blender/gpu/intern/gpu_vertex_format_private.h @@ -23,17 +23,17 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/gpu/gwn_vertex_format_private.h +/** \file blender/gpu/intern/gpu_vertex_format_private.h * \ingroup gpu * - * Gawain vertex format + * GPU vertex format */ -#ifndef __GWN_VERTEX_FORMAT_PRIVATE_H__ -#define __GWN_VERTEX_FORMAT_PRIVATE_H__ +#ifndef __GPU_VERTEX_FORMAT_PRIVATE_H__ +#define __GPU_VERTEX_FORMAT_PRIVATE_H__ -void VertexFormat_pack(Gwn_VertFormat*); +void VertexFormat_pack(GPUVertFormat*); uint padding(uint offset, uint alignment); -uint vertex_buffer_size(const Gwn_VertFormat*, uint vertex_len); +uint vertex_buffer_size(const GPUVertFormat*, uint vertex_len); -#endif /* __GWN_VERTEX_FORMAT_PRIVATE_H__ */ +#endif /* __GPU_VERTEX_FORMAT_PRIVATE_H__ */ diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index 0bf215f31a8..5d495779ba1 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -539,9 +539,9 @@ void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect) glUniform1i(GPU_shader_get_uniform(shader, "image"), 0); glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), halfx, halfy, 1.0f + halfx, 1.0f + halfy); glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x1, y1, x2, y2); - glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), 1.0f, 1.0f, 1.0f, 1.0f); + glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), 1.0f, 1.0f, 1.0f, 1.0f); - GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4); + GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); GPU_texture_unbind(color); } diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 0546dcb1a6c..55e1a43925d 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -82,9 +82,9 @@ typedef struct bMotionPath { int flag; /* baking settings - eMotionPath_Flag */ /* Used for drawing. */ - struct Gwn_VertBuf *points_vbo; - struct Gwn_Batch *batch_line; - struct Gwn_Batch *batch_points; + struct GPUVertBuf *points_vbo; + struct GPUBatch *batch_line; + struct GPUBatch *batch_points; void *pad; } bMotionPath; diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 80ad3840a8f..25d9e50ff7a 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -184,7 +184,7 @@ typedef struct wmWindow { struct wmWindow *next, *prev; void *ghostwin; /* don't want to include ghost.h stuff */ - void *gwnctx; /* don't want to include gawin stuff */ + void *gpuctx; /* don't want to include gpu stuff */ struct wmWindow *parent; /* Parent window */ diff --git a/source/blender/python/CMakeLists.txt b/source/blender/python/CMakeLists.txt index 8d26fee0abd..030576fefd1 100644 --- a/source/blender/python/CMakeLists.txt +++ b/source/blender/python/CMakeLists.txt @@ -17,7 +17,7 @@ # ***** END GPL LICENSE BLOCK ***** add_subdirectory(intern) -add_subdirectory(gawain) add_subdirectory(generic) +add_subdirectory(gpu) add_subdirectory(mathutils) add_subdirectory(bmesh) diff --git a/source/blender/python/gawain/CMakeLists.txt b/source/blender/python/gawain/CMakeLists.txt deleted file mode 100644 index 9eab323a0fe..00000000000 --- a/source/blender/python/gawain/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Contributor(s): Campbell Barton -# -# ***** END GPL LICENSE BLOCK ***** - -set(INC - . - ../../blenkernel - ../../blenlib - ../../gpu - ../../makesdna - ../../../../intern/gawain - ../../../../intern/guardedalloc - ../../../../intern/glew-mx -) - -set(INC_SYS - ${GLEW_INCLUDE_PATH} - ${PYTHON_INCLUDE_DIRS} -) - -set(SRC - gwn_py_api.c - gwn_py_types.c - - gwn_py_api.h - gwn_py_types.h -) - -add_definitions(${GL_DEFINITIONS}) - -blender_add_lib(bf_python_gawain "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/python/gawain/gwn_py_api.c b/source/blender/python/gawain/gwn_py_api.c deleted file mode 100644 index 1f7a1297448..00000000000 --- a/source/blender/python/gawain/gwn_py_api.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/gawain/gwn_py_api.c - * \ingroup pygawain - * - * Experimental Python API, not considered public yet (called '_gawain'), - * we may re-expose as public later. - */ - -#include - -#include "GPU_batch.h" -#include "GPU_vertex_format.h" - -#include "gwn_py_api.h" -#include "gwn_py_types.h" - -#include "BLI_utildefines.h" - -#include "../generic/python_utildefines.h" - -PyDoc_STRVAR(GWN_doc, -"This module provides access to gawain drawing functions." -); -static struct PyModuleDef GWN_module_def = { - PyModuleDef_HEAD_INIT, - .m_name = "_gawain", /* m_name */ - .m_doc = GWN_doc, /* m_doc */ -}; - -PyObject *BPyInit_gawain(void) -{ - PyObject *sys_modules = PyThreadState_GET()->interp->modules; - PyObject *submodule; - PyObject *mod; - - mod = PyModule_Create(&GWN_module_def); - - /* _gawain.types */ - PyModule_AddObject(mod, "types", (submodule = BPyInit_gawain_types())); - PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); - Py_INCREF(submodule); - - return mod; -} diff --git a/source/blender/python/gawain/gwn_py_api.h b/source/blender/python/gawain/gwn_py_api.h deleted file mode 100644 index 3ef85e8ae0f..00000000000 --- a/source/blender/python/gawain/gwn_py_api.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __GWN_PY_API_H__ -#define __GWN_PY_API_H__ - -/** \file blender/python/gawain/gwn_py_api.h - * \ingroup pygawain - */ - -PyObject *BPyInit_gawain(void); - -#endif /* __GWN_PY_API_H__ */ diff --git a/source/blender/python/gawain/gwn_py_types.c b/source/blender/python/gawain/gwn_py_types.c deleted file mode 100644 index 04c50ac0784..00000000000 --- a/source/blender/python/gawain/gwn_py_types.c +++ /dev/null @@ -1,847 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/gawain/gwn_py_types.c - * \ingroup pygawain - * - * - Use ``bpygwn_`` for local API. - * - Use ``BPyGwn_`` for public API. - */ - -#include - -#include "GPU_batch.h" -#include "GPU_vertex_format.h" - -#include "BLI_math.h" - -#include "GPU_batch.h" - -#include "MEM_guardedalloc.h" - -#include "../generic/py_capi_utils.h" -#include "../generic/python_utildefines.h" - -#include "gwn_py_types.h" /* own include */ - -#ifdef __BIG_ENDIAN__ - /* big endian */ -# define MAKE_ID2(c, d) ((c) << 8 | (d)) -# define MAKE_ID3(a, b, c) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 ) -# define MAKE_ID4(a, b, c, d) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d) ) -#else - /* little endian */ -# define MAKE_ID2(c, d) ((d) << 8 | (c)) -# define MAKE_ID3(a, b, c) ( (int)(c) << 16 | (b) << 8 | (a) ) -# define MAKE_ID4(a, b, c, d) ( (int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a) ) -#endif - -/* -------------------------------------------------------------------- */ - -/** \name Enum Conversion - * - * Use with PyArg_ParseTuple's "O&" formatting. - * \{ */ - -static int bpygwn_ParseVertCompType(PyObject *o, void *p) -{ - Py_ssize_t comp_type_id_len; - const char *comp_type_id = _PyUnicode_AsStringAndSize(o, &comp_type_id_len); - if (comp_type_id == NULL) { - PyErr_Format(PyExc_ValueError, - "expected a string, got %s", - Py_TYPE(o)->tp_name); - return 0; - } - - Gwn_VertCompType comp_type; - if (comp_type_id_len == 2) { - switch (*((ushort *)comp_type_id)) { - case MAKE_ID2('I', '8'): { comp_type = GWN_COMP_I8; goto success; } - case MAKE_ID2('U', '8'): { comp_type = GWN_COMP_U8; goto success; } - } - } - else if (comp_type_id_len == 3) { - switch (*((uint *)comp_type_id)) { - case MAKE_ID3('I', '1', '6'): { comp_type = GWN_COMP_I16; goto success; } - case MAKE_ID3('U', '1', '6'): { comp_type = GWN_COMP_U16; goto success; } - case MAKE_ID3('I', '3', '2'): { comp_type = GWN_COMP_I32; goto success; } - case MAKE_ID3('U', '3', '2'): { comp_type = GWN_COMP_U32; goto success; } - case MAKE_ID3('F', '3', '2'): { comp_type = GWN_COMP_F32; goto success; } - case MAKE_ID3('I', '1', '0'): { comp_type = GWN_COMP_I10; goto success; } - } - } - - PyErr_Format(PyExc_ValueError, - "unknown type literal: '%s'", - comp_type_id); - return 0; - -success: - *((Gwn_VertCompType *)p) = comp_type; - return 1; -} - -static int bpygwn_ParseVertFetchMode(PyObject *o, void *p) -{ - Py_ssize_t mode_id_len; - const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len); - if (mode_id == NULL) { - PyErr_Format(PyExc_ValueError, - "expected a string, got %s", - Py_TYPE(o)->tp_name); - return 0; - } -#define MATCH_ID(id) \ - if (mode_id_len == strlen(STRINGIFY(id))) { \ - if (STREQ(mode_id, STRINGIFY(id))) { \ - mode = GWN_FETCH_##id; \ - goto success; \ - } \ - } ((void)0) - - Gwn_VertFetchMode mode; - MATCH_ID(FLOAT); - MATCH_ID(INT); - MATCH_ID(INT_TO_FLOAT_UNIT); - MATCH_ID(INT_TO_FLOAT); -#undef MATCH_ID - PyErr_Format(PyExc_ValueError, - "unknown type literal: '%s'", - mode_id); - return 0; - -success: - (*(Gwn_VertFetchMode *)p) = mode; - return 1; -} - -static int bpygwn_ParsePrimType(PyObject *o, void *p) -{ - Py_ssize_t mode_id_len; - const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len); - if (mode_id == NULL) { - PyErr_Format(PyExc_ValueError, - "expected a string, got %s", - Py_TYPE(o)->tp_name); - return 0; - } -#define MATCH_ID(id) \ - if (mode_id_len == strlen(STRINGIFY(id))) { \ - if (STREQ(mode_id, STRINGIFY(id))) { \ - mode = GWN_PRIM_##id; \ - goto success; \ - } \ - } ((void)0) - - Gwn_PrimType mode; - MATCH_ID(POINTS); - MATCH_ID(LINES); - MATCH_ID(TRIS); - MATCH_ID(LINE_STRIP); - MATCH_ID(LINE_LOOP); - MATCH_ID(TRI_STRIP); - MATCH_ID(TRI_FAN); - MATCH_ID(LINE_STRIP_ADJ); - -#undef MATCH_ID - PyErr_Format(PyExc_ValueError, - "unknown type literal: '%s'", - mode_id); - return 0; - -success: - (*(Gwn_PrimType *)p) = mode; - return 1; -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name Utility Functions - * \{ */ - -#define PY_AS_NATIVE_SWITCH(attr) \ - switch (attr->comp_type) { \ - case GWN_COMP_I8: { PY_AS_NATIVE(int8_t, PyC_Long_AsI8); break; } \ - case GWN_COMP_U8: { PY_AS_NATIVE(uint8_t, PyC_Long_AsU8); break; } \ - case GWN_COMP_I16: { PY_AS_NATIVE(int16_t, PyC_Long_AsI16); break; } \ - case GWN_COMP_U16: { PY_AS_NATIVE(uint16_t, PyC_Long_AsU16); break; } \ - case GWN_COMP_I32: { PY_AS_NATIVE(int32_t, PyC_Long_AsI32); break; } \ - case GWN_COMP_U32: { PY_AS_NATIVE(uint32_t, PyC_Long_AsU32); break; } \ - case GWN_COMP_F32: { PY_AS_NATIVE(float, PyFloat_AsDouble); break; } \ - default: \ - BLI_assert(0); \ - } ((void)0) - -/* No error checking, callers must run PyErr_Occurred */ -static void fill_format_elem(void *data_dst_void, PyObject *py_src, const Gwn_VertAttr *attr) -{ -#define PY_AS_NATIVE(ty_dst, py_as_native) \ -{ \ - ty_dst *data_dst = data_dst_void; \ - *data_dst = py_as_native(py_src); \ -} ((void)0) - - PY_AS_NATIVE_SWITCH(attr); - -#undef PY_AS_NATIVE -} - -/* No error checking, callers must run PyErr_Occurred */ -static void fill_format_tuple(void *data_dst_void, PyObject *py_src, const Gwn_VertAttr *attr) -{ - const uint len = attr->comp_len; - -/** - * Args are constants, so range checks will be optimized out if they're nop's. - */ -#define PY_AS_NATIVE(ty_dst, py_as_native) \ - ty_dst *data_dst = data_dst_void; \ - for (uint i = 0; i < len; i++) { \ - data_dst[i] = py_as_native(PyTuple_GET_ITEM(py_src, i)); \ - } ((void)0) - - PY_AS_NATIVE_SWITCH(attr); - -#undef PY_AS_NATIVE -} - -#undef PY_AS_NATIVE_SWITCH -#undef WARN_TYPE_LIMIT_PUSH -#undef WARN_TYPE_LIMIT_POP - -static bool bpygwn_vertbuf_fill_impl( - Gwn_VertBuf *vbo, - uint data_id, PyObject *seq) -{ - bool ok = true; - const Gwn_VertAttr *attr = &vbo->format.attribs[data_id]; - - Gwn_VertBufRaw data_step; - GWN_vertbuf_attr_get_raw_data(vbo, data_id, &data_step); - - PyObject *seq_fast = PySequence_Fast(seq, "Vertex buffer fill"); - if (seq_fast == NULL) { - goto finally; - } - - const uint seq_len = PySequence_Fast_GET_SIZE(seq_fast); - - if (seq_len != vbo->vertex_len) { - PyErr_Format(PyExc_ValueError, - "Expected a sequence of size %d, got %d", - vbo->vertex_len, seq_len); - } - - PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast); - - if (attr->comp_len == 1) { - for (uint i = 0; i < seq_len; i++) { - uchar *data = (uchar *)GWN_vertbuf_raw_step(&data_step); - PyObject *item = seq_items[i]; - fill_format_elem(data, item, attr); - } - } - else { - for (uint i = 0; i < seq_len; i++) { - uchar *data = (uchar *)GWN_vertbuf_raw_step(&data_step); - PyObject *item = seq_items[i]; - if (!PyTuple_CheckExact(item)) { - PyErr_Format(PyExc_ValueError, - "expected a tuple, got %s", - Py_TYPE(item)->tp_name); - ok = false; - goto finally; - } - if (PyTuple_GET_SIZE(item) != attr->comp_len) { - PyErr_Format(PyExc_ValueError, - "expected a tuple of size %d, got %d", - attr->comp_len, PyTuple_GET_SIZE(item)); - ok = false; - goto finally; - } - - /* May trigger error, check below */ - fill_format_tuple(data, item, attr); - } - } - - if (PyErr_Occurred()) { - ok = false; - } - -finally: - - Py_DECREF(seq_fast); - return ok; -} - -/* handy, but not used just now */ -#if 0 -static int bpygwn_find_id(const Gwn_VertFormat *fmt, const char *id) -{ - for (int i = 0; i < fmt->attr_len; i++) { - for (uint j = 0; j < fmt->name_len; j++) { - if (STREQ(fmt->attribs[i].name[j], id)) { - return i; - } - } - } - return -1; -} -#endif - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name VertFormat Type - * \{ */ - -static PyObject *bpygwn_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) -{ - if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) { - PyErr_SetString(PyExc_TypeError, - "VertFormat(): takes no arguments"); - return NULL; - } - - BPyGwn_VertFormat *ret = (BPyGwn_VertFormat *)BPyGwn_VertFormat_CreatePyObject(NULL); - - return (PyObject *)ret; -} - -PyDoc_STRVAR(bpygwn_VertFormat_attr_add_doc, -"TODO" -); -static PyObject *bpygwn_VertFormat_attr_add(BPyGwn_VertFormat *self, PyObject *args, PyObject *kwds) -{ - static const char *kwlist[] = {"id", "comp_type", "len", "fetch_mode", NULL}; - - struct { - const char *id; - Gwn_VertCompType comp_type; - uint len; - Gwn_VertFetchMode fetch_mode; - } params; - - if (self->fmt.attr_len == GWN_VERT_ATTR_MAX_LEN) { - PyErr_SetString(PyExc_ValueError, "Maxumum attr reached " STRINGIFY(GWN_VERT_ATTR_MAX_LEN)); - return NULL; - } - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "$sO&IO&:attr_add", (char **)kwlist, - ¶ms.id, - bpygwn_ParseVertCompType, ¶ms.comp_type, - ¶ms.len, - bpygwn_ParseVertFetchMode, ¶ms.fetch_mode)) - { - return NULL; - } - - uint attr_id = GWN_vertformat_attr_add(&self->fmt, params.id, params.comp_type, params.len, params.fetch_mode); - return PyLong_FromLong(attr_id); -} - -static struct PyMethodDef bpygwn_VertFormat_methods[] = { - {"attr_add", (PyCFunction)bpygwn_VertFormat_attr_add, - METH_VARARGS | METH_KEYWORDS, bpygwn_VertFormat_attr_add_doc}, - {NULL, NULL, 0, NULL} -}; - - -static void bpygwn_VertFormat_dealloc(BPyGwn_VertFormat *self) -{ - Py_TYPE(self)->tp_free(self); -} - -PyTypeObject BPyGwn_VertFormat_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "Gwn_VertFormat", - .tp_basicsize = sizeof(BPyGwn_VertFormat), - .tp_dealloc = (destructor)bpygwn_VertFormat_dealloc, - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_methods = bpygwn_VertFormat_methods, - .tp_new = bpygwn_VertFormat_new, -}; - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name VertBuf Type - * \{ */ - -static PyObject *bpygwn_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) -{ - const char * const keywords[] = {"len", "format", NULL}; - - struct { - BPyGwn_VertFormat *py_fmt; - uint len; - } params; - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, - "$IO!:Gwn_VertBuf.__new__", (char **)keywords, - ¶ms.len, - &BPyGwn_VertFormat_Type, ¶ms.py_fmt)) - { - return NULL; - } - - struct Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(¶ms.py_fmt->fmt); - - GWN_vertbuf_data_alloc(vbo, params.len); - - return BPyGwn_VertBuf_CreatePyObject(vbo); -} - -PyDoc_STRVAR(bpygwn_VertBuf_fill_doc, -"TODO" -); -static PyObject *bpygwn_VertBuf_fill(BPyGwn_VertBuf *self, PyObject *args, PyObject *kwds) -{ - static const char *kwlist[] = {"id", "data", NULL}; - - struct { - uint id; - PyObject *py_seq_data; - } params; - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "$IO:fill", (char **)kwlist, - ¶ms.id, - ¶ms.py_seq_data)) - { - return NULL; - } - - if (params.id >= self->buf->format.attr_len) { - PyErr_Format(PyExc_ValueError, - "Format id %d out of range", - params.id); - return NULL; - } - - if (self->buf->data == NULL) { - PyErr_SetString(PyExc_ValueError, - "Can't fill, static buffer already in use"); - return NULL; - } - - if (!bpygwn_vertbuf_fill_impl(self->buf, params.id, params.py_seq_data)) { - return NULL; - } - Py_RETURN_NONE; -} - -static struct PyMethodDef bpygwn_VertBuf_methods[] = { - {"fill", (PyCFunction) bpygwn_VertBuf_fill, - METH_VARARGS | METH_KEYWORDS, bpygwn_VertBuf_fill_doc}, - {NULL, NULL, 0, NULL} -}; - -static void bpygwn_VertBuf_dealloc(BPyGwn_VertBuf *self) -{ - GWN_vertbuf_discard(self->buf); - Py_TYPE(self)->tp_free(self); -} - -PyTypeObject BPyGwn_VertBuf_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "Gwn_VertBuf", - .tp_basicsize = sizeof(BPyGwn_VertBuf), - .tp_dealloc = (destructor)bpygwn_VertBuf_dealloc, - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_methods = bpygwn_VertBuf_methods, - .tp_new = bpygwn_VertBuf_new, -}; - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name VertBatch Type - * \{ */ - -static PyObject *bpygwn_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) -{ - const char * const keywords[] = {"type", "buf", NULL}; - - struct { - Gwn_PrimType type_id; - BPyGwn_VertBuf *py_buf; - } params; - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, - "$O&O!:Gwn_Batch.__new__", (char **)keywords, - bpygwn_ParsePrimType, ¶ms.type_id, - &BPyGwn_VertBuf_Type, ¶ms.py_buf)) - { - return NULL; - } - - Gwn_Batch *batch = GWN_batch_create(params.type_id, params.py_buf->buf, NULL); - BPyGwn_Batch *ret = (BPyGwn_Batch *)BPyGwn_Batch_CreatePyObject(batch); - -#ifdef USE_GWN_PY_REFERENCES - ret->references = PyList_New(1); - PyList_SET_ITEM(ret->references, 0, (PyObject *)params.py_buf); - Py_INCREF(params.py_buf); - PyObject_GC_Track(ret); -#endif - - return (PyObject *)ret; -} - -PyDoc_STRVAR(bpygwn_VertBatch_vertbuf_add_doc, -"TODO" -); -static PyObject *bpygwn_VertBatch_vertbuf_add(BPyGwn_Batch *self, BPyGwn_VertBuf *py_buf) -{ - if (!BPyGwn_VertBuf_Check(py_buf)) { - PyErr_Format(PyExc_TypeError, - "Expected a Gwn_VertBuf, got %s", - Py_TYPE(py_buf)->tp_name); - return NULL; - } - - if (self->batch->verts[0]->vertex_len != py_buf->buf->vertex_len) { - PyErr_Format(PyExc_TypeError, - "Expected %d length, got %d", - self->batch->verts[0]->vertex_len, py_buf->buf->vertex_len); - return NULL; - } - -#ifdef USE_GWN_PY_REFERENCES - /* Hold user */ - PyList_Append(self->references, (PyObject *)py_buf); -#endif - - GWN_batch_vertbuf_add(self->batch, py_buf->buf); - Py_RETURN_NONE; -} - -/* Currently magic number from Py perspective. */ -PyDoc_STRVAR(bpygwn_VertBatch_program_set_builtin_doc, -"TODO" -); -static PyObject *bpygwn_VertBatch_program_set_builtin(BPyGwn_Batch *self, PyObject *args, PyObject *kwds) -{ - static const char *kwlist[] = {"id", NULL}; - - struct { - const char *shader; - } params; - - if (!PyArg_ParseTupleAndKeywords( - args, kwds, "s:program_set_builtin", (char **)kwlist, - ¶ms.shader)) - { - return NULL; - } - - GPUBuiltinShader shader; - -#define MATCH_ID(id) \ - if (STREQ(params.shader, STRINGIFY(id))) { \ - shader = GPU_SHADER_##id; \ - goto success; \ - } ((void)0) - - MATCH_ID(2D_FLAT_COLOR); - MATCH_ID(2D_SMOOTH_COLOR); - MATCH_ID(2D_UNIFORM_COLOR); - - MATCH_ID(3D_FLAT_COLOR); - MATCH_ID(3D_SMOOTH_COLOR); - MATCH_ID(3D_UNIFORM_COLOR); - -#undef MATCH_ID - - PyErr_SetString(PyExc_ValueError, - "shader name not known"); - return NULL; - -success: - GWN_batch_program_set_builtin(self->batch, shader); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_uniform_bool(BPyGwn_Batch *self, PyObject *args) -{ - struct { - const char *id; - bool values[1]; - } params; - - if (!PyArg_ParseTuple( - args, "sO&:uniform_bool", - ¶ms.id, - PyC_ParseBool, ¶ms.values[0])) - { - return NULL; - } - - GWN_batch_uniform_1b(self->batch, params.id, params.values[0]); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_uniform_i32(BPyGwn_Batch *self, PyObject *args) -{ - struct { - const char *id; - int values[1]; - } params; - - if (!PyArg_ParseTuple( - args, "si:uniform_i32", - ¶ms.id, - ¶ms.values[0])) - { - return NULL; - } - - GWN_batch_uniform_1i(self->batch, params.id, params.values[0]); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_uniform_f32(BPyGwn_Batch *self, PyObject *args) -{ - struct { - const char *id; - float values[4]; - } params; - - if (!PyArg_ParseTuple( - args, "sf|fff:uniform_f32", - ¶ms.id, - ¶ms.values[0], ¶ms.values[1], ¶ms.values[2], ¶ms.values[3])) - { - return NULL; - } - - switch (PyTuple_GET_SIZE(args)) { - case 2: GWN_batch_uniform_1f(self->batch, params.id, params.values[0]); break; - case 3: GWN_batch_uniform_2f(self->batch, params.id, UNPACK2(params.values)); break; - case 4: GWN_batch_uniform_3f(self->batch, params.id, UNPACK3(params.values)); break; - case 5: GWN_batch_uniform_4f(self->batch, params.id, UNPACK4(params.values)); break; - default: - BLI_assert(0); - } - Py_RETURN_NONE; -} - -PyDoc_STRVAR(bpygwn_VertBatch_draw_doc, -"TODO" -); -static PyObject *bpygwn_VertBatch_draw(BPyGwn_Batch *self) -{ - if (!glIsProgram(self->batch->program)) { - PyErr_SetString(PyExc_ValueError, - "batch program has not not set"); - } - GWN_batch_draw(self->batch); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_program_use_begin(BPyGwn_Batch *self) -{ - if (!glIsProgram(self->batch->program)) { - PyErr_SetString(PyExc_ValueError, - "batch program has not not set"); - } - GWN_batch_program_use_begin(self->batch); - Py_RETURN_NONE; -} - -static PyObject *bpygwn_VertBatch_program_use_end(BPyGwn_Batch *self) -{ - if (!glIsProgram(self->batch->program)) { - PyErr_SetString(PyExc_ValueError, - "batch program has not not set"); - } - GWN_batch_program_use_end(self->batch); - Py_RETURN_NONE; -} - -static struct PyMethodDef bpygwn_VertBatch_methods[] = { - {"vertbuf_add", (PyCFunction)bpygwn_VertBatch_vertbuf_add, - METH_O, bpygwn_VertBatch_vertbuf_add_doc}, - {"program_set_builtin", (PyCFunction)bpygwn_VertBatch_program_set_builtin, - METH_VARARGS | METH_KEYWORDS, bpygwn_VertBatch_program_set_builtin_doc}, - {"uniform_bool", (PyCFunction)bpygwn_VertBatch_uniform_bool, - METH_VARARGS, NULL}, - {"uniform_i32", (PyCFunction)bpygwn_VertBatch_uniform_i32, - METH_VARARGS, NULL}, - {"uniform_f32", (PyCFunction)bpygwn_VertBatch_uniform_f32, - METH_VARARGS, NULL}, - {"draw", (PyCFunction) bpygwn_VertBatch_draw, - METH_NOARGS, bpygwn_VertBatch_draw_doc}, - {"program_use_begin", (PyCFunction)bpygwn_VertBatch_program_use_begin, - METH_NOARGS, ""}, - {"program_use_end", (PyCFunction)bpygwn_VertBatch_program_use_end, - METH_NOARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -#ifdef USE_GWN_PY_REFERENCES - -static int bpygwn_Batch_traverse(BPyGwn_Batch *self, visitproc visit, void *arg) -{ - Py_VISIT(self->references); - return 0; -} - -static int bpygwn_Batch_clear(BPyGwn_Batch *self) -{ - Py_CLEAR(self->references); - return 0; -} - -#endif - -static void bpygwn_Batch_dealloc(BPyGwn_Batch *self) -{ - GWN_batch_discard(self->batch); - -#ifdef USE_GWN_PY_REFERENCES - if (self->references) { - PyObject_GC_UnTrack(self); - bpygwn_Batch_clear(self); - Py_XDECREF(self->references); - } -#endif - - Py_TYPE(self)->tp_free(self); -} - -PyTypeObject BPyGwn_Batch_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "Gwn_Batch", - .tp_basicsize = sizeof(BPyGwn_Batch), - .tp_dealloc = (destructor)bpygwn_Batch_dealloc, -#ifdef USE_GWN_PY_REFERENCES - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, - .tp_traverse = (traverseproc)bpygwn_Batch_traverse, - .tp_clear = (inquiry)bpygwn_Batch_clear, -#else - .tp_flags = Py_TPFLAGS_DEFAULT, -#endif - .tp_methods = bpygwn_VertBatch_methods, - .tp_new = bpygwn_Batch_new, -}; - -/* -------------------------------------------------------------------- */ - - -/** \name Gawain Types Module - * \{ */ - -static struct PyModuleDef BPy_BM_types_module_def = { - PyModuleDef_HEAD_INIT, - .m_name = "_gawain.types", -}; - -PyObject *BPyInit_gawain_types(void) -{ - PyObject *submodule; - - submodule = PyModule_Create(&BPy_BM_types_module_def); - - if (PyType_Ready(&BPyGwn_VertFormat_Type) < 0) - return NULL; - if (PyType_Ready(&BPyGwn_VertBuf_Type) < 0) - return NULL; - if (PyType_Ready(&BPyGwn_Batch_Type) < 0) - return NULL; - -#define MODULE_TYPE_ADD(s, t) \ - PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t) - - MODULE_TYPE_ADD(submodule, BPyGwn_VertFormat_Type); - MODULE_TYPE_ADD(submodule, BPyGwn_VertBuf_Type); - MODULE_TYPE_ADD(submodule, BPyGwn_Batch_Type); - -#undef MODULE_TYPE_ADD - - return submodule; -} - -/** \} */ - - -/* -------------------------------------------------------------------- */ - -/** \name Public API - * \{ */ - -PyObject *BPyGwn_VertFormat_CreatePyObject(Gwn_VertFormat *fmt) -{ - BPyGwn_VertFormat *self; - - self = PyObject_New(BPyGwn_VertFormat, &BPyGwn_VertFormat_Type); - if (fmt) { - self->fmt = *fmt; - } - else { - memset(&self->fmt, 0, sizeof(self->fmt)); - } - - return (PyObject *)self; -} - -PyObject *BPyGwn_VertBuf_CreatePyObject(Gwn_VertBuf *buf) -{ - BPyGwn_VertBuf *self; - - self = PyObject_New(BPyGwn_VertBuf, &BPyGwn_VertBuf_Type); - self->buf = buf; - - return (PyObject *)self; -} - - -PyObject *BPyGwn_Batch_CreatePyObject(Gwn_Batch *batch) -{ - BPyGwn_Batch *self; - -#ifdef USE_GWN_PY_REFERENCES - self = (BPyGwn_Batch *)_PyObject_GC_New(&BPyGwn_Batch_Type); - self->references = NULL; -#else - self = PyObject_New(BPyGwn_Batch, &BPyGwn_Batch_Type); -#endif - - self->batch = batch; - - return (PyObject *)self; -} - -/** \} */ diff --git a/source/blender/python/gawain/gwn_py_types.h b/source/blender/python/gawain/gwn_py_types.h deleted file mode 100644 index dde6cf98827..00000000000 --- a/source/blender/python/gawain/gwn_py_types.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/python/gawain/gwn_py_types.h - * \ingroup pygawain - */ - -#ifndef __GWN_PY_TYPES_H__ -#define __GWN_PY_TYPES_H__ - -#include "BLI_compiler_attrs.h" - -#define USE_GWN_PY_REFERENCES - -extern PyTypeObject BPyGwn_VertFormat_Type; -extern PyTypeObject BPyGwn_VertBuf_Type; -extern PyTypeObject BPyGwn_Batch_Type; - -#define BPyGwn_VertFormat_Check(v) (Py_TYPE(v) == &BPyGwn_VertFormat_Type) -#define BPyGwn_VertBuf_Check(v) (Py_TYPE(v) == &BPyGwn_VertBuf_Type) -#define BPyGwn_Batch_Check(v) (Py_TYPE(v) == &BPyGwn_Batch_Type) - -typedef struct BPyGwn_VertFormat { - PyObject_VAR_HEAD - struct Gwn_VertFormat fmt; -} BPyGwn_VertFormat; - -typedef struct BPyGwn_VertBuf { - PyObject_VAR_HEAD - /* The buf is owned, we may support thin wrapped batches later. */ - struct Gwn_VertBuf *buf; -} BPyGwn_VertBuf; - -typedef struct BPyGwn_Batch { - PyObject_VAR_HEAD - /* The batch is owned, we may support thin wrapped batches later. */ - struct Gwn_Batch *batch; -#ifdef USE_GWN_PY_REFERENCES - /* Just to keep a user to prevent freeing buf's we're using */ - PyObject *references; -#endif -} BPyGwn_Batch; - -PyObject *BPyInit_gawain_types(void); - -PyObject *BPyGwn_VertFormat_CreatePyObject(struct Gwn_VertFormat *fmt); -PyObject *BPyGwn_VertBuf_CreatePyObject(struct Gwn_VertBuf *vbo) ATTR_NONNULL(1); -PyObject *BPyGwn_Batch_CreatePyObject(struct Gwn_Batch *batch) ATTR_NONNULL(1); - -#endif /* __GWN_PY_TYPES_H__ */ diff --git a/source/blender/python/gpu/CMakeLists.txt b/source/blender/python/gpu/CMakeLists.txt new file mode 100644 index 00000000000..141a36bbcc2 --- /dev/null +++ b/source/blender/python/gpu/CMakeLists.txt @@ -0,0 +1,46 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Campbell Barton +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + . + ../../blenkernel + ../../blenlib + ../../gpu + ../../makesdna + ../../../../intern/guardedalloc + ../../../../intern/glew-mx +) + +set(INC_SYS + ${GLEW_INCLUDE_PATH} + ${PYTHON_INCLUDE_DIRS} +) + +set(SRC + gpu_py_api.c + gpu_py_types.c + + gpu_py_api.h + gpu_py_types.h +) + +add_definitions(${GL_DEFINITIONS}) + +blender_add_lib(bf_python_gpu "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/python/gpu/gpu_py_api.c b/source/blender/python/gpu/gpu_py_api.c new file mode 100644 index 00000000000..53285b372d8 --- /dev/null +++ b/source/blender/python/gpu/gpu_py_api.c @@ -0,0 +1,63 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/gpu/gpu_py_api.c + * \ingroup pygpu + * + * Experimental Python API, not considered public yet (called '_gpu'), + * we may re-expose as public later. + */ + +#include + +#include "GPU_batch.h" +#include "GPU_vertex_format.h" + +#include "gpu_py_api.h" +#include "gpu_py_types.h" + +#include "BLI_utildefines.h" + +#include "../generic/python_utildefines.h" + +PyDoc_STRVAR(GPU_doc, +"This module provides access to gpu drawing functions." +); +static struct PyModuleDef GPU_module_def = { + PyModuleDef_HEAD_INIT, + .m_name = "_gpu", /* m_name */ + .m_doc = GPU_doc, /* m_doc */ +}; + +PyObject *BPyInit_gpu(void) +{ + PyObject *sys_modules = PyThreadState_GET()->interp->modules; + PyObject *submodule; + PyObject *mod; + + mod = PyModule_Create(&GPU_module_def); + + /* _gpu.types */ + PyModule_AddObject(mod, "types", (submodule = BPyInit_gpu_types())); + PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule); + Py_INCREF(submodule); + + return mod; +} diff --git a/source/blender/python/gpu/gpu_py_api.h b/source/blender/python/gpu/gpu_py_api.h new file mode 100644 index 00000000000..387bfcab950 --- /dev/null +++ b/source/blender/python/gpu/gpu_py_api.h @@ -0,0 +1,30 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __GPU_PY_API_H__ +#define __GPU_PY_API_H__ + +/** \file blender/python/gpu/gpu_py_api.h + * \ingroup pygpu + */ + +PyObject *BPyInit_gpu(void); + +#endif /* __GPU_PY_API_H__ */ diff --git a/source/blender/python/gpu/gpu_py_types.c b/source/blender/python/gpu/gpu_py_types.c new file mode 100644 index 00000000000..0a21da5682b --- /dev/null +++ b/source/blender/python/gpu/gpu_py_types.c @@ -0,0 +1,847 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/gpu/gpu_py_types.c + * \ingroup pygpu + * + * - Use ``bpygpu_`` for local API. + * - Use ``BPyGPU`` for public API. + */ + +#include + +#include "GPU_batch.h" +#include "GPU_vertex_format.h" + +#include "BLI_math.h" + +#include "GPU_batch.h" + +#include "MEM_guardedalloc.h" + +#include "../generic/py_capi_utils.h" +#include "../generic/python_utildefines.h" + +#include "gpu_py_types.h" /* own include */ + +#ifdef __BIG_ENDIAN__ + /* big endian */ +# define MAKE_ID2(c, d) ((c) << 8 | (d)) +# define MAKE_ID3(a, b, c) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 ) +# define MAKE_ID4(a, b, c, d) ( (int)(a) << 24 | (int)(b) << 16 | (c) << 8 | (d) ) +#else + /* little endian */ +# define MAKE_ID2(c, d) ((d) << 8 | (c)) +# define MAKE_ID3(a, b, c) ( (int)(c) << 16 | (b) << 8 | (a) ) +# define MAKE_ID4(a, b, c, d) ( (int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a) ) +#endif + +/* -------------------------------------------------------------------- */ + +/** \name Enum Conversion + * + * Use with PyArg_ParseTuple's "O&" formatting. + * \{ */ + +static int bpygpu_ParseVertCompType(PyObject *o, void *p) +{ + Py_ssize_t comp_type_id_len; + const char *comp_type_id = _PyUnicode_AsStringAndSize(o, &comp_type_id_len); + if (comp_type_id == NULL) { + PyErr_Format(PyExc_ValueError, + "expected a string, got %s", + Py_TYPE(o)->tp_name); + return 0; + } + + GPUVertCompType comp_type; + if (comp_type_id_len == 2) { + switch (*((ushort *)comp_type_id)) { + case MAKE_ID2('I', '8'): { comp_type = GPU_COMP_I8; goto success; } + case MAKE_ID2('U', '8'): { comp_type = GPU_COMP_U8; goto success; } + } + } + else if (comp_type_id_len == 3) { + switch (*((uint *)comp_type_id)) { + case MAKE_ID3('I', '1', '6'): { comp_type = GPU_COMP_I16; goto success; } + case MAKE_ID3('U', '1', '6'): { comp_type = GPU_COMP_U16; goto success; } + case MAKE_ID3('I', '3', '2'): { comp_type = GPU_COMP_I32; goto success; } + case MAKE_ID3('U', '3', '2'): { comp_type = GPU_COMP_U32; goto success; } + case MAKE_ID3('F', '3', '2'): { comp_type = GPU_COMP_F32; goto success; } + case MAKE_ID3('I', '1', '0'): { comp_type = GPU_COMP_I10; goto success; } + } + } + + PyErr_Format(PyExc_ValueError, + "unknown type literal: '%s'", + comp_type_id); + return 0; + +success: + *((GPUVertCompType *)p) = comp_type; + return 1; +} + +static int bpygpu_ParseVertFetchMode(PyObject *o, void *p) +{ + Py_ssize_t mode_id_len; + const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len); + if (mode_id == NULL) { + PyErr_Format(PyExc_ValueError, + "expected a string, got %s", + Py_TYPE(o)->tp_name); + return 0; + } +#define MATCH_ID(id) \ + if (mode_id_len == strlen(STRINGIFY(id))) { \ + if (STREQ(mode_id, STRINGIFY(id))) { \ + mode = GPU_FETCH_##id; \ + goto success; \ + } \ + } ((void)0) + + GPUVertFetchMode mode; + MATCH_ID(FLOAT); + MATCH_ID(INT); + MATCH_ID(INT_TO_FLOAT_UNIT); + MATCH_ID(INT_TO_FLOAT); +#undef MATCH_ID + PyErr_Format(PyExc_ValueError, + "unknown type literal: '%s'", + mode_id); + return 0; + +success: + (*(GPUVertFetchMode *)p) = mode; + return 1; +} + +static int bpygpu_ParsePrimType(PyObject *o, void *p) +{ + Py_ssize_t mode_id_len; + const char *mode_id = _PyUnicode_AsStringAndSize(o, &mode_id_len); + if (mode_id == NULL) { + PyErr_Format(PyExc_ValueError, + "expected a string, got %s", + Py_TYPE(o)->tp_name); + return 0; + } +#define MATCH_ID(id) \ + if (mode_id_len == strlen(STRINGIFY(id))) { \ + if (STREQ(mode_id, STRINGIFY(id))) { \ + mode = GPU_PRIM_##id; \ + goto success; \ + } \ + } ((void)0) + + GPUPrimType mode; + MATCH_ID(POINTS); + MATCH_ID(LINES); + MATCH_ID(TRIS); + MATCH_ID(LINE_STRIP); + MATCH_ID(LINE_LOOP); + MATCH_ID(TRI_STRIP); + MATCH_ID(TRI_FAN); + MATCH_ID(LINE_STRIP_ADJ); + +#undef MATCH_ID + PyErr_Format(PyExc_ValueError, + "unknown type literal: '%s'", + mode_id); + return 0; + +success: + (*(GPUPrimType *)p) = mode; + return 1; +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Utility Functions + * \{ */ + +#define PY_AS_NATIVE_SWITCH(attr) \ + switch (attr->comp_type) { \ + case GPU_COMP_I8: { PY_AS_NATIVE(int8_t, PyC_Long_AsI8); break; } \ + case GPU_COMP_U8: { PY_AS_NATIVE(uint8_t, PyC_Long_AsU8); break; } \ + case GPU_COMP_I16: { PY_AS_NATIVE(int16_t, PyC_Long_AsI16); break; } \ + case GPU_COMP_U16: { PY_AS_NATIVE(uint16_t, PyC_Long_AsU16); break; } \ + case GPU_COMP_I32: { PY_AS_NATIVE(int32_t, PyC_Long_AsI32); break; } \ + case GPU_COMP_U32: { PY_AS_NATIVE(uint32_t, PyC_Long_AsU32); break; } \ + case GPU_COMP_F32: { PY_AS_NATIVE(float, PyFloat_AsDouble); break; } \ + default: \ + BLI_assert(0); \ + } ((void)0) + +/* No error checking, callers must run PyErr_Occurred */ +static void fill_format_elem(void *data_dst_void, PyObject *py_src, const GPUVertAttr *attr) +{ +#define PY_AS_NATIVE(ty_dst, py_as_native) \ +{ \ + ty_dst *data_dst = data_dst_void; \ + *data_dst = py_as_native(py_src); \ +} ((void)0) + + PY_AS_NATIVE_SWITCH(attr); + +#undef PY_AS_NATIVE +} + +/* No error checking, callers must run PyErr_Occurred */ +static void fill_format_tuple(void *data_dst_void, PyObject *py_src, const GPUVertAttr *attr) +{ + const uint len = attr->comp_len; + +/** + * Args are constants, so range checks will be optimized out if they're nop's. + */ +#define PY_AS_NATIVE(ty_dst, py_as_native) \ + ty_dst *data_dst = data_dst_void; \ + for (uint i = 0; i < len; i++) { \ + data_dst[i] = py_as_native(PyTuple_GET_ITEM(py_src, i)); \ + } ((void)0) + + PY_AS_NATIVE_SWITCH(attr); + +#undef PY_AS_NATIVE +} + +#undef PY_AS_NATIVE_SWITCH +#undef WARN_TYPE_LIMIT_PUSH +#undef WARN_TYPE_LIMIT_POP + +static bool bpygpu_vertbuf_fill_impl( + GPUVertBuf *vbo, + uint data_id, PyObject *seq) +{ + bool ok = true; + const GPUVertAttr *attr = &vbo->format.attribs[data_id]; + + GPUVertBufRaw data_step; + GPU_vertbuf_attr_get_raw_data(vbo, data_id, &data_step); + + PyObject *seq_fast = PySequence_Fast(seq, "Vertex buffer fill"); + if (seq_fast == NULL) { + goto finally; + } + + const uint seq_len = PySequence_Fast_GET_SIZE(seq_fast); + + if (seq_len != vbo->vertex_len) { + PyErr_Format(PyExc_ValueError, + "Expected a sequence of size %d, got %d", + vbo->vertex_len, seq_len); + } + + PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast); + + if (attr->comp_len == 1) { + for (uint i = 0; i < seq_len; i++) { + uchar *data = (uchar *)GPU_vertbuf_raw_step(&data_step); + PyObject *item = seq_items[i]; + fill_format_elem(data, item, attr); + } + } + else { + for (uint i = 0; i < seq_len; i++) { + uchar *data = (uchar *)GPU_vertbuf_raw_step(&data_step); + PyObject *item = seq_items[i]; + if (!PyTuple_CheckExact(item)) { + PyErr_Format(PyExc_ValueError, + "expected a tuple, got %s", + Py_TYPE(item)->tp_name); + ok = false; + goto finally; + } + if (PyTuple_GET_SIZE(item) != attr->comp_len) { + PyErr_Format(PyExc_ValueError, + "expected a tuple of size %d, got %d", + attr->comp_len, PyTuple_GET_SIZE(item)); + ok = false; + goto finally; + } + + /* May trigger error, check below */ + fill_format_tuple(data, item, attr); + } + } + + if (PyErr_Occurred()) { + ok = false; + } + +finally: + + Py_DECREF(seq_fast); + return ok; +} + +/* handy, but not used just now */ +#if 0 +static int bpygpu_find_id(const GPUVertFormat *fmt, const char *id) +{ + for (int i = 0; i < fmt->attr_len; i++) { + for (uint j = 0; j < fmt->name_len; j++) { + if (STREQ(fmt->attribs[i].name[j], id)) { + return i; + } + } + } + return -1; +} +#endif + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name VertFormat Type + * \{ */ + +static PyObject *bpygpu_VertFormat_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) +{ + if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) { + PyErr_SetString(PyExc_TypeError, + "VertFormat(): takes no arguments"); + return NULL; + } + + BPyGPUVertFormat *ret = (BPyGPUVertFormat *)BPyGPUVertFormat_CreatePyObject(NULL); + + return (PyObject *)ret; +} + +PyDoc_STRVAR(bpygpu_VertFormat_attr_add_doc, +"TODO" +); +static PyObject *bpygpu_VertFormat_attr_add(BPyGPUVertFormat *self, PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"id", "comp_type", "len", "fetch_mode", NULL}; + + struct { + const char *id; + GPUVertCompType comp_type; + uint len; + GPUVertFetchMode fetch_mode; + } params; + + if (self->fmt.attr_len == GPU_VERT_ATTR_MAX_LEN) { + PyErr_SetString(PyExc_ValueError, "Maxumum attr reached " STRINGIFY(GPU_VERT_ATTR_MAX_LEN)); + return NULL; + } + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "$sO&IO&:attr_add", (char **)kwlist, + ¶ms.id, + bpygpu_ParseVertCompType, ¶ms.comp_type, + ¶ms.len, + bpygpu_ParseVertFetchMode, ¶ms.fetch_mode)) + { + return NULL; + } + + uint attr_id = GPU_vertformat_attr_add(&self->fmt, params.id, params.comp_type, params.len, params.fetch_mode); + return PyLong_FromLong(attr_id); +} + +static struct PyMethodDef bpygpu_VertFormat_methods[] = { + {"attr_add", (PyCFunction)bpygpu_VertFormat_attr_add, + METH_VARARGS | METH_KEYWORDS, bpygpu_VertFormat_attr_add_doc}, + {NULL, NULL, 0, NULL} +}; + + +static void bpygpu_VertFormat_dealloc(BPyGPUVertFormat *self) +{ + Py_TYPE(self)->tp_free(self); +} + +PyTypeObject BPyGPUVertFormat_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "GPUVertFormat", + .tp_basicsize = sizeof(BPyGPUVertFormat), + .tp_dealloc = (destructor)bpygpu_VertFormat_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_methods = bpygpu_VertFormat_methods, + .tp_new = bpygpu_VertFormat_new, +}; + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name VertBuf Type + * \{ */ + +static PyObject *bpygpu_VertBuf_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) +{ + const char * const keywords[] = {"len", "format", NULL}; + + struct { + BPyGPUVertFormat *py_fmt; + uint len; + } params; + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, + "$IO!:GPUVertBuf.__new__", (char **)keywords, + ¶ms.len, + &BPyGPUVertFormat_Type, ¶ms.py_fmt)) + { + return NULL; + } + + struct GPUVertBuf *vbo = GPU_vertbuf_create_with_format(¶ms.py_fmt->fmt); + + GPU_vertbuf_data_alloc(vbo, params.len); + + return BPyGPUVertBuf_CreatePyObject(vbo); +} + +PyDoc_STRVAR(bpygpu_VertBuf_fill_doc, +"TODO" +); +static PyObject *bpygpu_VertBuf_fill(BPyGPUVertBuf *self, PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"id", "data", NULL}; + + struct { + uint id; + PyObject *py_seq_data; + } params; + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "$IO:fill", (char **)kwlist, + ¶ms.id, + ¶ms.py_seq_data)) + { + return NULL; + } + + if (params.id >= self->buf->format.attr_len) { + PyErr_Format(PyExc_ValueError, + "Format id %d out of range", + params.id); + return NULL; + } + + if (self->buf->data == NULL) { + PyErr_SetString(PyExc_ValueError, + "Can't fill, static buffer already in use"); + return NULL; + } + + if (!bpygpu_vertbuf_fill_impl(self->buf, params.id, params.py_seq_data)) { + return NULL; + } + Py_RETURN_NONE; +} + +static struct PyMethodDef bpygpu_VertBuf_methods[] = { + {"fill", (PyCFunction) bpygpu_VertBuf_fill, + METH_VARARGS | METH_KEYWORDS, bpygpu_VertBuf_fill_doc}, + {NULL, NULL, 0, NULL} +}; + +static void bpygpu_VertBuf_dealloc(BPyGPUVertBuf *self) +{ + GPU_vertbuf_discard(self->buf); + Py_TYPE(self)->tp_free(self); +} + +PyTypeObject BPyGPUVertBuf_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "GPUVertBuf", + .tp_basicsize = sizeof(BPyGPUVertBuf), + .tp_dealloc = (destructor)bpygpu_VertBuf_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_methods = bpygpu_VertBuf_methods, + .tp_new = bpygpu_VertBuf_new, +}; + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name VertBatch Type + * \{ */ + +static PyObject *bpygpu_Batch_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject *kwds) +{ + const char * const keywords[] = {"type", "buf", NULL}; + + struct { + GPUPrimType type_id; + BPyGPUVertBuf *py_buf; + } params; + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, + "$O&O!:GPUBatch.__new__", (char **)keywords, + bpygpu_ParsePrimType, ¶ms.type_id, + &BPyGPUVertBuf_Type, ¶ms.py_buf)) + { + return NULL; + } + + GPUBatch *batch = GPU_batch_create(params.type_id, params.py_buf->buf, NULL); + BPyGPUBatch *ret = (BPyGPUBatch *)BPyGPUBatch_CreatePyObject(batch); + +#ifdef USE_GPU_PY_REFERENCES + ret->references = PyList_New(1); + PyList_SET_ITEM(ret->references, 0, (PyObject *)params.py_buf); + Py_INCREF(params.py_buf); + PyObject_GC_Track(ret); +#endif + + return (PyObject *)ret; +} + +PyDoc_STRVAR(bpygpu_VertBatch_vertbuf_add_doc, +"TODO" +); +static PyObject *bpygpu_VertBatch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_buf) +{ + if (!BPyGPUVertBuf_Check(py_buf)) { + PyErr_Format(PyExc_TypeError, + "Expected a GPUVertBuf, got %s", + Py_TYPE(py_buf)->tp_name); + return NULL; + } + + if (self->batch->verts[0]->vertex_len != py_buf->buf->vertex_len) { + PyErr_Format(PyExc_TypeError, + "Expected %d length, got %d", + self->batch->verts[0]->vertex_len, py_buf->buf->vertex_len); + return NULL; + } + +#ifdef USE_GPU_PY_REFERENCES + /* Hold user */ + PyList_Append(self->references, (PyObject *)py_buf); +#endif + + GPU_batch_vertbuf_add(self->batch, py_buf->buf); + Py_RETURN_NONE; +} + +/* Currently magic number from Py perspective. */ +PyDoc_STRVAR(bpygpu_VertBatch_program_set_builtin_doc, +"TODO" +); +static PyObject *bpygpu_VertBatch_program_set_builtin(BPyGPUBatch *self, PyObject *args, PyObject *kwds) +{ + static const char *kwlist[] = {"id", NULL}; + + struct { + const char *shader; + } params; + + if (!PyArg_ParseTupleAndKeywords( + args, kwds, "s:program_set_builtin", (char **)kwlist, + ¶ms.shader)) + { + return NULL; + } + + GPUBuiltinShader shader; + +#define MATCH_ID(id) \ + if (STREQ(params.shader, STRINGIFY(id))) { \ + shader = GPU_SHADER_##id; \ + goto success; \ + } ((void)0) + + MATCH_ID(2D_FLAT_COLOR); + MATCH_ID(2D_SMOOTH_COLOR); + MATCH_ID(2D_UNIFORM_COLOR); + + MATCH_ID(3D_FLAT_COLOR); + MATCH_ID(3D_SMOOTH_COLOR); + MATCH_ID(3D_UNIFORM_COLOR); + +#undef MATCH_ID + + PyErr_SetString(PyExc_ValueError, + "shader name not known"); + return NULL; + +success: + GPU_batch_program_set_builtin(self->batch, shader); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_uniform_bool(BPyGPUBatch *self, PyObject *args) +{ + struct { + const char *id; + bool values[1]; + } params; + + if (!PyArg_ParseTuple( + args, "sO&:uniform_bool", + ¶ms.id, + PyC_ParseBool, ¶ms.values[0])) + { + return NULL; + } + + GPU_batch_uniform_1b(self->batch, params.id, params.values[0]); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_uniform_i32(BPyGPUBatch *self, PyObject *args) +{ + struct { + const char *id; + int values[1]; + } params; + + if (!PyArg_ParseTuple( + args, "si:uniform_i32", + ¶ms.id, + ¶ms.values[0])) + { + return NULL; + } + + GPU_batch_uniform_1i(self->batch, params.id, params.values[0]); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_uniform_f32(BPyGPUBatch *self, PyObject *args) +{ + struct { + const char *id; + float values[4]; + } params; + + if (!PyArg_ParseTuple( + args, "sf|fff:uniform_f32", + ¶ms.id, + ¶ms.values[0], ¶ms.values[1], ¶ms.values[2], ¶ms.values[3])) + { + return NULL; + } + + switch (PyTuple_GET_SIZE(args)) { + case 2: GPU_batch_uniform_1f(self->batch, params.id, params.values[0]); break; + case 3: GPU_batch_uniform_2f(self->batch, params.id, UNPACK2(params.values)); break; + case 4: GPU_batch_uniform_3f(self->batch, params.id, UNPACK3(params.values)); break; + case 5: GPU_batch_uniform_4f(self->batch, params.id, UNPACK4(params.values)); break; + default: + BLI_assert(0); + } + Py_RETURN_NONE; +} + +PyDoc_STRVAR(bpygpu_VertBatch_draw_doc, +"TODO" +); +static PyObject *bpygpu_VertBatch_draw(BPyGPUBatch *self) +{ + if (!glIsProgram(self->batch->program)) { + PyErr_SetString(PyExc_ValueError, + "batch program has not not set"); + } + GPU_batch_draw(self->batch); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_program_use_begin(BPyGPUBatch *self) +{ + if (!glIsProgram(self->batch->program)) { + PyErr_SetString(PyExc_ValueError, + "batch program has not not set"); + } + GPU_batch_program_use_begin(self->batch); + Py_RETURN_NONE; +} + +static PyObject *bpygpu_VertBatch_program_use_end(BPyGPUBatch *self) +{ + if (!glIsProgram(self->batch->program)) { + PyErr_SetString(PyExc_ValueError, + "batch program has not not set"); + } + GPU_batch_program_use_end(self->batch); + Py_RETURN_NONE; +} + +static struct PyMethodDef bpygpu_VertBatch_methods[] = { + {"vertbuf_add", (PyCFunction)bpygpu_VertBatch_vertbuf_add, + METH_O, bpygpu_VertBatch_vertbuf_add_doc}, + {"program_set_builtin", (PyCFunction)bpygpu_VertBatch_program_set_builtin, + METH_VARARGS | METH_KEYWORDS, bpygpu_VertBatch_program_set_builtin_doc}, + {"uniform_bool", (PyCFunction)bpygpu_VertBatch_uniform_bool, + METH_VARARGS, NULL}, + {"uniform_i32", (PyCFunction)bpygpu_VertBatch_uniform_i32, + METH_VARARGS, NULL}, + {"uniform_f32", (PyCFunction)bpygpu_VertBatch_uniform_f32, + METH_VARARGS, NULL}, + {"draw", (PyCFunction) bpygpu_VertBatch_draw, + METH_NOARGS, bpygpu_VertBatch_draw_doc}, + {"program_use_begin", (PyCFunction)bpygpu_VertBatch_program_use_begin, + METH_NOARGS, ""}, + {"program_use_end", (PyCFunction)bpygpu_VertBatch_program_use_end, + METH_NOARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +#ifdef USE_GPU_PY_REFERENCES + +static int bpygpu_Batch_traverse(BPyGPUBatch *self, visitproc visit, void *arg) +{ + Py_VISIT(self->references); + return 0; +} + +static int bpygpu_Batch_clear(BPyGPUBatch *self) +{ + Py_CLEAR(self->references); + return 0; +} + +#endif + +static void bpygpu_Batch_dealloc(BPyGPUBatch *self) +{ + GPU_batch_discard(self->batch); + +#ifdef USE_GPU_PY_REFERENCES + if (self->references) { + PyObject_GC_UnTrack(self); + bpygpu_Batch_clear(self); + Py_XDECREF(self->references); + } +#endif + + Py_TYPE(self)->tp_free(self); +} + +PyTypeObject BPyGPUBatch_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + .tp_name = "GPUBatch", + .tp_basicsize = sizeof(BPyGPUBatch), + .tp_dealloc = (destructor)bpygpu_Batch_dealloc, +#ifdef USE_GPU_PY_REFERENCES + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, + .tp_traverse = (traverseproc)bpygpu_Batch_traverse, + .tp_clear = (inquiry)bpygpu_Batch_clear, +#else + .tp_flags = Py_TPFLAGS_DEFAULT, +#endif + .tp_methods = bpygpu_VertBatch_methods, + .tp_new = bpygpu_Batch_new, +}; + +/* -------------------------------------------------------------------- */ + + +/** \name GPU Types Module + * \{ */ + +static struct PyModuleDef BPy_BM_types_module_def = { + PyModuleDef_HEAD_INIT, + .m_name = "_gpu.types", +}; + +PyObject *BPyInit_gpu_types(void) +{ + PyObject *submodule; + + submodule = PyModule_Create(&BPy_BM_types_module_def); + + if (PyType_Ready(&BPyGPUVertFormat_Type) < 0) + return NULL; + if (PyType_Ready(&BPyGPUVertBuf_Type) < 0) + return NULL; + if (PyType_Ready(&BPyGPUBatch_Type) < 0) + return NULL; + +#define MODULE_TYPE_ADD(s, t) \ + PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t) + + MODULE_TYPE_ADD(submodule, BPyGPUVertFormat_Type); + MODULE_TYPE_ADD(submodule, BPyGPUVertBuf_Type); + MODULE_TYPE_ADD(submodule, BPyGPUBatch_Type); + +#undef MODULE_TYPE_ADD + + return submodule; +} + +/** \} */ + + +/* -------------------------------------------------------------------- */ + +/** \name Public API + * \{ */ + +PyObject *BPyGPUVertFormat_CreatePyObject(GPUVertFormat *fmt) +{ + BPyGPUVertFormat *self; + + self = PyObject_New(BPyGPUVertFormat, &BPyGPUVertFormat_Type); + if (fmt) { + self->fmt = *fmt; + } + else { + memset(&self->fmt, 0, sizeof(self->fmt)); + } + + return (PyObject *)self; +} + +PyObject *BPyGPUVertBuf_CreatePyObject(GPUVertBuf *buf) +{ + BPyGPUVertBuf *self; + + self = PyObject_New(BPyGPUVertBuf, &BPyGPUVertBuf_Type); + self->buf = buf; + + return (PyObject *)self; +} + + +PyObject *BPyGPUBatch_CreatePyObject(GPUBatch *batch) +{ + BPyGPUBatch *self; + +#ifdef USE_GPU_PY_REFERENCES + self = (BPyGPUBatch *)_PyObject_GC_New(&BPyGPUBatch_Type); + self->references = NULL; +#else + self = PyObject_New(BPyGPUBatch, &BPyGPUBatch_Type); +#endif + + self->batch = batch; + + return (PyObject *)self; +} + +/** \} */ diff --git a/source/blender/python/gpu/gpu_py_types.h b/source/blender/python/gpu/gpu_py_types.h new file mode 100644 index 00000000000..f736a8f749a --- /dev/null +++ b/source/blender/python/gpu/gpu_py_types.h @@ -0,0 +1,67 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/gpu/gpu_py_types.h + * \ingroup pygpu + */ + +#ifndef __GPU_PY_TYPES_H__ +#define __GPU_PY_TYPES_H__ + +#include "BLI_compiler_attrs.h" + +#define USE_GPU_PY_REFERENCES + +extern PyTypeObject BPyGPUVertFormat_Type; +extern PyTypeObject BPyGPUVertBuf_Type; +extern PyTypeObject BPyGPUBatch_Type; + +#define BPyGPUVertFormat_Check(v) (Py_TYPE(v) == &BPyGPUVertFormat_Type) +#define BPyGPUVertBuf_Check(v) (Py_TYPE(v) == &BPyGPUVertBuf_Type) +#define BPyGPUBatch_Check(v) (Py_TYPE(v) == &BPyGPUBatch_Type) + +typedef struct BPyGPUVertFormat { + PyObject_VAR_HEAD + struct GPUVertFormat fmt; +} BPyGPUVertFormat; + +typedef struct BPyGPUVertBuf { + PyObject_VAR_HEAD + /* The buf is owned, we may support thin wrapped batches later. */ + struct GPUVertBuf *buf; +} BPyGPUVertBuf; + +typedef struct BPyGPUBatch { + PyObject_VAR_HEAD + /* The batch is owned, we may support thin wrapped batches later. */ + struct GPUBatch *batch; +#ifdef USE_GPU_PY_REFERENCES + /* Just to keep a user to prevent freeing buf's we're using */ + PyObject *references; +#endif +} BPyGPUBatch; + +PyObject *BPyInit_gpu_types(void); + +PyObject *BPyGPUVertFormat_CreatePyObject(struct GPUVertFormat *fmt); +PyObject *BPyGPUVertBuf_CreatePyObject(struct GPUVertBuf *vbo) ATTR_NONNULL(1); +PyObject *BPyGPUBatch_CreatePyObject(struct GPUBatch *batch) ATTR_NONNULL(1); + +#endif /* __GPU_PY_TYPES_H__ */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 0d7b0c92a90..64bc54c6221 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -75,7 +75,7 @@ #include "../generic/blf_py_api.h" #include "../generic/idprop_py_api.h" #include "../generic/imbuf_py_api.h" -#include "../gawain/gwn_py_api.h" +#include "../gpu/gpu_py_api.h" #include "../bmesh/bmesh_py_api.h" #include "../mathutils/mathutils.h" @@ -219,7 +219,7 @@ static struct _inittab bpy_internal_modules[] = { {"mathutils.kdtree", PyInit_mathutils_kdtree}, #endif {"_bpy_path", BPyInit__bpy_path}, - {"_gawain", BPyInit_gawain}, + {"_gpu", BPyInit_gpu}, {"bgl", BPyInit_bgl}, {"blf", BPyInit_blf}, {"imbuf", BPyInit_imbuf}, diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index cb32efb0b0f..df8953857ee 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -315,7 +315,7 @@ void RE_current_scene_update_cb(struct Render *re, void *handle, void (*f)(void void RE_gl_context_create(Render *re); void RE_gl_context_destroy(Render *re); void *RE_gl_context_get(Render *re); -void *RE_gwn_context_get(Render *re); +void *RE_gpu_context_get(Render *re); /* should move to kernel once... still unsure on how/where */ float RE_filter_value(int type, float x); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 117b82570e7..5d5d12f028a 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -160,7 +160,7 @@ struct Render { /* TODO replace by a whole draw manager. */ void *gl_context; - void *gwn_context; + void *gpu_context; }; /* **************** defines ********************* */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index af8746a4734..510a4aa4685 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1043,10 +1043,10 @@ void RE_gl_context_create(Render *re) void RE_gl_context_destroy(Render *re) { /* Needs to be called from the thread which used the ogl context for rendering. */ - if (re->gwn_context) { - GWN_context_active_set(re->gwn_context); - GWN_context_discard(re->gwn_context); - re->gwn_context = NULL; + if (re->gpu_context) { + GPU_context_active_set(re->gpu_context); + GPU_context_discard(re->gpu_context); + re->gpu_context = NULL; } if (re->gl_context) { WM_opengl_context_dispose(re->gl_context); @@ -1059,12 +1059,12 @@ void *RE_gl_context_get(Render *re) return re->gl_context; } -void *RE_gwn_context_get(Render *re) +void *RE_gpu_context_get(Render *re) { - if (re->gwn_context == NULL) { - re->gwn_context = GWN_context_create(); + if (re->gpu_context == NULL) { + re->gpu_context = GPU_context_create(); } - return re->gwn_context; + return re->gpu_context; } /* ********* add object data (later) ******** */ diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 5314c434c4c..160aeb6671b 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -456,9 +456,9 @@ void wm_draw_region_blend(ARegion *ar, int view, bool blend) glUniform1i(GPU_shader_get_uniform(shader, "image"), 0); glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), halfx, halfy, 1.0f + halfx, 1.0f + halfy); glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), ar->winrct.xmin, ar->winrct.ymin, ar->winrct.xmax + 1, ar->winrct.ymax + 1); - glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha); + glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha); - GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4); + GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); glBindTexture(GL_TEXTURE_2D, 0); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 84dcf30e63c..c191255cd21 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -188,7 +188,7 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) static void wm_window_substitute_old(wmWindowManager *oldwm, wmWindowManager *wm, wmWindow *oldwin, wmWindow *win) { win->ghostwin = oldwin->ghostwin; - win->gwnctx = oldwin->gwnctx; + win->gpuctx = oldwin->gpuctx; win->active = oldwin->active; if (win->active) { wm->winactive = win; @@ -202,7 +202,7 @@ static void wm_window_substitute_old(wmWindowManager *oldwm, wmWindowManager *wm GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ oldwin->ghostwin = NULL; - oldwin->gwnctx = NULL; + oldwin->gpuctx = NULL; win->eventstate = oldwin->eventstate; oldwin->eventstate = NULL; diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 4366013084c..06a7f3528c5 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -166,7 +166,7 @@ static void wm_gesture_draw_line(wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -181,7 +181,7 @@ static void wm_gesture_draw_line(wmGesture *gt) float xmin = (float)rect->xmin; float ymin = (float)rect->ymin; - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(shdr_pos, xmin, ymin); immVertex2f(shdr_pos, (float)rect->xmax, (float)rect->ymax); immEnd(); @@ -193,7 +193,7 @@ static void wm_gesture_draw_rect(wmGesture *gt) { rcti *rect = (rcti *)gt->customdata; - uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); glEnable(GL_BLEND); @@ -206,7 +206,7 @@ static void wm_gesture_draw_rect(wmGesture *gt) glDisable(GL_BLEND); - shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -231,7 +231,7 @@ static void wm_gesture_draw_circle(wmGesture *gt) glEnable(GL_BLEND); - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -346,7 +346,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt, bool filled) return; } - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -358,7 +358,7 @@ static void wm_gesture_draw_lasso(wmGesture *gt, bool filled) immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2); immUniform1f("dash_width", 2.0f); - immBegin((gt->type == WM_GESTURE_LASSO) ? GWN_PRIM_LINE_LOOP : GWN_PRIM_LINE_STRIP, numverts); + immBegin((gt->type == WM_GESTURE_LASSO) ? GPU_PRIM_LINE_LOOP : GPU_PRIM_LINE_STRIP, numverts); for (i = 0; i < gt->points; i++, lasso += 2) { immVertex2f(shdr_pos, (float)lasso[0], (float)lasso[1]); @@ -377,7 +377,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) float x1, x2, y1, y2; - const uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + const uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); @@ -389,7 +389,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt) immUniformArray4fv("colors", (float *)(float[][4]){{0.4f, 0.4f, 0.4f, 1.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, 2); immUniform1f("dash_width", 8.0f); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); x1 = (float)(rect->xmin - winsize_x); y1 = (float)rect->ymin; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 64aa64e1478..e757c7bee52 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2094,12 +2094,12 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph RNA_property_float_get_array(fill_ptr, fill_prop, col); } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (rc->gltex) { - uint texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, rc->gltex); @@ -2123,7 +2123,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph } /* draw textured quad */ - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texCoord, 0, 0); immVertex2f(pos, -radius, -radius); @@ -2226,8 +2226,8 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void if (rc->col_prop) RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fvAlpha(col, 0.5f); @@ -2237,14 +2237,14 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void /* draw original angle line */ GPU_matrix_rotate_2d(RAD2DEGF(rc->initial_value)); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); immEnd(); /* draw new angle line */ GPU_matrix_rotate_2d(RAD2DEGF(rc->current_value - rc->initial_value)); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); immEnd(); diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 00e7f77569b..6317cca8094 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -187,7 +187,7 @@ typedef enum eWS_Qual { static struct WindowStateGlobal { GHOST_SystemHandle ghost_system; void *ghost_window; - Gwn_Context *gwn_context; + GPUContext *gpu_context; /* events */ eWS_Qual qual; @@ -374,12 +374,12 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf GPU_matrix_push(); GPU_matrix_identity_set(); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ub(0, 255, 0); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, fac, -1.0f); immVertex2f(pos, fac, 1.0f); immEnd(); @@ -1284,7 +1284,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) //GHOST_ActivateWindowDrawingContext(g_WS.ghost_window); /* initialize OpenGL immediate mode */ - g_WS.gwn_context = GWN_context_create(); + g_WS.gpu_context = GPU_context_create(); GPU_init(); immActivate(); @@ -1555,10 +1555,10 @@ static char *wm_main_playanim_intern(int argc, const char **argv) GPU_shader_free_builtin_shaders(); - if (g_WS.gwn_context) { - GWN_context_active_set(g_WS.gwn_context); - GWN_context_discard(g_WS.gwn_context); - g_WS.gwn_context = NULL; + if (g_WS.gpu_context) { + GPU_context_active_set(g_WS.gpu_context); + GPU_context_discard(g_WS.gpu_context); + g_WS.gpu_context = NULL; } BLF_exit(); diff --git a/source/blender/windowmanager/intern/wm_stereo.c b/source/blender/windowmanager/intern/wm_stereo.c index 1e9f6d6231b..577145aff95 100644 --- a/source/blender/windowmanager/intern/wm_stereo.c +++ b/source/blender/windowmanager/intern/wm_stereo.c @@ -87,9 +87,9 @@ void wm_stereo3d_draw_interlace(wmWindow *win, ARegion *ar) float halfx = GLA_PIXEL_OFS / ar->winx; float halfy = GLA_PIXEL_OFS / ar->winy; - Gwn_VertFormat *format = immVertexFormat(); - uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* leave GL_TEXTURE0 as the latest active texture */ for (int view = 1; view >= 0; view--) { @@ -104,7 +104,7 @@ void wm_stereo3d_draw_interlace(wmWindow *win, ARegion *ar) immUniform1i("interlace_id", interlace_gpu_id_from_type(interlace_type)); - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texcoord, halfx, halfy); immVertex2f(pos, ar->winrct.xmin, ar->winrct.ymin); @@ -163,9 +163,9 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view) { bool cross_eyed = (win->stereo3d_format->flag & S3D_SIDEBYSIDE_CROSSEYED) != 0; - Gwn_VertFormat *format = immVertexFormat(); - uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE); @@ -188,7 +188,7 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view) immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */ - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texcoord, halfx, halfy); immVertex2f(pos, soffx, 0.0f); @@ -209,9 +209,9 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view) void wm_stereo3d_draw_topbottom(wmWindow *win, int view) { - Gwn_VertFormat *format = immVertexFormat(); - uint texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint texcoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_IMAGE); @@ -232,7 +232,7 @@ void wm_stereo3d_draw_topbottom(wmWindow *win, int view) immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */ - immBegin(GWN_PRIM_TRI_FAN, 4); + immBegin(GPU_PRIM_TRI_FAN, 4); immAttrib2f(texcoord, halfx, halfy); immVertex2f(pos, 0.0f, soffy); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 669480bf098..b87ae7e076c 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -194,14 +194,14 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win) /* We need this window's opengl context active to discard it. */ GHOST_ActivateWindowDrawingContext(win->ghostwin); - GWN_context_active_set(win->gwnctx); + GPU_context_active_set(win->gpuctx); - /* Delete local gawain objects. */ - GWN_context_discard(win->gwnctx); + /* Delete local gpu context. */ + GPU_context_discard(win->gpuctx); GHOST_DisposeWindow(g_system, win->ghostwin); win->ghostwin = NULL; - win->gwnctx = NULL; + win->gpuctx = NULL; } } @@ -645,7 +645,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm /* Clear drawable so we can set the new window. */ wm_window_clear_drawable(wm); - win->gwnctx = GWN_context_create(); + win->gpuctx = GPU_context_create(); /* needed so we can detect the graphics card below */ GPU_init(); @@ -1099,7 +1099,7 @@ static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool acti if (activate) { GHOST_ActivateWindowDrawingContext(win->ghostwin); } - GWN_context_active_set(win->gwnctx); + GPU_context_active_set(win->gpuctx); immActivate(); } -- cgit v1.2.3