Commit d200a77a by Le Quyen Committed by Commit Bot

Metal backend skeleton implementation.

Bug: angleproject:2634 Change-Id: I34be82f4a80a6851fecb53a51e069b134d82613a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1849079 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent aa292a59
...@@ -419,11 +419,20 @@ angle_static_library("translator") { ...@@ -419,11 +419,20 @@ angle_static_library("translator") {
defines += [ "ANGLE_ENABLE_HLSL" ] defines += [ "ANGLE_ENABLE_HLSL" ]
} }
if (angle_enable_vulkan || use_fuzzing_engine) { if (angle_enable_vulkan || use_fuzzing_engine || angle_enable_metal) {
# This translator is needed by metal backend also.
sources += angle_translator_lib_vulkan_sources sources += angle_translator_lib_vulkan_sources
}
if (angle_enable_vulkan || use_fuzzing_engine) {
defines += [ "ANGLE_ENABLE_VULKAN" ] defines += [ "ANGLE_ENABLE_VULKAN" ]
} }
if (angle_enable_metal) {
sources += angle_translator_lib_metal_sources
defines += [ "ANGLE_ENABLE_METAL" ]
}
public_configs += [ ":external_config" ] public_configs += [ ":external_config" ]
deps = [ deps = [
...@@ -524,6 +533,10 @@ config("angle_backend_config") { ...@@ -524,6 +533,10 @@ config("angle_backend_config") {
defines += [ "ANGLE_ENABLE_NULL" ] defines += [ "ANGLE_ENABLE_NULL" ]
} }
if (angle_enable_metal) {
configs = [ "src/libANGLE/renderer/metal:angle_metal_backend_config" ]
}
if (angle_enable_vulkan) { if (angle_enable_vulkan) {
configs = [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend_config" ] configs = [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend_config" ]
} }
...@@ -592,6 +605,10 @@ angle_source_set("libANGLE_base") { ...@@ -592,6 +605,10 @@ angle_source_set("libANGLE_base") {
public_deps += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend" ] public_deps += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend" ]
} }
if (angle_enable_metal) {
public_deps += [ "src/libANGLE/renderer/metal:angle_metal_backend" ]
}
# Enable extra Chromium style warnings for libANGLE. # Enable extra Chromium style warnings for libANGLE.
if (is_clang) { if (is_clang) {
suppressed_configs -= [ "//build/config/clang:find_bad_constructs" ] suppressed_configs -= [ "//build/config/clang:find_bad_constructs" ]
......
...@@ -93,6 +93,9 @@ declare_args() { ...@@ -93,6 +93,9 @@ declare_args() {
angle_enable_null = true angle_enable_null = true
angle_enable_essl = true angle_enable_essl = true
angle_enable_glsl = true angle_enable_glsl = true
# http://anglebug.com/2634
angle_enable_metal = is_mac
} }
declare_args() { declare_args() {
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
// Version number for shader translation API. // Version number for shader translation API.
// It is incremented every time the API changes. // It is incremented every time the API changes.
#define ANGLE_SH_VERSION 216 #define ANGLE_SH_VERSION 217
enum ShShaderSpec enum ShShaderSpec
{ {
...@@ -69,6 +69,10 @@ enum ShShaderOutput ...@@ -69,6 +69,10 @@ enum ShShaderOutput
// Output specialized GLSL to be fed to glslang for Vulkan SPIR. // Output specialized GLSL to be fed to glslang for Vulkan SPIR.
SH_GLSL_VULKAN_OUTPUT = 0x8B4B, SH_GLSL_VULKAN_OUTPUT = 0x8B4B,
// Output specialized GLSL to be fed to glslang for Vulkan SPIR to be cross compiled to Metal
// later.
SH_GLSL_METAL_OUTPUT = 0x8B4C,
}; };
// Compile options. // Compile options.
......
...@@ -175,6 +175,7 @@ IGNORED_INCLUDES = { ...@@ -175,6 +175,7 @@ IGNORED_INCLUDES = {
b'compiler/translator/TranslatorESSL.h', b'compiler/translator/TranslatorESSL.h',
b'compiler/translator/TranslatorGLSL.h', b'compiler/translator/TranslatorGLSL.h',
b'compiler/translator/TranslatorHLSL.h', b'compiler/translator/TranslatorHLSL.h',
b'compiler/translator/TranslatorMetal.h',
b'compiler/translator/TranslatorVulkan.h', b'compiler/translator/TranslatorVulkan.h',
b'libANGLE/renderer/d3d/DeviceD3D.h', b'libANGLE/renderer/d3d/DeviceD3D.h',
b'libANGLE/renderer/d3d/DisplayD3D.h', b'libANGLE/renderer/d3d/DisplayD3D.h',
...@@ -185,6 +186,7 @@ IGNORED_INCLUDES = { ...@@ -185,6 +186,7 @@ IGNORED_INCLUDES = {
b'libANGLE/renderer/gl/egl/ozone/DisplayOzone.h', b'libANGLE/renderer/gl/egl/ozone/DisplayOzone.h',
b'libANGLE/renderer/gl/egl/android/DisplayAndroid.h', b'libANGLE/renderer/gl/egl/android/DisplayAndroid.h',
b'libANGLE/renderer/gl/wgl/DisplayWGL.h', b'libANGLE/renderer/gl/wgl/DisplayWGL.h',
b'libANGLE/renderer/metal/DisplayMtl.h',
b'libANGLE/renderer/null/DisplayNULL.h', b'libANGLE/renderer/null/DisplayNULL.h',
b'libANGLE/renderer/vulkan/android/DisplayVkAndroid.h', b'libANGLE/renderer/vulkan/android/DisplayVkAndroid.h',
b'libANGLE/renderer/vulkan/fuchsia/DisplayVkFuchsia.h', b'libANGLE/renderer/vulkan/fuchsia/DisplayVkFuchsia.h',
......
...@@ -455,12 +455,12 @@ inline float float10ToFloat32(unsigned short fp11) ...@@ -455,12 +455,12 @@ inline float float10ToFloat32(unsigned short fp11)
// Convers to and from float and 16.16 fixed point format. // Convers to and from float and 16.16 fixed point format.
inline float FixedToFloat(uint32_t fixedInput) inline float ConvertFixedToFloat(uint32_t fixedInput)
{ {
return static_cast<float>(fixedInput) / 65536.0f; return static_cast<float>(fixedInput) / 65536.0f;
} }
inline uint32_t FloatToFixed(float floatInput) inline uint32_t ConvertFloatToFixed(float floatInput)
{ {
static constexpr uint32_t kHighest = 32767 * 65536 + 65535; static constexpr uint32_t kHighest = 32767 * 65536 + 65535;
static constexpr uint32_t kLowest = static_cast<uint32_t>(-32768 * 65536 + 65535); static constexpr uint32_t kLowest = static_cast<uint32_t>(-32768 * 65536 + 65535);
......
...@@ -310,6 +310,14 @@ if (is_android) { ...@@ -310,6 +310,14 @@ if (is_android) {
"src/compiler/translator/SymbolTable_autogen.cpp", "src/compiler/translator/SymbolTable_autogen.cpp",
] ]
} }
angle_translator_lib_metal_sources = [
"src/compiler/translator/OutputVulkanGLSLForMetal.mm",
"src/compiler/translator/OutputVulkanGLSLForMetal.h",
"src/compiler/translator/TranslatorMetal.cpp",
"src/compiler/translator/TranslatorMetal.h",
]
angle_preprocessor_sources = [ angle_preprocessor_sources = [
"src/compiler/preprocessor/DiagnosticsBase.cpp", "src/compiler/preprocessor/DiagnosticsBase.cpp",
"src/compiler/preprocessor/DiagnosticsBase.h", "src/compiler/preprocessor/DiagnosticsBase.h",
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
# include "compiler/translator/TranslatorVulkan.h" # include "compiler/translator/TranslatorVulkan.h"
#endif // ANGLE_ENABLE_VULKAN #endif // ANGLE_ENABLE_VULKAN
#ifdef ANGLE_ENABLE_METAL
# include "compiler/translator/TranslatorMetal.h"
#endif // ANGLE_ENABLE_METAL
#include "compiler/translator/util.h" #include "compiler/translator/util.h"
namespace sh namespace sh
...@@ -60,6 +64,13 @@ TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput ...@@ -60,6 +64,13 @@ TCompiler *ConstructCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput
} }
#endif // ANGLE_ENABLE_VULKAN #endif // ANGLE_ENABLE_VULKAN
#ifdef ANGLE_ENABLE_METAL
if (IsOutputMetal(output))
{
return new TranslatorMetal(type, spec);
}
#endif // ANGLE_ENABLE_METAL
// Unsupported compiler or unknown format. Return nullptr per the sh::ConstructCompiler API. // Unsupported compiler or unknown format. Return nullptr per the sh::ConstructCompiler API.
return nullptr; return nullptr;
} }
......
//
// Copyright (c) 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.
//
// TOutputVulkanGLSLForMetal:
// This is a special version Vulkan GLSL output that will make some special
// considerations for Metal backend limitations.
//
#include "compiler/translator/OutputVulkanGLSL.h"
namespace sh
{
class TOutputVulkanGLSLForMetal : public TOutputVulkanGLSL
{
public:
TOutputVulkanGLSLForMetal(TInfoSinkBase &objSink,
ShArrayIndexClampingStrategy clampingStrategy,
ShHashFunction64 hashFunction,
NameMap &nameMap,
TSymbolTable *symbolTable,
sh::GLenum shaderType,
int shaderVersion,
ShShaderOutput output,
ShCompileOptions compileOptions);
};
} // namespace sh
\ No newline at end of file
//
// Copyright (c) 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.
//
// TOutputVulkanGLSLForMetal:
// This is a special version Vulkan GLSL output that will make some special
// considerations for Metal backend limitations.
//
#include "compiler/translator/OutputVulkanGLSLForMetal.h"
#include "common/debug.h"
namespace sh
{
TOutputVulkanGLSLForMetal::TOutputVulkanGLSLForMetal(TInfoSinkBase &objSink,
ShArrayIndexClampingStrategy clampingStrategy,
ShHashFunction64 hashFunction,
NameMap &nameMap,
TSymbolTable *symbolTable,
sh::GLenum shaderType,
int shaderVersion,
ShShaderOutput output,
ShCompileOptions compileOptions)
: TOutputVulkanGLSL(objSink,
clampingStrategy,
hashFunction,
nameMap,
symbolTable,
shaderType,
shaderVersion,
output,
compileOptions)
{
UNIMPLEMENTED();
}
} // namespace sh
//
// Copyright (c) 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.
//
// TranslatorMetal:
// Translator for Metal backend.
//
#include "compiler/translator/TranslatorMetal.h"
#include "common/debug.h"
#include "compiler/translator/OutputVulkanGLSLForMetal.h"
namespace sh
{
TranslatorMetal::TranslatorMetal(sh::GLenum type, ShShaderSpec spec)
: TCompiler(type, spec, SH_GLSL_450_CORE_OUTPUT)
{}
bool TranslatorMetal::translate(TIntermBlock *root,
ShCompileOptions compileOptions,
PerformanceDiagnostics * /*perfDiagnostics*/)
{
TInfoSinkBase &sink = getInfoSink().obj;
TOutputVulkanGLSLForMetal outputGLSL(sink, getArrayIndexClampingStrategy(), getHashFunction(),
getNameMap(), &getSymbolTable(), getShaderType(),
getShaderVersion(), getOutputType(), compileOptions);
UNIMPLEMENTED();
root->traverse(&outputGLSL);
return false;
}
bool TranslatorMetal::shouldFlattenPragmaStdglInvariantAll()
{
UNIMPLEMENTED();
return false;
}
} // namespace sh
//
// Copyright (c) 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.
//
// TranslatorMetal:
// Translator for Metal backend.
//
#ifndef LIBANGLE_RENDERER_METAL_TRANSLATORMETAL_H_
#define LIBANGLE_RENDERER_METAL_TRANSLATORMETAL_H_
#include "compiler/translator/Compiler.h"
namespace sh
{
class TranslatorMetal : public TCompiler
{
public:
TranslatorMetal(sh::GLenum type, ShShaderSpec spec);
protected:
ANGLE_NO_DISCARD bool translate(TIntermBlock *root,
ShCompileOptions compileOptions,
PerformanceDiagnostics *perfDiagnostics) override;
bool shouldFlattenPragmaStdglInvariantAll() override;
};
} // namespace sh
#endif /* LIBANGLE_RENDERER_METAL_TRANSLATORMETAL_H_ */
...@@ -757,6 +757,10 @@ bool IsOutputVulkan(ShShaderOutput output) ...@@ -757,6 +757,10 @@ bool IsOutputVulkan(ShShaderOutput output)
{ {
return output == SH_GLSL_VULKAN_OUTPUT; return output == SH_GLSL_VULKAN_OUTPUT;
} }
bool IsOutputMetal(ShShaderOutput output)
{
return output == SH_GLSL_METAL_OUTPUT;
}
bool IsInShaderStorageBlock(TIntermTyped *node) bool IsInShaderStorageBlock(TIntermTyped *node)
{ {
......
...@@ -76,6 +76,7 @@ bool IsOutputESSL(ShShaderOutput output); ...@@ -76,6 +76,7 @@ bool IsOutputESSL(ShShaderOutput output);
bool IsOutputGLSL(ShShaderOutput output); bool IsOutputGLSL(ShShaderOutput output);
bool IsOutputHLSL(ShShaderOutput output); bool IsOutputHLSL(ShShaderOutput output);
bool IsOutputVulkan(ShShaderOutput output); bool IsOutputVulkan(ShShaderOutput output);
bool IsOutputMetal(ShShaderOutput output);
bool IsInShaderStorageBlock(TIntermTyped *node); bool IsInShaderStorageBlock(TIntermTyped *node);
......
...@@ -81,6 +81,10 @@ ...@@ -81,6 +81,10 @@
# endif # endif
#endif // defined(ANGLE_ENABLE_VULKAN) #endif // defined(ANGLE_ENABLE_VULKAN)
#if defined(ANGLE_ENABLE_METAL)
# include "libANGLE/renderer/metal/DisplayMtl.h"
#endif // defined(ANGLE_ENABLE_METAL)
namespace egl namespace egl
{ {
...@@ -178,6 +182,14 @@ EGLAttrib GetDisplayTypeFromEnvironment() ...@@ -178,6 +182,14 @@ EGLAttrib GetDisplayTypeFromEnvironment()
} }
#endif #endif
#if defined(ANGLE_ENABLE_METAL)
if (rx::DisplayMtl::IsMetalAvailable())
{
return EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE;
}
// else fallthrough to below
#endif
#if defined(ANGLE_ENABLE_D3D11) #if defined(ANGLE_ENABLE_D3D11)
return EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE; return EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE;
#elif defined(ANGLE_ENABLE_D3D9) #elif defined(ANGLE_ENABLE_D3D9)
...@@ -284,7 +296,17 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap, const D ...@@ -284,7 +296,17 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap, const D
UNREACHABLE(); UNREACHABLE();
#endif // defined(ANGLE_ENABLE_VULKAN) #endif // defined(ANGLE_ENABLE_VULKAN)
break; break;
case EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE:
#if defined(ANGLE_ENABLE_METAL)
if (rx::DisplayMtl::IsMetalAvailable())
{
impl = new rx::DisplayMtl(state);
break;
}
#endif
// No display available
UNREACHABLE();
break;
case EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE: case EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE:
#if defined(ANGLE_ENABLE_NULL) #if defined(ANGLE_ENABLE_NULL)
impl = new rx::DisplayNULL(state); impl = new rx::DisplayNULL(state);
...@@ -1251,6 +1273,10 @@ static ClientExtensions GenerateClientExtensions() ...@@ -1251,6 +1273,10 @@ static ClientExtensions GenerateClientExtensions()
extensions.platformANGLEDeviceTypeSwiftShader = true; extensions.platformANGLEDeviceTypeSwiftShader = true;
#endif #endif
#if defined(ANGLE_ENABLE_METAL)
extensions.platformANGLEMetal = true;
#endif
#if defined(ANGLE_USE_X11) #if defined(ANGLE_USE_X11)
extensions.x11Visual = true; extensions.x11Visual = true;
#endif #endif
......
...@@ -2430,12 +2430,12 @@ void ConvertTextureEnvFromFixed(TextureEnvParameter pname, const GLfixed *input, ...@@ -2430,12 +2430,12 @@ void ConvertTextureEnvFromFixed(TextureEnvParameter pname, const GLfixed *input,
{ {
case TextureEnvParameter::RgbScale: case TextureEnvParameter::RgbScale:
case TextureEnvParameter::AlphaScale: case TextureEnvParameter::AlphaScale:
output[0] = FixedToFloat(input[0]); output[0] = ConvertFixedToFloat(input[0]);
break; break;
case TextureEnvParameter::Color: case TextureEnvParameter::Color:
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
output[i] = FixedToFloat(input[i]); output[i] = ConvertFixedToFloat(input[i]);
} }
break; break;
default: default:
...@@ -2482,12 +2482,12 @@ void ConvertTextureEnvToFixed(TextureEnvParameter pname, const GLfloat *input, G ...@@ -2482,12 +2482,12 @@ void ConvertTextureEnvToFixed(TextureEnvParameter pname, const GLfloat *input, G
{ {
case TextureEnvParameter::RgbScale: case TextureEnvParameter::RgbScale:
case TextureEnvParameter::AlphaScale: case TextureEnvParameter::AlphaScale:
output[0] = FloatToFixed(input[0]); output[0] = ConvertFloatToFixed(input[0]);
break; break;
case TextureEnvParameter::Color: case TextureEnvParameter::Color:
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
output[i] = FloatToFixed(input[i]); output[i] = ConvertFloatToFixed(input[i]);
} }
break; break;
default: default:
......
# 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.
#
# This file houses the build configuration for the ANGLE Metal back-end.
import("../../../../gni/angle.gni")
assert(angle_enable_metal)
_metal_backend_sources = [
"BufferMtl.h",
"BufferMtl.mm",
"CompilerMtl.h",
"CompilerMtl.mm",
"ContextMtl.h",
"ContextMtl.mm",
"DisplayMtl.h",
"DisplayMtl.mm",
"FrameBufferMtl.h",
"FrameBufferMtl.mm",
"ProgramMtl.h",
"ProgramMtl.mm",
"RenderBufferMtl.h",
"RenderBufferMtl.mm",
"RendererMtl.h",
"RendererMtl.mm",
"ShaderMtl.h",
"ShaderMtl.mm",
"SurfaceMtl.h",
"SurfaceMtl.mm",
"TextureMtl.h",
"TextureMtl.mm",
"VertexArrayMtl.h",
"VertexArrayMtl.mm",
"mtl_common.h",
"mtl_common.mm",
]
config("angle_metal_backend_config") {
defines = [ "ANGLE_ENABLE_METAL" ]
}
angle_source_set("angle_metal_backend") {
public_configs = [ ":angle_metal_backend_config" ]
sources = _metal_backend_sources
cflags = []
cflags_cc = []
cflags_objc = []
cflags_objcc = []
ldflags = []
libs = []
public_deps = [
"${angle_root}:libANGLE_headers",
]
objc_flags = [
"-Wno-nullability-completeness",
"-Wno-unguarded-availability",
"-fno-objc-arc",
]
cflags_objc += objc_flags
cflags_objcc += objc_flags
libs += [ "Metal.framework" ]
if (is_mac) {
libs += [
"Cocoa.framework",
"IOSurface.framework",
"QuartzCore.framework",
]
}
# TODO(hqle): iOS support.
}
//
// 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.
//
// BufferMtl.h:
// Defines the class interface for BufferMtl, implementing BufferImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_BUFFERMTL_H_
#define LIBANGLE_RENDERER_METAL_BUFFERMTL_H_
#import <Metal/Metal.h>
#include <utility>
#include "libANGLE/Buffer.h"
#include "libANGLE/Observer.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/BufferImpl.h"
namespace rx
{
class BufferMtl : public BufferImpl
{
public:
BufferMtl(const gl::BufferState &state);
~BufferMtl() override;
void destroy(const gl::Context *context) override;
angle::Result setData(const gl::Context *context,
gl::BufferBinding target,
const void *data,
size_t size,
gl::BufferUsage usage) override;
angle::Result setSubData(const gl::Context *context,
gl::BufferBinding target,
const void *data,
size_t size,
size_t offset) override;
angle::Result copySubData(const gl::Context *context,
BufferImpl *source,
GLintptr sourceOffset,
GLintptr destOffset,
GLsizeiptr size) override;
angle::Result map(const gl::Context *context, GLenum access, void **mapPtr) override;
angle::Result mapRange(const gl::Context *context,
size_t offset,
size_t length,
GLbitfield access,
void **mapPtr) override;
angle::Result unmap(const gl::Context *context, GLboolean *result) override;
angle::Result getIndexRange(const gl::Context *context,
gl::DrawElementsType type,
size_t offset,
size_t count,
bool primitiveRestartEnabled,
gl::IndexRange *outRange) override;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_BUFFERMTL_H_ */
//
// 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.
//
// BufferMtl.mm:
// Implements the class methods for BufferMtl.
//
#include "libANGLE/renderer/metal/BufferMtl.h"
namespace rx
{
// BufferMtl implementation
BufferMtl::BufferMtl(const gl::BufferState &state) : BufferImpl(state)
{
UNIMPLEMENTED();
}
BufferMtl::~BufferMtl() {}
void BufferMtl::destroy(const gl::Context *context)
{
UNIMPLEMENTED();
}
angle::Result BufferMtl::setData(const gl::Context *context,
gl::BufferBinding target,
const void *data,
size_t size,
gl::BufferUsage usage)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result BufferMtl::setSubData(const gl::Context *context,
gl::BufferBinding target,
const void *data,
size_t size,
size_t offset)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result BufferMtl::copySubData(const gl::Context *context,
BufferImpl *source,
GLintptr sourceOffset,
GLintptr destOffset,
GLsizeiptr size)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result BufferMtl::map(const gl::Context *context, GLenum access, void **mapPtr)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result BufferMtl::mapRange(const gl::Context *context,
size_t offset,
size_t length,
GLbitfield access,
void **mapPtr)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result BufferMtl::unmap(const gl::Context *context, GLboolean *result)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result BufferMtl::getIndexRange(const gl::Context *context,
gl::DrawElementsType type,
size_t offset,
size_t count,
bool primitiveRestartEnabled,
gl::IndexRange *outRange)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
} // namespace rx
//
// 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.
//
// CompilerMtl.h:
// Defines the class interface for CompilerMtl, implementing CompilerImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_COMPILERMTL_H_
#define LIBANGLE_RENDERER_METAL_COMPILERMTL_H_
#include "libANGLE/renderer/CompilerImpl.h"
namespace rx
{
class CompilerMtl : public CompilerImpl
{
public:
CompilerMtl();
~CompilerMtl() override;
ShShaderOutput getTranslatorOutputType() const override;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_COMPILERMTL_H_ */
//
// 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.
//
// CompilerMtl.mm:
// Implements the class methods for CompilerMtl.
//
#include "libANGLE/renderer/metal/CompilerMtl.h"
#include "common/debug.h"
namespace rx
{
CompilerMtl::CompilerMtl() : CompilerImpl() {}
CompilerMtl::~CompilerMtl() {}
ShShaderOutput CompilerMtl::getTranslatorOutputType() const
{
return SH_GLSL_METAL_OUTPUT;
}
} // namespace rx
\ No newline at end of file
//
// 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.
//
// ContextMtl.h:
// Defines the class interface for ContextMtl, implementing ContextImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_CONTEXTMTL_H_
#define LIBANGLE_RENDERER_METAL_CONTEXTMTL_H_
#import <Metal/Metal.h>
#include "common/Optional.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/metal/mtl_common.h"
namespace rx
{
class RendererMtl;
class FramebufferMtl;
class VertexArrayMtl;
class ProgramMtl;
class ContextMtl : public ContextImpl, public mtl::Context
{
public:
ContextMtl(const gl::State &state, gl::ErrorSet *errorSet, RendererMtl *renderer);
~ContextMtl() override;
angle::Result initialize() override;
void onDestroy(const gl::Context *context) override;
// Flush and finish.
angle::Result flush(const gl::Context *context) override;
angle::Result finish(const gl::Context *context) override;
// Drawing methods.
angle::Result drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count) override;
angle::Result drawArraysInstanced(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count,
GLsizei instanceCount) override;
angle::Result drawArraysInstancedBaseInstance(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count,
GLsizei instanceCount,
GLuint baseInstance) override;
angle::Result drawElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
gl::DrawElementsType type,
const void *indices) override;
angle::Result drawElementsInstanced(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
gl::DrawElementsType type,
const void *indices,
GLsizei instanceCount) override;
angle::Result drawElementsInstancedBaseVertexBaseInstance(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
gl::DrawElementsType type,
const void *indices,
GLsizei instances,
GLint baseVertex,
GLuint baseInstance) override;
angle::Result drawRangeElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLuint start,
GLuint end,
GLsizei count,
gl::DrawElementsType type,
const void *indices) override;
angle::Result drawArraysIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
const void *indirect) override;
angle::Result drawElementsIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
gl::DrawElementsType type,
const void *indirect) override;
// Device loss
gl::GraphicsResetStatus getResetStatus() override;
// Vendor and description strings.
std::string getVendorString() const override;
std::string getRendererDescription() const override;
// EXT_debug_marker
void insertEventMarker(GLsizei length, const char *marker) override;
void pushGroupMarker(GLsizei length, const char *marker) override;
void popGroupMarker() override;
// KHR_debug
void pushDebugGroup(GLenum source, GLuint id, const std::string &message) override;
void popDebugGroup() override;
// State sync with dirty bits.
angle::Result syncState(const gl::Context *context,
const gl::State::DirtyBits &dirtyBits,
const gl::State::DirtyBits &bitMask) override;
// Disjoint timer queries
GLint getGPUDisjoint() override;
GLint64 getTimestamp() override;
// Context switching
angle::Result onMakeCurrent(const gl::Context *context) override;
angle::Result onUnMakeCurrent(const gl::Context *context) override;
// Native capabilities, unmodified by gl::Context.
gl::Caps getNativeCaps() const override;
const gl::TextureCapsMap &getNativeTextureCaps() const override;
const gl::Extensions &getNativeExtensions() const override;
const gl::Limitations &getNativeLimitations() const override;
// Shader creation
CompilerImpl *createCompiler() override;
ShaderImpl *createShader(const gl::ShaderState &state) override;
ProgramImpl *createProgram(const gl::ProgramState &state) override;
// Framebuffer creation
FramebufferImpl *createFramebuffer(const gl::FramebufferState &state) override;
// Texture creation
TextureImpl *createTexture(const gl::TextureState &state) override;
// Renderbuffer creation
RenderbufferImpl *createRenderbuffer(const gl::RenderbufferState &state) override;
// Buffer creation
BufferImpl *createBuffer(const gl::BufferState &state) override;
// Vertex Array creation
VertexArrayImpl *createVertexArray(const gl::VertexArrayState &state) override;
// Query and Fence creation
QueryImpl *createQuery(gl::QueryType type) override;
FenceNVImpl *createFenceNV() override;
SyncImpl *createSync() override;
// Transform Feedback creation
TransformFeedbackImpl *createTransformFeedback(
const gl::TransformFeedbackState &state) override;
// Sampler object creation
SamplerImpl *createSampler(const gl::SamplerState &state) override;
// Program Pipeline object creation
ProgramPipelineImpl *createProgramPipeline(const gl::ProgramPipelineState &data) override;
// Path object creation
std::vector<PathImpl *> createPaths(GLsizei) override;
// Memory object creation.
MemoryObjectImpl *createMemoryObject() override;
// Semaphore creation.
SemaphoreImpl *createSemaphore() override;
// Overlay creation.
OverlayImpl *createOverlay(const gl::OverlayState &state) override;
angle::Result dispatchCompute(const gl::Context *context,
GLuint numGroupsX,
GLuint numGroupsY,
GLuint numGroupsZ) override;
angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) override;
angle::Result memoryBarrier(const gl::Context *context, GLbitfield barriers) override;
angle::Result memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override;
// override mtl::ErrorHandler
void handleError(GLenum error,
const char *file,
const char *function,
unsigned int line) override;
using ContextImpl::handleError;
private:
gl::TextureCapsMap mNativeTextureCaps;
gl::Extensions mNativeExtensions;
gl::Caps mNativeCaps;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_CONTEXTMTL_H_ */
//
// 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.
//
// DisplayMtl.h:
// Defines the class interface for DisplayMtl, implementing DisplayImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_DISPLAYMTL_H_
#define LIBANGLE_RENDERER_METAL_DISPLAYMTL_H_
#include "libANGLE/renderer/DisplayImpl.h"
namespace egl
{
class Surface;
}
namespace rx
{
class RendererMtl;
class DisplayMtl : public DisplayImpl
{
public:
// Check whether minimum required Metal version is available on the host platform.
static bool IsMetalAvailable();
DisplayMtl(const egl::DisplayState &state);
~DisplayMtl() override;
egl::Error initialize(egl::Display *display) override;
void terminate() override;
bool testDeviceLost() override;
egl::Error restoreLostDevice(const egl::Display *display) override;
std::string getVendorString() const override;
DeviceImpl *createDevice() override;
egl::Error waitClient(const gl::Context *context) override;
egl::Error waitNative(const gl::Context *context, EGLint engine) override;
SurfaceImpl *createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferSurface(const egl::SurfaceState &state,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPbufferFromClientBuffer(const egl::SurfaceState &state,
EGLenum buftype,
EGLClientBuffer clientBuffer,
const egl::AttributeMap &attribs) override;
SurfaceImpl *createPixmapSurface(const egl::SurfaceState &state,
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs) override;
ImageImpl *createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs) override;
ContextImpl *createContext(const gl::State &state,
gl::ErrorSet *errorSet,
const egl::Config *configuration,
const gl::Context *shareContext,
const egl::AttributeMap &attribs) override;
StreamProducerImpl *createStreamProducerD3DTexture(egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs) override;
gl::Version getMaxSupportedESVersion() const override;
gl::Version getMaxConformantESVersion() const override;
EGLSyncImpl *createSync(const egl::AttributeMap &attribs) override;
egl::Error makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context) override;
void populateFeatureList(angle::FeatureList *features) override;
bool isValidNativeWindow(EGLNativeWindowType window) const override;
egl::ConfigSet generateConfigs() override;
RendererMtl *getRenderer() { return mRenderer.get(); }
protected:
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
void generateCaps(egl::Caps *outCaps) const override;
private:
std::unique_ptr<RendererMtl> mRenderer;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_DISPLAYMTL_H_ */
//
// Copyright (c) 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.
//
// DisplayMtl.mm: Metal implementation of DisplayImpl
#include "libANGLE/renderer/metal/DisplayMtl.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/metal/ContextMtl.h"
#include "libANGLE/renderer/metal/RendererMtl.h"
#include "libANGLE/renderer/metal/SurfaceMtl.h"
#include "EGL/eglext.h"
namespace rx
{
bool DisplayMtl::IsMetalAvailable()
{
// We only support macos 10.13+ and iOS 11 for now. Since they are requirements for Metal 2.0.
if (@available(macOS 10.13, iOS 11, *))
{
return true;
}
return false;
}
DisplayMtl::DisplayMtl(const egl::DisplayState &state)
: DisplayImpl(state), mRenderer(new RendererMtl())
{}
DisplayMtl::~DisplayMtl() {}
egl::Error DisplayMtl::initialize(egl::Display *display)
{
ASSERT(IsMetalAvailable());
angle::Result result = mRenderer->initialize(display);
if (result != angle::Result::Continue)
{
return egl::EglNotInitialized();
}
return egl::NoError();
}
void DisplayMtl::terminate()
{
mRenderer->onDestroy();
}
bool DisplayMtl::testDeviceLost()
{
return false;
}
egl::Error DisplayMtl::restoreLostDevice(const egl::Display *display)
{
return egl::NoError();
}
std::string DisplayMtl::getVendorString() const
{
return mRenderer->getVendorString();
}
DeviceImpl *DisplayMtl::createDevice()
{
UNIMPLEMENTED();
return nullptr;
}
egl::Error DisplayMtl::waitClient(const gl::Context *context)
{
UNIMPLEMENTED();
return egl::NoError();
}
egl::Error DisplayMtl::waitNative(const gl::Context *context, EGLint engine)
{
UNIMPLEMENTED();
return egl::EglBadAccess();
}
SurfaceImpl *DisplayMtl::createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs)
{
EGLint width = attribs.getAsInt(EGL_WIDTH, 0);
EGLint height = attribs.getAsInt(EGL_HEIGHT, 0);
return new SurfaceMtl(state, window, width, height);
}
SurfaceImpl *DisplayMtl::createPbufferSurface(const egl::SurfaceState &state,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return static_cast<SurfaceImpl *>(0);
}
SurfaceImpl *DisplayMtl::createPbufferFromClientBuffer(const egl::SurfaceState &state,
EGLenum buftype,
EGLClientBuffer clientBuffer,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return static_cast<SurfaceImpl *>(0);
}
SurfaceImpl *DisplayMtl::createPixmapSurface(const egl::SurfaceState &state,
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return static_cast<SurfaceImpl *>(0);
}
ImageImpl *DisplayMtl::createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return nullptr;
}
rx::ContextImpl *DisplayMtl::createContext(const gl::State &state,
gl::ErrorSet *errorSet,
const egl::Config *configuration,
const gl::Context *shareContext,
const egl::AttributeMap &attribs)
{
return new ContextMtl(state, errorSet, mRenderer.get());
}
StreamProducerImpl *DisplayMtl::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return nullptr;
}
gl::Version DisplayMtl::getMaxSupportedESVersion() const
{
UNIMPLEMENTED();
return gl::Version(1, 0);
}
gl::Version DisplayMtl::getMaxConformantESVersion() const
{
return std::min(getMaxSupportedESVersion(), gl::Version(2, 0));
}
EGLSyncImpl *DisplayMtl::createSync(const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return nullptr;
}
egl::Error DisplayMtl::makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context)
{
if (!context)
{
return egl::NoError();
}
return egl::NoError();
}
void DisplayMtl::generateExtensions(egl::DisplayExtensions *outExtensions) const {}
void DisplayMtl::generateCaps(egl::Caps *outCaps) const {}
void DisplayMtl::populateFeatureList(angle::FeatureList *features) {}
egl::ConfigSet DisplayMtl::generateConfigs()
{
UNIMPLEMENTED();
egl::ConfigSet configs;
return configs;
}
bool DisplayMtl::isValidNativeWindow(EGLNativeWindowType window) const
{
UNIMPLEMENTED();
return false;
}
} // namespace rx
\ No newline at end of file
//
// 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.
//
// FrameBufferMtl.h:
// Defines the class interface for FrameBufferMtl, implementing FrameBufferImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_FRAMEBUFFERMTL_H_
#define LIBANGLE_RENDERER_METAL_FRAMEBUFFERMTL_H_
#import <Metal/Metal.h>
#include "libANGLE/renderer/FramebufferImpl.h"
namespace rx
{
class FramebufferMtl : public FramebufferImpl
{
public:
explicit FramebufferMtl(const gl::FramebufferState &state);
~FramebufferMtl() override;
void destroy(const gl::Context *context) override;
angle::Result discard(const gl::Context *context,
size_t count,
const GLenum *attachments) override;
angle::Result invalidate(const gl::Context *context,
size_t count,
const GLenum *attachments) override;
angle::Result invalidateSub(const gl::Context *context,
size_t count,
const GLenum *attachments,
const gl::Rectangle &area) override;
angle::Result clear(const gl::Context *context, GLbitfield mask) override;
angle::Result clearBufferfv(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
const GLfloat *values) override;
angle::Result clearBufferuiv(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
const GLuint *values) override;
angle::Result clearBufferiv(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
const GLint *values) override;
angle::Result clearBufferfi(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
GLfloat depth,
GLint stencil) override;
GLenum getImplementationColorReadFormat(const gl::Context *context) const override;
GLenum getImplementationColorReadType(const gl::Context *context) const override;
angle::Result readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
void *pixels) override;
angle::Result blit(const gl::Context *context,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLbitfield mask,
GLenum filter) override;
bool checkStatus(const gl::Context *context) const override;
angle::Result syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
angle::Result getSamplePosition(const gl::Context *context,
size_t index,
GLfloat *xy) const override;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_FRAMEBUFFERMTL_H */
//
// 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.
//
// FramebufferMtl.mm:
// Implements the class methods for FramebufferMtl.
//
#include "libANGLE/renderer/metal/ContextMtl.h"
#include <TargetConditionals.h>
#include "common/angleutils.h"
#include "common/debug.h"
#include "libANGLE/renderer/metal/FrameBufferMtl.h"
namespace rx
{
// FramebufferMtl implementation
FramebufferMtl::FramebufferMtl(const gl::FramebufferState &state) : FramebufferImpl(state) {}
FramebufferMtl::~FramebufferMtl() {}
void FramebufferMtl::destroy(const gl::Context *context)
{
UNIMPLEMENTED();
}
angle::Result FramebufferMtl::discard(const gl::Context *context,
size_t count,
const GLenum *attachments)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result FramebufferMtl::invalidate(const gl::Context *context,
size_t count,
const GLenum *attachments)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result FramebufferMtl::invalidateSub(const gl::Context *context,
size_t count,
const GLenum *attachments,
const gl::Rectangle &area)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result FramebufferMtl::clear(const gl::Context *context, GLbitfield mask)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result FramebufferMtl::clearBufferfv(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
const GLfloat *values)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result FramebufferMtl::clearBufferuiv(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
const GLuint *values)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result FramebufferMtl::clearBufferiv(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
const GLint *values)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result FramebufferMtl::clearBufferfi(const gl::Context *context,
GLenum buffer,
GLint drawbuffer,
GLfloat depth,
GLint stencil)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
GLenum FramebufferMtl::getImplementationColorReadFormat(const gl::Context *context) const
{
UNIMPLEMENTED();
return GL_INVALID_ENUM;
}
GLenum FramebufferMtl::getImplementationColorReadType(const gl::Context *context) const
{
UNIMPLEMENTED();
return GL_INVALID_ENUM;
}
angle::Result FramebufferMtl::readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
void *pixels)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result FramebufferMtl::blit(const gl::Context *context,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLbitfield mask,
GLenum filter)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
bool FramebufferMtl::checkStatus(const gl::Context *context) const
{
UNIMPLEMENTED();
return false;
}
angle::Result FramebufferMtl::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result FramebufferMtl::getSamplePosition(const gl::Context *context,
size_t index,
GLfloat *xy) const
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
}
//
// 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.
//
// ProgramMtl.h:
// Defines the class interface for ProgramMtl, implementing ProgramImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_PROGRAMMTL_H_
#define LIBANGLE_RENDERER_METAL_PROGRAMMTL_H_
#import <Metal/Metal.h>
#include "libANGLE/renderer/ProgramImpl.h"
namespace rx
{
class ProgramMtl : public ProgramImpl
{
public:
ProgramMtl(const gl::ProgramState &state);
~ProgramMtl() override;
void destroy(const gl::Context *context) override;
std::unique_ptr<LinkEvent> load(const gl::Context *context,
gl::BinaryInputStream *stream,
gl::InfoLog &infoLog) override;
void save(const gl::Context *context, gl::BinaryOutputStream *stream) override;
void setBinaryRetrievableHint(bool retrievable) override;
void setSeparable(bool separable) override;
std::unique_ptr<LinkEvent> link(const gl::Context *context,
const gl::ProgramLinkedResources &resources,
gl::InfoLog &infoLog) override;
GLboolean validate(const gl::Caps &caps, gl::InfoLog *infoLog) override;
void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform3fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform4fv(GLint location, GLsizei count, const GLfloat *v) override;
void setUniform1iv(GLint location, GLsizei count, const GLint *v) override;
void setUniform2iv(GLint location, GLsizei count, const GLint *v) override;
void setUniform3iv(GLint location, GLsizei count, const GLint *v) override;
void setUniform4iv(GLint location, GLsizei count, const GLint *v) override;
void setUniform1uiv(GLint location, GLsizei count, const GLuint *v) override;
void setUniform2uiv(GLint location, GLsizei count, const GLuint *v) override;
void setUniform3uiv(GLint location, GLsizei count, const GLuint *v) override;
void setUniform4uiv(GLint location, GLsizei count, const GLuint *v) override;
void setUniformMatrix2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix2x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix3x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix2x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix4x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix3x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void setUniformMatrix4x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value) override;
void getUniformfv(const gl::Context *context, GLint location, GLfloat *params) const override;
void getUniformiv(const gl::Context *context, GLint location, GLint *params) const override;
void getUniformuiv(const gl::Context *context, GLint location, GLuint *params) const override;
void setPathFragmentInputGen(const std::string &inputName,
GLenum genMode,
GLint components,
const GLfloat *coeffs) override;
private:
template <int cols, int rows>
void setUniformMatrixfv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
template <class T>
void getUniformImpl(GLint location, T *v, GLenum entryPointType) const;
template <typename T>
void setUniformImpl(GLint location, GLsizei count, const T *v, GLenum entryPointType);
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_PROGRAMMTL_H_ */
//
// 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.
//
// ProgramMtl.mm:
// Implements the class methods for ProgramMtl.
//
#include "libANGLE/renderer/metal/ProgramMtl.h"
#include "common/debug.h"
#include "libANGLE/Context.h"
#include "libANGLE/ProgramLinkedResources.h"
#include "libANGLE/renderer/metal/ContextMtl.h"
namespace rx
{
// ProgramMtl implementation
ProgramMtl::ProgramMtl(const gl::ProgramState &state) : ProgramImpl(state) {}
ProgramMtl::~ProgramMtl() {}
void ProgramMtl::destroy(const gl::Context *context)
{
UNIMPLEMENTED();
}
std::unique_ptr<rx::LinkEvent> ProgramMtl::load(const gl::Context *context,
gl::BinaryInputStream *stream,
gl::InfoLog &infoLog)
{
UNIMPLEMENTED();
return std::make_unique<LinkEventDone>(angle::Result::Stop);
}
void ProgramMtl::save(const gl::Context *context, gl::BinaryOutputStream *stream)
{
UNIMPLEMENTED();
}
void ProgramMtl::setBinaryRetrievableHint(bool retrievable)
{
UNIMPLEMENTED();
}
void ProgramMtl::setSeparable(bool separable)
{
UNIMPLEMENTED();
}
std::unique_ptr<LinkEvent> ProgramMtl::link(const gl::Context *context,
const gl::ProgramLinkedResources &resources,
gl::InfoLog &infoLog)
{
UNIMPLEMENTED();
return nullptr;
}
GLboolean ProgramMtl::validate(const gl::Caps &caps, gl::InfoLog *infoLog)
{
UNIMPLEMENTED();
return GL_TRUE;
}
template <typename T>
void ProgramMtl::setUniformImpl(GLint location, GLsizei count, const T *v, GLenum entryPointType)
{
UNIMPLEMENTED();
}
template <typename T>
void ProgramMtl::getUniformImpl(GLint location, T *v, GLenum entryPointType) const
{
UNIMPLEMENTED();
}
void ProgramMtl::setUniform1fv(GLint location, GLsizei count, const GLfloat *v)
{
setUniformImpl(location, count, v, GL_FLOAT);
}
void ProgramMtl::setUniform2fv(GLint location, GLsizei count, const GLfloat *v)
{
setUniformImpl(location, count, v, GL_FLOAT_VEC2);
}
void ProgramMtl::setUniform3fv(GLint location, GLsizei count, const GLfloat *v)
{
setUniformImpl(location, count, v, GL_FLOAT_VEC3);
}
void ProgramMtl::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
{
setUniformImpl(location, count, v, GL_FLOAT_VEC4);
}
void ProgramMtl::setUniform1iv(GLint startLocation, GLsizei count, const GLint *v)
{
setUniformImpl(startLocation, count, v, GL_INT);
}
void ProgramMtl::setUniform2iv(GLint location, GLsizei count, const GLint *v)
{
setUniformImpl(location, count, v, GL_INT_VEC2);
}
void ProgramMtl::setUniform3iv(GLint location, GLsizei count, const GLint *v)
{
setUniformImpl(location, count, v, GL_INT_VEC3);
}
void ProgramMtl::setUniform4iv(GLint location, GLsizei count, const GLint *v)
{
setUniformImpl(location, count, v, GL_INT_VEC4);
}
void ProgramMtl::setUniform1uiv(GLint location, GLsizei count, const GLuint *v)
{
setUniformImpl(location, count, v, GL_UNSIGNED_INT);
}
void ProgramMtl::setUniform2uiv(GLint location, GLsizei count, const GLuint *v)
{
setUniformImpl(location, count, v, GL_UNSIGNED_INT_VEC2);
}
void ProgramMtl::setUniform3uiv(GLint location, GLsizei count, const GLuint *v)
{
setUniformImpl(location, count, v, GL_UNSIGNED_INT_VEC3);
}
void ProgramMtl::setUniform4uiv(GLint location, GLsizei count, const GLuint *v)
{
setUniformImpl(location, count, v, GL_UNSIGNED_INT_VEC4);
}
template <int cols, int rows>
void ProgramMtl::setUniformMatrixfv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
UNIMPLEMENTED();
}
void ProgramMtl::setUniformMatrix2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
setUniformMatrixfv<2, 2>(location, count, transpose, value);
}
void ProgramMtl::setUniformMatrix3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
setUniformMatrixfv<3, 3>(location, count, transpose, value);
}
void ProgramMtl::setUniformMatrix4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
setUniformMatrixfv<4, 4>(location, count, transpose, value);
}
void ProgramMtl::setUniformMatrix2x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
setUniformMatrixfv<2, 3>(location, count, transpose, value);
}
void ProgramMtl::setUniformMatrix3x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
setUniformMatrixfv<3, 2>(location, count, transpose, value);
}
void ProgramMtl::setUniformMatrix2x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
setUniformMatrixfv<2, 4>(location, count, transpose, value);
}
void ProgramMtl::setUniformMatrix4x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
setUniformMatrixfv<4, 2>(location, count, transpose, value);
}
void ProgramMtl::setUniformMatrix3x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
setUniformMatrixfv<3, 4>(location, count, transpose, value);
}
void ProgramMtl::setUniformMatrix4x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value)
{
setUniformMatrixfv<4, 3>(location, count, transpose, value);
}
void ProgramMtl::setPathFragmentInputGen(const std::string &inputName,
GLenum genMode,
GLint components,
const GLfloat *coeffs)
{
UNIMPLEMENTED();
}
void ProgramMtl::getUniformfv(const gl::Context *context, GLint location, GLfloat *params) const
{
getUniformImpl(location, params, GL_FLOAT);
}
void ProgramMtl::getUniformiv(const gl::Context *context, GLint location, GLint *params) const
{
getUniformImpl(location, params, GL_INT);
}
void ProgramMtl::getUniformuiv(const gl::Context *context, GLint location, GLuint *params) const
{
getUniformImpl(location, params, GL_UNSIGNED_INT);
}
} // namespace rx
//
// 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.
//
// RenderBufferMtl.h:
// Defines the class interface for RenderBufferMtl, implementing RenderBufferImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_RENDERBUFFERMTL_H_
#define LIBANGLE_RENDERER_METAL_RENDERBUFFERMTL_H_
#include "libANGLE/renderer/RenderbufferImpl.h"
namespace rx
{
class RenderbufferMtl : public RenderbufferImpl
{
public:
RenderbufferMtl(const gl::RenderbufferState &state);
~RenderbufferMtl() override;
void onDestroy(const gl::Context *context) override;
angle::Result setStorage(const gl::Context *context,
GLenum internalformat,
size_t width,
size_t height) override;
angle::Result setStorageMultisample(const gl::Context *context,
size_t samples,
GLenum internalformat,
size_t width,
size_t height) override;
angle::Result setStorageEGLImageTarget(const gl::Context *context, egl::Image *image) override;
angle::Result getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut) override;
angle::Result initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex) override;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_RENDERBUFFERMTL_H_ */
//
// 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.
//
// RenderBufferMtl.mm:
// Implements the class methods for RenderBufferMtl.
//
#include "libANGLE/renderer/metal/RenderBufferMtl.h"
#include "libANGLE/renderer/metal/ContextMtl.h"
namespace rx
{
RenderbufferMtl::RenderbufferMtl(const gl::RenderbufferState &state) : RenderbufferImpl(state) {}
RenderbufferMtl::~RenderbufferMtl() {}
void RenderbufferMtl::onDestroy(const gl::Context *context)
{
UNIMPLEMENTED();
}
angle::Result RenderbufferMtl::setStorage(const gl::Context *context,
GLenum internalformat,
size_t width,
size_t height)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result RenderbufferMtl::setStorageMultisample(const gl::Context *context,
size_t samples,
GLenum internalformat,
size_t width,
size_t height)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result RenderbufferMtl::setStorageEGLImageTarget(const gl::Context *context,
egl::Image *image)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result RenderbufferMtl::getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result RenderbufferMtl::initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
}
\ No newline at end of file
//
// 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.
//
// RendererMtl.h:
// Defines class interface for RendererMtl.
#ifndef LIBANGLE_RENDERER_METAL_RENDERERMTL_H_
#define LIBANGLE_RENDERER_METAL_RENDERERMTL_H_
#import <Metal/Metal.h>
#include "common/PackedEnums.h"
#include "libANGLE/Caps.h"
#include "libANGLE/angletypes.h"
namespace egl
{
class Display;
}
namespace rx
{
class ContextMtl;
class RendererMtl final : angle::NonCopyable
{
public:
RendererMtl();
~RendererMtl();
angle::Result initialize(egl::Display *display);
void onDestroy();
std::string getVendorString() const;
std::string getRendererDescription() const;
const gl::Limitations &getNativeLimitations() const;
id<MTLDevice> getMetalDevice() const { return nil; }
private:
gl::Limitations mNativeLimitations;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_RENDERERMTL_H_ */
//
// 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.
//
// RendererMtl.mm:
// Implements the class methods for RendererMtl.
//
#include "libANGLE/renderer/metal/RendererMtl.h"
#include "libANGLE/renderer/metal/mtl_common.h"
namespace rx
{
RendererMtl::RendererMtl() {}
RendererMtl::~RendererMtl() {}
angle::Result RendererMtl::initialize(egl::Display *display)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
void RendererMtl::onDestroy()
{
UNIMPLEMENTED();
}
std::string RendererMtl::getVendorString() const
{
std::string vendorString = "Google Inc.";
UNIMPLEMENTED();
return vendorString;
}
std::string RendererMtl::getRendererDescription() const
{
std::string desc = "Metal Renderer";
UNIMPLEMENTED();
return desc;
}
const gl::Limitations &RendererMtl::getNativeLimitations() const
{
UNIMPLEMENTED();
return mNativeLimitations;
}
}
//
// 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.
//
// ShaderMtl.h:
// Defines the class interface for ShaderMtl, implementing ShaderImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_SHADERMTL_H_
#define LIBANGLE_RENDERER_METAL_SHADERMTL_H_
#include <map>
#include "libANGLE/renderer/ShaderImpl.h"
namespace rx
{
class ShaderMtl : public ShaderImpl
{
public:
ShaderMtl(const gl::ShaderState &data);
~ShaderMtl() override;
std::shared_ptr<WaitableCompileEvent> compile(const gl::Context *context,
gl::ShCompilerInstance *compilerInstance,
ShCompileOptions options) override;
std::string getDebugInfo() const override;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_SHADERMTL_H_ */
//
// 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.
//
// ShaderMtl.mm:
// Implements the class methods for ShaderMtl.
//
#include "libANGLE/renderer/metal/ShaderMtl.h"
#include "common/debug.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/metal/ContextMtl.h"
namespace rx
{
ShaderMtl::ShaderMtl(const gl::ShaderState &data) : ShaderImpl(data) {}
ShaderMtl::~ShaderMtl() {}
std::shared_ptr<WaitableCompileEvent> ShaderMtl::compile(const gl::Context *context,
gl::ShCompilerInstance *compilerInstance,
ShCompileOptions options)
{
UNIMPLEMENTED();
return compileImpl(context, compilerInstance, mData.getSource(), options);
}
std::string ShaderMtl::getDebugInfo() const
{
return mData.getTranslatedSource();
}
} // namespace rx
//
// 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.
//
// SurfaceMtl.h: Defines the class interface for Metal Surface.
#ifndef LIBANGLE_RENDERER_METAL_SURFACEMTL_H_
#define LIBANGLE_RENDERER_METAL_SURFACEMTL_H_
#import <Metal/Metal.h>
#import <QuartzCore/CALayer.h>
#include "libANGLE/renderer/SurfaceImpl.h"
namespace rx
{
class SurfaceMtl : public SurfaceImpl
{
public:
SurfaceMtl(const egl::SurfaceState &state,
EGLNativeWindowType window,
EGLint width,
EGLint height);
~SurfaceMtl() override;
void destroy(const egl::Display *display) override;
egl::Error initialize(const egl::Display *display) override;
FramebufferImpl *createDefaultFramebuffer(const gl::Context *context,
const gl::FramebufferState &state) override;
egl::Error makeCurrent(const gl::Context *context) override;
egl::Error unMakeCurrent(const gl::Context *context) override;
egl::Error swap(const gl::Context *context) override;
egl::Error postSubBuffer(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height) override;
egl::Error querySurfacePointerANGLE(EGLint attribute, void **value) override;
egl::Error bindTexImage(const gl::Context *context,
gl::Texture *texture,
EGLint buffer) override;
egl::Error releaseTexImage(const gl::Context *context, EGLint buffer) override;
egl::Error getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc) override;
void setSwapInterval(EGLint interval) override;
void setFixedWidth(EGLint width) override;
void setFixedHeight(EGLint height) override;
// width and height can change with client window resizing
EGLint getWidth() const override;
EGLint getHeight() const override;
EGLint isPostSubBufferSupported() const override;
EGLint getSwapBehavior() const override;
angle::Result getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut) override;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_SURFACEMTL_H_ */
//
// 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.
//
// SurfaceMtl.mm:
// Implements the class methods for SurfaceMtl.
//
#include "libANGLE/renderer/metal/SurfaceMtl.h"
#include "libANGLE/renderer/metal/FrameBufferMtl.h"
namespace rx
{
SurfaceMtl::SurfaceMtl(const egl::SurfaceState &state,
EGLNativeWindowType window,
EGLint width,
EGLint height)
: SurfaceImpl(state)
{
UNIMPLEMENTED();
}
SurfaceMtl::~SurfaceMtl() {}
void SurfaceMtl::destroy(const egl::Display *display)
{
UNIMPLEMENTED();
}
egl::Error SurfaceMtl::initialize(const egl::Display *display)
{
UNIMPLEMENTED();
return egl::NoError();
}
FramebufferImpl *SurfaceMtl::createDefaultFramebuffer(const gl::Context *context,
const gl::FramebufferState &state)
{
auto fbo = new FramebufferMtl(state);
return fbo;
}
egl::Error SurfaceMtl::makeCurrent(const gl::Context *context)
{
UNIMPLEMENTED();
return egl::NoError();
}
egl::Error SurfaceMtl::unMakeCurrent(const gl::Context *context)
{
UNIMPLEMENTED();
return egl::NoError();
}
egl::Error SurfaceMtl::swap(const gl::Context *context)
{
UNIMPLEMENTED();
return egl::NoError();
}
egl::Error SurfaceMtl::postSubBuffer(const gl::Context *context,
EGLint x,
EGLint y,
EGLint width,
EGLint height)
{
UNIMPLEMENTED();
return egl::EglBadAccess();
}
egl::Error SurfaceMtl::querySurfacePointerANGLE(EGLint attribute, void **value)
{
UNIMPLEMENTED();
return egl::EglBadAccess();
}
egl::Error SurfaceMtl::bindTexImage(const gl::Context *context, gl::Texture *texture, EGLint buffer)
{
UNIMPLEMENTED();
return egl::EglBadAccess();
}
egl::Error SurfaceMtl::releaseTexImage(const gl::Context *context, EGLint buffer)
{
UNIMPLEMENTED();
return egl::EglBadAccess();
}
egl::Error SurfaceMtl::getSyncValues(EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc)
{
UNIMPLEMENTED();
return egl::EglBadAccess();
}
void SurfaceMtl::setSwapInterval(EGLint interval) {}
void SurfaceMtl::setFixedWidth(EGLint width)
{
UNIMPLEMENTED();
}
void SurfaceMtl::setFixedHeight(EGLint height)
{
UNIMPLEMENTED();
}
// width and height can change with client window resizing
EGLint SurfaceMtl::getWidth() const
{
UNIMPLEMENTED();
return 0;
}
EGLint SurfaceMtl::getHeight() const
{
UNIMPLEMENTED();
return 0;
}
EGLint SurfaceMtl::isPostSubBufferSupported() const
{
return EGL_FALSE;
}
EGLint SurfaceMtl::getSwapBehavior() const
{
return EGL_BUFFER_DESTROYED;
}
angle::Result SurfaceMtl::getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
}
//
// 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.
//
// TextureMtl.h:
// Defines the class interface for TextureMtl, implementing TextureImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_TEXTUREMTL_H_
#define LIBANGLE_RENDERER_METAL_TEXTUREMTL_H_
#include "common/PackedEnums.h"
#include "libANGLE/renderer/TextureImpl.h"
namespace rx
{
class TextureMtl : public TextureImpl
{
public:
TextureMtl(const gl::TextureState &state);
~TextureMtl() override;
void onDestroy(const gl::Context *context) override;
angle::Result setImage(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
const gl::Extents &size,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
const uint8_t *pixels) override;
angle::Result setSubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Box &area,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
gl::Buffer *unpackBuffer,
const uint8_t *pixels) override;
angle::Result setCompressedImage(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
const gl::Extents &size,
const gl::PixelUnpackState &unpack,
size_t imageSize,
const uint8_t *pixels) override;
angle::Result setCompressedSubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Box &area,
GLenum format,
const gl::PixelUnpackState &unpack,
size_t imageSize,
const uint8_t *pixels) override;
angle::Result copyImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Rectangle &sourceArea,
GLenum internalFormat,
gl::Framebuffer *source) override;
angle::Result copySubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Offset &destOffset,
const gl::Rectangle &sourceArea,
gl::Framebuffer *source) override;
angle::Result copyTexture(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
GLenum type,
size_t sourceLevel,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
const gl::Texture *source) override;
angle::Result copySubTexture(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Offset &destOffset,
size_t sourceLevel,
const gl::Box &sourceBox,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
const gl::Texture *source) override;
angle::Result copyCompressedTexture(const gl::Context *context,
const gl::Texture *source) override;
angle::Result setStorage(const gl::Context *context,
gl::TextureType type,
size_t levels,
GLenum internalFormat,
const gl::Extents &size) override;
angle::Result setStorageExternalMemory(const gl::Context *context,
gl::TextureType type,
size_t levels,
GLenum internalFormat,
const gl::Extents &size,
gl::MemoryObject *memoryObject,
GLuint64 offset) override;
angle::Result setEGLImageTarget(const gl::Context *context,
gl::TextureType type,
egl::Image *image) override;
angle::Result setImageExternal(const gl::Context *context,
gl::TextureType type,
egl::Stream *stream,
const egl::Stream::GLTextureDescription &desc) override;
angle::Result generateMipmap(const gl::Context *context) override;
angle::Result setBaseLevel(const gl::Context *context, GLuint baseLevel) override;
angle::Result bindTexImage(const gl::Context *context, egl::Surface *surface) override;
angle::Result releaseTexImage(const gl::Context *context) override;
angle::Result getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut) override;
angle::Result syncState(const gl::Context *context,
const gl::Texture::DirtyBits &dirtyBits) override;
angle::Result setStorageMultisample(const gl::Context *context,
gl::TextureType type,
GLsizei samples,
GLint internalformat,
const gl::Extents &size,
bool fixedSampleLocations) override;
angle::Result initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex) override;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_TEXTUREMTL_H_ */
//
// 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.
//
// TextureMtl.mm:
// Implements the class methods for TextureMtl.
//
#include "libANGLE/renderer/metal/TextureMtl.h"
namespace rx
{
// TextureMtl implementation
TextureMtl::TextureMtl(const gl::TextureState &state) : TextureImpl(state) {}
TextureMtl::~TextureMtl() = default;
void TextureMtl::onDestroy(const gl::Context *context)
{
UNIMPLEMENTED();
}
angle::Result TextureMtl::setImage(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
const gl::Extents &size,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
const uint8_t *pixels)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result TextureMtl::setSubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Box &area,
GLenum format,
GLenum type,
const gl::PixelUnpackState &unpack,
gl::Buffer *unpackBuffer,
const uint8_t *pixels)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result TextureMtl::setCompressedImage(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
const gl::Extents &size,
const gl::PixelUnpackState &unpack,
size_t imageSize,
const uint8_t *pixels)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result TextureMtl::setCompressedSubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Box &area,
GLenum format,
const gl::PixelUnpackState &unpack,
size_t imageSize,
const uint8_t *pixels)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result TextureMtl::copyImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Rectangle &sourceArea,
GLenum internalFormat,
gl::Framebuffer *source)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result TextureMtl::copySubImage(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Offset &destOffset,
const gl::Rectangle &sourceArea,
gl::Framebuffer *source)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result TextureMtl::copyTexture(const gl::Context *context,
const gl::ImageIndex &index,
GLenum internalFormat,
GLenum type,
size_t sourceLevel,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
const gl::Texture *source)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::copySubTexture(const gl::Context *context,
const gl::ImageIndex &index,
const gl::Offset &destOffset,
size_t sourceLevel,
const gl::Box &sourceBox,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
const gl::Texture *source)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::copyCompressedTexture(const gl::Context *context,
const gl::Texture *source)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::setStorage(const gl::Context *context,
gl::TextureType type,
size_t mipmaps,
GLenum internalFormat,
const gl::Extents &size)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result TextureMtl::setStorageExternalMemory(const gl::Context *context,
gl::TextureType type,
size_t levels,
GLenum internalFormat,
const gl::Extents &size,
gl::MemoryObject *memoryObject,
GLuint64 offset)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::setStorageMultisample(const gl::Context *context,
gl::TextureType type,
GLsizei samples,
GLint internalformat,
const gl::Extents &size,
bool fixedSampleLocations)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::setEGLImageTarget(const gl::Context *context,
gl::TextureType type,
egl::Image *image)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::setImageExternal(const gl::Context *context,
gl::TextureType type,
egl::Stream *stream,
const egl::Stream::GLTextureDescription &desc)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::generateMipmap(const gl::Context *context)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result TextureMtl::setBaseLevel(const gl::Context *context, GLuint baseLevel)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::bindTexImage(const gl::Context *context, egl::Surface *surface)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::releaseTexImage(const gl::Context *context)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::getAttachmentRenderTarget(const gl::Context *context,
GLenum binding,
const gl::ImageIndex &imageIndex,
GLsizei samples,
FramebufferAttachmentRenderTarget **rtOut)
{
UNIMPLEMENTED();
return angle::Result::Stop;
}
angle::Result TextureMtl::syncState(const gl::Context *context,
const gl::Texture::DirtyBits &dirtyBits)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
angle::Result TextureMtl::initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
}
//
// 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.
//
// VertexArrayMtl.h:
// Defines the class interface for VertexArrayMtl, implementing VertexArrayImpl.
//
#ifndef LIBANGLE_RENDERER_METAL_VERTEXARRAYMTL_H_
#define LIBANGLE_RENDERER_METAL_VERTEXARRAYMTL_H_
#include "libANGLE/renderer/VertexArrayImpl.h"
namespace rx
{
class ContextMtl;
class VertexArrayMtl : public VertexArrayImpl
{
public:
VertexArrayMtl(const gl::VertexArrayState &state);
~VertexArrayMtl() override;
void destroy(const gl::Context *context) override;
angle::Result syncState(const gl::Context *context,
const gl::VertexArray::DirtyBits &dirtyBits,
gl::VertexArray::DirtyAttribBitsArray *attribBits,
gl::VertexArray::DirtyBindingBitsArray *bindingBits) override;
};
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_VERTEXARRAYMTL_H_ */
//
// 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.
//
// VertexArrayMtl.mm:
// Implements the class methods for VertexArrayMtl.
//
#include "libANGLE/renderer/metal/VertexArrayMtl.h"
#include "common/debug.h"
namespace rx
{
// VertexArrayMtl implementation
VertexArrayMtl::VertexArrayMtl(const gl::VertexArrayState &state) : VertexArrayImpl(state)
{
UNIMPLEMENTED();
}
VertexArrayMtl::~VertexArrayMtl() {}
void VertexArrayMtl::destroy(const gl::Context *context)
{
UNIMPLEMENTED();
}
angle::Result VertexArrayMtl::syncState(const gl::Context *context,
const gl::VertexArray::DirtyBits &dirtyBits,
gl::VertexArray::DirtyAttribBitsArray *attribBits,
gl::VertexArray::DirtyBindingBitsArray *bindingBits)
{
UNIMPLEMENTED();
return angle::Result::Continue;
}
}
//
// 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.h:
// Declares common constants, template classes, and mtl::Context - the MTLDevice container &
// error handler base class.
//
#ifndef LIBANGLE_RENDERER_METAL_MTL_COMMON_H_
#define LIBANGLE_RENDERER_METAL_MTL_COMMON_H_
#import <Metal/Metal.h>
#include <string>
#include "common/Optional.h"
#include "common/PackedEnums.h"
#include "common/angleutils.h"
#include "libANGLE/Constants.h"
#include "libANGLE/Version.h"
#include "libANGLE/angletypes.h"
namespace rx
{
class RendererMtl;
namespace mtl
{
class ErrorHandler
{
public:
virtual ~ErrorHandler() {}
virtual void handleError(GLenum error,
const char *file,
const char *function,
unsigned int line) = 0;
};
class Context : public ErrorHandler
{
public:
Context(RendererMtl *rendererMtl);
_Nullable id<MTLDevice> getMetalDevice() const;
RendererMtl *getRenderer() const { return mRendererMtl; }
protected:
RendererMtl *mRendererMtl;
};
#define ANGLE_MTL_CHECK(context, test, error) \
do \
{ \
if (ANGLE_UNLIKELY(!test)) \
{ \
context->handleError(error, __FILE__, ANGLE_FUNCTION, __LINE__); \
return angle::Result::Stop; \
} \
} while (0)
#define ANGLE_MTL_TRY(context, test) ANGLE_MTL_CHECK(context, test, GL_INVALID_OPERATION)
} // namespace mtl
} // namespace rx
#endif /* LIBANGLE_RENDERER_METAL_MTL_COMMON_H_ */
//
// 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/RendererMtl.h"
namespace rx
{
namespace mtl
{
Context::Context(RendererMtl *rendererMtl) : mRendererMtl(rendererMtl) {}
id<MTLDevice> Context::getMetalDevice() const
{
return mRendererMtl->getMetalDevice();
}
} // namespace mtl
} // namespace rx
\ No newline at end of file
...@@ -740,7 +740,7 @@ bool ValidateFogfv(Context *context, GLenum pname, const GLfloat *params) ...@@ -740,7 +740,7 @@ bool ValidateFogfv(Context *context, GLenum pname, const GLfloat *params)
bool ValidateFogx(Context *context, GLenum pname, GLfixed param) bool ValidateFogx(Context *context, GLenum pname, GLfixed param)
{ {
GLfloat asFloat = FixedToFloat(param); GLfloat asFloat = ConvertFixedToFloat(param);
return ValidateFogCommon(context, pname, &asFloat); return ValidateFogCommon(context, pname, &asFloat);
} }
...@@ -751,7 +751,7 @@ bool ValidateFogxv(Context *context, GLenum pname, const GLfixed *params) ...@@ -751,7 +751,7 @@ bool ValidateFogxv(Context *context, GLenum pname, const GLfixed *params)
for (unsigned int i = 0; i < paramCount; i++) for (unsigned int i = 0; i < paramCount; i++)
{ {
paramsf[i] = FixedToFloat(params[i]); paramsf[i] = ConvertFixedToFloat(params[i]);
} }
return ValidateFogCommon(context, pname, paramsf); return ValidateFogCommon(context, pname, paramsf);
...@@ -901,7 +901,7 @@ bool ValidateLightfv(Context *context, GLenum light, LightParameter pname, const ...@@ -901,7 +901,7 @@ bool ValidateLightfv(Context *context, GLenum light, LightParameter pname, const
bool ValidateLightx(Context *context, GLenum light, LightParameter pname, GLfixed param) bool ValidateLightx(Context *context, GLenum light, LightParameter pname, GLfixed param)
{ {
return ValidateLightSingleComponent(context, light, pname, FixedToFloat(param)); return ValidateLightSingleComponent(context, light, pname, ConvertFixedToFloat(param));
} }
bool ValidateLightxv(Context *context, GLenum light, LightParameter pname, const GLfixed *params) bool ValidateLightxv(Context *context, GLenum light, LightParameter pname, const GLfixed *params)
...@@ -909,7 +909,7 @@ bool ValidateLightxv(Context *context, GLenum light, LightParameter pname, const ...@@ -909,7 +909,7 @@ bool ValidateLightxv(Context *context, GLenum light, LightParameter pname, const
GLfloat paramsf[4]; GLfloat paramsf[4];
for (unsigned int i = 0; i < GetLightParameterCount(pname); i++) for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
{ {
paramsf[i] = FixedToFloat(params[i]); paramsf[i] = ConvertFixedToFloat(params[i]);
} }
return ValidateLightCommon(context, light, pname, paramsf); return ValidateLightCommon(context, light, pname, paramsf);
...@@ -982,7 +982,7 @@ bool ValidateMaterialfv(Context *context, ...@@ -982,7 +982,7 @@ bool ValidateMaterialfv(Context *context,
bool ValidateMaterialx(Context *context, GLenum face, MaterialParameter pname, GLfixed param) bool ValidateMaterialx(Context *context, GLenum face, MaterialParameter pname, GLfixed param)
{ {
return ValidateMaterialSingleComponent(context, face, pname, FixedToFloat(param)); return ValidateMaterialSingleComponent(context, face, pname, ConvertFixedToFloat(param));
} }
bool ValidateMaterialxv(Context *context, bool ValidateMaterialxv(Context *context,
...@@ -994,7 +994,7 @@ bool ValidateMaterialxv(Context *context, ...@@ -994,7 +994,7 @@ bool ValidateMaterialxv(Context *context,
for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++) for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
{ {
paramsf[i] = FixedToFloat(params[i]); paramsf[i] = ConvertFixedToFloat(params[i]);
} }
return ValidateMaterialSetting(context, face, pname, paramsf); return ValidateMaterialSetting(context, face, pname, paramsf);
...@@ -1128,7 +1128,7 @@ bool ValidatePointParameterx(Context *context, PointParameter pname, GLfixed par ...@@ -1128,7 +1128,7 @@ bool ValidatePointParameterx(Context *context, PointParameter pname, GLfixed par
return false; return false;
} }
GLfloat paramf = FixedToFloat(param); GLfloat paramf = ConvertFixedToFloat(param);
return ValidatePointParameterCommon(context, pname, &paramf); return ValidatePointParameterCommon(context, pname, &paramf);
} }
...@@ -1137,7 +1137,7 @@ bool ValidatePointParameterxv(Context *context, PointParameter pname, const GLfi ...@@ -1137,7 +1137,7 @@ bool ValidatePointParameterxv(Context *context, PointParameter pname, const GLfi
GLfloat paramsf[4] = {}; GLfloat paramsf[4] = {};
for (unsigned int i = 0; i < GetPointParameterCount(pname); i++) for (unsigned int i = 0; i < GetPointParameterCount(pname); i++)
{ {
paramsf[i] = FixedToFloat(params[i]); paramsf[i] = ConvertFixedToFloat(params[i]);
} }
return ValidatePointParameterCommon(context, pname, paramsf); return ValidatePointParameterCommon(context, pname, paramsf);
} }
...@@ -1149,7 +1149,7 @@ bool ValidatePointSize(Context *context, GLfloat size) ...@@ -1149,7 +1149,7 @@ bool ValidatePointSize(Context *context, GLfloat size)
bool ValidatePointSizex(Context *context, GLfixed size) bool ValidatePointSizex(Context *context, GLfixed size)
{ {
return ValidatePointSizeCommon(context, FixedToFloat(size)); return ValidatePointSizeCommon(context, ConvertFixedToFloat(size));
} }
bool ValidatePolygonOffsetx(Context *context, GLfixed factor, GLfixed units) bool ValidatePolygonOffsetx(Context *context, GLfixed factor, GLfixed units)
...@@ -1299,7 +1299,7 @@ bool ValidateTexEnvxv(Context *context, ...@@ -1299,7 +1299,7 @@ bool ValidateTexEnvxv(Context *context,
bool ValidateTexParameterx(Context *context, TextureType target, GLenum pname, GLfixed param) bool ValidateTexParameterx(Context *context, TextureType target, GLenum pname, GLfixed param)
{ {
ANGLE_VALIDATE_IS_GLES1(context); ANGLE_VALIDATE_IS_GLES1(context);
GLfloat paramf = FixedToFloat(param); GLfloat paramf = ConvertFixedToFloat(param);
return ValidateTexParameterBase(context, target, pname, -1, false, &paramf); return ValidateTexParameterBase(context, target, pname, -1, false, &paramf);
} }
...@@ -1312,7 +1312,7 @@ bool ValidateTexParameterxv(Context *context, ...@@ -1312,7 +1312,7 @@ bool ValidateTexParameterxv(Context *context,
GLfloat paramsf[4] = {}; GLfloat paramsf[4] = {};
for (unsigned int i = 0; i < GetTexParameterCount(pname); i++) for (unsigned int i = 0; i < GetTexParameterCount(pname); i++)
{ {
paramsf[i] = FixedToFloat(params[i]); paramsf[i] = ConvertFixedToFloat(params[i]);
} }
return ValidateTexParameterBase(context, target, pname, -1, true, paramsf); return ValidateTexParameterBase(context, target, pname, -1, true, paramsf);
} }
...@@ -1390,12 +1390,13 @@ bool ValidateDrawTexxOES(Context *context, ...@@ -1390,12 +1390,13 @@ bool ValidateDrawTexxOES(Context *context,
GLfixed width, GLfixed width,
GLfixed height) GLfixed height)
{ {
return ValidateDrawTexCommon(context, FixedToFloat(width), FixedToFloat(height)); return ValidateDrawTexCommon(context, ConvertFixedToFloat(width), ConvertFixedToFloat(height));
} }
bool ValidateDrawTexxvOES(Context *context, const GLfixed *coords) bool ValidateDrawTexxvOES(Context *context, const GLfixed *coords)
{ {
return ValidateDrawTexCommon(context, FixedToFloat(coords[3]), FixedToFloat(coords[4])); return ValidateDrawTexCommon(context, ConvertFixedToFloat(coords[3]),
ConvertFixedToFloat(coords[4]));
} }
bool ValidateCurrentPaletteMatrixOES(Context *context, GLuint matrixpaletteindex) bool ValidateCurrentPaletteMatrixOES(Context *context, GLuint matrixpaletteindex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment