mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-17 09:21:45 +00:00
This CL add Instance and Adapter toggle stage, and promote DisallowUnsafeAPIs as an instance toggle, and can be required using DawnTogglesDescriptor chained in instance descriptor when creating instance. The instance's toggles state will get inherited to adapters and devices it create. Related tests are implemented and updated. Toggles inheritance can be overriden if not forced, so requiring DisallowUnsafeAPIs when creating device is still available and working like before. Note that currently we don't have toggle of adapter stage, and can not require toggles when creating adapter, until follow up CLs implement it. Currently the toggles state of a adapter is simply inherited from instance. Bug: dawn:1495 Change-Id: I6bf7aa0f950a99451afcc2cab5322c924b7d9520 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122021 Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
58 lines
2.2 KiB
C++
58 lines
2.2 KiB
C++
// Copyright 2020 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include <vector>
|
|
|
|
#include "dawn/tests/MockCallback.h"
|
|
#include "dawn/tests/unittests/validation/ValidationTest.h"
|
|
#include "dawn/utils/ComboRenderBundleEncoderDescriptor.h"
|
|
#include "dawn/utils/ComboRenderPipelineDescriptor.h"
|
|
#include "dawn/utils/WGPUHelpers.h"
|
|
|
|
namespace {
|
|
using testing::HasSubstr;
|
|
} // anonymous namespace
|
|
|
|
class UnsafeAPIValidationTest : public ValidationTest {
|
|
protected:
|
|
// UnsafeAPIValidationTest create the device with toggle DisallowUnsafeApis explicitly enabled,
|
|
// which overrides the inheritance.
|
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
|
// Enable the DisallowUnsafeAPIs toggles in device toggles descriptor to override the
|
|
// inheritance and create a device disallowing unsafe apis.
|
|
wgpu::DeviceDescriptor descriptor;
|
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
|
descriptor.nextInChain = &deviceTogglesDesc;
|
|
const char* toggle = "disallow_unsafe_apis";
|
|
deviceTogglesDesc.enabledToggles = &toggle;
|
|
deviceTogglesDesc.enabledTogglesCount = 1;
|
|
return dawnAdapter.CreateDevice(&descriptor);
|
|
}
|
|
};
|
|
|
|
// Check chromium_disable_uniformity_analysis is an unsafe API.
|
|
TEST_F(UnsafeAPIValidationTest, chromium_disable_uniformity_analysis) {
|
|
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
|
|
enable chromium_disable_uniformity_analysis;
|
|
|
|
@compute @workgroup_size(8) fn uniformity_error(
|
|
@builtin(local_invocation_id) local_invocation_id : vec3u
|
|
) {
|
|
if (local_invocation_id.x == 0u) {
|
|
workgroupBarrier();
|
|
}
|
|
}
|
|
)"));
|
|
}
|