Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per object rid info for 3.2 #43830

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion drivers/dummy/rasterizer_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,25 @@ class RasterizerStorageDummy : public RasterizerStorage {

void render_info_begin_capture() {}
void render_info_end_capture() {}
int get_captured_render_info(VS::RenderInfo p_info) { return 0; }

int get_render_info(VS::RenderInfo p_info) { return 0; }
String get_video_adapter_name() const { return String(); }
String get_video_adapter_vendor() const { return String(); }

const Vector<int> get_captured_render_info() { return Vector<int>(); }
const Vector<int> get_captured_selected_render_info(const Vector<RID> &p_rids) {
Vector<int> new_info;
new_info.resize(VS::INFO_MAX);
return new_info;
}
const Vector<int> get_render_info() {
Vector<int> new_info;
new_info.resize(VS::INFO_MAX);
return new_info;
}

bool has_shadows() { return true; }
Copy link
Member Author

@fire fire Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete has shadows.


static RasterizerStorage *base_singleton;

RasterizerStorageDummy(){};
Expand Down
96 changes: 34 additions & 62 deletions drivers/gles2/rasterizer_storage_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5880,68 +5880,40 @@ void RasterizerStorageGLES2::render_info_end_capture() {
info.snap._2d_draw_call_count = info.render._2d_draw_call_count - info.snap._2d_draw_call_count;
}

int RasterizerStorageGLES2::get_captured_render_info(VS::RenderInfo p_info) {

switch (p_info) {
case VS::INFO_OBJECTS_IN_FRAME: {
return info.snap.object_count;
} break;
case VS::INFO_VERTICES_IN_FRAME: {
return info.snap.vertices_count;
} break;
case VS::INFO_MATERIAL_CHANGES_IN_FRAME: {
return info.snap.material_switch_count;
} break;
case VS::INFO_SHADER_CHANGES_IN_FRAME: {
return info.snap.shader_rebind_count;
} break;
case VS::INFO_SURFACE_CHANGES_IN_FRAME: {
return info.snap.surface_switch_count;
} break;
case VS::INFO_DRAW_CALLS_IN_FRAME: {
return info.snap.draw_call_count;
} break;
case VS::INFO_2D_ITEMS_IN_FRAME: {
return info.snap._2d_item_count;
} break;
case VS::INFO_2D_DRAW_CALLS_IN_FRAME: {
return info.snap._2d_draw_call_count;
} break;
default: {
return get_render_info(p_info);
}
}
}

int RasterizerStorageGLES2::get_render_info(VS::RenderInfo p_info) {
switch (p_info) {
case VS::INFO_OBJECTS_IN_FRAME:
return info.render_final.object_count;
case VS::INFO_VERTICES_IN_FRAME:
return info.render_final.vertices_count;
case VS::INFO_MATERIAL_CHANGES_IN_FRAME:
return info.render_final.material_switch_count;
case VS::INFO_SHADER_CHANGES_IN_FRAME:
return info.render_final.shader_rebind_count;
case VS::INFO_SURFACE_CHANGES_IN_FRAME:
return info.render_final.surface_switch_count;
case VS::INFO_DRAW_CALLS_IN_FRAME:
return info.render_final.draw_call_count;
case VS::INFO_2D_ITEMS_IN_FRAME:
return info.render_final._2d_item_count;
case VS::INFO_2D_DRAW_CALLS_IN_FRAME:
return info.render_final._2d_draw_call_count;
case VS::INFO_USAGE_VIDEO_MEM_TOTAL:
return 0; //no idea
case VS::INFO_VIDEO_MEM_USED:
return info.vertex_mem + info.texture_mem;
case VS::INFO_TEXTURE_MEM_USED:
return info.texture_mem;
case VS::INFO_VERTEX_MEM_USED:
return info.vertex_mem;
default:
return 0; //no idea either
}
const Vector<int> RasterizerStorageGLES2::get_captured_selected_render_info(const Vector<RID> &p_rids) {
Vector<int> new_info;
new_info.resize(VS::INFO_MAX);
return new_info;
}

const Vector<int> RasterizerStorageGLES2::get_captured_render_info() {
Vector<int> new_info;
new_info.resize(VS::INFO_MAX);
int *info_write = new_info.ptrw();
info_write[VS::INFO_OBJECTS_IN_FRAME] = info.snap.object_count;
info_write[VS::INFO_VERTICES_IN_FRAME] = info.snap.vertices_count;
info_write[VS::INFO_MATERIAL_CHANGES_IN_FRAME] = info.snap.material_switch_count;
info_write[VS::INFO_SHADER_CHANGES_IN_FRAME] = info.snap.shader_rebind_count;
info_write[VS::INFO_SURFACE_CHANGES_IN_FRAME] = info.snap.surface_switch_count;
info_write[VS::INFO_DRAW_CALLS_IN_FRAME] = info.snap.draw_call_count;
return new_info;
}
Copy link
Member

@lawnjelly lawnjelly Nov 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this simply be passed as a structure to fill in?
e.g.

get_captured_render_info(StatsRenderInfo &r_info)
{
r_info.objects_in_frame = BLAH;
...
}

or directly return the structure as a const ref?

Ah maybe this is for some thread protection or something. Still seems like redundant copying is going on.


const Vector<int> RasterizerStorageGLES2::get_render_info() {
Vector<int> new_info;
new_info.resize(VS::INFO_MAX);
int *info_write = new_info.ptrw();
info_write[VS::INFO_OBJECTS_IN_FRAME] = info.render_final.object_count;
info_write[VS::INFO_VERTICES_IN_FRAME] = info.render_final.vertices_count;
info_write[VS::INFO_MATERIAL_CHANGES_IN_FRAME] = info.render_final.material_switch_count;
info_write[VS::INFO_SHADER_CHANGES_IN_FRAME] = info.render_final.shader_rebind_count;
info_write[VS::INFO_SURFACE_CHANGES_IN_FRAME] = info.render_final.surface_switch_count;
info_write[VS::INFO_DRAW_CALLS_IN_FRAME] = info.render_final.draw_call_count;
info_write[VS::INFO_USAGE_VIDEO_MEM_TOTAL] = 0; //no idea
info_write[VS::INFO_VIDEO_MEM_USED] = info.vertex_mem + info.texture_mem;
info_write[VS::INFO_TEXTURE_MEM_USED] = info.texture_mem;
info_write[VS::INFO_VERTEX_MEM_USED] = info.vertex_mem;
return new_info;
}

String RasterizerStorageGLES2::get_video_adapter_name() const {
Expand Down
9 changes: 7 additions & 2 deletions drivers/gles2/rasterizer_storage_gles2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,8 @@ class RasterizerStorageGLES2 : public RasterizerStorage {

} frame;

Vector<RID> render_info_rids;

void initialize();
void finalize();

Expand All @@ -1336,13 +1338,16 @@ class RasterizerStorageGLES2 : public RasterizerStorage {

virtual void set_debug_generate_wireframes(bool p_generate);

virtual const Vector<int> get_captured_render_info();
virtual const Vector<int> get_captured_selected_render_info(const Vector<RID> &p_rids);
virtual void set_object_detail_list(Vector<RID> p_rids) { render_info_rids.append_array(p_rids); };
virtual void clear_object_detail_list() { render_info_rids.clear(); }
virtual void render_info_begin_capture();
virtual void render_info_end_capture();
virtual int get_captured_render_info(VS::RenderInfo p_info);

virtual int get_render_info(VS::RenderInfo p_info);
virtual String get_video_adapter_name() const;
virtual String get_video_adapter_vendor() const;
virtual const Vector<int> get_render_info();

void buffer_orphan_and_upload(unsigned int p_buffer_size, unsigned int p_offset, unsigned int p_data_size, const void *p_data, GLenum p_target = GL_ARRAY_BUFFER, GLenum p_usage = GL_DYNAMIC_DRAW, bool p_optional_orphan = false) const;
bool safe_buffer_sub_data(unsigned int p_total_buffer_size, GLenum p_target, unsigned int p_offset, unsigned int p_data_size, const void *p_data, unsigned int &r_offset_after) const;
Expand Down
5 changes: 5 additions & 0 deletions drivers/gles3/rasterizer_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ void RasterizerGLES3::begin_frame(double frame_step) {
storage->info.render_final = storage->info.render;
storage->info.render.reset();

for (Map<RID_Data *, RasterizerStorageGLES3::Info::Render>::Element *E = storage->info.rid_render_info_render.front(); E; E = E->next()) {
storage->info.rid_render_info_final[E->key()] = E->get();
}
storage->info.rid_render_info_render.clear();

scene->iteration();
}

Expand Down
Loading