Add renderer draw descriptor contract

This commit is contained in:
2026-06-02 16:27:28 +02:00
parent 58f163788b
commit 483bbb4a9c
8 changed files with 157 additions and 31 deletions

View File

@@ -337,6 +337,40 @@ pp::foundation::Status validate_mesh_desc(MeshDesc desc) noexcept
return pp::foundation::Status::invalid_argument("mesh topology is not supported");
}
pp::foundation::Status validate_draw_desc(MeshDesc mesh, DrawDesc draw) noexcept
{
const auto mesh_status = validate_mesh_desc(mesh);
if (!mesh_status.ok()) {
return mesh_status;
}
if (draw.instance_count == 0) {
return pp::foundation::Status::invalid_argument("draw instance count must be greater than zero");
}
if (draw.vertex_count == 0 && draw.index_count == 0) {
return pp::foundation::Status::invalid_argument("draw must include vertices or indices");
}
if (draw.index_count > 0) {
if (mesh.index_count == 0) {
return pp::foundation::Status::invalid_argument("indexed draw requires an indexed mesh");
}
if (draw.first_index > mesh.index_count || draw.index_count > mesh.index_count - draw.first_index) {
return pp::foundation::Status::out_of_range("draw index range exceeds the bound mesh");
}
return pp::foundation::Status::success();
}
if (draw.first_vertex > mesh.vertex_count || draw.vertex_count > mesh.vertex_count - draw.first_vertex) {
return pp::foundation::Status::out_of_range("draw vertex range exceeds the bound mesh");
}
return pp::foundation::Status::success();
}
pp::foundation::Status validate_texture_slot(std::uint32_t slot) noexcept
{
if (slot >= max_texture_slots) {