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:
authorClément Foucault <foucault.clem@gmail.com>2018-03-12 01:43:09 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-03-12 01:44:10 +0300
commit765d7242d5a14551d0dc876f13bf6ee579b47b10 (patch)
treec18455eaabcad076fe98427d1a32d76d2c9c38f7 /source/blender/draw/intern
parent7194259fb1a8b9ef84c0896130b92ff577fc76b1 (diff)
GPUMaterial: Add Material shader cache.
This is mostly to avoid re-compilation when using undo/redo operators. This also has the benefit to reuse the same GPUShader for multiple materials using the same nodetree configuration. The cache stores GPUPasses that already contains the shader code and a hash to test for matches. We use refcounts to know when a GPUPass is not used anymore. I had to move the GPUInput list from GPUPass to GPUMaterial because it's containing references to the material nodetree and cannot be reused. A garbage collection is hardcoded to run every 60 seconds to free every unused GPUPass.
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r--source/blender/draw/intern/draw_manager_data.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 09ed1443701..4648c321f26 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -582,15 +582,14 @@ static DRWShadingGroup *drw_shgroup_material_create_ex(GPUPass *gpupass, DRWPass
return grp;
}
-static DRWShadingGroup *drw_shgroup_material_inputs(
- DRWShadingGroup *grp, struct GPUMaterial *material, GPUPass *gpupass)
+static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct GPUMaterial *material)
{
/* TODO : Ideally we should not convert. But since the whole codegen
* is relying on GPUPass we keep it as is for now. */
- /* Converting dynamic GPUInput to DRWUniform */
- ListBase *inputs = &gpupass->inputs;
+ ListBase *inputs = GPU_material_get_inputs(material);
+ /* Converting dynamic GPUInput to DRWUniform */
for (GPUInput *input = inputs->first; input; input = input->next) {
/* Textures */
if (input->ima) {
@@ -656,7 +655,7 @@ DRWShadingGroup *DRW_shgroup_material_create(
if (shgroup) {
drw_interface_init(shgroup, GPU_pass_shader(gpupass));
- drw_shgroup_material_inputs(shgroup, material, gpupass);
+ drw_shgroup_material_inputs(shgroup, material);
}
return shgroup;
@@ -673,7 +672,7 @@ DRWShadingGroup *DRW_shgroup_material_instance_create(
shgroup->instance_geom = geom;
drw_call_calc_orco(ob->data, shgroup->instance_orcofac);
drw_interface_instance_init(shgroup, GPU_pass_shader(gpupass), geom, format);
- drw_shgroup_material_inputs(shgroup, material, gpupass);
+ drw_shgroup_material_inputs(shgroup, material);
}
return shgroup;
@@ -693,7 +692,7 @@ DRWShadingGroup *DRW_shgroup_material_empty_tri_batch_create(
drw_interface_init(shgroup, GPU_pass_shader(gpupass));
shgroup->type = DRW_SHG_TRIANGLE_BATCH;
shgroup->instance_count = tri_count * 3;
- drw_shgroup_material_inputs(shgroup, material, gpupass);
+ drw_shgroup_material_inputs(shgroup, material);
}
return shgroup;