diff options
author | Jeroen Bakker <jbakker> | 2022-01-17 16:32:03 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-01-17 16:32:28 +0300 |
commit | 8fb2ff458ba579dba08bfdf57d043ad158b5db07 (patch) | |
tree | e6324c08c69de3e8ed34c1f85d0b2982fa1d38ed /source/blender/draw/intern/draw_shader_shared.h | |
parent | 08822801acf648d23791fa308ec8c1c26f86963e (diff) |
GPUShaderCreateInfo for interface abstraction
This is a first part of the Shader Create Info system could be.
A shader create info provides a way to define shader structure, resources
and interfaces. This makes for a quick way to provide backend agnostic
binding informations while also making shader variations easy to declare.
- Clear source input (only one file). Cleans up the GPU api since we can create a
shader from one descriptor
- Resources and interfaces are generated by the backend (much simpler than parsing).
- Bindings are explicit from position in the array.
- GPUShaderInterface becomes a trivial translation of enums and string copy.
- No external dependency to third party lib.
- Cleaner code, less fragmentation of resources in several libs.
- Easy to modify / extend at runtime.
- no parser involve, very easy to code.
- Does not hold any data, can be static and kept on disc.
- Could hold precompiled bytecode for static shaders.
This also includes a new global dependency system.
GLSL shaders can include other sources by using #pragma BLENDER_REQUIRE(...).
This patch already migrated several builtin shaders. Other shaders should be migrated
one at a time, and could be done inside master.
There is a new compile directive `WITH_GPU_SHADER_BUILDER` this is an optional
directive for linting shaders to increase turn around time.
What is remaining:
- pyGPU API {T94975}
- Migration of other shaders. This could be a community effort.
Reviewed By: jbakker
Maniphest Tasks: T94975
Differential Revision: https://developer.blender.org/D13360
Diffstat (limited to 'source/blender/draw/intern/draw_shader_shared.h')
-rw-r--r-- | source/blender/draw/intern/draw_shader_shared.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_shader_shared.h b/source/blender/draw/intern/draw_shader_shared.h new file mode 100644 index 00000000000..aa117f44e84 --- /dev/null +++ b/source/blender/draw/intern/draw_shader_shared.h @@ -0,0 +1,41 @@ + +#ifndef GPU_SHADER +# include "gpu_shader_shared_utils.h" +#endif + +#define DRW_SHADER_SHARED_H + +#define DRW_RESOURCE_CHUNK_LEN 512 + +struct ViewInfos { + /* View matrices */ + float4x4 persmat; + float4x4 persinv; + float4x4 viewmat; + float4x4 viewinv; + float4x4 winmat; + float4x4 wininv; + + float4 clipplanes[6]; + float4 viewvecs[2]; + /* Should not be here. Not view dependent (only main view). */ + float4 viewcamtexcofac; +}; +BLI_STATIC_ASSERT_ALIGN(ViewInfos, 16) + +/* TODO(fclem) Mass rename. */ +#define ViewProjectionMatrix drw_view.persmat +#define ViewProjectionMatrixInverse drw_view.persinv +#define ViewMatrix drw_view.viewmat +#define ViewMatrixInverse drw_view.viewinv +#define ProjectionMatrix drw_view.winmat +#define ProjectionMatrixInverse drw_view.wininv +#define clipPlanes drw_view.clipplanes +#define ViewVecs drw_view.viewvecs +#define CameraTexCoFactors drw_view.viewcamtexcofac + +struct ObjectMatrices { + float4x4 drw_modelMatrix; + float4x4 drw_modelMatrixInverse; +}; +BLI_STATIC_ASSERT_ALIGN(ViewInfos, 16) |