kakashidinho / metalangle Goto Github PK
View Code? Open in Web Editor NEWMetalANGLE: OpenGL ES to Metal API translation layer
License: Other
MetalANGLE: OpenGL ES to Metal API translation layer
License: Other
Hi @kakashidinho, thanks so much for your work on this project!
I'm trying to replace openGL with MetalANGLE on a tvOS project. First I tried simply to import MetalANGLE.framework into my project. It kept throwing "image not found" errors, until I realized I need to embed/codesign the framework into the product.
Once I was able to start my app, I changed my getProcAddr
to use com.google.OpenGLES
static void *glGetProcAddr(const char *name) {
CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII);
void *addr = CFBundleGetFunctionPointerForName(CFBundleGetBundleWithIdentifier(CFSTR("com.google.OpenGLES")), symbolName);
CFRelease(symbolName);
return addr;
}
Now I can call for example glGetProcAddr("glGetString")
and get a valid address. I checked in the debugger, and confirmed I'm getting an address from inside MetalANGLE:
(const GLubyte *(*)(GLenum)) $2 = 0x0000000103e202cc (MetalANGLE`::glGetString(GLenum) at libGLESv2_autogen.cpp:448:12)
Next I tried to run glGetString(GL_VERSION)
, but I only get back NULL
. Same thing with GL_EXTENSIONS
. What am I doing wrong?
(lldb) p glGetString(0x1F02)
(const GLubyte *) $3 = 0x0000000000000000 <no value available>
(lldb) p glGetString(0x3055)
(const GLubyte *) $4 = 0x0000000000000000 <no value available>
I seem to get a crash every time when I change my device orientation. The crash message is following (in MGLKitSampleApp):
-[MTLDebugRenderCommandEncoder setScissorRect:]:2702: failed assertion `(rect.x(0) + rect.width(2048))(2048) must be <= render pass width(1536)'
It seems that some internal state synchronisation is missing when the frame buffer size changes. I hit the same issue with my own tests also. I am testing using iPad Air 2, iOS 13.3.1.
FATAL: writeInt(189): ! Assert failed in writeInt (src/libANGLE/BinaryStream.h:189): angle::IsValueInRangeForNumericType<int>(param)
from here:
metalangle/src/libANGLE/renderer/metal/ProgramMtl.mm
Lines 525 to 528 in 78017f0
metalangle/src/libANGLE/BinaryStream.h
Lines 186 to 192 in 78017f0
(lldb) bt
frame #0: 0x0000000101bab268 gl::LogMessage::~LogMessage(this=0x000000016eedb848) at debug.cpp:179:13
frame #1: 0x0000000101baaba0 gl::LogMessage::~LogMessage(this=0x000000016eedb848) at debug.cpp:155:1
frame #2: 0x0000000101849160 void gl::BinaryOutputStream::writeInt<unsigned int>(this=0x000000016eedc170, param=4196274272) at BinaryStream.h:189:9
* frame #3: 0x000000010210c0b4 rx::ProgramMtl::saveShaderInternalInfo(this=0x0000000106078a00, stream=0x000000016eedc170) at ProgramMtl.mm:527:21
frame #4: 0x000000010210bf38 rx::ProgramMtl::save(this=0x0000000106078a00, context=0x0000000106030400, stream=0x000000016eedc170) at ProgramMtl.mm:286:5
frame #5: 0x0000000101834f24 gl::Program::serialize(this=0x0000000106863e00, context=0x0000000106030400, binaryOut=0x000000016eedc360) const at Program.cpp:5131:15
frame #6: 0x0000000101833d28 gl::Program::saveBinary(this=0x0000000106863e00, context=0x0000000106030400, binaryFormat=0x0000000000000000, binary=0x0000000000000000, bufSize=2147483647, length=0x000000016eedc530) const at Program.cpp:1921:5
frame #7: 0x0000000101835208 gl::Program::getBinaryLength(this=0x0000000106863e00, context=0x0000000106030400) const at Program.cpp:1967:9
frame #8: 0x0000000101642ab4 gl::QueryProgramiv(context=0x0000000106030400, program=0x0000000106863e00, pname=34625, params=0x000000016eedcbdc) at queryutils.cpp:1203:38
frame #9: 0x00000001015eee98 gl::Context::getProgramiv(this=0x0000000106030400, program=(value = 1), pname=34625, params=0x000000016eedcbdc) at Context.cpp:6223:5
frame #10: 0x0000000101393384 gl::GetProgramiv(program=1, pname=34625, params=0x000000016eedcbdc) at entry_points_gles_2_0_autogen.cpp:1509:22
(lldb) p shaderType
(gl::ShaderType) $0 = Geometry
(lldb) p uboBinding
(uint32_t) $1 = 4196274272
(lldb) p (int)uboBinding
(int) $2 = -98693024
(lldb) p mMslShaderTranslateInfo[shaderType].actualUBOBindings
(std::__1::array<unsigned int, 24>) $3 = {
__elems_ = {
[0] = 72575872
[1] = 983040
[2] = 34340864
[3] = 30212096
[4] = 57409536
[5] = 4196274272
[6] = 67179992
[7] = 983040
[8] = 34471936
[9] = 29622272
[10] = 58195968
[11] = 4199699584
[12] = 61530888
[13] = 983040
[14] = 34209792
[15] = 29491200
[16] = 59113472
[17] = 4203462736
[18] = 56277328
[19] = 983040
[20] = 34078720
[21] = 29097984
[22] = 60555264
[23] = 4207381552
}
}
I'm trying to use the standard (non-Xcode) compilation process for building ANGLE, but I'm hitting an error I'm not sure how to work around. I've followed the Dev Setup instructions with both the gles3
and gles3-dev
branches, and in both cases, the ninja build is almost complete when this appears:
ninja: Entering directory `out/Debug'
[2256/2266] LINK ./angle_perftests
FAILED: angle_perftests
TOOL_VERSION=1586137043 ../../build/toolchain/mac/linker_driver.py -Wcrl,strippath,/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip ../../third_party/llvm-build/Release+Asserts/bin/clang++ -B /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ -Wl,-fatal_warnings -stdlib=libc++ -arch x86_64 -segprot PROTECTED_MEMORY rw r -Werror -isysroot ../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.13 -Wl,-ObjC -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -o "./angle_perftests" -Wl,-filelist,"./angle_perftests.rsp" ./libangle_util.dylib -framework IOKit -framework CoreFoundation -framework CoreGraphics -framework OpenGL
Undefined symbols for architecture x86_64:
"angle::IsMetalRendererAvailable()", referenced from:
angle::IsConfigWhitelisted(angle::SystemInfo const&, angle::PlatformParameters const&) in angle_test_instantiate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Traceback (most recent call last):
File "../../build/toolchain/mac/linker_driver.py", line 287, in <module>
Main(sys.argv)
File "../../build/toolchain/mac/linker_driver.py", line 97, in Main
subprocess.check_call(compiler_driver_args, env=env)
File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 190, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['../../third_party/llvm-build/Release+Asserts/bin/clang++', '-B', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/', '-Wl,-fatal_warnings', '-stdlib=libc++', '-arch', 'x86_64', '-segprot', 'PROTECTED_MEMORY', 'rw', 'r', '-Werror', '-isysroot', '../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk', '-mmacosx-version-min=10.13', '-Wl,-ObjC', '-Wl,-rpath,@loader_path/.', '-Wl,-rpath,@loader_path/../../..', '-o', './angle_perftests', '-Wl,-filelist,./angle_perftests.rsp', './libangle_util.dylib', '-framework', 'IOKit', '-framework', 'CoreFoundation', '-framework', 'CoreGraphics', '-framework', 'OpenGL']' returned non-zero exit status 1
[2257/2266] LINK ./angle_end2end_tests
ninja: build stopped: subcommand failed.
Any ideas? Thanks!
Hi,
First of all thanks for your work.
I should port a project which needs the retained backing feature, so I started with the MGLPaint sample as a reference.
I faced two issues:
Iβm testing on simulators and the app only displays its content on version 13.+. Blank screen on previous versions.
If you enable GL_SCISSOR_TEST inside the rendering function (and donβt disable it before the [glLayer present] call) the screen flickers apparently mixing buffer contents.
To reproduce the problem you can modify PaintView.mm inside the MGLPaint project this way:
Change the background color inside the erase function (for example set it to red);
Add something like
glEnable(GL_SCISSOR_TEST);
glScissor(backingWidth / 4, backingHeight / 4, backingWidth / 2, backingHeight / 2);
after
[MGLContext setCurrentContext:context forLayer:glLayer];
at the beginning of renderLineFromPoint
You will see the screen flickering while drawing something.
Regards.
Luca.
Can you please kindly confirm whether the following is correct (or not) esp. point 2?
1.) The calling application should include#include <MetalANGLE/GLES3/gl3.h> and link against MetalANGLE.framework
2.) The calling application should NOT link against Metal.Framework and OpenGlES.framework. <== Can you please confirm this?This would ensure that all gl* calls resolve with Metal.Framework, which would internally dispatch them to either opengl or metal
Question regarding calling using function pointers
I have a current application that makes opengl calls using function pointers.
On iOS these are initialized like this.
void (* const glBindBuffer)(GLenum, GLuint) = ::glBindBuffer
On desktop these are initialized like this.
void (* const glBindBuffer)(GLenum, GLuint) = [](auto... args) {
return QOpenGLContext::currentContext()->functions()->glBindBuffer(args...);
};
_If I like the application only against Metal.Framework, would all the gl functions resolve correctly at link time?_*
When using GLKit one has to use the native scale (the property UIScreen.main.nativeScale in Swift) and not the ordinary scale (UIScreen.main.scale) to avoid the view being cropped on iPhones when the user has selected zoomed display (Settings > Display & Brightness > Display Zoom > Set to Zoomed). This scale is used when converting to OpenGL coordinates in my test app.
However, the issue does not arise when using MetalANGLE. When I use MetalANGLE I can use UIScreen.main.scale at all times, whether or not the display is zoomed. I am not complaining ( am a very happy user of MetalANGLE), and it will be easy to explain the change to my users when moving to MetalANGLE, but it is an inconsistency between the two systems and there is therefore a case for removing the inconsistency.
For clarity, please note that this issue refers to display zoom (Settings > Display & Brightness > Display Zoom ) not zooming in for accessibility (Settings > Accessibility > Zoom).
I'm trying to create a Framebuffer that uses RBOs.
The code that works on Windows results on my Mac in GL_FRAMEBUFFER_UNSUPPORTED when I check the framebuffer status.
Here is how I create everything:
glGenRenderbuffers(1, &_rbo);
glBindRenderbuffer(GL_RENDERBUFFER, _rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, width, height);
In Dart I use that RBO to connect it to a framebuffer:
rawOpenGl.glGenFramebuffers(1, fbo);
rawOpenGl.glBindFramebuffer(GL_FRAMEBUFFER, fbo.value);
final newTexture = FlutterGLTexture.fromMap(result, fbo.value, width, height);
print(rawOpenGl.glGetError());
rawOpenGl.glBindRenderbuffer(GL_RENDERBUFFER, newTexture.rboId);
rawOpenGl.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, newTexture.rboId);
var frameBufferCheck = rawOpenGl.glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (frameBufferCheck != GL_FRAMEBUFFER_COMPLETE) {
print("Framebuffer (color) check failed: ${frameBufferCheck.toRadixString(16)}");
}
Pointer<Int32> depthBuffer = calloc();
rawOpenGl.glGenRenderbuffers(1, depthBuffer.cast());
rawOpenGl.glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer.value);
if (Platform.isMacOS || Platform.isIOS) {
rawOpenGl.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
} else {
rawOpenGl.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
}
rawOpenGl.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer.value);
frameBufferCheck = rawOpenGl.glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (frameBufferCheck != GL_FRAMEBUFFER_COMPLETE) {
print("Framebuffer (depth) check failed: ${frameBufferCheck.toRadixString(16)}");
}
Attaching the ColorAttachment works, but as soon as I try to attach a depth attachment I get this error.
I tried different values for glRenderbufferStorage
but without any success.
Any idea what could be wrong?
Thanks a lot!
First of all, thank you very much for this project, could save a lot of opensource softwares and frameworks in the near future from Apple's OpenGLES-geddon!
I've started to migrate a Open Source framework for iOS
from OpenGLES
to MetalANGLE
, and at this time is gone quite smooth.
Unfortunately, some symbols seems to be undefined for me, starting from the -OES
ones:
_glBlendEquationOES
_glBlendEquationSeparateOES
_glBlendFuncSeparateOES
I've seen that the -OES
functions seems to be managed by the GL_GLEXT_PROTOTYPES
.
Hi,
I'm trying to add metalangle to a Pod for MacOS. I first tried to add the .framework file but wasn't able to access any of the headers of the framework. Not sure why. So I took all the library .a files and added them and flattened some of the includes so that I finally could access egl.h from my objective c file. But when I try to call any EGL function starting with a simple
void* display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
I get an EXC_BAD_ACCESS exception. Any idea what the problem could be? I only want to do off-screen rendering, so I don't need access to a real display.
I'm currently working on an M1 Mac with Rosetta, maybe that is a problem although I can run the MGLKitSampleApp with Rossetta.
Any help is highly appreciated :-)
I tried gl:RenderbufferStorge to add my own renderbuffer, however the image is not displayed successfully.
Hello and thank you for working on this framework.
I am not the smartest guy when it comes to OSX and IOS development but I am in charge to maintaining development targets for a cross platform development tool at https://www.cerberus-x.com. We have targets for OSX and IOS and use opengles 2.0 there. So MetalAngle would be an awesome solution for us.
I downloaded and build the examples which run fine. Now I am trying to integrate the metalangle.framework into our xcode project. I am confused, that the framework that was created is located in a temporary folder with the name DEBUG in its path.
Is that correct that there is no separate RELEASE version?
Hi,
I made good progress as you can see here in the current master https://github.com/FlutterGL/flutter_web_gl
But I have a little problem, that is that the pixel format that MacOS accepts in a CVPixelBufferCreate
is kCVPixelFormatType_32BGRA
while all in OpenGL is RGBA which leads to rather funny colors.
Unfortunately the OpenGL ES standard doesn't contain color format conversion in glReadPixels
and I can't create a Renderbuffer in BGRA
in OpenGL. Any idea how this could be easily solved?
ChΓ o bαΊ‘n! MΓ¬nh rαΊ₯t αΊ₯n tượng vα» dα»± Γ‘n của bαΊ‘n vΓ cΓ ng αΊ₯n tượng hΖ‘n khi bαΊ‘n lΓ ngΖ°α»i Viα»t! MΓ¬nh ΔΓ£ thΓ nh cΓ΄ng trong viα»c port Minecraft Java qua iOS (thΓ΄ng qua mα»t lα»p dα»ch nα»―a lΓ GL4ES: OpenGL 2.x -> OpenGL ES). NhΖ°ng thΓ΄ng qua nhiα»u lα»p dα»ch thΓ¬ game khΓ‘ lag :( (Γt nhαΊ₯t lΓ trΓͺn CPU A9/10)
NαΊΏu bαΊ‘n giα»i α» Δα» hα»a, bαΊ‘n cΓ³ kαΊΏ hoαΊ‘ch nΓ o cho Desktop OpenGL -> Metal khΓ΄ng? MΓ¬nh thαΊ₯y trong ANGLE cΕ©ng cΓ³ cung cαΊ₯p sαΊ΅n mα»t bα» API lΓͺn tαΊn GL 4.6 (src/libGL) mΓ toΓ n lΓ βstubβ.
Ngoà i ra, có 1 giải phÑp ngoà i lỠlà Zink (Gallium Driver của Mesa) -> MoltenVK -> Metal. Nhưng chắc Mesa không hỠtrợ iOS...
HoαΊ·c bαΊ‘n cΓ³ thα» dΓ nh chΓΊt thα»i gian cα»ng hiαΊΏn tΓ i nΔng của bαΊ‘n qua GL4ES khΓ΄ng? π Hiα»n tαΊ‘i GL4ES chα» hα» trợ OpenGL 2.1 vΓ shader thΓ¬ cΕ©ng rαΊ₯t giα»i hαΊ‘n.
CαΊ£m Ζ‘n nhiα»u!
I got this warning several times in the debugger console when using the iOS build of MetalANGLE on my iPhone 11:
[Metal Compiler Warning] Warning: Compilation succeeded with:
program_source:59:12: warning: unused variable 'flippedFragCoord'
float4 flippedFragCoord;
Otherwise everything worked perfectly, but I think the variable ought to be removed if possible.
Hi, thanks for great work.
I am making a game application for iOS devices with metalangle MetalANGLE framework, and need to implement animation sequence during launch.
When the app is launching, especially entered into main interface and the View created by controller which inherited MGLKViewController appears, it always shows with the sizing animation from left-top of the screen.
Also, background area not yet covered by the view has black color eventhough the background color of the view(root view of main storyboard scene) have been set as another color.
I tried to change this transition effect via setting transition style and presentation properties in XCode's storyboard editor, or even in code, but it doesn't work.
Is it possible to change or turn off transition animations of MGLKViewController's presentation?
I look forward to hearing from you a way to do it.
Hi, I tried to upload an App that uses MetalANGLE.framework
to the Apple App Store, but this error is thrown.
ITMS-90338: Non-public API usage
- The app links to non-public libraries in Frameworks/MetalANGLE.framework/MetalANGLE:
/System/Library/PrivateFrameworks/IOSurface.framework/IOSurface.
If method names in your source code match the private Apple APIs listed above,
altering your method names will help prevent this app from being flagged
in future submissions.
In addition, note that one or more of the above APIs may be located in a static library that was included with your app.
If so, they must be removed.
For further information, visit the Technical Support Information at http://developer.apple.com/support/technical/
I just tried metalAngle and it's awesome!
It simply worked, I'm probably going to use it in my current project.
Minor issue 1
At the moment I had to expose the pause
and resume
functions publicly to allow for on demand rendering.
Did you manage to halt the rendering loop only with enableSetNeedsDisplay
and by using MGLKViewController
?
With the GLKViewController, I was simply switching the paused
attribute since enableSetNeedsDisplay
was ignored (or automatically disabled internally).
I think enableSetNeedsDisplay
is meant to be used with View only, not with ViewController.
But I'm not an iOS expert, so take my remark with a pinch of salt :).
https://developer.apple.com/documentation/metalkit/mtkview/1535973-paused?language=objc
https://developer.apple.com/documentation/glkit/glkviewcontroller/1620712-paused?language=objc
Minor issue 2
In my code, I had to comment a call on glDebugMessageCallback
because it was crashing.
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(errorCallback, 0);
Maybe the problem is with my setup.
I'm using GLAD as an extension loader and it successfully report GL_KHR_debug
as supported.
I have a Mac program linked to MetalAngle.framework (latest master branch) running on Catalina 10.15.7 with Xcode 12.2 on a 2019 MBP 16 and keep getting this fatal shader compile error:
Internal error compiling Metal shader:
Compilation failed:
program_source:35:48: error: 'function_constant' attribute requires Metal language standard macos-metal1.2 or higher
constant bool ANGLERasterizationDisabled_tmp [[function_constant(0)]];
What does it mean? Do I need to upgrade to Big Sur or downgrade my Xcode?
It's quite hard to explain this without being able to create an MRP. But I'll try. (This is for a GL ES 3 app running on iOS.)
In the project I'm integrating MetalANGLE with, I run across a situation when after a change of shader, the Metal pipeline was left in an inconsistent state: it had a buffer from the last state (when another shader was bound) that was not needed anymore so other buffers were "offset" by one place.
With that situation, even though there still was an 80-byte buffer to hold some uniform data, it wasn't the one such data was assigned too, but to another (the one that should have gone away from the previous pipeline state), which was smaller. Metal validation would complain.
The workaround for me was this (has worked perfectly for the time being, without causing any regressions):
angle::Result ContextMtl::setupDraw(...)
{
// [...]
case DIRTY_BIT_RENDER_PIPELINE:
// Already handled. See checkIfPipelineChanged().
uniformBuffersDirty = true; // <--- This line is added by me
break;
// [...]
I'm not opening a PR because I believe this is a hacky workaround rather than a proper fix. I haven't had time to investigate the exact point in the pipeline bookkeeping logic where it should realize the need for the change.
The iOS sample runs great when using older iOS simulator versions (tested with 12.0 and 11.0), but crashes in RenderUtils::initClearResources():
The crash is really a failed assert (fragmentShader
is null). The error returned from corresponding newFunctionWithName
is following:
Error Domain=MTLLibraryErrorDomain Code=3 "Target OS is incompatible: library was not compiled for the simulator" UserInfo={NSLocalizedDescription=Target OS is incompatible: library was not compiled for the simulator}
Am I doing anything wrong or is there a compatibility issue with latest iOS versions?
You can observe this in wezterm with a nightly build from here: https://github.com/wez/wezterm/releases/download/nightly/WezTerm-macos-nightly.zip
What happens is that when the window is resized, the size of the layer seems to be slightly out of sync with the new window size and that results in a series of brief moments where the content is scaled to the window size, making the text in the terminal appear to "wobble" or "ripple" until it catches up.
If I switch the application back to CGL, this wobble effect is eliminated.
Is there something that I should add to my application logic to force things to be more closely in sync?
FWIW, I also observe a similar effect with ANGLE and Direct3D on Windows, so this may not be strictly MetalANGLE specific.
Hi,
any idea why the call to glReadPixels
never comes back?
glBindFramebuffer(GL_FRAMEBUFFER, currentTexture.fbo);
CVPixelBufferLockBaseAddress([currentTexture pixelData], 0);
void* buffer = (void*)CVPixelBufferGetBaseAddress([currentTexture pixelData]);
glReadPixels(0, 0, (GLsizei)[currentTexture width], (GLsizei)currentTexture.height, GL_RGBA, GL_UNSIGNED_BYTE, (void*)buffer);
CVPixelBufferUnlockBaseAddress([currentTexture pixelData],0);
The project currently requires iOS version 11+. I guess that means that MetalANGLE is implemented using Metal 2. Is there any way to support older iOS versions? I think MoltenGL does this by dispatching GL calls to Apple GLES implementation on older devices. Would this be feasible to add? Thanks.
Terminating app due to uncaught exception 'CAMetalLayerInvalid', reason: 'invalid pixel format 70'
It happen only on my MBP.
Occurs in :
https://github.com/kakashidinho/metalangle/blob/master/src/libANGLE/renderer/metal/SurfaceMtl.mm#L246
kDefaultFrameBufferColorFormatId = angle::FormatID::B8G8R8A8_UNORM;
mColorFormat = display->getPixelFormat(kDefaultFrameBufferColorFormatId);
mColorFormat.metalFormat = MTLPixelFormatRGBA8Unorm;
Should be MTLPixelFormatBGRA8Unorm
mPixelFormatTable initialisation is setting the wrong value :
https://github.com/kakashidinho/metalangle/blob/master/src/libANGLE/renderer/metal/mtl_format_table_autogen.mm#L46
the conversion should always return MTLPixelFormatBGRA8Unorm
I have reported this in the main ANGLE bug tracker, since, in case I'm right, both sides need to do changes: https://bugs.chromium.org/p/angleproject/issues/detail?id=4953#c1
Quoting it here:
What steps will reproduce the problem?
What is the expected output? What do you see instead?
The expectation is that -1 is handled gracefully.
What happens is a crash.
What version of the product are you using? On what operating system?
MetalANGLE commit 1964ec0 on iOS (iPhone 8).
Please provide any additional information below.
A location of -1 should be handled gracefully by the various implementations of uniform setters (like ProgramMtl::setUniformImpl in MetalANGLE), because, according to the spec, -1 is not an invalid value, but one with a special treatment.
Therefore, even with validation disabled, a crash shouldn't happen.
The validation code may keep checking for -1 but returning true instead of false because it's valid.
Keeping the current behavior of it returning false may work as an optimization since the -1 is known not to have any effect anyway when passed to the uniform setter)
We have successfully used MetalAngle in MapLibre iOS library. We have problem with our unit tests which are using MGLKit - if we run them locally on macos, they pass but of we run them on GitHub macos runner (tried 10.15 and 11.0) they fail with exception Failed To call eglInitialize()
- the related code in MetalAngle is here
Is this a known problem? Any hints what needs to be done?
The error log indicated that not writing to color attachment is illegal.
The current depth & stencil blit shader doesn't output anything to color attachment (the color attachment has write mask=none).
Hi,
We can now compile and access the EGL without problems.
I try to initialize EGL on a Mac like:
_display = eglGetDisplay();
final initializeResult = eglInitialize(_display);
debugPrint('EGL version: $initializeResult');
final chooseConfigResult = eglChooseConfig(
_display,
attributes: {
EglConfigAttribute.renderableType: EglValue.openglEs3Bit.toIntValue(),
EglConfigAttribute.redSize: 8,
EglConfigAttribute.greenSize: 8,
EglConfigAttribute.blueSize: 8,
EglConfigAttribute.alphaSize: 8,
EglConfigAttribute.depthSize: 16,
},
maxConfigs: 1,
);
_config = chooseConfigResult[0];
final existingConfigs = eglGetConfigs(_display, maxConfigs: 50);
print('Number of configs ${existingConfigs.length}');
for (int i = 0; i < existingConfigs.length; i++) {
print('\nConfig No: $i');
printConfigAttributes(_display, existingConfigs[i]);
}
_pluginContext = eglCreateContext(
_display,
_config,
contextClientVersion: 3,
);
/// we link both contexts so that app and plugin can share OpenGL Objects
shareContext: returnedPluginContext,
contextClientVersion: 3,
isDebugContext: debug);
/// to make a context current you have to provide some texture even if you don't use it afterwards
_dummySurface = eglCreatePbufferSurface(_display, _config, attributes: {
EglSurfaceAttributes.width: 16,
EglSurfaceAttributes.height: 16,
});
At this point I get an EGL-Error EGL_BAD_MATCH
When I query the possible configs I get:
Launching lib/main.dart on macOS in debug mode...
Connecting to VM Service at ws://127.0.0.1:51158/kyi1pq33GNI=/ws
flutter: EGL version: 1.4
flutter: Number of configs 8
flutter:
Config No: 0
flutter: EglConfigAttribute.alphaMaskSize: 0
flutter: EglConfigAttribute.alphaSize: 8
flutter: EglConfigAttribute.bindToTextureRgb: 0
flutter: EglConfigAttribute.bindToTextureRgba: 0
flutter: EglConfigAttribute.blueSize: 8
flutter: EglConfigAttribute.bufferSize: 32
flutter: EglConfigAttribute.colorBufferType: 12430
flutter: EglConfigAttribute.configCaveat: 12344
flutter: EglConfigAttribute.configId: 4
flutter: EglConfigAttribute.conformant: 68
flutter: EglConfigAttribute.depthSize: 0
flutter: EglConfigAttribute.greenSize: 8
flutter: EglConfigAttribute.level: 0
flutter: EglConfigAttribute.luminanceSize: 0
flutter: EglConfigAttribute.matchNativePixmap: 0
flutter: EglConfigAttribute.nativeRenderable: 1
flutter: EglConfigAttribute.maxSwapInterval: 1
flutter: EglConfigAttribute.minSwapInterval: 0
flutter: EglConfigAttribute.redSize: 8
flutter: EglConfigAttribute.sampleBuffers: 0
flutter: EglConfigAttribute.samples: 0
flutter: EglConfigAttribute.stencilSize: 0
flutter: EglConfigAttribute.renderableType: 69
flutter: SurfaceType: EGL_SWAP_BEHAVIOR_PRESERVED_BIT, EGL_WINDOW_BIT,
flutter: EglConfigAttribute.transparentType: 12344
flutter: EglConfigAttribute.transparentRedValue: 0
flutter: EglConfigAttribute.transparentGreenValue: 0
flutter: EglConfigAttribute.transparentBlueValue: 0
flutter:
Config No: 1
flutter: EglConfigAttribute.alphaMaskSize: 0
flutter: EglConfigAttribute.alphaSize: 8
flutter: EglConfigAttribute.bindToTextureRgb: 0
flutter: EglConfigAttribute.bindToTextureRgba: 0
flutter: EglConfigAttribute.blueSize: 8
flutter: EglConfigAttribute.bufferSize: 32
flutter: EglConfigAttribute.colorBufferType: 12430
flutter: EglConfigAttribute.configCaveat: 12344
flutter: EglConfigAttribute.configId: 3
flutter: EglConfigAttribute.conformant: 68
flutter: EglConfigAttribute.depthSize: 0
flutter: EglConfigAttribute.greenSize: 8
flutter: EglConfigAttribute.level: 0
flutter: EglConfigAttribute.luminanceSize: 0
flutter: EglConfigAttribute.matchNativePixmap: 0
flutter: EglConfigAttribute.nativeRenderable: 1
flutter: EglConfigAttribute.maxSwapInterval: 1
flutter: EglConfigAttribute.minSwapInterval: 0
flutter: EglConfigAttribute.redSize: 8
flutter: EglConfigAttribute.sampleBuffers: 0
flutter: EglConfigAttribute.samples: 0
flutter: EglConfigAttribute.stencilSize: 8
flutter: EglConfigAttribute.renderableType: 69
flutter: SurfaceType: EGL_SWAP_BEHAVIOR_PRESERVED_BIT, EGL_WINDOW_BIT,
flutter: EglConfigAttribute.transparentType: 12344
flutter: EglConfigAttribute.transparentRedValue: 0
flutter: EglConfigAttribute.transparentGreenValue: 0
flutter: EglConfigAttribute.transparentBlueValue: 0
flutter:
Config No: 2
flutter: EglConfigAttribute.alphaMaskSize: 0
flutter: EglConfigAttribute.alphaSize: 8
flutter: EglConfigAttribute.bindToTextureRgb: 0
flutter: EglConfigAttribute.bindToTextureRgba: 0
flutter: EglConfigAttribute.blueSize: 8
flutter: EglConfigAttribute.bufferSize: 32
flutter: EglConfigAttribute.colorBufferType: 12430
flutter: EglConfigAttribute.configCaveat: 12344
flutter: EglConfigAttribute.configId: 2
flutter: EglConfigAttribute.conformant: 68
flutter: EglConfigAttribute.depthSize: 24
flutter: EglConfigAttribute.greenSize: 8
flutter: EglConfigAttribute.level: 0
flutter: EglConfigAttribute.luminanceSize: 0
flutter: EglConfigAttribute.matchNativePixmap: 0
flutter: EglConfigAttribute.nativeRenderable: 1
flutter: EglConfigAttribute.maxSwapInterval: 1
flutter: EglConfigAttribute.minSwapInterval: 0
flutter: EglConfigAttribute.redSize: 8
flutter: EglConfigAttribute.sampleBuffers: 0
flutter: EglConfigAttribute.samples: 0
flutter: EglConfigAttribute.stencilSize: 0
flutter: EglConfigAttribute.renderableType: 69
flutter: SurfaceType: EGL_SWAP_BEHAVIOR_PRESERVED_BIT, EGL_WINDOW_BIT,
flutter: EglConfigAttribute.transparentType: 12344
flutter: EglConfigAttribute.transparentRedValue: 0
flutter: EglConfigAttribute.transparentGreenValue: 0
flutter: EglConfigAttribute.transparentBlueValue: 0
flutter:
Config No: 3
flutter: EglConfigAttribute.alphaMaskSize: 0
flutter: EglConfigAttribute.alphaSize: 8
flutter: EglConfigAttribute.bindToTextureRgb: 0
flutter: EglConfigAttribute.bindToTextureRgba: 0
flutter: EglConfigAttribute.blueSize: 8
flutter: EglConfigAttribute.bufferSize: 32
flutter: EglConfigAttribute.colorBufferType: 12430
flutter: EglConfigAttribute.configCaveat: 12344
flutter: EglConfigAttribute.configId: 1
flutter: EglConfigAttribute.conformant: 68
flutter: EglConfigAttribute.depthSize: 24
flutter: EglConfigAttribute.greenSize: 8
flutter: EglConfigAttribute.level: 0
flutter: EglConfigAttribute.luminanceSize: 0
flutter: EglConfigAttribute.matchNativePixmap: 0
flutter: EglConfigAttribute.nativeRenderable: 1
flutter: EglConfigAttribute.maxSwapInterval: 1
flutter: EglConfigAttribute.minSwapInterval: 0
flutter: EglConfigAttribute.redSize: 8
flutter: EglConfigAttribute.sampleBuffers: 0
flutter: EglConfigAttribute.samples: 0
flutter: EglConfigAttribute.stencilSize: 8
flutter: EglConfigAttribute.renderableType: 69
flutter: SurfaceType: EGL_SWAP_BEHAVIOR_PRESERVED_BIT, EGL_WINDOW_BIT,
flutter: EglConfigAttribute.transparentType: 12344
flutter: EglConfigAttribute.transparentRedValue: 0
flutter: EglConfigAttribute.transparentGreenValue: 0
flutter: EglConfigAttribute.transparentBlueValue: 0
flutter:
Config No: 4
flutter: EglConfigAttribute.alphaMaskSize: 0
flutter: EglConfigAttribute.alphaSize: 8
flutter: EglConfigAttribute.bindToTextureRgb: 0
flutter: EglConfigAttribute.bindToTextureRgba: 0
flutter: EglConfigAttribute.blueSize: 8
flutter: EglConfigAttribute.bufferSize: 32
flutter: EglConfigAttribute.colorBufferType: 12430
flutter: EglConfigAttribute.configCaveat: 12344
flutter: EglConfigAttribute.configId: 8
flutter: EglConfigAttribute.conformant: 68
flutter: EglConfigAttribute.depthSize: 0
flutter: EglConfigAttribute.greenSize: 8
flutter: EglConfigAttribute.level: 0
flutter: EglConfigAttribute.luminanceSize: 0
flutter: EglConfigAttribute.matchNativePixmap: 0
flutter: EglConfigAttribute.nativeRenderable: 1
flutter: EglConfigAttribute.maxSwapInterval: 1
flutter: EglConfigAttribute.minSwapInterval: 0
flutter: EglConfigAttribute.redSize: 8
flutter: EglConfigAttribute.sampleBuffers: 1
flutter: EglConfigAttribute.samples: 4
flutter: EglConfigAttribute.stencilSize: 0
flutter: EglConfigAttribute.renderableType: 69
flutter: SurfaceType: EGL_SWAP_BEHAVIOR_PRESERVED_BIT, EGL_WINDOW_BIT,
flutter: EglConfigAttribute.transparentType: 12344
flutter: EglConfigAttribute.transparentRedValue: 0
flutter: EglConfigAttribute.transparentGreenValue: 0
flutter: EglConfigAttribute.transparentBlueValue: 0
flutter:
Config No: 5
flutter: EglConfigAttribute.alphaMaskSize: 0
flutter: EglConfigAttribute.alphaSize: 8
flutter: EglConfigAttribute.bindToTextureRgb: 0
flutter: EglConfigAttribute.bindToTextureRgba: 0
flutter: EglConfigAttribute.blueSize: 8
flutter: EglConfigAttribute.bufferSize: 32
flutter: EglConfigAttribute.colorBufferType: 12430
flutter: EglConfigAttribute.configCaveat: 12344
flutter: EglConfigAttribute.configId: 7
flutter: EglConfigAttribute.conformant: 68
flutter: EglConfigAttribute.depthSize: 0
flutter: EglConfigAttribute.greenSize: 8
flutter: EglConfigAttribute.level: 0
flutter: EglConfigAttribute.luminanceSize: 0
flutter: EglConfigAttribute.matchNativePixmap: 0
flutter: EglConfigAttribute.nativeRenderable: 1
flutter: EglConfigAttribute.maxSwapInterval: 1
flutter: EglConfigAttribute.minSwapInterval: 0
flutter: EglConfigAttribute.redSize: 8
flutter: EglConfigAttribute.sampleBuffers: 1
flutter: EglConfigAttribute.samples: 4
flutter: EglConfigAttribute.stencilSize: 8
flutter: EglConfigAttribute.renderableType: 69
flutter: SurfaceType: EGL_SWAP_BEHAVIOR_PRESERVED_BIT, EGL_WINDOW_BIT,
flutter: EglConfigAttribute.transparentType: 12344
flutter: EglConfigAttribute.transparentRedValue: 0
flutter: EglConfigAttribute.transparentGreenValue: 0
flutter: EglConfigAttribute.transparentBlueValue: 0
flutter:
Config No: 6
flutter: EglConfigAttribute.alphaMaskSize: 0
flutter: EglConfigAttribute.alphaSize: 8
flutter: EglConfigAttribute.bindToTextureRgb: 0
flutter: EglConfigAttribute.bindToTextureRgba: 0
flutter: EglConfigAttribute.blueSize: 8
flutter: EglConfigAttribute.bufferSize: 32
flutter: EglConfigAttribute.colorBufferType: 12430
flutter: EglConfigAttribute.configCaveat: 12344
flutter: EglConfigAttribute.configId: 6
flutter: EglConfigAttribute.conformant: 68
flutter: EglConfigAttribute.depthSize: 24
flutter: EglConfigAttribute.greenSize: 8
flutter: EglConfigAttribute.level: 0
flutter: EglConfigAttribute.luminanceSize: 0
flutter: EglConfigAttribute.matchNativePixmap: 0
flutter: EglConfigAttribute.nativeRenderable: 1
flutter: EglConfigAttribute.maxSwapInterval: 1
flutter: EglConfigAttribute.minSwapInterval: 0
flutter: EglConfigAttribute.redSize: 8
flutter: EglConfigAttribute.sampleBuffers: 1
flutter: EglConfigAttribute.samples: 4
flutter: EglConfigAttribute.stencilSize: 0
flutter: EglConfigAttribute.renderableType: 69
flutter: SurfaceType: EGL_SWAP_BEHAVIOR_PRESERVED_BIT, EGL_WINDOW_BIT,
flutter: EglConfigAttribute.transparentType: 12344
flutter: EglConfigAttribute.transparentRedValue: 0
flutter: EglConfigAttribute.transparentGreenValue: 0
flutter: EglConfigAttribute.transparentBlueValue: 0
flutter:
Config No: 7
flutter: EglConfigAttribute.alphaMaskSize: 0
flutter: EglConfigAttribute.alphaSize: 8
flutter: EglConfigAttribute.bindToTextureRgb: 0
flutter: EglConfigAttribute.bindToTextureRgba: 0
flutter: EglConfigAttribute.blueSize: 8
flutter: EglConfigAttribute.bufferSize: 32
flutter: EglConfigAttribute.colorBufferType: 12430
flutter: EglConfigAttribute.configCaveat: 12344
flutter: EglConfigAttribute.configId: 5
flutter: EglConfigAttribute.conformant: 68
flutter: EglConfigAttribute.depthSize: 24
flutter: EglConfigAttribute.greenSize: 8
flutter: EglConfigAttribute.level: 0
flutter: EglConfigAttribute.luminanceSize: 0
flutter: EglConfigAttribute.matchNativePixmap: 0
flutter: EglConfigAttribute.nativeRenderable: 1
flutter: EglConfigAttribute.maxSwapInterval: 1
flutter: EglConfigAttribute.minSwapInterval: 0
flutter: EglConfigAttribute.redSize: 8
flutter: EglConfigAttribute.sampleBuffers: 1
flutter: EglConfigAttribute.samples: 4
flutter: EglConfigAttribute.stencilSize: 8
flutter: EglConfigAttribute.renderableType: 69
flutter: SurfaceType: EGL_SWAP_BEHAVIOR_PRESERVED_BIT, EGL_WINDOW_BIT,
flutter: EglConfigAttribute.transparentType: 12344
flutter: EglConfigAttribute.transparentRedValue: 0
flutter: EglConfigAttribute.transparentGreenValue: 0
flutter: EglConfigAttribute.transparentBlueValue: 0
According to https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglCreatePbufferSurface.xhtml
SurfaceType has to include EGL_PBUFFER_BIT
:
EGL_BAD_MATCH is generated if config does not support rendering to pixel buffers (the EGL_SURFACE_TYPE attribute does not contain EGL_PBUFFER_BIT).
Any Idea what the reason could be?
In Xcode I see this in the out put although I'm not sure if it comes from metalAngle or from Flutter
2021-03-08 22:30:23.025224+0100 example[13344:5088015] Metal API Validation Enabled
2021-03-08 22:30:23.186157+0100 example[13344:5088015] CVCGDisplayLink::setCurrentDisplay didn't find a valid display - falling back to 60Hz
flutter: Observatory listening on http://127.0.0.1:50952/Z20j3Mbz84o=/
2021-03-08 22:30:23.736173+0100 example[13344:5088647] [Metal Compiler Warning] Warning: Compilation succeeded with:
program_source:34:12: warning: unused variable '_tmp_1_inPosition'
float2 _tmp_1_inPosition = _in.inPosition;
^
2021-03-08 22:30:23.741058+0100 example[13344:5088647] -[MTLDebugRenderCommandEncoder validateFramebufferWithRenderPipelineState:], line 1288: error 'Framebuffer With Render Pipeline State Validation
For stencil attachment, the render pipeline's pixelFormat (MTLPixelFormatInvalid) does not match the framebuffer's pixelFormat (MTLPixelFormatStencil8).
'
-[MTLDebugRenderCommandEncoder validateFramebufferWithRenderPipelineState:]:1288: failed assertion `Framebuffer With Render Pipeline State Validation
For stencil attachment, the render pipeline's pixelFormat (MTLPixelFormatInvalid) does not match the framebuffer's pixelFormat (MTLPixelFormatStencil8).
'
-[MTLDebugRenderCommandEncoder validateFramebufferWithRenderPipelineState:]:1288: failed assertion `Framebuffer With Render Pipeline State Validation
For stencil attachment, the render pipeline's pixelFormat (MTLPixelFormatInvalid) does not match the framebuffer's pixelFormat (MTLPixelFormatStencil8).
'
(lldb)
Over in https://github.com/wez/wezterm I'm trying out using EGL via metalangle on macOS.
wezterm has existing EGL support on Linux and Windows, and CGL based support for macOS.
When I start wezterm+metalangle on my non-retina monitor, the UI is scaled to half size and sits in the bottom left corner of the window.
If I drag the window on my laptop's retina display, it displays correctly.
It feels like there might be an assumption about DPI/scaling somewhere in metalangle, but I'm not familiar enough to point to exactly where.
I can see that SurfaceMtl.mm looks at the layer.contentsScale to do some sizing math. I wonder if the issue is around there?
In wezterm's CGL implementation I use convertRectToBacking
to determine the physical pixel size and try to avoid letting macOS do any scaling of its own by using setWantsBestResolutionOpenGLSurface
.
Do you have recommendations on how best to use metalangle with non-retina displays?
Hi, I have and OpenGL app using SDL and I will like to try metalangle
I downloaded the MetalANGLE.dylib.mac.zip file but I'm not sure how I'm supposed to use it.
The headers is easy, I just include them, but, what I do with this dylib files?
I should include them all?
After including the headers, and linking the dylib files. Should I do something special to start using OpenGL on the app?
The only thing I can get is a black screen
Not sure if I did something wrong somewhere, but I'm getting
OpenGLES/angle_metal_backend/mtl_glslang_utils.mm:796: No member named 'force_native_arrays' in 'spirv_cross::CompilerMSL::Options'
.
Happens in the master branch since 252f999.
master
branch, OpenGLES.xcodeproj did not open with Xcode 10.1 on High Sierra due to a project version error. Solution: I had to edit OpenGLES.xcodeproj/project.pbxproj
with a text editor and change objectVersion = 52
=> objectVersion = 51
scripts/run_code_generation.py
before compiling the xcodeproj? (perhaps to generate High Sierra-compatible Metal shaders, etc?)Hi!
On the main page it says that multiple render targets are supported, but I when I tried to render to a framebuffer with 4 RGAB32F draw buffers I got this error:
-[MTLRenderPipelineDescriptorInternal validateWithDevice:]:2623: failed assertion `This set of render targets requires 64 bytes of pixel storage. This device supports 16 bytes.'
I tested it on iPad Air with Apple A7 (OS 12.4.9 (16H5)) with using OpenGL ES 3.0 on MetalANGLE.
I looked up the Metal Feature Set Table (https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf) for this chip and found out that it supports only 128bit of maximum total render target size, per pixel, when using multiple color render targets.
So I assume that it does not support natively 4 render targets with RGBA32F format, it can only handle up to 4 render targets with RGBA8 format.
As far as I know, there are no such thing as "maximum total render target size, per pixel, when using multiple color render targets" in OpenGL ES spec. So there is no way to fully support multiple render targets for all texture formats, or am I missing something?
ERR: initialize(609): ANGLE Display::initialize error 12289: Could not create the EAGL context.
ERR: initialize(609): ANGLE Display::initialize error 12289: Could not create the EAGL context.
INFO: insertMessage(462): EGL CRITICAL: eglInitialize: Could not create the EAGL context.
(lldb) bt
(anonymous namespace)::Throw(msg="Failed To call eglInitialize()") at MGLDisplay.mm:13:5 frame #1: 0x002a6c4e MetalANGLE
-[EGLDisplayHolder init](self=0x1654dc20, _cmd="init") at MGLDisplay.mm:37:13-[MGLDisplay init](self=0x165510c0, _cmd="init") at MGLDisplay.mm:82:36 frame #3: 0x002a6f90 MetalANGLE
+[MGLDisplay defaultDisplay](self=MGLDisplay, _cmd="defaultDisplay") at MGLDisplay.mm:71:27-[MGLLayer constructor](self=0x16551ea0, _cmd="constructor") at MGLLayer.mm:351:16 frame #5: 0x0033f444 MetalANGLE
-[MGLLayer init](self=0x16551ea0, _cmd="init") at MGLLayer.mm:330:9-[UIView _createLayerWithFrame:] + 138 frame #7: 0x200b3714 UIKit
UIViewCommonInitWithFrame + 850-[UIView initWithCoder:] + 458 frame #9: 0x00337372 MetalANGLE
-[MGLKView initWithCoder:](self=0x00000000, _cmd="initWithCoder:", coder=0x16881200) at MGLKView.mm:24:16-[UIClassSwapper initWithCoder:] + 218 frame #11: 0x206bc6ee UIKit
UINibDecoderDecodeObjectForValue + 834-[UINibDecoder decodeObjectForKey:] + 82 frame #13: 0x205820d2 UIKit
-[UIRuntimeConnection initWithCoder:] + 160UINibDecoderDecodeObjectForValue + 834 frame #15: 0x206bc646 UIKit
UINibDecoderDecodeObjectForValue + 666-[UINibDecoder decodeObjectForKey:] + 82 frame #17: 0x20581632 UIKit
-[UINib instantiateWithOwner:options:] + 1082-[UIViewController _loadViewFromNibNamed:bundle:] + 314 frame #19: 0x201deaba UIKit
-[UIViewController loadView] + 136-[UIViewController loadViewIfRequired] + 170 frame #21: 0x200b1ad8 UIKit
-[UIViewController view] + 22-[UIWindow addRootViewControllerViewIfPossible] + 72 frame #23: 0x200b55ba UIKit
-[UIWindow _setHidden:forced:] + 286-[UIWindow makeKeyAndVisible] + 42 frame #25: 0x20322b12 UIKit
-[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3906-[UIApplication _runWithMainScene:transitionContext:completion:] + 1640 frame #27: 0x2033a7c4 UIKit
__84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3149 + 40-[UIApplication workspaceDidEndTransaction:] + 142 frame #29: 0x1c760c12 FrontBoardServices
FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 18-[FBSSerialQueue _performNext] + 220 frame #31: 0x1c760db6 FrontBoardServices
-[FBSSerialQueue _performNextFromRunLoopSource] + 44__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12 frame #33: 0x1ae3bb04 CoreFoundation
__CFRunLoopDoSources0 + 424__CFRunLoopRun + 1160 frame #35: 0x1ad8d1ae CoreFoundation
CFRunLoopRunSpecific + 470CFRunLoopRunInMode + 104 frame #37: 0x2011ae2c UIKit
-[UIApplication _run] + 660UIApplicationMain + 150 frame #39: 0x00031f12 MGLKitSampleApp_ios9.0
main(argc=1, argv=0x0029fa1c) at main.m:25:12-[MTLDebugRenderCommandEncoder memoryBarrierWithResources:count:afterStages:beforeStages:]:5031: failed assertion `render memoryBarrierWithResources is not supported on this device'
in glBufferSubData
with Catalyst on Apple Silicon
I wonder whether it is possible to use MetalANGLE to translate the gl calls to metal calls but still use the GLKit. As I understand the GLKit it is just used for providing a display layer which just fetches the data with gl calls (which also gets translated?) but I can be totally wrong.
I tried it and it failed. But the reason it failed was strange. I tried to call gl::GetString with 0x1F02 (GL_VERSION) and it returned null but this shouldn't be affected by GLKit right? Does I have a misunderstanding here?
I am having difficulty building the project with Mac Catalyst support. Any instructions or documentation how to do that would be very helpful. Thanks.
First off, I want to say thank you so much for working on this project! This is very exciting and I'm sure it will help many apps survive Apple's OpenGL deprecation. Also, huge thanks for releasing prebuilt binaries -- getting ANGLE set up can be really tricky, so thanks for removing that step!
On to the actual issue... I was testing a simple application with the latest macOS dylib release, and I noticed that the call stream contained many redundant (or unnecessary) buffer and sampler bindings. You can see a snippet of the call stream here:
Notice the various setVertexBuffer:
calls. As far as I can tell, it's binding the same buffers over and over again, only adjusting the offset for each index between draw calls. Apple's best practices suggest using the setVertexBufferOffset:atIndex: for changing the offset of an already-bound buffer. I wonder if that might yield some performance increases since redundant buffer bindings will not occur.
Similarly, the repeated setFragmentSamplerState:
and setVertexSamplerState:
calls seem to be entirely unnecessary since the sampler state and LOD clamp values never change between draw calls.
Hi,
I'm extremely grateful that you wrote this library!
I'm evaluating to use Angle to implement a WebGL plugin for Flutter Apps. The graphic backend of Flutter on iOs and MacOS is currently migrated to use metal instead of OpenGL.
So my question is, if I can get access to the Metal layer of a Flutter Texture, would it be posible to create an OpenGL ES surface from this that could be used with MetalAngle to draw on it?
Cheers
Thomas
maybe when call linkProgram happen
Runner(4953,0x16c25f000) malloc: Heap corruption detected, free list is damaged at 0x28130d1c0
*** Incorrect guard value: 63956752584960
Runner(4953,0x16c25f000) malloc: *** set a breakpoint in malloc_error_break to debug
Runner(4953,0x16c25f000) malloc: Heap corruption detected, free list is damaged at 0x28130d1c0
*** Incorrect guard value: 63956752584960
There is no equivalent of the GLKView::deleteDrawable in MGLKView.
https://developer.apple.com/documentation/glkit/glkview/1615569-deletedrawable?language=objc
Currently our application calls when the application moves to background (user presses the home button on the iPhone or equivalent swipe up home gesture).
The application invokes bindDrawable again when the application enters foreground.
I was wondering when the ES 3.1 Metal implementation will get feature parity with lets say the ChromeOS ANGLE impl?
Is there some way to force MetalAngle to always call / pass through calls to opengl ES 2.0?
I have integrated an application with MetalAngle using MGLKit classes, but its not rendering as expected (in addition to errors). I want to force all calls to opengl ES2.0 instead of metal to resolve any issues in the changes I have done for integration using MGLKit. Once the application works using MGLKit and opengl ES2.0, I will switch over to metal.
Hi,
I am currently investigating means for converting a big OpenGL ES 2 based project from Qt 5 to Qt 6 for iOS without sticking with OpenGL. Qt 6 offers a native Metal layer implementation in conjunction with Qt 3D. But this would require to completely rewrite my project from scratch for Qt 3D.
MetalAngle seems to be a perfect solution for my problem. Basically Qt creates the Metal surface for its components (i.e. the Qml user interface). My own code keeps to use OpenGL together with the MetalAngle wrapper. Is this possible, or is it necessary to create all surface initialization stuff with MetalAngle?
Thanks,
First of all, thank you @kakashidinho for creating such a useful library! Your work is very impressive. π
I'm working on an application that creates an MGLKViewController
to display a game and later destroys it. I noticed that after the view controller itself has been destroyed, the MGLContext
object it was using is leaked. In my case, that prevented all of the memory allocated for the game's textures from being released.
I looked into the issue and figured out that there is a retain cycle between MGLContext
and the MGLSharegroup
associated with it. I was able to fix the problem by adding weak
to the firstContext
property of MGLSharegroup
.
// MGLSharegroup implementation
@interface MGLSharegroup ()
@property(atomic, weak) MGLContext *firstContext;
@end
After I made the reference weak
, both the MGLContext
and its MGLSharegroup
called dealloc
, and the game's texture memory was released properly. I'm not sure if there is any reason why firstContext
needs to be a strong reference, however.
Please let me know if I'm misunderstanding anything about the library, or if I can help in any way. Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.