Disallow pipeline statistics query as UnsafeAPIs

- Pipeline statistics query is not fully implemented, disallow its
  creation as unsafe
- Add pipeline statistics creation in UnsafeAPIsTest, because it needs
  enable extension, add a separate test class for it.

BUG: chromium:1177506
Change-Id: Ic77e04c9c854b396e7240674bd9deb0caf97a513
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/53889
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Hao Li 2021-06-09 08:47:37 +00:00 committed by Dawn LUCI CQ
parent 11379a3b59
commit 7cbcacc712
3 changed files with 45 additions and 2 deletions

View File

@ -58,6 +58,14 @@ namespace dawn_native {
break; break;
case wgpu::QueryType::PipelineStatistics: { case wgpu::QueryType::PipelineStatistics: {
// TODO(crbug.com/1177506): Pipeline statistics query is not fully implemented.
// Disallow it as unsafe until the implementaion is completed.
if (device->IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
return DAWN_VALIDATION_ERROR(
"Pipeline statistics query is disallowed because it's not fully "
"implemented");
}
if (!device->IsExtensionEnabled(Extension::PipelineStatisticsQuery)) { if (!device->IsExtensionEnabled(Extension::PipelineStatisticsQuery)) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"The pipeline statistics query feature is not supported"); "The pipeline statistics query feature is not supported");

View File

@ -226,7 +226,7 @@ class TimestampQueryValidationTest : public QuerySetValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = {"timestamp_query"}; descriptor.requiredExtensions.push_back("timestamp_query");
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };
@ -429,7 +429,10 @@ class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
protected: protected:
WGPUDevice CreateTestDevice() override { WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor; dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = {"pipeline_statistics_query"}; descriptor.requiredExtensions.push_back("pipeline_statistics_query");
// TODO(crbug.com/1177506): Pipeline statistic query is an unsafe API, disable disallowing
// unsafe APIs to test it.
descriptor.forceDisabledToggles.push_back("disallow_unsafe_apis");
return adapter.CreateDevice(&descriptor); return adapter.CreateDevice(&descriptor);
} }
}; };

View File

@ -201,3 +201,35 @@ TEST_F(UnsafeAPIValidationTest, DynamicStorageBuffer) {
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc)); ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc));
} }
} }
class UnsafeQueryAPIValidationTest : public ValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions.push_back("pipeline_statistics_query");
descriptor.forceEnabledToggles.push_back("disallow_unsafe_apis");
return adapter.CreateDevice(&descriptor);
}
};
// Check that pipeline statistics query are disallowed.
TEST_F(UnsafeQueryAPIValidationTest, PipelineStatisticsDisallowed) {
wgpu::QuerySetDescriptor descriptor;
descriptor.count = 1;
// Control case: occlusion query creation is allowed.
{
descriptor.type = wgpu::QueryType::Occlusion;
device.CreateQuerySet(&descriptor);
}
// Error case: pipeline statistics query creation is disallowed.
{
descriptor.type = wgpu::QueryType::PipelineStatistics;
std::vector<wgpu::PipelineStatisticName> pipelineStatistics = {
wgpu::PipelineStatisticName::VertexShaderInvocations};
descriptor.pipelineStatistics = pipelineStatistics.data();
descriptor.pipelineStatisticsCount = pipelineStatistics.size();
ASSERT_DEVICE_ERROR(device.CreateQuerySet(&descriptor));
}
}