Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to merge gles3-dev #94

Open
wants to merge 1 commit into
base: gles3-dev-upstream-up-to-date
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: kakashidinho
custom: https://www.paypal.com/paypalme/HQgame
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MetalANGLE - OpenGL ES to Apple Metal API Translation Layer

[![Build Status](https://travis-ci.com/kakashidinho/metalangle.svg?branch=master)](https://travis-ci.com/kakashidinho/metalangle)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/kakashidinho/metalangle?svg=true&branch=master)](https://ci.appveyor.com/project/kakashidinho/metalangle)
[![Build Status](https://github.com/kakashidinho/metalangle/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/kakashidinho/metalangle/actions?query=branch%3Amaster)

This is a fork of Google's [ANGLE project](https://chromium.googlesource.com/angle/angle). It adds Metal API backend support.
Apple announced OpenGL (ES) deprecation in 2018. So the purpose of MetalANGLE is to allow OpenGL ES applications
Expand All @@ -23,13 +23,13 @@ Preliminary Metal based WebGL benchmarks (based on [gles3-dev branch](https://gi
- [x] MSAA.
- [x] Multiple render targets.
- [x] 3D, array, shadow textures.
- [x] Texture swizzles.
- [x] Texture swizzles (__supported on iOS 13.0+, macOS 10.15+ only__).
- [x] Uniform buffers.
- [x] Fence sync.
- [x] Fence sync (__supported on iOS 12.0+, macOS 10.14+ only__).
- [x] Pixel buffer objects.
- [ ] Primitive Restart. Metal's primitive restart doesn't work reliably.
- [ ] Flat shading with last provoking vertex. Metal's default is first provoking vertex.
- [ ] Transform feedbacks.
- [x] Transform feedbacks.
- __OpenGL ES 1.0__ is not recommended to be used. Its implementation is not actively maintained by
original `ANGLE` project and currently buggy/not fully compliant.
- All basic samples are working.
Expand Down
35 changes: 34 additions & 1 deletion extensions/EGL_MGL_texture_client_buffer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Dependencies

Overview

This extension allows creating EGL surfaces from external metal/native OpenGL texture objects.
This extension allows creating EGL surfaces/images from external metal/native OpenGL texture
objects.

New Types

Expand All @@ -50,11 +51,43 @@ New Tokens
EGL_MTL_TEXTURE_MGL 0x3456
EGL_GL_TEXTURE_MGL 0x3457

Accepted in the <target> parameter of eglCreateImageKHR:

EGL_MTL_TEXTURE_MGL 0x3456

Accepted in the <attrib_list> parameter of eglCreatePbufferFromClientBuffer:

EGL_TEXTURE_TYPE_ANGLE 0x345C
EGL_TEXTURE_INTERNAL_FORMAT_ANGLE 0x345D

Additions to Chapter 2 of the EGL 1.2 Specification (EGL Operation)

Add to section 2.5.1 "EGLImage Specification" (as defined by the
EGL_KHR_image_base specification), in the description of
eglCreateImageKHR:

"Values accepted for <target> are listed in Table aaa, below.

+----------------------------+-----------------------------------------+
| <target> | Notes |
+----------------------------+-----------------------------------------+
| EGL_MTL_TEXTURE_MGL | Used for Metal texture objects |
+----------------------------+-----------------------------------------+
Table aaa. Legal values for eglCreateImageKHR <target> parameter

...

If <target> is EGL_MTL_TEXTURE_MGL, <dpy> must be a valid display, <ctx>
must be EGL_NO_CONTEXT, <buffer> must be a pointer to a valid MTLTexture
object (cast into the type EGLClientBuffer), and attributes are ignored.
The width and height of the pbuffer are determined by the width and height
of <buffer>."

If the EGL_ANGLE_device_mtl extension is present, the provided Metal texture
object must have been created by the same Metal device queried from the
display. If these requirements are not met, an EGL_BAD_PARAMETER error is
generated."

Additions to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors)

Replace the last sentence of paragraph 1 of Section 3.5.3 with the
Expand Down
81 changes: 81 additions & 0 deletions extensions/GL_MGL_EGL_image_cube.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Name

MGL_EGL_image_cube

Name Strings

GL_MGL_EGL_image_cube

Contact

Le Hoang Quyen ([email protected])

Contributors

Le Hoang Quyen

Status

Draft

Version

Revision: 0.1

Number

OpenGL ES Extension #XXX

Dependencies

OpenGL ES 2.0 is required.

Requires EGL 1.2 and either the EGL_KHR_image or EGL_KHR_image_base
extensions as well as OES_EGL_image.

This extension is written against the OpenGL ES 2.0 specification and
the OES_EGL_image extension.

Overview

This extension adds functionality to that provided by OES_EGL_image in
order to support cube map EGLImage. It extends the existing
EGLImageTargetTexture2DOES entry point from OES_EGL_image. Render buffers
are not extended to include cube map support.

EGLImage cube map can be created using extended versions of eglCreateImageKHR.
For example, EGL_MGL_mtl_texture_client_buffer can import cube map image native metal textures
on devices where such native textures can be created.

New Procedures and Functions

None.

New Tokens

None.

Additions to Chapter 3 of the OpenGL ES 2.0 Specification

In section 3.8.2 within the specification added by OES_EGL_Image:

"Currently, <target> must be TEXTURE_2D or TEXTURE_CUBE_MAP."

Errors

GL_INVALID_ENUM is generated by EGLImageTargetTexture2DOES if
<target> is not TEXTURE_2D or TEXTURE_CUBE_MAP

GL_INVALID_OPERATION is generated by EGLImageTargetTexture2DOES if:
- <target> is TEXTURE_CUBE_MAP and <image> is not cube map image.
- <target> is TEXTURE_2D and <image> is not 2d image.

Issues

None.

Revision History

Rev. Date Author Changes
---- ---------- -------- -----------------------------------------
0.1 07/30/2020 Quyen Initial draft
2 changes: 1 addition & 1 deletion gni/angle.gni
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ declare_args() {
angle_has_build && ((is_win && !angle_is_winuwp) ||
(is_linux && angle_use_x11 && !is_chromeos) ||
(is_android && ndk_api_level_at_least_26) ||
is_fuchsia || is_ggp || is_mac)
is_fuchsia || is_ggp)
angle_enable_null = true
angle_enable_essl = true
angle_enable_glsl = true
Expand Down
4 changes: 2 additions & 2 deletions include/EGL/egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ extern "C" {
#define EGL_VERSION_1_0 1
typedef unsigned int EGLBoolean;
typedef void *EGLDisplay;
#include <EGL/eglplatform.h>
#include <KHR/khrplatform.h>
#include "eglplatform.h"
#include "../KHR/khrplatform.h"
typedef void *EGLConfig;
typedef void *EGLSurface;
typedef void *EGLContext;
Expand Down
14 changes: 5 additions & 9 deletions include/GLSLANG/ShaderLang.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ const ShCompileOptions SH_EARLY_FRAGMENT_TESTS_OPTIMIZATION = UINT64_C(1) << 55;
// Allow compiler to insert Android pre-rotation code.
const ShCompileOptions SH_ADD_PRE_ROTATION = UINT64_C(1) << 56;

// This flag adds linear depth range mapping to shader on Metal back-end. It is used when Metal's
// auto MTLViewport's depth range mapping on old GPUs is simply a clamp instead of linear map. Thus,
// an emulation in shader is needed.
const ShCompileOptions SH_METAL_EMULATE_LINEAR_DEPTH_RANGE_MAP = UINT64_C(1) << 57;

// Defines alternate strategies for implementing array index clamping.
enum ShArrayIndexClampingStrategy
{
Expand Down Expand Up @@ -793,15 +798,6 @@ extern const char kAtomicCountersBlockName[];
extern const char kLineRasterEmulationPosition[];

} // namespace vk

namespace mtl
{
// Specialization constant to enable GL_SAMPLE_COVERAGE_VALUE emulation.
extern const char kCoverageMaskEnabledConstName[];

// Specialization constant to emulate rasterization discard.
extern const char kRasterizationDiscardEnabledConstName[];
} // namespace mtl
} // namespace sh

#endif // GLSLANG_SHADERLANG_H_
6 changes: 6 additions & 0 deletions include/platform/FeaturesMtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ struct FeaturesMtl : FeatureSetBase
"Turn this feature on to disallow Compute Shader based mipmap generation. Compute Shader "
"based mipmap generation might cause GPU hang on some older iOS devices.",
&members};

Feature emulateDepthRangeMappingInShader = {
"emulate_depth_range_mapping", FeatureCategory::MetalFeatures,
"Enable linear depth range mapping in shader. This is work-around for older GPUs where "
"viewport's depth range is simply a clamp instead of a map",
&members};
};

} // namespace angle
Expand Down
1 change: 1 addition & 0 deletions ios/xcode/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/gen
*xcuser*/
6 changes: 1 addition & 5 deletions ios/xcode/MGLKit/MGLContext+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
#include <EGL/egl.h>

@interface MGLContext () {
// ANGLE won't allow context to be current without surface.
// Create a dummy surface for it using this dummy layer.
CALayer *_dummyLayer;
EGLSurface _dummySurface;
MGLRenderingAPI _renderingApi;
MGLDisplay *_display;
}

@property(nonatomic, readonly) MGLDisplay *display;
@property(nonatomic, readonly) EGLContext eglContext;

@end
Expand Down
Loading