Commit: dccda1fe434e3e3af47c44720cfedc9c1c4ccf52
Author: Clément Foucault
Date:   Mon Apr 16 19:26:54 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBdccda1fe434e3e3af47c44720cfedc9c1c4ccf52

DRW/GWN: Add callId builtin uniform.

This uniforms can be used to have a unique id for each drawcall of a shgrp.
This only works for standard shgroups and is an exception for the outline
drawing.

===================================================================

M       intern/gawain/gawain/gwn_shader_interface.h
M       intern/gawain/src/gwn_shader_interface.c
M       source/blender/draw/intern/draw_manager.h
M       source/blender/draw/intern/draw_manager_data.c
M       source/blender/draw/intern/draw_manager_exec.c

===================================================================

diff --git a/intern/gawain/gawain/gwn_shader_interface.h 
b/intern/gawain/gawain/gwn_shader_interface.h
index 3be2831e539..150b3b4fcc0 100644
--- a/intern/gawain/gawain/gwn_shader_interface.h
+++ b/intern/gawain/gawain/gwn_shader_interface.h
@@ -36,6 +36,7 @@ typedef enum {
 
        GWN_UNIFORM_COLOR, // vec4 color
        GWN_UNIFORM_EYE, // vec3 eye
+       GWN_UNIFORM_CALLID, // int callId
 
        GWN_UNIFORM_CUSTOM, // custom uniform, not one of the above built-ins
 
diff --git a/intern/gawain/src/gwn_shader_interface.c 
b/intern/gawain/src/gwn_shader_interface.c
index e92cabec12f..95c18cf1d39 100644
--- a/intern/gawain/src/gwn_shader_interface.c
+++ b/intern/gawain/src/gwn_shader_interface.c
@@ -48,6 +48,7 @@ static const char* BuiltinUniform_name(Gwn_UniformBuiltin u)
 
                [GWN_UNIFORM_COLOR] = "color",
                [GWN_UNIFORM_EYE] = "eye",
+               [GWN_UNIFORM_CALLID] = "callId",
 
                [GWN_UNIFORM_CUSTOM] = NULL,
                [GWN_NUM_UNIFORMS] = NULL,
diff --git a/source/blender/draw/intern/draw_manager.h 
b/source/blender/draw/intern/draw_manager.h
index dd7e84f67d4..4f322b11931 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -222,6 +222,7 @@ struct DRWShadingGroup {
        int normalworld;
        int orcotexfac;
        int eye;
+       int callid;
        uint16_t matflag; /* Matrices needed, same as DRWCall.flag */
 
 #ifndef NDEBUG
diff --git a/source/blender/draw/intern/draw_manager_data.c 
b/source/blender/draw/intern/draw_manager_data.c
index ae7854b436c..544129ea124 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -498,6 +498,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, 
GPUShader *shader)
        shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, 
GWN_UNIFORM_WORLDNORMAL);
        shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, 
GWN_UNIFORM_ORCO);
        shgroup->eye = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_EYE);
+       shgroup->callid = GPU_shader_get_builtin_uniform(shader, 
GWN_UNIFORM_CALLID);
 
        shgroup->matflag = 0;
        if (shgroup->modelinverse > -1)
diff --git a/source/blender/draw/intern/draw_manager_exec.c 
b/source/blender/draw/intern/draw_manager_exec.c
index 0ff5522c109..e56206f9b7d 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -1005,6 +1005,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, 
DRWState pass_state)
        }
        else {
                bool prev_neg_scale = false;
+               int callid = 0;
                for (DRWCall *call = shgroup->calls.first; call; call = 
call->next) {
 
                        /* OPTI/IDEA(clem): Do this preparation in another 
thread. */
@@ -1013,6 +1014,12 @@ static void draw_shgroup(DRWShadingGroup *shgroup, 
DRWState pass_state)
                        if ((call->state->flag & DRW_CALL_CULLED) != 0)
                                continue;
 
+                       /* XXX small exception/optimisation for outline 
rendering. */
+                       if (shgroup->callid != -1) {
+                               GPU_shader_uniform_vector_int(shgroup->shader, 
shgroup->callid, 1, 1, &callid);
+                               callid += 1;
+                       }
+
                        /* Negative scale objects */
                        bool neg_scale = call->state->flag & DRW_CALL_NEGSCALE;
                        if (neg_scale != prev_neg_scale) {

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

Reply via email to