15 std::string res_condition_lambda;
18 res_condition_lambda =
", [](blender::Span<CompilationConstant> constants) { ";
20 res_condition_lambda +=
"}";
25 ss <<
"ADDITIONAL_INFO(" <<
var_name <<
")";
27 else if (
res_type ==
"legacy_iface") {
28 ss <<
"VERTEX_OUT(" <<
var_type <<
"_t)";
30 else if (
res_type ==
"resource_table") {
32 ss <<
".additional_info_with_condition(\"" <<
var_type <<
"\"" << res_condition_lambda
36 ss <<
".additional_info(\"" <<
var_type <<
"\")";
44 ss << res_condition_lambda <<
")";
48 ss <<
", blender::gpu::TextureFormat::" <<
res_format;
50 ss <<
", ImageReadWriteType::" <<
var_type;
53 ss << res_condition_lambda <<
")";
60 ss << res_condition_lambda <<
")";
68 ss << res_condition_lambda <<
")";
70 else if (
res_type ==
"acceleration_structure") {
71 ss <<
".acceleration_structure(" <<
res_slot;
74 ss << res_condition_lambda <<
")";
79 else if (
res_type ==
"push_constant") {
86 << res_condition_lambda <<
")";
89 else if (
res_type ==
"compilation_constant") {
96 else if (
res_type ==
"specialization_constant") {
104 std::stringstream ss;
119 std::stringstream ss;
120 ss <<
"GPU_SHADER_INTERFACE_INFO(" <<
name <<
"_t)\n";
122 for (
const auto &res : *
this) {
123 ss << res.serialize() <<
"\n";
126 ss <<
"GPU_SHADER_INTERFACE_END()\n";
132 std::stringstream ss;
149 std::stringstream ss;
157 std::stringstream ss;
158 ss <<
"GPU_SHADER_CREATE_INFO(" <<
name <<
")\n";
160 for (
const auto &res : *
this) {
161 ss << res.serialize() <<
"\n";
164 ss <<
"GPU_SHADER_CREATE_END()\n";
170 std::stringstream ss;
171 ss <<
"GPU_SHADER_CREATE_INFO(" <<
name <<
")\n";
173 for (
const auto &res : *
this) {
174 ss << res.serialize() <<
"\n";
177 ss <<
"GPU_SHADER_CREATE_END()\n";
183 std::string res_condition_lambda;
186 res_condition_lambda =
", [](blender::Span<CompilationConstant> constants) { ";
188 res_condition_lambda +=
"}";
191 std::stringstream ss;
193 << res_condition_lambda <<
")";
199 std::stringstream ss;
200 ss <<
"GPU_SHADER_CREATE_INFO(" <<
name <<
")\n";
202 for (
const auto &res : *
this) {
203 ss << res.serialize() <<
"\n";
206 ss <<
"GPU_SHADER_CREATE_END()\n";
249 return "sampler1DArray";
251 return "sampler2DArray";
259 return "KernelGlobals";
261 return "ShadingData";
268 std::stringstream ss;
269 ss <<
"static void " << function_name
270 <<
"(GPUSource &source, GPUFunctionDictionary *g_functions, GPUPrintFormatMap *g_formats) "
274 ss <<
" Vector<metadata::ArgumentFormat> args = {\n";
275 for (
auto arg : function.arguments) {
277 <<
"metadata::ArgumentFormat{"
278 <<
"metadata::Qualifier::" <<
enum_to_string(arg.qualifier) <<
", "
283 ss <<
" source.add_function(\"" << function.name <<
"\", args, g_functions);\n";
287 ss <<
" source.add_builtin(metadata::Builtin(" << std::to_string(
builtin) <<
"LLU));\n";
290 ss <<
" source.add_dependency(\"" << dependency <<
"\");\n";
293 ss <<
" source.add_shared_variable(Type::" << var.type <<
"_t, \"" << var.name <<
"\");\n";
296 ss <<
" source.add_printf_format(uint32_t(" << std::to_string(format.hash) <<
"), "
297 << format.format <<
", g_formats);\n";
300 ss <<
" UNUSED_VARS(source, g_functions, g_formats);\n";
307 std::stringstream ss;
308 ss <<
"#pragma once\n";
311 ss <<
"#include \"" << dependency <<
"\"\n";
327 ss << vert_inputs.serialize() <<
"\n";
331 ss << frag_outputs.serialize() <<
"\n";
334 ss << frag_inputs.serialize() <<
"\n";
338 ss << iface.serialize() <<
"\n";
342 ss <<
"GPU_SHADER_CREATE_INFO(" << res_table.name <<
")\n";
344 if (res_table.empty()) {
346 ss <<
"DEFINE(\"EMPTY_CREATE_INFO\")\n";
348 for (
const auto &res : res_table) {
349 ss << res.serialize() <<
"\n";
351 ss <<
"GPU_SHADER_CREATE_END()\n";
355 ss << declaration <<
"\n";