Branch
Hash :
5325904b
Author :
Date :
2025-01-29T14:43:35
Metal: Simplify error checking Use normal ANGLE_CHECK, ANGLE_CHECK_GL_ALLOC, ANGLE_CHECK_GL_MATH when appropriate. Use ANGLE_MTL_CHECK for checking Metal NSError return value. Remove mtl::ErrorHandler::handleError variant that responds to NSError. Uses "Internal error." that occur due to implementation bugs. Binary size is already expended with __FILE__ et al to disambiguate the location. The descriptions were not actionable for the API client and sometimes wrong cut-and-paste. Bug: angleproject:392938089 Change-Id: If9525d3d1610d5bc757855053600d78d2a1526c3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6211841 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// mtl_common.mm:
// Implementation of mtl::Context, the MTLDevice container & error handler class.
//
#include "libANGLE/renderer/metal/mtl_common.h"
#include <dispatch/dispatch.h>
#include <cstring>
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/metal/DisplayMtl.h"
namespace rx
{
namespace mtl
{
// ClearColorValue implementation
ClearColorValue &ClearColorValue::operator=(const ClearColorValue &src)
{
mType = src.mType;
mValueBytes = src.mValueBytes;
return *this;
}
void ClearColorValue::setAsFloat(float r, float g, float b, float a)
{
mType = PixelType::Float;
mRedF = r;
mGreenF = g;
mBlueF = b;
mAlphaF = a;
}
void ClearColorValue::setAsInt(int32_t r, int32_t g, int32_t b, int32_t a)
{
mType = PixelType::Int;
mRedI = r;
mGreenI = g;
mBlueI = b;
mAlphaI = a;
}
void ClearColorValue::setAsUInt(uint32_t r, uint32_t g, uint32_t b, uint32_t a)
{
mType = PixelType::UInt;
mRedU = r;
mGreenU = g;
mBlueU = b;
mAlphaU = a;
}
MTLClearColor ClearColorValue::toMTLClearColor() const
{
switch (mType)
{
case PixelType::Int:
return MTLClearColorMake(mRedI, mGreenI, mBlueI, mAlphaI);
case PixelType::UInt:
return MTLClearColorMake(mRedU, mGreenU, mBlueU, mAlphaU);
case PixelType::Float:
return MTLClearColorMake(mRedF, mGreenF, mBlueF, mAlphaF);
default:
UNREACHABLE();
return MTLClearColorMake(0, 0, 0, 0);
}
}
// ImageNativeIndex implementation
ImageNativeIndexIterator ImageNativeIndex::getLayerIterator(GLint layerCount) const
{
return ImageNativeIndexIterator(mNativeIndex.getLayerIterator(layerCount));
}
// Context implementation
Context::Context(DisplayMtl *display) : mDisplay(display) {}
mtl::CommandQueue &Context::cmdQueue()
{
return mDisplay->cmdQueue();
}
} // namespace mtl
} // namespace rx