Blender V5.3
draw_pass.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
42
43#include "BLI_assert.hh"
45#include "BLI_vector.hh"
46
47#include "BKE_image.hh"
48#include "BKE_image_gpu.hh"
49
50#include "GPU_batch.hh"
51#include "GPU_debug.hh"
52#include "GPU_index_buffer.hh"
53#include "GPU_material.hh"
54#include "GPU_pass.hh"
55#include "GPU_ray_tracing.hh"
56
57#include "DRW_gpu_wrapper.hh"
58
59#include "draw_command.hh"
60#include "draw_handle.hh"
61#include "draw_manager.hh"
62#include "draw_shader_shared.hh"
63#include "draw_state.hh"
64
65#include <cstdint>
66#include <sstream>
67
68namespace blender::draw {
69using namespace blender::draw;
70using namespace blender::draw::command;
71
74
75class Manager;
76
77namespace command {
78class DrawCommandBuf;
79}
80
81/* -------------------------------------------------------------------- */
84
85namespace detail {
86
90template<typename T,
92 int64_t block_size = 16>
94 private:
96
97 public:
98 void clear()
99 {
100 blocks_.clear();
101 }
102
104 {
105 /* Do not go over the inline size so that existing members never move. */
106 if (blocks_.is_empty() || blocks_.last()->size() == block_size) {
107 blocks_.append(std::make_unique<Vector<T, block_size>>());
108 }
109 return blocks_.last()->append_and_get_index(std::move(elem)) +
110 (blocks_.size() - 1) * block_size;
111 }
112
114 {
115 return (*blocks_[index / block_size])[index % block_size];
116 }
117
118 const T &operator[](int64_t index) const
119 {
120 return (*blocks_[index / block_size])[index % block_size];
121 }
122};
123
127template<
129 typename DrawCommandBufType>
130class PassBase {
131 friend Manager;
132 friend DrawCommandBuf;
133
135 static constexpr GPUSamplerState sampler_auto = GPUSamplerState::internal_sampler();
136
137 protected:
143 DrawCommandBufType &draw_commands_buf_;
148
151
152 bool is_empty_ = true;
153
154 public:
155 const char *debug_name;
156
158
159 PassBase(const char *name,
160 DrawCommandBufType &draw_command_buf,
162 gpu::Shader *shader = nullptr)
163 : draw_commands_buf_(draw_command_buf),
164 sub_passes_(sub_passes),
166 debug_name(name),
168
174 void init();
175
179 bool is_empty() const;
180
184 PassBase<DrawCommandBufType> &sub(const char *name);
185
196 void state_set(DRWState state, int clip_plane_count = 0);
197
202 void clear_depth(float depth);
203 void clear_stencil(uint8_t stencil);
204 void clear_depth_stencil(float depth, uint8_t stencil);
205 void clear_color_depth_stencil(float4 color, float depth, uint8_t stencil);
210 void clear_multi(Span<double4> colors);
211
224 void state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask);
225
230
236 void framebuffer_set(gpu::FrameBuffer **framebuffer);
237
243 void subpass_transition(GPUAttachmentState depth_attachment,
244 Span<GPUAttachmentState> color_attachments);
245
251 void material_set(Manager &manager,
252 GPUMaterial *material,
253 bool deferred_texture_loading = false,
254 GPUSamplerFiltering anisotropic_filtering = GPU_SAMPLER_FILTERING_DEFAULT);
255
261 void draw(gpu::Batch *batch,
262 uint instance_len = -1,
263 uint vertex_len = -1,
264 uint vertex_first = -1,
265 ResourceIDRange res_id = {},
266 uint custom_id = 0);
267
272 void draw(gpu::Batch *batch, ResourceIDRange res_id, uint custom_id = 0);
273
278 void draw_procedural(GPUPrimType primitive,
279 uint instance_len,
280 uint vertex_len,
281 uint vertex_first = -1,
282 ResourceIDRange res_id = {},
283 uint custom_id = 0);
284
298 void draw_expand(gpu::Batch *batch,
299 GPUPrimType primitive_type,
300 uint primitive_len,
301 uint instance_len,
302 uint vertex_len,
303 uint vertex_first,
304 ResourceIDRange res_id = {},
305 uint custom_id = 0);
306
311 void draw_expand(gpu::Batch *batch,
312 GPUPrimType primitive_type,
313 uint primitive_len,
314 uint instance_len,
315 ResourceIDRange res_id = {},
316 uint custom_id = 0);
317
322 void draw_indirect(gpu::Batch *batch,
323 StorageBuffer<DrawCommand, true> &indirect_buffer,
324 ResourceID res_id = {0});
326 StorageBuffer<DrawCommand, true> &indirect_buffer,
327 ResourceID res_id = {0});
328
332 void dispatch(int group_len);
333 void dispatch(int2 group_len);
334 void dispatch(int3 group_len);
335 void dispatch(int3 *group_len);
336 void dispatch(StorageBuffer<DispatchCommand> &indirect_buffer);
337
341 void barrier(GPUBarrier type);
342
355 void bind_image(const char *name, gpu::Texture *image);
356 void bind_image(const char *name, gpu::Texture **image);
357 void bind_image(int slot, gpu::Texture *image);
358 void bind_image(int slot, gpu::Texture **image);
359 void bind_texture(const char *name, gpu::Texture *texture, GPUSamplerState state = sampler_auto);
360 void bind_texture(const char *name,
361 gpu::Texture **texture,
362 GPUSamplerState state = sampler_auto);
363 void bind_texture(const char *name, gpu::VertBuf *buffer);
364 void bind_texture(const char *name, gpu::VertBuf **buffer);
365 void bind_texture(const char *name, gpu::VertBufPtr &buffer);
366 void bind_texture(int slot, gpu::Texture *texture, GPUSamplerState state = sampler_auto);
367 void bind_texture(int slot, gpu::Texture **texture, GPUSamplerState state = sampler_auto);
368 void bind_texture(int slot, gpu::VertBuf *buffer);
369 void bind_texture(int slot, gpu::VertBuf **buffer);
370 void bind_texture(int slot, gpu::VertBufPtr &buffer);
371 void bind_ssbo(const char *name, gpu::StorageBuf *buffer);
372 void bind_ssbo(const char *name, gpu::StorageBuf **buffer);
373 void bind_ssbo(int slot, gpu::StorageBuf *buffer);
374 void bind_ssbo(int slot, gpu::StorageBuf **buffer);
375 void bind_ssbo(const char *name, gpu::UniformBuf *buffer);
376 void bind_ssbo(const char *name, gpu::UniformBuf **buffer);
377 void bind_ssbo(int slot, gpu::UniformBuf *buffer);
378 void bind_ssbo(int slot, gpu::UniformBuf **buffer);
379 void bind_ssbo(const char *name, gpu::VertBuf *buffer);
380 void bind_ssbo(const char *name, gpu::VertBuf **buffer);
381 void bind_ssbo(const char *name, gpu::VertBufPtr &buffer);
382 void bind_ssbo(int slot, gpu::VertBuf *buffer);
383 void bind_ssbo(int slot, gpu::VertBuf **buffer);
384 void bind_ssbo(int slot, gpu::VertBufPtr &buffer);
385 void bind_ssbo(const char *name, gpu::IndexBuf *buffer);
386 void bind_ssbo(const char *name, gpu::IndexBuf **buffer);
387 void bind_ssbo(int slot, gpu::IndexBuf *buffer);
388 void bind_ssbo(int slot, gpu::IndexBuf **buffer);
389 void bind_tlas(const char *name, gpu::TopLevelAS *tlas);
390 void bind_tlas(int slot, gpu::TopLevelAS *tlas);
391 void bind_ubo(const char *name, gpu::UniformBuf *buffer);
392 void bind_ubo(const char *name, gpu::UniformBuf **buffer);
393 void bind_ubo(int slot, gpu::UniformBuf *buffer);
394 void bind_ubo(int slot, gpu::UniformBuf **buffer);
395
407 void push_constant(const char *name, const float &data);
408 void push_constant(const char *name, const float2 &data);
409 void push_constant(const char *name, const float3 &data);
410 void push_constant(const char *name, const float4 &data);
411 void push_constant(const char *name, const int &data);
412 void push_constant(const char *name, const int2 &data);
413 void push_constant(const char *name, const int3 &data);
414 void push_constant(const char *name, const int4 &data);
415 void push_constant(const char *name, const bool &data);
416 void push_constant(const char *name, const float4x4 &data);
417 void push_constant(const char *name, const float *data, int array_len = 1);
418 void push_constant(const char *name, const float2 *data, int array_len = 1);
419 void push_constant(const char *name, const float3 *data, int array_len = 1);
420 void push_constant(const char *name, const float4 *data, int array_len = 1);
421 void push_constant(const char *name, const int *data, int array_len = 1);
422 void push_constant(const char *name, const int2 *data, int array_len = 1);
423 void push_constant(const char *name, const int3 *data, int array_len = 1);
424 void push_constant(const char *name, const int4 *data, int array_len = 1);
425 void push_constant(const char *name, const float4x4 *data);
426
439 void specialize_constant(gpu::Shader *shader, const char *name, const float &data);
440 void specialize_constant(gpu::Shader *shader, const char *name, const int &data);
441 void specialize_constant(gpu::Shader *shader, const char *name, const uint &data);
442 void specialize_constant(gpu::Shader *shader, const char *name, const bool &data);
443 void specialize_constant(gpu::Shader *shader, const char *name, const float *data);
444 void specialize_constant(gpu::Shader *shader, const char *name, const int *data);
445 void specialize_constant(gpu::Shader *shader, const char *name, const uint *data);
446 void specialize_constant(gpu::Shader *shader, const char *name, const bool *data);
447
448 void texture_copy(gpu::Texture *src, gpu::Texture *dst);
449 void texture_copy(gpu::Texture **src, gpu::Texture **dst);
450 void texture_copy(gpu::Texture **src, gpu::Texture *dst);
451 void texture_copy(gpu::Texture *src, gpu::Texture **dst);
452
459 template<class U> void bind_resources(U &resources)
460 {
461 resources.bind_resources(*this);
462 }
463
467 std::string serialize(std::string line_prefix = "") const;
468
469 friend std::ostream &operator<<(std::ostream &stream, const PassBase &pass)
470 {
471 return stream << pass.serialize();
472 }
473
474 protected:
478
479 int push_constant_offset(const char *name);
480
481 void clear(GPUFrameBufferBits planes, float4 color, float depth, uint8_t stencil);
482
483 gpu::Batch *procedural_batch_get(GPUPrimType primitive);
484
489
495
497
499 {
500 /* NOTE: Even though manager fingerprint is not enough to check for update, it is still
501 * guaranteed to not be 0. So we can check weather or not this pass has generated commands
502 * after sync. Asserts will catch invalid usage . */
503 return manager_fingerprint_ != 0;
504 }
505};
506
507template<typename DrawCommandBufType> class Pass : public detail::PassBase<DrawCommandBufType> {
508 public:
510
511 private:
515 DrawCommandBufType draw_commands_buf_main_;
516
517 public:
518 Pass(const char *name)
519 : detail::PassBase<DrawCommandBufType>(name, draw_commands_buf_main_, sub_passes_main_) {};
520
521 void init()
522 {
523 this->manager_fingerprint_ = 0;
524 this->view_fingerprint_ = 0;
525 this->headers_.clear();
526 this->commands_.clear();
527 this->sub_passes_.clear();
528 this->draw_commands_buf_.clear();
529 this->is_empty_ = true;
530 }
531}; // namespace blender::draw
532
533} // namespace detail
534
536
537/* -------------------------------------------------------------------- */
540
544// using PassSimple = detail::Pass<DrawCommandBuf>;
545
553// using PassMain = detail::Pass<DrawMultiBuf>;
554
559class PassSortable : public PassMain {
560 friend Manager;
561
562 private:
564 Vector<float> sorting_values_;
565
566 bool sorted_ = false;
567
568 public:
569 PassSortable(const char *name_) : PassMain(name_) {};
570
571 void init()
572 {
573 sorting_values_.clear();
574 sorted_ = false;
576 }
577
578 PassMain::Sub &sub(const char *name, float sorting_value)
579 {
583 /* Some sub-pass can also create sub-sub-passes (curve, point-clouds...) which will de-sync
584 * the `sub_passes_.size()` and `sorting_values_.size()`, making the `Header::index` not
585 * reusable for the sorting value in the `sort()` function. To fix this, we flood the
586 * `sorting_values_` to ensure the same index is valid for `sorting_values_` and
587 * `sub_passes_`. */
588 int64_t sorting_index;
589 do {
590 sorting_index = sorting_values_.append_and_get_index(sorting_value);
591 } while (sorting_index != index);
592 return sub_passes_[index];
593 }
594
595 std::string serialize(std::string line_prefix = "") const
596 {
597 if (sorted_ == false) {
598 const_cast<PassSortable *>(this)->sort();
599 }
600 return PassMain::serialize(line_prefix);
601 }
602
603 protected:
604 void sort()
605 {
606 if (sorted_ == false) {
607 std::ranges::sort(headers_, [&](Header &a, Header &b) {
609 float a_val = sorting_values_[a.index];
610 float b_val = sorting_values_[b.index];
611 return a_val < b_val || (a_val == b_val && a.index < b.index);
612 });
613 sorted_ = true;
614 }
615 }
616};
617
619
620namespace detail {
621
622/* -------------------------------------------------------------------- */
625
626template<class T> inline bool PassBase<T>::is_empty() const
627{
628 if (!is_empty_) {
629 return false;
630 }
631
632 for (const command::Header &header : headers_) {
633 if (header.type != Type::SubPass) {
634 continue;
635 }
636 if (!sub_passes_[header.index].is_empty()) {
637 return false;
638 }
639 }
640
641 return true;
642}
643
645{
646 /* After render commands have been generated, the pass is read only.
647 * Call `init()` to be able modify it again. */
648 BLI_assert_msg(this->has_generated_commands() == false, "Command added after submission");
650 headers_.append({type, uint(index)});
651
652 if (ELEM(type,
661 {
662 is_empty_ = false;
663 }
664
665 return commands_[index];
666}
667
668template<class T>
671 float depth,
672 uint8_t stencil)
673{
674 create_command(command::Type::Clear).clear = {uint8_t(planes), stencil, depth, color};
675}
676
677template<class T> inline void PassBase<T>::clear_multi(Span<double4> colors)
678{
679 create_command(command::Type::ClearMulti).clear_multi = {colors.data(),
680 static_cast<int>(colors.size())};
681}
682
683template<class T> inline gpu::Batch *PassBase<T>::procedural_batch_get(GPUPrimType primitive)
684{
685 switch (primitive) {
686 case GPU_PRIM_POINTS:
688 case GPU_PRIM_LINES:
690 case GPU_PRIM_TRIS:
694 default:
695 /* Add new one as needed. */
697 return nullptr;
698 }
699}
700
708
709template<class T>
711{
712 GPU_debug_group_begin("warm_shader_specialization");
713 GPU_debug_group_begin(this->debug_name);
714
715 for (const command::Header &header : headers_) {
716 switch (header.type) {
717 default:
718 case Type::None:
719 break;
720 case Type::SubPass:
721 sub_passes_[header.index].warm_shader_specialization(state);
722 break;
724 break;
726 break;
728 commands_[header.index].shader_bind.execute(state);
729 break;
731 break;
733 break;
735 commands_[header.index].specialize_constant.execute(state);
736 break;
738 break;
740 break;
742 break;
744 break;
746 break;
748 break;
750 break;
752 break;
754 break;
756 break;
757 }
758 }
759
762}
763
765{
766 if (headers_.is_empty()) {
767 return;
768 }
769
771
772 for (const command::Header &header : headers_) {
773 switch (header.type) {
774 default:
775 case Type::None:
776 break;
777 case Type::SubPass:
778 sub_passes_[header.index].submit(state);
779 break;
781 commands_[header.index].framebuffer_bind.execute();
782 break;
784 commands_[header.index].subpass_transition.execute();
785 break;
787 commands_[header.index].shader_bind.execute(state);
788 break;
790 commands_[header.index].resource_bind.execute();
791 break;
793 commands_[header.index].push_constant.execute(state);
794 break;
796 commands_[header.index].specialize_constant.execute(state);
797 break;
799 commands_[header.index].draw.execute(state);
800 break;
802 commands_[header.index].draw_multi.execute(state);
803 break;
805 commands_[header.index].draw_indirect.execute(state);
806 break;
808 commands_[header.index].dispatch.execute(state);
809 break;
811 commands_[header.index].dispatch_indirect.execute(state);
812 break;
814 commands_[header.index].barrier.execute();
815 break;
817 commands_[header.index].clear.execute();
818 break;
820 commands_[header.index].clear_multi.execute();
821 break;
823 commands_[header.index].state_set.execute(state);
824 break;
826 commands_[header.index].stencil_set.execute();
827 break;
829 commands_[header.index].texture_copy.execute();
830 }
831 }
832
834}
835
836template<class T> std::string PassBase<T>::serialize(std::string line_prefix) const
837{
838 std::stringstream ss;
839 ss << line_prefix << "." << debug_name << std::endl;
840 line_prefix += " ";
841 for (const command::Header &header : headers_) {
842 switch (header.type) {
843 default:
844 case Type::None:
845 break;
846 case Type::SubPass:
847 ss << sub_passes_[header.index].serialize(line_prefix);
848 break;
850 ss << line_prefix << commands_[header.index].framebuffer_bind.serialize() << std::endl;
851 break;
853 ss << line_prefix << commands_[header.index].subpass_transition.serialize() << std::endl;
854 break;
855 case Type::ShaderBind:
856 ss << line_prefix << commands_[header.index].shader_bind.serialize() << std::endl;
857 break;
859 ss << line_prefix << commands_[header.index].resource_bind.serialize() << std::endl;
860 break;
862 ss << line_prefix << commands_[header.index].push_constant.serialize() << std::endl;
863 break;
864 case Type::Draw:
865 ss << line_prefix << commands_[header.index].draw.serialize() << std::endl;
866 break;
867 case Type::DrawMulti:
868 ss << commands_[header.index].draw_multi.serialize(line_prefix);
869 break;
871 ss << line_prefix << commands_[header.index].draw_indirect.serialize() << std::endl;
872 break;
873 case Type::Dispatch:
874 ss << line_prefix << commands_[header.index].dispatch.serialize() << std::endl;
875 break;
877 ss << line_prefix << commands_[header.index].dispatch_indirect.serialize() << std::endl;
878 break;
879 case Type::Barrier:
880 ss << line_prefix << commands_[header.index].barrier.serialize() << std::endl;
881 break;
882 case Type::Clear:
883 ss << line_prefix << commands_[header.index].clear.serialize() << std::endl;
884 break;
885 case Type::ClearMulti:
886 ss << line_prefix << commands_[header.index].clear_multi.serialize() << std::endl;
887 break;
888 case Type::StateSet:
889 ss << line_prefix << commands_[header.index].state_set.serialize() << std::endl;
890 break;
891 case Type::StencilSet:
892 ss << line_prefix << commands_[header.index].stencil_set.serialize() << std::endl;
893 break;
894 }
895 }
896 return ss.str();
897}
898
900
901/* -------------------------------------------------------------------- */
904
905template<class T>
906inline void PassBase<T>::draw(gpu::Batch *batch,
907 uint instance_len,
908 uint vertex_len,
909 uint vertex_first,
910 ResourceIDRange res_id,
911 uint custom_id)
912{
913 if (instance_len == 0 || vertex_len == 0) {
914 return;
915 }
916 BLI_assert(batch);
918 draw_commands_buf_.append_draw(headers_,
919 commands_,
920 batch,
921 instance_len,
922 vertex_len,
923 vertex_first,
924 res_id,
925 custom_id,
927 0);
928 is_empty_ = false;
929}
930
931template<class T>
932inline void PassBase<T>::draw(gpu::Batch *batch, ResourceIDRange res_id, uint custom_id)
933{
934 this->draw(batch, -1, -1, -1, res_id, custom_id);
935}
936
937template<class T>
938inline void PassBase<T>::draw_expand(gpu::Batch *batch,
939 GPUPrimType primitive_type,
940 uint primitive_len,
941 uint instance_len,
942 uint vertex_len,
943 uint vertex_first,
944 ResourceIDRange res_id,
945 uint custom_id)
946{
947 if (instance_len == 0 || vertex_len == 0 || primitive_len == 0) {
948 return;
949 }
951 draw_commands_buf_.append_draw(headers_,
952 commands_,
953 batch,
954 instance_len,
955 vertex_len,
956 vertex_first,
957 res_id,
958 custom_id,
959 primitive_type,
960 primitive_len);
961 is_empty_ = false;
962}
963
964template<class T>
965inline void PassBase<T>::draw_expand(gpu::Batch *batch,
966 GPUPrimType primitive_type,
967 uint primitive_len,
968 uint instance_len,
969 ResourceIDRange res_id,
970 uint custom_id)
971{
972 this->draw_expand(batch, primitive_type, primitive_len, instance_len, -1, -1, res_id, custom_id);
973}
974
975template<class T>
977 uint instance_len,
978 uint vertex_len,
979 uint vertex_first,
980 ResourceIDRange res_id,
981 uint custom_id)
982{
983 this->draw(
984 procedural_batch_get(primitive), instance_len, vertex_len, vertex_first, res_id, custom_id);
985}
986
988
989/* -------------------------------------------------------------------- */
992
993template<class T>
994inline void PassBase<T>::draw_indirect(gpu::Batch *batch,
995 StorageBuffer<DrawCommand, true> &indirect_buffer,
996 ResourceID res_id)
997{
999 create_command(Type::DrawIndirect).draw_indirect = {batch, &indirect_buffer, res_id};
1000}
1001
1002template<class T>
1004 GPUPrimType primitive, StorageBuffer<DrawCommand, true> &indirect_buffer, ResourceID res_id)
1005{
1006 this->draw_indirect(procedural_batch_get(primitive), indirect_buffer, res_id);
1007}
1008
1010
1011/* -------------------------------------------------------------------- */
1014
1015template<class T> inline void PassBase<T>::dispatch(int group_len)
1016{
1018 create_command(Type::Dispatch).dispatch = {int3(group_len, 1, 1)};
1019}
1020
1021template<class T> inline void PassBase<T>::dispatch(int2 group_len)
1022{
1024 create_command(Type::Dispatch).dispatch = {int3(group_len.x, group_len.y, 1)};
1025}
1026
1027template<class T> inline void PassBase<T>::dispatch(int3 group_len)
1028{
1030 create_command(Type::Dispatch).dispatch = {group_len};
1031}
1032
1033template<class T> inline void PassBase<T>::dispatch(int3 *group_len)
1034{
1036 create_command(Type::Dispatch).dispatch = {group_len};
1037}
1038
1039template<class T>
1041{
1043 create_command(Type::DispatchIndirect).dispatch_indirect = {&indirect_buffer};
1044}
1045
1047
1048/* -------------------------------------------------------------------- */
1051
1052template<class T> inline void PassBase<T>::clear_color(float4 color)
1053{
1054 this->clear(GPU_COLOR_BIT, color, 0.0f, 0);
1055}
1056
1057template<class T> inline void PassBase<T>::clear_depth(float depth)
1058{
1059 this->clear(GPU_DEPTH_BIT, float4(0.0f), depth, 0);
1060}
1061
1062template<class T> inline void PassBase<T>::clear_stencil(uint8_t stencil)
1063{
1064 this->clear(GPU_STENCIL_BIT, float4(0.0f), 0.0f, stencil);
1065}
1066
1067template<class T> inline void PassBase<T>::clear_depth_stencil(float depth, uint8_t stencil)
1068{
1069 this->clear(GPU_DEPTH_BIT | GPU_STENCIL_BIT, float4(0.0f), depth, stencil);
1070}
1071
1072template<class T>
1074{
1075 this->clear(GPU_DEPTH_BIT | GPU_STENCIL_BIT | GPU_COLOR_BIT, color, depth, stencil);
1076}
1077
1079
1080/* -------------------------------------------------------------------- */
1083
1084template<class T> inline void PassBase<T>::barrier(GPUBarrier type)
1085{
1086 create_command(Type::Barrier).barrier = {type};
1087}
1088
1090
1091/* -------------------------------------------------------------------- */
1094
1095template<class T> inline void PassBase<T>::state_set(DRWState state, int clip_plane_count)
1096{
1098 if (clip_plane_count > 0) {
1100 }
1101 /* Assumed to always be enabled. */
1103 create_command(Type::StateSet).state_set = {state, clip_plane_count};
1104}
1105
1106template<class T>
1107inline void PassBase<T>::state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask)
1108{
1109 create_command(Type::StencilSet).stencil_set = {write_mask, compare_mask, reference};
1110}
1111
1112template<class T> inline void PassBase<T>::shader_set(gpu::Shader *shader)
1113{
1114 shader_ = shader;
1115 create_command(Type::ShaderBind).shader_bind = {shader};
1116}
1117
1118template<class T> inline void PassBase<T>::framebuffer_set(gpu::FrameBuffer **framebuffer)
1119{
1120 create_command(Type::FramebufferBind).framebuffer_bind = {framebuffer};
1121}
1122
1123template<class T>
1125 Span<GPUAttachmentState> color_attachments)
1126{
1127 uint8_t color_states[8] = {GPU_ATTACHMENT_IGNORE};
1128 for (auto i : color_attachments.index_range()) {
1129 color_states[i] = uint8_t(color_attachments[i]);
1130 }
1131 create_command(Type::SubPassTransition).subpass_transition = {uint8_t(depth_attachment),
1132 {color_states[0],
1133 color_states[1],
1134 color_states[2],
1135 color_states[3],
1136 color_states[4],
1137 color_states[5],
1138 color_states[6],
1139 color_states[7]}};
1140}
1141
1142template<class T>
1143inline void PassBase<T>::material_set(Manager &manager,
1144 GPUMaterial *material,
1145 bool deferred_texture_loading,
1146 GPUSamplerFiltering anisotropic_filtering)
1147{
1148 GPUPass *gpupass = GPU_material_get_pass(material);
1150
1151 /* Bind all textures needed by the material. */
1152 ListBaseT<GPUMaterialTexture> textures = GPU_material_textures(material);
1154 if (tex->ima) {
1155 /* Image */
1156 const bool use_tile_mapping = tex->tiled_mapping_name[0];
1157 ImageUser *iuser = tex->iuser_available ? &tex->iuser : nullptr;
1158
1159 /* Try to get image textures, will return null if not loaded yet. */
1161 tex->ima, iuser, use_tile_mapping, deferred_texture_loading);
1162
1163 GPUSamplerState sampler_state = tex->sampler_state;
1164 /* If any anisotropic filtering is requested, reset it to the scene setting. */
1165 if (sampler_state.filtering & GPU_SAMPLER_FILTERING_ANISOTROPIC_ENABLE) {
1166 sampler_state.disable_filtering_flag(GPU_SAMPLER_FILTERING_ANISOTROPIC_MASK);
1167 sampler_state.enable_filtering_flag(anisotropic_filtering);
1168 }
1169
1170 if (gputex.texture == nullptr && deferred_texture_loading) {
1171 /* Texture not yet loaded, add to deferred list and bind by reference.
1172 * The pointer will be filled in later by #Manager::load_deferred_textures. */
1174 tex->ima, iuser, use_tile_mapping);
1175 bind_texture(tex->sampler_name, &deferred.texture, sampler_state);
1176 if (gputex.need_tile_mapping) {
1177 bind_texture(tex->tiled_mapping_name, &deferred.tile_mapping, sampler_state);
1178 }
1179 }
1180 else {
1181 /* Texture is loaded, bind by value. */
1182 if (gputex.texture) {
1183 bind_texture(tex->sampler_name, gputex.texture, sampler_state);
1184 manager.hold_texture(gputex.texture);
1185 }
1186 if (gputex.tile_mapping) {
1187 bind_texture(tex->tiled_mapping_name, gputex.tile_mapping, sampler_state);
1188 manager.hold_texture(gputex.tile_mapping);
1189 }
1190 }
1191 }
1192 else if (tex->colorband) {
1193 /* Color Ramp */
1194 bind_texture(tex->sampler_name, *tex->colorband);
1195 }
1196 else if (tex->sky) {
1197 /* Sky */
1198 bind_texture(tex->sampler_name, *tex->sky, tex->sampler_state);
1199 }
1200 }
1201
1203 if (ubo != nullptr) {
1204 bind_ubo(GPU_NODE_TREE_UBO_SLOT, ubo);
1205 }
1206}
1207
1209
1210/* -------------------------------------------------------------------- */
1213
1214template<class T> inline int PassBase<T>::push_constant_offset(const char *name)
1215{
1216 return GPU_shader_get_uniform(shader_, name);
1217}
1218
1219template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::StorageBuf *buffer)
1220{
1221 BLI_assert(buffer != nullptr);
1222 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1223}
1224
1225template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::UniformBuf *buffer)
1226{
1227 BLI_assert(buffer != nullptr);
1228 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1229}
1230
1231template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::UniformBuf **buffer)
1232{
1233 BLI_assert(buffer != nullptr);
1234 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1235}
1236
1237template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::VertBuf *buffer)
1238{
1239 BLI_assert(buffer != nullptr);
1240 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1241}
1242
1243template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::VertBuf **buffer)
1244{
1245 BLI_assert(buffer != nullptr);
1246 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1247}
1248
1249template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::VertBufPtr &buffer)
1250{
1251 BLI_assert(buffer.get() != nullptr);
1252 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer.get());
1253}
1254
1255template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::IndexBuf *buffer)
1256{
1257 BLI_assert(buffer != nullptr);
1258 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1259}
1260
1261template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::IndexBuf **buffer)
1262{
1263 BLI_assert(buffer != nullptr);
1264 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1265}
1266
1267template<class T> inline void PassBase<T>::bind_tlas(const char *name, gpu::TopLevelAS *tlas)
1268{
1269 BLI_assert(tlas != nullptr);
1270 this->bind_tlas(GPU_shader_get_tlas_binding(shader_, name), tlas);
1271}
1272
1273template<class T> inline void PassBase<T>::bind_ubo(const char *name, gpu::UniformBuf *buffer)
1274{
1275 BLI_assert(buffer != nullptr);
1276 this->bind_ubo(GPU_shader_get_ubo_binding(shader_, name), buffer);
1277}
1278
1279template<class T>
1280inline void PassBase<T>::bind_texture(const char *name,
1283{
1284 BLI_assert(texture != nullptr);
1286}
1287
1288template<class T> inline void PassBase<T>::bind_texture(const char *name, gpu::VertBuf *buffer)
1289{
1290 BLI_assert(buffer != nullptr);
1292}
1293
1294template<class T> inline void PassBase<T>::bind_texture(const char *name, gpu::VertBuf **buffer)
1295{
1296 BLI_assert(buffer != nullptr);
1298}
1299
1300template<class T> inline void PassBase<T>::bind_texture(const char *name, gpu::VertBufPtr &buffer)
1301{
1302 BLI_assert(buffer.get() != nullptr);
1303 this->bind_texture(GPU_shader_get_sampler_binding(shader_, name), buffer.get());
1304}
1305
1306template<class T> inline void PassBase<T>::bind_image(const char *name, gpu::Texture *image)
1307{
1308 BLI_assert(image != nullptr);
1310}
1311
1312template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::StorageBuf *buffer)
1313{
1314 BLI_assert(buffer != nullptr);
1315 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1316}
1317
1318template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::UniformBuf *buffer)
1319{
1320 BLI_assert(buffer != nullptr);
1321 create_command(Type::ResourceBind).resource_bind = {
1323}
1324
1325template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::UniformBuf **buffer)
1326{
1327 BLI_assert(buffer != nullptr);
1328 create_command(Type::ResourceBind).resource_bind = {
1330}
1331
1332template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::VertBuf *buffer)
1333{
1334 BLI_assert(buffer != nullptr);
1335 create_command(Type::ResourceBind).resource_bind = {
1337}
1338
1339template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::VertBuf **buffer)
1340{
1341 BLI_assert(buffer != nullptr);
1342 create_command(Type::ResourceBind).resource_bind = {
1344}
1345
1346template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::VertBufPtr &buffer)
1347{
1348 BLI_assert(buffer.get() != nullptr);
1349 create_command(Type::ResourceBind).resource_bind = {
1350 slot, buffer.get(), ResourceBind::Type::VertexAsStorageBuf};
1351}
1352
1353template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::IndexBuf *buffer)
1354{
1355 BLI_assert(buffer != nullptr);
1356 create_command(Type::ResourceBind).resource_bind = {
1358}
1359
1360template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::IndexBuf **buffer)
1361{
1362 BLI_assert(buffer != nullptr);
1363 create_command(Type::ResourceBind).resource_bind = {
1365}
1366
1367template<class T> inline void PassBase<T>::bind_tlas(int slot, gpu::TopLevelAS *tlas)
1368{
1369 BLI_assert(tlas != nullptr);
1370 create_command(Type::ResourceBind).resource_bind = {slot, tlas};
1371}
1372
1373template<class T> inline void PassBase<T>::bind_ubo(int slot, gpu::UniformBuf *buffer)
1374{
1375 BLI_assert(buffer != nullptr);
1376 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1377}
1378
1379template<class T>
1381{
1382 BLI_assert(texture != nullptr);
1383 create_command(Type::ResourceBind).resource_bind = {slot, texture, state};
1384}
1385
1386template<class T> inline void PassBase<T>::bind_texture(int slot, gpu::VertBuf *buffer)
1387{
1388 BLI_assert(buffer != nullptr);
1389 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1390}
1391
1392template<class T> inline void PassBase<T>::bind_texture(int slot, gpu::VertBuf **buffer)
1393{
1394 BLI_assert(buffer != nullptr);
1395 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1396}
1397
1398template<class T> inline void PassBase<T>::bind_texture(int slot, gpu::VertBufPtr &buffer)
1399{
1400 BLI_assert(buffer.get() != nullptr);
1401 create_command(Type::ResourceBind).resource_bind = {slot, buffer.get()};
1402}
1403
1404template<class T> inline void PassBase<T>::bind_image(int slot, gpu::Texture *image)
1405{
1406 BLI_assert(image != nullptr);
1407 create_command(Type::ResourceBind).resource_bind = {slot, as_image(image)};
1408}
1409
1410template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::StorageBuf **buffer)
1411{
1412 BLI_assert(buffer != nullptr);
1413 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1414}
1415
1416template<class T> inline void PassBase<T>::bind_ubo(const char *name, gpu::UniformBuf **buffer)
1417{
1418 BLI_assert(buffer != nullptr);
1419 this->bind_ubo(GPU_shader_get_ubo_binding(shader_, name), buffer);
1420}
1421
1422template<class T>
1423inline void PassBase<T>::bind_texture(const char *name,
1426{
1427 BLI_assert(texture != nullptr);
1429}
1430
1431template<class T> inline void PassBase<T>::bind_image(const char *name, gpu::Texture **image)
1432{
1433 BLI_assert(image != nullptr);
1435}
1436
1437template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::StorageBuf **buffer)
1438{
1439
1440 BLI_assert(buffer != nullptr);
1441 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1442}
1443
1444template<class T> inline void PassBase<T>::bind_ubo(int slot, gpu::UniformBuf **buffer)
1445{
1446 BLI_assert(buffer != nullptr);
1447 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1448}
1449
1450template<class T>
1452{
1453 BLI_assert(texture != nullptr);
1454 create_command(Type::ResourceBind).resource_bind = {slot, texture, state};
1455}
1456
1457template<class T> inline void PassBase<T>::bind_image(int slot, gpu::Texture **image)
1458{
1459 BLI_assert(image != nullptr);
1460 create_command(Type::ResourceBind).resource_bind = {slot, as_image(image)};
1461}
1462
1464
1465/* -------------------------------------------------------------------- */
1468
1469template<class T> inline void PassBase<T>::push_constant(const char *name, const float &data)
1470{
1472}
1473
1474template<class T> inline void PassBase<T>::push_constant(const char *name, const float2 &data)
1475{
1477}
1478
1479template<class T> inline void PassBase<T>::push_constant(const char *name, const float3 &data)
1480{
1482}
1483
1484template<class T> inline void PassBase<T>::push_constant(const char *name, const float4 &data)
1485{
1487}
1488
1489template<class T> inline void PassBase<T>::push_constant(const char *name, const int &data)
1490{
1492}
1493
1494template<class T> inline void PassBase<T>::push_constant(const char *name, const int2 &data)
1495{
1497}
1498
1499template<class T> inline void PassBase<T>::push_constant(const char *name, const int3 &data)
1500{
1502}
1503
1504template<class T> inline void PassBase<T>::push_constant(const char *name, const int4 &data)
1505{
1507}
1508
1509template<class T> inline void PassBase<T>::push_constant(const char *name, const bool &data)
1510{
1512}
1513
1514template<class T>
1515inline void PassBase<T>::push_constant(const char *name, const float *data, int array_len)
1516{
1517 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1518}
1519
1520template<class T>
1521inline void PassBase<T>::push_constant(const char *name, const float2 *data, int array_len)
1522{
1523 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1524}
1525
1526template<class T>
1527inline void PassBase<T>::push_constant(const char *name, const float3 *data, int array_len)
1528{
1529 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1530}
1531
1532template<class T>
1533inline void PassBase<T>::push_constant(const char *name, const float4 *data, int array_len)
1534{
1535 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1536}
1537
1538template<class T>
1539inline void PassBase<T>::push_constant(const char *name, const int *data, int array_len)
1540{
1541 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1542}
1543
1544template<class T>
1545inline void PassBase<T>::push_constant(const char *name, const int2 *data, int array_len)
1546{
1547 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1548}
1549
1550template<class T>
1551inline void PassBase<T>::push_constant(const char *name, const int3 *data, int array_len)
1552{
1553 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1554}
1555
1556template<class T>
1557inline void PassBase<T>::push_constant(const char *name, const int4 *data, int array_len)
1558{
1559 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1560}
1561
1562template<class T> inline void PassBase<T>::push_constant(const char *name, const float4x4 *data)
1563{
1565}
1566
1567template<class T> inline void PassBase<T>::push_constant(const char *name, const float4x4 &data)
1568{
1569 /* WORKAROUND: Push 3 consecutive commands to hold the 64 bytes of the float4x4.
1570 * This assumes that all commands are always stored in flat array of memory. */
1571 Undetermined commands[3];
1572
1573 PushConstant &cmd = commands[0].push_constant;
1574 cmd.location = push_constant_offset(name);
1575 cmd.array_len = 1;
1576 cmd.comp_len = 16;
1578 /* Copy overrides the next 2 commands. We append them as Type::None to not evaluate them. */
1579 *reinterpret_cast<float4x4 *>(&cmd.float4_value) = data;
1580
1581 create_command(Type::PushConstant) = commands[0];
1582 create_command(Type::None) = commands[1];
1583 create_command(Type::None) = commands[2];
1584}
1585
1587
1588/* -------------------------------------------------------------------- */
1591
1592template<class T>
1594 const char *constant_name,
1595 const int &constant_value)
1596{
1598 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1599}
1600
1601template<class T>
1603 const char *constant_name,
1604 const uint &constant_value)
1605{
1606 create_command(Type::SpecializeConstant).specialize_constant = {
1607 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1608}
1609
1610template<class T>
1612 const char *constant_name,
1613 const float &constant_value)
1614{
1615 create_command(Type::SpecializeConstant).specialize_constant = {
1616 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1617}
1618
1619template<class T>
1621 const char *constant_name,
1622 const bool &constant_value)
1623{
1624 create_command(Type::SpecializeConstant).specialize_constant = {
1625 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1626}
1627
1628template<class T>
1630 const char *constant_name,
1631 const int *constant_value)
1632{
1633 create_command(Type::SpecializeConstant).specialize_constant = {
1634 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1635}
1636
1637template<class T>
1639 const char *constant_name,
1640 const uint *constant_value)
1641{
1642 create_command(Type::SpecializeConstant).specialize_constant = {
1643 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1644}
1645
1646template<class T>
1648 const char *constant_name,
1649 const float *constant_value)
1650{
1651 create_command(Type::SpecializeConstant).specialize_constant = {
1652 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1653}
1654
1655template<class T>
1657 const char *constant_name,
1658 const bool *constant_value)
1659{
1660 create_command(Type::SpecializeConstant).specialize_constant = {
1661 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1662}
1663
1665
1666/* -------------------------------------------------------------------- */
1669
1670template<class T> inline void PassBase<T>::texture_copy(gpu::Texture *src, gpu::Texture *dst)
1671{
1672 create_command(Type::TextureCopy).texture_copy = {
1673 .src = src, .dst = dst, .src_is_ref = false, .dst_is_ref = false};
1674}
1675template<class T> inline void PassBase<T>::texture_copy(gpu::Texture **src, gpu::Texture **dst)
1676{
1677 create_command(Type::TextureCopy).texture_copy = {
1678 .src_ref = src, .dst_ref = dst, .src_is_ref = true, .dst_is_ref = true};
1679}
1680template<class T> inline void PassBase<T>::texture_copy(gpu::Texture **src, gpu::Texture *dst)
1681{
1682 create_command(Type::TextureCopy).texture_copy = {
1683 .src_ref = src, .dst = dst, .src_is_ref = true, .dst_is_ref = false};
1684}
1685template<class T> inline void PassBase<T>::texture_copy(gpu::Texture *src, gpu::Texture **dst)
1686{
1687 create_command(Type::TextureCopy).texture_copy = {
1688 .src = src, .dst_ref = dst, .src_is_ref = false, .dst_is_ref = true};
1689}
1690
1692
1693} // namespace detail
1694} // namespace blender::draw
#define BLI_assert_unreachable()
#define ELEM(...)
#define BLI_assert_msg(a, msg)
virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const
Data buffer MUST be 16 byte aligned.
constexpr const T * data() const
Definition BLI_span.hh:219
constexpr int64_t size() const
Definition BLI_span.hh:256
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
int64_t append_and_get_index(const T &value)
void append(const T &value)
bool is_empty() const
void hold_texture(gpu::Texture *texture)
DeferredTexture & add_texture_deferred(blender::Image *image, blender::ImageUser *image_user, const bool use_tile_mapping)
std::string serialize(std::string line_prefix="") const
Definition draw_pass.hh:595
PassSortable(const char *name_)
Definition draw_pass.hh:569
PassMain::Sub & sub(const char *name, float sorting_value)
Definition draw_pass.hh:578
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceIDRange res_id={}, uint custom_id=0)
Definition draw_pass.hh:976
void bind_resources(U &resources)
Definition draw_pass.hh:459
void framebuffer_set(gpu::FrameBuffer **framebuffer)
friend std::ostream & operator<<(std::ostream &stream, const PassBase &pass)
Definition draw_pass.hh:469
void shader_set(gpu::Shader *shader)
void material_set(Manager &manager, GPUMaterial *material, bool deferred_texture_loading=false, GPUSamplerFiltering anisotropic_filtering=GPU_SAMPLER_FILTERING_DEFAULT)
void texture_copy(gpu::Texture *src, gpu::Texture *dst)
void bind_texture(const char *name, gpu::Texture *texture, GPUSamplerState state=sampler_auto)
void draw_procedural_indirect(GPUPrimType primitive, StorageBuffer< DrawCommand, true > &indirect_buffer, ResourceID res_id={0})
Vector< command::Header, 0 > headers_
Definition draw_pass.hh:139
void draw_indirect(gpu::Batch *batch, StorageBuffer< DrawCommand, true > &indirect_buffer, ResourceID res_id={0})
Definition draw_pass.hh:994
void clear_stencil(uint8_t stencil)
void clear(GPUFrameBufferBits planes, float4 color, float depth, uint8_t stencil)
Definition draw_pass.hh:669
void clear_color(float4 color)
void warm_shader_specialization(command::RecordingState &state) const
Definition draw_pass.hh:710
void specialize_constant(gpu::Shader *shader, const char *name, const float &data)
void subpass_transition(GPUAttachmentState depth_attachment, Span< GPUAttachmentState > color_attachments)
void bind_image(const char *name, gpu::Texture *image)
void clear_depth_stencil(float depth, uint8_t stencil)
void bind_tlas(const char *name, gpu::TopLevelAS *tlas)
PassBase(const char *name, DrawCommandBufType &draw_command_buf, SubPassVector< PassBase< DrawCommandBufType > > &sub_passes, gpu::Shader *shader=nullptr)
Definition draw_pass.hh:159
SubPassVector< PassBase< DrawCommandBufType > > & sub_passes_
Definition draw_pass.hh:145
command::Undetermined & create_command(command::Type type)
Definition draw_pass.hh:644
PassBase< DrawCommandBufType > & sub(const char *name)
Definition draw_pass.hh:701
void dispatch(int group_len)
int push_constant_offset(const char *name)
void submit(command::RecordingState &state) const
Definition draw_pass.hh:764
void state_set(DRWState state, int clip_plane_count=0)
void draw_expand(gpu::Batch *batch, GPUPrimType primitive_type, uint primitive_len, uint instance_len, uint vertex_len, uint vertex_first, ResourceIDRange res_id={}, uint custom_id=0)
Definition draw_pass.hh:938
void clear_multi(Span< double4 > colors)
Definition draw_pass.hh:677
void barrier(GPUBarrier type)
Vector< command::Undetermined, 0 > commands_
Definition draw_pass.hh:141
void state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask)
void clear_color_depth_stencil(float4 color, float depth, uint8_t stencil)
void bind_ubo(const char *name, gpu::UniformBuf *buffer)
std::string serialize(std::string line_prefix="") const
Definition draw_pass.hh:836
void push_constant(const char *name, const float &data)
void bind_ssbo(const char *name, gpu::StorageBuf *buffer)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceIDRange res_id={}, uint custom_id=0)
Definition draw_pass.hh:906
gpu::Batch * procedural_batch_get(GPUPrimType primitive)
Definition draw_pass.hh:683
DrawCommandBufType & draw_commands_buf_
Definition draw_pass.hh:143
detail::PassBase< command::DrawCommandBuf > Sub
Definition draw_pass.hh:509
Pass(const char *name)
Definition draw_pass.hh:518
const T & operator[](int64_t index) const
Definition draw_pass.hh:118
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
const int state
#define T
draw::StorageBuffer< DrawCommand, true > DrawIndirectBuf
Definition draw_pass.hh:73
detail::Pass< command::DrawMultiBuf > PassMain
draw::StorageBuffer< DispatchCommand > DispatchIndirectBuf
Definition draw_pass.hh:72
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int GPU_shader_get_sampler_binding(gpu::Shader *shader, const char *name)
unsigned __int64 uint64_t
Definition BKE_text.h:91
__int64 int64_t
Definition BKE_text.h:90
VecBase< int32_t, 4 > int4
unsigned int uint
Definition BKE_text.h:55
int GPU_shader_get_constant(gpu::Shader *shader, const char *name)
gpu::Batch * GPU_batch_procedural_points_get()
Definition gpu_batch.cc:513
ImageGPUTextures BKE_image_acquire_gpu_material_texture(Image *image, ImageUser *iuser, const bool use_tile_mapping, const bool try_only)
Definition image_gpu.cc:762
@ GPU_PRIM_TRI_STRIP
@ GPU_SAMPLER_FILTERING_DEFAULT
MatBase< float, 4, 4 > float4x4
gpu::UniformBuf * GPU_material_uniform_buffer_get(GPUMaterial *material)
int GPU_shader_get_ssbo_binding(gpu::Shader *shader, const char *name)
VecBase< float, 4 > float4
gpu::Shader * GPU_pass_shader_get(GPUPass *pass)
Definition gpu_pass.cc:176
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
ListBaseWrapperTemplate< ListBase, T > ListBaseWrapper
BMesh const char void * data
GPUPass * GPU_material_get_pass(GPUMaterial *material)
unsigned char uint8_t
Definition BKE_text.h:79
gpu::Batch * GPU_batch_procedural_triangle_strips_get()
Definition gpu_batch.cc:528
int GPU_shader_get_tlas_binding(gpu::Shader *shader, const char *name)
@ DRW_STATE_CLIP_PLANES
Definition draw_state.hh:72
@ DRW_STATE_PROGRAM_POINT_SIZE
Definition draw_state.hh:75
void GPU_debug_group_end()
Definition gpu_debug.cc:34
ListBaseT< GPUMaterialTexture > GPU_material_textures(GPUMaterial *material)
int GPU_shader_get_uniform(gpu::Shader *shader, const char *name)
gpu::Batch * GPU_batch_procedural_triangles_get()
Definition gpu_batch.cc:523
int GPU_shader_get_ubo_binding(gpu::Shader *shader, const char *name)
VecBase< float, 3 > float3
gpu::Batch * GPU_batch_procedural_lines_get()
Definition gpu_batch.cc:518
void GPU_debug_group_begin(const char *name)
Definition gpu_debug.cc:23
void disable_filtering_flag(GPUSamplerFiltering filtering_flags)
GPUSamplerFiltering filtering
static constexpr GPUSamplerState internal_sampler()
void enable_filtering_flag(GPUSamplerFiltering filtering_flags)
enum blender::draw::command::PushConstant::Type type