|
Blender V5.0
|
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correctly provided, this is all that is needed to create and compile a blender::gpu::Shader. More...
#include <gpu_shader_create_info.hh>
Inherited by blender::gpu::shader::GPUCodegenCreateInfo.
Classes | |
| struct | ResourceString |
| struct | VertIn |
| struct | GeometryStageLayout |
| struct | ComputeStageLayout |
| struct | FragOut |
| struct | SubpassIn |
| struct | SharedVariable |
| struct | Sampler |
| struct | Image |
| struct | UniformBuf |
| struct | StorageBuf |
| struct | Resource |
| struct | PushConst |
Public Types | |
| using | Self = ShaderCreateInfo |
Public Member Functions | |
| Vector< Resource > & | resources_get_ (Frequency freq) |
| Vector< Resource > | resources_get_all_ () const |
| ShaderCreateInfo (const char *name) | |
| ~ShaderCreateInfo ()=default | |
Shaders in/outs (fixed function pipeline config) | |
| Self & | vertex_in (int slot, Type type, StringRefNull name) |
| Self & | vertex_out (StageInterfaceInfo &interface) |
| Self & | geometry_layout (PrimitiveIn prim_in, PrimitiveOut prim_out, int max_vertices, int invocations=-1) |
| Self & | local_group_size (int local_size_x, int local_size_y=1, int local_size_z=1) |
| Self & | early_fragment_test (bool enable) |
| Self & | geometry_out (StageInterfaceInfo &interface) |
| Self & | fragment_out (int slot, Type type, StringRefNull name, DualBlend blend=DualBlend::NONE, int raster_order_group=-1) |
| Self & | subpass_in (int slot, Type type, ImageType img_type, StringRefNull name, int raster_order_group=-1) |
| Self & | shared_resource_descriptor (void(*fn)(ShaderCreateInfo &)) |
Shader compilation constants | |
Compilation constants are constants defined in the create info. They cannot be changed after the shader is created. It is a replacement to macros with added type safety. | |
| Self & | compilation_constant (Type type, StringRefNull name, double default_value) |
Shader specialization constants | |
| Self & | specialization_constant (Type type, StringRefNull name, double default_value) |
Compute shader Shared variables | |
| Self & | shared_variable (Type type, StringRefNull name) |
Resources bindings points | |
| Self & | uniform_buf (int slot, StringRefNull type_name, StringRefNull name, Frequency freq=Frequency::PASS) |
| Self & | storage_buf (int slot, Qualifier qualifiers, StringRefNull type_name, StringRefNull name, Frequency freq=Frequency::PASS) |
| Self & | image (int slot, TextureFormat format, Qualifier qualifiers, ImageReadWriteType type, StringRefNull name, Frequency freq=Frequency::PASS) |
| Self & | sampler (int slot, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS, GPUSamplerState sampler=GPUSamplerState::internal_sampler()) |
Shader Source | |
| Self & | vertex_source (StringRefNull filename) |
| Self & | fragment_source (StringRefNull filename) |
| Self & | compute_source (StringRefNull filename) |
| Self & | vertex_function (StringRefNull function_name) |
| Self & | fragment_function (StringRefNull function_name) |
| Self & | compute_function (StringRefNull function_name) |
Push constants | |
Data managed by blender::gpu::Shader. Can be set through uniform functions. Must be less than 128bytes. | |
| Self & | push_constant (Type type, StringRefNull name, int array_size=0) |
Defines | |
| Self & | define (StringRefNull name, StringRefNull value="") |
| Self & | do_static_compilation (bool value) |
| Self & | builtins (BuiltinBits builtin) |
| Self & | depth_write (DepthWrite value) |
| Self & | auto_resource_location (bool value) |
| Self & | metal_backend_only (bool flag) |
Additional Create Info | |
Used to share parts of the infos that are common to many shaders. | |
| Self & | additional_info (StringRefNull info_name) |
| template<typename... Args> | |
| Self & | additional_info (StringRefNull info_name, Args... args) |
Typedef Sources | |
Some resource declarations might need some special structure defined. Adding a file using typedef_source will include it before the resource and interface definitions. | |
| Self & | typedef_source (StringRefNull filename) |
mtl_max_total_threads_per_threadgroup | |
max_total_threads_per_threadgroup - Provides compiler hint for maximum threadgroup size up front. Maximum value is 1024. | |
| Self & | mtl_max_total_threads_per_threadgroup (ushort max_total_threads_per_threadgroup) |
Recursive evaluation. | |
Flatten all dependency so that this descriptor contains all the data from the additional descriptors. This avoids tedious traversal in shader source creation. | |
| void | finalize (const bool recursive=false) |
| void | resource_guard_defines (std::string &defines) const |
| std::string | check_error () const |
| bool | is_vulkan_compatible () const |
| void | validate_merge (const ShaderCreateInfo &other_info) |
| void | validate_vertex_attributes (const ShaderCreateInfo *other_info=nullptr) |
Operators. | |
| bool | operator== (const ShaderCreateInfo &b) const |
| bool | has_resource_type (Resource::BindType bind_type) const |
| bool | has_resource_image () const |
| std::ostream & | operator<< (std::ostream &stream, const ShaderCreateInfo &info) |
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correctly provided, this is all that is needed to create and compile a blender::gpu::Shader.
IMPORTANT: All strings are references only. Make sure all the strings used by a ShaderCreateInfo are not freed until it is consumed or deleted.
Definition at line 686 of file gpu_shader_create_info.hh.
Definition at line 1008 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1005 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1395 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
|
inline |
Definition at line 1401 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1375 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1362 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
| std::string blender::gpu::shader::ShaderCreateInfo::check_error | ( | ) | const |
Definition at line 280 of file gpu_shader_create_info.cc.
Referenced by GPU_shader_create_info_check_error().
|
inline |
Definition at line 1116 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1311 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1293 of file gpu_shader_create_info.hh.
Referenced by blender::opensubdiv::compile_eval_patches_shader(), and blender::opensubdiv::compile_eval_stencil_shader().
|
inline |
|
inline |
Definition at line 1369 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1356 of file gpu_shader_create_info.hh.
|
inline |
Force fragment tests before fragment shader invocation. IMPORTANT: This is incompatible with using the gl_FragDepth output.
Definition at line 1051 of file gpu_shader_create_info.hh.
| void blender::gpu::shader::ShaderCreateInfo::finalize | ( | const bool | recursive = false | ) |
Definition at line 115 of file gpu_shader_create_info.cc.
|
inline |
Definition at line 1305 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1069 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
inline |
Definition at line 1287 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
inline |
Definition at line 1027 of file gpu_shader_create_info.hh.
|
inline |
Only needed if geometry shader is enabled. IMPORTANT: Input and output instance name will have respectively "_in" and "_out" suffix appended in the geometry shader IF AND ONLY IF the vertex_out interface instance name matches the geometry_out interface instance name.
Definition at line 1063 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1566 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1546 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1241 of file gpu_shader_create_info.hh.
| bool blender::gpu::shader::ShaderCreateInfo::is_vulkan_compatible | ( | ) | const |
Definition at line 80 of file gpu_shader_create_info.cc.
|
inline |
Definition at line 1039 of file gpu_shader_create_info.hh.
Referenced by blender::opensubdiv::compile_eval_patches_shader(), and blender::opensubdiv::compile_eval_stencil_shader().
|
inline |
Definition at line 1381 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1439 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1481 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1326 of file gpu_shader_create_info.hh.
Referenced by blender::opensubdiv::compile_eval_patches_shader(), blender::opensubdiv::compile_eval_stencil_shader(), and blender::ocio::GPUShaderBinder::create_gpu_shader().
| void blender::gpu::shader::ShaderCreateInfo::resource_guard_defines | ( | std::string & | defines | ) | const |
Definition at line 99 of file gpu_shader_create_info.cc.
|
inline |
Definition at line 942 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 957 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1258 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader(), and blender::eevee::ShaderModule::material_create_info_amend().
|
inline |
Definition at line 1100 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1201 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1166 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1226 of file gpu_shader_create_info.hh.
Referenced by blender::opensubdiv::compile_eval_patches_shader(), and blender::opensubdiv::compile_eval_stencil_shader().
|
inline |
Allows to fetch frame-buffer values from previous render sub-pass.
On Apple Silicon, the additional raster_order_group is there to set the sub-pass dependencies. Any sub-pass input need to have the same raster_order_group defined in the shader writing them.
IMPORTANT: Currently emulated on all backend except Metal. This is only for debugging purpose as it is too slow to be viable.
TODO(fclem): Vulkan can implement that using subpassInput. However sub-pass boundaries might be difficult to inject implicitly and will require more high level changes. TODO(fclem): OpenGL can emulate that using GL_EXT_shader_framebuffer_fetch.
Definition at line 1093 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1418 of file gpu_shader_create_info.hh.
Referenced by blender::opensubdiv::compile_eval_patches_shader(), blender::opensubdiv::compile_eval_stencil_shader(), and blender::ocio::GPUShaderBinder::create_gpu_shader().
|
inline |
Definition at line 1213 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
| void blender::gpu::shader::ShaderCreateInfo::validate_merge | ( | const ShaderCreateInfo & | other_info | ) |
Error detection that some backend compilers do not complain about.
Definition at line 378 of file gpu_shader_create_info.cc.
| void blender::gpu::shader::ShaderCreateInfo::validate_vertex_attributes | ( | const ShaderCreateInfo * | other_info = nullptr | ) |
Definition at line 451 of file gpu_shader_create_info.cc.
|
inline |
Definition at line 1299 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1014 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
inline |
Definition at line 1021 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
inline |
Definition at line 1281 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
friend |
Debug print
Definition at line 1510 of file gpu_shader_create_info.hh.
Name of other infos to recursively merge with this one. No data slot must overlap otherwise we throw an error.
Definition at line 997 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
If true, all resources will have an automatic location assigned.
Definition at line 696 of file gpu_shader_create_info.hh.
Definition at line 940 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
| BuiltinBits blender::gpu::shader::ShaderCreateInfo::builtins_ = BuiltinBits::NONE |
Manually set builtins.
Definition at line 710 of file gpu_shader_create_info.hh.
| Vector<CompilationConstant, 0> blender::gpu::shader::ShaderCreateInfo::compilation_constants_ |
Definition at line 851 of file gpu_shader_create_info.hh.
Definition at line 990 of file gpu_shader_create_info.hh.
Definition at line 809 of file gpu_shader_create_info.hh.
Definition at line 988 of file gpu_shader_create_info.hh.
Definition at line 714 of file gpu_shader_create_info.hh.
Referenced by GPU_shader_create_from_info_python().
| Vector<std::array<StringRefNull, 2> > blender::gpu::shader::ShaderCreateInfo::defines_ |
Definition at line 992 of file gpu_shader_create_info.hh.
Manually set generated dependencies file names.
Definition at line 718 of file gpu_shader_create_info.hh.
| DepthWrite blender::gpu::shader::ShaderCreateInfo::depth_write_ = DepthWrite::UNCHANGED |
Allow optimization when fragment shader writes to gl_FragDepth.
Definition at line 700 of file gpu_shader_create_info.hh.
True if the shader is static and can be pre-compiled at compile time.
Definition at line 690 of file gpu_shader_create_info.hh.
Referenced by GPU_shader_create_from_info_name().
If true, force depth and stencil tests to always happen before fragment shader invocation.
Definition at line 698 of file gpu_shader_create_info.hh.
If true, all additionally linked create info will be merged into this one.
Definition at line 694 of file gpu_shader_create_info.hh.
Definition at line 990 of file gpu_shader_create_info.hh.
Definition at line 829 of file gpu_shader_create_info.hh.
Definition at line 988 of file gpu_shader_create_info.hh.
Definition at line 713 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader(), and GPU_shader_create_from_info_python().
| GeneratedSourceList blender::gpu::shader::ShaderCreateInfo::generated_sources |
Definition at line 720 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
Definition at line 989 of file gpu_shader_create_info.hh.
Definition at line 794 of file gpu_shader_create_info.hh.
Definition at line 967 of file gpu_shader_create_info.hh.
Definition at line 940 of file gpu_shader_create_info.hh.
Definition at line 988 of file gpu_shader_create_info.hh.
Definition at line 715 of file gpu_shader_create_info.hh.
Referenced by GPU_shader_create_from_info_python().
Maximum length of all the resource names including each null terminator. Only for names used by #gpu::ShaderInterface.
Definition at line 708 of file gpu_shader_create_info.hh.
True if the shader is not part of gpu_shader_create_info_list.
Definition at line 692 of file gpu_shader_create_info.hh.
GPU Backend compatibility flag. Temporary requirement until Metal enablement is fully complete.
Definition at line 703 of file gpu_shader_create_info.hh.
Shader name for debugging.
Definition at line 688 of file gpu_shader_create_info.hh.
Referenced by GPU_shader_create_from_info_name(), and blender::eevee::ShaderModule::material_create_info_amend().
Resources are grouped by frequency of change. Pass resources are meant to be valid for the whole pass. Batch resources can be changed in a more granular manner (per object/material). Geometry resources can be changed in a very granular manner (per draw-call). Misuse will only produce suboptimal performance.
Definition at line 940 of file gpu_shader_create_info.hh.
Definition at line 983 of file gpu_shader_create_info.hh.
Definition at line 859 of file gpu_shader_create_info.hh.
| Vector<SpecializationConstant> blender::gpu::shader::ShaderCreateInfo::specialization_constants_ |
Definition at line 852 of file gpu_shader_create_info.hh.
Definition at line 849 of file gpu_shader_create_info.hh.
Definition at line 716 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
Definition at line 986 of file gpu_shader_create_info.hh.
Definition at line 989 of file gpu_shader_create_info.hh.
Definition at line 776 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
Definition at line 966 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
Definition at line 988 of file gpu_shader_create_info.hh.
Manually set generated code.
Definition at line 712 of file gpu_shader_create_info.hh.
Referenced by GPU_shader_create_from_info_python().