Skip to content

Commit f236b9b

Browse files
committed
Merge pull request #91530 from DarioSamo/timestamp_validation
Add draw and dispatch count to timestamp validation.
2 parents 4313524 + c41e407 commit f236b9b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

servers/rendering/rendering_device.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3858,6 +3858,8 @@ void RenderingDevice::draw_list_draw(DrawListID p_list, bool p_use_indices, uint
38583858

38593859
draw_graph.add_draw_list_draw(to_draw, p_instances);
38603860
}
3861+
3862+
dl->state.draw_count++;
38613863
}
38623864

38633865
void RenderingDevice::draw_list_enable_scissor(DrawListID p_list, const Rect2 &p_rect) {
@@ -4201,6 +4203,7 @@ void RenderingDevice::compute_list_dispatch(ComputeListID p_list, uint32_t p_x_g
42014203
}
42024204

42034205
draw_graph.add_compute_list_dispatch(p_x_groups, p_y_groups, p_z_groups);
4206+
cl->state.dispatch_count++;
42044207
}
42054208

42064209
void RenderingDevice::compute_list_dispatch_threads(ComputeListID p_list, uint32_t p_x_threads, uint32_t p_y_threads, uint32_t p_z_threads) {
@@ -4294,6 +4297,7 @@ void RenderingDevice::compute_list_dispatch_indirect(ComputeListID p_list, RID p
42944297
}
42954298

42964299
draw_graph.add_compute_list_dispatch_indirect(buffer->driver_id, p_offset);
4300+
cl->state.dispatch_count++;
42974301

42984302
if (buffer->draw_tracker != nullptr) {
42994303
draw_graph.add_compute_list_usage(buffer->draw_tracker, RDG::RESOURCE_USAGE_INDIRECT_BUFFER_READ);
@@ -5206,8 +5210,8 @@ void RenderingDevice::_free_rids(T &p_owner, const char *p_type) {
52065210
}
52075211

52085212
void RenderingDevice::capture_timestamp(const String &p_name) {
5209-
ERR_FAIL_COND_MSG(draw_list != nullptr, "Capturing timestamps during draw list creation is not allowed. Offending timestamp was: " + p_name);
5210-
ERR_FAIL_COND_MSG(compute_list != nullptr, "Capturing timestamps during compute list creation is not allowed. Offending timestamp was: " + p_name);
5213+
ERR_FAIL_COND_MSG(draw_list != nullptr && draw_list->state.draw_count > 0, "Capturing timestamps during draw list creation is not allowed. Offending timestamp was: " + p_name);
5214+
ERR_FAIL_COND_MSG(compute_list != nullptr && compute_list->state.dispatch_count > 0, "Capturing timestamps during compute list creation is not allowed. Offending timestamp was: " + p_name);
52115215
ERR_FAIL_COND(frames[frame].timestamp_count >= max_timestamp_query_elements);
52125216

52135217
draw_graph.add_capture_timestamp(frames[frame].timestamp_pool, frames[frame].timestamp_count);

servers/rendering/rendering_device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,7 @@ class RenderingDevice : public RenderingDeviceCommons {
10461046
uint32_t pipeline_shader_layout_hash = 0;
10471047
RID vertex_array;
10481048
RID index_array;
1049+
uint32_t draw_count = 0;
10491050
} state;
10501051

10511052
#ifdef DEBUG_ENABLED
@@ -1147,6 +1148,7 @@ class RenderingDevice : public RenderingDeviceCommons {
11471148
uint32_t local_group_size[3] = { 0, 0, 0 };
11481149
uint8_t push_constant_data[MAX_PUSH_CONSTANT_SIZE] = {};
11491150
uint32_t push_constant_size = 0;
1151+
uint32_t dispatch_count = 0;
11501152
} state;
11511153

11521154
#ifdef DEBUG_ENABLED

0 commit comments

Comments
 (0)