mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-16 00:49:14 +00:00
Disallow timestamp query creation if disallow_unsafe_apis
Bug: chromium:1226078 Change-Id: I567522c5562d8cba616ef4315c91a0420d5146d6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59044 Reviewed-by: Hao Li <hao.x.li@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
f844ff071c
commit
01ceccb1eb
@ -94,6 +94,12 @@ namespace dawn_native {
|
|||||||
return DAWN_VALIDATION_ERROR("The timestamp query feature is not supported");
|
return DAWN_VALIDATION_ERROR("The timestamp query feature is not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (device->IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"The timestamp query is disallowed because it may expose precise timing "
|
||||||
|
"information");
|
||||||
|
}
|
||||||
|
|
||||||
if (descriptor->pipelineStatisticsCount != 0) {
|
if (descriptor->pipelineStatisticsCount != 0) {
|
||||||
return DAWN_VALIDATION_ERROR(
|
return DAWN_VALIDATION_ERROR(
|
||||||
"The pipeline statistics should not be set if query type is Timestamp");
|
"The pipeline statistics should not be set if query type is Timestamp");
|
||||||
|
@ -227,6 +227,7 @@ class TimestampQueryValidationTest : public QuerySetValidationTest {
|
|||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice() override {
|
||||||
dawn_native::DeviceDescriptor descriptor;
|
dawn_native::DeviceDescriptor descriptor;
|
||||||
descriptor.requiredExtensions.push_back("timestamp_query");
|
descriptor.requiredExtensions.push_back("timestamp_query");
|
||||||
|
descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
|
||||||
return adapter.CreateDevice(&descriptor);
|
return adapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -191,6 +191,7 @@ class UnsafeQueryAPIValidationTest : public ValidationTest {
|
|||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice() override {
|
||||||
dawn_native::DeviceDescriptor descriptor;
|
dawn_native::DeviceDescriptor descriptor;
|
||||||
descriptor.requiredExtensions.push_back("pipeline_statistics_query");
|
descriptor.requiredExtensions.push_back("pipeline_statistics_query");
|
||||||
|
descriptor.requiredExtensions.push_back("timestamp_query");
|
||||||
descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis");
|
descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis");
|
||||||
return adapter.CreateDevice(&descriptor);
|
return adapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
@ -217,3 +218,21 @@ TEST_F(UnsafeQueryAPIValidationTest, PipelineStatisticsDisallowed) {
|
|||||||
ASSERT_DEVICE_ERROR(device.CreateQuerySet(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateQuerySet(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check timestamp queries are disallowed.
|
||||||
|
TEST_F(UnsafeQueryAPIValidationTest, TimestampQueryDisallowed) {
|
||||||
|
wgpu::QuerySetDescriptor descriptor;
|
||||||
|
descriptor.count = 1;
|
||||||
|
|
||||||
|
// Control case: occlusion query creation is allowed.
|
||||||
|
{
|
||||||
|
descriptor.type = wgpu::QueryType::Occlusion;
|
||||||
|
device.CreateQuerySet(&descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error case: timestamp query creation is disallowed.
|
||||||
|
{
|
||||||
|
descriptor.type = wgpu::QueryType::Timestamp;
|
||||||
|
ASSERT_DEVICE_ERROR(device.CreateQuerySet(&descriptor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user