54 state.specialization_constants_in_use =
false;
144 if (
state.specialization_constants_in_use ==
false) {
146 state.specialization_constants_in_use =
true;
151 state.specialization_constants.set_value(
location, int_value);
154 state.specialization_constants.set_value(
location, *int_ref);
157 state.specialization_constants.set_value(
location, uint_value);
160 state.specialization_constants.set_value(
location, *uint_ref);
163 state.specialization_constants.set_value(
location, float_value);
166 state.specialization_constants.set_value(
location, *float_ref);
169 state.specialization_constants.set_value(
location, bool_value);
172 state.specialization_constants.set_value(
location, *bool_ref);
182 uint instance_first = 0;
184 instance_first =
state.instance_offset;
220 DrawMultiBuf::DrawCommandBuf &indirect_buf =
multi_draw_buf->command_buf_;
224 while (group_index !=
uint(-1)) {
225 const DrawGroup &group = groups[group_index];
228 gpu::Batch *
batch = group.
desc.gpu_batch;
233 group.
desc.gpu_batch,
state.shader,
state.specialization_constants_get());
241 intptr_t offset = stride * group_index * 2;
245 state.front_facing_set(
true);
250 state.front_facing_set(
false);
255 group_index = group.
next;
270 state.shader, size_ref->x, size_ref->y, size_ref->z,
state.specialization_constants_get());
274 state.shader, size.x, size.y, size.z,
state.specialization_constants_get());
305 if (!state_changed && !clip_changed) {
396 return std::string(
".framebuffer_bind(") +
408 return std::string(
".subpass_transition(\n") +
424 return std::string(
".bind_texture") + (
is_reference ?
"_ref" :
"") +
"(" +
427 return std::string(
".bind_vertbuf_as_texture") + (
is_reference ?
"_ref" :
"") +
"(" +
428 std::to_string(
slot) +
")";
430 return std::string(
".bind_image") + (
is_reference ?
"_ref" :
"") +
"(" +
431 std::to_string(
slot) +
")";
433 return std::string(
".bind_uniform_buf") + (
is_reference ?
"_ref" :
"") +
"(" +
434 std::to_string(
slot) +
")";
436 return std::string(
".bind_storage_buf") + (
is_reference ?
"_ref" :
"") +
"(" +
437 std::to_string(
slot) +
")";
439 return std::string(
".bind_uniform_as_ssbo") + (
is_reference ?
"_ref" :
"") +
"(" +
440 std::to_string(
slot) +
")";
442 return std::string(
".bind_vertbuf_as_ssbo") + (
is_reference ?
"_ref" :
"") +
"(" +
443 std::to_string(
slot) +
")";
445 return std::string(
".bind_indexbuf_as_ssbo") + (
is_reference ?
"_ref" :
"") +
"(" +
446 std::to_string(
slot) +
")";
455 std::stringstream ss;
530 (&float4_value)[0], (&float4_value)[1], (&float4_value)[2], (&float4_value)[3]);
543 return std::string(
".push_constant(") + std::to_string(
location) +
", data=" + ss.str() +
")";
548 std::stringstream ss;
575 return std::string(
".specialize_constant(") + std::to_string(
location) +
", data=" + ss.str() +
585 return std::string(
".draw(inst_len=") + inst_len +
", vert_len=" + vert_len +
586 ", vert_first=" + vert_first +
", res_id=" + std::to_string(
res_id.
index()) +
")";
602 uint prefix_sum = 0u;
604 group.start = prefix_sum;
605 prefix_sum += group.front_facing_counter + group.back_facing_counter;
608 std::stringstream ss;
612 while (group_index !=
uint(-1)) {
613 const DrawGroup &grp = groups[group_index];
615 ss << std::endl << line_prefix <<
" .group(id=" << group_index <<
", len=" << grp.
len <<
")";
625 << line_prefix <<
" .proto(instance_len=" << std::to_string(proto.instance_len)
626 <<
", resource_id=" << std::to_string(res_id.
index()) <<
", back_face)";
637 << line_prefix <<
" .proto(instance_len=" << std::to_string(proto.instance_len)
638 <<
", resource_id=" << std::to_string(res_id.
index()) <<
", front_face)";
642 group_index = grp.
next;
648 return line_prefix +
".draw_multi(" + std::to_string(group_len) +
")" + ss.str();
653 return std::string(
".draw_indirect()");
659 return std::string(
".dispatch") + (
is_reference ?
"_ref" :
"") +
"(" + std::to_string(sz.x) +
660 ", " + std::to_string(sz.y) +
", " + std::to_string(sz.z) +
")";
665 return std::string(
".dispatch_indirect()");
671 return std::string(
".barrier(") + std::to_string(
type) +
")";
676 std::stringstream ss;
678 ss <<
"color=" <<
color;
684 ss <<
"depth=" <<
depth;
690 ss <<
"stencil=0b" << std::bitset<8>(
stencil) <<
")";
692 return std::string(
".clear(") + ss.str() +
")";
697 std::stringstream ss;
701 return std::string(
".clear_multi(colors={") + ss.str() +
"})";
707 return std::string(
".state_set(") + std::to_string(
new_state) +
")";
712 std::stringstream ss;
713 ss <<
".stencil_set(write_mask=0b" << std::bitset<8>(
write_mask) <<
", reference=0b"
720 return ".texture_copy()";
731 SubPassVector &sub_passes,
732 uint &resource_id_count,
733 ResourceIdBuf &resource_id_buf)
735 for (
const Header &header : headers) {
738 auto &sub = sub_passes[
int64_t(header.index)];
740 sub.headers_, sub.commands_, sub_passes, resource_id_count, resource_id_buf);
747 Draw &cmd = commands[header.index].draw;
749 int batch_vert_len, batch_vert_first, batch_base_index, batch_inst_len;
752 cmd.
batch, &batch_vert_len, &batch_vert_first, &batch_base_index, &batch_inst_len);
768 uint instance_first = resource_id_count;
771 resource_id_buf.get_or_resize(resource_id_count - 1);
775 for (
int i = instance_first; i < (instance_first + cmd.
instance_len); i++) {
776 resource_id_buf[i] =
index;
784 SubPassVector &sub_passes)
788 resource_id_buf_.get_or_resize(0) = 0;
789 resource_id_count_ = 1;
790 finalize_commands(headers, commands, sub_passes, resource_id_count_, resource_id_buf_);
791 resource_id_buf_.push_update();
802 int visibility_word_per_draw,
808 resource_id_count_ = 0u;
811 group.start = resource_id_count_;
812 resource_id_count_ += group.len;
814 int batch_vert_len, batch_vert_first, batch_base_index, batch_inst_len;
822 group.vertex_len = group.desc.vertex_len == 0 ? batch_vert_len : group.desc.vertex_len;
823 group.vertex_first = group.desc.vertex_first == -1 ? batch_vert_first :
824 group.desc.vertex_first;
825 group.base_index = batch_base_index;
834 group.desc.gpu_batch->prim_type,
838 group.desc.expand_prim_len);
840 group.vertex_first = vert_range.
start();
841 group.vertex_len = vert_range.
size();
844 group.base_index = -1;
848 group.total_counter = group.front_facing_counter = group.back_facing_counter = 0;
851 group_buf_.push_update();
852 prototype_buf_.push_update();
854 resource_id_buf_.get_or_resize(resource_id_count_ * view_len * (use_custom_ids ? 2 : 1));
856 command_buf_.get_or_resize(group_count_ * 2);
858 if (prototype_count_ > 0) {
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_framebuffer_ensure_config(_fb,...)
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
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
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
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
static gpu::Batch * procedural_batch_get(GPUPrimType primitive)
StorageArrayBuffer< uint, 4, true > VisibilityBuf
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void GPU_batch_draw_indirect(gpu::Batch *batch, gpu::StorageBuf *indirect_buf, intptr_t offset)
void GPU_storagebuf_debug_unbind_all()
bool GPU_texture_has_depth_format(const gpu::Texture *texture)
gpu::FrameBuffer * GPU_framebuffer_active_get()
void GPU_vertbuf_bind_as_texture(gpu::VertBuf *verts, int binding)
void GPU_framebuffer_clear(gpu::FrameBuffer *fb, GPUFrameBufferBits buffers, const double4 clear_col, float clear_depth, unsigned int clear_stencil)
void GPU_batch_bind_as_resources(gpu::Batch *batch, gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants=nullptr)
void GPU_state_set(GPUWriteMask write_mask, GPUBlend blend, GPUFaceCullTest culling_test, GPUDepthTest depth_test, GPUStencilTest stencil_test, GPUStencilOp stencil_op, GPUProvokingVertex provoking_vert)
bool GPU_texture_is_view(const gpu::Texture *texture)
const char * GPU_framebuffer_get_name(gpu::FrameBuffer *fb)
bool assign_if_different(T &old_value, T &&new_value)
void GPU_framebuffer_free(gpu::FrameBuffer *fb)
void GPU_clip_distances(int distances_enabled)
void GPU_storagebuf_sync_as_indirect_buffer(gpu::StorageBuf *ssbo)
BLI_INLINE float fb(float length, float L)
gpu::Batch * GPU_batch_procedural_points_get()
void GPU_point_size(float size)
void GPU_texture_copy(gpu::Texture *dst, gpu::Texture *src)
void GPU_line_smooth(bool enable)
gpu::Shader * DRW_shader_draw_command_generate_get()
void GPU_texture_unbind_all()
void GPU_batch_set_shader(gpu::Batch *batch, gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
MatBase< float, 4, 4 > float4x4
void GPU_compute_dispatch(gpu::Shader *shader, uint groups_x_len, uint groups_y_len, uint groups_z_len, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_compute_dispatch_indirect(gpu::Shader *shader, gpu::StorageBuf *indirect_buf_, const gpu::shader::SpecializationConstants *constants_state)
void GPU_shader_uniform_int_ex(gpu::Shader *shader, int location, int length, int array_size, const int *value)
void GPU_shader_uniform_1b(gpu::Shader *sh, const char *name, bool value)
void GPU_vertbuf_bind_as_ssbo(gpu::VertBuf *verts, int binding)
MINLINE unsigned int log2_ceil_u(unsigned int x)
int GPU_shader_get_ssbo_binding(gpu::Shader *shader, const char *name)
void GPU_line_width(float width)
void GPU_stencil_reference_set(uint reference)
void GPU_indexbuf_bind_as_ssbo(gpu::IndexBuf *elem, int binding)
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)
VecBase< int32_t, 3 > int3
void GPU_memory_barrier(GPUBarrier barrier)
void GPU_shader_uniform_float_ex(gpu::Shader *shader, int location, int length, int array_size, const float *value)
gpu::Batch * GPU_batch_procedural_triangle_strips_get()
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
void GPU_uniformbuf_bind_as_ssbo(gpu::UniformBuf *ubo, int slot)
void GPU_program_point_size(bool enable)
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_1i(gpu::Shader *sh, const char *name, int value)
@ GPU_BARRIER_SHADER_STORAGE
@ DRW_STATE_CLIP_CONTROL_UNIT_RANGE
@ DRW_STATE_PROGRAM_POINT_SIZE
void GPU_storagebuf_bind(gpu::StorageBuf *ssbo, int slot)
void GPU_uniformbuf_bind(gpu::UniformBuf *ubo, int slot)
void GPU_texture_bind_ex(gpu::Texture *texture, GPUSamplerState state, int unit)
void GPU_framebuffer_blit(gpu::FrameBuffer *fb_read, int read_slot, gpu::FrameBuffer *fb_write, int write_slot, GPUFrameBufferBits blit_buffers)
gpu::FrameBuffer * GPU_framebuffer_create(const char *name)
void GPU_debug_group_end()
void GPU_framebuffer_multi_clear(gpu::FrameBuffer *fb, Span< double4 > clear_colors)
gpu::Batch * GPU_batch_procedural_triangles_get()
void GPU_clip_control_unit_range(bool enable)
MINLINE uint divide_ceil_u(uint a, uint b)
const char * GPU_shader_get_name(gpu::Shader *shader)
void GPU_texture_image_unbind_all()
void GPU_texture_image_bind(gpu::Texture *texture, int unit)
void GPU_batch_draw_advanced(gpu::Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
void GPU_stencil_write_mask_set(uint write_mask)
void GPU_uniformbuf_debug_unbind_all()
void GPU_framebuffer_subpass_transition_array(gpu::FrameBuffer *fb, const GPUAttachmentState *attachment_states, uint attachment_len)
void GPU_batch_draw_parameter_get(gpu::Batch *batch, int *r_vertex_count, int *r_vertex_first, int *r_base_index, int *r_instance_count)
void GPU_stencil_compare_mask_set(uint compare_mask)
VecBase< double, 4 > double4
gpu::Batch * GPU_batch_procedural_lines_get()
void GPU_debug_group_begin(const char *name)
const gpu::shader::SpecializationConstants & GPU_shader_get_default_constant_state(gpu::Shader *sh)
std::string to_string() const
bool has_inverted_handedness() const
std::string serialize() const
std::string serialize() const
std::string serialize() const
std::string serialize() const
void execute(RecordingState &state) const
gpu::StorageBuf ** indirect_buf
std::string serialize() const
void execute(RecordingState &state) const
struct blender::draw::command::DrawGroup::@260053362377366347260167202326266235125360167346 desc
uint front_facing_counter
void execute(RecordingState &state) const
std::string serialize() const
gpu::StorageBuf ** indirect_buf
std::string serialize(const std::string &line_prefix) const
DrawMultiBuf * multi_draw_buf
void execute(RecordingState &state) const
bool is_primitive_expansion() const
void execute(RecordingState &state) const
std::string serialize() const
uint32_t expand_prim_type
gpu::FrameBuffer ** framebuffer
std::string serialize() const
void execute(RecordingState &state) const
std::string serialize() const
enum blender::draw::command::PushConstant::Type type
enum blender::draw::command::ResourceBind::Type type
std::string serialize() const
void execute(RecordingState &state) const
std::string serialize() const
void execute(RecordingState &state) const
enum blender::draw::command::SpecializeConstant::Type type
std::string serialize() const
std::string serialize() const
void execute(RecordingState &state) const
static void set(DRWState state=DRW_STATE_DEFAULT)
std::string serialize() const
std::string serialize() const
std::string serialize() const