Hash :
6ddbfa39
Author :
Date :
2022-05-09T09:06:16
Metal: Log the shader source when a shader fails to translate Refactor Metal logging to include a message string. Bug: chromium:1322521 Change-Id: I3a7b5c36fcf140b3664ad96a9da924819326bf94 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3634725 Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kenneth Russell <kbr@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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
//
// 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();
}
std::string FormatMetalErrorMessage(GLenum errorCode)
{
return "Metal backend encountered an error";
}
std::string FormatMetalErrorMessage(NSError *error)
{
if (!error)
{
return "";
}
std::stringstream errorStream;
errorStream << "Metal backend encountered an error: \n"
<< error.localizedDescription.UTF8String;
return errorStream.str();
}
} // namespace mtl
} // namespace rx