26#define GPU_FORCE_ENABLE_SHADER_PRINTF 0
28#if !defined(NDEBUG) || GPU_FORCE_ENABLE_SHADER_PRINTF
29# define GPU_SHADER_PRINTF_ENABLE 1
31# define GPU_SHADER_PRINTF_ENABLE 0
33#define GPU_SHADER_PRINTF_SLOT 13
34#define GPU_SHADER_PRINTF_MAX_CAPACITY (1024 * 4)
37#define GPU_SSBO_INDEX_BUF_SLOT 7
42#ifndef GPU_SHADER_CREATE_INFO
43# define GPU_SHADER_INTERFACE_INFO(_interface, _inst_name) \
44 StageInterfaceInfo _interface(#_interface, _inst_name); \
46# define GPU_SHADER_CREATE_INFO(_info) \
47 ShaderCreateInfo _info(#_info); \
68 BLI_assert_msg(0,
"Error: Cannot convert eGPUType to shader::Type.");
77 return stream <<
"float";
79 return stream <<
"vec2";
81 return stream <<
"vec3";
83 return stream <<
"vec4";
85 return stream <<
"mat3";
87 return stream <<
"mat4";
89 return stream <<
"vec3_1010102_Inorm";
91 return stream <<
"uchar";
93 return stream <<
"uchar2";
95 return stream <<
"uchar3";
97 return stream <<
"uchar4";
99 return stream <<
"char";
101 return stream <<
"char2";
103 return stream <<
"char3";
105 return stream <<
"char4";
107 return stream <<
"int";
109 return stream <<
"ivec2";
111 return stream <<
"ivec3";
113 return stream <<
"ivec4";
115 return stream <<
"uint";
117 return stream <<
"uvec2";
119 return stream <<
"uvec3";
121 return stream <<
"uvec4";
123 return stream <<
"ushort";
125 return stream <<
"ushort2";
127 return stream <<
"ushort3";
129 return stream <<
"ushort4";
131 return stream <<
"short";
133 return stream <<
"short2";
135 return stream <<
"short3";
137 return stream <<
"short4";
139 return stream <<
"bool";
150 return stream <<
"Closure";
152 return stream <<
to_type(type);
338 return *(
Self *)
this;
344 return *(
Self *)
this;
350 return *(
Self *)
this;
396#define TEST_EQUAL(a, b, _member) \
397 if (!((a)._member == (b)._member)) { \
401#define TEST_VECTOR_EQUAL(a, b, _vector) \
402 TEST_EQUAL(a, b, _vector.size()); \
403 for (auto i : _vector.index_range()) { \
404 TEST_EQUAL(a, b, _vector[i]); \
582 return all_resources;
621#ifdef WITH_METAL_BACKEND
622 ushort mtl_max_threads_per_threadgroup_ = 0;
639 return *(
Self *)
this;
645 return *(
Self *)
this;
651 int invocations = -1)
657 return *(
Self *)
this;
665 return *(
Self *)
this;
675 return *(
Self *)
this;
687 return *(
Self *)
this;
694 int raster_order_group = -1)
697 return *(
Self *)
this;
717 return *(
Self *)
this;
751 constant.
type = type;
752 constant.
name = name;
755 constant.
value.
i =
static_cast<int>(default_value);
759 constant.
value.
u =
static_cast<uint>(default_value);
762 constant.
value.
f =
static_cast<float>(default_value);
770 return *(
Self *)
this;
793 return *(
Self *)
this;
808 return *(
Self *)
this;
825 return *(
Self *)
this;
842 return *(
Self *)
this;
854 return *(
Self *)
this;
860 return *(
Self *)
this;
866 return *(
Self *)
this;
872 return *(
Self *)
this;
888 "Array syntax is forbidden for push constants."
889 "Use the array_size parameter instead.");
892 return *(
Self *)
this;
904 return *(
Self *)
this;
916 return *(
Self *)
this;
922 return *(
Self *)
this;
929 return *(
Self *)
this;
935 return *(
Self *)
this;
941 return *(
Self *)
this;
947 return *(
Self *)
this;
961 return *(
Self *)
this;
968 return *(
Self *)
this;
984 return *(
Self *)
this;
999 return *(
Self *)
this;
1006 return *(
Self *)
this;
1023#ifdef WITH_METAL_BACKEND
1024 mtl_max_threads_per_threadgroup_ = max_total_threads_per_threadgroup;
1028 return *(
Self *)
this;
1043 void finalize(
const bool recursive =
false);
1095 switch (res.bind_type) {
1097 stream <<
"UNIFORM_BUFFER(" << res.slot <<
", " << res.uniformbuf.name <<
")"
1101 stream <<
"STORAGE_BUFFER(" << res.slot <<
", " << res.storagebuf.name <<
")"
1105 stream <<
"SAMPLER(" << res.slot <<
", " << res.sampler.name <<
")" << std::endl;
1108 stream <<
"IMAGE(" << res.slot <<
", " << res.image.name <<
")" << std::endl;
1129 if (res.bind_type == bind_type) {
1134 if (res.bind_type == bind_type) {
1139 if (res.bind_type == bind_type) {
1154#undef TEST_VECTOR_EQUAL
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
#define ENUM_OPERATORS(_type, _max)
constexpr int64_t size() const
void append(const T &value)
void extend(Span< T > array)
local_group_size(16, 16) .push_constant(Type b
#define TEST_VECTOR_EQUAL(a, b, _vector)
#define TEST_EQUAL(a, b, _member)
static std::ostream & operator<<(std::ostream &stream, const Type type)
static Type to_type(const eGPUType type)
static void print_resource(std::ostream &os, const ShaderCreateInfo::Resource &res)
unsigned __int64 uint64_t
static constexpr GPUSamplerState internal_sampler()
uint64_t operator()(const Vector< blender::gpu::shader::SpecializationConstant::Value > &key) const
bool operator==(const ComputeStageLayout &b) const
bool operator==(const FragOut &b) const
bool operator==(const GeometryStageLayout &b) const
PrimitiveOut primitive_out
bool operator==(const PushConst &b) const
bool operator==(const Resource &b) const
Resource(BindType type, int _slot)
bool operator==(const VertIn &b) const
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
Self & legacy_resource_location(bool value)
StringRefNull vertex_source_
Vector< StageInterfaceInfo * > vertex_out_interfaces_
Self & image(int slot, eGPUTextureFormat format, Qualifier qualifiers, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS)
StringRefNull compute_source_
Vector< SubpassIn > subpass_inputs_
ShaderCreateInfo(const char *name)
Self & mtl_max_total_threads_per_threadgroup(ushort max_total_threads_per_threadgroup)
Self & compute_source(StringRefNull filename)
Vector< Resource > geometry_resources_
bool has_resource_image() const
Self & do_static_compilation(bool value)
Self & geometry_layout(PrimitiveIn prim_in, PrimitiveOut prim_out, int max_vertices, int invocations=-1)
Self & fragment_source(StringRefNull filename)
std::string fragment_source_generated
Self & depth_write(DepthWrite value)
Vector< std::array< StringRefNull, 2 > > defines_
void validate_vertex_attributes(const ShaderCreateInfo *other_info=nullptr)
Vector< const char * > tf_names_
Self & metal_backend_only(bool flag)
Vector< Resource > & resources_get_(Frequency freq)
Self & vertex_in(int slot, Type type, StringRefNull name)
Self & builtins(BuiltinBits builtin)
std::string check_error() const
Vector< VertIn > vertex_inputs_
bool early_fragment_test_
bool auto_resource_location_
Self & auto_resource_location(bool value)
void finalize(const bool recursive=false)
Vector< Resource > batch_resources_
Self & push_constant(Type type, StringRefNull name, int array_size=0)
bool is_vulkan_compatible() const
Self & geometry_out(StageInterfaceInfo &interface)
size_t interface_names_size_
Self & transform_feedback_mode(eGPUShaderTFBType tf_mode)
bool operator==(const ShaderCreateInfo &b) const
Vector< StringRefNull > additional_infos_
Self & additional_info(StringRefNull info_name)
Self & typedef_source(StringRefNull filename)
Self & fragment_out(int slot, Type type, StringRefNull name, DualBlend blend=DualBlend::NONE, int raster_order_group=-1)
StringRefNull geometry_source_
Self & local_group_size(int local_size_x=-1, int local_size_y=-1, int local_size_z=-1)
std::string vertex_source_generated
Self & vertex_out(StageInterfaceInfo &interface)
Vector< StageInterfaceInfo * > geometry_out_interfaces_
Self & storage_buf(int slot, Qualifier qualifiers, StringRefNull type_name, StringRefNull name, Frequency freq=Frequency::PASS)
Vector< Resource > pass_resources_
Self & geometry_source(StringRefNull filename)
std::string typedef_source_generated
bool has_resource_type(Resource::BindType bind_type) const
Vector< const char *, 0 > dependencies_generated
Vector< Resource > resources_get_all_() const
bool legacy_resource_location_
Self & vertex_source(StringRefNull filename)
GeometryStageLayout geometry_layout_
StringRefNull fragment_source_
Self & transform_feedback_output_name(const char *name)
Self & sampler(int slot, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS, GPUSamplerState sampler=GPUSamplerState::internal_sampler())
bool do_static_compilation_
ComputeStageLayout compute_layout_
Self & additional_info(StringRefNull info_name, Args... args)
Self & uniform_buf(int slot, StringRefNull type_name, StringRefNull name, Frequency freq=Frequency::PASS)
Self & subpass_in(int slot, Type type, StringRefNull name, int raster_order_group=-1)
std::string compute_source_generated
Self & specialization_constant(Type type, StringRefNull name, double default_value)
eGPUShaderTFBType tf_type_
friend std::ostream & operator<<(std::ostream &stream, const ShaderCreateInfo &info)
std::string geometry_source_generated
void validate_merge(const ShaderCreateInfo &other_info)
Self & early_fragment_test(bool enable)
Self & define(StringRefNull name, StringRefNull value="")
Vector< SpecializationConstant > specialization_constants_
Vector< StringRefNull > typedef_sources_
Vector< PushConst > push_constants_
Vector< FragOut > fragment_outputs_
Self & smooth(Type type, StringRefNull _name)
StageInterfaceInfo(const char *name_, const char *instance_name_)
Self & no_perspective(Type type, StringRefNull _name)
StringRefNull instance_name
Self & flat(Type type, StringRefNull _name)