dawn_node: Implement requesting limits
And reject the device creation promise with an error that looks like an OperationError to make the CTS happy. Bug: dawn:1242 Change-Id: I43ec3ebc030cb4178520c9174e164a42b94f6bf8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85060 Reviewed-by: Brandon Jones <bajones@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
21163f1ade
commit
fc1a2ae904
|
@ -49,7 +49,7 @@ namespace wgpu::binding {
|
|||
|
||||
static Napi::Error New(Napi::Env env,
|
||||
std::string name,
|
||||
std::string message = {},
|
||||
std::string message,
|
||||
unsigned short code = 0) {
|
||||
auto err = Napi::Error::New(env);
|
||||
err.Set("name", name);
|
||||
|
@ -60,120 +60,120 @@ namespace wgpu::binding {
|
|||
|
||||
} // namespace
|
||||
|
||||
Napi::Error Errors::HierarchyRequestError(Napi::Env env) {
|
||||
return New(env, kHierarchyRequestError);
|
||||
Napi::Error Errors::HierarchyRequestError(Napi::Env env, std::string message) {
|
||||
return New(env, kHierarchyRequestError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::WrongDocumentError(Napi::Env env) {
|
||||
return New(env, kWrongDocumentError);
|
||||
Napi::Error Errors::WrongDocumentError(Napi::Env env, std::string message) {
|
||||
return New(env, kWrongDocumentError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::InvalidCharacterError(Napi::Env env) {
|
||||
return New(env, kInvalidCharacterError);
|
||||
Napi::Error Errors::InvalidCharacterError(Napi::Env env, std::string message) {
|
||||
return New(env, kInvalidCharacterError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::NoModificationAllowedError(Napi::Env env) {
|
||||
return New(env, kNoModificationAllowedError);
|
||||
Napi::Error Errors::NoModificationAllowedError(Napi::Env env, std::string message) {
|
||||
return New(env, kNoModificationAllowedError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::NotFoundError(Napi::Env env) {
|
||||
return New(env, kNotFoundError);
|
||||
Napi::Error Errors::NotFoundError(Napi::Env env, std::string message) {
|
||||
return New(env, kNotFoundError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::NotSupportedError(Napi::Env env) {
|
||||
return New(env, kNotSupportedError);
|
||||
Napi::Error Errors::NotSupportedError(Napi::Env env, std::string message) {
|
||||
return New(env, kNotSupportedError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::InUseAttributeError(Napi::Env env) {
|
||||
return New(env, kInUseAttributeError);
|
||||
Napi::Error Errors::InUseAttributeError(Napi::Env env, std::string message) {
|
||||
return New(env, kInUseAttributeError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::InvalidStateError(Napi::Env env) {
|
||||
return New(env, kInvalidStateError);
|
||||
Napi::Error Errors::InvalidStateError(Napi::Env env, std::string message) {
|
||||
return New(env, kInvalidStateError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::SyntaxError(Napi::Env env) {
|
||||
return New(env, kSyntaxError);
|
||||
Napi::Error Errors::SyntaxError(Napi::Env env, std::string message) {
|
||||
return New(env, kSyntaxError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::InvalidModificationError(Napi::Env env) {
|
||||
return New(env, kInvalidModificationError);
|
||||
Napi::Error Errors::InvalidModificationError(Napi::Env env, std::string message) {
|
||||
return New(env, kInvalidModificationError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::NamespaceError(Napi::Env env) {
|
||||
return New(env, kNamespaceError);
|
||||
Napi::Error Errors::NamespaceError(Napi::Env env, std::string message) {
|
||||
return New(env, kNamespaceError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::SecurityError(Napi::Env env) {
|
||||
return New(env, kSecurityError);
|
||||
Napi::Error Errors::SecurityError(Napi::Env env, std::string message) {
|
||||
return New(env, kSecurityError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::NetworkError(Napi::Env env) {
|
||||
return New(env, kNetworkError);
|
||||
Napi::Error Errors::NetworkError(Napi::Env env, std::string message) {
|
||||
return New(env, kNetworkError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::AbortError(Napi::Env env) {
|
||||
return New(env, kAbortError);
|
||||
Napi::Error Errors::AbortError(Napi::Env env, std::string message) {
|
||||
return New(env, kAbortError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::URLMismatchError(Napi::Env env) {
|
||||
return New(env, kURLMismatchError);
|
||||
Napi::Error Errors::URLMismatchError(Napi::Env env, std::string message) {
|
||||
return New(env, kURLMismatchError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::QuotaExceededError(Napi::Env env) {
|
||||
return New(env, kQuotaExceededError);
|
||||
Napi::Error Errors::QuotaExceededError(Napi::Env env, std::string message) {
|
||||
return New(env, kQuotaExceededError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::TimeoutError(Napi::Env env) {
|
||||
return New(env, kTimeoutError);
|
||||
Napi::Error Errors::TimeoutError(Napi::Env env, std::string message) {
|
||||
return New(env, kTimeoutError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::InvalidNodeTypeError(Napi::Env env) {
|
||||
return New(env, kInvalidNodeTypeError);
|
||||
Napi::Error Errors::InvalidNodeTypeError(Napi::Env env, std::string message) {
|
||||
return New(env, kInvalidNodeTypeError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::DataCloneError(Napi::Env env) {
|
||||
return New(env, kDataCloneError);
|
||||
Napi::Error Errors::DataCloneError(Napi::Env env, std::string message) {
|
||||
return New(env, kDataCloneError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::EncodingError(Napi::Env env) {
|
||||
return New(env, kEncodingError);
|
||||
Napi::Error Errors::EncodingError(Napi::Env env, std::string message) {
|
||||
return New(env, kEncodingError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::NotReadableError(Napi::Env env) {
|
||||
return New(env, kNotReadableError);
|
||||
Napi::Error Errors::NotReadableError(Napi::Env env, std::string message) {
|
||||
return New(env, kNotReadableError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::UnknownError(Napi::Env env) {
|
||||
return New(env, kUnknownError);
|
||||
Napi::Error Errors::UnknownError(Napi::Env env, std::string message) {
|
||||
return New(env, kUnknownError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::ConstraintError(Napi::Env env) {
|
||||
return New(env, kConstraintError);
|
||||
Napi::Error Errors::ConstraintError(Napi::Env env, std::string message) {
|
||||
return New(env, kConstraintError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::DataError(Napi::Env env) {
|
||||
return New(env, kDataError);
|
||||
Napi::Error Errors::DataError(Napi::Env env, std::string message) {
|
||||
return New(env, kDataError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::TransactionInactiveError(Napi::Env env) {
|
||||
return New(env, kTransactionInactiveError);
|
||||
Napi::Error Errors::TransactionInactiveError(Napi::Env env, std::string message) {
|
||||
return New(env, kTransactionInactiveError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::ReadOnlyError(Napi::Env env) {
|
||||
return New(env, kReadOnlyError);
|
||||
Napi::Error Errors::ReadOnlyError(Napi::Env env, std::string message) {
|
||||
return New(env, kReadOnlyError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::VersionError(Napi::Env env) {
|
||||
return New(env, kVersionError);
|
||||
Napi::Error Errors::VersionError(Napi::Env env, std::string message) {
|
||||
return New(env, kVersionError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::OperationError(Napi::Env env) {
|
||||
return New(env, kOperationError);
|
||||
Napi::Error Errors::OperationError(Napi::Env env, std::string message) {
|
||||
return New(env, kOperationError, message);
|
||||
}
|
||||
|
||||
Napi::Error Errors::NotAllowedError(Napi::Env env) {
|
||||
return New(env, kNotAllowedError);
|
||||
Napi::Error Errors::NotAllowedError(Napi::Env env, std::string message) {
|
||||
return New(env, kNotAllowedError, message);
|
||||
}
|
||||
|
||||
} // namespace wgpu::binding
|
||||
|
|
|
@ -24,35 +24,35 @@ namespace wgpu::binding {
|
|||
// https://heycam.github.io/webidl/#idl-DOMException-error-names
|
||||
class Errors {
|
||||
public:
|
||||
static Napi::Error HierarchyRequestError(Napi::Env);
|
||||
static Napi::Error WrongDocumentError(Napi::Env);
|
||||
static Napi::Error InvalidCharacterError(Napi::Env);
|
||||
static Napi::Error NoModificationAllowedError(Napi::Env);
|
||||
static Napi::Error NotFoundError(Napi::Env);
|
||||
static Napi::Error NotSupportedError(Napi::Env);
|
||||
static Napi::Error InUseAttributeError(Napi::Env);
|
||||
static Napi::Error InvalidStateError(Napi::Env);
|
||||
static Napi::Error SyntaxError(Napi::Env);
|
||||
static Napi::Error InvalidModificationError(Napi::Env);
|
||||
static Napi::Error NamespaceError(Napi::Env);
|
||||
static Napi::Error SecurityError(Napi::Env);
|
||||
static Napi::Error NetworkError(Napi::Env);
|
||||
static Napi::Error AbortError(Napi::Env);
|
||||
static Napi::Error URLMismatchError(Napi::Env);
|
||||
static Napi::Error QuotaExceededError(Napi::Env);
|
||||
static Napi::Error TimeoutError(Napi::Env);
|
||||
static Napi::Error InvalidNodeTypeError(Napi::Env);
|
||||
static Napi::Error DataCloneError(Napi::Env);
|
||||
static Napi::Error EncodingError(Napi::Env);
|
||||
static Napi::Error NotReadableError(Napi::Env);
|
||||
static Napi::Error UnknownError(Napi::Env);
|
||||
static Napi::Error ConstraintError(Napi::Env);
|
||||
static Napi::Error DataError(Napi::Env);
|
||||
static Napi::Error TransactionInactiveError(Napi::Env);
|
||||
static Napi::Error ReadOnlyError(Napi::Env);
|
||||
static Napi::Error VersionError(Napi::Env);
|
||||
static Napi::Error OperationError(Napi::Env);
|
||||
static Napi::Error NotAllowedError(Napi::Env);
|
||||
static Napi::Error HierarchyRequestError(Napi::Env, std::string message = {});
|
||||
static Napi::Error WrongDocumentError(Napi::Env, std::string message = {});
|
||||
static Napi::Error InvalidCharacterError(Napi::Env, std::string message = {});
|
||||
static Napi::Error NoModificationAllowedError(Napi::Env, std::string message = {});
|
||||
static Napi::Error NotFoundError(Napi::Env, std::string message = {});
|
||||
static Napi::Error NotSupportedError(Napi::Env, std::string message = {});
|
||||
static Napi::Error InUseAttributeError(Napi::Env, std::string message = {});
|
||||
static Napi::Error InvalidStateError(Napi::Env, std::string message = {});
|
||||
static Napi::Error SyntaxError(Napi::Env, std::string message = {});
|
||||
static Napi::Error InvalidModificationError(Napi::Env, std::string message = {});
|
||||
static Napi::Error NamespaceError(Napi::Env, std::string message = {});
|
||||
static Napi::Error SecurityError(Napi::Env, std::string message = {});
|
||||
static Napi::Error NetworkError(Napi::Env, std::string message = {});
|
||||
static Napi::Error AbortError(Napi::Env, std::string message = {});
|
||||
static Napi::Error URLMismatchError(Napi::Env, std::string message = {});
|
||||
static Napi::Error QuotaExceededError(Napi::Env, std::string message = {});
|
||||
static Napi::Error TimeoutError(Napi::Env, std::string message = {});
|
||||
static Napi::Error InvalidNodeTypeError(Napi::Env, std::string message = {});
|
||||
static Napi::Error DataCloneError(Napi::Env, std::string message = {});
|
||||
static Napi::Error EncodingError(Napi::Env, std::string message = {});
|
||||
static Napi::Error NotReadableError(Napi::Env, std::string message = {});
|
||||
static Napi::Error UnknownError(Napi::Env, std::string message = {});
|
||||
static Napi::Error ConstraintError(Napi::Env, std::string message = {});
|
||||
static Napi::Error DataError(Napi::Env, std::string message = {});
|
||||
static Napi::Error TransactionInactiveError(Napi::Env, std::string message = {});
|
||||
static Napi::Error ReadOnlyError(Napi::Env, std::string message = {});
|
||||
static Napi::Error VersionError(Napi::Env, std::string message = {});
|
||||
static Napi::Error OperationError(Napi::Env, std::string message = {});
|
||||
static Napi::Error NotAllowedError(Napi::Env, std::string message = {});
|
||||
};
|
||||
|
||||
} // namespace wgpu::binding
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "src/dawn/node/binding/Errors.h"
|
||||
#include "src/dawn/node/binding/Flags.h"
|
||||
#include "src/dawn/node/binding/GPUDevice.h"
|
||||
#include "src/dawn/node/binding/GPUSupportedLimits.h"
|
||||
|
@ -48,6 +49,34 @@ namespace {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
#define FOR_EACH_LIMIT(X) \
|
||||
X(maxTextureDimension1D) \
|
||||
X(maxTextureDimension2D) \
|
||||
X(maxTextureDimension3D) \
|
||||
X(maxTextureArrayLayers) \
|
||||
X(maxBindGroups) \
|
||||
X(maxDynamicUniformBuffersPerPipelineLayout) \
|
||||
X(maxDynamicStorageBuffersPerPipelineLayout) \
|
||||
X(maxSampledTexturesPerShaderStage) \
|
||||
X(maxSamplersPerShaderStage) \
|
||||
X(maxStorageBuffersPerShaderStage) \
|
||||
X(maxStorageTexturesPerShaderStage) \
|
||||
X(maxUniformBuffersPerShaderStage) \
|
||||
X(maxUniformBufferBindingSize) \
|
||||
X(maxStorageBufferBindingSize) \
|
||||
X(minUniformBufferOffsetAlignment) \
|
||||
X(minStorageBufferOffsetAlignment) \
|
||||
X(maxVertexBuffers) \
|
||||
X(maxVertexAttributes) \
|
||||
X(maxVertexBufferArrayStride) \
|
||||
X(maxInterStageShaderComponents) \
|
||||
X(maxComputeWorkgroupStorageSize) \
|
||||
X(maxComputeInvocationsPerWorkgroup) \
|
||||
X(maxComputeWorkgroupSizeX) \
|
||||
X(maxComputeWorkgroupSizeY) \
|
||||
X(maxComputeWorkgroupSizeZ) \
|
||||
X(maxComputeWorkgroupsPerDimension)
|
||||
|
||||
namespace wgpu::binding {
|
||||
|
||||
namespace {
|
||||
|
@ -138,33 +167,8 @@ namespace wgpu::binding {
|
|||
|
||||
wgpu::SupportedLimits wgpuLimits{};
|
||||
|
||||
#define COPY_LIMIT(LIMIT) wgpuLimits.limits.LIMIT = limits.limits.LIMIT
|
||||
COPY_LIMIT(maxTextureDimension1D);
|
||||
COPY_LIMIT(maxTextureDimension2D);
|
||||
COPY_LIMIT(maxTextureDimension3D);
|
||||
COPY_LIMIT(maxTextureArrayLayers);
|
||||
COPY_LIMIT(maxBindGroups);
|
||||
COPY_LIMIT(maxDynamicUniformBuffersPerPipelineLayout);
|
||||
COPY_LIMIT(maxDynamicStorageBuffersPerPipelineLayout);
|
||||
COPY_LIMIT(maxSampledTexturesPerShaderStage);
|
||||
COPY_LIMIT(maxSamplersPerShaderStage);
|
||||
COPY_LIMIT(maxStorageBuffersPerShaderStage);
|
||||
COPY_LIMIT(maxStorageTexturesPerShaderStage);
|
||||
COPY_LIMIT(maxUniformBuffersPerShaderStage);
|
||||
COPY_LIMIT(maxUniformBufferBindingSize);
|
||||
COPY_LIMIT(maxStorageBufferBindingSize);
|
||||
COPY_LIMIT(minUniformBufferOffsetAlignment);
|
||||
COPY_LIMIT(minStorageBufferOffsetAlignment);
|
||||
COPY_LIMIT(maxVertexBuffers);
|
||||
COPY_LIMIT(maxVertexAttributes);
|
||||
COPY_LIMIT(maxVertexBufferArrayStride);
|
||||
COPY_LIMIT(maxInterStageShaderComponents);
|
||||
COPY_LIMIT(maxComputeWorkgroupStorageSize);
|
||||
COPY_LIMIT(maxComputeInvocationsPerWorkgroup);
|
||||
COPY_LIMIT(maxComputeWorkgroupSizeX);
|
||||
COPY_LIMIT(maxComputeWorkgroupSizeY);
|
||||
COPY_LIMIT(maxComputeWorkgroupSizeZ);
|
||||
COPY_LIMIT(maxComputeWorkgroupsPerDimension);
|
||||
#define COPY_LIMIT(LIMIT) wgpuLimits.limits.LIMIT = limits.limits.LIMIT;
|
||||
FOR_EACH_LIMIT(COPY_LIMIT)
|
||||
#undef COPY_LIMIT
|
||||
|
||||
return interop::GPUSupportedLimits::Create<GPUSupportedLimits>(env, wgpuLimits);
|
||||
|
@ -210,6 +214,20 @@ namespace wgpu::binding {
|
|||
UNIMPLEMENTED("required: ", required);
|
||||
}
|
||||
|
||||
wgpu::RequiredLimits limits;
|
||||
#define COPY_LIMIT(LIMIT) \
|
||||
if (descriptor.requiredLimits.count(#LIMIT)) { \
|
||||
limits.limits.LIMIT = descriptor.requiredLimits[#LIMIT]; \
|
||||
descriptor.requiredLimits.erase(#LIMIT); \
|
||||
}
|
||||
FOR_EACH_LIMIT(COPY_LIMIT)
|
||||
#undef COPY_LIMIT
|
||||
|
||||
for (auto [key, _] : descriptor.requiredLimits) {
|
||||
promise.Reject(binding::Errors::OperationError(env, "Unknown limit \"" + key + "\""));
|
||||
return promise;
|
||||
}
|
||||
|
||||
// Propogate enabled/disabled dawn features
|
||||
// Note: DawnDeviceTogglesDescriptor::forceEnabledToggles and forceDisabledToggles are
|
||||
// vectors of 'const char*', so we make sure the parsed strings survive the CreateDevice()
|
||||
|
@ -233,6 +251,7 @@ namespace wgpu::binding {
|
|||
|
||||
desc.requiredFeaturesCount = requiredFeatures.size();
|
||||
desc.requiredFeatures = requiredFeatures.data();
|
||||
desc.requiredLimits = &limits;
|
||||
|
||||
DawnTogglesDeviceDescriptor togglesDesc = {};
|
||||
desc.nextInChain = &togglesDesc;
|
||||
|
@ -245,7 +264,7 @@ namespace wgpu::binding {
|
|||
if (wgpu_device) {
|
||||
promise.Resolve(interop::GPUDevice::Create<GPUDevice>(env, env, wgpu_device));
|
||||
} else {
|
||||
Napi::Error::New(env, "failed to create device").ThrowAsJavaScriptException();
|
||||
promise.Reject(binding::Errors::OperationError(env, "failed to create device"));
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue