|
Blender V4.5
|
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 #GPUShader. More...
#include <gpu_shader_create_info.hh>
Inherited by blender::gpu::shader::GPUCodegenCreateInfo.
Classes | |
| struct | VertIn |
| struct | GeometryStageLayout |
| struct | ComputeStageLayout |
| struct | FragOut |
| struct | SubpassIn |
| 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) |
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) |
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, eGPUTextureFormat 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) |
Push constants | |
Data managed by GPUShader. 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) |
API-Specific Parameters | |
Optional parameters exposed by specific back-ends to enable additional features and performance tuning. NOTE: These functions can be exposed as a pass-through on unsupported configurations. | |
| 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) |
| 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 #GPUShader.
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 626 of file gpu_shader_create_info.hh.
Definition at line 905 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 902 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1255 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
|
inline |
Definition at line 1261 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1235 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1222 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 245 of file gpu_shader_create_info.cc.
Referenced by GPU_shader_create_info_check_error().
|
inline |
Definition at line 1007 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1172 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 1229 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1216 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 948 of file gpu_shader_create_info.hh.
| void blender::gpu::shader::ShaderCreateInfo::finalize | ( | const bool | recursive = false | ) |
Definition at line 99 of file gpu_shader_create_info.cc.
|
inline |
Definition at line 966 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
inline |
Definition at line 1166 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
inline |
Definition at line 924 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 960 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1422 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1402 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1120 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 936 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 1241 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1297 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1337 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1186 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 841 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 856 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1137 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 1057 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1105 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 990 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 1278 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 1092 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 333 of file gpu_shader_create_info.cc.
| void blender::gpu::shader::ShaderCreateInfo::validate_vertex_attributes | ( | const ShaderCreateInfo * | other_info = nullptr | ) |
Definition at line 406 of file gpu_shader_create_info.cc.
|
inline |
Definition at line 911 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
inline |
Definition at line 918 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
inline |
Definition at line 1160 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
|
friend |
Debug print
Definition at line 1366 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 894 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 634 of file gpu_shader_create_info.hh.
Definition at line 839 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 648 of file gpu_shader_create_info.hh.
| Vector<CompilationConstant, 0> blender::gpu::shader::ShaderCreateInfo::compilation_constants_ |
Definition at line 757 of file gpu_shader_create_info.hh.
Definition at line 715 of file gpu_shader_create_info.hh.
Definition at line 887 of file gpu_shader_create_info.hh.
Definition at line 652 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 889 of file gpu_shader_create_info.hh.
Manually set generated dependencies.
Definition at line 656 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 638 of file gpu_shader_create_info.hh.
True if the shader is static and can be pre-compiled at compile time.
Definition at line 630 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 636 of file gpu_shader_create_info.hh.
If true, all additionally linked create info will be merged into this one.
Definition at line 632 of file gpu_shader_create_info.hh.
Definition at line 735 of file gpu_shader_create_info.hh.
Definition at line 887 of file gpu_shader_create_info.hh.
Definition at line 651 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader(), GPU_shader_create_from_info_python(), and blender::eevee::ShaderModule::material_create_info_amend().
Definition at line 700 of file gpu_shader_create_info.hh.
Definition at line 866 of file gpu_shader_create_info.hh.
Definition at line 839 of file gpu_shader_create_info.hh.
Definition at line 887 of file gpu_shader_create_info.hh.
Definition at line 653 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 646 of file gpu_shader_create_info.hh.
GPU Backend compatibility flag. Temporary requirement until Metal enablement is fully complete.
Definition at line 641 of file gpu_shader_create_info.hh.
Shader name for debugging.
Definition at line 628 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 839 of file gpu_shader_create_info.hh.
Definition at line 882 of file gpu_shader_create_info.hh.
| Vector<SpecializationConstant> blender::gpu::shader::ShaderCreateInfo::specialization_constants_ |
Definition at line 758 of file gpu_shader_create_info.hh.
Definition at line 755 of file gpu_shader_create_info.hh.
Definition at line 654 of file gpu_shader_create_info.hh.
Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader().
Definition at line 885 of file gpu_shader_create_info.hh.
Definition at line 682 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
Definition at line 865 of file gpu_shader_create_info.hh.
Referenced by blender::eevee::ShaderModule::material_create_info_amend().
Definition at line 887 of file gpu_shader_create_info.hh.
Manually set generated code.
Definition at line 650 of file gpu_shader_create_info.hh.
Referenced by GPU_shader_create_from_info_python(), and blender::eevee::ShaderModule::material_create_info_amend().