{"action":"created","issue":{"url":"https://api.github.com/repos/google/filament/issues/360","repository_url":"https://api.github.com/repos/google/filament","labels_url":"https://api.github.com/repos/google/filament/issues/360/labels{/name}","comments_url":"https://api.github.com/repos/google/filament/issues/360/comments","events_url":"https://api.github.com/repos/google/filament/issues/360/events","html_url":"https://github.com/google/filament/pull/360","id":368386088,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxNTc2OTA3","number":360,"title":"Add iOS support to Filament","user":{"login":"bejado","id":5298046,"node_id":"MDQ6VXNlcjUyOTgwNDY=","avatar_url":"https://avatars0.githubusercontent.com/u/5298046?v=4","gravatar_id":"","url":"https://api.github.com/users/bejado","html_url":"https://github.com/bejado","followers_url":"https://api.github.com/users/bejado/followers","following_url":"https://api.github.com/users/bejado/following{/other_user}","gists_url":"https://api.github.com/users/bejado/gists{/gist_id}","starred_url":"https://api.github.com/users/bejado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bejado/subscriptions","organizations_url":"https://api.github.com/users/bejado/orgs","repos_url":"https://api.github.com/users/bejado/repos","events_url":"https://api.github.com/users/bejado/events{/privacy}","received_events_url":"https://api.github.com/users/bejado/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-10-09T20:36:13Z","updated_at":"2018-10-11T12:58:16Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/google/filament/pulls/360","html_url":"https://github.com/google/filament/pull/360","diff_url":"https://github.com/google/filament/pull/360.diff","patch_url":"https://github.com/google/filament/pull/360.patch"},"body":"iOS support for Filament on ARM64 devices.\r\n\r\nKey changes:\r\n- New platform: `PlatformVkCocoaTouch`\r\n- Build script supports iOS platform and downloads [Apple's ARM toolchain](https://opensource.apple.com/source/clang/clang-800.0.38/src/cmake/platforms/iOS.cmake)\r\n- Added libMoltenVK.dylib ARM64 binary, copied into App bundle at build time\r\n\r\nTwo commits:\r\n1. Add iOS support to Filament and `build.sh` (use `./build.sh -p ios debug` on Mac host to build)\r\n2. Add a hello-triangle sample iOS app\r\n\r\nI haven't had a chance to build on Windows or Linux yet, so I'll wait for Kokoro to succeed before merging."},"comment":{"url":"https://api.github.com/repos/google/filament/issues/comments/428945137","html_url":"https://github.com/google/filament/pull/360#issuecomment-428945137","issue_url":"https://api.github.com/repos/google/filament/issues/360","id":428945137,"node_id":"MDEyOklzc3VlQ29tbWVudDQyODk0NTEzNw==","user":{"login":"bejado","id":5298046,"node_id":"MDQ6VXNlcjUyOTgwNDY=","avatar_url":"https://avatars0.githubusercontent.com/u/5298046?v=4","gravatar_id":"","url":"https://api.github.com/users/bejado","html_url":"https://github.com/bejado","followers_url":"https://api.github.com/users/bejado/followers","following_url":"https://api.github.com/users/bejado/following{/other_user}","gists_url":"https://api.github.com/users/bejado/gists{/gist_id}","starred_url":"https://api.github.com/users/bejado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bejado/subscriptions","organizations_url":"https://api.github.com/users/bejado/orgs","repos_url":"https://api.github.com/users/bejado/repos","events_url":"https://api.github.com/users/bejado/events{/privacy}","received_events_url":"https://api.github.com/users/bejado/received_events","type":"User","site_admin":false},"created_at":"2018-10-11T12:58:16Z","updated_at":"2018-10-11T12:58:16Z","author_association":"MEMBER","body":"My current approach is to create a framebuffer and renderbuffer inside of `createDefaultRenderTarget` when on iOS:\r\n\r\n```\r\nvoid OpenGLDriver::createDefaultRenderTarget(\r\n        Driver::RenderTargetHandle rth, int) {\r\n    DEBUG_MARKER()\r\n\r\n    construct<GLRenderTarget>(rth);\r\n\r\n#if defined(IOS)\r\n    /* Special case on iOS. iOS has no concept of a \"default framebuffer\", we are forced\r\n     * to create one here. */\r\n\r\n    GLRenderTarget* rt = handle_cast<GLRenderTarget*>(rth);\r\n\r\n    // Create a framebuffer object\r\n    GLuint framebuffer;\r\n    glGenFramebuffers(1, &framebuffer);\r\n\r\n    // Create a renderbuffer object\r\n    GLuint renderbuffer;\r\n    glGenRenderbuffers(1, &renderbuffer);\r\n\r\n    rt->gl.color.id = renderbuffer;\r\n    rt->gl.fbo = framebuffer;\r\n#endif\r\n\r\n    // nothing more to do\r\n}\r\n```\r\nThen, inside of `PlatformCocoaTouchGL::makeCurrent`, I use the iOS-specific `renderbufferStorage` call to associate the renderbuffer to the `CAEAGLLayer`, which is our `SwapChain`:\r\n```\r\nvoid PlatformCocoaTouchGL::makeCurrent(SwapChain* drawSwapChain, SwapChain* readSwapChain) noexcept {\r\n    [EAGLContext setCurrentContext:pImpl->mGLContext];\r\n\r\n    OpenGLDriver::create(this, sharedGLContext);\r\n\r\n    // TODO: assuming renderbuffer and framebuffer are both 1\r\n    CAEAGLLayer* glLayer = (CAEAGLLayer*) drawSwapChain;\r\n    glBindFramebuffer(GL_FRAMEBUFFER, 1);\r\n    glBindRenderbuffer(GL_RENDERBUFFER, 1);\r\n    [pImpl->mGLContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:glLayer];\r\n    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 1);\r\n}\r\n```\r\nThe problem with this is that I have no way of knowing which framebuffer and renderbuffer to bind (I've hard-coded `1` here, which works, but I don't know if we can always assume this).\r\n\r\nOne possible solution would be to pass the default renderbuffer to `FSwapChain::makeCurrent`.\r\n\r\n```\r\nRenderer.cpp:\r\n    swapChain->makeCurrent(driver, mRenderTarget);\r\n```\r\n\r\nThen `OpenGLDriver` could bind the renderbuffer and framebuffer of `mRenderTarget` before calling `mPlatform.makeCurrent`. Then `makeCurrent` just calls the iOS `renderbufferStorage` method."}}
{"actor":{"display_login":"bejado"}}