Commit: 9f344c6b887306b42156279deffb5112f88757d1 Author: Nick Wu Date: Mon Jul 23 11:34:30 2018 +0800 Branches: soc-2018-npr https://developer.blender.org/rB9f344c6b887306b42156279deffb5112f88757d1
Merge and changed GWN APIs into GPU ones. =================================================================== M source/blender/draw/engines/lanpr/lanpr_all.h M source/blender/draw/engines/lanpr/lanpr_chain.c M source/blender/draw/engines/lanpr/lanpr_dpix.c M source/blender/draw/engines/lanpr/lanpr_engine.c M source/blender/draw/engines/lanpr/lanpr_ops.c M source/blender/draw/engines/lanpr/lanpr_snake.c M source/blender/draw/intern/draw_manager.c =================================================================== diff --git a/source/blender/draw/engines/lanpr/lanpr_all.h b/source/blender/draw/engines/lanpr/lanpr_all.h index 158a9057ef3..702c22e1132 100644 --- a/source/blender/draw/engines/lanpr/lanpr_all.h +++ b/source/blender/draw/engines/lanpr/lanpr_all.h @@ -215,8 +215,8 @@ typedef struct LANPR_PrivateData { unsigned i_buf; unsigned l_buf; - Gwn_VertFormat snake_gwn_format; - Gwn_Batch *snake_batch; + GPUVertFormat snake_gwn_format; + GPUBatch *snake_batch; ListBase dpix_batch_list; @@ -228,8 +228,8 @@ typedef struct LANPR_StorageList { typedef struct LANPR_BatchItem { Link Item; - Gwn_Batch *dpix_transform_batch; - Gwn_Batch *dpix_preview_batch; + GPUBatch *dpix_transform_batch; + GPUBatch *dpix_preview_batch; Object *ob; } LANPR_BatchItem; @@ -308,8 +308,8 @@ typedef struct LANPR_RenderBuffer { nListHandle IntersectingVertexBuffer; - struct Gwn_Batch *DPIXIntersectionTransformBatch; - struct Gwn_Batch *DPIXIntersectionBatch; + struct GPUBatch *DPIXIntersectionTransformBatch; + struct GPUBatch *DPIXIntersectionBatch; /* use own-implemented one */ nStaticMemoryPool RenderDataPool; @@ -348,7 +348,7 @@ typedef struct LANPR_RenderBuffer { nListHandle EdgeMarks; nListHandle Chains; - Gwn_Batch* ChainDrawBatch; + GPUBatch* ChainDrawBatch; DRWShadingGroup* ChainShgrp; SpinLock csInfo; diff --git a/source/blender/draw/engines/lanpr/lanpr_chain.c b/source/blender/draw/engines/lanpr/lanpr_chain.c index 758493fb1b2..d60c75bd11b 100644 --- a/source/blender/draw/engines/lanpr/lanpr_chain.c +++ b/source/blender/draw/engines/lanpr/lanpr_chain.c @@ -279,16 +279,16 @@ void lanpr_ChainGenerateDrawCommand(LANPR_RenderBuffer *rb){ float* lengths; float length_target[2]; - static Gwn_VertFormat format = { 0 }; + static GPUVertFormat format = { 0 }; static struct { uint pos, offset, type, level; } 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.offset = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - attr_id.type = GWN_vertformat_attr_add(&format, "type", GWN_COMP_I32, 1, GWN_FETCH_FLOAT); - attr_id.level = GWN_vertformat_attr_add(&format, "level", GWN_COMP_I32, 1, GWN_FETCH_INT); + attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.offset = GPU_vertformat_attr_add(&format, "uvs", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + attr_id.type = GPU_vertformat_attr_add(&format, "type", GPU_COMP_I32, 1, GPU_FETCH_FLOAT); + attr_id.level = GPU_vertformat_attr_add(&format, "level", GPU_COMP_I32, 1, GPU_FETCH_INT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); for(rlc = rb->Chains.pFirst; rlc;rlc=rlc->Item.pNext){ int count = lanpr_CountChain(rlc); @@ -296,12 +296,12 @@ void lanpr_ChainGenerateDrawCommand(LANPR_RenderBuffer *rb){ vert_count += count; } - GWN_vertbuf_data_alloc(vbo, vert_count+1); // serve as end point's adj. + GPU_vertbuf_data_alloc(vbo, vert_count+1); // serve as end point's adj. lengths = MEM_callocN(sizeof(float)*vert_count, "chain lengths"); - Gwn_IndexBufBuilder elb; - GWN_indexbuf_init_ex(&elb, GWN_PRIM_LINES_ADJ, vert_count*4, vert_count, true);// elem count will not exceed vert_count + GPUIndexBufBuilder elb; + GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINES_ADJ, vert_count*4, vert_count, true);// elem count will not exceed vert_count for(rlc = rb->Chains.pFirst; rlc; rlc=rlc->Item.pNext){ @@ -312,25 +312,25 @@ void lanpr_ChainGenerateDrawCommand(LANPR_RenderBuffer *rb){ length_target[0] = lengths[i]; length_target[1] = total_length - lengths[i]; - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rlci->pos); - GWN_vertbuf_attr_set(vbo, attr_id.offset, i, length_target); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, rlci->pos); + GPU_vertbuf_attr_set(vbo, attr_id.offset, i, length_target); if (rlci == rlc->Chain.pLast) { if (rlci->Item.pPrev == rlc->Chain.pFirst) { length_target[1] = total_length; - GWN_vertbuf_attr_set(vbo, attr_id.offset, i, length_target); + GPU_vertbuf_attr_set(vbo, attr_id.offset, i, length_target); } i++; continue; } if (rlci == rlc->Chain.pFirst) { - if (rlci->Item.pNext == rlc->Chain.pLast) GWN_indexbuf_add_line_adj_verts(&elb, vert_count, i, i + 1, vert_count); - else GWN_indexbuf_add_line_adj_verts(&elb, vert_count, i, i + 1, i + 2); + if (rlci->Item.pNext == rlc->Chain.pLast) GPU_indexbuf_add_line_adj_verts(&elb, vert_count, i, i + 1, vert_count); + else GPU_indexbuf_add_line_adj_verts(&elb, vert_count, i, i + 1, i + 2); } else { - if (rlci->Item.pNext == rlc->Chain.pLast) GWN_indexbuf_add_line_adj_verts(&elb, i-1, i, i + 1, vert_count); - else GWN_indexbuf_add_line_adj_verts(&elb, i-1, i, i + 1, i + 2); + if (rlci->Item.pNext == rlc->Chain.pLast) GPU_indexbuf_add_line_adj_verts(&elb, i-1, i, i + 1, vert_count); + else GPU_indexbuf_add_line_adj_verts(&elb, i-1, i, i + 1, i + 2); } i++; @@ -339,10 +339,10 @@ void lanpr_ChainGenerateDrawCommand(LANPR_RenderBuffer *rb){ //set end point flag value. length_target[0] = 3e30f; length_target[1] = 3e30f; - GWN_vertbuf_attr_set(vbo, attr_id.pos, vert_count, length_target); + GPU_vertbuf_attr_set(vbo, attr_id.pos, vert_count, length_target); MEM_freeN(lengths); - rb->ChainDrawBatch = GWN_batch_create_ex(GWN_PRIM_LINES_ADJ, vbo, GWN_indexbuf_build(&elb), GWN_USAGE_DYNAMIC | GWN_BATCH_OWNS_VBO); + rb->ChainDrawBatch = GPU_batch_create_ex(GPU_PRIM_LINES_ADJ, vbo, GPU_indexbuf_build(&elb), GPU_USAGE_DYNAMIC | GPU_BATCH_OWNS_VBO); } \ No newline at end of file diff --git a/source/blender/draw/engines/lanpr/lanpr_dpix.c b/source/blender/draw/engines/lanpr/lanpr_dpix.c index f3a7a305e4f..e231eafb7f1 100644 --- a/source/blender/draw/engines/lanpr/lanpr_dpix.c +++ b/source/blender/draw/engines/lanpr/lanpr_dpix.c @@ -281,32 +281,32 @@ int lanpr_feed_atlas_trigger_preview_obj(void *vedata, Object *ob, int BeginInde int i; float co[2]; - 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.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - static Gwn_VertFormat format2 = { 0 }; + static GPUVertFormat format2 = { 0 }; static struct { uint pos, uvs; } attr_id2; if (format2.attr_len == 0) { - attr_id2.pos = GWN_vertformat_attr_add(&format2, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id2.pos = GPU_vertformat_attr_add(&format2, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - Gwn_VertBuf *vbo2 = GWN_vertbuf_create_with_format(&format2); - GWN_vertbuf_data_alloc(vbo, edge_count); - GWN_vertbuf_data_alloc(vbo2, edge_count); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPUVertBuf *vbo2 = GPU_vertbuf_create_with_format(&format2); + GPU_vertbuf_data_alloc(vbo, edge_count); + GPU_vertbuf_data_alloc(vbo2, edge_count); for (i = 0; i < edge_count; i++) { lanpr_dpix_index_to_coord(i + BeginIndex, &co[0], &co[1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, co); lanpr_dpix_index_to_coord_absolute(i + BeginIndex, &co[0], &co[1]); - GWN_vertbuf_attr_set(vbo2, attr_id2.pos, i, co); + GPU_vertbuf_attr_set(vbo2, attr_id2.pos, i, co); } - Gwn_Batch *gb = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, 0, GWN_USAGE_STATIC | GWN_BATCH_OWNS_VBO); - Gwn_Batch *gb2 = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo2, 0, GWN_USAGE_STATIC | GWN_BATCH_OWNS_VBO); + GPUBatch *gb = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, 0, GPU_USAGE_STATIC | GPU_BATCH_OWNS_VBO); + GPUBatch *gb2 = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo2, 0, GPU_USAGE_STATIC | GPU_BATCH_OWNS_VBO); LANPR_BatchItem *bi = BLI_mempool_alloc(pd->mp_batch_list); BLI_addtail(&pd->dpix_batch_list, bi); @@ -328,36 +328,36 @@ void lanpr_create_atlas_intersection_preview(void *vedata, int BeginIndex) { if (!rb) return; - if (rb->DPIXIntersectionBatch) GWN_batch_discard(rb->DPIXIntersectionBatch); + if (rb->DPIXIntersectionBatch) GPU_batch_discard(rb->DPIXIntersectionBatch); rb->DPIXIntersectionBatch = 0; if (!rb->IntersectionCount) return; - 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.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - static Gwn_VertFormat format2 = { 0 }; + static GPUVertFormat format2 = { 0 }; static struct { uint pos, uvs; } attr_id2; if (format2.attr_len == 0) { - attr_id2.pos = GWN_vertformat_attr_add(&format2, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + attr_id2.pos = GPU_vertformat_attr_add(&format2, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, rb->IntersectionCount); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, rb->IntersectionCount); - Gwn_VertBuf *vbo2 = GWN_vertbuf_create_with_format(&format2); - GWN_vertbuf_data_alloc(vbo2, rb->IntersectionCount); + GPUVertBuf *vbo2 = GPU_vertbuf_create_with_format(&format2); + GPU_vertbuf_data_alloc(vbo2, rb->IntersectionCount); for (i = 0; i < rb->IntersectionCount; i++) { lanpr_dpix_index_to_coord(i + BeginIndex, &co[0], &co[1]); - GWN_vertbuf_attr_set(vbo, attr_id.pos, i, co); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i, co); lanpr_dpix_index_to_coord_absolute(i + BeginIndex, &co[0], &co[1]); - GWN_vertbuf_attr_set(vbo2, attr_id2.pos, i, co); + GPU_vertbuf_attr_set(vbo2, attr_id2.pos, i, co); } - rb->DPIXIntersectionTransformBatch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, 0, GWN_USAGE_S @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs