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-12 14:48:44 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-02-15 22:33:16 +0300
commit007f1b74a67302fb4c164eb26969419434a98aee (patch)
treef56ba0eecbbc11fc22e6a47aa0d76582e553e3da /source/blender/gpu/intern/gpu_material.c
parent6701db773e660e5306e305a1b10f8ea52955f06b (diff)
Cleanup: split off code from gpu_codegen.c into smaller files
Diffstat (limited to 'source/blender/gpu/intern/gpu_material.c')
-rw-r--r--source/blender/gpu/intern/gpu_material.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index d8d431e329a..9eed3e4619b 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -52,6 +52,7 @@
#include "DRW_engine.h"
#include "gpu_codegen.h"
+#include "gpu_node_graph.h"
/* Structs */
#define MAX_COLOR_BAND 128
@@ -70,15 +71,11 @@ struct GPUMaterial {
const void *engine_type; /* attached engine type */
int options; /* to identify shader variations (shadow, probe, world background...) */
- /* for creating the material */
- ListBase nodes;
- GPUNodeLink *outlink;
+ /* Nodes */
+ GPUNodeGraph graph;
/* for binding the material */
GPUPass *pass;
- ListBase inputs; /* GPUInput */
- GPUVertAttrLayers attrs;
- int builtins;
/* XXX: Should be in Material. But it depends on the output node
* used and since the output selection is different for GPUMaterial...
@@ -169,8 +166,7 @@ static void gpu_material_free_single(GPUMaterial *material)
/* Cancel / wait any pending lazy compilation. */
DRW_deferred_shader_remove(material);
- GPU_pass_free_nodes(&material->nodes);
- GPU_inputs_free(&material->inputs);
+ gpu_node_graph_free(&material->graph);
if (material->pass != NULL) {
GPU_pass_release(material->pass);
@@ -203,7 +199,7 @@ void GPU_material_free(ListBase *gpumaterial)
eGPUBuiltin GPU_get_material_builtins(GPUMaterial *material)
{
- return material->builtins;
+ return material->graph.builtins;
}
Scene *GPU_material_scene(GPUMaterial *material)
@@ -218,7 +214,7 @@ GPUPass *GPU_material_get_pass(GPUMaterial *material)
ListBase *GPU_material_get_inputs(GPUMaterial *material)
{
- return &material->inputs;
+ return &material->graph.inputs;
}
/* Return can be NULL if it's a world material. */
@@ -573,19 +569,19 @@ struct GPUUniformBuffer *GPU_material_create_sss_profile_ubo(void)
void GPU_material_vertex_attrs(GPUMaterial *material, GPUVertAttrLayers *r_attrs)
{
- *r_attrs = material->attrs;
+ *r_attrs = material->graph.attrs;
}
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link)
{
- if (!material->outlink) {
- material->outlink = link;
+ if (!material->graph.outlink) {
+ material->graph.outlink = link;
}
}
void gpu_material_add_node(GPUMaterial *material, GPUNode *node)
{
- BLI_addtail(&material->nodes, node);
+ BLI_addtail(&material->graph.nodes, node);
}
GSet *gpu_material_used_libraries(GPUMaterial *material)
@@ -682,7 +678,7 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
SET_FLAG_FROM_TEST(mat->domain, has_surface_output, GPU_DOMAIN_SURFACE);
SET_FLAG_FROM_TEST(mat->domain, has_volume_output, GPU_DOMAIN_VOLUME);
- if (mat->outlink) {
+ if (mat->graph.outlink) {
/* HACK: this is only for eevee. We add the define here after the nodetree evaluation. */
if (GPU_material_flag_get(mat, GPU_MATFLAG_SSS)) {
defines = BLI_string_joinN(defines,
@@ -691,15 +687,7 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
"#endif\n");
}
/* Create source code and search pass cache for an already compiled version. */
- mat->pass = GPU_generate_pass(mat,
- mat->outlink,
- &mat->attrs,
- &mat->nodes,
- &mat->builtins,
- vert_code,
- geom_code,
- frag_lib,
- defines);
+ mat->pass = GPU_generate_pass(mat, &mat->graph, vert_code, geom_code, frag_lib, defines);
if (GPU_material_flag_get(mat, GPU_MATFLAG_SSS)) {
MEM_freeN((char *)defines);
@@ -714,7 +702,7 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
if (sh != NULL) {
/* We had a cache hit and the shader is already compiled. */
mat->status = GPU_MAT_SUCCESS;
- GPU_nodes_extract_dynamic_inputs(sh, &mat->inputs, &mat->nodes);
+ gpu_node_graph_extract_dynamic_inputs(sh, &mat->graph);
}
else {
mat->status = GPU_MAT_QUEUED;
@@ -760,12 +748,12 @@ void GPU_material_compile(GPUMaterial *mat)
GPUShader *sh = GPU_pass_shader_get(mat->pass);
if (sh != NULL) {
mat->status = GPU_MAT_SUCCESS;
- GPU_nodes_extract_dynamic_inputs(sh, &mat->inputs, &mat->nodes);
+ gpu_node_graph_extract_dynamic_inputs(sh, &mat->graph);
}
}
else {
mat->status = GPU_MAT_FAILED;
- GPU_pass_free_nodes(&mat->nodes);
+ gpu_node_graph_free(&mat->graph);
GPU_pass_release(mat->pass);
mat->pass = NULL;
}