[Bf-blender-cvs] [b104057d00] blender2.8: OpenGL: enable program point size for keyframes
Commit: b104057d001d2472cc55c7fa51cff3275e331523 Author: Mike Erwin Date: Sun Feb 12 01:56:08 2017 -0500 Branches: blender2.8 https://developer.blender.org/rBb104057d001d2472cc55c7fa51cff3275e331523 OpenGL: enable program point size for keyframes Allows vertex shader to determine how large to rasterize each point sprite. Forgot to do this before. === M source/blender/editors/animation/keyframes_draw.c M source/blender/editors/interface/interface_icons.c M source/blender/editors/space_clip/clip_dopesheet_draw.c M source/blender/editors/space_nla/nla_draw.c === diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 3c5f626fac..c8d141eab0 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -52,6 +52,7 @@ #include "BKE_fcurve.h" +#include "GPU_draw.h" #include "GPU_immediate.h" #include "UI_resources.h" @@ -623,6 +624,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa unsigned int color_id = add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT); unsigned int outline_color_id = add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); + GPU_enable_program_point_size(); immBegin(PRIM_POINTS, key_ct); for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) { @@ -633,6 +635,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa } immEnd(); + GPU_disable_program_point_size(); immUnbindProgram(); } } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index b7eab9f2a5..a9cdb34f63 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -35,6 +35,7 @@ #include "GPU_extensions.h" #include "GPU_basic_shader.h" +#include "GPU_draw.h" #include "GPU_immediate.h" #include "BLI_blenlib.h" @@ -60,7 +61,6 @@ #include "IMB_imbuf_types.h" #include "IMB_thumbs.h" -#include "BIF_gl.h" #include "BIF_glutil.h" #include "ED_datafiles.h" @@ -262,6 +262,7 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, unsigned int outline_color_id = add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); + GPU_enable_program_point_size(); immBegin(PRIM_POINTS, 1); /* draw keyframe @@ -272,6 +273,7 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, pos_id, size_id, color_id, outline_color_id); immEnd(); + GPU_disable_program_point_size(); immUnbindProgram(); UI_Theme_Restore(_state); diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index c381a58ba1..872e62dbc9 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -42,8 +42,6 @@ #include "ED_screen.h" #include "ED_clip.h" -#include "BIF_gl.h" - #include "WM_types.h" #include "UI_interface.h" @@ -54,6 +52,7 @@ #include "RNA_access.h" +#include "GPU_draw.h" #include "GPU_immediate.h" #include "clip_intern.h" /* own include */ @@ -221,7 +220,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) unsigned int outline_color_id = add_attrib(format, "outlineColor", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); - + GPU_enable_program_point_size(); immBegin(PRIM_POINTS, keyframe_ct); /* all same size with black outline */ @@ -276,6 +275,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) } immEnd(); + GPU_disable_program_point_size(); immUnbindProgram(); } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 86eae70c0f..e744a39fde 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -146,6 +146,7 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa unsigned int
[Bf-blender-cvs] [09bfc37889] blender2.8: OpenGL: convert NLA editor to new imm mode
Commit: 09bfc378895f320bcc12ac5c77252f58780e73fc Author: Mike Erwin Date: Sun Feb 12 01:29:59 2017 -0500 Branches: blender2.8 https://developer.blender.org/rB09bfc378895f320bcc12ac5c77252f58780e73fc OpenGL: convert NLA editor to new imm mode Plus plenty of C99 cleanup. Part of T49043. Needs more testing, I don't really use the NLA editor. === M source/blender/editors/space_nla/nla_draw.c === diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 9d34b6c4e2..86eae70c0f 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -54,7 +54,6 @@ #include "ED_anim_api.h" #include "ED_keyframes_draw.h" -#include "BIF_gl.h" #include "BIF_glutil.h" #include "GPU_immediate.h" @@ -109,7 +108,7 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa action_to_keylist(adt, act, , NULL); BLI_dlrbTree_linkedlist_sync(); - if (ELEM(NULL, act, keys.first)) + if (!(act && keys.first)) return; /* draw a darkened region behind the strips @@ -168,57 +167,55 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, float y, floa /* Strip Markers */ /* Markers inside an action strip */ -static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymaxc) +static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymaxc, int shade, unsigned int pos) { - bAction *act = strip->act; - TimeMarker *marker; - - if (ELEM(NULL, strip->act, strip->act->markers.first)) + const bAction *act = strip->act; + + if (!(act && act->markers.first)) return; - - for (marker = act->markers.first; marker; marker = marker->next) { + + immUniformThemeColorShade(TH_STRIP_SELECT, shade); + + immBeginAtMost(PRIM_POINTS, BLI_listbase_count(>markers)); + for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) { float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP); - + /* just a simple line for now */ - // XXX: draw a triangle instead... - fdrawline(frame, yminc + 1, frame, ymaxc - 1); + /* XXX: draw a triangle instead... */ + immVertex2f(pos, frame, yminc + 1); + immVertex2f(pos, frame, ymaxc - 1); } } + immEnd(); } /* Markers inside a NLA-Strip */ -static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc) +static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc, unsigned int pos) { glLineWidth(2.0f); if (strip->type == NLASTRIP_TYPE_CLIP) { /* try not to be too conspicuous, while being visible enough when transforming */ - if (strip->flag & NLASTRIP_FLAG_SELECT) - UI_ThemeColorShade(TH_STRIP_SELECT, -60); - else - UI_ThemeColorShade(TH_STRIP_SELECT, -40); - + int shade = (strip->flag & NLASTRIP_FLAG_SELECT) ? -60 : -40; + setlinestyle(3); /* just draw the markers in this clip */ - nla_actionclip_draw_markers(strip, yminc, ymaxc); + nla_actionclip_draw_markers(strip, yminc, ymaxc, shade, pos); setlinestyle(0); } else if (strip->flag & NLASTRIP_FLAG_TEMP_META) { /* just a solid color, so that it is very easy to spot */ - UI_ThemeColorShade(TH_STRIP_SELECT, 20); - + int shade = 20; /* draw the markers in the first level of strips only (if they are actions) */ for (NlaStrip *nls = strip->strips.first; nls; nls = nls->next) { if (nls->type == NLASTRIP_TYPE_CLIP) { - nla_actionclip_draw_markers(nls, yminc, ymaxc); + nla_actionclip_draw_markers(nls, yminc, ymaxc, shade, pos); } } } - - glLineWidth(1.0); } /* Strips (Proper) -- */ @@ -286,12 +283,8 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col } /* helper call for drawing influence/time control curves for a given NLA-strip */ -static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) +static void nla_draw_strip_curves(NlaStrip *strip, float yminc,
[Bf-blender-cvs] [7b6d09e9bd] cloth-improvements: Fix stack overflow in spring angle calculation
Commit: 7b6d09e9bd94ca4e28441632733d4077a2f27b1c Author: Luca Rood Date: Sun Feb 12 01:48:10 2017 -0200 Branches: cloth-improvements https://developer.blender.org/rB7b6d09e9bd94ca4e28441632733d4077a2f27b1c Fix stack overflow in spring angle calculation === M source/blender/blenkernel/intern/cloth.c M source/blender/physics/intern/implicit_blender.c === diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index bcb979e656..23b9fb5dc2 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -960,24 +960,25 @@ BLI_INLINE float spring_angle(ClothVertex *verts, int i, int j, int *i_a, int *i float dir_a[3], dir_b[3]; float tmp1[3], tmp2[3], vec_e[3]; float sin, cos; - float (*array_a)[3] = BLI_array_alloca(array_a, len_a); - float (*array_b)[3] = BLI_array_alloca(array_b, len_b); + float fact_a = 1.0f / len_a; + float fact_b = 1.0f / len_b; int x; + zero_v3(co_a); + zero_v3(co_b); + /* assign poly vert coords to arrays */ for (x = 0; x < len_a; x++) { - copy_v3_v3(array_a[x], verts[i_a[x]].xrest); + madd_v3_v3fl(co_a, verts[i_a[x]].xrest, fact_a); } for (x = 0; x < len_b; x++) { - copy_v3_v3(array_b[x], verts[i_b[x]].xrest); + madd_v3_v3fl(co_b, verts[i_b[x]].xrest, fact_b); } /* get edge vert coords and poly centroid coords. */ copy_v3_v3(co_i, verts[i].xrest); copy_v3_v3(co_j, verts[j].xrest); - cent_poly_v3(co_a, array_a, len_a); - cent_poly_v3(co_b, array_b, len_b); /* find dir for poly a */ sub_v3_v3v3(tmp1, co_j, co_a); diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c index 2d14502d52..d38f173ced 100644 --- a/source/blender/physics/intern/implicit_blender.c +++ b/source/blender/physics/intern/implicit_blender.c @@ -1700,8 +1700,8 @@ BLI_INLINE bool spring_angle(Implicit_Data *data, int i, int j, int *i_a, int *i float co_i[3], co_j[3], co_a[3], co_b[3]; float tmp1[3], tmp2[3], vec_e[3]; float sin, cos; - float (*array_a)[3] = BLI_array_alloca(array_a, len_a); - float (*array_b)[3] = BLI_array_alloca(array_b, len_b); + float (*array_a)[3] = MEM_mallocN(sizeof(*array_a) * len_a, "spring angle poly a"); + float (*array_b)[3] = MEM_mallocN(sizeof(*array_b) * len_b, "spring angle poly b"); int x; /* assign poly vert coords to arrays */ @@ -1765,6 +1765,9 @@ BLI_INLINE bool spring_angle(Implicit_Data *data, int i, int j, int *i_a, int *i sub_v3_v3(r_vel_a, tmp1); sub_v3_v3(r_vel_b, tmp1); + MEM_freeN(array_a); + MEM_freeN(array_b); + return true; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5552e83b53] master: Cycles: Don't use built-in API for image sequences in preview mode
Commit: 5552e83b533814e7882c2236d83d77e0bc61d38a Author: Sergey Sharybin Date: Sat Feb 11 22:24:59 2017 +0100 Branches: master https://developer.blender.org/rB5552e83b533814e7882c2236d83d77e0bc61d38a Cycles: Don't use built-in API for image sequences in preview mode Our Python API is not ready for such things at all. Better be slower but more correct for until we improve our API. === M intern/cycles/blender/blender_shader.cpp === diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index f6ec015e1b..8baa53fc2e 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -609,7 +609,8 @@ static ShaderNode *add_node(Scene *scene, bool is_builtin = b_image.packed_file() || b_image.source() == BL::Image::source_GENERATED || b_image.source() == BL::Image::source_MOVIE || - b_engine.is_preview(); + (b_engine.is_preview() && + b_image.source() != BL::Image::source_SEQUENCE); if(is_builtin) { /* for builtin images we're using image datablock name to find an image to @@ -662,7 +663,8 @@ static ShaderNode *add_node(Scene *scene, bool is_builtin = b_image.packed_file() || b_image.source() == BL::Image::source_GENERATED || b_image.source() == BL::Image::source_MOVIE || - b_engine.is_preview(); + (b_engine.is_preview() && + b_image.source() != BL::Image::source_SEQUENCE); if(is_builtin) { int scene_frame = b_scene.frame_current(); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e76364adcd] master: Image: Fix non-deterministic behavior of image sequence loading
Commit: e76364adcd3810134f0b9a55fd7fa40de72a008b Author: Sergey Sharybin Date: Sat Feb 11 22:15:30 2017 +0100 Branches: master https://developer.blender.org/rBe76364adcd3810134f0b9a55fd7fa40de72a008b Image: Fix non-deterministic behavior of image sequence loading The issue was caused by usage of non-initialized image user, which could have different settings, causing some random image being loaded or not loaded at all. This caused non-deterministic behavior of Cycles image loading because it was querying image information from several places. This fixes crash reported in T50616, but it's not a complete fix because preview rendering in material is wrong (same wrong as in 2.78a release). === M source/blender/blenkernel/intern/image.c === diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a2d94ccc47..318f6480aa 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -3159,7 +3159,7 @@ static ImBuf *load_sequence_single(Image *ima, ImageUser *iuser, int frame, cons struct ImBuf *ibuf; char name[FILE_MAX]; int flag; - ImageUser iuser_t; + ImageUser iuser_t = {0}; /* XXX temp stuff? */ if (ima->lastframe != frame) @@ -3167,8 +3167,12 @@ static ImBuf *load_sequence_single(Image *ima, ImageUser *iuser, int frame, cons ima->lastframe = frame; - if (iuser) + if (iuser) { iuser_t = *iuser; + } + else { + /* TODO(sergey): Do we need to initialize something here? */ + } iuser_t.view = view_id; BKE_image_user_file_path(_t, ima, name); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [24703c97a1] blender2.8: GPU shaders / Clay engine : small renaming / cleanup
Commit: 24703c97a15dc5c071d768274d3ebdcd4b4a7324 Author: Clément Foucault Date: Sat Feb 11 21:15:46 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB24703c97a15dc5c071d768274d3ebdcd4b4a7324 GPU shaders / Clay engine : small renaming / cleanup === M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c M source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl R100source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl source/blender/gpu/shaders/gpu_shader_3D_passthrough_vert.glsl R066source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl source/blender/gpu/shaders/gpu_shader_instance_screenspace_variying_color_vert.glsl M source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl M source/blender/gpu/shaders/gpu_shader_instance_vert.glsl === diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index a5b2d0a09c..0298db1a5c 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -113,12 +113,13 @@ static DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float return grp; } -static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float *size) +static DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Batch *geom, float *size) { - GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_LAMP_COMMON); + GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR +); DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom); - DRW_shgroup_attrib_float(grp, "lamp_pos", 3); + DRW_shgroup_attrib_float(grp, "world_pos", 3); DRW_shgroup_attrib_float(grp, "color", 3); DRW_shgroup_uniform_float(grp, "size", size, 1); DRW_shgroup_uniform_float(grp, "pixel_size", DRW_viewport_pixelsize_get(), 1); @@ -128,7 +129,7 @@ static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float *s return grp; } -static DRWShadingGroup *shgroup_empty(DRWPass *pass, struct Batch *geom) +static DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Batch *geom) { GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); @@ -144,9 +145,6 @@ static DRWShadingGroup *shgroup_empty(DRWPass *pass, struct Batch *geom) * The passes are populated by the rendering engine using the DRW_shgroup_* functions. */ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPass **non_meshes, DRWPass **ob_center) { - /* Theses are defined for the whole application so make sure they rely on global settings */ - - UI_GetThemeColor4fv(TH_WIRE, colorWire); UI_GetThemeColor4fv(TH_WIRE_EDIT, colorWireEdit); UI_GetThemeColor4fv(TH_ACTIVE, colorActive); @@ -189,28 +187,28 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa /* Empties */ geom = DRW_cache_plain_axes_get(); - plain_axes = shgroup_empty(*non_meshes, geom); + plain_axes = shgroup_instance(*non_meshes, geom); geom = DRW_cache_cube_get(); - cube = shgroup_empty(*non_meshes, geom); + cube = shgroup_instance(*non_meshes, geom); geom = DRW_cache_circle_get(); - circle = shgroup_empty(*non_meshes, geom); + circle = shgroup_instance(*non_meshes, geom); geom = DRW_cache_empty_sphere_get(); - sphere = shgroup_empty(*non_meshes, geom); + sphere = shgroup_instance(*non_meshes, geom); geom = DRW_cache_empty_cone_get(); - cone = shgroup_empty(*non_meshes, geom); + cone = shgroup_instance(*non_meshes, geom); geom = DRW_cache_single_arrow_get(); - single_arrow = shgroup_empty(*non_meshes, geom); + single_arrow = shgroup_instance(*non_meshes, geom); geom = DRW_cache_single_line_get(); - single_arrow_line = shgroup_empty(*non_meshes, geom); + single_arrow_line = shgroup_instance(*non_meshes, geom); geom = DRW_cache_single_arrow_get(); - arrows = shgroup_empty(*non_meshes, geom); + arrows = shgroup_instance(*non_meshes, geom); /* Lamps */ lampCenterSize = (U.obcenter_dia + 1.5f) * U.pixelsize; @@ -223,11 +221,11 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa lamp_center_group =
[Bf-blender-cvs] [e05800d23b] blender2.8: Clay Engine: converted Empties to the new instancing method
Commit: e05800d23b40a6eda0b154de934f8f8c6e1b3438 Author: Clément Foucault Date: Thu Feb 9 20:55:31 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBe05800d23b40a6eda0b154de934f8f8c6e1b3438 Clay Engine: converted Empties to the new instancing method === M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_shader.c A source/blender/gpu/shaders/gpu_shader_instance_variying_size_variying_color_vert.glsl R100source/blender/gpu/shaders/gpu_shader_3D_instance_vert.glsl source/blender/gpu/shaders/gpu_shader_instance_vert.glsl === diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 53ee769c04..a5b2d0a09c 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -38,61 +38,14 @@ /* Store list of shading group for easy access*/ /* Empties */ -static DRWShadingGroup *plain_axes_wire; -static DRWShadingGroup *plain_axes_active; -static DRWShadingGroup *plain_axes_select; -static DRWShadingGroup *plain_axes_transform; -static DRWShadingGroup *plain_axes_group; -static DRWShadingGroup *plain_axes_group_active; - -static DRWShadingGroup *cube_wire; -static DRWShadingGroup *cube_active; -static DRWShadingGroup *cube_select; -static DRWShadingGroup *cube_transform; -static DRWShadingGroup *cube_group; -static DRWShadingGroup *cube_group_active; - -static DRWShadingGroup *circle_wire; -static DRWShadingGroup *circle_active; -static DRWShadingGroup *circle_select; -static DRWShadingGroup *circle_transform; -static DRWShadingGroup *circle_group; -static DRWShadingGroup *circle_group_active; - -static DRWShadingGroup *sphere_wire; -static DRWShadingGroup *sphere_active; -static DRWShadingGroup *sphere_select; -static DRWShadingGroup *sphere_transform; -static DRWShadingGroup *sphere_group; -static DRWShadingGroup *sphere_group_active; - -static DRWShadingGroup *cone_wire; -static DRWShadingGroup *cone_active; -static DRWShadingGroup *cone_select; -static DRWShadingGroup *cone_transform; -static DRWShadingGroup *cone_group; -static DRWShadingGroup *cone_group_active; - -static DRWShadingGroup *single_arrow_wire; -static DRWShadingGroup *single_arrow_active; -static DRWShadingGroup *single_arrow_select; -static DRWShadingGroup *single_arrow_transform; -static DRWShadingGroup *single_arrow_group; -static DRWShadingGroup *single_arrow_group_active; - -static DRWShadingGroup *single_arrow_line_wire; -static DRWShadingGroup *single_arrow_line_active; -static DRWShadingGroup *single_arrow_line_select; -static DRWShadingGroup *single_arrow_line_transform; -static DRWShadingGroup *single_arrow_line_group; -static DRWShadingGroup *single_arrow_line_group_active; - -static DRWShadingGroup *arrows_wire; -static DRWShadingGroup *arrows_active; -static DRWShadingGroup *arrows_select; -static DRWShadingGroup *arrows_transform; -static DRWShadingGroup *arrows_group; -static DRWShadingGroup *arrows_group_active; +static DRWShadingGroup *plain_axes; +static DRWShadingGroup *cube; +static DRWShadingGroup *circle; +static DRWShadingGroup *sphere; +static DRWShadingGroup *cone; +static DRWShadingGroup *single_arrow; +static DRWShadingGroup *single_arrow_line; +static DRWShadingGroup *arrows; /* Lamps */ static DRWShadingGroup *lamp_center; @@ -117,17 +70,6 @@ static float colorActive[4], colorSelect[4], colorTransform[4], colorGroup[4], c static float colorEmpty[4], colorLamp[4], colorCamera[4], colorSpeaker[4]; static float lampCenterSize, lampCircleRad, lampCircleShadowRad, colorLampNoAlpha[4]; -static DRWShadingGroup *shgroup_instance_uniform_color(DRWPass *pass, struct Batch *geom, float color[4]) -{ - GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR_INSTANCE); - - DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom); - DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16); - DRW_shgroup_uniform_vec4(grp, "color", color, 1); - - return grp; -} - static DRWShadingGroup *shgroup_dynlines_uniform_color(DRWPass *pass, float color[4]) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR); @@ -186,6 +128,18 @@ static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float *s return grp; } +static DRWShadingGroup *shgroup_empty(DRWPass *pass, struct Batch *geom) +{ + GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE); + + DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom); + DRW_shgroup_attrib_float(grp, "color", 3); + DRW_shgroup_attrib_float(grp, "size", 1); + DRW_shgroup_attrib_float(grp,
[Bf-blender-cvs] [fc0797142d] blender2.8: Clay Engine: Refactoring of the dynamic batches
Commit: fc0797142d0c94342832bbead9db40e3e6ca9186 Author: Clément Foucault Date: Thu Feb 9 17:26:13 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBfc0797142d0c94342832bbead9db40e3e6ca9186 Clay Engine: Refactoring of the dynamic batches Support more attribs for interesting instancing === M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager.c M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/gawain/batch.c M source/blender/gpu/gawain/batch.h === diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 2cd0634168..78edae803b 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -158,16 +158,17 @@ typedef enum { DRW_STATE_BLEND = (1 << 12), } DRWState; -/* Used by DRWShadingGroup.dyntype */ -#define DRW_DYN_POINTS 1 -#define DRW_DYN_LINES 2 -#define DRW_DYN_INSTANCE 3 - DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass); +DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, struct Batch *geom); +DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass); +DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass); + void DRW_shgroup_free(struct DRWShadingGroup *shgroup); void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Batch *geom, float (*obmat)[4]); +void DRW_shgroup_dynamic_call_add(DRWShadingGroup *shgroup, ...); void DRW_shgroup_state_set(DRWShadingGroup *shgroup, DRWState state); -void DRW_shgroup_dyntype_set(DRWShadingGroup *shgroup, int type); +void DRW_shgroup_attrib_int(DRWShadingGroup *shgroup, const char *name, int size); +void DRW_shgroup_attrib_float(DRWShadingGroup *shgroup, const char *name, int size); void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const struct GPUTexture *tex, int loc); void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const struct GPUUniformBuffer *ubo, int loc); @@ -185,7 +186,6 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const /* Passes */ DRWPass *DRW_pass_create(const char *name, DRWState state); -DRWShadingGroup *DRW_pass_nth_shgroup_get(DRWPass *pass, int n); /* Viewport */ typedef enum { diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 983f22bad5..55ef8359e2 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -58,6 +58,8 @@ #include "clay.h" +#define MAX_ATTRIB_NAME 32 + extern char datatoc_gpu_shader_2D_vert_glsl[]; extern char datatoc_gpu_shader_3D_vert_glsl[]; extern char datatoc_gpu_shader_basic_vert_glsl[]; @@ -74,7 +76,12 @@ typedef enum { DRW_UNIFORM_BLOCK } DRWUniformType; -struct DRWUniform { +typedef enum { + DRW_ATTRIB_INT, + DRW_ATTRIB_FLOAT, +} DRWAttribType; + +typedef struct DRWUniform { struct DRWUniform *next, *prev; DRWUniformType type; int location; @@ -82,10 +89,24 @@ struct DRWUniform { int arraysize; int bindloc; const void *value; -}; +} DRWUniform; + +typedef struct DRWAttrib { + struct DRWAttrib *next, *prev; + char name[MAX_ATTRIB_NAME]; + int location; + int format_id; + int size; /* number of component */ + int type; +} DRWAttrib; struct DRWInterface { - ListBase uniforms; + ListBase uniforms; /* DRWUniform */ + ListBase attribs;/* DRWAttrib */ + int attribs_count; + int attribs_stride; + int attribs_size[16]; + int attribs_loc[16]; /* matrices locations */ int modelview; int projection; @@ -93,10 +114,14 @@ struct DRWInterface { int viewprojection; int normal; int eye; + /* Dynamic batch */ + GLuint instance_vbo; + int instance_count; + VertexFormat vbo_format; }; struct DRWPass { - ListBase shgroups; + ListBase shgroups; /* DRWShadingGroup */ DRWState state; float state_param; /* Line / Point width */ }; @@ -104,19 +129,33 @@ struct DRWPass { typedef struct DRWCall { struct DRWCall *next, *prev; Batch *geometry; - float(*obmat)[4]; + float (*obmat)[4]; } DRWCall; +typedef struct DRWDynamicCall { + struct DRWDynamicCall *next, *prev; + const void *data[]; +} DRWDynamicCall; + struct DRWShadingGroup { struct DRWShadingGroup *next, *prev; + struct GPUShader *shader;/* Shader to bind */ struct DRWInterface *interface; /* Uniforms pointers */ - ListBase calls; /* List with all geometry and
[Bf-blender-cvs] [eb473143a8] blender2.8: Clay Engine: Convert Lamp to use new instancing feature.
Commit: eb473143a8cf26260bd165cb63e043ae9da7a216 Author: Clément Foucault Date: Thu Feb 9 18:33:50 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBeb473143a8cf26260bd165cb63e043ae9da7a216 Clay Engine: Convert Lamp to use new instancing feature. === M source/blender/draw/intern/draw_mode_pass.c M source/blender/gpu/intern/gpu_shader.c M source/blender/gpu/shaders/gpu_shader_3D_lamp_vert.glsl === diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 4a9a340cf1..53ee769c04 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -100,23 +100,8 @@ static DRWShadingGroup *lamp_center_group; static DRWShadingGroup *lamp_groundpoint; static DRWShadingGroup *lamp_groundline; static DRWShadingGroup *lamp_circle; -static DRWShadingGroup *lamp_circle_active; -static DRWShadingGroup *lamp_circle_select; -static DRWShadingGroup *lamp_circle_transform; -static DRWShadingGroup *lamp_circle_group; -static DRWShadingGroup *lamp_circle_group_active; static DRWShadingGroup *lamp_circle_shadow; -static DRWShadingGroup *lamp_circle_shadow_active; -static DRWShadingGroup *lamp_circle_shadow_select; -static DRWShadingGroup *lamp_circle_shadow_transform; -static DRWShadingGroup *lamp_circle_shadow_group; -static DRWShadingGroup *lamp_circle_shadow_group_active; static DRWShadingGroup *lamp_sunrays; -static DRWShadingGroup *lamp_sunrays_active; -static DRWShadingGroup *lamp_sunrays_select; -static DRWShadingGroup *lamp_sunrays_transform; -static DRWShadingGroup *lamp_sunrays_group; -static DRWShadingGroup *lamp_sunrays_group_active; /* Helpers */ static DRWShadingGroup *relationship_lines; @@ -186,13 +171,13 @@ static DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float return grp; } -static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float color[4], float *size) +static DRWShadingGroup *shgroup_lamp(DRWPass *pass, struct Batch *geom, float *size) { GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_LAMP_COMMON); DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom); - DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16); - DRW_shgroup_uniform_vec4(grp, "color", color, 1); + DRW_shgroup_attrib_float(grp, "lamp_pos", 3); + DRW_shgroup_attrib_float(grp, "color", 3); DRW_shgroup_uniform_float(grp, "size", size, 1); DRW_shgroup_uniform_float(grp, "pixel_size", DRW_viewport_pixelsize_get(), 1); DRW_shgroup_uniform_vec3(grp, "screen_vecs", DRW_viewport_screenvecs_get(), 2); @@ -324,26 +309,11 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa lamp_center_group = shgroup_dynpoints_uniform_color(*non_meshes, colorGroup, ); geom = DRW_cache_lamp_get(); - lamp_circle = shgroup_lamp(*non_meshes, geom, colorLampNoAlpha, ); - lamp_circle_active = shgroup_lamp(*non_meshes, geom, colorActive, ); - lamp_circle_select = shgroup_lamp(*non_meshes, geom, colorSelect, ); - lamp_circle_transform = shgroup_lamp(*non_meshes, geom, colorTransform, ); - lamp_circle_group = shgroup_lamp(*non_meshes, geom, colorGroup, ); - lamp_circle_group_active = shgroup_lamp(*non_meshes, geom, colorGroupActive, ); - lamp_circle_shadow = shgroup_lamp(*non_meshes, geom, colorLampNoAlpha, ); - lamp_circle_shadow_active = shgroup_lamp(*non_meshes, geom, colorActive, ); - lamp_circle_shadow_select = shgroup_lamp(*non_meshes, geom, colorSelect, ); - lamp_circle_shadow_transform = shgroup_lamp(*non_meshes, geom, colorTransform, ); - lamp_circle_shadow_group = shgroup_lamp(*non_meshes, geom, colorGroup, ); - lamp_circle_shadow_group_active = shgroup_lamp(*non_meshes, geom, colorGroupActive, ); + lamp_circle = shgroup_lamp(*non_meshes, geom, ); + lamp_circle_shadow = shgroup_lamp(*non_meshes, geom, ); geom = DRW_cache_lamp_sunrays_get(); - lamp_sunrays = shgroup_lamp(*non_meshes, geom, colorLampNoAlpha, ); - lamp_sunrays_active = shgroup_lamp(*non_meshes, geom, colorActive, ); - lamp_sunrays_select = shgroup_lamp(*non_meshes, geom, colorSelect, ); - lamp_sunrays_transform = shgroup_lamp(*non_meshes, geom, colorTransform, ); - lamp_sunrays_group = shgroup_lamp(*non_meshes, geom, colorGroup, ); - lamp_sunrays_group_active = shgroup_lamp(*non_meshes, geom, colorGroupActive, ); + lamp_sunrays = shgroup_lamp(*non_meshes, geom, );
[Bf-blender-cvs] [737d349dbc] blender2.8: Clay Engine: fix instancing (again)
Commit: 737d349dbce972459df5db03bf861c28604c3826 Author: Clément Foucault Date: Thu Feb 9 23:57:54 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB737d349dbce972459df5db03bf861c28604c3826 Clay Engine: fix instancing (again) === M source/blender/draw/intern/draw_manager.c === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 0cfe75c311..970bd2f6de 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -334,6 +334,7 @@ static DRWInterface *DRW_interface_create(GPUShader *shader) interface->instance_count = 0; interface->attribs_count = 0; interface->attribs_stride = 0; + interface->instance_vbo = 0; memset(>vbo_format, 0, sizeof(VertexFormat)); @@ -577,7 +578,6 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const /* Creates a VBO containing OGL primitives for all DRWDynamicCall */ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup) { - int i = 0; DRWInterface *interface = shgroup->interface; int nbr = interface->instance_count; @@ -587,25 +587,28 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup) return; /* Upload Data */ - for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next) { - BLI_assert(attrib->size <= 4); /* matrices have no place here for now */ - if (attrib->type == DRW_ATTRIB_FLOAT) { - attrib->format_id = add_attrib(>vbo_format, attrib->name, GL_FLOAT, attrib->size, KEEP_FLOAT); - } - else if (attrib->type == DRW_ATTRIB_INT) { - attrib->format_id = add_attrib(>vbo_format, attrib->name, GL_BYTE, attrib->size, KEEP_INT); - } - else { - BLI_assert(false); + if (interface->vbo_format.attrib_ct == 0) { + for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next) { + BLI_assert(attrib->size <= 4); /* matrices have no place here for now */ + if (attrib->type == DRW_ATTRIB_FLOAT) { + attrib->format_id = add_attrib(>vbo_format, attrib->name, GL_FLOAT, attrib->size, KEEP_FLOAT); + } + else if (attrib->type == DRW_ATTRIB_INT) { + attrib->format_id = add_attrib(>vbo_format, attrib->name, GL_BYTE, attrib->size, KEEP_INT); + } + else { + BLI_assert(false); + } } } VertexBuffer *vbo = VertexBuffer_create_with_format(>vbo_format); VertexBuffer_allocate_data(vbo, nbr); - for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) { - int j = 0; - for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next, j++) { + int j = 0; + for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next, j++) { + int i = 0; + for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) { setAttrib(vbo, attrib->format_id, j, call->data[i]); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1abd2f279d] blender2.8: Clay Engine: Small instancing fixes
Commit: 1abd2f279dfe87c2d1d648b9780f25697a9b2c52 Author: Clément Foucault Date: Thu Feb 9 20:54:37 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB1abd2f279dfe87c2d1d648b9780f25697a9b2c52 Clay Engine: Small instancing fixes === M source/blender/draw/intern/draw_manager.c === diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 55ef8359e2..0cfe75c311 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -623,6 +623,7 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) int offset = 0; DRWInterface *interface = shgroup->interface; int vert_nbr = interface->instance_count; + int buffer_size = 0; if (vert_nbr == 0) { if (interface->instance_vbo) { @@ -635,6 +636,7 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) /* only once */ if (interface->attribs_stride == 0) { for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, i++) { + BLI_assert(attrib->type == DRW_ATTRIB_FLOAT); /* Only float for now */ interface->attribs_stride += attrib->size; interface->attribs_size[i] = attrib->size; interface->attribs_loc[i] = attrib->location; @@ -642,15 +644,13 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) } /* Gather Data */ - float *data = MEM_mallocN(sizeof(float) * interface->attribs_stride * vert_nbr , "Instance VBO data"); + buffer_size = sizeof(float) * interface->attribs_stride * vert_nbr; + float *data = MEM_mallocN(buffer_size, "Instance VBO data"); - i = 0; - for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next, i++) { - int j = 0; - for (DRWAttrib *attrib = interface->attribs.first; attrib; attrib = attrib->next, j++) { - BLI_assert(attrib->type == DRW_ATTRIB_FLOAT); /* Only float for now */ - memcpy(data + offset, call->data[j], sizeof(float) * attrib->size); - offset += attrib->size; + for (DRWDynamicCall *call = shgroup->calls.first; call; call = call->next) { + for (int j = 0; j < interface->attribs_count; ++j) { + memcpy(data + offset, call->data[j], sizeof(float) * interface->attribs_size[j]); + offset += interface->attribs_size[j]; } } @@ -662,7 +662,7 @@ static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) glGenBuffers(1, >instance_vbo); glBindBuffer(GL_ARRAY_BUFFER, interface->instance_vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4 * 4 * vert_nbr, data, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, buffer_size, data, GL_STATIC_DRAW); MEM_freeN(data); } @@ -785,10 +785,10 @@ typedef struct DRWBoundTexture { GPUTexture *tex; } DRWBoundTexture; -static void draw_geometry(DRWShadingGroup *shgroup, DRWInterface *interface, Batch *geom, - unsigned int instance_vbo, int instance_count, const float (*obmat)[4]) +static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*obmat)[4]) { RegionView3D *rv3d = CTX_wm_region_view3d(DST.context); + DRWInterface *interface = shgroup->interface; float mvp[4][4], mv[4][4], n[3][3]; float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */ @@ -840,8 +840,8 @@ static void draw_geometry(DRWShadingGroup *shgroup, DRWInterface *interface, Bat /* step 2 : bind vertex array & draw */ Batch_set_program(geom, GPU_shader_get_program(shgroup->shader)); - if (instance_vbo) { - Batch_draw_stupid_instanced(geom, instance_vbo, instance_count, interface->attribs_count, + if (interface->instance_vbo) { + Batch_draw_stupid_instanced(geom, interface->instance_vbo, interface->instance_count, interface->attribs_count, interface->attribs_stride, interface->attribs_size, interface->attribs_loc); } else { @@ -918,18 +918,18 @@ static void draw_shgroup(DRWShadingGroup *shgroup) unit_m4(obmat); if (shgroup->type == DRW_SHG_INSTANCE && interface->instance_count > 0) { - draw_geometry(shgroup, interface, shgroup->instance_geom, interface->instance_vbo, interface->instance_count, obmat); + draw_geometry(shgroup, shgroup->instance_geom, obmat); } else { /* Some dynamic batch can have no geom (no call to
[Bf-blender-cvs] [1976fd7af1] blender2.8: Clay Engine: Fix instance attrib.
Commit: 1976fd7af18bd784fadccc1ba4abbf7be878689d Author: Clément Foucault Date: Thu Feb 9 18:33:12 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB1976fd7af18bd784fadccc1ba4abbf7be878689d Clay Engine: Fix instance attrib. === M source/blender/gpu/gawain/batch.c === diff --git a/source/blender/gpu/gawain/batch.c b/source/blender/gpu/gawain/batch.c index 6beddaca6c..55ccd94a55 100644 --- a/source/blender/gpu/gawain/batch.c +++ b/source/blender/gpu/gawain/batch.c @@ -314,9 +314,9 @@ void Batch_draw_stupid_instanced(Batch* batch, unsigned int instance_vbo, int in glVertexAttribPointer(loc + atr_ofs, (size > 4) ? 4 : size, GL_FLOAT, GL_FALSE, sizeof(float) * attrib_stride, (GLvoid*)(sizeof(float) * ptr_ofs)); glVertexAttribDivisor(loc + atr_ofs, 1); - size -= 4; atr_ofs++; ptr_ofs += (size > 4) ? 4 : size; + size -= 4; } } glBindBuffer(GL_ARRAY_BUFFER, 0); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [08c1afb088] blender2.8: Clay Engine: Separate batch for Z straight line
Commit: 08c1afb088743a57eb2e9475a6e531ae27b8b4ac Author: Clément Foucault Date: Thu Feb 9 17:27:01 2017 +0100 Branches: blender2.8 https://developer.blender.org/rB08c1afb088743a57eb2e9475a6e531ae27b8b4ac Clay Engine: Separate batch for Z straight line === M source/blender/draw/intern/draw_cache.c M source/blender/draw/intern/draw_cache.h === diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 1255a083b8..7ea6b8d006 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -42,9 +42,9 @@ static struct DRWShapeCache{ Batch *drw_fullscreen_quad; Batch *drw_plain_axes; Batch *drw_single_arrow; - Batch *drw_single_arrow_line; Batch *drw_cube; Batch *drw_circle; + Batch *drw_line; Batch *drw_empty_sphere; Batch *drw_empty_cone; Batch *drw_arrows; @@ -62,12 +62,12 @@ void DRW_shape_cache_free(void) Batch_discard_all(SHC.drw_plain_axes); if (SHC.drw_single_arrow) Batch_discard_all(SHC.drw_single_arrow); - if (SHC.drw_single_arrow_line) - Batch_discard_all(SHC.drw_single_arrow_line); if (SHC.drw_cube) Batch_discard_all(SHC.drw_cube); if (SHC.drw_circle) Batch_discard_all(SHC.drw_circle); + if (SHC.drw_line) + Batch_discard_all(SHC.drw_line); if (SHC.drw_empty_sphere) Batch_discard_all(SHC.drw_empty_sphere); if (SHC.drw_empty_cone) @@ -149,7 +149,6 @@ Batch *DRW_cache_cube_get(void) return SHC.drw_cube; } - Batch *DRW_cache_circle_get(void) { #define CIRCLE_RESOL 32 @@ -184,6 +183,31 @@ Batch *DRW_cache_circle_get(void) #undef CIRCLE_RESOL } +Batch *DRW_cache_single_line_get(void) +{ + /* Z axis line */ + if (!SHC.drw_line) { + float v1[3] = {0.0f, 0.0f, 0.0f}; + float v2[3] = {0.0f, 0.0f, 1.0f}; + + /* Position Only 3D format */ + static VertexFormat format = { 0 }; + static unsigned pos_id; + if (format.attrib_ct == 0) { + pos_id = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); + } + + VertexBuffer *vbo = VertexBuffer_create_with_format(); + VertexBuffer_allocate_data(vbo, 2); + + setAttrib(vbo, pos_id, 0, v1); + setAttrib(vbo, pos_id, 1, v2); + + SHC.drw_line = Batch_create(GL_LINES, vbo, NULL); + } + return SHC.drw_line; +} + /* Empties */ Batch *DRW_cache_plain_axes_get(void) { @@ -218,9 +242,9 @@ Batch *DRW_cache_plain_axes_get(void) return SHC.drw_plain_axes; } -Batch *DRW_cache_single_arrow_get(Batch **line) +Batch *DRW_cache_single_arrow_get(void) { - if (!SHC.drw_single_arrow_line || !SHC.drw_single_arrow) { + if (!SHC.drw_single_arrow) { float v1[3] = {0.0f, 0.0f, 0.0f}, v2[3], v3[3]; /* Position Only 3D format */ @@ -230,18 +254,8 @@ Batch *DRW_cache_single_arrow_get(Batch **line) pos_id = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); } - /* Line */ - VertexBuffer *vbo = VertexBuffer_create_with_format(); - VertexBuffer_allocate_data(vbo, 2); - - setAttrib(vbo, pos_id, 0, v1); - v1[2] = 1.0f; - setAttrib(vbo, pos_id, 1, v1); - - SHC.drw_single_arrow_line = Batch_create(GL_LINES, vbo, NULL); - /* Square Pyramid */ - vbo = VertexBuffer_create_with_format(); + VertexBuffer *vbo = VertexBuffer_create_with_format(); VertexBuffer_allocate_data(vbo, 12); v2[0] = 0.035f; v2[1] = 0.035f; @@ -265,7 +279,6 @@ Batch *DRW_cache_single_arrow_get(Batch **line) SHC.drw_single_arrow = Batch_create(GL_TRIANGLES, vbo, NULL); } - *line = SHC.drw_single_arrow_line; return SHC.drw_single_arrow; } diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index c53f3d88af..0e467bddbf 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -34,10 +34,11 @@ void DRW_shape_cache_free(void); /* Common Shapes */ struct Batch *DRW_cache_fullscreen_quad_get(void); struct Batch *DRW_cache_single_vert_get(void); +struct Batch *DRW_cache_single_line_get(void); /* Empties */ struct Batch *DRW_cache_plain_axes_get(void); -struct Batch *DRW_cache_single_arrow_get(struct Batch **line); +struct Batch *DRW_cache_single_arrow_get(void); struct Batch *DRW_cache_cube_get(void); struct Batch *DRW_cache_circle_get(void); struct Batch
[Bf-blender-cvs] [1ac6e4c7a2] master: UI: Redesign the VSE multicam strip
Commit: 1ac6e4c7a2f0c3a38468edb0c501e52c0aea5f28 Author: Aaron Carlisle Date: Sat Feb 11 11:35:02 2017 -0500 Branches: master https://developer.blender.org/rB1ac6e4c7a2f0c3a38468edb0c501e52c0aea5f28 UI: Redesign the VSE multicam strip Idea from https://rightclickselect.com/p/sequencer/zfbbbc/sequencer-panels-update by @pauloup |{F434631}|{F434624}| |Before |After| Test file: {F434643} === M release/scripts/startup/bl_ui/space_sequencer.py === diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 6bb516cf92..8ab5b4724b 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -652,17 +652,39 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): col.prop(strip, "rotation_start", text="Rotation") elif strip.type == 'MULTICAM': -layout.prop(strip, "multicam_source") - -row = layout.row(align=True) -sub = row.row(align=True) -sub.scale_x = 2.0 - -sub.operator("screen.animation_play", text="", icon='PAUSE' if context.screen.is_animation_playing else 'PLAY') +col = layout.column(align=True) +strip_channel = strip.channel + +col.prop(strip, "multicam_source", text="Source Channel") + +# The multicam strip needs at least 2 strips to be useful +if strip_channel > 2: +BT_ROW = 4 + +col.label("Cut To:") +row = col.row() + +for i in range(1, strip_channel): +if (i % BT_ROW) == 1: +row = col.row(align=True) + +# Workaround - .active has to have a separate UI block to work +if i == strip.multicam_source: +sub = row.row(align=True) +sub.active = False +sub.operator("sequencer.cut_multicam", text="%d" % i).camera = i +else: +sub_1 = row.row(align=True) +sub_1.active = True +sub_1.operator("sequencer.cut_multicam", text="%d" % i).camera = i + +if strip.channel > BT_ROW and (strip_channel - 1) % BT_ROW: +for i in range(strip.channel, strip_channel + ((BT_ROW + 1 - strip_channel) % BT_ROW)): +row.label("") +else: +col.separator() +col.label(text="Two or more channels are needed below this strip.", icon="INFO") -row.label("Cut To") -for i in range(1, strip.channel): -row.operator("sequencer.cut_multicam", text="%d" % i).camera = i elif strip.type == 'TEXT': col = layout.column() ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c5f2380be7] blender2.8: OpenGL immediate mode: drawarmature.c (cont)
Commit: c5f2380be715916c17d86c7b34e49c5ac0cad792 Author: Clément Foucault Date: Sat Feb 11 14:19:23 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBc5f2380be715916c17d86c7b34e49c5ac0cad792 OpenGL immediate mode: drawarmature.c (cont) Cube bone wire. Fix do_const_color. This breaks the selection in glSelect mode. Occlusion queries are fine. === M source/blender/editors/space_view3d/drawarmature.c === diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 61584b0a44..a7bff0a830 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -356,7 +356,7 @@ static void set_ebone_glColor(const unsigned int boneflag) /* *** Armature drawing, helper calls for parts *** */ /* half the cube, in Y */ -static const float cube[8][3] = { +static const float cube_vert[8][3] = { {-1.0, 0.0, -1.0}, {-1.0, 0.0, 1.0}, {-1.0, 1.0, 1.0}, @@ -367,6 +367,12 @@ static const float cube[8][3] = { { 1.0, 1.0, -1.0}, }; +static const float cube_wire[24] = { + 0, 1, 1, 2, 2, 3, 3, 0, + 4, 5, 5, 6, 6, 7, 7, 4, + 0, 4, 1, 5, 2, 6, 3, 7, +}; + static void drawsolidcube_size(float xsize, float ysize, float zsize) { static GLuint displist = 0; @@ -381,26 +387,26 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize) glBegin(GL_QUADS); n[0] = -1.0; glNormal3fv(n); - glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); + glVertex3fv(cube_vert[0]); glVertex3fv(cube_vert[1]); glVertex3fv(cube_vert[2]); glVertex3fv(cube_vert[3]); n[0] = 0; n[1] = -1.0; glNormal3fv(n); - glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[1]); + glVertex3fv(cube_vert[0]); glVertex3fv(cube_vert[4]); glVertex3fv(cube_vert[5]); glVertex3fv(cube_vert[1]); n[1] = 0; n[0] = 1.0; glNormal3fv(n); - glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[6]); glVertex3fv(cube[5]); + glVertex3fv(cube_vert[4]); glVertex3fv(cube_vert[7]); glVertex3fv(cube_vert[6]); glVertex3fv(cube_vert[5]); n[0] = 0; n[1] = 1.0; glNormal3fv(n); - glVertex3fv(cube[7]); glVertex3fv(cube[3]); glVertex3fv(cube[2]); glVertex3fv(cube[6]); + glVertex3fv(cube_vert[7]); glVertex3fv(cube_vert[3]); glVertex3fv(cube_vert[2]); glVertex3fv(cube_vert[6]); n[1] = 0; n[2] = 1.0; glNormal3fv(n); - glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[2]); + glVertex3fv(cube_vert[1]); glVertex3fv(cube_vert[5]); glVertex3fv(cube_vert[6]); glVertex3fv(cube_vert[2]); n[2] = -1.0; glNormal3fv(n); - glVertex3fv(cube[7]); glVertex3fv(cube[4]); glVertex3fv(cube[0]); glVertex3fv(cube[3]); + glVertex3fv(cube_vert[7]); glVertex3fv(cube_vert[4]); glVertex3fv(cube_vert[0]); glVertex3fv(cube_vert[3]); glEnd(); glEndList(); @@ -411,30 +417,42 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize) static void drawcube_size(float xsize, float ysize, float zsize) { - static GLuint displist = 0; - - if (displist == 0) { - displist = glGenLists(1); - glNewList(displist, GL_COMPILE); - - glBegin(GL_LINE_STRIP); - glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); - glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); - glVertex3fv(cube[7]); glVertex3fv(cube[4]); - glEnd(); - - glBegin(GL_LINES); - glVertex3fv(cube[1]); glVertex3fv(cube[5]); - glVertex3fv(cube[2]); glVertex3fv(cube[6]); - glVertex3fv(cube[3]); glVertex3fv(cube[7]); - glEnd(); - - glEndList(); + static VertexFormat format = {0}; + static VertexBuffer vbo = {0}; + static ElementListBuilder elb = {0}; + static ElementList el = {0}; + static Batch batch = {0}; + + if (format.attrib_ct == 0) { + /* Vertex format */ + unsigned int pos = add_attrib(, "pos", GL_FLOAT, 3, KEEP_FLOAT); + + /* Elements */ + ElementListBuilder_init(, GL_LINES, 12, 8); +
[Bf-blender-cvs] [a644f2b46c] cycles_split_kernel: Cycles: Refactor device split kernel code
Commit: a644f2b46c54259809bf2c88ee26465aa33e7b37 Author: Mai Lavelle Date: Fri Feb 3 22:40:59 2017 -0500 Branches: cycles_split_kernel https://developer.blender.org/rBa644f2b46c54259809bf2c88ee26465aa33e7b37 Cycles: Refactor device split kernel code Moved all split kernel related stuff out of `Device` as it doesnt belong there. Those functions are now apart of `DeviceSplitKernel` which now must be implemented for each device type supporting the split kernel. No functional changes. === M intern/cycles/device/device.h M intern/cycles/device/device_cpu.cpp M intern/cycles/device/device_cuda.cpp M intern/cycles/device/device_split_kernel.cpp M intern/cycles/device/device_split_kernel.h M intern/cycles/device/opencl/opencl_split.cpp === diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 6da7767ae2..c740cada98 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -33,7 +33,6 @@ CCL_NAMESPACE_BEGIN class Progress; class RenderTile; -class DeviceSplitKernel; /* Device Types */ @@ -205,28 +204,6 @@ public: std::ostream& operator <<(std::ostream , const DeviceRequestedFeatures& requested_features); -/* Types used for split kernel */ - -class KernelDimensions { -public: - size_t global_size[2]; - size_t local_size[2]; - - KernelDimensions(size_t global_size_[2], size_t local_size_[2]) - { - memcpy(global_size, global_size_, sizeof(global_size)); - memcpy(local_size, local_size_, sizeof(local_size)); - } -}; - -class SplitKernelFunction { -public: - virtual ~SplitKernelFunction() {} - - /* enqueue the kernel, returns false if there is an error */ - virtual bool enqueue(const KernelDimensions& dim, device_memory& kg, device_memory& data) = 0; -}; - /* Device */ struct DeviceDrawParams { @@ -292,44 +269,6 @@ public: const DeviceRequestedFeatures& /*requested_features*/) { return true; } -private: - /* split kernel */ - virtual bool enqueue_split_kernel_data_init(const KernelDimensions& /*dim*/, - RenderTile& /*rtile*/, - int /*num_global_elements*/, - device_memory& /*kernel_globals*/, - device_memory& /*kernel_data*/, - device_memory& /*split_data*/, - device_memory& /*ray_state*/, - device_memory& /*queue_index*/, - device_memory& /*use_queues_flag*/, - device_memory& /*work_pool_wgs*/) - { - assert(!"not implemented for this device"); - return false; - } - - virtual SplitKernelFunction* get_split_kernel_function(string /*kernel_name*/, const DeviceRequestedFeatures&) - { - assert(!"not implemented for this device"); - return NULL; - } - - virtual int2 split_kernel_local_size() - { - assert(!"not implemented for this device"); - return make_int2(0, 0); - } - - virtual int2 split_kernel_global_size(DeviceTask */*task*/, DeviceSplitKernel& /*split_kernel*/) - { - assert(!"not implemented for this device"); - return make_int2(64, 64); - } - - friend class DeviceSplitKernel; - -public: /* tasks */ virtual int get_split_task_count(DeviceTask& task) = 0; virtual void task_add(DeviceTask& task) = 0; diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index f423fdf60b..722274d042 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -53,33 +53,25 @@ CCL_NAMESPACE_BEGIN class CPUDevice; -class CPUSplitKernelFunction : public SplitKernelFunction { +class CPUSplitKernel : public DeviceSplitKernel { + CPUDevice *device; public: - CPUDevice* device; - void (*func)(KernelGlobals *kg, KernelData *data); - - CPUSplitKernelFunction(CPUDevice* device) : device(device), func(NULL) {} - ~CPUSplitKernelFunction() {} - - virtual bool enqueue(const KernelDimensions& dim, device_memory& kernel_globals, device_memory& data) - { - if(!func) { - return false; - } - - KernelGlobals *kg = (KernelGlobals*)kernel_globals.device_pointer; - kg->global_size = make_int2(dim.global_size[0], dim.global_size[1]); +
[Bf-blender-cvs] [83ef38068b] cycles_split_kernel: Cycles: Move kgbuffer allocation out of split kernel code
Commit: 83ef38068b71ae4453f94d566fd0da02e5912ad1 Author: Mai Lavelle Date: Sat Feb 11 06:25:01 2017 -0500 Branches: cycles_split_kernel https://developer.blender.org/rB83ef38068b71ae4453f94d566fd0da02e5912ad1 Cycles: Move kgbuffer allocation out of split kernel code Allocating the buffer is the job of the device implementation, not the split kernel, so makes more sense to separate that code. === M intern/cycles/device/device.h M intern/cycles/device/device_cpu.cpp M intern/cycles/device/device_cuda.cpp M intern/cycles/device/device_split_kernel.cpp M intern/cycles/device/device_split_kernel.h M intern/cycles/device/opencl/opencl_split.cpp === diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index dd176c7577..6da7767ae2 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -315,16 +315,6 @@ private: return NULL; } - virtual void alloc_kernel_globals(device_memory& /*mem*/) - { - assert(!"not implemented for this device"); - } - - virtual void free_kernel_globals(device_memory& /*mem*/) - { - assert(!"not implemented for this device"); - } - virtual int2 split_kernel_local_size() { assert(!"not implemented for this device"); diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 69a5169613..f423fdf60b 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -446,14 +446,25 @@ public: DeviceSplitKernel split_kernel(this); + /* allocate buffer for kernel globals */ + device_memory kgbuffer; + kgbuffer.resize(sizeof(KernelGlobals)); + mem_alloc("kernel_globals", kgbuffer, MEM_READ_WRITE); + + KernelGlobals *kg = (KernelGlobals*)kgbuffer.device_pointer; + *kg = thread_kernel_globals_init(); + requested_features.max_closure = MAX_CLOSURE; if(!split_kernel.load_kernels(requested_features)) { + thread_kernel_globals_free((KernelGlobals*)kgbuffer.device_pointer); + mem_free(kgbuffer); + return; } while(task.acquire_tile(this, tile)) { device_memory data; - split_kernel.path_trace(, tile, data); + split_kernel.path_trace(, tile, kgbuffer, data); task.release_tile(tile); @@ -462,6 +473,9 @@ public: break; } } + + thread_kernel_globals_free((KernelGlobals*)kgbuffer.device_pointer); + mem_free(kgbuffer); } void thread_film_convert(DeviceTask& task) @@ -818,21 +832,6 @@ protected: return kernel; } - virtual void alloc_kernel_globals(device_memory& mem) - { - mem.resize(sizeof(KernelGlobals)); - mem_alloc("kernel_globals", mem, MEM_READ_WRITE); - - KernelGlobals *kg = (KernelGlobals*)mem.device_pointer; - *kg = thread_kernel_globals_init(); - } - - virtual void free_kernel_globals(device_memory& mem) - { - thread_kernel_globals_free((KernelGlobals*)mem.device_pointer); - mem_free(mem); - } - virtual int2 split_kernel_global_size(DeviceTask *task, DeviceSplitKernel& /*split_kernel*/) { /* TODO(mai): this needs investigation but cpu gives incorrect render if global size doesnt match tile size */ diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 39bf2de780..8985c27c7a 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1313,8 +1313,8 @@ public: split_kernel.load_kernels(requested_features); while(task->acquire_tile(this, tile)) { - device_memory data; - split_kernel.path_trace(task, tile, data); + device_memory void_buffer; + split_kernel.path_trace(task, tile, void_buffer, void_buffer); task->release_tile(tile); @@ -1527,14 +1527,6 @@ public: return new CUDASplitKernelFunction(this, func); } - void alloc_kernel_globals(device_memory& /*mem*/) - { - } - - void free_kernel_globals(device_memory& /*mem*/) - { - } - int2 split_kernel_local_size() {