[Bf-blender-cvs] [f6371454500] blender2.8: Fix compilation on gcc

2017-05-21 Thread Antony Riakiotakis
Commit: f637145450010d14660fcb029d41560a138eae14
Author: Antony Riakiotakis
Date:   Mon May 22 03:33:31 2017 +0300
Branches: blender2.8
https://developer.blender.org/rBf637145450010d14660fcb029d41560a138eae14

Fix compilation on gcc

===

M   intern/gawain/src/element.c

===

diff --git a/intern/gawain/src/element.c b/intern/gawain/src/element.c
index 1346be024e3..1875c0a3cc8 100644
--- a/intern/gawain/src/element.c
+++ b/intern/gawain/src/element.c
@@ -33,6 +33,12 @@ unsigned ElementList_size(const ElementList* elem)
case INDEX_U8: return elem->index_ct * sizeof(GLubyte);
case INDEX_U16: return elem->index_ct * sizeof(GLushort);
case INDEX_U32: return elem->index_ct * sizeof(GLuint);
+
+   default:
+#if TRUST_NO_ONE
+   assert(false);
+#endif
+   return 0;
}
 
 #else

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3f6f02e4336] blender2.8: Gawain: drop support for APPLE_flush_buffer_range

2017-05-21 Thread Mike Erwin
Commit: 3f6f02e4336455bd70df7b604bea57ce75d1d87c
Author: Mike Erwin
Date:   Sun May 21 17:06:42 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB3f6f02e4336455bd70df7b604bea57ce75d1d87c

Gawain: drop support for APPLE_flush_buffer_range

Modern GL's glMapBufferRange works the same on all platforms.

Part of T49012

===

M   intern/gawain/gawain/common.h
M   intern/gawain/src/immediate.c

===

diff --git a/intern/gawain/gawain/common.h b/intern/gawain/gawain/common.h
index 1c8153e750e..e21b241160d 100644
--- a/intern/gawain/gawain/common.h
+++ b/intern/gawain/gawain/common.h
@@ -25,9 +25,3 @@
 #if TRUST_NO_ONE
   #include 
 #endif
-
-#if defined(__APPLE__) && defined(WITH_GL_PROFILE_COMPAT)
-  #define APPLE_LEGACY 1
-#else
-  #define APPLE_LEGACY 0
-#endif
diff --git a/intern/gawain/src/immediate.c b/intern/gawain/src/immediate.c
index ae691c71a72..7c3b0e11e92 100644
--- a/intern/gawain/src/immediate.c
+++ b/intern/gawain/src/immediate.c
@@ -69,11 +69,6 @@ void immInit(void)
glBindBuffer(GL_ARRAY_BUFFER, imm.vbo_id);
glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW);
 
-#if APPLE_LEGACY
-   glBufferParameteriAPPLE(GL_ARRAY_BUFFER, 
GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_FALSE);
-   glBufferParameteriAPPLE(GL_ARRAY_BUFFER, 
GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE);
-#endif
-
imm.prim_type = PRIM_NONE;
imm.strict_vertex_ct = true;
 
@@ -208,7 +203,7 @@ void immBegin(PrimitiveType prim_type, unsigned vertex_ct)
else
{
// orphan this buffer & start with a fresh one
-#if 1 || APPLE_LEGACY
+#if 1
// this method works on all platforms, old & new
glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, 
GL_DYNAMIC_DRAW);
 #else
@@ -235,12 +230,8 @@ void immBegin(PrimitiveType prim_type, unsigned vertex_ct)
 
 // printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + 
bytes_needed - 1);
 
-#if APPLE_LEGACY
-   imm.buffer_data = (GLubyte*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY) 
+ imm.buffer_offset;
-#else
imm.buffer_data = glMapBufferRange(GL_ARRAY_BUFFER, imm.buffer_offset, 
bytes_needed,
   GL_MAP_WRITE_BIT | 
GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_ct ? 0 : 
GL_MAP_FLUSH_EXPLICIT_BIT));
-#endif
 
 #if TRUST_NO_ONE
assert(imm.buffer_data != NULL);
@@ -390,11 +381,10 @@ void immEnd(void)
// unused buffer bytes are available to the next 
immBegin
// printf(" %u of %u bytes\n", buffer_bytes_used, 
imm.buffer_bytes_mapped);
}
-#if !APPLE_LEGACY
+
// tell OpenGL what range was modified so it doesn't copy the 
whole mapped range
// printf("flushing %u to %u\n", imm.buffer_offset, 
imm.buffer_offset + buffer_bytes_used - 1);
glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, buffer_bytes_used);
-#endif
}
 
 #if IMM_BATCH_COMBO
@@ -412,11 +402,6 @@ void immEnd(void)
else
 #endif
{
-#if APPLE_LEGACY
-   // tell OpenGL what range was modified so it doesn't copy the 
whole buffer
-   // printf("flushing %u to %u\n", imm.buffer_offset, 
imm.buffer_offset + buffer_bytes_used - 1);
-   glFlushMappedBufferRangeAPPLE(GL_ARRAY_BUFFER, 
imm.buffer_offset, buffer_bytes_used);
-#endif
glUnmapBuffer(GL_ARRAY_BUFFER);
 
if (imm.vertex_ct > 0)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [054eb9422ca] blender2.8: Gawain: use integer math to convert int16 to int10

2017-05-21 Thread Mike Erwin
Commit: 054eb9422ca5bfea460229374cd8986d297f74c8
Author: Mike Erwin
Date:   Sun May 21 18:07:23 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB054eb9422ca5bfea460229374cd8986d297f74c8

Gawain: use integer math to convert int16 to int10

@fclem does this work for you?

===

M   intern/gawain/src/vertex_format.c

===

diff --git a/intern/gawain/src/vertex_format.c 
b/intern/gawain/src/vertex_format.c
index d2f89455cbc..963e660dc3d 100644
--- a/intern/gawain/src/vertex_format.c
+++ b/intern/gawain/src/vertex_format.c
@@ -276,6 +276,13 @@ static int quantize(float x)
return clampi(qx, SIGNED_INT_10_MIN, SIGNED_INT_10_MAX);
}
 
+static int convert_i16(short x)
+   {
+   // 16-bit signed --> 10-bit signed
+   return x >> 6;
+   // TODO: round?
+   }
+
 PackedNormal convert_i10_v3(const float data[3])
{
PackedNormal n = { .x = quantize(data[0]), .y = quantize(data[1]), .z = 
quantize(data[2]) };
@@ -284,10 +291,6 @@ PackedNormal convert_i10_v3(const float data[3])
 
 PackedNormal convert_i10_s3(const short data[3])
{
-   PackedNormal n = {
-   .x = quantize((float)data[0] / 32767.0f),
-   .y = quantize((float)data[1] / 32767.0f),
-   .z = quantize((float)data[2] / 32767.0f)
-   };
+   PackedNormal n = { .x = convert_i16(data[0]), .y = 
convert_i16(data[1]), .z = convert_i16(data[2]) };
return n;
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [68d8618538e] blender2.8: Gawain: promote 10_10_10 to first-class vertex format

2017-05-21 Thread Mike Erwin
Commit: 68d8618538e6715e659d5be4e3f15bfbcf2db574
Author: Mike Erwin
Date:   Sun May 21 15:59:34 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB68d8618538e6715e659d5be4e3f15bfbcf2db574

Gawain: promote 10_10_10 to first-class vertex format

This format is part of OpenGL 3.3, and one of the reasons for choosing 3.3 over 
3.2.

Instead of checking #if USE_10_10_10 just use it wherever needed.

===

M   intern/gawain/gawain/vertex_format.h
M   intern/gawain/src/vertex_format.c
M   source/blender/draw/intern/draw_cache_impl_mesh.c

===

diff --git a/intern/gawain/gawain/vertex_format.h 
b/intern/gawain/gawain/vertex_format.h
index fa93abeb717..b4cce0b930f 100644
--- a/intern/gawain/gawain/vertex_format.h
+++ b/intern/gawain/gawain/vertex_format.h
@@ -18,8 +18,6 @@
 #define AVG_VERTEX_ATTRIB_NAME_LEN 11
 #define VERTEX_ATTRIB_NAMES_BUFFER_LEN ((AVG_VERTEX_ATTRIB_NAME_LEN + 1) * 
MAX_VERTEX_ATTRIBS)
 
-#define USE_10_10_10 1
-
 typedef enum {
COMP_I8,
COMP_U8,
@@ -30,9 +28,7 @@ typedef enum {
 
COMP_F32,
 
-#if USE_10_10_10
COMP_I10
-#endif
 } VertexCompType;
 
 typedef enum {
@@ -71,8 +67,6 @@ void VertexFormat_add_alias(VertexFormat*, const char* alias);
 
 // format conversion
 
-#if USE_10_10_10
-
 typedef struct {
int x : 10;
int y : 10;
@@ -82,5 +76,3 @@ typedef struct {
 
 PackedNormal convert_i10_v3(const float data[3]);
 PackedNormal convert_i10_s3(const short data[3]);
-
-#endif // USE_10_10_10
diff --git a/intern/gawain/src/vertex_format.c 
b/intern/gawain/src/vertex_format.c
index 7fea0d393e4..d2f89455cbc 100644
--- a/intern/gawain/src/vertex_format.c
+++ b/intern/gawain/src/vertex_format.c
@@ -64,9 +64,7 @@ static GLenum convert_comp_type_to_gl(VertexCompType type)
 
[COMP_F32] = GL_FLOAT,
 
-   #if USE_10_10_10
[COMP_I10] = GL_INT_2_10_10_10_REV
-   #endif
};
return table[type];
}
@@ -83,20 +81,16 @@ static unsigned comp_sz(VertexCompType type)
 
 static unsigned attrib_sz(const Attrib *a)
{
-#if USE_10_10_10
if (a->comp_type == COMP_I10)
return 4; // always packed as 10_10_10_2
-#endif
 
return a->comp_ct * comp_sz(a->comp_type);
}
 
 static unsigned attrib_align(const Attrib *a)
{
-#if USE_10_10_10
if (a->comp_type == COMP_I10)
return 4; // always packed as 10_10_10_2
-#endif
 
unsigned c = comp_sz(a->comp_type);
if (a->comp_ct == 3 && c <= 2)
@@ -156,14 +150,12 @@ unsigned VertexFormat_add_attrib(VertexFormat* format, 
const char* name, VertexC
// float type can only kept as float
assert(fetch_mode == KEEP_FLOAT);
break;
- #if USE_10_10_10
case COMP_I10:
// 10_10_10 format intended for normals (xyz) or colors 
(rgb)
// extra component packed.w can be manually set to { 
-2, -1, 0, 1 }
assert(comp_ct == 3 || comp_ct == 4);
assert(fetch_mode == NORMALIZE_INT_TO_FLOAT); // not 
strictly required, may relax later
break;
- #endif
default:
// integer types can be kept as int or 
converted/normalized to float
assert(fetch_mode != KEEP_FLOAT);
@@ -177,11 +169,7 @@ unsigned VertexFormat_add_attrib(VertexFormat* format, 
const char* name, VertexC
attrib->name[attrib->name_ct++] = copy_attrib_name(format, name);
attrib->comp_type = comp_type;
attrib->gl_comp_type = convert_comp_type_to_gl(comp_type);
-#if USE_10_10_10
attrib->comp_ct = (comp_type == COMP_I10) ? 4 : comp_ct; // system 
needs 10_10_10_2 to be 4 or BGRA
-#else
-   attrib->comp_ct = comp_ct;
-#endif
attrib->sz = attrib_sz(attrib);
attrib->offset = 0; // offsets & stride are calculated later (during 
pack)
attrib->fetch_mode = fetch_mode;
@@ -262,8 +250,6 @@ void VertexFormat_pack(VertexFormat* format)
}
 
 
-#if USE_10_10_10
-
 // OpenGL ES packs in a different order as desktop GL but component conversion 
is the same.
 // Of the code here, only struct PackedNormal needs to change.
 
@@ -305,5 +291,3 @@ PackedNormal convert_i10_s3(const short data[3])
};
return n;
}
-
-#endif // USE_10_10_10
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c 
b/source/blender/draw/intern/draw_cache_impl_mesh.c
index a9299acb472..c0fe58ec5d9 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -1367,15 +1367,11 @@ static void add_overlay_tri(
const short *svnor = mesh_render_data_vert_nor(rdata, 
tri_vert_idx[i]);
   

[Bf-blender-cvs] [ea31c55b08e] blender2.8: Gawain: cleanup code formatting

2017-05-21 Thread Mike Erwin
Commit: ea31c55b08e0add843f56af0a62d030fd25606f2
Author: Mike Erwin
Date:   Sun May 21 17:53:16 2017 -0400
Branches: blender2.8
https://developer.blender.org/rBea31c55b08e0add843f56af0a62d030fd25606f2

Gawain: cleanup code formatting

===

M   intern/gawain/src/imm_util.c
M   intern/gawain/src/immediate.c

===

diff --git a/intern/gawain/src/imm_util.c b/intern/gawain/src/imm_util.c
index 74caeb6fd3a..de50ca96907 100644
--- a/intern/gawain/src/imm_util.c
+++ b/intern/gawain/src/imm_util.c
@@ -14,33 +14,33 @@
 
 
 void immRectf(unsigned pos, float x1, float y1, float x2, float y2)
-{
+   {
immBegin(PRIM_TRIANGLE_FAN, 4);
immVertex2f(pos, x1, y1);
immVertex2f(pos, x2, y1);
immVertex2f(pos, x2, y2);
immVertex2f(pos, x1, y2);
immEnd();
-}
+   }
 
 void immRecti(unsigned pos, int x1, int y1, int x2, int y2)
-{
+   {
immBegin(PRIM_TRIANGLE_FAN, 4);
immVertex2i(pos, x1, y1);
immVertex2i(pos, x2, y1);
immVertex2i(pos, x2, y2);
immVertex2i(pos, x1, y2);
immEnd();
-}
+   }
 
 #if 0 // more complete version in case we want that
 void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
-{
+   {
VertexFormat *format = immVertexFormat();
unsigned pos = add_attrib(format, "pos", COMP_I32, 2, 
CONVERT_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
immRecti(pos, x1, y1, x2, y2);
immUnbindProgram();
-}
+   }
 #endif
diff --git a/intern/gawain/src/immediate.c b/intern/gawain/src/immediate.c
index 7c3b0e11e92..8b6f0fdbff5 100644
--- a/intern/gawain/src/immediate.c
+++ b/intern/gawain/src/immediate.c
@@ -749,12 +749,10 @@ void immVertex2iv(unsigned attrib_id, const int data[2])
 #define GET_UNIFORM const ShaderInput* uniform = 
ShaderInterface_uniform(imm.shader_interface, name);
   #endif
 #else
-/* NOTE: It is possible to have uniform fully optimized out from the shader.
- * In this case we can't assert failure or allow NULL-pointer dereference.
- *
- * TODO(sergey): How can we detect existing-but-optimized-out uniform but still
- * catch typos in uniform names passed to immUniform*() functions?
- */
+   // NOTE: It is possible to have uniform fully optimized out from the 
shader.
+   //   In this case we can't assert failure or allow NULL-pointer 
dereference.
+   // TODO(sergey): How can we detect existing-but-optimized-out uniform 
but still
+   //   catch typos in uniform names passed to immUniform*() 
functions?
   #define GET_UNIFORM const ShaderInput* uniform = 
ShaderInterface_uniform(imm.shader_interface, name); if (uniform == NULL) 
return;
 #endif
 
@@ -765,16 +763,16 @@ void immUniform1f(const char* name, float x)
}
 
 void immUniform2f(const char* name, float x, float y)
-{
+   {
GET_UNIFORM
glUniform2f(uniform->location, x, y);
-}
+   }
 
 void immUniform2fv(const char* name, const float data[2])
-{
+   {
GET_UNIFORM
glUniform2fv(uniform->location, 1, data);
-}
+   }
 
 void immUniform3f(const char* name, float x, float y, float z)
{

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [23035cf46fb] blender2.8: Gawain: remove GLenum from IndexType API

2017-05-21 Thread Mike Erwin
Commit: 23035cf46fb4dd6a0bf7e688b0f15128030c77d1
Author: Mike Erwin
Date:   Sun May 21 18:25:30 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB23035cf46fb4dd6a0bf7e688b0f15128030c77d1

Gawain: remove GLenum from IndexType API

Goal is to make most of the API independent of OpenGL, Vulkan, any other 
backend.

Able to remove default case from ElementList_size because IndexType only covers 
index types. Not that and *everything else* like GLenum.

===

M   intern/gawain/gawain/element.h
M   intern/gawain/src/batch.c
M   intern/gawain/src/element.c

===

diff --git a/intern/gawain/gawain/element.h b/intern/gawain/gawain/element.h
index fde395ce898..0e2ece1d2f1 100644
--- a/intern/gawain/gawain/element.h
+++ b/intern/gawain/gawain/element.h
@@ -16,15 +16,16 @@
 #define TRACK_INDEX_RANGE 1
 
 typedef enum {
-   INDEX_U8 = GL_UNSIGNED_BYTE, // GL has this, Vulkan does not
-   INDEX_U16 = GL_UNSIGNED_SHORT,
-   INDEX_U32 = GL_UNSIGNED_INT
+   INDEX_U8, // GL has this, Vulkan does not
+   INDEX_U16,
+   INDEX_U32
 } IndexType;
 
 typedef struct {
unsigned index_ct;
 #if TRACK_INDEX_RANGE
IndexType index_type;
+   GLenum gl_index_type;
unsigned min_index;
unsigned max_index;
unsigned base_index;
diff --git a/intern/gawain/src/batch.c b/intern/gawain/src/batch.c
index 5067a567f55..059de41ab3e 100644
--- a/intern/gawain/src/batch.c
+++ b/intern/gawain/src/batch.c
@@ -273,9 +273,9 @@ void Batch_draw(Batch* batch)
 
 #if TRACK_INDEX_RANGE
if (el->base_index)
-   glDrawRangeElementsBaseVertex(batch->gl_prim_type, 
el->min_index, el->max_index, el->index_ct, el->index_type, 0, el->base_index);
+   glDrawRangeElementsBaseVertex(batch->gl_prim_type, 
el->min_index, el->max_index, el->index_ct, el->gl_index_type, 0, 
el->base_index);
else
-   glDrawRangeElements(batch->gl_prim_type, el->min_index, 
el->max_index, el->index_ct, el->index_type, 0);
+   glDrawRangeElements(batch->gl_prim_type, el->min_index, 
el->max_index, el->index_ct, el->gl_index_type, 0);
 #else
glDrawElements(batch->gl_prim_type, el->index_ct, 
GL_UNSIGNED_INT, 0);
 #endif
@@ -310,9 +310,9 @@ void Batch_draw_stupid(Batch* batch)
 
 #if TRACK_INDEX_RANGE
if (el->base_index)
-   glDrawRangeElementsBaseVertex(batch->gl_prim_type, 
el->min_index, el->max_index, el->index_ct, el->index_type, 0, el->base_index);
+   glDrawRangeElementsBaseVertex(batch->gl_prim_type, 
el->min_index, el->max_index, el->index_ct, el->gl_index_type, 0, 
el->base_index);
else
-   glDrawRangeElements(batch->gl_prim_type, el->min_index, 
el->max_index, el->index_ct, el->index_type, 0);
+   glDrawRangeElements(batch->gl_prim_type, el->min_index, 
el->max_index, el->index_ct, el->gl_index_type, 0);
 #else
glDrawElements(batch->gl_prim_type, el->index_ct, 
GL_UNSIGNED_INT, 0);
 #endif
diff --git a/intern/gawain/src/element.c b/intern/gawain/src/element.c
index f27f3a6c43a..1346be024e3 100644
--- a/intern/gawain/src/element.c
+++ b/intern/gawain/src/element.c
@@ -15,6 +15,16 @@
 
 #define KEEP_SINGLE_COPY 1
 
+static GLenum convert_index_type_to_gl(IndexType type)
+   {
+   static const GLenum table[] = {
+   [INDEX_U8] = GL_UNSIGNED_BYTE, // GL has this, Vulkan does not
+   [INDEX_U16] = GL_UNSIGNED_SHORT,
+   [INDEX_U32] = GL_UNSIGNED_INT
+   };
+   return table[type];
+   }
+
 unsigned ElementList_size(const ElementList* elem)
{
 #if TRACK_INDEX_RANGE
@@ -23,11 +33,6 @@ unsigned ElementList_size(const ElementList* elem)
case INDEX_U8: return elem->index_ct * sizeof(GLubyte);
case INDEX_U16: return elem->index_ct * sizeof(GLushort);
case INDEX_U32: return elem->index_ct * sizeof(GLuint);
-   default:
-   #if TRUST_NO_ONE
-   assert(false);
-   #endif
-   return 0;
}
 
 #else
@@ -252,6 +257,8 @@ void ElementList_build_in_place(ElementListBuilder* 
builder, ElementList* elem)
 
elem->data = builder->data;
}
+
+   elem->gl_index_type = convert_index_type_to_gl(elem->index_type);
 #else
if (builder->index_ct < builder->max_index_ct)
{

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [90a1d491800] blender2.8: Gawain: drop support for APPLE_vertex_array_object

2017-05-21 Thread Mike Erwin
Commit: 90a1d491800cf1021d158973813265e9da71dbdd
Author: Mike Erwin
Date:   Sun May 21 16:48:54 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB90a1d491800cf1021d158973813265e9da71dbdd

Gawain: drop support for APPLE_vertex_array_object

Recent versions of OpenGL support VAOs natively.

Part of T49012

===

M   intern/gawain/gawain/common.h

===

diff --git a/intern/gawain/gawain/common.h b/intern/gawain/gawain/common.h
index 71b284ba0ad..1c8153e750e 100644
--- a/intern/gawain/gawain/common.h
+++ b/intern/gawain/gawain/common.h
@@ -31,14 +31,3 @@
 #else
   #define APPLE_LEGACY 0
 #endif
-
-#if APPLE_LEGACY
-  #undef glGenVertexArrays
-  #define glGenVertexArrays glGenVertexArraysAPPLE
-
-  #undef glDeleteVertexArrays
-  #define glDeleteVertexArrays glDeleteVertexArraysAPPLE
-
-  #undef glBindVertexArray
-  #define glBindVertexArray glBindVertexArrayAPPLE
-#endif

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cad9f2fd177] greasepencil-object: Fix UI panel problem in properties tab

2017-05-21 Thread Antonio Vazquez
Commit: cad9f2fd177736de6395f890dd40851b4c71eb88
Author: Antonio Vazquez
Date:   Sun May 21 17:44:29 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBcad9f2fd177736de6395f890dd40851b4c71eb88

Fix UI panel problem in properties tab

===

M   release/scripts/startup/bl_ui/properties_grease_pencil_common.py

===

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py 
b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index da7db65d9cd..b2f24109afc 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -884,7 +884,7 @@ class GreasePencilDataPanel:
 if context.gpencil_data is None:
 return False
 
-if context.space_data.type == 'VIEW_3D':
+if context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
 if ts.grease_pencil_source == 'SCENE':
 if context.space_data.context != 'SCENE':
 return False

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e545a50e2a2] greasepencil-object: Fix segment fault when using eraser

2017-05-21 Thread Antonio Vazquez
Commit: e545a50e2a2d23bf14bcb7e57db6b151f669a8eb
Author: Antonio Vazquez
Date:   Sun May 21 19:40:08 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBe545a50e2a2d23bf14bcb7e57db6b151f669a8eb

Fix segment fault when using eraser

The cache must be marked as dirty after any change operation, and the eraser 
change the strokes

===

M   source/blender/editors/gpencil/gpencil_edit.c
M   source/blender/editors/gpencil/gpencil_paint.c

===

diff --git a/source/blender/editors/gpencil/gpencil_edit.c 
b/source/blender/editors/gpencil/gpencil_edit.c
index a74d1963cb2..e7c780c2535 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -357,7 +357,7 @@ void ED_gpencil_strokes_copybuf_free(void)

if (gps->points)MEM_freeN(gps->points);
if (gps->triangles) MEM_freeN(gps->triangles);
-   
+
BLI_freelinkN(_strokes_copypastebuf, gps);
}

@@ -931,7 +931,7 @@ static int gp_delete_selected_strokes(bContext *C)
if (gps->points) MEM_freeN(gps->points);
if (gps->triangles) MEM_freeN(gps->triangles);
BLI_freelinkN(>strokes, gps);
-   
+
changed = true;
}
}
@@ -999,6 +999,7 @@ static int gp_dissolve_selected_points(bContext *C)
MEM_freeN(gps->triangles);
}
BLI_freelinkN(>strokes, gps);
+   BKE_gpencil_batch_cache_dirty(gpd, 0);
}
else {
/* just copy all unselected into a 
smaller buffer */
@@ -1201,7 +1202,7 @@ static int gp_delete_selected_points(bContext *C)

/* delete unwanted points by splitting stroke 
into several smaller ones */
gp_stroke_delete_tagged_points(gpf, gps, gpsn, 
GP_SPOINT_SELECT);
-   
+
changed = true;
}
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c 
b/source/blender/editors/gpencil/gpencil_paint.c
index c8dbf108def..409e0175f1a 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1141,6 +1141,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
if (gps->triangles)
MEM_freeN(gps->triangles);
BLI_freelinkN(>strokes, gps);
+   BKE_gpencil_batch_cache_dirty(p->gpd, 0);
}
else if (gps->totpoints == 1) {
/* only process if it hasn't been masked out... */
@@ -1158,6 +1159,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
if (gps->triangles)
MEM_freeN(gps->triangles);
BLI_freelinkN(>strokes, gps);
+   BKE_gpencil_batch_cache_dirty(p->gpd, 
0);
}
}
}
@@ -1245,6 +1247,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
if (do_cull) {
gp_stroke_delete_tagged_points(gpf, gps, gps->next, 
GP_SPOINT_TAG);
}
+   BKE_gpencil_batch_cache_dirty(p->gpd, 0);
}
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f3d9f0c779c] master: [msvc] Use debug nunmpy archive for debug builds

2017-05-21 Thread lazydodo
Commit: f3d9f0c779ca788d5c1c4755bb211b4fb3a26310
Author: lazydodo
Date:   Sun May 21 09:31:55 2017 -0600
Branches: master
https://developer.blender.org/rBf3d9f0c779ca788d5c1c4755bb211b4fb3a26310

[msvc] Use debug nunmpy archive for debug builds

===

M   source/creator/CMakeLists.txt

===

diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index eea45545949..504d0de9145 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -721,9 +721,9 @@ elseif(WIN32)
add_custom_command(
OUTPUT 
${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
COMMAND ${CMAKE_COMMAND} -E
-   tar xzvf 
"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_${PYTHON_NUMPY_VERSION}.tar.gz"
+   tar xzvf 
"${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_${PYTHON_NUMPY_VERSION}$<$:d>.tar.gz"
DEPENDS
-   
${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_${PYTHON_NUMPY_VERSION}.tar.gz
+   
${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_${PYTHON_NUMPY_VERSION}$<$:d>.tar.gz

${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
WORKING_DIRECTORY 
${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [32a8f3551f6] greasepencil-object: Cleanup: More unused include files, reorganization and name changes

2017-05-21 Thread Antonio Vazquez
Commit: 32a8f3551f6148f45d5688bdfaf410bdf2fa3f53
Author: Antonio Vazquez
Date:   Sun May 21 17:29:58 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB32a8f3551f6148f45d5688bdfaf410bdf2fa3f53

Cleanup: More unused include files, reorganization and name changes

===

M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 290f6773c45..6f0ac02de65 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -38,7 +38,6 @@
  /* If builtin shaders are needed */
 #include "GPU_shader.h"
 #include "GPU_texture.h"
-#include "GPU_glew.h"
 
 #include "IMB_imbuf_types.h"
 
@@ -461,7 +460,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, 
GPENCIL_e_data *e_dat
}
 
/* limit the number of shading groups */
-   if (stl->storage->pal_id >= MAX_GPENCIL_MAT) {
+   if (stl->storage->pal_id >= GPENCIL_MAX_SHGROUPS) {
continue;
}
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 18e5f9293d4..ae58e79ce23 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -119,8 +119,8 @@ static void GPENCIL_cache_init(void *vedata)
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | 
DRW_STATE_DEPTH_LESS;
psl->stroke_pass = DRW_pass_create("Gpencil Stroke Pass", 
state);
stl->storage->pal_id = 0;
-   memset(stl->storage->shgrps_fill, 0, sizeof(DRWShadingGroup *) 
* MAX_GPENCIL_MAT);
-   memset(stl->storage->shgrps_stroke, 0, sizeof(DRWShadingGroup 
*) * MAX_GPENCIL_MAT);
+   memset(stl->storage->shgrps_fill, 0, sizeof(DRWShadingGroup *) 
* GPENCIL_MAX_SHGROUPS);
+   memset(stl->storage->shgrps_stroke, 0, sizeof(DRWShadingGroup 
*) * GPENCIL_MAX_SHGROUPS);
stl->g_data->shgrps_point_volumetric = 
DRW_gpencil_shgroup_point_volumetric_create(psl->stroke_pass, 
e_data.gpencil_volumetric_sh);
 
state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 96053b81a36..587161eee84 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -28,13 +28,12 @@
 
 #include "GPU_batch.h"
 
-#define MAX_GPENCIL_MAT 65536
+ /* TODO: these could be system parameter in userprefs screen */
+#define GPENCIL_CACHE_BLOCK_SIZE 8 
+#define GPENCIL_MAX_SHGROUPS 65536
 #define GPENCIL_MIN_BATCH_SLOTS_CHUNK 8
 
  /* *** OBJECTS CACHE *** */
- /* TODO: this could be a system parameter in userprefs screen */
-#define GPENCIL_CACHE_BLOCK_SIZE 8 
-
  /* used to sort gpencil objects */
 typedef struct tGPencilObjectCache {
Object *ob;
@@ -44,36 +43,32 @@ typedef struct tGPencilObjectCache {
  /* *** LISTS *** */
 typedef struct GPENCIL_Storage {
int pal_id; /* total elements */
-   int t_mix[MAX_GPENCIL_MAT];
-   int t_flip[MAX_GPENCIL_MAT];
-   int t_clamp[MAX_GPENCIL_MAT];
-   int fill_style[MAX_GPENCIL_MAT];
-   DRWShadingGroup *shgrps_fill[MAX_GPENCIL_MAT];
-   DRWShadingGroup *shgrps_stroke[MAX_GPENCIL_MAT];
+   int t_mix[GPENCIL_MAX_SHGROUPS];
+   int t_flip[GPENCIL_MAX_SHGROUPS];
+   int t_clamp[GPENCIL_MAX_SHGROUPS];
+   int fill_style[GPENCIL_MAX_SHGROUPS];
+   DRWShadingGroup *shgrps_fill[GPENCIL_MAX_SHGROUPS];
+   DRWShadingGroup *shgrps_stroke[GPENCIL_MAX_SHGROUPS];
float unit_matrix[4][4];
int is_persp;   /* rv3d->is_persp (1-yes) */
int xray;
 } GPENCIL_Storage;
 
-/* keep it under MAX_STORAGE */
 typedef struct GPENCIL_StorageList {
struct GPENCIL_Storage *storage;
struct g_data *g_data;
 } GPENCIL_StorageList;
 
-/* keep it under MAX_PASSES */
 typedef struct GPENCIL_PassList {
struct DRWPass *stroke_pass;
struct DRWPass *edit_pass;
struct DRWPass *drawing_pass;
 } GPENCIL_PassList;
 
-/* keep it under MAX_BUFFERS */
 typedef struct GPENCIL_FramebufferList {
struct GPUFrameBuffer *fb;
 } GPENCIL_FramebufferList;
 
-/* keep it under MAX_TEXTURES */
 typedef struct GPENCIL_TextureList {
struct GPUTexture *texture;
 } GPENCIL_TextureList;

___

[Bf-blender-cvs] [7af2a45a38b] greasepencil-object: Cleanup: Remove unused include files

2017-05-21 Thread Antonio Vazquez
Commit: 7af2a45a38b44e8ce73e69a80e006dc16ab0b4b1
Author: Antonio Vazquez
Date:   Sun May 21 17:19:55 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB7af2a45a38b44e8ce73e69a80e006dc16ab0b4b1

Cleanup: Remove unused include files

===

M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 4b05799778c..290f6773c45 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -26,7 +26,6 @@
 #include "DRW_engine.h"
 #include "DRW_render.h"
 
-#include "BKE_main.h"
 #include "BKE_global.h"
 #include "BKE_gpencil.h"
 #include "BKE_image.h"
@@ -41,13 +40,9 @@
 #include "GPU_texture.h"
 #include "GPU_glew.h"
 
-#include "draw_common.h"
-
-#include "draw_mode_engines.h"
-#include "gpencil_engine.h"
-
 #include "IMB_imbuf_types.h"
 
+#include "gpencil_engine.h"
 
 /* allocate cache to store GP objects */
 tGPencilObjectCache *gpencil_object_cache_allocate(tGPencilObjectCache *cache, 
int *gp_cache_size, int *gp_cache_used)
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index bc5c2d10447..18e5f9293d4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -26,27 +26,13 @@
 #include "DRW_engine.h"
 #include "DRW_render.h"
 
-#include "BKE_main.h"
 #include "BKE_global.h"
-#include "BKE_gpencil.h"
-#include "BKE_image.h"
-#include "ED_gpencil.h"
 
 #include "DNA_gpencil_types.h"
 #include "DNA_view3d_types.h"
 
- /* If builtin shaders are needed */
-#include "GPU_shader.h"
-#include "GPU_texture.h"
-#include "GPU_glew.h"
-
-#include "draw_common.h"
-
-#include "draw_mode_engines.h"
 #include "gpencil_engine.h"
 
-#include "IMB_imbuf_types.h"
-
 extern char datatoc_gpencil_fill_vert_glsl[];
 extern char datatoc_gpencil_fill_frag_glsl[];
 extern char datatoc_gpencil_stroke_vert_glsl[];

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ecd4984278b] greasepencil-object: Merge branch 'blender2.8' into greasepencil-object

2017-05-21 Thread Antonio Vazquez
Commit: ecd4984278be41c3194395d4b673d5212dfb596d
Author: Antonio Vazquez
Date:   Sun May 21 16:32:28 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBecd4984278be41c3194395d4b673d5212dfb596d

Merge branch 'blender2.8' into greasepencil-object

===



===

diff --cc source/blender/draw/modes/object_mode.c
index d594635d5ea,89e085423d4..d2710b607ca
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@@ -1366,11 -1506,8 +1521,11 @@@ static void OBJECT_cache_populate(void 
DRW_shgroup_camera(stl, ob, sl);
break;
case OB_EMPTY:
-   DRW_shgroup_empty(stl, ob, sl);
+   DRW_shgroup_empty(stl, psl, ob, sl);
break;
 +  case OB_GPENCIL:
 +  DRW_shgroup_gpencil(stl, ob, sl);
 +  break;
case OB_SPEAKER:
DRW_shgroup_speaker(stl, ob, sl);
break;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8c0f4aa5571] greasepencil-object: Cleanup: Create several separated functions

2017-05-21 Thread Antonio Vazquez
Commit: 8c0f4aa55715c04400db9515d5aca4964c6a0073
Author: Antonio Vazquez
Date:   Sat May 20 20:27:40 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB8c0f4aa55715c04400db9515d5aca4964c6a0073

Cleanup: Create several separated functions

===

M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 09e150338d4..bb1e8933a67 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -191,7 +191,7 @@ static DRWShadingGroup 
*DRW_gpencil_shgroup_fill_create(GPENCIL_Data *vedata, DR
stl->storage->t_flip[id] = palcolor->flag & PAC_COLOR_FLIP_FILL ? 1 : 0;
DRW_shgroup_uniform_int(grp, "t_flip", >storage->t_flip[id], 1);
 
-   DRW_shgroup_uniform_int(grp, "xraymode", >xray_mode, 1);
+   DRW_shgroup_uniform_int(grp, "xraymode", (const int *) >xray_mode, 
1);
 
/* image texture */
if ((palcolor->fill_style == FILL_STYLE_TEXTURE) || (palcolor->flag & 
PAC_COLOR_TEX_MIX)) {
@@ -250,7 +250,7 @@ DRWShadingGroup 
*DRW_gpencil_shgroup_stroke_create(GPENCIL_Data *vedata, DRWPass
DRW_shgroup_uniform_int(grp, "is_persp", >storage->is_persp, 1);
 
if (gpd) {
-   DRW_shgroup_uniform_int(grp, "xraymode", >xray_mode, 1);
+   DRW_shgroup_uniform_int(grp, "xraymode", (const int *) 
>xray_mode, 1);
}
else {
/* for drawing always on front */
@@ -290,6 +290,98 @@ static int DRW_gpencil_shgroup_find(GPENCIL_Storage 
*storage, PaletteColor *palc
return -1;
 }
 
+/* add fill shading group to pass */
+static void gpencil_add_fill_shgroup(GpencilBatchCache *cache, DRWShadingGroup 
*fillgrp, 
+   bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, 
+   const float tintcolor[4], const bool onion, const bool custonion)
+{
+   if (gps->totpoints >= 3) {
+   float tfill[4];
+   /* set color using palette, tint color and opacity */
+   interp_v3_v3v3(tfill, gps->palcolor->fill, tintcolor, 
tintcolor[3]);
+   tfill[3] = gps->palcolor->fill[3] * gpl->opacity;
+   if ((tfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) || 
(gps->palcolor->fill_style > 0)) {
+   const float *color;
+   if (!onion) {
+   color = tfill;
+   }
+   else {
+   if (custonion) {
+   color = tintcolor;
+   }
+   else {
+   ARRAY_SET_ITEMS(tfill, 
UNPACK3(gps->palcolor->fill), tintcolor[3]);
+   color = tfill;
+   }
+   }
+   if (cache->is_dirty) {
+   gpencil_batch_cache_check_free_slots(gpd);
+   cache->batch_fill[cache->cache_idx] = 
DRW_gpencil_get_fill_geom(gps, color);
+   }
+   DRW_shgroup_call_add(fillgrp, 
cache->batch_fill[cache->cache_idx], gpf->viewmatrix);
+   }
+   }
+}
+
+/* add stroke shading group to pass */
+static void gpencil_add_stroke_shgroup(GPENCIL_StorageList *stl, 
GpencilBatchCache *cache, DRWShadingGroup *strokegrp,
+   bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, 
+   const float opacity, const float tintcolor[4], const bool onion, const 
bool custonion)
+{
+   float tcolor[4];
+   float ink[4];
+
+   /* set color using palette, tint color and opacity */
+   if (!onion) {
+   interp_v3_v3v3(tcolor, gps->palcolor->rgb, tintcolor, 
tintcolor[3]);
+   tcolor[3] = gps->palcolor->rgb[3] * opacity;
+   copy_v4_v4(ink, tcolor);
+   }
+   else {
+   if (custonion) {
+   copy_v4_v4(ink, tintcolor);
+   }
+   else {
+   ARRAY_SET_ITEMS(tcolor, gps->palcolor->rgb[0], 
gps->palcolor->rgb[1], gps->palcolor->rgb[2], opacity);
+   copy_v4_v4(ink, tcolor);
+   }
+   }
+   short sthickness = gps->thickness + gpl->thickness;
+   if (sthickness > 0) {
+   if (gps->totpoints > 1) {
+   if (cache->is_dirty) {
+   gpencil_batch_cache_check_free_slots(gpd);
+   cache->batch_stroke[cache->cache_idx] = 
DRW_gpencil_get_stroke_geom(gpf, gps, sthickness, ink);
+   }
+   

[Bf-blender-cvs] [82e3302f448] greasepencil-object: Create a cache to drawing objects

2017-05-21 Thread Antonio Vazquez
Commit: 82e3302f448a153011259a776ed38d7ff4f3b6e3
Author: Antonio Vazquez
Date:   Sun May 21 16:28:56 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB82e3302f448a153011259a776ed38d7ff4f3b6e3

Create a cache to drawing objects

Due speciall requirements for 2D drawing, the GP objects must be drawn after be 
sorteed by zdepth value.

We cannot use a simple GPU zdepth because this override the current 
layer/strokes order and the artists need to keep these controls as primary 
sorting method instead of GPU zdepth.

===

M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 38b2bf0bbe6..4b05799778c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -31,6 +31,7 @@
 #include "BKE_gpencil.h"
 #include "BKE_image.h"
 #include "ED_gpencil.h"
+#include "ED_view3d.h"
 
 #include "DNA_gpencil_types.h"
 #include "DNA_view3d_types.h"
@@ -48,6 +49,76 @@
 #include "IMB_imbuf_types.h"
 
 
+/* allocate cache to store GP objects */
+tGPencilObjectCache *gpencil_object_cache_allocate(tGPencilObjectCache *cache, 
int *gp_cache_size, int *gp_cache_used)
+{
+   tGPencilObjectCache *p = NULL;
+
+   /* By default a cache is created with one block with a predefined 
number of free slots,
+   if the size is not enough, the cache is reallocated adding a new block 
of free slots.
+   This is done in order to keep cache small */
+   if (*gp_cache_used + 1 > *gp_cache_size) {
+   if ((*gp_cache_size == 0) || (cache == NULL)) {
+   p = MEM_callocN(sizeof(struct tGPencilObjectCache) * 
GP_CACHE_BLOCK_SIZE, "tGPencilObjectCache");
+   *gp_cache_size = GP_CACHE_BLOCK_SIZE;
+   }
+   else {
+   *gp_cache_size += GP_CACHE_BLOCK_SIZE;
+   p = MEM_recallocN(cache, sizeof(struct 
tGPencilObjectCache) * *gp_cache_size);
+   }
+   cache = p;
+   }
+   return cache;
+}
+
+/* add a gpencil object to cache to defer drawing */
+void gpencil_object_cache_add(tGPencilObjectCache *cache, RegionView3D *rv3d, 
Object *ob, int *gp_cache_used)
+{
+   /* save object */
+   cache[*gp_cache_used].ob = ob;
+
+   /* calculate zdepth from point of view */
+   float zdepth = 0.0;
+   if (rv3d->is_persp) {
+   zdepth = ED_view3d_calc_zfac(rv3d, ob->loc, NULL);
+   }
+   else {
+   zdepth = -dot_v3v3(rv3d->viewinv[2], ob->loc);
+   }
+   cache[*gp_cache_used].zdepth = zdepth;
+
+   /* increase slots used in cache */
+   ++*gp_cache_used;
+}
+
+/* helper function to sort gpencil objects using qsort */
+static int gpencil_object_cache_compare_zdepth(const void *a1, const void *a2)
+{
+   const tGPencilObjectCache *ps1 = a1, *ps2 = a2;
+
+   if (ps1->zdepth > ps2->zdepth) return 1;
+   else if (ps1->zdepth < ps2->zdepth) return -1;
+
+   return 0;
+}
+
+/* draw objects in cache from back to from */
+void gpencil_object_cache_draw(GPENCIL_e_data *e_data, GPENCIL_Data *vedata, 
ToolSettings *ts,
+   Scene *scene, tGPencilObjectCache *cache, int gp_cache_used)
+{
+   if (gp_cache_used > 0) {
+   /* sort by zdepth */
+   qsort(cache, gp_cache_used, sizeof(tGPencilObjectCache), 
gpencil_object_cache_compare_zdepth);
+   /* inverse loop to draw from back to front */
+   for (int i = gp_cache_used; i > 0; --i) {
+   Object *ob = cache[i - 1].ob;
+   DRW_gpencil_populate_datablock(e_data, vedata, scene, 
ob, ts, ob->gpd);
+   }
+   }
+   /* free memory */
+   MEM_SAFE_FREE(cache);
+}
+
 /* verify if cache is valid */
 static bool gpencil_batch_cache_valid(bGPdata *gpd, int cfra)
 {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 1a35acb8bfb..bc5c2d10447 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -124,6 +124,11 @@ static void GPENCIL_cache_init(void *vedata)
}
 
{
+   /* init gp objects cache */
+   stl->g_data->gp_cache_used = 0;
+   stl->g_data->gp_cache_size = 0;
+   stl->g_data->gp_object_cache = NULL;
+
/* Stroke pass */
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | 
DRW_STATE_DEPTH_LESS;

[Bf-blender-cvs] [cccd0cfc12a] greasepencil-object: Disable zdepth write for strokes

2017-05-21 Thread Antonio Vazquez
Commit: cccd0cfc12af5111a36b890aa0501cf8ad1fae86
Author: Antonio Vazquez
Date:   Sun May 21 13:10:50 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBcccd0cfc12af5111a36b890aa0501cf8ad1fae86

Disable zdepth write for strokes

After some analysis, the strokes must work without affect the zdepth buffer or 
the layer system will not work.

The 2D artist agree that layer system must be the main zdepth order and not the 
GPU checking.

===

M   source/blender/draw/engines/gpencil/gpencil_engine.c

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 0e35540bb14..3eec7b5db71 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -125,7 +125,7 @@ static void GPENCIL_cache_init(void *vedata)
 
{
/* Stroke pass */
-   DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | 
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+   DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | 
DRW_STATE_DEPTH_LESS;
psl->stroke_pass = DRW_pass_create("Gpencil Stroke Pass", 
state);
stl->storage->pal_id = 0;
memset(stl->storage->shgrps_fill, 0, sizeof(DRWShadingGroup *) 
* MAX_GPENCIL_MAT);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [62a8d9fb12c] greasepencil-object: Create a shading group by stroke

2017-05-21 Thread Antonio Vazquez
Commit: 62a8d9fb12c10ea16f1b345883f62f82322e3282
Author: Antonio Vazquez
Date:   Sun May 21 13:20:28 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB62a8d9fb12c10ea16f1b345883f62f82322e3282

Create a shading group by stroke

As the drawing order is very important in 2D, each stroke must use its own 
shading group and don't share with others or the drawing order is missing and 
the layer system does not work.

===

M   source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index bb1e8933a67..38b2bf0bbe6 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -277,19 +277,6 @@ DRWShadingGroup 
*DRW_gpencil_shgroup_drawing_fill_create(DRWPass *pass, GPUShade
return grp;
 }
 
-/* find shader group */
-static int DRW_gpencil_shgroup_find(GPENCIL_Storage *storage, PaletteColor 
*palcolor)
-{
-   for (int i = 0; i < storage->pal_id; ++i) {
-   if (storage->materials[i] == palcolor) {
-   return i;
-   }
-   }
-
-   /* not found */
-   return -1;
-}
-
 /* add fill shading group to pass */
 static void gpencil_add_fill_shgroup(GpencilBatchCache *cache, DRWShadingGroup 
*fillgrp, 
bGPdata *gpd, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, 
@@ -406,16 +393,17 @@ static void gpencil_draw_strokes(GpencilBatchCache 
*cache, GPENCIL_e_data *e_dat
if (gpencil_can_draw_stroke(rv3d, gpf, gps) == false) {
continue;
}
-   /* try to find shader group or create a new one */
+
+   /* limit the number of shading groups */
+   if (stl->storage->pal_id >= MAX_GPENCIL_MAT) {
+   continue;
+   }
+
if (gps->totpoints > 1) {
-   int id = DRW_gpencil_shgroup_find(stl->storage, 
gps->palcolor);
-   if (id == -1) {
-   id = stl->storage->pal_id;
-   stl->storage->materials[id] = gps->palcolor;
-   stl->storage->shgrps_fill[id] = 
DRW_gpencil_shgroup_fill_create(vedata, psl->stroke_pass, 
e_data->gpencil_fill_sh, gpd, gps->palcolor, id);
-   stl->storage->shgrps_stroke[id] = 
DRW_gpencil_shgroup_stroke_create(vedata, psl->stroke_pass, 
e_data->gpencil_stroke_sh, gpd);
-   ++stl->storage->pal_id;
-   }
+   int id = stl->storage->pal_id;
+   stl->storage->shgrps_fill[id] = 
DRW_gpencil_shgroup_fill_create(vedata, psl->stroke_pass, 
e_data->gpencil_fill_sh, gpd, gps->palcolor, id);
+   stl->storage->shgrps_stroke[id] = 
DRW_gpencil_shgroup_stroke_create(vedata, psl->stroke_pass, 
e_data->gpencil_stroke_sh, gpd);
+   ++stl->storage->pal_id;
 
fillgrp = stl->storage->shgrps_fill[id];
strokegrp = stl->storage->shgrps_stroke[id];
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 3eec7b5db71..1a35acb8bfb 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -130,7 +130,6 @@ static void GPENCIL_cache_init(void *vedata)
stl->storage->pal_id = 0;
memset(stl->storage->shgrps_fill, 0, sizeof(DRWShadingGroup *) 
* MAX_GPENCIL_MAT);
memset(stl->storage->shgrps_stroke, 0, sizeof(DRWShadingGroup 
*) * MAX_GPENCIL_MAT);
-   memset(stl->storage->materials, 0, sizeof(PaletteColor *) * 
MAX_GPENCIL_MAT);
stl->g_data->shgrps_point_volumetric = 
DRW_gpencil_shgroup_point_volumetric_create(psl->stroke_pass, 
e_data.gpencil_volumetric_sh);
 
state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 96735435c69..c9cb7256528 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -28,7 +28,7 @@
 
 #include "GPU_batch.h"
 
-#define MAX_GPENCIL_MAT 512 
+#define MAX_GPENCIL_MAT 65536
 #define GPENCIL_MIN_BATCH_SLOTS_CHUNK 8
 
  /* *** LISTS *** */
@@ -38,7 +38,6 @@ typedef struct GPENCIL_Storage {
int t_flip[MAX_GPENCIL_MAT];
int t_clamp[MAX_GPENCIL_MAT];
 

[Bf-blender-cvs] [5bd0a6d25bb] greasepencil-object: Enable again write depth pass for strokes only

2017-05-21 Thread Antonio Vazquez
Commit: 5bd0a6d25bb4ac77e3a2c610584afb6f65b59207
Author: Antonio Vazquez
Date:   Sat May 20 19:40:35 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB5bd0a6d25bb4ac77e3a2c610584afb6f65b59207

Enable again write depth pass for strokes only

===

M   source/blender/draw/engines/gpencil/gpencil_engine.c

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 3eec7b5db71..0e35540bb14 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -125,7 +125,7 @@ static void GPENCIL_cache_init(void *vedata)
 
{
/* Stroke pass */
-   DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | 
DRW_STATE_DEPTH_LESS;
+   DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | 
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
psl->stroke_pass = DRW_pass_create("Gpencil Stroke Pass", 
state);
stl->storage->pal_id = 0;
memset(stl->storage->shgrps_fill, 0, sizeof(DRWShadingGroup *) 
* MAX_GPENCIL_MAT);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [48a8a365bab] workspaces: Merge branch 'blender2.8' into workspaces

2017-05-21 Thread Julian Eisel
Commit: 48a8a365babd3365dfde4a3e448d92d17f87cc74
Author: Julian Eisel
Date:   Sat May 20 15:48:16 2017 +0200
Branches: workspaces
https://developer.blender.org/rB48a8a365babd3365dfde4a3e448d92d17f87cc74

Merge branch 'blender2.8' into workspaces

Conflicts:
source/blender/windowmanager/intern/wm_event_system.c

===



===

diff --cc source/blender/blenloader/intern/readfile.c
index 2a0d9d6cbd1,f44fe3327c9..fd9fce9137d
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@@ -6429,9 -6306,9 +6428,10 @@@ static void direct_link_scene(FileData 
direct_link_scene_collection(fd, sce->collection);
}
  
 -  link_list(fd, >render_layers);
 +  /* insert into global old-new map for reading without UI (link_global 
accesses it again) */
 +  link_glob_list(fd, >render_layers);
for (sl = sce->render_layers.first; sl; sl = sl->next) {
+   sl->stats = NULL;
link_list(fd, >object_bases);
sl->basact = newdataadr(fd, sl->basact);
direct_link_layer_collections(fd, >layer_collections);
diff --cc source/blender/editors/space_view3d/view3d_header.c
index 17d2e352867,6d1393a2905..31677e08207
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@@ -299,12 -304,37 +299,7 @@@ void uiTemplateHeader3D(uiLayout *layou
  
/* other buttons: */
UI_block_emboss_set(block, UI_EMBOSS);
 -  
 -  /* mode */
 -  if ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)) {
 -  modeselect = OB_MODE_GPENCIL;
 -  }
 -  else if (ob) {
 -  modeselect = ob->mode;
 -  is_paint = ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, 
OB_MODE_WEIGHT_PAINT, OB_MODE_TEXTURE_PAINT);
 -  }
 -  else {
 -  modeselect = OB_MODE_OBJECT;
 -  }
 -
 -  row = uiLayoutRow(layout, false);
 -  {
 -  EnumPropertyItem *item = rna_enum_object_mode_items;
 -  const char *name = "";
 -  int icon = ICON_OBJECT_DATAMODE;
 -
 -  while (item->identifier) {
 -  if (item->value == modeselect && item->identifier[0]) {
 -  name = IFACE_(item->name);
 -  icon = item->icon;
 -  break;
 -  }
 -  item++;
 -  }
 -
 -  uiItemMenuEnumO(row, C, "OBJECT_OT_mode_set", "mode", name, 
icon);
 -  }
  
-   if (IS_VIEWPORT_LEGACY(v3d)) {
-   /* Draw type */
-   uiItemR(layout, , "viewport_shade", UI_ITEM_R_ICON_ONLY, 
"", ICON_NONE);
-   }
- 
row = uiLayoutRow(layout, true);
uiItemR(row, , "pivot_point", UI_ITEM_R_ICON_ONLY, "", 
ICON_NONE);
if (!ob || ELEM(ob->mode, OB_MODE_OBJECT, OB_MODE_POSE, 
OB_MODE_WEIGHT_PAINT)) {
diff --cc source/blender/windowmanager/intern/wm_event_system.c
index 84a57d2ba1c,5d4b7a68d42..c4776f53f42
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@@ -334,7 -319,8 +335,8 @@@ void wm_event_do_notifiers(bContext *C
}
}
if (ELEM(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, 
NC_WM)) {
-   ED_info_stats_clear(scene);
 -  SceneLayer *sl = 
BKE_scene_layer_context_active(win->screen->scene);
++  SceneLayer *sl = 
BKE_scene_layer_context_active(scene);
+   ED_info_stats_clear(sl);
WM_event_add_notifier(C, NC_SPACE | 
ND_SPACE_INFO, NULL);
}
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs