diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-04-17 13:59:18 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-04-17 14:24:48 +0300 |
commit | ad648b769395492e9735eec7fe3998619952b1d8 (patch) | |
tree | 6a6e924a3b92c5047f21ad47b97554a20d02aeb9 /source | |
parent | 17041bd895eadca1bff3bf88bc8b0f9982fe4573 (diff) |
DRW: Add DRW_UNIFORM_INT_COPY.
This allow to use int uniforms that are not references. Convenient for ids.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.h | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 6 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 7 |
4 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 27f2d891cc0..1f1c7f322f4 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -379,6 +379,8 @@ void DRW_shgroup_uniform_ivec2(DRWShadingGroup *shgroup, const char *name, const void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize); void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float *value); void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float *value); +/* Store value instead of referencing it. */ +void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value); /* Passes */ DRWPass *DRW_pass_create(const char *name, DRWState state); diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 4f322b11931..fd75405f346 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -157,6 +157,7 @@ typedef enum { DRW_UNIFORM_SHORT_TO_INT, DRW_UNIFORM_SHORT_TO_FLOAT, DRW_UNIFORM_INT, + DRW_UNIFORM_INT_COPY, DRW_UNIFORM_FLOAT, DRW_UNIFORM_TEXTURE, DRW_UNIFORM_TEXTURE_PERSIST, diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 544129ea124..74f39cf9073 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -211,6 +211,12 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 16, 1); } +/* Stores the int instead of a pointer. */ +void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value) +{ + drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, SET_INT_IN_POINTER(value), 1, 1); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index dcd976805fd..3716c9d9acf 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -873,7 +873,12 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) case DRW_UNIFORM_SHORT_TO_INT: val = (int)*((short *)uni->value); GPU_shader_uniform_vector_int( - shgroup->shader, uni->location, uni->length, uni->arraysize, (int *)&val); + shgroup->shader, uni->location, uni->length, uni->arraysize, &val); + break; + case DRW_UNIFORM_INT_COPY: + val = GET_INT_FROM_POINTER(uni->value); + GPU_shader_uniform_vector_int( + shgroup->shader, uni->location, uni->length, uni->arraysize, &val); break; case DRW_UNIFORM_SHORT_TO_FLOAT: fval = (float)*((short *)uni->value); |