67using namespace blender::draw;
68using namespace blender::draw::command;
104 if (blocks_.is_empty() || blocks_.last()->size() == block_size) {
107 return blocks_.last()->append_and_get_index(std::move(elem)) +
108 (blocks_.size() - 1) * block_size;
113 return (*blocks_[index / block_size])[index % block_size];
118 return (*blocks_[index / block_size])[index % block_size];
127 typename DrawCommandBufType>
130 friend DrawCommandBuf;
158 DrawCommandBufType &draw_command_buf,
222 void state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask);
251 bool deferred_texture_loading =
false);
259 uint instance_len = -1,
260 uint vertex_len = -1,
261 uint vertex_first = -1,
278 uint vertex_first = -1,
323 StorageBuffer<DrawCommand, true> &indirect_buffer,
324 ResourceIndex res_index = {0});
333 void dispatch(StorageBuffer<DispatchCommand> &indirect_buffer);
354 void bind_image(
int slot, gpu::Texture *image);
355 void bind_image(
int slot, gpu::Texture **image);
359 GPUSamplerState
state = sampler_auto);
370 void bind_ssbo(
int slot, gpu::StorageBuf *buffer);
371 void bind_ssbo(
int slot, gpu::StorageBuf **buffer);
374 void bind_ssbo(
int slot, gpu::UniformBuf *buffer);
375 void bind_ssbo(
int slot, gpu::UniformBuf **buffer);
379 void bind_ssbo(
int slot, gpu::VertBuf *buffer);
380 void bind_ssbo(
int slot, gpu::VertBuf **buffer);
384 void bind_ssbo(
int slot, gpu::IndexBuf *buffer);
385 void bind_ssbo(
int slot, gpu::IndexBuf **buffer);
386 void bind_ubo(
const char *
name, gpu::UniformBuf *buffer);
387 void bind_ubo(
const char *
name, gpu::UniformBuf **buffer);
388 void bind_ubo(
int slot, gpu::UniformBuf *buffer);
389 void bind_ubo(
int slot, gpu::UniformBuf **buffer);
451 resources.bind_resources(*
this);
457 std::string
serialize(std::string line_prefix =
"")
const;
505 DrawCommandBufType draw_commands_buf_main_;
509 :
detail::
PassBase<DrawCommandBufType>(
name, draw_commands_buf_main_, sub_passes_main_) {};
513 this->manager_fingerprint_ = 0;
514 this->view_fingerprint_ = 0;
515 this->headers_.
clear();
516 this->commands_.
clear();
517 this->sub_passes_.
clear();
518 this->draw_commands_buf_.clear();
519 this->is_empty_ =
true;
556 bool sorted_ =
false;
563 sorting_values_.clear();
580 sorting_index = sorting_values_.append_and_get_index(sorting_value);
581 }
while (sorting_index != index);
585 std::string
serialize(std::string line_prefix =
"")
const
587 if (sorted_ ==
false) {
596 if (sorted_ ==
false) {
598 BLI_assert(a.type == Type::SubPass && b.type == Type::SubPass);
599 float a_val = sorting_values_[a.index];
600 float b_val = sorting_values_[b.index];
601 return a_val < b_val || (a_val == b_val && a.index < b.index);
669 static_cast<int>(colors.
size())};
705 switch (header.type) {
762 switch (header.type) {
770 commands_[header.index].framebuffer_bind.execute();
773 commands_[header.index].subpass_transition.execute();
779 commands_[header.index].resource_bind.execute();
803 commands_[header.index].barrier.execute();
809 commands_[header.index].clear_multi.execute();
815 commands_[header.index].stencil_set.execute();
825 std::stringstream ss;
826 ss << line_prefix <<
"." <<
debug_name << std::endl;
829 switch (header.type) {
834 ss <<
sub_passes_[header.index].serialize(line_prefix);
837 ss << line_prefix <<
commands_[header.index].framebuffer_bind.serialize() << std::endl;
840 ss << line_prefix <<
commands_[header.index].subpass_transition.serialize() << std::endl;
843 ss << line_prefix <<
commands_[header.index].shader_bind.serialize() << std::endl;
846 ss << line_prefix <<
commands_[header.index].resource_bind.serialize() << std::endl;
849 ss << line_prefix <<
commands_[header.index].push_constant.serialize() << std::endl;
852 ss << line_prefix <<
commands_[header.index].draw.serialize() << std::endl;
855 ss <<
commands_[header.index].draw_multi.serialize(line_prefix);
858 ss << line_prefix <<
commands_[header.index].draw_indirect.serialize() << std::endl;
861 ss << line_prefix <<
commands_[header.index].dispatch.serialize() << std::endl;
864 ss << line_prefix <<
commands_[header.index].dispatch_indirect.serialize() << std::endl;
867 ss << line_prefix <<
commands_[header.index].barrier.serialize() << std::endl;
870 ss << line_prefix <<
commands_[header.index].clear.serialize() << std::endl;
873 ss << line_prefix <<
commands_[header.index].clear_multi.serialize() << std::endl;
876 ss << line_prefix <<
commands_[header.index].state_set.serialize() << std::endl;
879 ss << line_prefix <<
commands_[header.index].stencil_set.serialize() << std::endl;
900 if (instance_len == 0 || vertex_len == 0) {
921 this->
draw(
batch, -1, -1, -1, res_index, custom_id);
934 if (instance_len == 0 || vertex_len == 0 || primitive_len == 0) {
960 batch, primitive_type, primitive_len, instance_len, -1, -1, res_index, custom_id);
1092 if (clip_plane_count > 0) {
1123 color_states[
i] = uint8_t(color_attachments[
i]);
1139 bool deferred_texture_loading)
1149 const bool use_tile_mapping = tex->tiled_mapping_name[0];
1150 ImageUser *iuser = tex->iuser_available ? &tex->iuser :
nullptr;
1153 if (deferred_texture_loading) {
1160 if (*gputex.
texture ==
nullptr) {
1178 else if (tex->colorband) {
1182 else if (tex->sky) {
1184 bind_texture(tex->sampler_name, *tex->sky, tex->sampler_state);
1189 if (ubo !=
nullptr) {
1568 const char *constant_name,
1569 const int &constant_value)
1577 const char *constant_name,
1578 const uint &constant_value)
1586 const char *constant_name,
1587 const float &constant_value)
1595 const char *constant_name,
1596 const bool &constant_value)
1604 const char *constant_name,
1605 const int *constant_value)
1613 const char *constant_name,
1614 const uint *constant_value)
1622 const char *constant_name,
1623 const float *constant_value)
1631 const char *constant_name,
1632 const bool *constant_value)
ImageGPUTextures BKE_image_get_gpu_material_texture_try(Image *image, ImageUser *iuser, const bool use_tile_mapping)
ImageGPUTextures BKE_image_get_gpu_material_texture(Image *image, ImageUser *iuser, const bool use_tile_mapping)
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
blender::gpu::Batch * GPU_batch_procedural_triangle_strips_get()
blender::gpu::Batch * GPU_batch_procedural_lines_get()
blender::gpu::Batch * GPU_batch_procedural_points_get()
blender::gpu::Batch * GPU_batch_procedural_triangles_get()
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)
blender::gpu::UniformBuf * GPU_material_uniform_buffer_get(GPUMaterial *material)
blender::gpu::Shader * GPU_pass_shader_get(GPUPass *pass)
int GPU_shader_get_ubo_binding(blender::gpu::Shader *shader, const char *name)
int GPU_shader_get_constant(blender::gpu::Shader *shader, const char *name)
int GPU_shader_get_sampler_binding(blender::gpu::Shader *shader, const char *name)
int GPU_shader_get_ssbo_binding(blender::gpu::Shader *shader, const char *name)
int GPU_shader_get_uniform(blender::gpu::Shader *shader, const char *name)
BMesh const char void * data
unsigned long long int uint64_t
constexpr const T * data() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
void acquire_texture(gpu::Texture *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_resources(U &resources)
void framebuffer_set(gpu::FrameBuffer **framebuffer)
friend std::ostream & operator<<(std::ostream &stream, const PassBase &pass)
void shader_set(gpu::Shader *shader)
void clear_depth(float depth)
void bind_texture(const char *name, gpu::Texture *texture, GPUSamplerState state=sampler_auto)
Vector< command::Header, 0 > headers_
uint64_t view_fingerprint_
uint64_t manager_fingerprint_
bool has_generated_commands() const
void clear_stencil(uint8_t stencil)
void clear(GPUFrameBufferBits planes, float4 color, float depth, uint8_t stencil)
void clear_color(float4 color)
void warm_shader_specialization(command::RecordingState &state) const
void specialize_constant(gpu::Shader *shader, const char *name, const float &data)
void subpass_transition(GPUAttachmentState depth_attachment, Span< GPUAttachmentState > color_attachments)
void bind_image(const char *name, gpu::Texture *image)
void clear_depth_stencil(float depth, uint8_t stencil)
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceIndexRange res_index={}, uint custom_id=0)
PassBase(const char *name, DrawCommandBufType &draw_command_buf, SubPassVector< PassBase< DrawCommandBufType > > &sub_passes, gpu::Shader *shader=nullptr)
SubPassVector< PassBase< DrawCommandBufType > > & sub_passes_
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 draw_procedural_indirect(GPUPrimType primitive, StorageBuffer< DrawCommand, true > &indirect_buffer, ResourceIndex res_index={0})
void draw_indirect(gpu::Batch *batch, StorageBuffer< DrawCommand, true > &indirect_buffer, ResourceIndex res_index={0})
void draw_expand(gpu::Batch *batch, GPUPrimType primitive_type, uint primitive_len, uint instance_len, uint vertex_len, uint vertex_first, ResourceIndexRange res_index={}, uint custom_id=0)
void state_set(DRWState state, int clip_plane_count=0)
void barrier(GPUBarrier type)
Vector< command::Undetermined, 0 > commands_
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceIndexRange res_index={}, uint custom_id=0)
void state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask)
void clear_color_depth_stencil(float4 color, float depth, uint8_t stencil)
void bind_ubo(const char *name, gpu::UniformBuf *buffer)
void material_set(Manager &manager, GPUMaterial *material, bool deferred_texture_loading=false)
std::string serialize(std::string line_prefix="") const
void push_constant(const char *name, const float &data)
void bind_ssbo(const char *name, gpu::StorageBuf *buffer)
gpu::Batch * procedural_batch_get(GPUPrimType primitive)
DrawCommandBufType & draw_commands_buf_
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)
GPUSamplerState sampler_state
@ DRW_STATE_PROGRAM_POINT_SIZE
struct @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 batch
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
static void clear(Message &msg)
draw::StorageBuffer< DrawCommand, true > DrawIndirectBuf
detail::Pass< command::DrawMultiBuf > PassMain
static Image * as_image(gpu::Texture *tex)
draw::StorageBuffer< DispatchCommand > DispatchIndirectBuf
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
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()
blender::gpu::Texture ** tile_mapping
blender::gpu::Texture ** texture
enum blender::draw::command::PushConstant::Type type
PushConstant push_constant