Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2020-02-14 12:47:20 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-02-15 23:09:29 +0300
commit322dc723165a705c34df1e3246e500da1a9927de (patch)
treed82e780e36c89b327d58aa2b8ee215ee8a9fd514 /source/blender/draw
parent007f1b74a67302fb4c164eb26969419434a98aee (diff)
Cleanup: refactor GPU material attribute and texture requests
Diffstat (limited to 'source/blender/draw')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c10
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c9
-rw-r--r--source/blender/draw/intern/draw_manager_data.c52
3 files changed, 34 insertions, 37 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 1c3996e2290..20eff0fb6b8 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -307,16 +307,16 @@ static void curve_cd_calc_used_gpu_layers(int *cd_layers,
struct GPUMaterial **gpumat_array,
int gpumat_array_len)
{
- GPUVertAttrLayers gpu_attrs = {{{0}}};
for (int i = 0; i < gpumat_array_len; i++) {
struct GPUMaterial *gpumat = gpumat_array[i];
if (gpumat == NULL) {
continue;
}
- GPU_material_vertex_attrs(gpumat, &gpu_attrs);
- for (int j = 0; j < gpu_attrs.totlayer; j++) {
- const char *name = gpu_attrs.layer[j].name;
- int type = gpu_attrs.layer[j].type;
+
+ ListBase gpu_attrs = GPU_material_attributes(gpumat);
+ for (GPUMaterialAttribute *gpu_attr = gpu_attrs.first; gpu_attr; gpu_attr = gpu_attr->next) {
+ const char *name = gpu_attr->name;
+ int type = gpu_attr->type;
/* Curves cannot have named layers.
* Note: We could relax this assumption later. */
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index ed60e16c7cc..5b273159cdf 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -142,11 +142,10 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Mesh *me,
for (int i = 0; i < gpumat_array_len; i++) {
GPUMaterial *gpumat = gpumat_array[i];
if (gpumat) {
- GPUVertAttrLayers gpu_attrs;
- GPU_material_vertex_attrs(gpumat, &gpu_attrs);
- for (int j = 0; j < gpu_attrs.totlayer; j++) {
- const char *name = gpu_attrs.layer[j].name;
- int type = gpu_attrs.layer[j].type;
+ ListBase gpu_attrs = GPU_material_attributes(gpumat);
+ for (GPUMaterialAttribute *gpu_attr = gpu_attrs.first; gpu_attr; gpu_attr = gpu_attr->next) {
+ const char *name = gpu_attr->name;
+ int type = gpu_attr->type;
int layer = -1;
if (type == CD_AUTO_FROM_NAME) {
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);