Initial Grease Pencil 3.0 stage #106848

Merged
Falk David merged 224 commits from filedescriptor/blender:grease-pencil-v3 into main 2023-05-30 11:14:22 +02:00
2 changed files with 17 additions and 6 deletions
Showing only changes of commit f27e618e79 - Show all commits

View File

@ -160,6 +160,10 @@ class ObjectModule {
object_subpass.state_set(state);
object_subpass.shader_set(shaders_.static_shader_get(GREASE_PENCIL));
GPUVertBuf *position_tx = DRW_cache_grease_pencil_position_buffer_get(object, current_frame_);
GPUVertBuf *color_tx = DRW_cache_grease_pencil_color_buffer_get(object, current_frame_);
GPUBatch *geom = DRW_cache_grease_pencil_get(object, current_frame_);
grease_pencil.foreach_visible_drawing(

Typically dead code is discouraged.
Not sure what is it part of, so can't really give strong suggestions.

Typically dead code is discouraged. Not sure what is it part of, so can't really give strong suggestions.
current_frame_, [&](GreasePencilDrawing &drawing, bke::gpencil::Layer &layer) {
/* TODO(fclem): Pass per frame object matrix here. */
@ -171,11 +175,6 @@ class ObjectModule {
ob.layer_offset = layer_offset;
ob.material_offset = material_offset;
GPUVertBuf *position_tx = DRW_cache_grease_pencil_position_buffer_get(object,
current_frame_);
GPUVertBuf *color_tx = DRW_cache_grease_pencil_color_buffer_get(object, current_frame_);
GPUBatch *geom = DRW_cache_grease_pencil_get(object, current_frame_);
if (do_layer_blending) {
// for (const LayerData &layer : frame.layers) {
// UNUSED_VARS(layer);

View File

@ -22,6 +22,7 @@
#include "draw_cache_impl.h"
#include "../engines/gpencil/gpencil_defines.h"
#include "../engines/gpencil/gpencil_shader_shared.h"
namespace blender::draw {
@ -201,7 +202,7 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
/* First count how many vertices and triangles are needed for the whole object. */
int total_points_num = 0;
int total_triangles_num = 0; // TODO
int total_triangles_num = 0;
grease_pencil.foreach_visible_drawing(
cfra, [&](GreasePencilDrawing &drawing, blender::bke::gpencil::Layer &layer) {
bke::CurvesGeometry &curves = drawing.geometry.wrap();

More specific/helpful variable names than t and v would be nice here

More specific/helpful variable names than `t` and `v` would be nice here
@ -209,6 +210,7 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
/* One vertex is stored before and after as padding. Cyclic strokes have one extra
* vertex.*/
total_points_num += curves.points_num() + num_cyclic + curves.curves_num() * 2;
total_triangles_num += (curves.points_num() + num_cyclic) * 2;
});
GPUUsageType vbo_flag = GPU_USAGE_STATIC | GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY;
@ -262,6 +264,11 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
verts[v].point_id = v;
verts[v].stroke_id = v_start;
verts[v].mat = materials[curve_i] % GPENCIL_MATERIAL_BUFFER_LEN;
int v_mat = (v << GP_VERTEX_ID_SHIFT) | GP_IS_STROKE_VERTEX_BIT;
GPU_indexbuf_add_tri_verts(&ibo, v_mat + 0, v_mat + 1, v_mat + 2);
GPU_indexbuf_add_tri_verts(&ibo, v_mat + 2, v_mat + 1, v_mat + 3);
v++;
}

Use the * overload rather than adding .varray at the end

Use the `*` overload rather than adding `.varray` at the end
@ -272,6 +279,11 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
verts[v].point_id = v;
verts[v].stroke_id = v_start;
verts[v].mat = materials[curve_i] % GPENCIL_MATERIAL_BUFFER_LEN;
int v_mat = (v << GP_VERTEX_ID_SHIFT) | GP_IS_STROKE_VERTEX_BIT;
GPU_indexbuf_add_tri_verts(&ibo, v_mat + 0, v_mat + 1, v_mat + 2);
GPU_indexbuf_add_tri_verts(&ibo, v_mat + 2, v_mat + 1, v_mat + 3);

These .as_span() calls shouldn't be necessary

These `.as_span()` calls shouldn't be necessary
v++;
}