Merge branch 'blender-v4.3-release'
# Conflicts: # source/blender/draw/intern/shaders/draw_view_info.hh
This commit is contained in:
@@ -240,6 +240,9 @@ ShadowRayPunctual shadow_ray_generate_punctual(LightData light, vec2 random_2d,
|
||||
float clip_far = intBitsToFloat(light.clip_far);
|
||||
float clip_near = intBitsToFloat(light.clip_near);
|
||||
float shape_radius = light_spot_data_get(light).shadow_radius;
|
||||
/* Clamp to a minimum value to avoid `local_ray_up` being degenerate. Could be revisited as the
|
||||
* issue might reappear at different zoom level. */
|
||||
shape_radius = max(0.00002, shape_radius);
|
||||
|
||||
vec3 direction;
|
||||
if (is_area_light(light.type)) {
|
||||
|
||||
@@ -767,7 +767,7 @@ void DrawMultiBuf::bind(RecordingState &state,
|
||||
for (DrawGroup &group : MutableSpan<DrawGroup>(group_buf_.data(), group_count_)) {
|
||||
/* Compute prefix sum of all instance of previous group. */
|
||||
group.start = resource_id_count_;
|
||||
resource_id_count_ += group.len * view_len;
|
||||
resource_id_count_ += group.len;
|
||||
|
||||
int batch_vert_len, batch_vert_first, batch_base_index, batch_inst_len;
|
||||
/* Now that GPUBatches are guaranteed to be finished, extract their parameters. */
|
||||
@@ -808,7 +808,7 @@ void DrawMultiBuf::bind(RecordingState &state,
|
||||
group_buf_.push_update();
|
||||
prototype_buf_.push_update();
|
||||
/* Allocate enough for the expansion pass. */
|
||||
resource_id_buf_.get_or_resize(resource_id_count_ * (use_custom_ids ? 2 : 1));
|
||||
resource_id_buf_.get_or_resize(resource_id_count_ * view_len * (use_custom_ids ? 2 : 1));
|
||||
/* Two commands per group (inverted and non-inverted scale). */
|
||||
command_buf_.get_or_resize(group_count_ * 2);
|
||||
|
||||
@@ -817,6 +817,7 @@ void DrawMultiBuf::bind(RecordingState &state,
|
||||
GPU_shader_bind(shader);
|
||||
GPU_shader_uniform_1i(shader, "prototype_len", prototype_count_);
|
||||
GPU_shader_uniform_1i(shader, "visibility_word_per_draw", visibility_word_per_draw);
|
||||
GPU_shader_uniform_1i(shader, "view_len", view_len);
|
||||
GPU_shader_uniform_1i(shader, "view_shift", log2_ceil_u(view_len));
|
||||
GPU_shader_uniform_1b(shader, "use_custom_ids", use_custom_ids);
|
||||
GPU_storagebuf_bind(group_buf_, GPU_shader_get_ssbo_binding(shader, "group_buf"));
|
||||
|
||||
@@ -26,6 +26,12 @@ struct DrawGroup {
|
||||
/** Index of next #DrawGroup from the same header. */
|
||||
uint next;
|
||||
|
||||
/**
|
||||
* IMPORTANT: All the following 3 members do not take multi-view into account.
|
||||
* They only count the number of input instances. The command generation shader must multiply
|
||||
* them by view_len to get the correct indices for resource ids.
|
||||
*/
|
||||
|
||||
/** Index of the first instances after sorting. */
|
||||
uint start;
|
||||
/** Total number of instances (including inverted facing). Needed to issue the draw call. */
|
||||
@@ -39,9 +45,11 @@ struct DrawGroup {
|
||||
/* Set to -1 if not an indexed draw. */
|
||||
int base_index;
|
||||
|
||||
/** Atomic counters used during command sorting. */
|
||||
uint total_counter;
|
||||
/** Atomic counters used during command sorting. GPU only. Reset on CPU. */
|
||||
|
||||
/* Counts visible and invisble instances. Create drawcalls when it reaches `DrawGroup::len`. */
|
||||
uint total_counter;
|
||||
/* Counts only visible instance (counting multi-view). Used to issue the drawcalls. */
|
||||
uint front_facing_counter;
|
||||
uint back_facing_counter;
|
||||
|
||||
|
||||
@@ -17,19 +17,21 @@ void write_draw_call(DrawGroup group, uint group_id)
|
||||
cmd.vertex_len = group.vertex_len;
|
||||
cmd.vertex_first = group.vertex_first;
|
||||
bool indexed_draw = group.base_index != -1;
|
||||
|
||||
/* Back-facing command. */
|
||||
uint back_facing_start = group.start * view_len;
|
||||
if (indexed_draw) {
|
||||
cmd.base_index = group.base_index;
|
||||
cmd.instance_first_indexed = group.start;
|
||||
cmd.instance_first_indexed = back_facing_start;
|
||||
}
|
||||
else {
|
||||
cmd._instance_first_array = group.start;
|
||||
cmd._instance_first_array = back_facing_start;
|
||||
}
|
||||
/* Back-facing command. */
|
||||
cmd.instance_len = group_buf[group_id].back_facing_counter;
|
||||
command_buf[group_id * 2 + 0] = cmd;
|
||||
|
||||
/* Front-facing command. */
|
||||
uint front_facing_start = group.start + (group.len - group.front_facing_len);
|
||||
uint front_facing_start = (group.start + (group.len - group.front_facing_len)) * view_len;
|
||||
if (indexed_draw) {
|
||||
cmd.instance_first_indexed = front_facing_start;
|
||||
}
|
||||
@@ -85,9 +87,8 @@ void main()
|
||||
return;
|
||||
}
|
||||
|
||||
uint back_facing_len = group.len - group.front_facing_len;
|
||||
uint front_facing_len = group.front_facing_len;
|
||||
uint dst_index = group.start;
|
||||
uint back_facing_len = (group.len - group.front_facing_len) * view_len;
|
||||
uint dst_index = group.start * view_len;
|
||||
if (is_inverted) {
|
||||
uint offset = atomicAdd(group_buf[group_id].back_facing_counter, visible_instance_len);
|
||||
dst_index += offset;
|
||||
|
||||
@@ -266,6 +266,7 @@ STORAGE_BUF(DRW_RESOURCE_ID_SLOT, WRITE, uint, resource_id_buf[])
|
||||
PUSH_CONSTANT(INT, prototype_len)
|
||||
PUSH_CONSTANT(INT, visibility_word_per_draw)
|
||||
PUSH_CONSTANT(INT, view_shift)
|
||||
PUSH_CONSTANT(INT, view_len)
|
||||
PUSH_CONSTANT(BOOL, use_custom_ids)
|
||||
COMPUTE_SOURCE("draw_command_generate_comp.glsl")
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
Reference in New Issue
Block a user