Dawn: Deprecate DawnTogglesDeviceDescriptor with DawnTogglesDescriptor
This CL deprecates DawnTogglesDeviceDescriptor and replace it with DawnTogglesDescriptor, which will be also used to provide instance and adapter toggles with future CLs. Bug: dawn:1495 Change-Id: I5f5cfdf38dcbcd237727a7f921462597b9301f1f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117174 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Kokoro: Zhaoming Jiang <zhaoming.jiang@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
64d8d18a93
commit
a12ff9abd1
19
dawn.json
19
dawn.json
|
@ -159,7 +159,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dawn toggles device descriptor": {
|
"dawn toggles device descriptor": {
|
||||||
"tags": ["dawn", "native"],
|
"tags": ["dawn", "native", "deprecated"],
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"chained": "in",
|
"chained": "in",
|
||||||
"chain roots": ["device descriptor"],
|
"chain roots": ["device descriptor"],
|
||||||
|
@ -170,6 +170,18 @@
|
||||||
{"name": "force disabled toggles", "type": "char", "annotation": "const*const*", "length": "force disabled toggles count"}
|
{"name": "force disabled toggles", "type": "char", "annotation": "const*const*", "length": "force disabled toggles count"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"dawn toggles descriptor": {
|
||||||
|
"tags": ["dawn", "native"],
|
||||||
|
"category": "structure",
|
||||||
|
"chained": "in",
|
||||||
|
"chain roots": ["device descriptor"],
|
||||||
|
"members": [
|
||||||
|
{"name": "enabled toggles count", "type": "uint32_t", "default": 0},
|
||||||
|
{"name": "enabled toggles", "type": "char", "annotation": "const*const*", "length": "enabled toggles count"},
|
||||||
|
{"name": "disabled toggles count", "type": "uint32_t", "default": 0},
|
||||||
|
{"name": "disabled toggles", "type": "char", "annotation": "const*const*", "length": "disabled toggles count"}
|
||||||
|
]
|
||||||
|
},
|
||||||
"dawn cache device descriptor" : {
|
"dawn cache device descriptor" : {
|
||||||
"tags": ["dawn", "native"],
|
"tags": ["dawn", "native"],
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
|
@ -2601,12 +2613,13 @@
|
||||||
{"value": 14, "name": "surface descriptor from windows swap chain panel", "tags": ["dawn"]},
|
{"value": 14, "name": "surface descriptor from windows swap chain panel", "tags": ["dawn"]},
|
||||||
{"value": 15, "name": "render pass descriptor max draw count"},
|
{"value": 15, "name": "render pass descriptor max draw count"},
|
||||||
{"value": 1000, "name": "dawn texture internal usage descriptor", "tags": ["dawn"]},
|
{"value": 1000, "name": "dawn texture internal usage descriptor", "tags": ["dawn"]},
|
||||||
{"value": 1002, "name": "dawn toggles device descriptor", "tags": ["dawn", "native"]},
|
{"value": 1002, "name": "dawn toggles device descriptor", "tags": ["dawn", "native", "deprecated"]},
|
||||||
{"value": 1003, "name": "dawn encoder internal usage descriptor", "tags": ["dawn"]},
|
{"value": 1003, "name": "dawn encoder internal usage descriptor", "tags": ["dawn"]},
|
||||||
{"value": 1004, "name": "dawn instance descriptor", "tags": ["dawn", "native"]},
|
{"value": 1004, "name": "dawn instance descriptor", "tags": ["dawn", "native"]},
|
||||||
{"value": 1005, "name": "dawn cache device descriptor", "tags": ["dawn", "native"]},
|
{"value": 1005, "name": "dawn cache device descriptor", "tags": ["dawn", "native"]},
|
||||||
{"value": 1006, "name": "dawn adapter properties power preference", "tags": ["dawn", "native"]},
|
{"value": 1006, "name": "dawn adapter properties power preference", "tags": ["dawn", "native"]},
|
||||||
{"value": 1007, "name": "dawn buffer descriptor error info from wire client", "tags": ["dawn"]}
|
{"value": 1007, "name": "dawn buffer descriptor error info from wire client", "tags": ["dawn"]},
|
||||||
|
{"value": 1008, "name": "dawn toggles descriptor", "tags": ["dawn", "native"]}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"texture": {
|
"texture": {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "dawn/common/Constants.h"
|
#include "dawn/common/Constants.h"
|
||||||
#include "dawn/common/GPUInfo.h"
|
#include "dawn/common/GPUInfo.h"
|
||||||
|
#include "dawn/common/Log.h"
|
||||||
#include "dawn/native/ChainUtils_autogen.h"
|
#include "dawn/native/ChainUtils_autogen.h"
|
||||||
#include "dawn/native/Device.h"
|
#include "dawn/native/Device.h"
|
||||||
#include "dawn/native/Instance.h"
|
#include "dawn/native/Instance.h"
|
||||||
|
@ -233,10 +234,38 @@ ResultOrError<Ref<DeviceBase>> AdapterBase::CreateDeviceInternal(
|
||||||
// Check overriden toggles before creating device, as some device features may be guarded by
|
// Check overriden toggles before creating device, as some device features may be guarded by
|
||||||
// toggles, and requiring such features without using corresponding toggles should fails the
|
// toggles, and requiring such features without using corresponding toggles should fails the
|
||||||
// device creating.
|
// device creating.
|
||||||
const DawnTogglesDeviceDescriptor* togglesDesc = nullptr;
|
const DawnTogglesDescriptor* deviceTogglesDesc = nullptr;
|
||||||
FindInChain(descriptor->nextInChain, &togglesDesc);
|
FindInChain(descriptor->nextInChain, &deviceTogglesDesc);
|
||||||
|
|
||||||
|
// Handle the deprecated DawnTogglesDeviceDescriptor
|
||||||
|
// TODO(dawn:1495): Remove this fallback once Chromium is changed to use DawnToggleDescriptor
|
||||||
|
// and DawnTogglesDeviceDescriptor is removed.
|
||||||
|
const DawnTogglesDeviceDescriptor* deprecatedTogglesDeviceDesc = nullptr;
|
||||||
|
DawnTogglesDescriptor convertedDeviceTogglesDesc = {};
|
||||||
|
FindInChain(descriptor->nextInChain, &deprecatedTogglesDeviceDesc);
|
||||||
|
|
||||||
|
if (deprecatedTogglesDeviceDesc) {
|
||||||
|
// Emit the deprecation warning.
|
||||||
|
dawn::WarningLog()
|
||||||
|
<< "DawnTogglesDeviceDescriptor is deprecated and replaced by DawnTogglesDescriptor.";
|
||||||
|
// Ensure that at most one toggles descriptor is used.
|
||||||
|
DAWN_INVALID_IF(
|
||||||
|
deviceTogglesDesc && deprecatedTogglesDeviceDesc,
|
||||||
|
"DawnTogglesDeviceDescriptor should not be used together with DawnTogglesDescriptor.");
|
||||||
|
|
||||||
|
convertedDeviceTogglesDesc.enabledToggles =
|
||||||
|
deprecatedTogglesDeviceDesc->forceEnabledToggles;
|
||||||
|
convertedDeviceTogglesDesc.enabledTogglesCount =
|
||||||
|
deprecatedTogglesDeviceDesc->forceEnabledTogglesCount;
|
||||||
|
convertedDeviceTogglesDesc.disabledToggles =
|
||||||
|
deprecatedTogglesDeviceDesc->forceDisabledToggles;
|
||||||
|
convertedDeviceTogglesDesc.disabledTogglesCount =
|
||||||
|
deprecatedTogglesDeviceDesc->forceDisabledTogglesCount;
|
||||||
|
deviceTogglesDesc = &convertedDeviceTogglesDesc;
|
||||||
|
}
|
||||||
|
|
||||||
TripleStateTogglesSet userProvidedToggles =
|
TripleStateTogglesSet userProvidedToggles =
|
||||||
TripleStateTogglesSet::CreateFromTogglesDeviceDescriptor(togglesDesc);
|
TripleStateTogglesSet::CreateFromTogglesDescriptor(deviceTogglesDesc);
|
||||||
|
|
||||||
// Validate all required features are supported by the adapter and suitable under given toggles.
|
// Validate all required features are supported by the adapter and suitable under given toggles.
|
||||||
for (uint32_t i = 0; i < descriptor->requiredFeaturesCount; ++i) {
|
for (uint32_t i = 0; i < descriptor->requiredFeaturesCount; ++i) {
|
||||||
|
|
|
@ -38,10 +38,10 @@ struct ComboDeprecatedDawnDeviceDescriptor : DeviceDescriptor {
|
||||||
|
|
||||||
if (deviceDescriptor != nullptr) {
|
if (deviceDescriptor != nullptr) {
|
||||||
desc->nextInChain = &mTogglesDesc;
|
desc->nextInChain = &mTogglesDesc;
|
||||||
mTogglesDesc.forceEnabledToggles = deviceDescriptor->forceEnabledToggles.data();
|
mTogglesDesc.enabledToggles = deviceDescriptor->forceEnabledToggles.data();
|
||||||
mTogglesDesc.forceEnabledTogglesCount = deviceDescriptor->forceEnabledToggles.size();
|
mTogglesDesc.enabledTogglesCount = deviceDescriptor->forceEnabledToggles.size();
|
||||||
mTogglesDesc.forceDisabledToggles = deviceDescriptor->forceDisabledToggles.data();
|
mTogglesDesc.disabledToggles = deviceDescriptor->forceDisabledToggles.data();
|
||||||
mTogglesDesc.forceDisabledTogglesCount = deviceDescriptor->forceDisabledToggles.size();
|
mTogglesDesc.disabledTogglesCount = deviceDescriptor->forceDisabledToggles.size();
|
||||||
|
|
||||||
desc->requiredLimits =
|
desc->requiredLimits =
|
||||||
reinterpret_cast<const RequiredLimits*>(deviceDescriptor->requiredLimits);
|
reinterpret_cast<const RequiredLimits*>(deviceDescriptor->requiredLimits);
|
||||||
|
@ -55,7 +55,7 @@ struct ComboDeprecatedDawnDeviceDescriptor : DeviceDescriptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnTogglesDeviceDescriptor mTogglesDesc = {};
|
DawnTogglesDescriptor mTogglesDesc = {};
|
||||||
std::vector<wgpu::FeatureName> mRequiredFeatures = {};
|
std::vector<wgpu::FeatureName> mRequiredFeatures = {};
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -400,20 +400,20 @@ std::vector<const char*> TogglesSet::GetContainedToggleNames() const {
|
||||||
return togglesNameInUse;
|
return togglesNameInUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
TripleStateTogglesSet TripleStateTogglesSet::CreateFromTogglesDeviceDescriptor(
|
TripleStateTogglesSet TripleStateTogglesSet::CreateFromTogglesDescriptor(
|
||||||
const DawnTogglesDeviceDescriptor* togglesDesc) {
|
const DawnTogglesDescriptor* togglesDesc) {
|
||||||
TripleStateTogglesSet userToggles;
|
TripleStateTogglesSet userToggles;
|
||||||
if (togglesDesc != nullptr) {
|
if (togglesDesc != nullptr) {
|
||||||
TogglesInfo togglesInfo;
|
TogglesInfo togglesInfo;
|
||||||
for (uint32_t i = 0; i < togglesDesc->forceEnabledTogglesCount; ++i) {
|
for (uint32_t i = 0; i < togglesDesc->enabledTogglesCount; ++i) {
|
||||||
Toggle toggle = togglesInfo.ToggleNameToEnum(togglesDesc->forceEnabledToggles[i]);
|
Toggle toggle = togglesInfo.ToggleNameToEnum(togglesDesc->enabledToggles[i]);
|
||||||
if (toggle != Toggle::InvalidEnum) {
|
if (toggle != Toggle::InvalidEnum) {
|
||||||
userToggles.togglesIsProvided.Set(toggle, true);
|
userToggles.togglesIsProvided.Set(toggle, true);
|
||||||
userToggles.providedTogglesEnabled.Set(toggle, true);
|
userToggles.providedTogglesEnabled.Set(toggle, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < togglesDesc->forceDisabledTogglesCount; ++i) {
|
for (uint32_t i = 0; i < togglesDesc->disabledTogglesCount; ++i) {
|
||||||
Toggle toggle = togglesInfo.ToggleNameToEnum(togglesDesc->forceDisabledToggles[i]);
|
Toggle toggle = togglesInfo.ToggleNameToEnum(togglesDesc->disabledToggles[i]);
|
||||||
if (toggle != Toggle::InvalidEnum) {
|
if (toggle != Toggle::InvalidEnum) {
|
||||||
userToggles.togglesIsProvided.Set(toggle, true);
|
userToggles.togglesIsProvided.Set(toggle, true);
|
||||||
userToggles.providedTogglesEnabled.Set(toggle, false);
|
userToggles.providedTogglesEnabled.Set(toggle, false);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
||||||
struct DawnTogglesDeviceDescriptor;
|
struct DawnTogglesDescriptor;
|
||||||
|
|
||||||
enum class Toggle {
|
enum class Toggle {
|
||||||
EmulateStoreAndMSAAResolve,
|
EmulateStoreAndMSAAResolve,
|
||||||
|
@ -114,8 +114,8 @@ struct TripleStateTogglesSet {
|
||||||
TogglesSet togglesIsProvided;
|
TogglesSet togglesIsProvided;
|
||||||
TogglesSet providedTogglesEnabled;
|
TogglesSet providedTogglesEnabled;
|
||||||
|
|
||||||
static TripleStateTogglesSet CreateFromTogglesDeviceDescriptor(
|
static TripleStateTogglesSet CreateFromTogglesDescriptor(
|
||||||
const DawnTogglesDeviceDescriptor* togglesDesc);
|
const DawnTogglesDescriptor* togglesDesc);
|
||||||
// Provide a single toggle with given state.
|
// Provide a single toggle with given state.
|
||||||
void Set(Toggle toggle, bool enabled);
|
void Set(Toggle toggle, bool enabled);
|
||||||
bool IsProvided(Toggle toggle) const;
|
bool IsProvided(Toggle toggle) const;
|
||||||
|
|
|
@ -162,23 +162,23 @@ interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevi
|
||||||
}
|
}
|
||||||
|
|
||||||
// Propogate enabled/disabled dawn features
|
// Propogate enabled/disabled dawn features
|
||||||
// Note: DawnDeviceTogglesDescriptor::forceEnabledToggles and forceDisabledToggles are
|
// Note: DawnTogglesDescriptor::enabledToggles and disabledToggles are vectors of 'const char*',
|
||||||
// vectors of 'const char*', so we make sure the parsed strings survive the CreateDevice()
|
// so we make sure the parsed strings survive the CreateDevice() call by storing them on the
|
||||||
// call by storing them on the stack.
|
// stack.
|
||||||
std::vector<std::string> enabledToggles;
|
std::vector<std::string> enabledTogglesString;
|
||||||
std::vector<std::string> disabledToggles;
|
std::vector<std::string> disabledTogglesString;
|
||||||
std::vector<const char*> forceEnabledToggles;
|
std::vector<const char*> enabledToggles;
|
||||||
std::vector<const char*> forceDisabledToggles;
|
std::vector<const char*> disabledToggles;
|
||||||
if (auto values = flags_.Get("enable-dawn-features")) {
|
if (auto values = flags_.Get("enable-dawn-features")) {
|
||||||
enabledToggles = Split(*values, ',');
|
enabledTogglesString = Split(*values, ',');
|
||||||
for (auto& t : enabledToggles) {
|
for (auto& t : enabledTogglesString) {
|
||||||
forceEnabledToggles.emplace_back(t.c_str());
|
enabledToggles.emplace_back(t.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (auto values = flags_.Get("disable-dawn-features")) {
|
if (auto values = flags_.Get("disable-dawn-features")) {
|
||||||
disabledToggles = Split(*values, ',');
|
disabledTogglesString = Split(*values, ',');
|
||||||
for (auto& t : disabledToggles) {
|
for (auto& t : disabledTogglesString) {
|
||||||
forceDisabledToggles.emplace_back(t.c_str());
|
disabledToggles.emplace_back(t.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,12 +186,12 @@ interop::Promise<interop::Interface<interop::GPUDevice>> GPUAdapter::requestDevi
|
||||||
desc.requiredFeatures = requiredFeatures.data();
|
desc.requiredFeatures = requiredFeatures.data();
|
||||||
desc.requiredLimits = &limits;
|
desc.requiredLimits = &limits;
|
||||||
|
|
||||||
DawnTogglesDeviceDescriptor togglesDesc = {};
|
DawnTogglesDescriptor deviceTogglesDesc = {};
|
||||||
desc.nextInChain = &togglesDesc;
|
desc.nextInChain = &deviceTogglesDesc;
|
||||||
togglesDesc.forceEnabledTogglesCount = forceEnabledToggles.size();
|
deviceTogglesDesc.enabledTogglesCount = enabledToggles.size();
|
||||||
togglesDesc.forceEnabledToggles = forceEnabledToggles.data();
|
deviceTogglesDesc.enabledToggles = enabledToggles.data();
|
||||||
togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
|
deviceTogglesDesc.disabledTogglesCount = disabledToggles.size();
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
|
deviceTogglesDesc.disabledToggles = disabledToggles.data();
|
||||||
|
|
||||||
auto wgpu_device = adapter_.CreateDevice(&desc);
|
auto wgpu_device = adapter_.CreateDevice(&desc);
|
||||||
if (wgpu_device) {
|
if (wgpu_device) {
|
||||||
|
|
|
@ -79,12 +79,12 @@ std::unique_ptr<dawn::platform::Platform> DawnNativeTest::CreateTestPlatform() {
|
||||||
WGPUDevice DawnNativeTest::CreateTestDevice() {
|
WGPUDevice DawnNativeTest::CreateTestDevice() {
|
||||||
// Disabled disallowing unsafe APIs so we can test them.
|
// Disabled disallowing unsafe APIs so we can test them.
|
||||||
wgpu::DeviceDescriptor deviceDescriptor = {};
|
wgpu::DeviceDescriptor deviceDescriptor = {};
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc = {};
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc = {};
|
||||||
deviceDescriptor.nextInChain = &togglesDesc;
|
deviceDescriptor.nextInChain = &deviceTogglesDesc;
|
||||||
|
|
||||||
const char* toggle = "disallow_unsafe_apis";
|
const char* toggle = "disallow_unsafe_apis";
|
||||||
togglesDesc.forceDisabledToggles = &toggle;
|
deviceTogglesDesc.disabledToggles = &toggle;
|
||||||
togglesDesc.forceDisabledTogglesCount = 1;
|
deviceTogglesDesc.disabledTogglesCount = 1;
|
||||||
|
|
||||||
return adapter.CreateDevice(&deviceDescriptor);
|
return adapter.CreateDevice(&deviceDescriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -882,15 +882,15 @@ WGPUDevice DawnTestBase::CreateDeviceImpl(std::string isolationKey) {
|
||||||
deviceDescriptor.requiredFeatures = requiredFeatures.data();
|
deviceDescriptor.requiredFeatures = requiredFeatures.data();
|
||||||
deviceDescriptor.requiredFeaturesCount = requiredFeatures.size();
|
deviceDescriptor.requiredFeaturesCount = requiredFeatures.size();
|
||||||
|
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc = {};
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc = {};
|
||||||
deviceDescriptor.nextInChain = &togglesDesc;
|
deviceDescriptor.nextInChain = &deviceTogglesDesc;
|
||||||
togglesDesc.forceEnabledToggles = forceEnabledToggles.data();
|
deviceTogglesDesc.enabledToggles = forceEnabledToggles.data();
|
||||||
togglesDesc.forceEnabledTogglesCount = forceEnabledToggles.size();
|
deviceTogglesDesc.enabledTogglesCount = forceEnabledToggles.size();
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
|
deviceTogglesDesc.disabledToggles = forceDisabledToggles.data();
|
||||||
togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
|
deviceTogglesDesc.disabledTogglesCount = forceDisabledToggles.size();
|
||||||
|
|
||||||
wgpu::DawnCacheDeviceDescriptor cacheDesc = {};
|
wgpu::DawnCacheDeviceDescriptor cacheDesc = {};
|
||||||
togglesDesc.nextInChain = &cacheDesc;
|
deviceTogglesDesc.nextInChain = &cacheDesc;
|
||||||
cacheDesc.isolationKey = isolationKey.c_str();
|
cacheDesc.isolationKey = isolationKey.c_str();
|
||||||
|
|
||||||
return mBackendAdapter.CreateDevice(&deviceDescriptor);
|
return mBackendAdapter.CreateDevice(&deviceDescriptor);
|
||||||
|
|
|
@ -77,11 +77,11 @@ TEST_F(FeatureTests, AdapterWithRequiredFeatureDisabled) {
|
||||||
unsafeDeviceDescriptor.requiredFeatures = &featureName;
|
unsafeDeviceDescriptor.requiredFeatures = &featureName;
|
||||||
unsafeDeviceDescriptor.requiredFeaturesCount = 1;
|
unsafeDeviceDescriptor.requiredFeaturesCount = 1;
|
||||||
|
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
unsafeDeviceDescriptor.nextInChain = &togglesDesc;
|
unsafeDeviceDescriptor.nextInChain = &deviceTogglesDesc;
|
||||||
const char* toggle = "disallow_unsafe_apis";
|
const char* toggle = "disallow_unsafe_apis";
|
||||||
togglesDesc.forceDisabledToggles = &toggle;
|
deviceTogglesDesc.disabledToggles = &toggle;
|
||||||
togglesDesc.forceDisabledTogglesCount = 1;
|
deviceTogglesDesc.disabledTogglesCount = 1;
|
||||||
|
|
||||||
WGPUDevice deviceWithFeature = adapterWithoutFeature.CreateDevice(
|
WGPUDevice deviceWithFeature = adapterWithoutFeature.CreateDevice(
|
||||||
reinterpret_cast<const WGPUDeviceDescriptor*>(&unsafeDeviceDescriptor));
|
reinterpret_cast<const WGPUDeviceDescriptor*>(&unsafeDeviceDescriptor));
|
||||||
|
@ -133,9 +133,9 @@ TEST_F(FeatureTests, RequireAndGetEnabledFeatures) {
|
||||||
unsafeDeviceDescriptor.requiredFeaturesCount = 1;
|
unsafeDeviceDescriptor.requiredFeaturesCount = 1;
|
||||||
|
|
||||||
const char* const disableToggles[] = {"disallow_unsafe_apis"};
|
const char* const disableToggles[] = {"disallow_unsafe_apis"};
|
||||||
wgpu::DawnTogglesDeviceDescriptor toggleDesc;
|
wgpu::DawnTogglesDescriptor toggleDesc;
|
||||||
toggleDesc.forceDisabledToggles = disableToggles;
|
toggleDesc.disabledToggles = disableToggles;
|
||||||
toggleDesc.forceDisabledTogglesCount = 1;
|
toggleDesc.disabledTogglesCount = 1;
|
||||||
unsafeDeviceDescriptor.nextInChain = &toggleDesc;
|
unsafeDeviceDescriptor.nextInChain = &toggleDesc;
|
||||||
|
|
||||||
dawn::native::DeviceBase* deviceBase = dawn::native::FromAPI(adapter.CreateDevice(
|
dawn::native::DeviceBase* deviceBase = dawn::native::FromAPI(adapter.CreateDevice(
|
||||||
|
|
|
@ -77,12 +77,12 @@ TEST_F(DeviceCreationTest, CreateDeviceSuccess) {
|
||||||
// Test successful call to CreateDevice with toggle descriptor.
|
// Test successful call to CreateDevice with toggle descriptor.
|
||||||
TEST_F(DeviceCreationTest, CreateDeviceWithTogglesSuccess) {
|
TEST_F(DeviceCreationTest, CreateDeviceWithTogglesSuccess) {
|
||||||
wgpu::DeviceDescriptor desc = {};
|
wgpu::DeviceDescriptor desc = {};
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc = {};
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc = {};
|
||||||
desc.nextInChain = &togglesDesc;
|
desc.nextInChain = &deviceTogglesDesc;
|
||||||
|
|
||||||
const char* toggle = "skip_validation";
|
const char* toggle = "skip_validation";
|
||||||
togglesDesc.forceEnabledToggles = &toggle;
|
deviceTogglesDesc.enabledToggles = &toggle;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
deviceTogglesDesc.enabledTogglesCount = 1;
|
||||||
|
|
||||||
wgpu::Device device = adapter.CreateDevice(&desc);
|
wgpu::Device device = adapter.CreateDevice(&desc);
|
||||||
EXPECT_NE(device, nullptr);
|
EXPECT_NE(device, nullptr);
|
||||||
|
@ -110,10 +110,10 @@ TEST_F(DeviceCreationTest, CreateDeviceRequiringFeaturesGuardedByToggle) {
|
||||||
// Test creating device without DisallowUnsafeApis toggle disabled.
|
// Test creating device without DisallowUnsafeApis toggle disabled.
|
||||||
{
|
{
|
||||||
const char* const disableToggles[] = {"disallow_unsafe_apis"};
|
const char* const disableToggles[] = {"disallow_unsafe_apis"};
|
||||||
wgpu::DawnTogglesDeviceDescriptor toggleDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
toggleDesc.forceDisabledToggles = disableToggles;
|
deviceTogglesDesc.disabledToggles = disableToggles;
|
||||||
toggleDesc.forceDisabledTogglesCount = 1;
|
deviceTogglesDesc.disabledTogglesCount = 1;
|
||||||
deviceDescriptor.nextInChain = &toggleDesc;
|
deviceDescriptor.nextInChain = &deviceTogglesDesc;
|
||||||
|
|
||||||
wgpu::Device device = adapter.CreateDevice(&deviceDescriptor);
|
wgpu::Device device = adapter.CreateDevice(&deviceDescriptor);
|
||||||
EXPECT_NE(device, nullptr);
|
EXPECT_NE(device, nullptr);
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
WGPUDevice DeprecationTests::CreateTestDevice(dawn::native::Adapter dawnAdapter) {
|
WGPUDevice DeprecationTests::CreateTestDevice(dawn::native::Adapter dawnAdapter) {
|
||||||
wgpu::DeviceDescriptor descriptor = {};
|
wgpu::DeviceDescriptor descriptor = {};
|
||||||
|
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc = {};
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc = {};
|
||||||
const char* forceEnabledToggles[1] = {kDisallowDeprecatedAPIsToggleName};
|
const char* enabledToggles[1] = {kDisallowDeprecatedAPIsToggleName};
|
||||||
togglesDesc.forceEnabledToggles = forceEnabledToggles;
|
deviceTogglesDesc.enabledToggles = enabledToggles;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
deviceTogglesDesc.enabledTogglesCount = 1;
|
||||||
|
|
||||||
if (GetParam()) {
|
if (GetParam()) {
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
}
|
}
|
||||||
return dawnAdapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,11 +279,11 @@ class TimestampQueryValidationTest : public QuerySetValidationTest {
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 1;
|
descriptor.requiredFeaturesCount = 1;
|
||||||
|
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
const char* forceDisabledToggles[1] = {"disallow_unsafe_apis"};
|
const char* disabledToggles[1] = {"disallow_unsafe_apis"};
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggles;
|
deviceTogglesDesc.disabledToggles = disabledToggles;
|
||||||
togglesDesc.forceDisabledTogglesCount = 1;
|
deviceTogglesDesc.disabledTogglesCount = 1;
|
||||||
|
|
||||||
return dawnAdapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
@ -582,11 +582,11 @@ class TimestampQueryInsidePassesValidationTest : public QuerySetValidationTest {
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 2;
|
descriptor.requiredFeaturesCount = 2;
|
||||||
|
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
const char* forceDisabledToggles[1] = {"disallow_unsafe_apis"};
|
const char* disabledToggles[1] = {"disallow_unsafe_apis"};
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggles;
|
deviceTogglesDesc.disabledToggles = disabledToggles;
|
||||||
togglesDesc.forceDisabledTogglesCount = 1;
|
deviceTogglesDesc.disabledTogglesCount = 1;
|
||||||
|
|
||||||
return dawnAdapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
@ -729,11 +729,11 @@ class PipelineStatisticsQueryValidationTest : public QuerySetValidationTest {
|
||||||
|
|
||||||
// TODO(crbug.com/1177506): Pipeline statistic query is an unsafe API, disable disallowing
|
// TODO(crbug.com/1177506): Pipeline statistic query is an unsafe API, disable disallowing
|
||||||
// unsafe APIs to test it.
|
// unsafe APIs to test it.
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
const char* forceDisabledToggles[1] = {"disallow_unsafe_apis"};
|
const char* disabledToggles[1] = {"disallow_unsafe_apis"};
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggles;
|
deviceTogglesDesc.disabledToggles = disabledToggles;
|
||||||
togglesDesc.forceDisabledTogglesCount = 1;
|
deviceTogglesDesc.disabledTogglesCount = 1;
|
||||||
|
|
||||||
return dawnAdapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,20 +27,20 @@ class RenderPipelineValidationTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
// Disabled disallowing unsafe APIs so we can test ShaderF16 feature.
|
// Disabled disallowing unsafe APIs so we can test ShaderF16 feature.
|
||||||
const char* forceDisabledToggle[] = {"disallow_unsafe_apis"};
|
const char* disabledToggle[] = {"disallow_unsafe_apis"};
|
||||||
|
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::ShaderF16};
|
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::ShaderF16};
|
||||||
descriptor.requiredFeatures = requiredFeatures;
|
descriptor.requiredFeatures = requiredFeatures;
|
||||||
descriptor.requiredFeaturesCount = 1;
|
descriptor.requiredFeaturesCount = 1;
|
||||||
|
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
|
|
||||||
togglesDesc.forceEnabledToggles = nullptr;
|
deviceTogglesDesc.enabledToggles = nullptr;
|
||||||
togglesDesc.forceEnabledTogglesCount = 0;
|
deviceTogglesDesc.enabledTogglesCount = 0;
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggle;
|
deviceTogglesDesc.disabledToggles = disabledToggle;
|
||||||
togglesDesc.forceDisabledTogglesCount = 1;
|
deviceTogglesDesc.disabledTogglesCount = 1;
|
||||||
|
|
||||||
return dawnAdapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,11 +731,11 @@ class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||||
|
|
||||||
// TODO(dawn:814): Remove when 1D texture support is complete.
|
// TODO(dawn:814): Remove when 1D texture support is complete.
|
||||||
const char* kDisallowUnsafeApis = "disallow_unsafe_apis";
|
const char* kDisallowUnsafeApis = "disallow_unsafe_apis";
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
togglesDesc.forceDisabledToggles = &kDisallowUnsafeApis;
|
deviceTogglesDesc.disabledToggles = &kDisallowUnsafeApis;
|
||||||
togglesDesc.forceDisabledTogglesCount = 1;
|
deviceTogglesDesc.disabledTogglesCount = 1;
|
||||||
|
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
|
|
||||||
return dawnAdapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,10 +51,10 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
||||||
{
|
{
|
||||||
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
togglesDesc.forceEnabledToggles = &kValidToggleName;
|
deviceTogglesDesc.enabledToggles = &kValidToggleName;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
deviceTogglesDesc.enabledTogglesCount = 1;
|
||||||
|
|
||||||
wgpu::Device deviceWithToggle =
|
wgpu::Device deviceWithToggle =
|
||||||
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
||||||
|
@ -72,10 +72,10 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
||||||
{
|
{
|
||||||
const char* kInvalidToggleName = "!@#$%^&*";
|
const char* kInvalidToggleName = "!@#$%^&*";
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
togglesDesc.forceEnabledToggles = &kInvalidToggleName;
|
deviceTogglesDesc.enabledToggles = &kInvalidToggleName;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
deviceTogglesDesc.enabledTogglesCount = 1;
|
||||||
|
|
||||||
wgpu::Device deviceWithToggle =
|
wgpu::Device deviceWithToggle =
|
||||||
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
||||||
|
@ -93,10 +93,10 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
||||||
TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
|
TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
|
||||||
const char* kValidToggleName = "turn_off_vsync";
|
const char* kValidToggleName = "turn_off_vsync";
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
togglesDesc.forceEnabledToggles = &kValidToggleName;
|
deviceTogglesDesc.enabledToggles = &kValidToggleName;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
deviceTogglesDesc.enabledTogglesCount = 1;
|
||||||
|
|
||||||
wgpu::Device deviceWithToggle =
|
wgpu::Device deviceWithToggle =
|
||||||
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
wgpu::Device::Acquire(GetBackendAdapter().CreateDevice(&descriptor));
|
||||||
|
|
|
@ -28,11 +28,11 @@ class UnsafeAPIValidationTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override {
|
||||||
wgpu::DeviceDescriptor descriptor;
|
wgpu::DeviceDescriptor descriptor;
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
descriptor.nextInChain = &togglesDesc;
|
descriptor.nextInChain = &deviceTogglesDesc;
|
||||||
const char* toggle = "disallow_unsafe_apis";
|
const char* toggle = "disallow_unsafe_apis";
|
||||||
togglesDesc.forceEnabledToggles = &toggle;
|
deviceTogglesDesc.enabledToggles = &toggle;
|
||||||
togglesDesc.forceEnabledTogglesCount = 1;
|
deviceTogglesDesc.enabledTogglesCount = 1;
|
||||||
return dawnAdapter.CreateDevice(&descriptor);
|
return dawnAdapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -264,25 +264,25 @@ dawn::native::Adapter& ValidationTest::GetBackendAdapter() {
|
||||||
|
|
||||||
WGPUDevice ValidationTest::CreateTestDevice(dawn::native::Adapter dawnAdapter) {
|
WGPUDevice ValidationTest::CreateTestDevice(dawn::native::Adapter dawnAdapter) {
|
||||||
// Disabled disallowing unsafe APIs so we can test them.
|
// Disabled disallowing unsafe APIs so we can test them.
|
||||||
std::vector<const char*> forceEnabledToggles;
|
std::vector<const char*> enabledToggles;
|
||||||
std::vector<const char*> forceDisabledToggles = {"disallow_unsafe_apis"};
|
std::vector<const char*> disabledToggles = {"disallow_unsafe_apis"};
|
||||||
|
|
||||||
for (const std::string& toggle : gToggleParser->GetEnabledToggles()) {
|
for (const std::string& toggle : gToggleParser->GetEnabledToggles()) {
|
||||||
forceEnabledToggles.push_back(toggle.c_str());
|
enabledToggles.push_back(toggle.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const std::string& toggle : gToggleParser->GetDisabledToggles()) {
|
for (const std::string& toggle : gToggleParser->GetDisabledToggles()) {
|
||||||
forceDisabledToggles.push_back(toggle.c_str());
|
disabledToggles.push_back(toggle.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::DeviceDescriptor deviceDescriptor;
|
wgpu::DeviceDescriptor deviceDescriptor;
|
||||||
wgpu::DawnTogglesDeviceDescriptor togglesDesc;
|
wgpu::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
deviceDescriptor.nextInChain = &togglesDesc;
|
deviceDescriptor.nextInChain = &deviceTogglesDesc;
|
||||||
|
|
||||||
togglesDesc.forceEnabledToggles = forceEnabledToggles.data();
|
deviceTogglesDesc.enabledToggles = enabledToggles.data();
|
||||||
togglesDesc.forceEnabledTogglesCount = forceEnabledToggles.size();
|
deviceTogglesDesc.enabledTogglesCount = enabledToggles.size();
|
||||||
togglesDesc.forceDisabledToggles = forceDisabledToggles.data();
|
deviceTogglesDesc.disabledToggles = disabledToggles.data();
|
||||||
togglesDesc.forceDisabledTogglesCount = forceDisabledToggles.size();
|
deviceTogglesDesc.disabledTogglesCount = disabledToggles.size();
|
||||||
|
|
||||||
return dawnAdapter.CreateDevice(&deviceDescriptor);
|
return dawnAdapter.CreateDevice(&deviceDescriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,11 +267,11 @@ class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
|
||||||
// Create another device based on the original
|
// Create another device based on the original
|
||||||
backendAdapter =
|
backendAdapter =
|
||||||
dawn::native::vulkan::ToBackend(dawn::native::FromAPI(device.Get())->GetAdapter());
|
dawn::native::vulkan::ToBackend(dawn::native::FromAPI(device.Get())->GetAdapter());
|
||||||
deviceDescriptor.nextInChain = &togglesDesc;
|
deviceDescriptor.nextInChain = &deviceTogglesDesc;
|
||||||
togglesDesc.forceEnabledToggles = GetParam().forceEnabledWorkarounds.data();
|
deviceTogglesDesc.enabledToggles = GetParam().forceEnabledWorkarounds.data();
|
||||||
togglesDesc.forceEnabledTogglesCount = GetParam().forceEnabledWorkarounds.size();
|
deviceTogglesDesc.enabledTogglesCount = GetParam().forceEnabledWorkarounds.size();
|
||||||
togglesDesc.forceDisabledToggles = GetParam().forceDisabledWorkarounds.data();
|
deviceTogglesDesc.disabledToggles = GetParam().forceDisabledWorkarounds.data();
|
||||||
togglesDesc.forceDisabledTogglesCount = GetParam().forceDisabledWorkarounds.size();
|
deviceTogglesDesc.disabledTogglesCount = GetParam().forceDisabledWorkarounds.size();
|
||||||
|
|
||||||
secondDeviceVk =
|
secondDeviceVk =
|
||||||
dawn::native::vulkan::ToBackend(backendAdapter->APICreateDevice(&deviceDescriptor));
|
dawn::native::vulkan::ToBackend(backendAdapter->APICreateDevice(&deviceDescriptor));
|
||||||
|
@ -281,7 +281,7 @@ class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
|
||||||
protected:
|
protected:
|
||||||
dawn::native::vulkan::Adapter* backendAdapter;
|
dawn::native::vulkan::Adapter* backendAdapter;
|
||||||
dawn::native::DeviceDescriptor deviceDescriptor;
|
dawn::native::DeviceDescriptor deviceDescriptor;
|
||||||
dawn::native::DawnTogglesDeviceDescriptor togglesDesc;
|
dawn::native::DawnTogglesDescriptor deviceTogglesDesc;
|
||||||
|
|
||||||
wgpu::Device secondDevice;
|
wgpu::Device secondDevice;
|
||||||
dawn::native::vulkan::Device* secondDeviceVk;
|
dawn::native::vulkan::Device* secondDeviceVk;
|
||||||
|
|
Loading…
Reference in New Issue