37 # define USE_TRANSFORM_FEEDBACK
38 # define USE_COMPUTE_SHADERS
43 #ifdef USE_COMPUTE_SHADERS
48 #ifdef USE_TRANSFORM_FEEDBACK
54 #ifndef USE_TRANSFORM_FEEDBACK
55 struct ParticleRefineCall {
56 struct ParticleRefineCall *
next;
62 static ParticleRefineCall *g_tf_calls =
nullptr;
63 static int g_tf_id_offset;
64 static int g_tf_target_width;
65 static int g_tf_target_height;
80 #if defined(USE_TRANSFORM_FEEDBACK) || defined(USE_COMPUTE_SHADERS)
93 const float vert[4] = {0.0f, 0.0f, 0.0f, 0.0f};
102 "g_dummy_curves_info");
123 const int final_points_len = cache->
final[subdiv].
strands_res * strands_len;
124 if (final_points_len > 0) {
131 int strands_start = 0;
132 while (strands_start < strands_len) {
133 int batch_strands_len =
MIN2(strands_len - strands_start, max_strands_per_call);
137 strands_start += batch_strands_len;
146 if (final_points_len > 0) {
149 #ifdef USE_TRANSFORM_FEEDBACK
155 ParticleRefineCall *pr_call = (ParticleRefineCall *)
MEM_mallocN(
sizeof(*pr_call), __func__);
156 pr_call->next = g_tf_calls;
158 pr_call->shgrp = tf_shgrp;
159 pr_call->vert_len = final_points_len;
160 g_tf_calls = pr_call;
180 object, psys, md, &cache, gpu_material, subdiv, thickness_res);
202 object, psys, md,
nullptr, subdiv, thickness_res);
210 float (*dupli_mat)[4])
215 if ((dupli_parent !=
nullptr) && (dupli_object !=
nullptr)) {
219 if (collection !=
nullptr) {
243 float dupli_mat[4][4];
249 object, psys, md, gpu_material, subdiv, thickness_res);
281 float hair_rad_shape = part->
shape;
314 #ifndef USE_TRANSFORM_FEEDBACK
325 if (g_tf_calls ==
nullptr) {
331 for (ParticleRefineCall *pr_call = g_tf_calls; pr_call; pr_call = pr_call->next) {
332 max_size =
max_ii(max_size, pr_call->vert_len);
342 g_tf_target_height =
height;
343 g_tf_target_width =
width;
346 GPU_framebuffer_ensure_config(&
fb,
349 GPU_ATTACHMENT_TEXTURE(
tex),
355 while (g_tf_calls !=
nullptr) {
356 ParticleRefineCall *pr_call = g_tf_calls;
357 g_tf_calls = g_tf_calls->next;
360 while (pr_call->vert_len > 0) {
369 sizeof(
float[4]) * g_tf_id_offset,
370 sizeof(
float[4]) * max_read_px_len,
373 g_tf_id_offset += max_read_px_len;
374 pr_call->vert_len -= max_read_px_len;
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
bool invert_m4(float R[4][4])
void unit_m4(float m[4][4])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
MINLINE void sub_v3_v3(float r[3], const float a[3])
Object groups, one object can be in many groups at once.
#define DRW_shgroup_vertex_buffer(shgroup, name, vert)
#define DRW_shgroup_call_no_cull(shgroup, geom, ob)
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
#define DRW_TEXTURE_FREE_SAFE(tex)
bool GPU_compute_shader_support(void)
int GPU_max_work_group_count(int index)
bool GPU_shader_storage_buffer_objects_support(void)
struct GPUFrameBuffer GPUFrameBuffer
void GPU_framebuffer_free(GPUFrameBuffer *fb)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
struct GPUShader GPUShader
void GPU_memory_barrier(eGPUBarrier barrier)
@ GPU_BARRIER_SHADER_STORAGE
struct GPUTexture GPUTexture
GPUTexture * GPU_texture_create_from_vertbuf(const char *name, struct GPUVertBuf *vert)
#define GPU_vertbuf_create_with_format(format)
struct GPUVertBuf GPUVertBuf
void GPU_vertbuf_update_sub(GPUVertBuf *verts, uint start, uint len, const void *data)
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
void GPU_vertbuf_use(GPUVertBuf *)
void GPU_vertbuf_attr_fill(GPUVertBuf *, uint a_idx, const void *data)
bool particles_ensure_procedural_data(Object *object, ParticleSystem *psys, ModifierData *md, ParticleHairCache **r_hair_cache, GPUMaterial *gpu_material, int subdiv, int thickness_res)
DRWShadingGroup * DRW_shgroup_hair_create_sub(Object *object, ParticleSystem *psys, ModifierData *md, DRWShadingGroup *shgrp_parent, GPUMaterial *gpu_material)
BLI_INLINE eParticleRefineShaderType drw_hair_shader_type_get()
static blender::draw::UniformBuffer< CurvesInfos > * g_dummy_curves_info
static GPUTexture * g_dummy_texture
static GPUVertBuf * g_dummy_vbo
static void drw_hair_particle_cache_update_compute(ParticleHairCache *cache, const int subdiv)
void DRW_hair_duplimat_get(Object *object, ParticleSystem *UNUSED(psys), ModifierData *UNUSED(md), float(*dupli_mat)[4])
static GPUShader * hair_refine_shader_get(ParticleRefineShader refinement)
static void drw_hair_particle_cache_shgrp_attach_resources(DRWShadingGroup *shgrp, ParticleHairCache *cache, const int subdiv)
GPUVertBuf * DRW_hair_pos_buffer_get(Object *object, ParticleSystem *psys, ModifierData *md)
static void drw_hair_particle_cache_update_transform_feedback(ParticleHairCache *cache, const int subdiv)
static DRWPass * g_tf_pass
static ParticleHairCache * drw_hair_particle_cache_get(Object *object, ParticleSystem *psys, ModifierData *md, GPUMaterial *gpu_material, int subdiv, int thickness_res)
@ PART_REFINE_CATMULL_ROM
#define MAX_LAYER_NAME_CT
struct Object * DRW_object_get_dupli_parent(const Object *UNUSED(ob))
struct DupliObject * DRW_object_get_dupli(const Object *UNUSED(ob))
const DRWContextState * DRW_context_state_get(void)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_shgroup_call_compute(DRWShadingGroup *shgroup, int groups_x_len, int groups_y_len, int groups_z_len)
void DRW_shgroup_call_procedural_points(DRWShadingGroup *shgroup, Object *ob, uint point_count)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
DRWShadingGroup * DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, GPUVertBuf *tf_target)
void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial *material)
DRWShadingGroup * DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
DRWPass * DRW_pass_create(const char *name, DRWState state)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_shgroup_uniform_mat4_copy(DRWShadingGroup *shgroup, const char *name, const float(*value)[4])
void DRW_draw_pass(DRWPass *pass)
void DRW_draw_pass_subset(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group)
GPUTexture * DRW_texture_pool_query_2d(int w, int h, eGPUTextureFormat format, DrawEngineType *engine_type)
GPUShader * DRW_shader_hair_refine_get(ParticleRefineShader refinement, eParticleRefineShaderType sh_type)
eParticleRefineShaderType
@ PART_REFINE_SHADER_TRANSFORM_FEEDBACK_WORKAROUND
@ PART_REFINE_SHADER_COMPUTE
@ PART_REFINE_SHADER_TRANSFORM_FEEDBACK
void GPU_framebuffer_read_color(GPUFrameBuffer *gpu_fb, int x, int y, int w, int h, int channels, int slot, eGPUDataFormat format, void *data)
BLI_INLINE float fb(float length, float L)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
static void update(bNodeTree *ntree)
struct Collection * instance_collection
GPUTexture * uv_tex[MAX_MTFACE]
char uv_layer_names[MAX_MTFACE][MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]
GPUTexture * strand_seg_tex
ParticleHairFinalCache final[MAX_HAIR_SUBDIV]
char(* col_layer_names)[MAX_LAYER_NAME_CT][MAX_LAYER_NAME_LEN]
GPUBatch * proc_hairs[MAX_THICKRES]