diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-02-14 12:47:20 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2020-02-15 23:09:29 +0300 |
commit | 322dc723165a705c34df1e3246e500da1a9927de (patch) | |
tree | d82e780e36c89b327d58aa2b8ee215ee8a9fd514 /source/blender/draw/intern/draw_manager_data.c | |
parent | 007f1b74a67302fb4c164eb26969419434a98aee (diff) |
Cleanup: refactor GPU material attribute and texture requests
Diffstat (limited to 'source/blender/draw/intern/draw_manager_data.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 1b2195b8e41..0af68181478 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -49,7 +49,6 @@ #include "GPU_material.h" #include "intern/gpu_codegen.h" -#include "intern/gpu_node_graph.h" /* -------------------------------------------------------------------- */ /** \name Uniform Buffer Object (DRW_uniformbuffer) @@ -1207,40 +1206,39 @@ static DRWShadingGroup *drw_shgroup_material_create_ex(GPUPass *gpupass, DRWPass static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct GPUMaterial *material) { - ListBase *inputs = GPU_material_get_inputs(material); + ListBase textures = GPU_material_textures(material); - /* Converting dynamic GPUInput to DRWUniform */ - for (GPUInput *input = inputs->first; input; input = input->next) { - /* Textures */ - if (input->source == GPU_SOURCE_TEX) { - GPUTexture *tex = NULL; + /* Bind all textures needed by the material. */ + for (GPUMaterialTexture *tex = textures.first; tex; tex = tex->next) { + GPUTexture *gputex; - if (input->ima) { - GPUTexture **tex_ref = BLI_memblock_alloc(DST.vmempool->images); + if (tex->ima) { + /* Image */ + GPUTexture **gputex_ref = BLI_memblock_alloc(DST.vmempool->images); - int textarget; - if (input->type == GPU_TEX2D_ARRAY) { - textarget = GL_TEXTURE_2D_ARRAY; - } - else if (input->type == GPU_TEX1D_ARRAY) { - textarget = GL_TEXTURE_1D_ARRAY; - } - else { - textarget = GL_TEXTURE_2D; - } - *tex_ref = tex = GPU_texture_from_blender(input->ima, input->iuser, NULL, textarget); - - GPU_texture_ref(tex); + int textarget; + if (tex->type == GPU_TEX2D_ARRAY) { + textarget = GL_TEXTURE_2D_ARRAY; + } + else if (tex->type == GPU_TEX1D_ARRAY) { + textarget = GL_TEXTURE_1D_ARRAY; } else { - /* Color Ramps */ - tex = *input->coba; + textarget = GL_TEXTURE_2D; } + *gputex_ref = gputex = GPU_texture_from_blender(tex->ima, tex->iuser, NULL, textarget); - if (input->bindtex) { - drw_shgroup_uniform_create_ex(grp, input->shaderloc, DRW_UNIFORM_TEXTURE, tex, 0, 1); - } + GPU_texture_ref(gputex); + } + else if (tex->colorband) { + /* Color Ramp */ + gputex = *tex->colorband; } + else { + continue; + } + + DRW_shgroup_uniform_texture(grp, tex->shadername, gputex); } GPUUniformBuffer *ubo = GPU_material_uniform_buffer_get(material); |