diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-07-18 01:12:21 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-07-18 12:49:15 +0300 |
commit | 8cd7828792419fb4eac9a2a477968535b4c71535 (patch) | |
tree | 8fc733149fe07b7d9edd4b8b1e709519b4481887 /source/blender/draw/intern | |
parent | 247ad2034de2c33a6d9cb7d3b6f1ef7ffa5b859d (diff) |
GWN: Port to GPU module: Replace GWN prefix by GPU
Diffstat (limited to 'source/blender/draw/intern')
24 files changed, 2173 insertions, 2202 deletions
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); |