mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-14 19:31:25 +00:00
Improve validation errors for CreateQuerySet
Bug: dawn:563 Change-Id: I7ed446f9fed3e8e9c2fdf367ea8cedcbbff334b9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65561 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
200ed613ba
commit
547c4ed0ca
@ -1297,7 +1297,8 @@ namespace dawn_native {
|
|||||||
const QuerySetDescriptor* descriptor) {
|
const QuerySetDescriptor* descriptor) {
|
||||||
DAWN_TRY(ValidateIsAlive());
|
DAWN_TRY(ValidateIsAlive());
|
||||||
if (IsValidationEnabled()) {
|
if (IsValidationEnabled()) {
|
||||||
DAWN_TRY(ValidateQuerySetDescriptor(this, descriptor));
|
DAWN_TRY_CONTEXT(ValidateQuerySetDescriptor(this, descriptor), "validating %s",
|
||||||
|
descriptor);
|
||||||
}
|
}
|
||||||
return CreateQuerySetImpl(descriptor);
|
return CreateQuerySetImpl(descriptor);
|
||||||
}
|
}
|
||||||
|
@ -40,43 +40,34 @@ namespace dawn_native {
|
|||||||
|
|
||||||
MaybeError ValidateQuerySetDescriptor(DeviceBase* device,
|
MaybeError ValidateQuerySetDescriptor(DeviceBase* device,
|
||||||
const QuerySetDescriptor* descriptor) {
|
const QuerySetDescriptor* descriptor) {
|
||||||
if (descriptor->nextInChain != nullptr) {
|
DAWN_INVALID_IF(descriptor->nextInChain != nullptr, "nextInChain must be nullptr");
|
||||||
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor->count > kMaxQueryCount) {
|
|
||||||
return DAWN_VALIDATION_ERROR("Max query count exceeded");
|
|
||||||
}
|
|
||||||
|
|
||||||
DAWN_TRY(ValidateQueryType(descriptor->type));
|
DAWN_TRY(ValidateQueryType(descriptor->type));
|
||||||
|
|
||||||
|
DAWN_INVALID_IF(descriptor->count > kMaxQueryCount,
|
||||||
|
"Query count (%u) exceeds the maximum query count (%u).", descriptor->count,
|
||||||
|
kMaxQueryCount);
|
||||||
|
|
||||||
switch (descriptor->type) {
|
switch (descriptor->type) {
|
||||||
case wgpu::QueryType::Occlusion:
|
case wgpu::QueryType::Occlusion:
|
||||||
if (descriptor->pipelineStatisticsCount != 0) {
|
DAWN_INVALID_IF(descriptor->pipelineStatisticsCount != 0,
|
||||||
return DAWN_VALIDATION_ERROR(
|
"Pipeline statistics specified for a query of type %s.",
|
||||||
"The pipeline statistics should not be set if query type is Occlusion");
|
descriptor->type);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wgpu::QueryType::PipelineStatistics: {
|
case wgpu::QueryType::PipelineStatistics: {
|
||||||
// TODO(crbug.com/1177506): Pipeline statistics query is not fully implemented.
|
// TODO(crbug.com/1177506): Pipeline statistics query is not fully implemented.
|
||||||
// Disallow it as unsafe until the implementaion is completed.
|
// Disallow it as unsafe until the implementaion is completed.
|
||||||
if (device->IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
DAWN_INVALID_IF(device->IsToggleEnabled(Toggle::DisallowUnsafeAPIs),
|
||||||
return DAWN_VALIDATION_ERROR(
|
"Pipeline statistics queries are disallowed because they are not "
|
||||||
"Pipeline statistics query is disallowed because it's not fully "
|
"fully implemented");
|
||||||
"implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!device->IsExtensionEnabled(Extension::PipelineStatisticsQuery)) {
|
DAWN_INVALID_IF(
|
||||||
return DAWN_VALIDATION_ERROR(
|
!device->IsExtensionEnabled(Extension::PipelineStatisticsQuery),
|
||||||
"The pipeline statistics query feature is not supported");
|
"Pipeline statistics query set created without the extension being enabled.");
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor->pipelineStatisticsCount == 0) {
|
DAWN_INVALID_IF(descriptor->pipelineStatisticsCount == 0,
|
||||||
return DAWN_VALIDATION_ERROR(
|
"Pipeline statistics query set created with 0 statistics.");
|
||||||
"At least one pipeline statistics is set if query type is "
|
|
||||||
"PipelineStatistics");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<wgpu::PipelineStatisticName> pipelineStatisticsSet;
|
std::set<wgpu::PipelineStatisticName> pipelineStatisticsSet;
|
||||||
for (uint32_t i = 0; i < descriptor->pipelineStatisticsCount; i++) {
|
for (uint32_t i = 0; i < descriptor->pipelineStatisticsCount; i++) {
|
||||||
@ -84,27 +75,22 @@ namespace dawn_native {
|
|||||||
|
|
||||||
std::pair<std::set<wgpu::PipelineStatisticName>::iterator, bool> res =
|
std::pair<std::set<wgpu::PipelineStatisticName>::iterator, bool> res =
|
||||||
pipelineStatisticsSet.insert((descriptor->pipelineStatistics[i]));
|
pipelineStatisticsSet.insert((descriptor->pipelineStatistics[i]));
|
||||||
if (!res.second) {
|
DAWN_INVALID_IF(!res.second, "Statistic %s is specified more than once.",
|
||||||
return DAWN_VALIDATION_ERROR("Duplicate pipeline statistics found");
|
descriptor->pipelineStatistics[i]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case wgpu::QueryType::Timestamp:
|
case wgpu::QueryType::Timestamp:
|
||||||
if (!device->IsExtensionEnabled(Extension::TimestampQuery)) {
|
DAWN_INVALID_IF(device->IsToggleEnabled(Toggle::DisallowUnsafeAPIs),
|
||||||
return DAWN_VALIDATION_ERROR("The timestamp query feature is not supported");
|
"Timestamp queries are disallowed because they may expose precise "
|
||||||
}
|
"timing information.");
|
||||||
|
|
||||||
if (device->IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
DAWN_INVALID_IF(!device->IsExtensionEnabled(Extension::TimestampQuery),
|
||||||
return DAWN_VALIDATION_ERROR(
|
"Timestamp query set created without the extension being enabled.");
|
||||||
"The timestamp query is disallowed because it may expose precise timing "
|
|
||||||
"information");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor->pipelineStatisticsCount != 0) {
|
DAWN_INVALID_IF(descriptor->pipelineStatisticsCount != 0,
|
||||||
return DAWN_VALIDATION_ERROR(
|
"Pipeline statistics specified for a query of type %s.",
|
||||||
"The pipeline statistics should not be set if query type is Timestamp");
|
descriptor->type);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -166,9 +152,7 @@ namespace dawn_native {
|
|||||||
|
|
||||||
MaybeError QuerySetBase::ValidateCanUseInSubmitNow() const {
|
MaybeError QuerySetBase::ValidateCanUseInSubmitNow() const {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
if (mState == QuerySetState::Destroyed) {
|
DAWN_INVALID_IF(mState == QuerySetState::Destroyed, "%s used while destroyed.", this);
|
||||||
return DAWN_VALIDATION_ERROR("Destroyed query set used in a submit");
|
|
||||||
}
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user