Blender V5.0
draw_command.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "GPU_batch.hh"
10#include "GPU_capabilities.hh"
11#include "GPU_compute.hh"
12#include "GPU_debug.hh"
13
14#include "draw_command.hh"
15#include "draw_pass.hh"
16#include "draw_shader.hh"
17#include "draw_view.hh"
18
19#include <bitset>
20#include <sstream>
21
23
24static gpu::Batch *procedural_batch_get(GPUPrimType primitive)
25{
26 switch (primitive) {
27 case GPU_PRIM_POINTS:
29 case GPU_PRIM_LINES:
31 case GPU_PRIM_TRIS:
35 default:
36 /* Add new one as needed. */
38 return nullptr;
39 }
40}
41
42/* -------------------------------------------------------------------- */
45
47{
48 state.shader_use_specialization = !GPU_shader_get_default_constant_state(shader).is_empty();
49 if (assign_if_different(state.shader, shader) || state.shader_use_specialization) {
50 GPU_shader_bind(shader, state.specialization_constants_get());
51 }
52 /* Signal that we can reload the default for a different specialization later on.
53 * However, we keep the specialization_constants state around for compute shaders. */
54 state.specialization_constants_in_use = false;
55}
56
61
63{
64 /* TODO(fclem): Require framebuffer bind to always be part of the pass so that we can track it
65 * inside RecordingState. */
67 /* Unpack to the real enum type. */
68 const GPUAttachmentState states[9] = {
78 };
79 GPU_framebuffer_subpass_transition_array(framebuffer, states, ARRAY_SIZE(states));
80}
81
114
135
137{
138 /* All specialization constants should exist as they are not optimized out like uniforms. */
139 BLI_assert(location != -1);
140
141 if (state.specialization_constants_in_use == false) {
142 state.specialization_constants = GPU_shader_get_default_constant_state(this->shader);
143 state.specialization_constants_in_use = true;
144 }
145
146 switch (type) {
148 state.specialization_constants.set_value(location, int_value);
149 break;
151 state.specialization_constants.set_value(location, *int_ref);
152 break;
154 state.specialization_constants.set_value(location, uint_value);
155 break;
157 state.specialization_constants.set_value(location, *uint_ref);
158 break;
160 state.specialization_constants.set_value(location, float_value);
161 break;
163 state.specialization_constants.set_value(location, *float_ref);
164 break;
166 state.specialization_constants.set_value(location, bool_value);
167 break;
169 state.specialization_constants.set_value(location, *bool_ref);
170 break;
171 }
172}
173
175{
176 state.front_facing_set(res_index.has_inverted_handedness());
177
178 /* Use same logic as in `finalize_commands`. */
179 uint instance_first = 0;
180 if (res_index.raw > 0) {
181 instance_first = state.instance_offset;
182 state.instance_offset += instance_len;
183 }
184
186
188 /* Expanded draw-call. */
190 batch->prim_type,
195
196 if (expanded_range.is_empty()) {
197 /* Nothing to draw, and can lead to asserts in GPU_batch_bind_as_resources. */
198 return;
199 }
200
201 GPU_batch_bind_as_resources(batch, state.shader, state.specialization_constants_get());
202
203 gpu::Batch *gpu_batch = procedural_batch_get(GPUPrimType(expand_prim_type));
204 GPU_batch_set_shader(gpu_batch, state.shader, state.specialization_constants_get());
206 gpu_batch, expanded_range.start(), expanded_range.size(), instance_first, instance_len);
207 }
208 else {
209 /* Regular draw-call. */
210 GPU_batch_set_shader(batch, state.shader, state.specialization_constants_get());
212 }
213}
214
216{
217 DrawMultiBuf::DrawCommandBuf &indirect_buf = multi_draw_buf->command_buf_;
218 DrawMultiBuf::DrawGroupBuf &groups = multi_draw_buf->group_buf_;
219
220 uint group_index = this->group_first;
221 while (group_index != uint(-1)) {
222 const DrawGroup &group = groups[group_index];
223
224 if (group.vertex_len > 0) {
225 gpu::Batch *batch = group.desc.gpu_batch;
226
228 /* Bind original batch as resource and use a procedural batch to issue the draw-call. */
230 group.desc.gpu_batch, state.shader, state.specialization_constants_get());
232 }
233
234 GPU_batch_set_shader(batch, state.shader, state.specialization_constants_get());
235
236 constexpr intptr_t stride = sizeof(DrawCommand);
237 /* We have 2 indirect command reserved per draw group. */
238 intptr_t offset = stride * group_index * 2;
239
240 /* Draw negatively scaled geometry first. */
241 if (group.len - group.front_facing_len > 0) {
242 state.front_facing_set(true);
243 GPU_batch_draw_indirect(batch, indirect_buf, offset);
244 }
245
246 if (group.front_facing_len > 0) {
247 state.front_facing_set(false);
248 GPU_batch_draw_indirect(batch, indirect_buf, offset + stride);
249 }
250 }
251
252 group_index = group.next;
253 }
254}
255
257{
258 state.front_facing_set(res_index.has_inverted_handedness());
259
261}
262
264{
265 if (is_reference) {
267 state.shader, size_ref->x, size_ref->y, size_ref->z, state.specialization_constants_get());
268 }
269 else {
271 state.shader, size.x, size.y, size.z, state.specialization_constants_get());
272 }
273}
274
276{
277 GPU_compute_dispatch_indirect(state.shader, *indirect_buf, state.specialization_constants_get());
278}
279
281{
283}
284
290
296
297void StateSet::execute(RecordingState &recording_state) const
298{
299 bool state_changed = assign_if_different(recording_state.pipeline_state, new_state);
300 bool clip_changed = assign_if_different(recording_state.clip_plane_count, clip_plane_count);
301
302 if (!state_changed && !clip_changed) {
303 return;
304 }
305
313
316 }
317 else {
319 }
320
322 GPU_shadow_offset(true);
323 }
324 else {
325 GPU_shadow_offset(false);
326 }
327
328 /* TODO: this should be part of shader state. */
329 GPU_clip_distances(recording_state.clip_plane_count);
330
332 /* XXX `GPU_depth_range` is not a perfect solution
333 * since very distant geometries can still be occluded.
334 * Also the depth test precision of these geometries is impaired.
335 * However, it solves the selection for the vast majority of cases. */
336 GPU_depth_range(0.0f, 0.01f);
337 }
338 else {
339 GPU_depth_range(0.0f, 1.0f);
340 }
341
344 }
345 else {
347 }
348}
349
351{
352 RecordingState recording_state;
353 StateSet{state, 0}.execute(recording_state);
354
355 /* This function is used for cleaning the state for the viewport drawing.
356 * Make sure to reset textures resources to avoid feedback loop when rendering (see #131652). */
361
362 /* Remained of legacy draw manager. Kept it to avoid regression, but might become unneeded. */
364 GPU_line_smooth(false);
365 GPU_line_width(0.0f);
366}
367
374
376
377/* -------------------------------------------------------------------- */
380
381std::string ShaderBind::serialize() const
382{
383 return std::string(".shader_bind(") + GPU_shader_get_name(shader) + ")";
384}
385
386std::string FramebufferBind::serialize() const
387{
388 return std::string(".framebuffer_bind(") +
389 (*framebuffer == nullptr ? "nullptr" : GPU_framebuffer_get_name(*framebuffer)) + ")";
390}
391
393{
394 auto to_str = [](GPUAttachmentState state) {
395 return (state != GPU_ATTACHMENT_IGNORE) ?
396 ((state == GPU_ATTACHMENT_WRITE) ? "write" : "read") :
397 "ignore";
398 };
399
400 return std::string(".subpass_transition(\n") +
401 "depth=" + to_str(GPUAttachmentState(depth_state)) + ",\n" +
402 "color0=" + to_str(GPUAttachmentState(color_states[0])) + ",\n" +
403 "color1=" + to_str(GPUAttachmentState(color_states[1])) + ",\n" +
404 "color2=" + to_str(GPUAttachmentState(color_states[2])) + ",\n" +
405 "color3=" + to_str(GPUAttachmentState(color_states[3])) + ",\n" +
406 "color4=" + to_str(GPUAttachmentState(color_states[4])) + ",\n" +
407 "color5=" + to_str(GPUAttachmentState(color_states[5])) + ",\n" +
408 "color6=" + to_str(GPUAttachmentState(color_states[6])) + ",\n" +
409 "color7=" + to_str(GPUAttachmentState(color_states[7])) + "\n)";
410}
411
412std::string ResourceBind::serialize() const
413{
414 switch (type) {
415 case Type::Sampler:
416 return std::string(".bind_texture") + (is_reference ? "_ref" : "") + "(" +
417 std::to_string(slot) + ", sampler=" + sampler.to_string() + ")";
419 return std::string(".bind_vertbuf_as_texture") + (is_reference ? "_ref" : "") + "(" +
420 std::to_string(slot) + ")";
421 case Type::Image:
422 return std::string(".bind_image") + (is_reference ? "_ref" : "") + "(" +
423 std::to_string(slot) + ")";
424 case Type::UniformBuf:
425 return std::string(".bind_uniform_buf") + (is_reference ? "_ref" : "") + "(" +
426 std::to_string(slot) + ")";
427 case Type::StorageBuf:
428 return std::string(".bind_storage_buf") + (is_reference ? "_ref" : "") + "(" +
429 std::to_string(slot) + ")";
431 return std::string(".bind_uniform_as_ssbo") + (is_reference ? "_ref" : "") + "(" +
432 std::to_string(slot) + ")";
434 return std::string(".bind_vertbuf_as_ssbo") + (is_reference ? "_ref" : "") + "(" +
435 std::to_string(slot) + ")";
437 return std::string(".bind_indexbuf_as_ssbo") + (is_reference ? "_ref" : "") + "(" +
438 std::to_string(slot) + ")";
439 default:
441 return "";
442 }
443}
444
445std::string PushConstant::serialize() const
446{
447 std::stringstream ss;
448 for (int i = 0; i < array_len; i++) {
449 switch (comp_len) {
450 case 1:
451 switch (type) {
452 case Type::IntValue:
453 ss << int1_value;
454 break;
456 ss << int_ref[i];
457 break;
458 case Type::FloatValue:
459 ss << float1_value;
460 break;
462 ss << float_ref[i];
463 break;
464 }
465 break;
466 case 2:
467 switch (type) {
468 case Type::IntValue:
469 ss << int2_value;
470 break;
472 ss << int2_ref[i];
473 break;
474 case Type::FloatValue:
475 ss << float2_value;
476 break;
478 ss << float2_ref[i];
479 break;
480 }
481 break;
482 case 3:
483 switch (type) {
484 case Type::IntValue:
485 ss << int3_value;
486 break;
488 ss << int3_ref[i];
489 break;
490 case Type::FloatValue:
491 ss << float3_value;
492 break;
494 ss << float3_ref[i];
495 break;
496 }
497 break;
498 case 4:
499 switch (type) {
500 case Type::IntValue:
501 ss << int4_value;
502 break;
504 ss << int4_ref[i];
505 break;
506 case Type::FloatValue:
507 ss << float4_value;
508 break;
510 ss << float4_ref[i];
511 break;
512 }
513 break;
514 case 16:
515 switch (type) {
516 case Type::IntValue:
519 break;
520 case Type::FloatValue:
521 ss << float4x4(
522 (&float4_value)[0], (&float4_value)[1], (&float4_value)[2], (&float4_value)[3]);
523 break;
525 ss << *float4x4_ref;
526 break;
527 }
528 break;
529 }
530 if (i < array_len - 1) {
531 ss << ", ";
532 }
533 }
534
535 return std::string(".push_constant(") + std::to_string(location) + ", data=" + ss.str() + ")";
536}
537
539{
540 std::stringstream ss;
541 switch (type) {
542 case Type::IntValue:
543 ss << int_value;
544 break;
545 case Type::UintValue:
546 ss << uint_value;
547 break;
548 case Type::FloatValue:
549 ss << float_value;
550 break;
551 case Type::BoolValue:
552 ss << bool_value;
553 break;
555 ss << *int_ref;
556 break;
558 ss << *uint_ref;
559 break;
561 ss << *float_ref;
562 break;
564 ss << *bool_ref;
565 break;
566 }
567 return std::string(".specialize_constant(") + std::to_string(location) + ", data=" + ss.str() +
568 ")";
569}
570
571std::string Draw::serialize() const
572{
573 std::string inst_len = std::to_string(instance_len);
574 std::string vert_len = (vertex_len == uint(-1)) ? "from_batch" : std::to_string(vertex_len);
575 std::string vert_first = (vertex_first == uint(-1)) ? "from_batch" :
576 std::to_string(vertex_first);
577 return std::string(".draw(inst_len=") + inst_len + ", vert_len=" + vert_len +
578 ", vert_first=" + vert_first + ", res_id=" + std::to_string(res_index.resource_index()) +
579 ")";
580}
581
582std::string DrawMulti::serialize(const std::string &line_prefix) const
583{
584 DrawMultiBuf::DrawGroupBuf &groups = multi_draw_buf->group_buf_;
585
586 MutableSpan<DrawPrototype> prototypes(multi_draw_buf->prototype_buf_.data(),
587 multi_draw_buf->prototype_count_);
588
589 /* This emulates the GPU sorting but without the unstable draw order. */
590 std::sort(
591 prototypes.begin(), prototypes.end(), [](const DrawPrototype &a, const DrawPrototype &b) {
592 return (a.group_id < b.group_id) ||
593 (a.group_id == b.group_id && a.res_index > b.res_index);
594 });
595
596 /* Compute prefix sum to have correct offsets. */
597 uint prefix_sum = 0u;
598 for (DrawGroup &group : groups) {
599 group.start = prefix_sum;
600 prefix_sum += group.front_facing_counter + group.back_facing_counter;
601 }
602
603 std::stringstream ss;
604
605 uint group_len = 0;
606 uint group_index = this->group_first;
607 while (group_index != uint(-1)) {
608 const DrawGroup &grp = groups[group_index];
609
610 ss << std::endl << line_prefix << " .group(id=" << group_index << ", len=" << grp.len << ")";
611
612 intptr_t offset = grp.start;
613
614 if (grp.back_facing_counter > 0) {
615 for (DrawPrototype &proto : prototypes.slice_safe({offset, grp.back_facing_counter})) {
616 BLI_assert(proto.group_id == group_index);
617 ResourceIndex res_index(proto.res_index);
619 ss << std::endl
620 << line_prefix << " .proto(instance_len=" << std::to_string(proto.instance_len)
621 << ", resource_id=" << std::to_string(res_index.resource_index()) << ", back_face)";
622 }
623 offset += grp.back_facing_counter;
624 }
625
626 if (grp.front_facing_counter > 0) {
627 for (DrawPrototype &proto : prototypes.slice_safe({offset, grp.front_facing_counter})) {
628 BLI_assert(proto.group_id == group_index);
629 ResourceIndex res_index(proto.res_index);
631 ss << std::endl
632 << line_prefix << " .proto(instance_len=" << std::to_string(proto.instance_len)
633 << ", resource_id=" << std::to_string(res_index.resource_index()) << ", front_face)";
634 }
635 }
636
637 group_index = grp.next;
638 group_len++;
639 }
640
641 ss << std::endl;
642
643 return line_prefix + ".draw_multi(" + std::to_string(group_len) + ")" + ss.str();
644}
645
646std::string DrawIndirect::serialize() const
647{
648 return std::string(".draw_indirect()");
649}
650
651std::string Dispatch::serialize() const
652{
653 int3 sz = is_reference ? *size_ref : size;
654 return std::string(".dispatch") + (is_reference ? "_ref" : "") + "(" + std::to_string(sz.x) +
655 ", " + std::to_string(sz.y) + ", " + std::to_string(sz.z) + ")";
656}
657
659{
660 return std::string(".dispatch_indirect()");
661}
662
663std::string Barrier::serialize() const
664{
665 /* TODO(@fclem): Better serialization... */
666 return std::string(".barrier(") + std::to_string(type) + ")";
667}
668
669std::string Clear::serialize() const
670{
671 std::stringstream ss;
673 ss << "color=" << color;
675 ss << ", ";
676 }
677 }
679 ss << "depth=" << depth;
681 ss << ", ";
682 }
683 }
685 ss << "stencil=0b" << std::bitset<8>(stencil) << ")";
686 }
687 return std::string(".clear(") + ss.str() + ")";
688}
689
690std::string ClearMulti::serialize() const
691{
692 std::stringstream ss;
694 ss << color << ", ";
695 }
696 return std::string(".clear_multi(colors={") + ss.str() + "})";
697}
698
699std::string StateSet::serialize() const
700{
701 /* TODO(@fclem): Better serialization... */
702 return std::string(".state_set(") + std::to_string(new_state) + ")";
703}
704
705std::string StencilSet::serialize() const
706{
707 std::stringstream ss;
708 ss << ".stencil_set(write_mask=0b" << std::bitset<8>(write_mask) << ", reference=0b"
709 << std::bitset<8>(reference) << ", compare_mask=0b" << std::bitset<8>(compare_mask) << ")";
710 return ss.str();
711}
712
714
715/* -------------------------------------------------------------------- */
718
719void DrawCommandBuf::finalize_commands(Vector<Header, 0> &headers,
720 Vector<Undetermined, 0> &commands,
721 SubPassVector &sub_passes,
722 uint &resource_id_count,
723 ResourceIdBuf &resource_id_buf)
724{
725 for (const Header &header : headers) {
726 if (header.type == Type::SubPass) {
728 auto &sub = sub_passes[int64_t(header.index)];
729 finalize_commands(
730 sub.headers_, sub.commands_, sub_passes, resource_id_count, resource_id_buf);
731 }
732
733 if (header.type != Type::Draw) {
734 continue;
735 }
736
737 Draw &cmd = commands[header.index].draw;
738
739 int batch_vert_len, batch_vert_first, batch_base_index, batch_inst_len;
740 /* Now that GPUBatches are guaranteed to be finished, extract their parameters. */
742 cmd.batch, &batch_vert_len, &batch_vert_first, &batch_base_index, &batch_inst_len);
743 /* Instancing attributes are not supported using the new pipeline since we use the base
744 * instance to set the correct resource_id. Workaround is a storage_buf + gl_InstanceID. */
745 BLI_assert(batch_inst_len == 1);
746
747 if (cmd.vertex_len == uint(-1)) {
748 cmd.vertex_len = batch_vert_len;
749 }
750
751 /* NOTE: Only do this if a handle is present. If a draw-call is using instancing with null
752 * handle, the shader should not rely on `resource_id` at ***all***. This allows procedural
753 * instanced draw-calls with lots of instances with no overhead. */
754 /* TODO(fclem): Think about either fixing this feature or removing support for instancing all
755 * together. */
756 if (cmd.res_index.raw > 0) {
757 /* Save correct offset to start of resource_id buffer region for this draw. */
758 uint instance_first = resource_id_count;
759 resource_id_count += cmd.instance_len;
760 /* Ensure the buffer is big enough. */
761 resource_id_buf.get_or_resize(resource_id_count - 1);
762
763 /* Copy the resource id for all instances. */
764 uint index = cmd.res_index.resource_index();
765 for (int i = instance_first; i < (instance_first + cmd.instance_len); i++) {
766 resource_id_buf[i] = index;
767 }
768 }
769 }
770}
771
773 Vector<Undetermined, 0> &commands,
774 SubPassVector &sub_passes)
775{
776 /* First instance ID contains the null handle with identity transform.
777 * This is referenced for draw-calls with no handle. */
778 resource_id_buf_.get_or_resize(0) = 0;
779 resource_id_count_ = 1;
780 finalize_commands(headers, commands, sub_passes, resource_id_count_, resource_id_buf_);
781 resource_id_buf_.push_update();
782}
783
785{
786 GPU_storagebuf_bind(resource_id_buf_, DRW_RESOURCE_ID_SLOT);
787}
788
790 Vector<Undetermined, 0> & /*commands*/,
791 VisibilityBuf &visibility_buf,
792 int visibility_word_per_draw,
793 int view_len,
794 bool use_custom_ids)
795{
796 GPU_debug_group_begin("DrawMultiBuf.bind");
797
798 resource_id_count_ = 0u;
799 for (DrawGroup &group : MutableSpan<DrawGroup>(group_buf_.data(), group_count_)) {
800 /* Compute prefix sum of all instance of previous group. */
801 group.start = resource_id_count_;
802 resource_id_count_ += group.len;
803
804 int batch_vert_len, batch_vert_first, batch_base_index, batch_inst_len;
805 /* Now that GPUBatches are guaranteed to be finished, extract their parameters. */
806 GPU_batch_draw_parameter_get(group.desc.gpu_batch,
807 &batch_vert_len,
808 &batch_vert_first,
809 &batch_base_index,
810 &batch_inst_len);
811
812 group.vertex_len = group.desc.vertex_len == 0 ? batch_vert_len : group.desc.vertex_len;
813 group.vertex_first = group.desc.vertex_first == -1 ? batch_vert_first :
814 group.desc.vertex_first;
815 group.base_index = batch_base_index;
816 /* Instancing attributes are not supported using the new pipeline since we use the base
817 * instance to set the correct resource_id. Workaround is a storage_buf + gl_InstanceID. */
818 BLI_assert(batch_inst_len == 1);
819 UNUSED_VARS_NDEBUG(batch_inst_len);
820
821 if (group.desc.expand_prim_type != GPU_PRIM_NONE) {
822 /* Expanded draw-call. */
824 group.desc.gpu_batch->prim_type,
825 GPUPrimType(group.desc.expand_prim_type),
826 group.vertex_len,
827 group.vertex_first,
828 group.desc.expand_prim_len);
829
830 group.vertex_first = vert_range.start();
831 group.vertex_len = vert_range.size();
832 /* Override base index to -1 as the generated draw-call will not use an index buffer and do
833 * the indirection manually inside the shader. */
834 group.base_index = -1;
835 }
836
837 /* Reset counters to 0 for the GPU. */
838 group.total_counter = group.front_facing_counter = group.back_facing_counter = 0;
839 }
840
841 group_buf_.push_update();
842 prototype_buf_.push_update();
843 /* Allocate enough for the expansion pass. */
844 resource_id_buf_.get_or_resize(resource_id_count_ * view_len * (use_custom_ids ? 2 : 1));
845 /* Two commands per group (inverted and non-inverted scale). */
846 command_buf_.get_or_resize(group_count_ * 2);
847
848 if (prototype_count_ > 0) {
850 GPU_shader_bind(shader);
851 GPU_shader_uniform_1i(shader, "prototype_len", prototype_count_);
852 GPU_shader_uniform_1i(shader, "visibility_word_per_draw", visibility_word_per_draw);
853 GPU_shader_uniform_1i(shader, "view_len", view_len);
854 GPU_shader_uniform_1i(shader, "view_shift", log2_ceil_u(view_len));
855 GPU_shader_uniform_1b(shader, "use_custom_ids", use_custom_ids);
856 GPU_storagebuf_bind(group_buf_, GPU_shader_get_ssbo_binding(shader, "group_buf"));
857 GPU_storagebuf_bind(visibility_buf, GPU_shader_get_ssbo_binding(shader, "visibility_buf"));
858 GPU_storagebuf_bind(prototype_buf_, GPU_shader_get_ssbo_binding(shader, "prototype_buf"));
859 GPU_storagebuf_bind(command_buf_, GPU_shader_get_ssbo_binding(shader, "command_buf"));
860 GPU_storagebuf_bind(resource_id_buf_, DRW_RESOURCE_ID_SLOT);
861 GPU_compute_dispatch(shader, divide_ceil_u(prototype_count_, DRW_COMMAND_GROUP_SIZE), 1, 1);
862 /* TODO(@fclem): Investigate moving the barrier in the bind function. */
865 }
866
868}
869
871{
872 GPU_storagebuf_bind(resource_id_buf_, DRW_RESOURCE_ID_SLOT);
873}
874
876
877}; // namespace blender::draw::command
#define BLI_assert_unreachable()
Definition BLI_assert.h:93
#define BLI_assert(a)
Definition BLI_assert.h:46
MINLINE unsigned int log2_ceil_u(unsigned int x)
MINLINE uint divide_ceil_u(uint a, uint b)
unsigned int uint
#define ARRAY_SIZE(arr)
#define UNUSED_VARS_NDEBUG(...)
blender::gpu::Batch * GPU_batch_procedural_triangle_strips_get()
Definition gpu_batch.cc:525
blender::gpu::Batch * GPU_batch_procedural_lines_get()
Definition gpu_batch.cc:515
void GPU_batch_draw_advanced(blender::gpu::Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
blender::IndexRange GPU_batch_draw_expanded_parameter_get(GPUPrimType input_prim_type, GPUPrimType output_prim_type, int vertex_count, int vertex_first, int output_primitive_cout)
Definition gpu_batch.cc:323
blender::gpu::Batch * GPU_batch_procedural_points_get()
Definition gpu_batch.cc:510
blender::gpu::Batch * GPU_batch_procedural_triangles_get()
Definition gpu_batch.cc:520
void GPU_batch_draw_indirect(blender::gpu::Batch *batch, blender::gpu::StorageBuf *indirect_buf, intptr_t offset)
void GPU_batch_bind_as_resources(blender::gpu::Batch *batch, blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants=nullptr)
void GPU_batch_draw_parameter_get(blender::gpu::Batch *batch, int *r_vertex_count, int *r_vertex_first, int *r_base_index, int *r_instance_count)
void GPU_batch_set_shader(blender::gpu::Batch *batch, blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
GPUAttachmentState
@ GPU_ATTACHMENT_WRITE
@ GPU_ATTACHMENT_IGNORE
void GPU_compute_dispatch(blender::gpu::Shader *shader, uint groups_x_len, uint groups_y_len, uint groups_z_len, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_debug_group_end()
Definition gpu_debug.cc:33
void GPU_debug_group_begin(const char *name)
Definition gpu_debug.cc:22
void GPU_framebuffer_subpass_transition_array(blender::gpu::FrameBuffer *fb, const GPUAttachmentState *attachment_states, uint attachment_len)
GPUFrameBufferBits
@ GPU_DEPTH_BIT
@ GPU_STENCIL_BIT
@ GPU_COLOR_BIT
void GPU_framebuffer_multi_clear(blender::gpu::FrameBuffer *fb, const float(*clear_colors)[4])
const char * GPU_framebuffer_get_name(blender::gpu::FrameBuffer *fb)
void GPU_framebuffer_clear(blender::gpu::FrameBuffer *fb, GPUFrameBufferBits buffers, const float clear_col[4], float clear_depth, unsigned int clear_stencil)
void GPU_framebuffer_bind(blender::gpu::FrameBuffer *fb)
blender::gpu::FrameBuffer * GPU_framebuffer_active_get()
void GPU_indexbuf_bind_as_ssbo(blender::gpu::IndexBuf *elem, int binding)
GPUPrimType
@ GPU_PRIM_NONE
@ GPU_PRIM_LINES
@ GPU_PRIM_POINTS
@ GPU_PRIM_TRI_STRIP
@ GPU_PRIM_TRIS
void GPU_shader_uniform_1b(blender::gpu::Shader *sh, const char *name, bool value)
const blender::gpu::shader::SpecializationConstants & GPU_shader_get_default_constant_state(blender::gpu::Shader *sh)
void GPU_shader_bind(blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
int GPU_shader_get_ssbo_binding(blender::gpu::Shader *shader, const char *name)
void GPU_shader_uniform_int_ex(blender::gpu::Shader *shader, int location, int length, int array_size, const int *value)
void GPU_shader_uniform_1i(blender::gpu::Shader *sh, const char *name, int value)
const char * GPU_shader_get_name(blender::gpu::Shader *shader)
void GPU_shader_uniform_float_ex(blender::gpu::Shader *shader, int location, int length, int array_size, const float *value)
void GPU_program_point_size(bool enable)
Definition gpu_state.cc:180
@ GPU_BARRIER_SHADER_STORAGE
Definition GPU_state.hh:48
void GPU_line_width(float width)
Definition gpu_state.cc:166
void GPU_line_smooth(bool enable)
Definition gpu_state.cc:78
void GPU_stencil_write_mask_set(uint write_mask)
Definition gpu_state.cc:210
void GPU_depth_range(float near, float far)
Definition gpu_state.cc:159
void GPU_state_set(GPUWriteMask write_mask, GPUBlend blend, GPUFaceCullTest culling_test, GPUDepthTest depth_test, GPUStencilTest stencil_test, GPUStencilOp stencil_op, GPUProvokingVertex provoking_vert)
Definition gpu_state.cc:129
void GPU_stencil_reference_set(uint reference)
Definition gpu_state.cc:205
void GPU_stencil_compare_mask_set(uint compare_mask)
Definition gpu_state.cc:215
void GPU_memory_barrier(GPUBarrier barrier)
Definition gpu_state.cc:326
void GPU_point_size(float size)
Definition gpu_state.cc:172
void GPU_clip_control_unit_range(bool enable)
Definition gpu_state.cc:148
void GPU_clip_distances(int distances_enabled)
Definition gpu_state.cc:124
void GPU_shadow_offset(bool enable)
Definition gpu_state.cc:119
void GPU_storagebuf_bind(blender::gpu::StorageBuf *ssbo, int slot)
void GPU_storagebuf_debug_unbind_all()
void GPU_storagebuf_sync_as_indirect_buffer(blender::gpu::StorageBuf *ssbo)
void GPU_texture_image_unbind_all()
void GPU_texture_bind_ex(blender::gpu::Texture *texture, GPUSamplerState state, int unit)
void GPU_texture_image_bind(blender::gpu::Texture *texture, int unit)
void GPU_texture_unbind_all()
void GPU_uniformbuf_bind(blender::gpu::UniformBuf *ubo, int slot)
void GPU_uniformbuf_bind_as_ssbo(blender::gpu::UniformBuf *ubo, int slot)
void GPU_uniformbuf_debug_unbind_all()
void GPU_vertbuf_bind_as_ssbo(blender::gpu::VertBuf *verts, int binding)
void GPU_vertbuf_bind_as_texture(blender::gpu::VertBuf *verts, int binding)
long long int int64_t
constexpr int64_t size() const
constexpr bool is_empty() const
constexpr int64_t start() const
constexpr MutableSpan slice_safe(const int64_t start, const int64_t size) const
Definition BLI_span.hh:590
constexpr T * end() const
Definition BLI_span.hh:548
constexpr T * begin() const
Definition BLI_span.hh:544
void generate_commands(Vector< Header, 0 > &headers, Vector< Undetermined, 0 > &commands, SubPassVector &sub_passes)
void bind(RecordingState &state)
void generate_commands(Vector< Header, 0 > &headers, Vector< Undetermined, 0 > &commands, VisibilityBuf &visibility_buf, int visibility_word_per_draw, int view_len, bool use_custom_ids)
void bind(RecordingState &state)
#define DRW_RESOURCE_ID_SLOT
#define DRW_COMMAND_GROUP_SIZE
blender::gpu::Shader * DRW_shader_draw_command_generate_get()
DRWState
Definition draw_state.hh:25
@ DRW_STATE_IN_FRONT_SELECT
Definition draw_state.hh:69
@ DRW_STATE_PROGRAM_POINT_SIZE
Definition draw_state.hh:74
@ DRW_STATE_CLIP_CONTROL_UNIT_RANGE
Definition draw_state.hh:68
@ DRW_STATE_SHADOW_OFFSET
Definition draw_state.hh:70
void GPU_compute_dispatch_indirect(blender::gpu::Shader *shader, blender::gpu::StorageBuf *indirect_buf_, const blender::gpu::shader::SpecializationConstants *constants_state)
BLI_INLINE float fb(float length, float L)
static ulong state[N]
static gpu::Batch * procedural_batch_get(GPUPrimType primitive)
static GPUFaceCullTest to_face_cull_test(DRWState state)
static GPUWriteMask to_write_mask(DRWState state)
static GPUDepthTest to_depth_test(DRWState state)
static GPUStencilOp to_stencil_op(DRWState state)
static GPUBlend to_blend(DRWState state)
static GPUProvokingVertex to_provoking_vertex(DRWState state)
static GPUStencilTest to_stencil_test(DRWState state)
StorageArrayBuffer< uint, 4, true > VisibilityBuf
Definition draw_view.hh:35
bool assign_if_different(T &old_value, T new_value)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 3 > int3
bool has_inverted_handedness() const
std::string serialize() const
void execute(RecordingState &state) const
void execute(RecordingState &state) const
struct blender::draw::command::DrawGroup::@065172161005140006364026044166345126204356255202 desc
void execute(RecordingState &state) const
std::string serialize(const std::string &line_prefix) const
void execute(RecordingState &state) const
void execute(RecordingState &state) const
std::string serialize() const
void execute(RecordingState &state) const
enum blender::draw::command::PushConstant::Type type
enum blender::draw::command::ResourceBind::Type type
void execute(RecordingState &state) const
void execute(RecordingState &state) const
enum blender::draw::command::SpecializeConstant::Type type
void execute(RecordingState &state) const
static void set(DRWState state=DRW_STATE_DEFAULT)
i
Definition text_draw.cc:230