GithubHelp home page GithubHelp logo

mulle-kybernetik-tv / metalnanovg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ollix/metalnanovg

0.0 1.0 0.0 603 KB

The Metal port of NanoVG.

License: MIT License

Objective-C 15.04% C 82.87% Metal 1.43% Shell 0.66%

metalnanovg's Introduction

MetalNanoVG

MetalNanoVG is the native Metal port of NanoVG that tries to get the most out of Apple's Graphics APIs.

Donation

If you found this project useful, please consider donating to show your support ❤️

Donate

Precautions

  • Works only on macOS 10.11+, tvOS 9.0+ and iOS 8.0+.
  • Simulator support is available since iOS 13 and requires Xcode 11+ running on macOS 10.15+.
  • Not all Apple hardwares are supported even if meets the OS requirement.
  • ARC is required.

Advantages

  • Shared buffers between CPU and GPU.
  • Various Metal states are cached whenever possible.
  • Low overheads compared to OpenGL.
  • Pre-compiled shaders. (no need to compile shaders at runtime)
  • Seamless integration with powerful Metal features such as Metal Performance Shaders.

Installation

  1. Download both NanoVG and MetalNanoVG source codes.
  2. Add both NanoVG and MetalNanoVG's src directories to the header search path.
  3. Add NanoVG's src/nanovg.c and MetalNanoVG's src/nanovg_mtl.m to the Compile Sources section in Xcode.
  4. Link the Metal and QuartzCore frameworks.
  5. For best performance, disable GPU Frame Capture and Metal API Validation as described here.

Done.

Usage

  1. Include the headers.
#include "nanovg.h"
#include "nanovg_mtl.h"
  1. Pass the CAMetalLayer object when creating the NanoVG context.
NVGcontext* ctx = nvgCreateMTL(metalLayer, NVG_ANTIALIAS | NVG_STENCIL_STROKES);

Benchmark

The following table depicts a simple CPU usage benchmark of running the NanoVG demo app on iOS devices with full Retina resolution. Both Metal and OpenGL ES2 implementations get constant 60 FPS.

iPhone 6s+ iPad Pro 12.7" (2015)
Resolution 1080 x 1920 2732 * 2048
Metal 20% 20%
OpenGL ES2 35% 33%

Example

MetalNanoVG was originally created to improve the performance of the iOS app Fog of World.

Screenshot of Fog of World

metalnanovg's People

Contributors

dagagren avatar olilarkin avatar olliwang avatar scheffle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.