65using namespace blender::draw;
66using namespace blender::draw::command;
99 if (blocks_.is_empty() || blocks_.last()->size() == block_size) {
102 return blocks_.last()->append_and_get_index(std::move(elem)) +
103 (blocks_.size() - 1) * block_size;
108 return (*blocks_[index / block_size])[index % block_size];
113 return (*blocks_[index / block_size])[index % block_size];
122 typename DrawCommandBufType>
125 friend DrawCommandBuf;
148 DrawCommandBufType &draw_command_buf,
242 uint instance_len = -1,
243 uint vertex_len = -1,
244 uint vertex_first = -1,
261 uint vertex_first = -1,
282 uint vertex_len = -1,
283 uint vertex_first = -1,
306 StorageBuffer<DrawCommand, true> &indirect_buffer,
307 ResourceHandle handle = {0});
316 void dispatch(StorageBuffer<DispatchCommand> &indirect_buffer);
341 void bind_texture(
const char *name, gpu::VertBuf *buffer);
342 void bind_texture(
const char *name, 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);
428 resources.bind_resources(*
this);
434 std::string
serialize(std::string line_prefix =
"")
const;
468 DrawCommandBufType draw_commands_buf_main_;
472 :
detail::
PassBase<DrawCommandBufType>(name, draw_commands_buf_main_, sub_passes_main_){};
476 this->headers_.
clear();
477 this->commands_.
clear();
478 this->sub_passes_.
clear();
479 this->draw_commands_buf_.clear();
516 bool sorted_ =
false;
523 sorting_values_.clear();
540 sorting_index = sorting_values_.append_and_get_index(sorting_value);
541 }
while (sorting_index != index);
545 std::string
serialize(std::string line_prefix =
"")
const
547 if (sorted_ ==
false) {
556 if (sorted_ ==
false) {
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);
595 static_cast<int>(colors.
size())};
629 switch (header.type) {
637 commands_[header.index].framebuffer_bind.execute();
640 commands_[header.index].subpass_transition.execute();
646 commands_[header.index].resource_bind.execute();
652 commands_[header.index].specialize_constant.execute();
670 commands_[header.index].barrier.execute();
676 commands_[header.index].clear_multi.execute();
682 commands_[header.index].stencil_set.execute();
692 std::stringstream ss;
693 ss << line_prefix <<
"." <<
debug_name << std::endl;
696 switch (header.type) {
701 ss <<
sub_passes_[header.index].serialize(line_prefix);
704 ss << line_prefix <<
commands_[header.index].framebuffer_bind.serialize() << std::endl;
707 ss << line_prefix <<
commands_[header.index].subpass_transition.serialize() << std::endl;
710 ss << line_prefix <<
commands_[header.index].shader_bind.serialize() << std::endl;
713 ss << line_prefix <<
commands_[header.index].resource_bind.serialize() << std::endl;
716 ss << line_prefix <<
commands_[header.index].push_constant.serialize() << std::endl;
719 ss << line_prefix <<
commands_[header.index].draw.serialize() << std::endl;
722 ss <<
commands_[header.index].draw_multi.serialize(line_prefix);
725 ss << line_prefix <<
commands_[header.index].draw_indirect.serialize() << std::endl;
728 ss << line_prefix <<
commands_[header.index].dispatch.serialize() << std::endl;
731 ss << line_prefix <<
commands_[header.index].dispatch_indirect.serialize() << std::endl;
734 ss << line_prefix <<
commands_[header.index].barrier.serialize() << std::endl;
737 ss << line_prefix <<
commands_[header.index].clear.serialize() << std::endl;
740 ss << line_prefix <<
commands_[header.index].clear_multi.serialize() << std::endl;
743 ss << line_prefix <<
commands_[header.index].state_set.serialize() << std::endl;
746 ss << line_prefix <<
commands_[header.index].stencil_set.serialize() << std::endl;
767 if (instance_len == 0 || vertex_len == 0) {
779#ifdef WITH_METAL_BACKEND
789 this->
draw(
batch, -1, -1, -1, handle, custom_id);
802 if (instance_len == 0 || vertex_len == 0 || primitive_len == 0) {
814#ifdef WITH_METAL_BACKEND
829 this->
draw_expand(
batch, primitive_type, primitive_len, instance_len, -1, -1, handle, custom_id);
957 if (clip_plane_count > 0) {
988 color_states[i] =
uint8_t(color_attachments[i]);
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);
1024 else if (tex->colorband) {
1028 else if (tex->sky) {
1030 bind_texture(tex->sampler_name, *tex->sky, tex->sampler_state);
1035 if (ubo !=
nullptr) {
1387 const char *constant_name,
1388 const int &constant_value)
1396 const char *constant_name,
1397 const uint &constant_value)
1405 const char *constant_name,
1406 const float &constant_value)
1414 const char *constant_name,
1415 const bool &constant_value)
1423 const char *constant_name,
1424 const int *constant_value)
1432 const char *constant_name,
1433 const uint *constant_value)
1441 const char *constant_name,
1442 const float *constant_value)
1450 const char *constant_name,
1451 const bool *constant_value)
ImageGPUTextures BKE_image_get_gpu_material_texture(Image *image, ImageUser *iuser, const bool use_tile_mapping)
#define BLI_assert_unreachable()
void GPU_debug_group_end()
void GPU_debug_group_begin(const char *name)
GPUPass * GPU_material_get_pass(GPUMaterial *material)
ListBase GPU_material_textures(GPUMaterial *material)
GPUUniformBuf * GPU_material_uniform_buffer_get(GPUMaterial *material)
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)
struct GPUShader GPUShader
constexpr const T * data() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
void acquire_texture(GPUTexture *texture)
std::string serialize(std::string line_prefix="") const
PassSortable(const char *name_)
PassMain::Sub & sub(const char *name, float sorting_value)
void clear_multi(Span< float4 > colors)
void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state=sampler_auto)
void bind_resources(U &resources)
void draw_procedural_indirect(GPUPrimType primitive, StorageBuffer< DrawCommand, true > &indirect_buffer, ResourceHandle handle={0})
void bind_image(const char *name, GPUTexture *image)
friend std::ostream & operator<<(std::ostream &stream, const PassBase &pass)
void clear_depth(float depth)
Vector< command::Header, 0 > headers_
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)
void clear_stencil(uint8_t stencil)
void clear_color(float4 color)
void subpass_transition(GPUAttachmentState depth_attachment, Span< GPUAttachmentState > color_attachments)
void clear_depth_stencil(float depth, uint8_t stencil)
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
SubPassVector< PassBase< DrawCommandBufType > > & sub_passes_
PassBase(const char *name, DrawCommandBufType &draw_command_buf, SubPassVector< PassBase< DrawCommandBufType > > &sub_passes, GPUShader *shader=nullptr)
command::Undetermined & create_command(command::Type type)
PassBase< DrawCommandBufType > & sub(const char *name)
void dispatch(int group_len)
int push_constant_offset(const char *name)
void submit(command::RecordingState &state) const
void barrier(eGPUBarrier type)
void state_set(DRWState state, int clip_plane_count=0)
void draw_indirect(gpu::Batch *batch, StorageBuffer< DrawCommand, true > &indirect_buffer, ResourceHandle handle={0})
void bind_ubo(const char *name, GPUUniformBuf *buffer)
void clear(eGPUFrameBufferBits planes, float4 color, float depth, uint8_t stencil)
void framebuffer_set(GPUFrameBuffer **framebuffer)
Vector< command::Undetermined, 0 > commands_
void state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask)
void clear_color_depth_stencil(float4 color, float depth, uint8_t stencil)
std::string serialize(std::string line_prefix="") const
void push_constant(const char *name, const float &data)
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)
void material_set(Manager &manager, GPUMaterial *material)
gpu::Batch * procedural_batch_get(GPUPrimType primitive)
DrawCommandBufType & draw_commands_buf_
void bind_ssbo(const char *name, GPUStorageBuf *buffer)
void shader_set(GPUShader *shader)
detail::PassBase< command::DrawCommandBuf > Sub
T & operator[](int64_t index)
const T & operator[](int64_t index) const
int64_t append_and_get_index(T &&elem)
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
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()
@ DRW_STATE_PROGRAM_POINT_SIZE
struct @157336070235062372277311340362362342103123126032::@262166344314164341202215145112231240022370055142 batch
GPUShader * GPU_pass_shader_get(GPUPass *pass)
static void clear(Message &msg)
static Image * as_image(GPUTexture *tex)
detail::Pass< command::DrawMultiBuf > PassMain
VecBase< int32_t, 4 > int4
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
ListBaseWrapperTemplate< ListBase, T > ListBaseWrapper
VecBase< float, 3 > float3
static constexpr GPUSamplerState internal_sampler()
GPUTexture * tile_mapping
enum blender::draw::command::PushConstant::Type type
PushConstant push_constant