diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-07-14 18:40:54 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-07-14 18:46:10 +0300 |
commit | 2a489273d7e2354a9f1afc3212863ff4b463cf86 (patch) | |
tree | a12701d9ca43b6ace0993cfc31bc278eed3cc4fb /source/blender/gpu/GPU_material.h | |
parent | 73b142529705e75790a4b9279109763014ca63e6 (diff) |
Implement Uniformbuffer objects for nodetree parameters
For users that means you can tweak shaders in the nodetree and things
are way faster. This is a huge improvement, particularly in
systems that have no shader cache.
From the code perspective it means we are no longer re-compiling the
shader every time a value is tweaked in the UI. We are using uniforms
for those values.
It would be slow to add that many uniforms for all the shaders. So
instead we are using UBO (Uniform Buffer Objects).
This fixes the main issue of T51467. However GWN_shaderinterface_create() still
needs to be improvedi. When opening a .blend all shaders are compiled once, so
optimizing it will bring a measurable impact.
========================================================================
NOTE: This breaks update of Cycles material upon nodetree nodes
tweaking. It will be fixed separately by depsgraph, once tackling T51925
(Animated Eevee values slowdown).
The idea is to make Depsgraph update more granular. The XXX TODO in
rna_nodetree.c will be tackled at that time as well.
========================================================================
Reviewers: sergey, brecht, fclem
Differential Revision: https://developer.blender.org/D2739
Diffstat (limited to 'source/blender/gpu/GPU_material.h')
-rw-r--r-- | source/blender/gpu/GPU_material.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index ec50bd9d9f5..47035c8c64e 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -43,6 +43,7 @@ extern "C" { struct Image; struct ImageUser; +struct ListBase; struct Material; struct Object; struct Scene; @@ -53,9 +54,11 @@ struct GPUNodeLink; struct GPUNodeStack; struct GPUMaterial; struct GPUTexture; +struct GPUUniformBuffer; struct GPULamp; struct PreviewImage; struct World; +struct bNode; struct bNodeTree; typedef struct GPUNode GPUNode; @@ -143,6 +146,7 @@ typedef struct GPUNodeStack { #define GPU_DYNAMIC_GROUP_MIST 0x00050000 #define GPU_DYNAMIC_GROUP_WORLD 0x00060000 #define GPU_DYNAMIC_GROUP_MAT 0x00070000 +#define GPU_DYNAMIC_UBO 0x00080000 typedef enum GPUDynamicType { @@ -202,6 +206,7 @@ typedef enum GPUDynamicType { GPUNodeLink *GPU_attribute(CustomDataType type, const char *name); GPUNodeLink *GPU_uniform(float *num); GPUNodeLink *GPU_dynamic_uniform(float *num, GPUDynamicType dynamictype, void *data); +GPUNodeLink *GPU_uniform_buffer(float *num, GPUType gputype); GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, bool is_data); GPUNodeLink *GPU_cube_map(struct Image *ima, struct ImageUser *iuser, bool is_data); GPUNodeLink *GPU_image_preview(struct PreviewImage *prv); @@ -212,7 +217,10 @@ GPUNodeLink *GPU_opengl_builtin(GPUOpenGLBuiltin builtin); void GPU_node_link_set_type(GPUNodeLink *link, GPUType type); bool GPU_link(GPUMaterial *mat, const char *name, ...); -bool GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNodeStack *out, ...); +bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out, ...); +GPUNodeLink *GPU_uniformbuffer_link_out( + struct GPUMaterial *mat, struct bNode *node, + struct GPUNodeStack *stack, const int index); void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link); void GPU_material_enable_alpha(GPUMaterial *material); @@ -244,6 +252,10 @@ struct Scene *GPU_material_scene(GPUMaterial *material); GPUMatType GPU_Material_get_type(GPUMaterial *material); struct GPUPass *GPU_material_get_pass(GPUMaterial *material); +struct GPUUniformBuffer *GPU_material_get_uniform_buffer(GPUMaterial *material); +void GPU_material_create_uniform_buffer(GPUMaterial *material, struct ListBase *inputs); +void GPU_material_uniform_buffer_tag_dirty(struct ListBase *gpumaterials); + void GPU_material_vertex_attributes(GPUMaterial *material, struct GPUVertexAttribs *attrib); |