24 #ifndef GPU_SHADER_CREATE_INFO
26 # define GPU_SHADER_INTERFACE_INFO(_interface, _inst_name) \
27 StageInterfaceInfo _interface(#_interface, _inst_name); \
29 # define GPU_SHADER_CREATE_INFO(_info) \
30 ShaderCreateInfo _info(#_info); \
69 BLI_assert_msg(0,
"Error: Cannot convert eGPUType to shader::Type.");
78 return stream <<
"float";
80 return stream <<
"vec2";
82 return stream <<
"vec3";
84 return stream <<
"vec4";
86 return stream <<
"mat3";
88 return stream <<
"mat4";
99 return stream <<
"Closure";
252 return *(
Self *)
this;
258 return *(
Self *)
this;
264 return *(
Self *)
this;
306 #define TEST_EQUAL(a, b, _member) \
307 if (!((a)._member == (b)._member)) { \
311 #define TEST_VECTOR_EQUAL(a, b, _vector) \
312 TEST_EQUAL(a, b, _vector.size()); \
313 for (auto i : _vector.index_range()) { \
314 TEST_EQUAL(a, b, _vector[i]); \
507 return *(
Self *)
this;
513 return *(
Self *)
this;
525 int invocations = -1)
531 return *(
Self *)
this;
539 return *(
Self *)
this;
549 return *(
Self *)
this;
561 return *(
Self *)
this;
567 return *(
Self *)
this;
581 Resource res(Resource::BindType::UNIFORM_BUFFER, slot);
586 return *(
Self *)
this;
595 Resource res(Resource::BindType::STORAGE_BUFFER, slot);
601 return *(
Self *)
this;
611 Resource res(Resource::BindType::IMAGE, slot);
618 return *(
Self *)
this;
627 Resource res(Resource::BindType::SAMPLER, slot);
635 return *(
Self *)
this;
647 return *(
Self *)
this;
653 return *(
Self *)
this;
659 return *(
Self *)
this;
665 return *(
Self *)
this;
679 "Array syntax is forbidden for push constants."
680 "Use the array_size parameter instead.");
683 return *(
Self *)
this;
695 return *(
Self *)
this;
707 return *(
Self *)
this;
713 return *(
Self *)
this;
720 return *(
Self *)
this;
726 return *(
Self *)
this;
732 return *(
Self *)
this;
752 if (!info_name1.is_empty()) {
755 if (!info_name2.is_empty()) {
758 if (!info_name3.is_empty()) {
761 if (!info_name4.is_empty()) {
764 if (!info_name5.is_empty()) {
767 if (!info_name6.is_empty()) {
770 return *(
Self *)
this;
786 return *(
Self *)
this;
847 switch (res.bind_type) {
848 case Resource::BindType::UNIFORM_BUFFER:
849 stream <<
"UNIFORM_BUFFER(" << res.slot <<
", " << res.uniformbuf.name <<
")"
852 case Resource::BindType::STORAGE_BUFFER:
853 stream <<
"STORAGE_BUFFER(" << res.slot <<
", " << res.storagebuf.name <<
")"
856 case Resource::BindType::SAMPLER:
857 stream <<
"SAMPLER(" << res.slot <<
", " << res.sampler.name <<
")" << std::endl;
859 case Resource::BindType::IMAGE:
860 stream <<
"IMAGE(" << res.slot <<
", " << res.image.name <<
")" << std::endl;
878 if (res.bind_type == bind_type) {
883 if (res.bind_type == bind_type) {
903 #undef TEST_VECTOR_EQUAL
#define BLI_assert_msg(a, msg)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
constexpr int64_t find(char c, int64_t pos=0) const
constexpr int64_t size() const
static void print_resource(std::ostream &os, const ShaderCreateInfo::Resource &res)
#define TEST_VECTOR_EQUAL(a, b, _vector)
#define TEST_EQUAL(a, b, _member)
static Type to_type(const eGPUType type)
static std::ostream & operator<<(std::ostream &stream, const Type type)
ENUM_OPERATORS(BuiltinBits, BuiltinBits::WORK_GROUP_SIZE)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
bool operator==(const ComputeStageLayout &b)
bool operator==(const FragOut &b)
PrimitiveOut primitive_out
bool operator==(const GeometryStageLayout &b)
bool operator==(const PushConst &b)
bool operator==(const Resource &b)
Resource(BindType type, int _slot)
bool operator==(const VertIn &b)
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
Self & typedef_source(StringRefNull filename)
Self & auto_resource_location(bool value)
StringRefNull vertex_source_
Vector< StageInterfaceInfo * > vertex_out_interfaces_
Self & depth_write(DepthWrite value)
StringRefNull compute_source_
ShaderCreateInfo(const char *name)
Self & uniform_buf(int slot, StringRefNull type_name, StringRefNull name, Frequency freq=Frequency::PASS)
Self & sampler(int slot, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS, eGPUSamplerState sampler=(eGPUSamplerState) -1)
bool has_resource_image() const
std::string fragment_source_generated
Vector< std::array< StringRefNull, 2 > > defines_
Self & geometry_source(StringRefNull filename)
void validate_vertex_attributes(const ShaderCreateInfo *other_info=nullptr)
std::string check_error() const
Vector< VertIn > vertex_inputs_
bool early_fragment_test_
Self & fragment_source(StringRefNull filename)
bool auto_resource_location_
Self & builtins(BuiltinBits builtin)
Self & geometry_out(StageInterfaceInfo &interface)
Vector< Resource > batch_resources_
Self & storage_buf(int slot, Qualifier qualifiers, StringRefNull type_name, StringRefNull name, Frequency freq=Frequency::PASS)
Self & additional_info(StringRefNull info_name0, StringRefNull info_name1="", StringRefNull info_name2="", StringRefNull info_name3="", StringRefNull info_name4="", StringRefNull info_name5="", StringRefNull info_name6="")
size_t interface_names_size_
friend std::ostream & operator<<(std::ostream &stream, const ShaderCreateInfo &info)
Vector< StringRefNull > additional_infos_
Self & do_static_compilation(bool value)
Self & local_group_size(int local_size_x=-1, int local_size_y=-1, int local_size_z=-1)
StringRefNull geometry_source_
std::string vertex_source_generated
Vector< StageInterfaceInfo * > geometry_out_interfaces_
Self & compute_source(StringRefNull filename)
Vector< Resource > pass_resources_
Self & vertex_in(int slot, Type type, StringRefNull name)
std::string typedef_source_generated
bool has_resource_type(Resource::BindType bind_type) const
Self & vertex_out(StageInterfaceInfo &interface)
Vector< const char *, 0 > dependencies_generated
bool legacy_resource_location_
Self & early_fragment_test(bool enable)
Self & push_constant(Type type, StringRefNull name, int array_size=0)
GeometryStageLayout geometry_layout_
StringRefNull fragment_source_
Self & legacy_resource_location(bool value)
Self & define(StringRefNull name, StringRefNull value="")
bool operator==(const ShaderCreateInfo &b)
bool do_static_compilation_
ComputeStageLayout compute_layout_
Self & vertex_source(StringRefNull filename)
std::string geometry_source_generated
Self & geometry_layout(PrimitiveIn prim_in, PrimitiveOut prim_out, int max_vertices, int invocations=-1)
void validate_merge(const ShaderCreateInfo &other_info)
bool has_resource_storage() const
Self & image(int slot, eGPUTextureFormat format, Qualifier qualifiers, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS)
Vector< StringRefNull > typedef_sources_
Vector< PushConst > push_constants_
Vector< FragOut > fragment_outputs_
Self & fragment_out(int slot, Type type, StringRefNull name, DualBlend blend=DualBlend::NONE)
Self & no_perspective(Type type, StringRefNull _name)
StageInterfaceInfo(const char *name_, const char *instance_name_)
StringRefNull instance_name
Self & smooth(Type type, StringRefNull _name)
Self & flat(Type type, StringRefNull _name)
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)