26#include <fmt/format.h>
27#include <fmt/ranges.h>
49 return "noperspective";
96 case TextureFormat::UINT_8_8_8_8:
98 case TextureFormat::SINT_8_8_8_8:
100 case TextureFormat::UNORM_8_8_8_8:
102 case TextureFormat::UINT_32_32_32_32:
104 case TextureFormat::SINT_32_32_32_32:
106 case TextureFormat::SFLOAT_32_32_32_32:
108 case TextureFormat::UINT_16_16_16_16:
110 case TextureFormat::SINT_16_16_16_16:
112 case TextureFormat::SFLOAT_16_16_16_16:
114 case TextureFormat::UNORM_16_16_16_16:
116 case TextureFormat::UINT_8_8:
118 case TextureFormat::SINT_8_8:
120 case TextureFormat::UNORM_8_8:
122 case TextureFormat::UINT_32_32:
124 case TextureFormat::SINT_32_32:
126 case TextureFormat::SFLOAT_32_32:
128 case TextureFormat::UINT_16_16:
130 case TextureFormat::SINT_16_16:
132 case TextureFormat::SFLOAT_16_16:
134 case TextureFormat::UNORM_16_16:
136 case TextureFormat::UINT_8:
138 case TextureFormat::SINT_8:
140 case TextureFormat::UNORM_8:
142 case TextureFormat::UINT_32:
144 case TextureFormat::SINT_32:
146 case TextureFormat::SFLOAT_32:
148 case TextureFormat::UINT_16:
150 case TextureFormat::SINT_16:
152 case TextureFormat::SFLOAT_16:
154 case TextureFormat::UNORM_16:
156 case TextureFormat::UFLOAT_11_11_10:
157 return "r11f_g11f_b10f";
158 case TextureFormat::UNORM_10_10_10_2:
173 return "lines_adjacency";
177 return "triangles_adjacency";
191 return "triangle_strip";
203 return "depth_greater";
207 return "depth_unchanged";
216 case ImageType::IntBuffer:
217 case ImageType::Int1D:
218 case ImageType::Int1DArray:
219 case ImageType::Int2D:
220 case ImageType::Int2DArray:
221 case ImageType::Int3D:
222 case ImageType::IntCube:
223 case ImageType::IntCubeArray:
224 case ImageType::AtomicInt2D:
225 case ImageType::AtomicInt2DArray:
226 case ImageType::AtomicInt3D:
229 case ImageType::UintBuffer:
230 case ImageType::Uint1D:
231 case ImageType::Uint1DArray:
232 case ImageType::Uint2D:
233 case ImageType::Uint2DArray:
234 case ImageType::Uint3D:
235 case ImageType::UintCube:
236 case ImageType::UintCubeArray:
237 case ImageType::AtomicUint2D:
238 case ImageType::AtomicUint2DArray:
239 case ImageType::AtomicUint3D:
254 case ImageType::FloatBuffer:
255 case ImageType::IntBuffer:
256 case ImageType::UintBuffer:
259 case ImageType::Float1D:
260 case ImageType::Float1DArray:
261 case ImageType::Int1D:
262 case ImageType::Int1DArray:
263 case ImageType::Uint1D:
264 case ImageType::Uint1DArray:
267 case ImageType::Float2D:
268 case ImageType::Float2DArray:
269 case ImageType::Int2D:
270 case ImageType::Int2DArray:
271 case ImageType::Uint2D:
272 case ImageType::Uint2DArray:
273 case ImageType::Shadow2D:
274 case ImageType::Shadow2DArray:
275 case ImageType::Depth2D:
276 case ImageType::Depth2DArray:
277 case ImageType::AtomicInt2D:
278 case ImageType::AtomicInt2DArray:
279 case ImageType::AtomicUint2D:
280 case ImageType::AtomicUint2DArray:
283 case ImageType::Float3D:
284 case ImageType::Int3D:
285 case ImageType::AtomicInt3D:
286 case ImageType::Uint3D:
287 case ImageType::AtomicUint3D:
290 case ImageType::FloatCube:
291 case ImageType::FloatCubeArray:
292 case ImageType::IntCube:
293 case ImageType::IntCubeArray:
294 case ImageType::UintCube:
295 case ImageType::UintCubeArray:
296 case ImageType::ShadowCube:
297 case ImageType::ShadowCubeArray:
298 case ImageType::DepthCube:
299 case ImageType::DepthCubeArray:
307 case ImageType::Float1DArray:
308 case ImageType::Float2DArray:
309 case ImageType::FloatCubeArray:
310 case ImageType::Int1DArray:
311 case ImageType::Int2DArray:
312 case ImageType::IntCubeArray:
313 case ImageType::Uint1DArray:
314 case ImageType::Uint2DArray:
315 case ImageType::UintCubeArray:
316 case ImageType::Shadow2DArray:
317 case ImageType::ShadowCubeArray:
318 case ImageType::Depth2DArray:
319 case ImageType::DepthCubeArray:
320 case ImageType::AtomicUint2DArray:
328 case ImageType::Shadow2D:
329 case ImageType::Shadow2DArray:
330 case ImageType::ShadowCube:
331 case ImageType::ShadowCubeArray:
359 os <<
"layout(binding = " <<
uint32_t(location);
361 os <<
", " <<
to_string(res.image.format);
375 os << res.sampler.name <<
";";
381 os << res.image.name <<
";";
384 os <<
"uniform _" << res.uniformbuf.name.str_no_array() <<
" { " << res.uniformbuf.type_name
385 <<
" " << res.uniformbuf.name <<
"; };";
389 os <<
"buffer _" << res.storagebuf.name.str_no_array() <<
" { " << res.storagebuf.type_name
390 <<
" " << res.storagebuf.name <<
"; };";
393 os <<
"uniform accelerationStructureEXT " << res.acceleration_structure.name <<
";";
415 os <<
"\n#define CREATE_INFO_RES_" << res_frequency <<
"_" << res.
info_name <<
" \\\n";
433 const std::string &prefix,
439 os <<
"layout(location=" << location <<
") " << prefix <<
" " <<
to_string(
inout.interp) <<
" "
446 const std::string &prefix,
451 std::string struct_name = prefix + iface.
name;
454 os <<
"struct " << struct_name <<
" {\n";
459 os <<
"layout(location=" << location <<
") " << prefix <<
" " <<
to_string(qualifier) <<
" "
460 << struct_name <<
" " << iface.
instance_name << suffix <<
";\n";
468 const std::string &prefix,
484 std::stringstream ss;
487 ss <<
"void main_function_();\n";
489 ss <<
"void main() {\n";
491 ss <<
" main_function_();\n";
495 ss <<
"#define main main_function_\n";
502 return fmt::to_string(fmt::join(sources,
""));
513 vk_interface->
init(info);
514 interface = vk_interface;
517 max_input_attachment_index_ = 0;
535 vk_descriptor_set_layout_ = VK_NULL_HANDLE;
539 shaderc_shader_kind stage,
544 std::string source_patch;
547 case shaderc_vertex_shader:
550 case shaderc_geometry_shader:
553 case shaderc_fragment_shader:
556 case shaderc_compute_shader:
560 BLI_assert_msg(0,
"Only forced ShaderC shader kinds are supported.");
573 build_shader_module(sources, shaderc_vertex_shader,
vertex_module);
579 build_shader_module(sources, shaderc_geometry_shader,
geometry_module);
585 build_shader_module(sources, shaderc_fragment_shader,
fragment_module);
591 build_shader_module(sources, shaderc_compute_shader,
compute_module);
603 if (info ==
nullptr) {
607 if (do_geometry_shader_injection(info)) {
608 std::string source = workaround_geometry_shader_source_create(*info);
610 sources.append(
"version");
611 sources.append(source);
617 if (!finalize_descriptor_set_layouts(device, vk_interface)) {
620 if (!finalize_pipeline_layout(device, vk_interface)) {
640 if (is_compute_shader_) {
652bool VKShader::finalize_shader_module(
VKShaderModule &shader_module,
const char *stage_name)
656 shaderc_compilation_status_null_result_object,
657 shaderc_compilation_status_success);
668 std::string full_name = std::string(
name) +
"_" + stage_name;
669 shader_module.
finalize(full_name.c_str());
675 return compilation_succeeded;
678bool VKShader::finalize_pipeline_layout(
VKDevice &device,
681 const uint32_t layout_count = vk_descriptor_set_layout_ == VK_NULL_HANDLE ? 0 : 1;
682 VkPipelineLayoutCreateInfo pipeline_info = {};
683 VkPushConstantRange push_constant_range = {};
684 pipeline_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
685 pipeline_info.flags = 0;
686 pipeline_info.setLayoutCount = layout_count;
687 pipeline_info.pSetLayouts = &vk_descriptor_set_layout_;
690 const VKPushConstants::Layout &push_constants_layout =
693 push_constant_range.offset = 0;
694 push_constant_range.size = push_constants_layout.
size_in_bytes();
695 push_constant_range.stageFlags = is_compute_shader_ ? VK_SHADER_STAGE_COMPUTE_BIT :
696 VK_SHADER_STAGE_ALL_GRAPHICS;
697 pipeline_info.pushConstantRangeCount = 1;
698 pipeline_info.pPushConstantRanges = &push_constant_range;
701 if (device.
functions.vkCreatePipelineLayout(
712bool VKShader::finalize_descriptor_set_layouts(
VKDevice &vk_device,
724 BLI_assert(vk_descriptor_set_layout_ == VK_NULL_HANDLE);
727 return vk_descriptor_set_layout_ != VK_NULL_HANDLE;
734 context->specialization_constants_set(constants_state);
755 std::stringstream ss;
757 ss <<
"\n#line " << __LINE__ <<
" \"" << __FILE__ <<
"\"\n";
760 uint constant_id = 0;
762 ss <<
"layout (constant_id=" << constant_id++ <<
") const ";
765 ss <<
"int " << sc.
name <<
"=" << std::to_string(sc.
value.i) <<
";\n";
768 ss <<
"uint " << sc.
name <<
"=" << std::to_string(sc.
value.u) <<
"u;\n";
771 ss <<
"bool " << sc.
name <<
"=" << (sc.
value.u ?
"true" :
"false") <<
";\n";
776 ss <<
"uint " << sc.
name <<
"_uint=" << std::to_string(sc.
value.u) <<
"u;\n";
777 ss <<
"#define " << sc.
name <<
" uintBitsToFloat(" << sc.
name <<
"_uint)\n";
790 ss <<
"int " << sc.
name <<
"=" << std::to_string(sc.
value.i) <<
";\n";
793 ss <<
"uint " << sc.
name <<
"=" << std::to_string(sc.
value.u) <<
"u;\n";
796 ss <<
"bool " << sc.
name <<
"=" << (sc.
value.u ?
"true" :
"false") <<
";\n";
808 ss <<
"\n#define CREATE_INFO_RES_SHARED_VARS_" << sv.
info_name <<
" \\\n";
825 print_resource(ss, vk_interface, res, info,
"BATCH", active_info);
832 print_resource(ss, vk_interface, res, info,
"GEOMETRY", active_info);
843 ss <<
"layout(push_constant, std430) uniform constants\n";
847 <<
", std140) uniform constants\n";
853 ss <<
"[" <<
uniform.array_size <<
"]";
866 std::stringstream ss;
867 std::string pre_main;
868 std::string post_main;
875 ss <<
"layout(location = " << attr.
index <<
") ";
885 ss <<
"layout(location=" << location <<
") out float vk_ClipDistance[6];\n";
886 pre_main +=
"#define gl_ClipDistance vk_ClipDistance\n";
890 const bool has_geometry_stage = do_geometry_shader_injection(&info) ||
895 if (has_geometry_stage) {
896 if (do_layer_output) {
897 ss <<
"layout(location=" << (location++) <<
") out int gpu_Layer;\n ";
899 if (do_viewport_output) {
900 ss <<
"layout(location=" << (location++) <<
") out int gpu_ViewportIndex;\n";
904 if (do_layer_output) {
905 ss <<
"#define gpu_Layer gl_Layer\n";
907 if (do_viewport_output) {
908 ss <<
"#define gpu_ViewportIndex gl_ViewportIndex\n";
915 const bool retarget_depth = !has_geometry_stage;
916 if (retarget_depth) {
917 post_main +=
"gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n";
920 if (!pre_main.empty() || !post_main.empty()) {
975 std::stringstream ss;
976 std::string pre_main;
981 pre_main +=
" for (int i = 0; i < 6; i++) {\n";
982 pre_main +=
" if (vk_ClipDistance[i] < 0.0) { discard; }\n";
995 ss <<
"layout(location=" << location <<
") in float vk_ClipDistance[6];\n";
1000 ss <<
"#define gpu_Layer gl_Layer\n";
1003 ss <<
"#define gpu_ViewportIndex gl_ViewportIndex\n";
1009 ss <<
"layout(location=" << (location++) <<
") smooth in vec3 gpu_BaryCoord;\n";
1010 ss <<
"layout(location=" << (location++) <<
") noperspective in vec3 gpu_BaryCoordNoPersp;\n";
1014 ss <<
"layout(early_fragment_tests) in;\n";
1018 if (use_gl_frag_depth) {
1026 if (use_local_read) {
1027 uint32_t subpass_input_binding_index = 0;
1029 std::string input_attachment_name =
"gpu_input_attachment_";
1030 input_attachment_name += std::to_string(input.
index);
1037 switch (component_type) {
1048 ss <<
"layout(input_attachment_index = " << (input.
index)
1049 <<
", binding = " << (subpass_input_binding_index++) <<
") uniform " << typePrefix
1050 <<
"subpassInput " << input_attachment_name <<
"; \n";
1052 std::stringstream ss_pre;
1053 static const std::string swizzle =
"xyzw";
1055 ss_pre <<
" " << input.
name <<
" = " << input.
type <<
"( subpassLoad("
1059 pre_main += ss_pre.str();
1064 std::string image_name =
"gpu_subpass_img_";
1065 image_name += std::to_string(input.
index);
1073 bool is_layered_input =
ELEM(
1074 input.
img_type, ImageType::Uint2DArray, ImageType::Int2DArray, ImageType::Float2DArray);
1079 Resource res(info, Resource::BindType::SAMPLER, input.
index,
nullptr);
1081 res.sampler.name = image_name;
1084 char swizzle[] =
"xyzw";
1087 std::string texel_co = (is_layered_input) ?
1088 ((is_layered_fb) ?
"ivec3(gl_FragCoord.xy, gpu_Layer)" :
1092 "ivec3(gl_FragCoord.xy, 0)") :
1093 "ivec2(gl_FragCoord.xy)";
1095 std::stringstream ss_pre;
1097 ss_pre <<
" " << input.
name <<
" = texelFetch(" << image_name <<
", " << texel_co <<
", 0)."
1098 << swizzle <<
";\n";
1100 pre_main += ss_pre.str();
1106 const int location = output.index;
1107 ss <<
"layout(location = " << location;
1108 switch (output.blend) {
1109 case DualBlend::SRC_0:
1110 ss <<
", index = 0";
1112 case DualBlend::SRC_1:
1113 ss <<
", index = 1";
1123 if (pre_main.empty() ==
false) {
1124 std::string post_main;
1125 ss << main_function_wrapper(pre_main, post_main);
1133 for (
auto [iface, cond] : ifaces) {
1134 if (iface->instance_name == name) {
1143 ss <<
"void gpu_EmitVertex() {\n";
1144 ss <<
" gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n";
1145 ss <<
" EmitVertex();\n";
1154 std::stringstream ss;
1157 if (invocations != -1) {
1158 ss <<
", invocations = " << invocations;
1163 <<
", max_vertices = " << max_verts <<
") out;\n";
1170 std::stringstream ss;
1177 const char *suffix = (has_matching_output_iface) ?
"_in[]" :
"[]";
1186 const char *suffix = (has_matching_input_iface) ?
"_out" :
"";
1198 std::stringstream ss;
1214std::string VKShader::workaround_geometry_shader_source_create(
1217 std::stringstream ss;
1250 if (do_clip_distance_workaround) {
1251 ss <<
"layout(location=" << location <<
") in float vk_ClipDistance_in[][6];\n";
1252 ss <<
"layout(location=" << location <<
") out float vk_ClipDistance[6];\n";
1256 int location_in = location;
1257 int location_out = location;
1258 if (do_layer_output) {
1259 ss <<
"layout(location=" << (location_in++) <<
") in int gpu_Layer[];\n";
1261 if (do_viewport_output) {
1262 ss <<
"layout(location=" << (location_in++) <<
") in int gpu_ViewportIndex[];\n";
1264 if (do_barycentric_workaround) {
1265 ss <<
"layout(location=" << (location_out++) <<
") smooth out vec3 gpu_BaryCoord;\n";
1266 ss <<
"layout(location=" << (location_out++)
1267 <<
") noperspective out vec3 gpu_BaryCoordNoPersp;\n";
1271 ss <<
"void main()\n";
1278 const char *out_suffix = (has_matching_output_iface) ?
"_out" :
"";
1279 const char *in_suffix = (has_matching_output_iface) ?
"_in" :
"";
1281 for (
const StageInterfaceInfo::InOut &
inout : iface->
inouts) {
1282 ss <<
inout.name << out_suffix <<
" = " <<
inout.name << in_suffix <<
"[" << i <<
"];\n";
1286 for (
const StageInterfaceInfo::InOut &
inout : iface->
inouts) {
1293 if (do_barycentric_workaround) {
1294 ss <<
" gpu_BaryCoordNoPersp = gpu_BaryCoord =";
1295 ss <<
" vec3(" << int(i == 0) <<
", " << int(i == 1) <<
", " << int(i == 2) <<
");\n";
1297 if (do_clip_distance_workaround) {
1298 ss <<
" vk_ClipDistance = vk_ClipDistance_in[" << i <<
"];\n";
1300 ss <<
" gl_Position = gl_in[" << i <<
"].gl_Position;\n";
1301 if (do_layer_output) {
1302 ss <<
" gl_Layer = gpu_Layer[" << i <<
"];\n";
1304 if (do_viewport_output) {
1305 ss <<
" gl_ViewportIndex = gpu_ViewportIndex[" << i <<
"];\n";
1307 ss <<
" gpu_EmitVertex();\n";
1318 flag_is_set(builtins, BuiltinBits::BARYCENTRIC_COORD))
1322 if (flag_is_set(builtins, BuiltinBits::LAYER) ||
1323 flag_is_set(builtins, BuiltinBits::VIEWPORT_INDEX))
1343 if (constants_state.
values.is_empty() && vk_pipeline_base_ != VK_NULL_HANDLE) {
1344 return vk_pipeline_base_;
1355 compute_info, is_static_shader_, vk_pipeline_base_,
name_get());
1356 if (vk_pipeline_base_ == VK_NULL_HANDLE) {
1357 vk_pipeline_base_ = vk_pipeline;
1395 pipeline_state.specialization_constants_);
1407 pipeline_state.depth_format_);
1409 pipeline_state.stencil_format_);
1417 bool pipeline_created =
false;
1419 graphics_info, is_static_shader_, vk_pipeline_base_,
name_get(), pipeline_created);
1420 has_precompiled_pipelines_ =
true;
1422 if (vk_pipeline == VK_NULL_HANDLE) {
1425 if (vk_pipeline_base_ == VK_NULL_HANDLE) {
1426 vk_pipeline_base_ = vk_pipeline;
1446 "GPU_PRIM_POINTS is used with a shader that doesn't set point size before "
1447 "drawing fragments. Calling code should be adapted to use a shader that sets the "
1448 "gl_PointSize before entering the fragment stage. For example `GPU_SHADER_3D_POINT_*`.");
1461 vertex_input_description_key;
1475 graphics_info.
shaders.
has_depth = depth_attachment_format != VK_FORMAT_UNDEFINED;
1476 graphics_info.
shaders.
has_stencil = stencil_attachment_format != VK_FORMAT_UNDEFINED;
1497 const bool use_static_cache = is_static_shader_ &&
1499 bool pipeline_created =
false;
1501 graphics_info, use_static_cache, vk_pipeline_base_,
name_get(), pipeline_created);
1505 if (has_precompiled_pipelines_ && pipeline_created) {
1512 "Pipeline states were compiled for `%s`, however a pipeline state triggered a new "
1513 "pipeline compilation.",
1520 BLI_assert(!context.debug_pipeline_creation);
1524 if (vk_pipeline_base_ == VK_NULL_HANDLE) {
1525 vk_pipeline_base_ = vk_pipeline;
1533 "Interface can be accessed after the VKShader has been initialized "
1534 "`VKShader::init`");
#define CLOG_DEBUG(clg_ref,...)
#define CLOG_INFO(clg_ref,...)
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
#define BLI_assert_msg(a, msg)
constexpr IndexRange()=default
constexpr bool is_empty() const
constexpr int64_t find(char c, int64_t pos=0) const
std::unique_ptr< const shader::SpecializationConstants > constants
ShaderInterface * interface
StringRefNull name_get() const
void print_log(Span< StringRefNull > sources, const char *log, const char *stage, bool error, GPULogParser *parser)
VkDescriptorSetLayout get_or_create(const VKDescriptorSetLayoutInfo &info, bool &r_created, bool &r_needed)
VKDescriptorSetLayouts & descriptor_set_layouts_get()
VkDevice vk_handle() const
const VKExtensions & extensions_get() const
VolkDeviceTable functions
std::string glsl_compute_patch_get(bool use_ray_query) const
const VKWorkarounds & workarounds_get() const
std::string glsl_vertex_patch_get(bool use_ray_query) const
std::string glsl_geometry_patch_get() const
std::string glsl_fragment_patch_get(bool use_ray_query) const
static VKDiscardPool & discard_pool_get()
void discard_pipeline_layout(VkPipelineLayout vk_pipeline_layout)
VkFormat stencil_attachment_format_get() const
uint32_t viewport_size() const
VkFormat depth_attachment_format_get() const
void vk_viewports_append(Vector< VkViewport, GPU_MAX_VIEWPORTS > &r_viewports) const
void vk_render_areas_append(Vector< VkRect2D, GPU_MAX_VIEWPORTS > &r_render_areas) const
Span< VkFormat > color_attachment_formats_get() const
Get color attachment formats in used by the framebuffer.
VkPipeline get_or_create_compute_pipeline(const VKComputeInfo &compute_info, bool is_static_shader, VkPipeline vk_pipeline_base, StringRefNull name)
void discard(VKDiscardPool &discard_pool, VkPipelineLayout vk_pipeline_layout)
VkPipeline get_or_create_graphics_pipeline(const VKGraphicsInfo &graphics_info, bool is_static_shader, VkPipeline vk_pipeline_base, StringRefNull name, bool &r_created)
void push_constant_set(int32_t location, int32_t comp_len, int32_t array_size, const T *input_data)
static bool compile_module(VKShader &shader, shaderc_shader_kind stage, VKShaderModule &shader_module)
const VKPushConstants::Layout & push_constants_layout_get() const
VKDescriptorSet::Location descriptor_set_location(const shader::ShaderCreateInfo::Resource &resource) const
const VKDescriptorSetLayoutInfo & descriptor_set_layout_info_get() const
VKShaderInterface()=default
void init(const shader::ShaderCreateInfo &info)
std::string original_sources
shaderc::SpvCompilationResult compilation_result
VkShaderModule vk_shader_module
std::string combined_sources
void finalize(StringRefNull name)
Vector< uint32_t > spirv_binary
void fragment_shader_from_glsl(const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
VKShaderModule compute_module
std::string fragment_interface_declare(const shader::ShaderCreateInfo &info) const override
VkPipeline ensure_and_get_compute_pipeline(const shader::SpecializationConstants &constants_state)
VKShaderModule fragment_module
std::string geometry_interface_declare(const shader::ShaderCreateInfo &info) const override
void warm_cache(int limit) override
VKPushConstants push_constants
std::string resources_declare(const shader::ShaderCreateInfo &info) const override
void geometry_shader_from_glsl(const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
std::string compute_layout_declare(const shader::ShaderCreateInfo &info) const override
VkPipelineLayout vk_pipeline_layout
bool ensure_graphics_pipelines(Span< shader::PipelineState > pipeline_states)
void vertex_shader_from_glsl(const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
void uniform_int(int location, int comp_len, int array_size, const int *data) override
void compute_shader_from_glsl(const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
VKShader(const char *name)
VKShaderModule vertex_module
void bind(const shader::SpecializationConstants *constants_state) override
VKShaderModule geometry_module
std::string geometry_layout_declare(const shader::ShaderCreateInfo &info) const override
bool finalize_post(Span< shader::PipelineState > pipeline_states)
void uniform_float(int location, int comp_len, int array_size, const float *data) override
const VKShaderInterface & interface_get() const
VkPipeline ensure_and_get_graphics_pipeline(GPUPrimType primitive, VKVertexInputDescriptionPool::Key vertex_input_description_key, VKStateManager &state_manager, const VKFrameBuffer &framebuffer, shader::SpecializationConstants &constants_state)
void init(const shader::ShaderCreateInfo &info, bool is_codegen_only) override
bool finalize(const shader::ShaderCreateInfo *info=nullptr) override
std::string vertex_interface_declare(const shader::ShaderCreateInfo &info) const override
#define SOURCES_INDEX_VERSION
ccl_device_inline float interp(const float a, const float b, const float t)
void object_label(GLenum type, GLuint object, const char *name)
BLI_INLINE int to_component_count(const Type &type)
static void print_image_type(std::ostream &os, const ImageType &type, const ShaderCreateInfo::Resource::BindType bind_type)
const char * to_string(ShaderStage stage)
int get_location_count(const Type &type)
static StageInterfaceInfo * find_interface_by_name(const Span< ShaderCreateInfo::StageInterfaceInfoHandle > ifaces, const StringRefNull name)
static void print_interface_as_attributes(std::ostream &os, const std::string &prefix, const StageInterfaceInfo &iface, int &location, const StringRefNull &suffix)
VkFormat to_vk_format(const TextureFormat format)
static void print_interface(std::ostream &os, const std::string &prefix, const StageInterfaceInfo &iface, int &location, const StringRefNull &suffix="")
static void print_resource(std::ostream &os, const VKDescriptorSet::Location location, const ShaderCreateInfo::Resource &res, const ShaderCreateInfo &)
static std::string combine_sources(Span< StringRefNull > sources)
static std::ostream & print_qualifier(std::ostream &os, const Qualifier &qualifiers)
static Type to_component_type(const Type &type)
static void print_interface_as_struct(std::ostream &os, const std::string &prefix, const StageInterfaceInfo &iface, int &location, const StringRefNull &suffix)
static std::string main_function_wrapper(std::string &pre_main, std::string &post_main)
VkPrimitiveTopology to_vk_primitive_topology(const GPUPrimType prim_type)
static StringRefNull to_component_type(ImageType type)
static void declare_emit_vertex(std::stringstream &ss)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool assign_if_different(T &old_value, T &&new_value)
MINLINE uint max_uu(uint a, uint b)
BMesh const char void * data
Vector< shader::SpecializationConstant::Value > specialization_constants
VkShaderModule vk_shader_module
VkPipelineLayout vk_pipeline_layout
bool extended_dynamic_state
bool fragment_shader_barycentric
bool shader_clip_distance
bool dynamic_rendering_local_read
bool shader_viewport_index_layer
bool vertex_input_dynamic_state
VkFormat stencil_attachment_format
Vector< VkFormat, GPU_FB_MAX_COLOR_ATTACHMENT > color_attachment_formats
VkFormat depth_attachment_format
VkShaderModule vk_geometry_module
uint32_t color_attachment_count
VkShaderModule vk_vertex_module
Vector< VkRect2D, GPU_MAX_VIEWPORTS > scissors
Vector< VkViewport, GPU_MAX_VIEWPORTS > viewports
VkPrimitiveTopology vk_topology
VkPipelineLayout vk_pipeline_layout
VkShaderModule vk_fragment_module
uint32_t max_input_attachment_index
Vector< shader::SpecializationConstant::Value > specialization_constants
VKVertexInputDescriptionPool::Key vertex_input_key
VkPrimitiveTopology vk_topology
std::string pipeline_info_source() const
uint32_t size_in_bytes() const
VKDescriptorSet::Location descriptor_set_location_get() const
StorageType storage_type_get() const
bool static_viewport_scissor
Description of a graphical pipeline to pre-compile during shader creation.
PrimitiveOut primitive_out
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
StringRefNull compute_source_
Vector< Resource, 0 > geometry_resources_
Self & geometry_layout(PrimitiveIn prim_in, PrimitiveOut prim_out, int max_vertices, int invocations=-1)
Vector< SpecializationConstant, 0 > specialization_constants_
Vector< CompilationConstant, 0 > compilation_constants_
bool early_fragment_test_
Vector< VertIn, 0 > vertex_inputs_
Vector< StageInterfaceInfoHandle, 0 > geometry_out_interfaces_
Vector< StageInterfaceInfoHandle, 0 > vertex_out_interfaces_
Vector< Resource, 0 > pass_resources_
Vector< PushConst, 0 > push_constants_
StringRefNull geometry_source_
GeometryStageLayout geometry_layout_
StringRefNull fragment_source_
Vector< SubpassIn, 0 > subpass_inputs_
Vector< Resource, 0 > batch_resources_
Vector< SharedVariable, 0 > shared_variables_
bool do_static_compilation_
ComputeStageLayout compute_layout_
Vector< PipelineState, 0 > pipelines_
std::string compute_source_generated
Vector< FragOut, 0 > fragment_outputs_
BuiltinBits builtins_combined() const
Vector< SpecializationConstant::Value, 8 > values
StringRefNull instance_name
#define NOT_YET_IMPLEMENTED