Improving Metal backend validation messages.
Improves validation messages in various Metal backend files: - SamplerMTL.mm - ShaderModuleMTL.mm - SwapChainMTL.mm - TextureMTL.mm Bug: dawn:563 Change-Id: I076c08bb3dbecc430d5d4d7fbfeea48166070688 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/67320 Commit-Queue: Brandon Jones <bajones@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
1ca2dd6fb6
commit
eb0d900506
|
@ -53,10 +53,12 @@ namespace dawn_native { namespace metal {
|
||||||
// static
|
// static
|
||||||
ResultOrError<Ref<Sampler>> Sampler::Create(Device* device,
|
ResultOrError<Ref<Sampler>> Sampler::Create(Device* device,
|
||||||
const SamplerDescriptor* descriptor) {
|
const SamplerDescriptor* descriptor) {
|
||||||
if (descriptor->compare != wgpu::CompareFunction::Undefined &&
|
DAWN_INVALID_IF(
|
||||||
device->IsToggleEnabled(Toggle::MetalDisableSamplerCompare)) {
|
descriptor->compare != wgpu::CompareFunction::Undefined &&
|
||||||
return DAWN_VALIDATION_ERROR("Sampler compare function not supported.");
|
device->IsToggleEnabled(Toggle::MetalDisableSamplerCompare),
|
||||||
}
|
"Sampler compare function (%s) not supported. Compare functions are disabled with the "
|
||||||
|
"Metal backend.",
|
||||||
|
descriptor->compare);
|
||||||
|
|
||||||
Ref<Sampler> sampler = AcquireRef(new Sampler(device, descriptor));
|
Ref<Sampler> sampler = AcquireRef(new Sampler(device, descriptor));
|
||||||
DAWN_TRY(sampler->Initialize(descriptor));
|
DAWN_TRY(sampler->Initialize(descriptor));
|
||||||
|
|
|
@ -143,14 +143,13 @@ namespace dawn_native { namespace metal {
|
||||||
if (it != data->remappings.end()) {
|
if (it != data->remappings.end()) {
|
||||||
*remappedEntryPointName = it->second;
|
*remappedEntryPointName = it->second;
|
||||||
} else {
|
} else {
|
||||||
if (GetDevice()->IsToggleEnabled(Toggle::DisableSymbolRenaming)) {
|
DAWN_INVALID_IF(!GetDevice()->IsToggleEnabled(Toggle::DisableSymbolRenaming),
|
||||||
*remappedEntryPointName = entryPointName;
|
"Could not find remapped name for entry point.");
|
||||||
} else {
|
|
||||||
return DAWN_VALIDATION_ERROR("Could not find remapped name for entry point.");
|
*remappedEntryPointName = entryPointName;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return DAWN_VALIDATION_ERROR("Transform output missing renamer data.");
|
return DAWN_FORMAT_VALIDATION_ERROR("Transform output missing renamer data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
tint::writer::msl::Options options;
|
tint::writer::msl::Options options;
|
||||||
|
@ -161,10 +160,8 @@ namespace dawn_native { namespace metal {
|
||||||
stage == SingleShaderStage::Vertex &&
|
stage == SingleShaderStage::Vertex &&
|
||||||
renderPipeline->GetPrimitiveTopology() == wgpu::PrimitiveTopology::PointList;
|
renderPipeline->GetPrimitiveTopology() == wgpu::PrimitiveTopology::PointList;
|
||||||
auto result = tint::writer::msl::Generate(&program, options);
|
auto result = tint::writer::msl::Generate(&program, options);
|
||||||
if (!result.success) {
|
DAWN_INVALID_IF(!result.success, "An error occured while generating MSL: %s.",
|
||||||
errorStream << "Generator: " << result.error << std::endl;
|
result.error);
|
||||||
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
*needsStorageBufferLength = result.needs_storage_buffer_sizes;
|
*needsStorageBufferLength = result.needs_storage_buffer_sizes;
|
||||||
*hasInvariantAttribute = result.has_invariant_attribute;
|
*hasInvariantAttribute = result.has_invariant_attribute;
|
||||||
|
@ -226,10 +223,9 @@ namespace dawn_native { namespace metal {
|
||||||
options:compileOptions.Get()
|
options:compileOptions.Get()
|
||||||
error:&error]);
|
error:&error]);
|
||||||
if (error != nullptr) {
|
if (error != nullptr) {
|
||||||
if (error.code != MTLLibraryErrorCompileWarning) {
|
DAWN_INVALID_IF(error.code != MTLLibraryErrorCompileWarning,
|
||||||
return DAWN_VALIDATION_ERROR(std::string("Unable to create library object: ") +
|
"Unable to create library object: %s.",
|
||||||
[error.localizedDescription UTF8String]);
|
[error.localizedDescription UTF8String]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ASSERT(library != nil);
|
ASSERT(library != nil);
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ namespace dawn_native { namespace metal {
|
||||||
// TODO(crbug.com/dawn/269): figure out what should happen when surfaces are used by
|
// TODO(crbug.com/dawn/269): figure out what should happen when surfaces are used by
|
||||||
// multiple backends one after the other. It probably needs to block until the backend
|
// multiple backends one after the other. It probably needs to block until the backend
|
||||||
// and GPU are completely finished with the previous swapchain.
|
// and GPU are completely finished with the previous swapchain.
|
||||||
if (previousSwapChain->GetBackendType() != wgpu::BackendType::Metal) {
|
DAWN_INVALID_IF(previousSwapChain->GetBackendType() != wgpu::BackendType::Metal,
|
||||||
return DAWN_VALIDATION_ERROR("metal::SwapChain cannot switch between APIs");
|
"Metal SwapChain cannot switch backend types from %s to %s.",
|
||||||
}
|
previousSwapChain->GetBackendType(), wgpu::BackendType::Metal);
|
||||||
|
|
||||||
previousSwapChain->DetachFromSurface();
|
previousSwapChain->DetachFromSurface();
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,8 @@ namespace dawn_native { namespace metal {
|
||||||
case kCVPixelFormatType_OneComponent8:
|
case kCVPixelFormatType_OneComponent8:
|
||||||
return wgpu::TextureFormat::R8Unorm;
|
return wgpu::TextureFormat::R8Unorm;
|
||||||
default:
|
default:
|
||||||
return DAWN_VALIDATION_ERROR("Unsupported IOSurface format");
|
return DAWN_FORMAT_VALIDATION_ERROR("Unsupported IOSurface format (%x).",
|
||||||
|
format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,38 +328,38 @@ namespace dawn_native { namespace metal {
|
||||||
// IOSurfaceGetPlaneCount can return 0 for non-planar IOSurfaces but we will treat
|
// IOSurfaceGetPlaneCount can return 0 for non-planar IOSurfaces but we will treat
|
||||||
// non-planar like it is a single plane.
|
// non-planar like it is a single plane.
|
||||||
size_t surfacePlaneCount = std::max(size_t(1), IOSurfaceGetPlaneCount(ioSurface));
|
size_t surfacePlaneCount = std::max(size_t(1), IOSurfaceGetPlaneCount(ioSurface));
|
||||||
if (plane >= surfacePlaneCount) {
|
DAWN_INVALID_IF(plane >= surfacePlaneCount,
|
||||||
return DAWN_VALIDATION_ERROR("IOSurface plane doesn't exist");
|
"IOSurface plane (%u) exceeds the surface's plane count (%u).", plane,
|
||||||
}
|
surfacePlaneCount);
|
||||||
|
|
||||||
if (descriptor->dimension != wgpu::TextureDimension::e2D) {
|
DAWN_INVALID_IF(descriptor->dimension != wgpu::TextureDimension::e2D,
|
||||||
return DAWN_VALIDATION_ERROR("IOSurface texture must be 2D");
|
"Texture dimension (%s) is not %s.", descriptor->dimension,
|
||||||
}
|
wgpu::TextureDimension::e2D);
|
||||||
|
|
||||||
if (descriptor->mipLevelCount != 1) {
|
DAWN_INVALID_IF(descriptor->mipLevelCount != 1, "Mip level count (%u) is not 1.",
|
||||||
return DAWN_VALIDATION_ERROR("IOSurface mip level count must be 1");
|
descriptor->mipLevelCount);
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor->size.depthOrArrayLayers != 1) {
|
DAWN_INVALID_IF(descriptor->size.depthOrArrayLayers != 1,
|
||||||
return DAWN_VALIDATION_ERROR("IOSurface array layer count must be 1");
|
"Array layer count (%u) is not 1.", descriptor->size.depthOrArrayLayers);
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor->sampleCount != 1) {
|
DAWN_INVALID_IF(descriptor->sampleCount != 1, "Sample count (%u) is not 1.",
|
||||||
return DAWN_VALIDATION_ERROR("IOSurface sample count must be 1");
|
descriptor->sampleCount);
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptor->size.width != IOSurfaceGetWidthOfPlane(ioSurface, plane) ||
|
uint32_t surfaceWidth = IOSurfaceGetWidthOfPlane(ioSurface, plane);
|
||||||
descriptor->size.height != IOSurfaceGetHeightOfPlane(ioSurface, plane) ||
|
uint32_t surfaceHeight = IOSurfaceGetHeightOfPlane(ioSurface, plane);
|
||||||
descriptor->size.depthOrArrayLayers != 1) {
|
|
||||||
return DAWN_VALIDATION_ERROR("IOSurface size doesn't match descriptor");
|
DAWN_INVALID_IF(
|
||||||
}
|
descriptor->size.width != surfaceWidth || descriptor->size.height != surfaceHeight ||
|
||||||
|
descriptor->size.depthOrArrayLayers != 1,
|
||||||
|
"IOSurface size (width: %u, height %u, depth: 1) doesn't match descriptor size %s.",
|
||||||
|
surfaceWidth, surfaceHeight, &descriptor->size);
|
||||||
|
|
||||||
wgpu::TextureFormat ioSurfaceFormat;
|
wgpu::TextureFormat ioSurfaceFormat;
|
||||||
DAWN_TRY_ASSIGN(ioSurfaceFormat,
|
DAWN_TRY_ASSIGN(ioSurfaceFormat,
|
||||||
GetFormatEquivalentToIOSurfaceFormat(IOSurfaceGetPixelFormat(ioSurface)));
|
GetFormatEquivalentToIOSurfaceFormat(IOSurfaceGetPixelFormat(ioSurface)));
|
||||||
if (descriptor->format != ioSurfaceFormat) {
|
DAWN_INVALID_IF(descriptor->format != ioSurfaceFormat,
|
||||||
return DAWN_VALIDATION_ERROR("IOSurface format doesn't match descriptor");
|
"IOSurface format (%s) doesn't match the descriptor format (%s).",
|
||||||
}
|
ioSurfaceFormat, descriptor->format);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue