Add renderer trace scope contract
This commit is contained in:
@@ -12,6 +12,20 @@ namespace {
|
||||
return text == nullptr || text[0] == '\0';
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t bounded_c_string_length(const char* text, std::size_t limit) noexcept
|
||||
{
|
||||
if (text == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::size_t length = 0;
|
||||
while (length <= limit && text[length] != '\0') {
|
||||
++length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
[[nodiscard]] pp::foundation::Status validate_shader_stage_source(
|
||||
ShaderStageSource source,
|
||||
const char* stage_name) noexcept
|
||||
@@ -506,6 +520,27 @@ pp::foundation::Status validate_shader_uniform_write(
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_trace_label(const char* component, const char* name) noexcept
|
||||
{
|
||||
if (is_empty_c_string(component)) {
|
||||
return pp::foundation::Status::invalid_argument("trace component must not be empty");
|
||||
}
|
||||
|
||||
if (is_empty_c_string(name)) {
|
||||
return pp::foundation::Status::invalid_argument("trace name must not be empty");
|
||||
}
|
||||
|
||||
if (bounded_c_string_length(component, max_trace_label_bytes) > max_trace_label_bytes) {
|
||||
return pp::foundation::Status::out_of_range("trace component exceeds the configured limit");
|
||||
}
|
||||
|
||||
if (bounded_c_string_length(name, max_trace_label_bytes) > max_trace_label_bytes) {
|
||||
return pp::foundation::Status::out_of_range("trace name exceeds the configured limit");
|
||||
}
|
||||
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status validate_readback_region(TextureDesc desc, ReadbackRegion region) noexcept
|
||||
{
|
||||
const auto extent_status = validate_extent(desc.extent);
|
||||
|
||||
Reference in New Issue
Block a user