Blender V4.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
44#include "BLI_vector.hh"
45
46#include "BKE_image.hh"
47
48#include "GPU_debug.hh"
49#include "GPU_material.hh"
50
51#include "DRW_gpu_wrapper.hh"
52
53#include "draw_command.hh"
54#include "draw_handle.hh"
55#include "draw_manager.hh"
56#include "draw_pass.hh"
57#include "draw_shader_shared.hh"
58#include "draw_state.hh"
59
60#include "intern/gpu_codegen.hh"
61
62#include <sstream>
63
64namespace blender::draw {
65using namespace blender::draw;
66using namespace blender::draw::command;
67
68class Manager;
69
70namespace command {
71class DrawCommandBuf;
72}
73
74/* -------------------------------------------------------------------- */
78namespace detail {
79
83template<typename T,
85 int64_t block_size = 16>
87 private:
89
90 public:
91 void clear()
92 {
93 blocks_.clear();
94 }
95
97 {
98 /* Do not go over the inline size so that existing members never move. */
99 if (blocks_.is_empty() || blocks_.last()->size() == block_size) {
100 blocks_.append(std::make_unique<Vector<T, block_size>>());
101 }
102 return blocks_.last()->append_and_get_index(std::move(elem)) +
103 (blocks_.size() - 1) * block_size;
104 }
105
107 {
108 return (*blocks_[index / block_size])[index % block_size];
109 }
110
111 const T &operator[](int64_t index) const
112 {
113 return (*blocks_[index / block_size])[index % block_size];
114 }
115};
116
120template<
122 typename DrawCommandBufType>
123class PassBase {
124 friend Manager;
125 friend DrawCommandBuf;
126
128 static constexpr GPUSamplerState sampler_auto = GPUSamplerState::internal_sampler();
129
130 protected:
135 /* Reference to draw commands buffer. Either own or from parent pass. */
136 DrawCommandBufType &draw_commands_buf_;
137 /* Reference to sub-pass commands buffer. Either own or from parent pass. */
141
142 public:
143 const char *debug_name;
144
146
147 PassBase(const char *name,
148 DrawCommandBufType &draw_command_buf,
150 GPUShader *shader = nullptr)
151 : draw_commands_buf_(draw_command_buf),
152 sub_passes_(sub_passes),
153 shader_(shader),
154 debug_name(name),
156
162 void init();
163
168
179 void state_set(DRWState state, int clip_plane_count = 0);
180
184 void clear_color(float4 color);
185 void clear_depth(float depth);
186 void clear_stencil(uint8_t stencil);
187 void clear_depth_stencil(float depth, uint8_t stencil);
188 void clear_color_depth_stencil(float4 color, float depth, uint8_t stencil);
194
207 void state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask);
208
212 void shader_set(GPUShader *shader);
213
219 void framebuffer_set(GPUFrameBuffer **framebuffer);
220
227 Span<GPUAttachmentState> color_attachments);
228
234 void material_set(Manager &manager, GPUMaterial *material);
235
241 void draw(gpu::Batch *batch,
242 uint instance_len = -1,
243 uint vertex_len = -1,
244 uint vertex_first = -1,
245 ResourceHandle handle = {0},
246 uint custom_id = 0);
247
252 void draw(gpu::Batch *batch, ResourceHandle handle, uint custom_id = 0);
253
259 uint instance_len,
260 uint vertex_len,
261 uint vertex_first = -1,
262 ResourceHandle handle = {0},
263 uint custom_id = 0);
264
278 void draw_expand(gpu::Batch *batch,
279 GPUPrimType primitive_type,
280 uint primitive_len,
281 uint instance_len,
282 uint vertex_len = -1,
283 uint vertex_first = -1,
284 ResourceHandle handle = {0},
285 uint custom_id = 0);
286
291 void draw_expand(gpu::Batch *batch,
292 GPUPrimType primitive_type,
293 uint primitive_len,
294 uint instance_len,
295 ResourceHandle handle = {0},
296 uint custom_id = 0);
297
302 void draw_indirect(gpu::Batch *batch,
303 StorageBuffer<DrawCommand, true> &indirect_buffer,
304 ResourceHandle handle = {0});
306 StorageBuffer<DrawCommand, true> &indirect_buffer,
307 ResourceHandle handle = {0});
308
312 void dispatch(int group_len);
313 void dispatch(int2 group_len);
314 void dispatch(int3 group_len);
315 void dispatch(int3 *group_len);
317
322
335 void bind_image(const char *name, GPUTexture *image);
336 void bind_image(const char *name, GPUTexture **image);
337 void bind_image(int slot, GPUTexture *image);
338 void bind_image(int slot, GPUTexture **image);
339 void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state = sampler_auto);
340 void bind_texture(const char *name, GPUTexture **texture, GPUSamplerState state = sampler_auto);
341 void bind_texture(const char *name, gpu::VertBuf *buffer);
342 void bind_texture(const char *name, gpu::VertBuf **buffer);
343 void bind_texture(int slot, GPUTexture *texture, GPUSamplerState state = sampler_auto);
344 void bind_texture(int slot, GPUTexture **texture, GPUSamplerState state = sampler_auto);
345 void bind_texture(int slot, gpu::VertBuf *buffer);
346 void bind_texture(int slot, gpu::VertBuf **buffer);
347 void bind_ssbo(const char *name, GPUStorageBuf *buffer);
348 void bind_ssbo(const char *name, GPUStorageBuf **buffer);
349 void bind_ssbo(int slot, GPUStorageBuf *buffer);
350 void bind_ssbo(int slot, GPUStorageBuf **buffer);
351 void bind_ssbo(const char *name, GPUUniformBuf *buffer);
352 void bind_ssbo(const char *name, GPUUniformBuf **buffer);
353 void bind_ssbo(int slot, GPUUniformBuf *buffer);
354 void bind_ssbo(int slot, GPUUniformBuf **buffer);
355 void bind_ssbo(const char *name, gpu::VertBuf *buffer);
356 void bind_ssbo(const char *name, gpu::VertBuf **buffer);
357 void bind_ssbo(int slot, gpu::VertBuf *buffer);
358 void bind_ssbo(int slot, gpu::VertBuf **buffer);
359 void bind_ssbo(const char *name, gpu::IndexBuf *buffer);
360 void bind_ssbo(const char *name, gpu::IndexBuf **buffer);
361 void bind_ssbo(int slot, gpu::IndexBuf *buffer);
362 void bind_ssbo(int slot, gpu::IndexBuf **buffer);
363 void bind_ubo(const char *name, GPUUniformBuf *buffer);
364 void bind_ubo(const char *name, GPUUniformBuf **buffer);
365 void bind_ubo(int slot, GPUUniformBuf *buffer);
366 void bind_ubo(int slot, GPUUniformBuf **buffer);
367
379 void push_constant(const char *name, const float &data);
380 void push_constant(const char *name, const float2 &data);
381 void push_constant(const char *name, const float3 &data);
382 void push_constant(const char *name, const float4 &data);
383 void push_constant(const char *name, const int &data);
384 void push_constant(const char *name, const int2 &data);
385 void push_constant(const char *name, const int3 &data);
386 void push_constant(const char *name, const int4 &data);
387 void push_constant(const char *name, const bool &data);
388 void push_constant(const char *name, const float4x4 &data);
389 void push_constant(const char *name, const float *data, int array_len = 1);
390 void push_constant(const char *name, const float2 *data, int array_len = 1);
391 void push_constant(const char *name, const float3 *data, int array_len = 1);
392 void push_constant(const char *name, const float4 *data, int array_len = 1);
393 void push_constant(const char *name, const int *data, int array_len = 1);
394 void push_constant(const char *name, const int2 *data, int array_len = 1);
395 void push_constant(const char *name, const int3 *data, int array_len = 1);
396 void push_constant(const char *name, const int4 *data, int array_len = 1);
397 void push_constant(const char *name, const float4x4 *data);
398
411 void specialize_constant(GPUShader *shader, const char *name, const float &data);
412 void specialize_constant(GPUShader *shader, const char *name, const int &data);
413 void specialize_constant(GPUShader *shader, const char *name, const uint &data);
414 void specialize_constant(GPUShader *shader, const char *name, const bool &data);
415 void specialize_constant(GPUShader *shader, const char *name, const float *data);
416 void specialize_constant(GPUShader *shader, const char *name, const int *data);
417 void specialize_constant(GPUShader *shader, const char *name, const uint *data);
418 void specialize_constant(GPUShader *shader, const char *name, const bool *data);
419
426 template<class U> void bind_resources(U &resources)
427 {
428 resources.bind_resources(*this);
429 }
430
434 std::string serialize(std::string line_prefix = "") const;
435
436 friend std::ostream &operator<<(std::ostream &stream, const PassBase &pass)
437 {
438 return stream << pass.serialize();
439 }
440
441 protected:
446 int push_constant_offset(const char *name);
447
448 void clear(eGPUFrameBufferBits planes, float4 color, float depth, uint8_t stencil);
449
450 gpu::Batch *procedural_batch_get(GPUPrimType primitive);
451
456
458};
459
460template<typename DrawCommandBufType> class Pass : public detail::PassBase<DrawCommandBufType> {
461 public:
463
464 private:
468 DrawCommandBufType draw_commands_buf_main_;
469
470 public:
471 Pass(const char *name)
472 : detail::PassBase<DrawCommandBufType>(name, draw_commands_buf_main_, sub_passes_main_){};
473
474 void init()
475 {
476 this->headers_.clear();
477 this->commands_.clear();
478 this->sub_passes_.clear();
479 this->draw_commands_buf_.clear();
480 }
481}; // namespace blender::draw
482
483} // namespace detail
484
487/* -------------------------------------------------------------------- */
494// using PassSimple = detail::Pass<DrawCommandBuf>;
495
503// using PassMain = detail::Pass<DrawMultiBuf>;
504
509class PassSortable : public PassMain {
510 friend Manager;
511
512 private:
514 Vector<float> sorting_values_;
515
516 bool sorted_ = false;
517
518 public:
519 PassSortable(const char *name_) : PassMain(name_){};
520
521 void init()
522 {
523 sorting_values_.clear();
524 sorted_ = false;
526 }
527
528 PassMain::Sub &sub(const char *name, float sorting_value)
529 {
530 int64_t index = sub_passes_.append_and_get_index(
532 headers_.append({Type::SubPass, uint(index)});
533 /* Some sub-pass can also create sub-sub-passes (curve, point-clouds...) which will de-sync
534 * the `sub_passes_.size()` and `sorting_values_.size()`, making the `Header::index` not
535 * reusable for the sorting value in the `sort()` function. To fix this, we flood the
536 * `sorting_values_` to ensure the same index is valid for `sorting_values_` and
537 * `sub_passes_`. */
538 int64_t sorting_index;
539 do {
540 sorting_index = sorting_values_.append_and_get_index(sorting_value);
541 } while (sorting_index != index);
542 return sub_passes_[index];
543 }
544
545 std::string serialize(std::string line_prefix = "") const
546 {
547 if (sorted_ == false) {
548 const_cast<PassSortable *>(this)->sort();
549 }
550 return PassMain::serialize(line_prefix);
551 }
552
553 protected:
554 void sort()
555 {
556 if (sorted_ == false) {
557 std::sort(headers_.begin(), headers_.end(), [&](Header &a, Header &b) {
558 BLI_assert(a.type == Type::SubPass && b.type == Type::SubPass);
559 float a_val = sorting_values_[a.index];
560 float b_val = sorting_values_[b.index];
561 return a_val < b_val || (a_val == b_val && a.index < b.index);
562 });
563 sorted_ = true;
564 }
565 }
566};
567
570namespace detail {
571
572/* -------------------------------------------------------------------- */
577{
578 int64_t index = commands_.append_and_get_index({});
579 headers_.append({type, uint(index)});
580 return commands_[index];
581}
582
583template<class T>
585 float4 color,
586 float depth,
587 uint8_t stencil)
588{
589 create_command(command::Type::Clear).clear = {uint8_t(planes), stencil, depth, color};
590}
591
592template<class T> inline void PassBase<T>::clear_multi(Span<float4> colors)
593{
594 create_command(command::Type::ClearMulti).clear_multi = {colors.data(),
595 static_cast<int>(colors.size())};
596}
597
598template<class T> inline gpu::Batch *PassBase<T>::procedural_batch_get(GPUPrimType primitive)
599{
600 switch (primitive) {
601 case GPU_PRIM_POINTS:
603 case GPU_PRIM_LINES:
605 case GPU_PRIM_TRIS:
609 default:
610 /* Add new one as needed. */
612 return nullptr;
613 }
614}
615
616template<class T> inline PassBase<T> &PassBase<T>::sub(const char *name)
617{
618 int64_t index = sub_passes_.append_and_get_index(
619 PassBase(name, draw_commands_buf_, sub_passes_, shader_));
620 headers_.append({command::Type::SubPass, uint(index)});
621 return sub_passes_[index];
622}
623
625{
626 GPU_debug_group_begin(debug_name);
627
628 for (const command::Header &header : headers_) {
629 switch (header.type) {
630 default:
631 case Type::None:
632 break;
633 case Type::SubPass:
634 sub_passes_[header.index].submit(state);
635 break;
636 case command::Type::FramebufferBind:
637 commands_[header.index].framebuffer_bind.execute();
638 break;
639 case command::Type::SubPassTransition:
640 commands_[header.index].subpass_transition.execute();
641 break;
642 case command::Type::ShaderBind:
643 commands_[header.index].shader_bind.execute(state);
644 break;
645 case command::Type::ResourceBind:
646 commands_[header.index].resource_bind.execute();
647 break;
648 case command::Type::PushConstant:
649 commands_[header.index].push_constant.execute(state);
650 break;
651 case command::Type::SpecializeConstant:
652 commands_[header.index].specialize_constant.execute();
653 break;
654 case command::Type::Draw:
655 commands_[header.index].draw.execute(state);
656 break;
657 case command::Type::DrawMulti:
658 commands_[header.index].draw_multi.execute(state);
659 break;
660 case command::Type::DrawIndirect:
661 commands_[header.index].draw_indirect.execute(state);
662 break;
663 case command::Type::Dispatch:
664 commands_[header.index].dispatch.execute(state);
665 break;
666 case command::Type::DispatchIndirect:
667 commands_[header.index].dispatch_indirect.execute(state);
668 break;
669 case command::Type::Barrier:
670 commands_[header.index].barrier.execute();
671 break;
672 case command::Type::Clear:
673 commands_[header.index].clear.execute();
674 break;
675 case command::Type::ClearMulti:
676 commands_[header.index].clear_multi.execute();
677 break;
678 case command::Type::StateSet:
679 commands_[header.index].state_set.execute(state);
680 break;
681 case command::Type::StencilSet:
682 commands_[header.index].stencil_set.execute();
683 break;
684 }
685 }
686
688}
689
690template<class T> std::string PassBase<T>::serialize(std::string line_prefix) const
691{
692 std::stringstream ss;
693 ss << line_prefix << "." << debug_name << std::endl;
694 line_prefix += " ";
695 for (const command::Header &header : headers_) {
696 switch (header.type) {
697 default:
698 case Type::None:
699 break;
700 case Type::SubPass:
701 ss << sub_passes_[header.index].serialize(line_prefix);
702 break;
703 case Type::FramebufferBind:
704 ss << line_prefix << commands_[header.index].framebuffer_bind.serialize() << std::endl;
705 break;
706 case Type::SubPassTransition:
707 ss << line_prefix << commands_[header.index].subpass_transition.serialize() << std::endl;
708 break;
709 case Type::ShaderBind:
710 ss << line_prefix << commands_[header.index].shader_bind.serialize() << std::endl;
711 break;
712 case Type::ResourceBind:
713 ss << line_prefix << commands_[header.index].resource_bind.serialize() << std::endl;
714 break;
715 case Type::PushConstant:
716 ss << line_prefix << commands_[header.index].push_constant.serialize() << std::endl;
717 break;
718 case Type::Draw:
719 ss << line_prefix << commands_[header.index].draw.serialize() << std::endl;
720 break;
721 case Type::DrawMulti:
722 ss << commands_[header.index].draw_multi.serialize(line_prefix);
723 break;
724 case Type::DrawIndirect:
725 ss << line_prefix << commands_[header.index].draw_indirect.serialize() << std::endl;
726 break;
727 case Type::Dispatch:
728 ss << line_prefix << commands_[header.index].dispatch.serialize() << std::endl;
729 break;
730 case Type::DispatchIndirect:
731 ss << line_prefix << commands_[header.index].dispatch_indirect.serialize() << std::endl;
732 break;
733 case Type::Barrier:
734 ss << line_prefix << commands_[header.index].barrier.serialize() << std::endl;
735 break;
736 case Type::Clear:
737 ss << line_prefix << commands_[header.index].clear.serialize() << std::endl;
738 break;
739 case Type::ClearMulti:
740 ss << line_prefix << commands_[header.index].clear_multi.serialize() << std::endl;
741 break;
742 case Type::StateSet:
743 ss << line_prefix << commands_[header.index].state_set.serialize() << std::endl;
744 break;
745 case Type::StencilSet:
746 ss << line_prefix << commands_[header.index].stencil_set.serialize() << std::endl;
747 break;
748 }
749 }
750 return ss.str();
751}
752
755/* -------------------------------------------------------------------- */
759template<class T>
760inline void PassBase<T>::draw(gpu::Batch *batch,
761 uint instance_len,
762 uint vertex_len,
763 uint vertex_first,
764 ResourceHandle handle,
765 uint custom_id)
766{
767 if (instance_len == 0 || vertex_len == 0) {
768 return;
769 }
770 BLI_assert(shader_);
771 draw_commands_buf_.append_draw(headers_,
772 commands_,
773 batch,
774 instance_len,
775 vertex_len,
776 vertex_first,
777 handle,
778 custom_id,
779#ifdef WITH_METAL_BACKEND
780 GPU_shader_uses_ssbo_vertex_fetch(shader_) ? shader_ : nullptr,
781#endif
783 0);
784}
785
786template<class T>
787inline void PassBase<T>::draw(gpu::Batch *batch, ResourceHandle handle, uint custom_id)
788{
789 this->draw(batch, -1, -1, -1, handle, custom_id);
790}
791
792template<class T>
793inline void PassBase<T>::draw_expand(gpu::Batch *batch,
794 GPUPrimType primitive_type,
795 uint primitive_len,
796 uint instance_len,
797 uint vertex_len,
798 uint vertex_first,
799 ResourceHandle handle,
800 uint custom_id)
801{
802 if (instance_len == 0 || vertex_len == 0 || primitive_len == 0) {
803 return;
804 }
805 BLI_assert(shader_);
806 draw_commands_buf_.append_draw(headers_,
807 commands_,
808 batch,
809 instance_len,
810 vertex_len,
811 vertex_first,
812 handle,
813 custom_id,
814#ifdef WITH_METAL_BACKEND
815 GPU_shader_uses_ssbo_vertex_fetch(shader_) ? shader_ : nullptr,
816#endif
817 primitive_type,
818 primitive_len);
819}
820
821template<class T>
822inline void PassBase<T>::draw_expand(gpu::Batch *batch,
823 GPUPrimType primitive_type,
824 uint primitive_len,
825 uint instance_len,
826 ResourceHandle handle,
827 uint custom_id)
828{
829 this->draw_expand(batch, primitive_type, primitive_len, instance_len, -1, -1, handle, custom_id);
830}
831
832template<class T>
834 uint instance_len,
835 uint vertex_len,
836 uint vertex_first,
837 ResourceHandle handle,
838 uint custom_id)
839{
840 this->draw(
841 procedural_batch_get(primitive), instance_len, vertex_len, vertex_first, handle, custom_id);
842}
843
846/* -------------------------------------------------------------------- */
850template<class T>
851inline void PassBase<T>::draw_indirect(gpu::Batch *batch,
852 StorageBuffer<DrawCommand, true> &indirect_buffer,
853 ResourceHandle handle)
854{
855 BLI_assert(shader_);
856 create_command(Type::DrawIndirect).draw_indirect = {batch, &indirect_buffer, handle};
857}
858
859template<class T>
861 GPUPrimType primitive,
862 StorageBuffer<DrawCommand, true> &indirect_buffer,
863 ResourceHandle handle)
864{
865 this->draw_indirect(procedural_batch_get(primitive), indirect_buffer, handle);
866}
867
870/* -------------------------------------------------------------------- */
874template<class T> inline void PassBase<T>::dispatch(int group_len)
875{
876 BLI_assert(shader_);
877 create_command(Type::Dispatch).dispatch = {int3(group_len, 1, 1)};
878}
879
880template<class T> inline void PassBase<T>::dispatch(int2 group_len)
881{
882 BLI_assert(shader_);
883 create_command(Type::Dispatch).dispatch = {int3(group_len.x, group_len.y, 1)};
884}
885
886template<class T> inline void PassBase<T>::dispatch(int3 group_len)
887{
888 BLI_assert(shader_);
889 create_command(Type::Dispatch).dispatch = {group_len};
890}
891
892template<class T> inline void PassBase<T>::dispatch(int3 *group_len)
893{
894 BLI_assert(shader_);
895 create_command(Type::Dispatch).dispatch = {group_len};
896}
897
898template<class T>
900{
901 BLI_assert(shader_);
902 create_command(Type::DispatchIndirect).dispatch_indirect = {&indirect_buffer};
903}
904
907/* -------------------------------------------------------------------- */
911template<class T> inline void PassBase<T>::clear_color(float4 color)
912{
913 this->clear(GPU_COLOR_BIT, color, 0.0f, 0);
914}
915
916template<class T> inline void PassBase<T>::clear_depth(float depth)
917{
918 this->clear(GPU_DEPTH_BIT, float4(0.0f), depth, 0);
919}
920
921template<class T> inline void PassBase<T>::clear_stencil(uint8_t stencil)
922{
923 this->clear(GPU_STENCIL_BIT, float4(0.0f), 0.0f, stencil);
924}
925
926template<class T> inline void PassBase<T>::clear_depth_stencil(float depth, uint8_t stencil)
927{
928 this->clear(GPU_DEPTH_BIT | GPU_STENCIL_BIT, float4(0.0f), depth, stencil);
929}
930
931template<class T>
932inline void PassBase<T>::clear_color_depth_stencil(float4 color, float depth, uint8_t stencil)
933{
934 this->clear(GPU_DEPTH_BIT | GPU_STENCIL_BIT | GPU_COLOR_BIT, color, depth, stencil);
935}
936
939/* -------------------------------------------------------------------- */
943template<class T> inline void PassBase<T>::barrier(eGPUBarrier type)
944{
945 create_command(Type::Barrier).barrier = {type};
946}
947
950/* -------------------------------------------------------------------- */
954template<class T> inline void PassBase<T>::state_set(DRWState state, int clip_plane_count)
955{
957 if (clip_plane_count > 0) {
959 }
960 /* Assumed to always be enabled. */
962 create_command(Type::StateSet).state_set = {state, clip_plane_count};
963}
964
965template<class T>
966inline void PassBase<T>::state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask)
967{
968 create_command(Type::StencilSet).stencil_set = {write_mask, compare_mask, reference};
969}
970
971template<class T> inline void PassBase<T>::shader_set(GPUShader *shader)
972{
973 shader_ = shader;
974 create_command(Type::ShaderBind).shader_bind = {shader};
975}
976
977template<class T> inline void PassBase<T>::framebuffer_set(GPUFrameBuffer **framebuffer)
978{
979 create_command(Type::FramebufferBind).framebuffer_bind = {framebuffer};
980}
981
982template<class T>
984 Span<GPUAttachmentState> color_attachments)
985{
986 uint8_t color_states[8] = {GPU_ATTACHMENT_IGNORE};
987 for (auto i : color_attachments.index_range()) {
988 color_states[i] = uint8_t(color_attachments[i]);
989 }
990 create_command(Type::SubPassTransition).subpass_transition = {uint8_t(depth_attachment),
991 {color_states[0],
992 color_states[1],
993 color_states[2],
994 color_states[3],
995 color_states[4],
996 color_states[5],
997 color_states[6],
998 color_states[7]}};
999}
1000
1001template<class T> inline void PassBase<T>::material_set(Manager &manager, GPUMaterial *material)
1002{
1003 GPUPass *gpupass = GPU_material_get_pass(material);
1004 shader_set(GPU_pass_shader_get(gpupass));
1005
1006 /* Bind all textures needed by the material. */
1007 ListBase textures = GPU_material_textures(material);
1009 if (tex->ima) {
1010 /* Image */
1011 const bool use_tile_mapping = tex->tiled_mapping_name[0];
1012 ImageUser *iuser = tex->iuser_available ? &tex->iuser : nullptr;
1014 tex->ima, iuser, use_tile_mapping);
1015
1016 manager.acquire_texture(gputex.texture);
1017 bind_texture(tex->sampler_name, gputex.texture, tex->sampler_state);
1018
1019 if (gputex.tile_mapping) {
1020 manager.acquire_texture(gputex.tile_mapping);
1021 bind_texture(tex->tiled_mapping_name, gputex.tile_mapping, tex->sampler_state);
1022 }
1023 }
1024 else if (tex->colorband) {
1025 /* Color Ramp */
1026 bind_texture(tex->sampler_name, *tex->colorband);
1027 }
1028 else if (tex->sky) {
1029 /* Sky */
1030 bind_texture(tex->sampler_name, *tex->sky, tex->sampler_state);
1031 }
1032 }
1033
1034 GPUUniformBuf *ubo = GPU_material_uniform_buffer_get(material);
1035 if (ubo != nullptr) {
1036 bind_ubo(GPU_NODE_TREE_UBO_SLOT, ubo);
1037 }
1038}
1039
1042/* -------------------------------------------------------------------- */
1046template<class T> inline int PassBase<T>::push_constant_offset(const char *name)
1047{
1048 return GPU_shader_get_uniform(shader_, name);
1049}
1050
1051template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUStorageBuf *buffer)
1052{
1053 BLI_assert(buffer != nullptr);
1054 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1055}
1056
1057template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUUniformBuf *buffer)
1058{
1059 BLI_assert(buffer != nullptr);
1060 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1061}
1062
1063template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUUniformBuf **buffer)
1064{
1065 BLI_assert(buffer != nullptr);
1066 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1067}
1068
1069template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::VertBuf *buffer)
1070{
1071 BLI_assert(buffer != nullptr);
1072 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1073}
1074
1075template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::VertBuf **buffer)
1076{
1077 BLI_assert(buffer != nullptr);
1078 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1079}
1080
1081template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::IndexBuf *buffer)
1082{
1083 BLI_assert(buffer != nullptr);
1084 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1085}
1086
1087template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::IndexBuf **buffer)
1088{
1089 BLI_assert(buffer != nullptr);
1090 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1091}
1092
1093template<class T> inline void PassBase<T>::bind_ubo(const char *name, GPUUniformBuf *buffer)
1094{
1095 BLI_assert(buffer != nullptr);
1096 this->bind_ubo(GPU_shader_get_ubo_binding(shader_, name), buffer);
1097}
1098
1099template<class T>
1100inline void PassBase<T>::bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state)
1101{
1102 BLI_assert(texture != nullptr);
1103 this->bind_texture(GPU_shader_get_sampler_binding(shader_, name), texture, state);
1104}
1105
1106template<class T> inline void PassBase<T>::bind_texture(const char *name, gpu::VertBuf *buffer)
1107{
1108 BLI_assert(buffer != nullptr);
1109 this->bind_texture(GPU_shader_get_sampler_binding(shader_, name), buffer);
1110}
1111
1112template<class T> inline void PassBase<T>::bind_texture(const char *name, gpu::VertBuf **buffer)
1113{
1114 BLI_assert(buffer != nullptr);
1115 this->bind_texture(GPU_shader_get_sampler_binding(shader_, name), buffer);
1116}
1117
1118template<class T> inline void PassBase<T>::bind_image(const char *name, GPUTexture *image)
1119{
1120 BLI_assert(image != nullptr);
1121 this->bind_image(GPU_shader_get_sampler_binding(shader_, name), image);
1122}
1123
1124template<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUStorageBuf *buffer)
1125{
1126 BLI_assert(buffer != nullptr);
1127 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1128}
1129
1130template<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUUniformBuf *buffer)
1131{
1132 BLI_assert(buffer != nullptr);
1133 create_command(Type::ResourceBind).resource_bind = {
1134 slot, buffer, ResourceBind::Type::UniformAsStorageBuf};
1135}
1136
1137template<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUUniformBuf **buffer)
1138{
1139 BLI_assert(buffer != nullptr);
1140 create_command(Type::ResourceBind).resource_bind = {
1141 slot, buffer, ResourceBind::Type::UniformAsStorageBuf};
1142}
1143
1144template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::VertBuf *buffer)
1145{
1146 BLI_assert(buffer != nullptr);
1147 create_command(Type::ResourceBind).resource_bind = {
1148 slot, buffer, ResourceBind::Type::VertexAsStorageBuf};
1149}
1150
1151template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::VertBuf **buffer)
1152{
1153 BLI_assert(buffer != nullptr);
1154 create_command(Type::ResourceBind).resource_bind = {
1155 slot, buffer, ResourceBind::Type::VertexAsStorageBuf};
1156}
1157
1158template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::IndexBuf *buffer)
1159{
1160 BLI_assert(buffer != nullptr);
1161 create_command(Type::ResourceBind).resource_bind = {
1162 slot, buffer, ResourceBind::Type::IndexAsStorageBuf};
1163}
1164
1165template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::IndexBuf **buffer)
1166{
1167 BLI_assert(buffer != nullptr);
1168 create_command(Type::ResourceBind).resource_bind = {
1169 slot, buffer, ResourceBind::Type::IndexAsStorageBuf};
1170}
1171
1172template<class T> inline void PassBase<T>::bind_ubo(int slot, GPUUniformBuf *buffer)
1173{
1174 BLI_assert(buffer != nullptr);
1175 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1176}
1177
1178template<class T>
1179inline void PassBase<T>::bind_texture(int slot, GPUTexture *texture, GPUSamplerState state)
1180{
1181 BLI_assert(texture != nullptr);
1182 create_command(Type::ResourceBind).resource_bind = {slot, texture, state};
1183}
1184
1185template<class T> inline void PassBase<T>::bind_texture(int slot, gpu::VertBuf *buffer)
1186{
1187 BLI_assert(buffer != nullptr);
1188 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1189}
1190
1191template<class T> inline void PassBase<T>::bind_texture(int slot, gpu::VertBuf **buffer)
1192{
1193 BLI_assert(buffer != nullptr);
1194 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1195}
1196
1197template<class T> inline void PassBase<T>::bind_image(int slot, GPUTexture *image)
1198{
1199 BLI_assert(image != nullptr);
1200 create_command(Type::ResourceBind).resource_bind = {slot, as_image(image)};
1201}
1202
1203template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUStorageBuf **buffer)
1204{
1205 BLI_assert(buffer != nullptr);
1206 this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
1207}
1208
1209template<class T> inline void PassBase<T>::bind_ubo(const char *name, GPUUniformBuf **buffer)
1210{
1211 BLI_assert(buffer != nullptr);
1212 this->bind_ubo(GPU_shader_get_ubo_binding(shader_, name), buffer);
1213}
1214
1215template<class T>
1216inline void PassBase<T>::bind_texture(const char *name,
1217 GPUTexture **texture,
1219{
1220 BLI_assert(texture != nullptr);
1221 this->bind_texture(GPU_shader_get_sampler_binding(shader_, name), texture, state);
1222}
1223
1224template<class T> inline void PassBase<T>::bind_image(const char *name, GPUTexture **image)
1225{
1226 BLI_assert(image != nullptr);
1227 this->bind_image(GPU_shader_get_sampler_binding(shader_, name), image);
1228}
1229
1230template<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUStorageBuf **buffer)
1231{
1232
1233 BLI_assert(buffer != nullptr);
1234 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1235}
1236
1237template<class T> inline void PassBase<T>::bind_ubo(int slot, GPUUniformBuf **buffer)
1238{
1239 BLI_assert(buffer != nullptr);
1240 create_command(Type::ResourceBind).resource_bind = {slot, buffer};
1241}
1242
1243template<class T>
1244inline void PassBase<T>::bind_texture(int slot, GPUTexture **texture, GPUSamplerState state)
1245{
1246 BLI_assert(texture != nullptr);
1247 create_command(Type::ResourceBind).resource_bind = {slot, texture, state};
1248}
1249
1250template<class T> inline void PassBase<T>::bind_image(int slot, GPUTexture **image)
1251{
1252 BLI_assert(image != nullptr);
1253 create_command(Type::ResourceBind).resource_bind = {slot, as_image(image)};
1254}
1255
1258/* -------------------------------------------------------------------- */
1262template<class T> inline void PassBase<T>::push_constant(const char *name, const float &data)
1263{
1264 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1265}
1266
1267template<class T> inline void PassBase<T>::push_constant(const char *name, const float2 &data)
1268{
1269 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1270}
1271
1272template<class T> inline void PassBase<T>::push_constant(const char *name, const float3 &data)
1273{
1274 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1275}
1276
1277template<class T> inline void PassBase<T>::push_constant(const char *name, const float4 &data)
1278{
1279 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1280}
1281
1282template<class T> inline void PassBase<T>::push_constant(const char *name, const int &data)
1283{
1284 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1285}
1286
1287template<class T> inline void PassBase<T>::push_constant(const char *name, const int2 &data)
1288{
1289 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1290}
1291
1292template<class T> inline void PassBase<T>::push_constant(const char *name, const int3 &data)
1293{
1294 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1295}
1296
1297template<class T> inline void PassBase<T>::push_constant(const char *name, const int4 &data)
1298{
1299 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1300}
1301
1302template<class T> inline void PassBase<T>::push_constant(const char *name, const bool &data)
1303{
1304 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1305}
1306
1307template<class T>
1308inline void PassBase<T>::push_constant(const char *name, const float *data, int array_len)
1309{
1310 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1311}
1312
1313template<class T>
1314inline void PassBase<T>::push_constant(const char *name, const float2 *data, int array_len)
1315{
1316 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1317}
1318
1319template<class T>
1320inline void PassBase<T>::push_constant(const char *name, const float3 *data, int array_len)
1321{
1322 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1323}
1324
1325template<class T>
1326inline void PassBase<T>::push_constant(const char *name, const float4 *data, int array_len)
1327{
1328 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1329}
1330
1331template<class T>
1332inline void PassBase<T>::push_constant(const char *name, const int *data, int array_len)
1333{
1334 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1335}
1336
1337template<class T>
1338inline void PassBase<T>::push_constant(const char *name, const int2 *data, int array_len)
1339{
1340 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1341}
1342
1343template<class T>
1344inline void PassBase<T>::push_constant(const char *name, const int3 *data, int array_len)
1345{
1346 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1347}
1348
1349template<class T>
1350inline void PassBase<T>::push_constant(const char *name, const int4 *data, int array_len)
1351{
1352 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data, array_len};
1353}
1354
1355template<class T> inline void PassBase<T>::push_constant(const char *name, const float4x4 *data)
1356{
1357 create_command(Type::PushConstant).push_constant = {push_constant_offset(name), data};
1358}
1359
1360template<class T> inline void PassBase<T>::push_constant(const char *name, const float4x4 &data)
1361{
1362 /* WORKAROUND: Push 3 consecutive commands to hold the 64 bytes of the float4x4.
1363 * This assumes that all commands are always stored in flat array of memory. */
1364 Undetermined commands[3];
1365
1366 PushConstant &cmd = commands[0].push_constant;
1367 cmd.location = push_constant_offset(name);
1368 cmd.array_len = 1;
1369 cmd.comp_len = 16;
1370 cmd.type = PushConstant::Type::FloatValue;
1371 /* Copy overrides the next 2 commands. We append them as Type::None to not evaluate them. */
1372 *reinterpret_cast<float4x4 *>(&cmd.float4_value) = data;
1373
1374 create_command(Type::PushConstant) = commands[0];
1375 create_command(Type::None) = commands[1];
1376 create_command(Type::None) = commands[2];
1377}
1378
1381/* -------------------------------------------------------------------- */
1385template<class T>
1387 const char *constant_name,
1388 const int &constant_value)
1389{
1390 create_command(Type::SpecializeConstant).specialize_constant = {
1391 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1392}
1393
1394template<class T>
1396 const char *constant_name,
1397 const uint &constant_value)
1398{
1399 create_command(Type::SpecializeConstant).specialize_constant = {
1400 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1401}
1402
1403template<class T>
1405 const char *constant_name,
1406 const float &constant_value)
1407{
1408 create_command(Type::SpecializeConstant).specialize_constant = {
1409 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1410}
1411
1412template<class T>
1414 const char *constant_name,
1415 const bool &constant_value)
1416{
1417 create_command(Type::SpecializeConstant).specialize_constant = {
1418 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1419}
1420
1421template<class T>
1423 const char *constant_name,
1424 const int *constant_value)
1425{
1426 create_command(Type::SpecializeConstant).specialize_constant = {
1427 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1428}
1429
1430template<class T>
1432 const char *constant_name,
1433 const uint *constant_value)
1434{
1435 create_command(Type::SpecializeConstant).specialize_constant = {
1436 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1437}
1438
1439template<class T>
1441 const char *constant_name,
1442 const float *constant_value)
1443{
1444 create_command(Type::SpecializeConstant).specialize_constant = {
1445 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1446}
1447
1448template<class T>
1450 const char *constant_name,
1451 const bool *constant_value)
1452{
1453 create_command(Type::SpecializeConstant).specialize_constant = {
1454 shader, GPU_shader_get_constant(shader, constant_name), constant_value};
1455}
1456
1459} // namespace detail
1460
1461} // namespace blender::draw
ImageGPUTextures BKE_image_get_gpu_material_texture(Image *image, ImageUser *iuser, const bool use_tile_mapping)
Definition image_gpu.cc:486
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
#define BLI_assert(a)
Definition BLI_assert.h:50
unsigned int uint
GPUAttachmentState
@ GPU_ATTACHMENT_IGNORE
void GPU_debug_group_end()
Definition gpu_debug.cc:33
void GPU_debug_group_begin(const char *name)
Definition gpu_debug.cc:22
eGPUFrameBufferBits
@ GPU_DEPTH_BIT
@ GPU_STENCIL_BIT
@ GPU_COLOR_BIT
GPUPass * GPU_material_get_pass(GPUMaterial *material)
ListBase GPU_material_textures(GPUMaterial *material)
GPUUniformBuf * GPU_material_uniform_buffer_get(GPUMaterial *material)
GPUPrimType
@ GPU_PRIM_NONE
@ GPU_PRIM_LINES
@ GPU_PRIM_POINTS
@ GPU_PRIM_TRI_STRIP
@ GPU_PRIM_TRIS
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
int GPU_shader_get_ubo_binding(GPUShader *shader, const char *name)
bool GPU_shader_uses_ssbo_vertex_fetch(GPUShader *shader)
int GPU_shader_get_ssbo_binding(GPUShader *shader, const char *name)
int GPU_shader_get_constant(GPUShader *shader, const char *name)
eGPUBarrier
Definition GPU_state.hh:29
#define GPU_NODE_TREE_UBO_SLOT
struct GPUShader GPUShader
unsigned int U
Definition btGjkEpa3.h:78
constexpr IndexRange index_range() const
Definition BLI_span.hh:402
int64_t size() const
int64_t append_and_get_index(const T &value)
void append(const T &value)
const T & last(const int64_t n=0) const
bool is_empty() const
void acquire_texture(GPUTexture *texture)
std::string serialize(std::string line_prefix="") const
Definition draw_pass.hh:545
PassSortable(const char *name_)
Definition draw_pass.hh:519
PassMain::Sub & sub(const char *name, float sorting_value)
Definition draw_pass.hh:528
void bind_ssbo(int slot, gpu::IndexBuf *buffer)
void clear_multi(Span< float4 > colors)
Definition draw_pass.hh:592
void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state=sampler_auto)
void specialize_constant(GPUShader *shader, const char *name, const uint &data)
void bind_texture(const char *name, GPUTexture **texture, GPUSamplerState state=sampler_auto)
void push_constant(const char *name, const float3 *data, int array_len=1)
void dispatch(StorageBuffer< DispatchCommand > &indirect_buffer)
Definition draw_pass.hh:899
void push_constant(const char *name, const int *data, int array_len=1)
void bind_texture(int slot, gpu::VertBuf *buffer)
void push_constant(const char *name, const int &data)
void bind_resources(U &resources)
Definition draw_pass.hh:426
void draw_procedural_indirect(GPUPrimType primitive, StorageBuffer< DrawCommand, true > &indirect_buffer, ResourceHandle handle={0})
Definition draw_pass.hh:860
void bind_ssbo(int slot, GPUStorageBuf **buffer)
void push_constant(const char *name, const int2 &data)
void bind_image(const char *name, GPUTexture *image)
void draw_expand(gpu::Batch *batch, GPUPrimType primitive_type, uint primitive_len, uint instance_len, ResourceHandle handle={0}, uint custom_id=0)
Definition draw_pass.hh:822
void push_constant(const char *name, const bool &data)
friend std::ostream & operator<<(std::ostream &stream, const PassBase &pass)
Definition draw_pass.hh:436
void push_constant(const char *name, const int3 &data)
void bind_ssbo(const char *name, gpu::IndexBuf *buffer)
void bind_ssbo(int slot, gpu::VertBuf **buffer)
void push_constant(const char *name, const float *data, int array_len=1)
void clear_depth(float depth)
Definition draw_pass.hh:916
void bind_texture(int slot, GPUTexture **texture, GPUSamplerState state=sampler_auto)
Vector< command::Header, 0 > headers_
Definition draw_pass.hh:132
void specialize_constant(GPUShader *shader, const char *name, const bool *data)
void specialize_constant(GPUShader *shader, const char *name, const float &data)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
Definition draw_pass.hh:760
void clear_stencil(uint8_t stencil)
Definition draw_pass.hh:921
void clear_color(float4 color)
Definition draw_pass.hh:911
void push_constant(const char *name, const float4 *data, int array_len=1)
void subpass_transition(GPUAttachmentState depth_attachment, Span< GPUAttachmentState > color_attachments)
Definition draw_pass.hh:983
void bind_texture(const char *name, gpu::VertBuf *buffer)
void push_constant(const char *name, const float4x4 *data)
void bind_ssbo(int slot, gpu::VertBuf *buffer)
void clear_depth_stencil(float depth, uint8_t stencil)
Definition draw_pass.hh:926
void bind_ssbo(int slot, GPUUniformBuf **buffer)
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
Definition draw_pass.hh:833
void specialize_constant(GPUShader *shader, const char *name, const int *data)
void push_constant(const char *name, const float2 &data)
void dispatch(int3 *group_len)
Definition draw_pass.hh:892
SubPassVector< PassBase< DrawCommandBufType > > & sub_passes_
Definition draw_pass.hh:138
void bind_ubo(int slot, GPUUniformBuf **buffer)
PassBase(const char *name, DrawCommandBufType &draw_command_buf, SubPassVector< PassBase< DrawCommandBufType > > &sub_passes, GPUShader *shader=nullptr)
Definition draw_pass.hh:147
void bind_image(const char *name, GPUTexture **image)
command::Undetermined & create_command(command::Type type)
Definition draw_pass.hh:576
void bind_ssbo(const char *name, gpu::VertBuf *buffer)
void bind_ssbo(const char *name, gpu::IndexBuf **buffer)
void specialize_constant(GPUShader *shader, const char *name, const uint *data)
PassBase< DrawCommandBufType > & sub(const char *name)
Definition draw_pass.hh:616
void dispatch(int group_len)
Definition draw_pass.hh:874
int push_constant_offset(const char *name)
void bind_image(int slot, GPUTexture *image)
void submit(command::RecordingState &state) const
Definition draw_pass.hh:624
void push_constant(const char *name, const float4x4 &data)
void bind_ssbo(int slot, gpu::IndexBuf **buffer)
void push_constant(const char *name, const float2 *data, int array_len=1)
void push_constant(const char *name, const float4 &data)
void barrier(eGPUBarrier type)
Definition draw_pass.hh:943
void state_set(DRWState state, int clip_plane_count=0)
Definition draw_pass.hh:954
void bind_ssbo(int slot, GPUUniformBuf *buffer)
void bind_ubo(const char *name, GPUUniformBuf **buffer)
void specialize_constant(GPUShader *shader, const char *name, const float *data)
void specialize_constant(GPUShader *shader, const char *name, const bool &data)
void draw_indirect(gpu::Batch *batch, StorageBuffer< DrawCommand, true > &indirect_buffer, ResourceHandle handle={0})
Definition draw_pass.hh:851
void bind_ubo(const char *name, GPUUniformBuf *buffer)
void push_constant(const char *name, const int2 *data, int array_len=1)
void dispatch(int3 group_len)
Definition draw_pass.hh:886
void clear(eGPUFrameBufferBits planes, float4 color, float depth, uint8_t stencil)
Definition draw_pass.hh:584
void dispatch(int2 group_len)
Definition draw_pass.hh:880
void push_constant(const char *name, const float3 &data)
void framebuffer_set(GPUFrameBuffer **framebuffer)
Definition draw_pass.hh:977
Vector< command::Undetermined, 0 > commands_
Definition draw_pass.hh:134
void state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask)
Definition draw_pass.hh:966
void clear_color_depth_stencil(float4 color, float depth, uint8_t stencil)
Definition draw_pass.hh:932
std::string serialize(std::string line_prefix="") const
Definition draw_pass.hh:690
void push_constant(const char *name, const float &data)
void bind_ssbo(const char *name, gpu::VertBuf **buffer)
void push_constant(const char *name, const int4 *data, int array_len=1)
void bind_texture(int slot, GPUTexture *texture, GPUSamplerState state=sampler_auto)
void bind_ssbo(const char *name, GPUUniformBuf **buffer)
void bind_ssbo(int slot, GPUStorageBuf *buffer)
void bind_ssbo(const char *name, GPUUniformBuf *buffer)
void bind_texture(const char *name, gpu::VertBuf **buffer)
void draw_expand(gpu::Batch *batch, GPUPrimType primitive_type, uint primitive_len, uint instance_len, uint vertex_len=-1, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
Definition draw_pass.hh:793
void specialize_constant(GPUShader *shader, const char *name, const int &data)
void bind_ubo(int slot, GPUUniformBuf *buffer)
void push_constant(const char *name, const int4 &data)
void material_set(Manager &manager, GPUMaterial *material)
void draw(gpu::Batch *batch, ResourceHandle handle, uint custom_id=0)
Definition draw_pass.hh:787
void bind_texture(int slot, gpu::VertBuf **buffer)
void bind_ssbo(const char *name, GPUStorageBuf **buffer)
gpu::Batch * procedural_batch_get(GPUPrimType primitive)
Definition draw_pass.hh:598
DrawCommandBufType & draw_commands_buf_
Definition draw_pass.hh:136
void bind_ssbo(const char *name, GPUStorageBuf *buffer)
void push_constant(const char *name, const int3 *data, int array_len=1)
void shader_set(GPUShader *shader)
Definition draw_pass.hh:971
void bind_image(int slot, GPUTexture **image)
Pass(const char *name)
Definition draw_pass.hh:471
const T & operator[](int64_t index) const
Definition draw_pass.hh:111
int64_t append_and_get_index(T &&elem)
Definition draw_pass.hh:96
local_group_size(16, 16) .push_constant(Type b
local_group_size(16, 16) .push_constant(Type texture
blender::gpu::Batch * drw_cache_procedural_lines_get()
blender::gpu::Batch * drw_cache_procedural_triangles_get()
blender::gpu::Batch * drw_cache_procedural_triangle_strips_get()
blender::gpu::Batch * drw_cache_procedural_points_get()
DRWState
Definition draw_state.hh:25
@ DRW_STATE_CLIP_PLANES
Definition draw_state.hh:69
@ DRW_STATE_PROGRAM_POINT_SIZE
Definition draw_state.hh:72
struct @620::@622 batch
GPUShader * GPU_pass_shader_get(GPUPass *pass)
static ulong state[N]
#define T
static void clear(Message &msg)
Definition msgfmt.cc:218
VecBase< float, 4 > float4
VecBase< int32_t, 3 > int3
ListBaseWrapperTemplate< ListBase, T > ListBaseWrapper
__int64 int64_t
Definition stdint.h:89
unsigned char uint8_t
Definition stdint.h:78
static constexpr GPUSamplerState internal_sampler()
GPUTexture * tile_mapping
Definition BKE_image.hh:584
GPUTexture * texture
Definition BKE_image.hh:583
struct ImageUser iuser
struct Image * ima
enum blender::draw::command::PushConstant::Type type