Validate OpenGL command plan dependencies
This commit is contained in:
@@ -69,6 +69,14 @@ void record_render_pass_order_error(OpenGlCommandPlan& plan, std::size_t index)
|
||||
}
|
||||
}
|
||||
|
||||
void record_dependency_error(OpenGlCommandPlan& plan, std::size_t index) noexcept
|
||||
{
|
||||
++plan.dependency_error_count;
|
||||
if (plan.first_dependency_error == OpenGlCommandPlan::npos) {
|
||||
plan.first_dependency_error = index;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const char* planned_command_kind_name(OpenGlPlannedCommandKind kind) noexcept
|
||||
@@ -286,6 +294,8 @@ OpenGlCommandPlan plan_recorded_render_commands(
|
||||
plan.commands.reserve(commands.size());
|
||||
|
||||
bool in_render_pass = false;
|
||||
bool shader_bound_in_pass = false;
|
||||
bool mesh_bound_in_pass = false;
|
||||
for (std::size_t index = 0; index < commands.size(); ++index) {
|
||||
OpenGlPlannedCommand planned = plan_recorded_render_command(commands[index]);
|
||||
|
||||
@@ -300,30 +310,47 @@ OpenGlCommandPlan plan_recorded_render_commands(
|
||||
record_render_pass_order_error(plan, index);
|
||||
}
|
||||
in_render_pass = true;
|
||||
shader_bound_in_pass = false;
|
||||
mesh_bound_in_pass = false;
|
||||
break;
|
||||
case OpenGlPlannedCommandKind::end_render_pass:
|
||||
if (!in_render_pass) {
|
||||
record_render_pass_order_error(plan, index);
|
||||
}
|
||||
in_render_pass = false;
|
||||
shader_bound_in_pass = false;
|
||||
mesh_bound_in_pass = false;
|
||||
break;
|
||||
case OpenGlPlannedCommandKind::draw:
|
||||
++plan.draw_command_count;
|
||||
if (!in_render_pass) {
|
||||
record_render_pass_order_error(plan, index);
|
||||
}
|
||||
if (!shader_bound_in_pass || !mesh_bound_in_pass) {
|
||||
record_dependency_error(plan, index);
|
||||
}
|
||||
break;
|
||||
case OpenGlPlannedCommandKind::bind_shader:
|
||||
++plan.shader_bind_command_count;
|
||||
if (!in_render_pass) {
|
||||
record_render_pass_order_error(plan, index);
|
||||
}
|
||||
shader_bound_in_pass = true;
|
||||
break;
|
||||
case OpenGlPlannedCommandKind::set_shader_uniform:
|
||||
++plan.uniform_command_count;
|
||||
if (!in_render_pass) {
|
||||
record_render_pass_order_error(plan, index);
|
||||
}
|
||||
if (!shader_bound_in_pass) {
|
||||
record_dependency_error(plan, index);
|
||||
}
|
||||
break;
|
||||
case OpenGlPlannedCommandKind::bind_mesh:
|
||||
if (!in_render_pass) {
|
||||
record_render_pass_order_error(plan, index);
|
||||
}
|
||||
mesh_bound_in_pass = true;
|
||||
break;
|
||||
case OpenGlPlannedCommandKind::upload_texture:
|
||||
++plan.upload_command_count;
|
||||
@@ -368,7 +395,8 @@ OpenGlCommandPlan plan_recorded_render_commands(
|
||||
}
|
||||
|
||||
plan.supported = plan.unsupported_command_count == 0U
|
||||
&& plan.render_pass_order_error_count == 0U;
|
||||
&& plan.render_pass_order_error_count == 0U
|
||||
&& plan.dependency_error_count == 0U;
|
||||
return plan;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,10 @@ struct OpenGlCommandPlan {
|
||||
std::uint32_t trace_command_count = 0;
|
||||
std::uint32_t unsupported_command_count = 0;
|
||||
std::uint32_t render_pass_order_error_count = 0;
|
||||
std::uint32_t dependency_error_count = 0;
|
||||
std::size_t first_unsupported_command = npos;
|
||||
std::size_t first_render_pass_order_error = npos;
|
||||
std::size_t first_dependency_error = npos;
|
||||
bool ended_in_render_pass = false;
|
||||
bool supported = true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user