Blender
V3.3
|
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>
Classes | |
struct | ComputeStageLayout |
struct | FragOut |
struct | GeometryStageLayout |
struct | Image |
struct | PushConst |
struct | Resource |
struct | Sampler |
struct | StorageBuf |
struct | UniformBuf |
struct | VertIn |
Public Types | |
using | Self = ShaderCreateInfo |
Public Member Functions | |
ShaderCreateInfo (const char *name) | |
~ShaderCreateInfo () | |
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=-1, 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) |
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, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS) |
Self & | sampler (int slot, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS, eGPUSamplerState sampler=(eGPUSamplerState) -1) |
Shader Source | |
Self & | vertex_source (StringRefNull filename) |
Self & | geometry_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 & | legacy_resource_location (bool value) |
Additional Create Info | |
Used to share parts of the infos that are common to many shaders. | |
Self & | additional_info (StringRefNull info_name0, StringRefNull info_name1="", StringRefNull info_name2="", StringRefNull info_name3="", StringRefNull info_name4="", StringRefNull info_name5="", StringRefNull info_name6="") |
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) |
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 () |
std::string | check_error () const |
void | validate_merge (const ShaderCreateInfo &other_info) |
void | validate_vertex_attributes (const ShaderCreateInfo *other_info=nullptr) |
Operators. | |
bool | operator== (const ShaderCreateInfo &b) |
bool | has_resource_type (Resource::BindType bind_type) const |
bool | has_resource_image () const |
bool | has_resource_storage () 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 276 of file gpu_shader_create_info.hh.
Definition at line 497 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 494 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 495 of file gpu_shader_create_info.hh.
|
inline |
Definition at line 743 of file gpu_shader_create_info.hh.
References additional_infos_.
Referenced by eevee_shader_material_create_info_amend(), GPUCodegen::GPUCodegen(), and blender::eevee::ShaderModule::material_create_info_ammend().
Definition at line 723 of file gpu_shader_create_info.hh.
References auto_resource_location_.
Referenced by eevee_shader_material_create_info_amend(), and blender::eevee::ShaderModule::material_create_info_ammend().
|
inline |
Definition at line 710 of file gpu_shader_create_info.hh.
References builtins_.
Referenced by eevee_shader_material_create_info_amend(), and blender::eevee::ShaderModule::material_create_info_ammend().
std::string blender::gpu::shader::ShaderCreateInfo::check_error | ( | ) | const |
Definition at line 142 of file gpu_shader_create_info.cc.
References compute_source_, error(), fragment_source_, geometry_source_, blender::StringRefBase::is_empty(), name_, and vertex_source_.
Referenced by GPU_shader_create_from_info(), and GPU_shader_create_info_check_error().
|
inline |
Definition at line 662 of file gpu_shader_create_info.hh.
References compute_source_.
|
inline |
Definition at line 692 of file gpu_shader_create_info.hh.
References defines_.
Referenced by createGPUShader(), eevee_shader_material_create_info_amend(), GPUCodegen::generate_resources(), and blender::eevee::ShaderModule::material_create_info_ammend().
|
inline |
Definition at line 717 of file gpu_shader_create_info.hh.
References depth_write_.
Definition at line 704 of file gpu_shader_create_info.hh.
References do_static_compilation_.
Force fragment tests before fragment shader invocation. IMPORTANT: This is incompatible with using the gl_FragDepth output.
Definition at line 546 of file gpu_shader_create_info.hh.
References early_fragment_test_.
void blender::gpu::shader::ShaderCreateInfo::finalize | ( | ) |
Definition at line 34 of file gpu_shader_create_info.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), additional_infos_, blender::gpu::shader::ANY, auto_resource_location_, batch_resources_, BLI_assert, compute_layout_, compute_source_, defines_, depth_write_, early_fragment_test_, error(), finalized_, fragment_outputs_, fragment_source_, geometry_layout_, geometry_out_interfaces_, geometry_source_, gpu_shader_create_info_get(), interface_names_size_, blender::StringRefBase::is_empty(), blender::gpu::shader::ShaderCreateInfo::ComputeStageLayout::local_size_x, name_, pass_resources_, push_constants_, typedef_sources_, validate_merge(), validate_vertex_attributes(), vertex_inputs_, vertex_out_interfaces_, and vertex_source_.
|
inline |
Definition at line 564 of file gpu_shader_create_info.hh.
References blend(), fragment_outputs_, and type.
Referenced by createGPUShader(), and pygpu_shader_info_fragment_out().
|
inline |
Definition at line 656 of file gpu_shader_create_info.hh.
References fragment_source_.
Referenced by createGPUShader(), eevee_shader_material_create_info_amend(), and pygpu_shader_info_fragment_source().
|
inline |
IMPORTANT: invocations count is only used if GL_ARB_gpu_shader5 is supported. On implementations that do not supports it, the max_vertices will be multiplied by invocations. Your shader needs to account for this fact. Use #ifdef GPU_ARB_gpu_shader5
and make a code path that does not rely on #gl_InvocationID.
Definition at line 522 of file gpu_shader_create_info.hh.
References geometry_layout_, blender::gpu::shader::ShaderCreateInfo::GeometryStageLayout::invocations, blender::gpu::shader::ShaderCreateInfo::GeometryStageLayout::max_vertices, blender::gpu::shader::ShaderCreateInfo::GeometryStageLayout::primitive_in, and blender::gpu::shader::ShaderCreateInfo::GeometryStageLayout::primitive_out.
Referenced by eevee_shader_material_create_info_amend().
|
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 558 of file gpu_shader_create_info.hh.
References geometry_out_interfaces_.
|
inline |
Definition at line 650 of file gpu_shader_create_info.hh.
References geometry_source_.
Referenced by eevee_shader_material_create_info_amend().
|
inline |
Definition at line 890 of file gpu_shader_create_info.hh.
References has_resource_type().
|
inline |
Definition at line 895 of file gpu_shader_create_info.hh.
References has_resource_type().
|
inline |
Definition at line 875 of file gpu_shader_create_info.hh.
References batch_resources_, and pass_resources_.
Referenced by has_resource_image(), and has_resource_storage().
|
inline |
Definition at line 604 of file gpu_shader_create_info.hh.
References batch_resources_, blender::gpu::shader::ShaderCreateInfo::Image::format, blender::gpu::shader::ShaderCreateInfo::Resource::image, interface_names_size_, blender::gpu::shader::ShaderCreateInfo::Image::name, blender::gpu::shader::PASS, pass_resources_, blender::gpu::shader::ShaderCreateInfo::Image::qualifiers, blender::StringRefBase::size(), type, and blender::gpu::shader::ShaderCreateInfo::Image::type.
Definition at line 729 of file gpu_shader_create_info.hh.
References legacy_resource_location_.
Referenced by eevee_shader_material_create_info_amend().
|
inline |
Definition at line 534 of file gpu_shader_create_info.hh.
References compute_layout_, blender::gpu::shader::ShaderCreateInfo::ComputeStageLayout::local_size_x, blender::gpu::shader::ShaderCreateInfo::ComputeStageLayout::local_size_y, and blender::gpu::shader::ShaderCreateInfo::ComputeStageLayout::local_size_z.
|
inline |
Definition at line 816 of file gpu_shader_create_info.hh.
References additional_infos_, usdtokens::b(), batch_resources_, builtins_, compute_layout_, compute_source_, defines_, fragment_outputs_, fragment_source_, fragment_source_generated, geometry_layout_, geometry_out_interfaces_, geometry_source_, pass_resources_, push_constants_, TEST_EQUAL, TEST_VECTOR_EQUAL, typedef_source_generated, typedef_sources_, vertex_inputs_, vertex_out_interfaces_, vertex_source_, and vertex_source_generated.
|
inline |
Definition at line 676 of file gpu_shader_create_info.hh.
References BLI_assert_msg, blender::StringRefBase::find(), interface_names_size_, push_constants_, blender::StringRefBase::size(), and type.
Referenced by createGPUShader(), and pygpu_shader_info_push_constant().
|
inline |
Definition at line 621 of file gpu_shader_create_info.hh.
References batch_resources_, interface_names_size_, blender::gpu::shader::ShaderCreateInfo::Sampler::name, blender::gpu::shader::PASS, pass_resources_, blender::gpu::shader::ShaderCreateInfo::Resource::sampler, blender::StringRefBase::size(), type, blender::gpu::shader::ShaderCreateInfo::Sampler::type, and UNUSED_VARS.
Referenced by createGPUShader(), eevee_shader_material_create_info_amend(), GPUCodegen::generate_resources(), blender::eevee::ShaderModule::material_create_info_ammend(), and pygpu_shader_info_sampler().
|
inline |
Definition at line 589 of file gpu_shader_create_info.hh.
References batch_resources_, interface_names_size_, blender::gpu::shader::ShaderCreateInfo::StorageBuf::name, blender::gpu::shader::PASS, pass_resources_, blender::gpu::shader::ShaderCreateInfo::StorageBuf::qualifiers, blender::StringRefBase::size(), blender::gpu::shader::ShaderCreateInfo::Resource::storagebuf, and blender::gpu::shader::ShaderCreateInfo::StorageBuf::type_name.
|
inline |
Definition at line 783 of file gpu_shader_create_info.hh.
References typedef_sources_.
Referenced by createGPUShader(), and pygpu_shader_info_typedef_source().
|
inline |
Definition at line 576 of file gpu_shader_create_info.hh.
References batch_resources_, interface_names_size_, blender::gpu::shader::ShaderCreateInfo::UniformBuf::name, blender::gpu::shader::PASS, pass_resources_, blender::StringRefBase::size(), blender::gpu::shader::ShaderCreateInfo::UniformBuf::type_name, and blender::gpu::shader::ShaderCreateInfo::Resource::uniformbuf.
Referenced by createGPUShader(), GPUCodegen::generate_resources(), and pygpu_shader_info_uniform_buf().
void blender::gpu::shader::ShaderCreateInfo::validate_merge | ( | const ShaderCreateInfo & | other_info | ) |
Error detection that some backend compilers do not complain about.
Definition at line 170 of file gpu_shader_create_info.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), auto_resource_location_, batch_resources_, name_, and pass_resources_.
Referenced by finalize().
void blender::gpu::shader::ShaderCreateInfo::validate_vertex_attributes | ( | const ShaderCreateInfo * | other_info = nullptr | ) |
Definition at line 228 of file gpu_shader_create_info.cc.
References BLI_assert, blender::gpu::shader::MAT4, name_, and vertex_inputs_.
Referenced by finalize().
|
inline |
Definition at line 503 of file gpu_shader_create_info.hh.
References interface_names_size_, blender::StringRefBase::size(), type, and vertex_inputs_.
Referenced by createGPUShader(), GPUCodegen::generate_attribs(), and pygpu_shader_info_vertex_in().
|
inline |
Definition at line 510 of file gpu_shader_create_info.hh.
References vertex_out_interfaces_.
Referenced by createGPUShader(), eevee_shader_material_create_info_amend(), GPUCodegen::generate_attribs(), and pygpu_shader_info_vertex_out().
|
inline |
Definition at line 644 of file gpu_shader_create_info.hh.
References vertex_source_.
Referenced by createGPUShader(), eevee_shader_material_create_info_amend(), and pygpu_shader_info_vertex_source().
|
friend |
Debug print
Definition at line 842 of file gpu_shader_create_info.hh.
Vector<StringRefNull> blender::gpu::shader::ShaderCreateInfo::additional_infos_ |
Name of other infos to recursively merge with this one. No data slot must overlap otherwise we throw an error.
Definition at line 491 of file gpu_shader_create_info.hh.
Referenced by additional_info(), finalize(), and operator==().
bool blender::gpu::shader::ShaderCreateInfo::auto_resource_location_ = false |
If true, all resources will have an automatic location assigned.
Definition at line 284 of file gpu_shader_create_info.hh.
Referenced by auto_resource_location(), finalize(), and validate_merge().
Definition at line 460 of file gpu_shader_create_info.hh.
Referenced by finalize(), blender::gpu::GLShaderInterface::GLShaderInterface(), has_resource_type(), image(), operator==(), blender::gpu::GLShader::resources_declare(), sampler(), storage_buf(), uniform_buf(), and validate_merge().
BuiltinBits blender::gpu::shader::ShaderCreateInfo::builtins_ = BuiltinBits::NONE |
Manually set builtins.
Definition at line 297 of file gpu_shader_create_info.hh.
Referenced by builtins(), blender::gpu::GLShader::fragment_interface_declare(), operator==(), and blender::gpu::GLShader::vertex_interface_declare().
ComputeStageLayout blender::gpu::shader::ShaderCreateInfo::compute_layout_ |
Definition at line 363 of file gpu_shader_create_info.hh.
Referenced by blender::gpu::GLShader::compute_layout_declare(), finalize(), local_group_size(), and operator==().
StringRefNull blender::gpu::shader::ShaderCreateInfo::compute_source_ |
Definition at line 484 of file gpu_shader_create_info.hh.
Referenced by check_error(), compute_source(), finalize(), GPU_shader_create_from_info(), and operator==().
Vector<std::array<StringRefNull, 2> > blender::gpu::shader::ShaderCreateInfo::defines_ |
Definition at line 486 of file gpu_shader_create_info.hh.
Referenced by define(), blender::gpu::Shader::defines_declare(), finalize(), and operator==().
Vector<const char *, 0> blender::gpu::shader::ShaderCreateInfo::dependencies_generated |
Manually set generated dependencies.
Definition at line 304 of file gpu_shader_create_info.hh.
Referenced by GPUCodegen::generate_library().
DepthWrite blender::gpu::shader::ShaderCreateInfo::depth_write_ = DepthWrite::ANY |
Allow optimization when fragment shader writes to gl_FragDepth
.
Definition at line 290 of file gpu_shader_create_info.hh.
Referenced by depth_write(), finalize(), and blender::gpu::GLShader::fragment_interface_declare().
bool blender::gpu::shader::ShaderCreateInfo::do_static_compilation_ = false |
True if the shader is static and can be pre-compiled at compile time.
Definition at line 280 of file gpu_shader_create_info.hh.
Referenced by do_static_compilation(), and GPU_shader_create_from_info_name().
bool blender::gpu::shader::ShaderCreateInfo::early_fragment_test_ = false |
If true, force depth and stencil tests to always happen before fragment shader invocation.
Definition at line 286 of file gpu_shader_create_info.hh.
Referenced by early_fragment_test(), finalize(), and blender::gpu::GLShader::fragment_interface_declare().
bool blender::gpu::shader::ShaderCreateInfo::finalized_ = false |
If true, all additionally linked create info will be merged into this one.
Definition at line 282 of file gpu_shader_create_info.hh.
Referenced by finalize().
Definition at line 380 of file gpu_shader_create_info.hh.
Referenced by finalize(), blender::gpu::GLShader::fragment_interface_declare(), fragment_out(), and operator==().
StringRefNull blender::gpu::shader::ShaderCreateInfo::fragment_source_ |
Definition at line 484 of file gpu_shader_create_info.hh.
Referenced by check_error(), finalize(), fragment_source(), GPU_shader_create_from_info(), and operator==().
std::string blender::gpu::shader::ShaderCreateInfo::fragment_source_generated = "" |
Definition at line 300 of file gpu_shader_create_info.hh.
Referenced by createGPUShader(), eevee_shader_material_create_info_amend(), blender::eevee::ShaderModule::material_create_info_ammend(), operator==(), and pygpu_shader_info_fragment_source().
GeometryStageLayout blender::gpu::shader::ShaderCreateInfo::geometry_layout_ |
Definition at line 348 of file gpu_shader_create_info.hh.
Referenced by finalize(), geometry_layout(), blender::gpu::GLShader::geometry_layout_declare(), and operator==().
Vector<StageInterfaceInfo *> blender::gpu::shader::ShaderCreateInfo::geometry_out_interfaces_ |
Definition at line 463 of file gpu_shader_create_info.hh.
Referenced by finalize(), blender::gpu::GLShader::fragment_interface_declare(), blender::gpu::GLShader::geometry_interface_declare(), geometry_out(), and operator==().
StringRefNull blender::gpu::shader::ShaderCreateInfo::geometry_source_ |
Definition at line 484 of file gpu_shader_create_info.hh.
Referenced by check_error(), finalize(), blender::gpu::GLShader::fragment_interface_declare(), geometry_source(), gpu_pass_shader_validate(), GPU_shader_create_from_info(), and operator==().
std::string blender::gpu::shader::ShaderCreateInfo::geometry_source_generated = "" |
Definition at line 301 of file gpu_shader_create_info.hh.
Referenced by eevee_shader_material_create_info_amend().
size_t blender::gpu::shader::ShaderCreateInfo::interface_names_size_ = 0 |
Maximum length of all the resource names including each null terminator. Only for names used by gpu::ShaderInterface.
Definition at line 295 of file gpu_shader_create_info.hh.
Referenced by finalize(), blender::gpu::GLShaderInterface::GLShaderInterface(), image(), push_constant(), sampler(), storage_buf(), uniform_buf(), and vertex_in().
bool blender::gpu::shader::ShaderCreateInfo::legacy_resource_location_ = false |
If true, force the use of the GL shader introspection for resource location.
Definition at line 288 of file gpu_shader_create_info.hh.
Referenced by blender::gpu::GLShader::finalize(), GPU_shader_create_from_info(), and legacy_resource_location().
StringRefNull blender::gpu::shader::ShaderCreateInfo::name_ |
Shader name for debugging.
Definition at line 278 of file gpu_shader_create_info.hh.
Referenced by check_error(), finalize(), GPU_pass_compile(), GPU_shader_create_from_info(), GPU_shader_create_from_info_name(), validate_merge(), and validate_vertex_attributes().
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). Mis-usage will only produce suboptimal performance.
Definition at line 460 of file gpu_shader_create_info.hh.
Referenced by count_active_texture_sampler(), finalize(), blender::gpu::GLShaderInterface::GLShaderInterface(), has_resource_type(), image(), operator==(), blender::gpu::GLShader::resources_declare(), sampler(), storage_buf(), uniform_buf(), and validate_merge().
Definition at line 479 of file gpu_shader_create_info.hh.
Referenced by constants_calc_size(), finalize(), blender::gpu::GLShaderInterface::GLShaderInterface(), operator==(), push_constant(), and blender::gpu::GLShader::resources_declare().
std::string blender::gpu::shader::ShaderCreateInfo::typedef_source_generated = "" |
Definition at line 302 of file gpu_shader_create_info.hh.
Referenced by createGPUShader(), eevee_shader_material_create_info_amend(), GPUCodegen::generate_resources(), GPU_shader_create_from_info(), operator==(), and pygpu_shader_info_typedef_source().
Vector<StringRefNull> blender::gpu::shader::ShaderCreateInfo::typedef_sources_ |
Definition at line 482 of file gpu_shader_create_info.hh.
Referenced by finalize(), GPU_shader_create_from_info(), operator==(), pygpu_shader_info_typedef_source(), and typedef_source().
Definition at line 330 of file gpu_shader_create_info.hh.
Referenced by eevee_shader_material_create_info_amend(), finalize(), blender::gpu::GLShaderInterface::GLShaderInterface(), blender::eevee::ShaderModule::material_create_info_ammend(), operator==(), validate_vertex_attributes(), vertex_in(), and blender::gpu::GLShader::vertex_interface_declare().
Vector<StageInterfaceInfo *> blender::gpu::shader::ShaderCreateInfo::vertex_out_interfaces_ |
Definition at line 462 of file gpu_shader_create_info.hh.
Referenced by eevee_shader_material_create_info_amend(), finalize(), blender::gpu::GLShader::fragment_interface_declare(), blender::gpu::GLShader::geometry_interface_declare(), blender::eevee::ShaderModule::material_create_info_ammend(), operator==(), blender::gpu::GLShader::vertex_interface_declare(), and vertex_out().
StringRefNull blender::gpu::shader::ShaderCreateInfo::vertex_source_ |
Definition at line 484 of file gpu_shader_create_info.hh.
Referenced by check_error(), finalize(), GPU_shader_create_from_info(), operator==(), and vertex_source().
std::string blender::gpu::shader::ShaderCreateInfo::vertex_source_generated = "" |
Manually set generated code.
Definition at line 299 of file gpu_shader_create_info.hh.
Referenced by eevee_shader_material_create_info_amend(), blender::eevee::ShaderModule::material_create_info_ammend(), operator==(), and pygpu_shader_info_vertex_source().