Google Filament 源码学习(二):三方库分类总结

前言

拿到Filament代码一头雾水,到底要怎么看呢,先从第三方库看起吧,如下对三方库进行了分类梳理。

注:刚刚开始学习,有很多库和基本概念都不是很清楚,有不当之处请大家随时指出,本人一定虚心接受。


1. 压缩相关

1.1 draco

简介: Draco是谷歌Chrome 团队在2017年1月发布的一个Draco是用于压缩和解压缩3D几何网格和点云的库,旨在改善3D图形的存储和传输,大幅加速 3D 数据的编码、传输和解码。
Draco 可以被用来压缩 mesh 和点云数据。它还支持压缩点( compressing points),连接信息,纹理协调,颜色信息,法线以及其他与几何相关的通用属性。
参考网址: https://github.com/google/draco

1.2 libz

简介: zlib 是一个通用的数据压缩库。所有的代码都是线程安全的。zlib库使用的数据格式由RFC描述(征求意见)文件中的1950年至1952年 http://tools.ietf.org/html/rfc1950(zlib格式)、rfc1951(deflate格式)和 rfc1952(gzip格式)。
参考网址:https://github.com/madler/zlib


2. 图像、纹理操作

2.1 basisu

简介: Basis Universal是一个“超压缩”GPU纹理数据交换系统,支持两种高度压缩的中间文件格式(.Basis或Khronos Group的.KTX2开放标准),可以快速转码为各种GPU压缩和非压缩像素格式:ASTC 4x4 L/LA/RGB/RGBA、PVRTC1 4bpp RGB/RGBA、PVRTC2 RGB/RGB、BC7模式6 RGB、,BC1-5 RGB/RGBA/X/XY、ETC1 RGB、ETC2 RGBA、ATC RGB/RGBA、ETC2 EAC R11和RG11、FXT1 RGB和未压缩光栅图像格式8888/565/4444。

Basis Universal is a “supercompressed” GPU texture data interchange system that supports two highly compressed intermediate file formats (.basis or the .KTX2 open standard from the Khronos Group) that can be quickly transcoded to a very wide variety of GPU compressed and uncompressed pixel formats: ASTC 4x4 L/LA/RGB/RGBA, PVRTC1 4bpp RGB/RGBA, PVRTC2 RGB/RGBA, BC7 mode 6 RGB, BC7 mode 5 RGB/RGBA, BC1-5 RGB/RGBA/X/XY, ETC1 RGB, ETC2 RGBA, ATC RGB/RGBA, ETC2 EAC R11 and RG11, FXT1 RGB, and uncompressed raster image formats 8888/565/4444.

谷歌在2019年与Binomial合作开源了Basis Universal纹理编解码器,目标是为网络传输和GPU用例实现更有效的高质量纹理。以GPU为例,Basis Universal纹理格式要比JPEG小6-8倍,但两者的存储大小相似。由于当前的GPU压缩方法效率低下,而且不支持跨平台操作,这使得它成为了一种优秀的替代方案。所述格式适用于各种用例,例如游戏、VR/AR、地图、照片、小视频等等。

参考网址:https://github.com/BinomialLLC/basis_universal

2.2 libpng

简介: png图片编解码库
参考网址:https://github.com/glennrp/libpng

2.3 stb

简介: 简单易用的图像库, 主要特性:

  • 图像读取:支持JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC规格的解析
  • 图像写:支持 PNG, TGA, BMP
  • 图像像素调整
  • truetype字体处理:解析、解码和光栅化truetype字体中的字符
  • 音频波形合成器。

参考网址:https://github.com/nothings/stb

2.4 tinyexr

简介:tinyexr是一个用于加载和保存OpenEXR(.exr)图像(一种高动态范围的栅格文件格式)的小型单头库。tinyexr是用可移植C++编写的(除了STL之外,没有库依赖关系),因此tinyexrs很适合嵌入到应用程序中。要使用tinyexr,只需复制tinyexr.h进入你的项目。

tinyexr is a small, single header-only library to load and save OpenEXR (.exr) images. tinyexr is written in portable C++ (no library dependency except for STL), thus tinyexr is good to embed into your application. To use tinyexr, simply copy tinyexr.h into your project.

参考网址:https://github.com/syoyo/tinyexr


3. 测试框架

3.1 benchmark

简介: ”Benchmark在计算机领域应用最成功的就是性能测试,主要测试负载的执行时间、传输速度、吞吐量、资源占用率等。
性能调优的两大利器是Benchmark和profile工具。Benchmark用压力测试挖掘整个系统的性能状况,而profile工具最大限度地呈现系统的运行状态和性能指标,方便用户诊断性能问题和进行调优。
参考官网: https://github.com/google/benchmark

3.2 libgtest

简介: Gtest是Google的一个开源框架,它主要用于单元测试,可在多个平台上使用(包括Linux, Mac OS X, Windows, Cygwin和Symbian)。它提供了丰富的断言、致命和非致命失败判断,能进行值参数化测试、类型参数化测试、死亡测试(Death tests)。

参考网址:https://github.com/google/googletest


4. 三维模型操作

4.1 cgltf

简介: 单文件、STB-style的 glTF文件读、写库。

  • 支持gltf 2.0规格,扩展名可以是gltf(JSON规格)和glb(二进制规格)。
  • 同时也支持了glTF的一些扩展属性, 如 EXT_mesh_gpu_instancing, EXT_meshopt_compression, KHR_draco_mesh_compression … …
    如果对gltf不熟的话,可以参考网站: https://github.com/KhronosGroup/glTF
    它被应用于: bgfx, Filament, gltfpack, raylib, Unigine, and more!

参考网址:https://github.com/jkuhlmann/cgltf

4.2 libassimp

简介: Open Asset Importer Lib(简称 assimp)是一个库,用于加载和处理来自各种 3D 数据格式的几何场景。它主要用于从各种来源导入资产一次并将其存储为特定于引擎的格式,以便于轻松快速地加载。assimp 还能够对导入的数据应用各种后处操作:法线和切线空间生成、三角剖分、顶点缓存局部优化、删除退化图元和重复顶点、按图元类型排序、合并冗余材质等。

Additionally, assimp features various mesh post processing tools: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more.

  • 支持3DS, BLEND, FBX, DXF, glTF2.0, OBJ, PLY 等五十多种规格的加载
  • 支持DAE,STL,OBJ,PLY,X,3DS,GLTF2.0,FBX等十几种规格的导出

参考网址:https://github.com/assimp/assimp


5. UI界面及硬件交互库

5.1 imgui

简介: Dear ImGui是一个面向C++的免费图形用户界面库。它输出优化的顶点缓冲区,您可以在启用3D管道的应用程序中随时渲染。它是快速的、可移植的、与渲染器无关的、自包含的(没有外部依赖关系)。

Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).

Dear ImGui旨在实现快速迭代,并使程序员能够创建内容创建工具和可视化/调试工具(与普通最终用户的UI相反)。它有利于实现这一目标的简单性和生产力,但缺少通常在更高级的库中找到的某些特性。

Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.

Dear ImGui特别适合集成在游戏引擎(用于工具)、实时3D应用程序、全屏应用程序、嵌入式应用程序或操作系统功能不标准的控制台平台上的任何应用程序中。

Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.

参考网址:https://github.com/ocornut/imgui

5.2 gltumble

简介: 提供了一个名为Trackball的数学类,允许用户通过鼠标、触控板或触摸屏拖动来翻转对象。它可以选择应用惯性,以使对象在轻弹时继续旋转。

This library provides a math class called Trackball that allows users to tumble an object by dragging with a mouse, trackpad, or touch screen. It optionally applies inertia such that the object continues to spin if you flick it.

参考网址:https://github.com/prideout/gltumble

5.3 libsdl2

简介: Simple DirectMedia Layer是一个跨平台开发库,旨在通过OpenGL和Direct3D提供对音频、键盘、鼠标、操纵杆和图形硬件的低级访问。它被视频播放软件、模拟器和流行游戏使用,包括Valve的获奖目录和许多Humble Bundle游戏。
参考网址:github: https://github.com/libsdl-org/
博文:SDL(Simple DirectMedia Layer) 简介


6. 渲染相关

6.1 glslang

简介: glslang 提供了如下组件/功能

  • Reference Validator and GLSL/ESSL -> AST Front End
    An OpenGL GLSL and OpenGL|ES GLSL (ESSL) front-end for reference validation and translation of GLSL/ESSL into an internal abstract syntax tree (AST).

  • HLSL -> AST Front End
    An HLSL front-end for translation of an approximation of HLSL to glslang’s AST form.

  • AST -> SPIR-V Back End
    Translates glslang’s AST to the Khronos-specified SPIR-V intermediate language.

  • Reflector
    An API for getting reflection information from the AST, reflection types/variables/etc. from the HLL source (not the SPIR-V).

  • Standalone Wrapper
    glslangValidator is command-line tool for accessing the functionality above.

参考:glslangValidator是OpenGL标准定制官方Khronos Group定制的GLSL参考编译器,命令行编译模式方便了用户直接测试glsl语法而绕过C/C++的相关依赖库编译,也不需要在主文件编写大量初始化代码。

参考网址:https://github.com/KhronosGroup/glslang

6.2 meshoptimizer

简介:当GPU渲染三角形网格时,GPU管道的各个阶段必须处理顶点和索引数据。这些阶段的效率取决于您提供给它们的数据;该库提供了帮助优化这些阶段网格的算法,以及降低网格复杂性和存储开销的算法。

When a GPU renders triangle meshes, various stages of the GPU pipeline have to process vertex and index data. The efficiency of these stages depends on the data you feed to them; this library provides algorithms to help optimize meshes for these stages, as well as algorithms to reduce the mesh complexity and storage overhead.

它也同时提供了一个gltfpack工具,以实现对于glTF文件的优化功能。

mesh数据将被通过如下“管线”进行优化:

  1. Indexing
  2. (optional, discussed last) Simplification
  3. Vertex cache optimization
  4. Overdraw optimization
  5. Vertex fetch optimization
  6. Vertex quantization
  7. (optional) Vertex/index buffer compression

参考网址:https://github.com/zeux/meshoptimizer

6.3 smol-v

简介: SMOL-V 实现将 Vulkan/Khronos SPIR-V 规格变得更小、更压缩。

SMOL-V encodes Vulkan/Khronos SPIR-V format programs into a form that is smoller, and is more compressible.

参考网址: https://github.com/aras-p/smol-v

6.4 spirv-cross

简介: SPIRV-Cross 实现将SRIR-V规格解析转换成其他shader语言。

SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages.

主要特性包括:

  • Convert SPIR-V to readable, usable and efficient GLSL
  • Convert SPIR-V to readable, usable and efficient Metal Shading Language (MSL)
  • Convert SPIR-V to readable, usable and efficient HLSL
  • Convert SPIR-V to debuggable C++ [DEPRECATED]
  • Convert SPIR-V to a JSON reflection format [EXPERIMENTAL]
  • Reflection API to simplify the creation of Vulkan pipeline layouts
  • Reflection API to modify and tweak OpDecorations
  • Supports “all” of vertex, fragment, tessellation, geometry and compute shaders.

参考网址: https://github.com/KhronosGroup/SPIRV-Cross

6.5 spirv-tools

简介: SPIR-V Tools 提供了处理SPIR-V 模型的API和指令。
该项目包括SPIR-V的汇编程序、二进制模块解析器、反汇编程序、验证器和优化器。除了优化器之外,所有这些都基于一个通用的静态库。该库包含所有实现细节,并在独立工具中使用,同时还可以直接集成到其他代码库中。优化器实现驻留在它自己的库中,该库依赖于核心库。

The project includes an assembler, binary module parser, disassembler, validator, and optimizer for SPIR-V. Except for the optimizer, all are based on a common static library. The library contains all of the implementation details, and is used in the standalone tools whilst also enabling integration into other code bases directly. The optimizer implementation resides in its own library, which depends on the core library.

参考网址:https://github.com/KhronosGroup/SPIRV-Tools

6.6 vkmemalloc

简介: 一款易于集成的Vulkan内存管理库。这个库通过提供更高层的功能函数帮助游戏开发者更好的管理内存分配和资源创建。

  • 有助于根据内存的预期使用情况选择正确和最佳内存类型的功能
  • 分配内存块、保留部分内存块并将其返回给用户的函数(VkDeviceMemory+偏移量+大小)。
  • 可以创建图像/缓冲区、为其分配内存并将它们绑定在一起的函数-所有这些都在一个调用中。
  • Functions that help to choose correct and optimal memory type based on intended usage of the memory.
  • Functions that allocate memory blocks, reserve and return parts of them (VkDeviceMemory + offset + size) to the user.
  • Functions that can create an image/buffer, allocate memory for it and bind them together - all in one call.

参考网址: https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator


7. 工具类库

7.1 civetweb

简介: 项目任务是提供易于使用、功能强大的C(C/C++)嵌入式web服务器,并提供可选的CGI、SSL和Lua支持。CivetWeb拥有麻省理工学院许可证,因此您可以无限制地进行创新。

Project mission is to provide easy to use, powerful, C (C/C++) embeddable web server with optional CGI, SSL and Lua support. CivetWeb has a MIT license so you can innovate without restrictions.

它既可以被当做类库,增加到现有程序中以增加web服务功能,同时也可以作为独立运行于Windows,Mac,Linux,UNIX, IOS, Android, Buildroot等各种平台的web 服务器。
我比较关注的官网描述的几个特性如下:

  • Works on Windows, Mac, Linux, UNIX, IOS, Android, Buildroot, and many other platforms.
  • Scripting and database support (CGI, Lua Server Pages, Server side Lua scripts, Lua SQLite database, Server side JavaScript). This provides a ready to go, powerful web development platform in a one single-click executable with no dependencies. 0
  • Support for CGI, SSI, HTTP digest (MD5) authorization, WebSocket, WebDAV.
  • HTTPS (SSL/TLS) support using OpenSSL.
  • Resumed download, URL rewrite, file blacklist, IP-based ACL.

参考网址:https://github.com/civetweb/civetweb

7.2 getopt

简介: 函数说明 getopt()用来分析命令行参数。

  1. 参数argc和argv分别代表参数个数和内容,跟main()函数的命令行参数是一样的。
  2. 参数 optstring为选项字符串, 告知 getopt()可以处理哪个选项以及哪个选项需要参数,如果选项字符串里的字母后接着冒号“:”,则表示还有相关的参数,全域变量optarg 即会指向此额外参数。
  3. 如果在处理期间遇到了不符合optstring指定的其他选项getopt()将显示一个错误消息,并将全域变量optopt设为“?”字符,如果不希望getopt()打印出错信息,则只要将全域变量opterr设为0即可。

参考网址:没找到代码出处,使用说明可见百度百科,说明和举例都很清晰 https://baike.baidu.com/item/getopt/4705064

7.3 hat-trie

简介: 基于"HAT-trie:ACache-consciousTrie-based数据结构的Trie实现(Askitis Nikolas and Sinha Ranjan,2007)论文。目前,只有纯HAT-trie已经实现,混合版本可能会在稍后到达。关于HAT-trie数据结构的详细信息可以在这里找到。

Trie implementation based on the “HAT-trie: A Cache-conscious Trie-based Data Structure for Strings.” (Askitis Nikolas and Sinha Ranjan, 2007) paper. For now, only the pure HAT-trie has been implemented, the hybrid version may arrive later. Details regarding the HAT-trie data structure can be found here.

该库通过压缩常用前缀,提供了一种高效、紧凑的存储字符串集或映射的方法。它还允许搜索与前缀匹配的键。注意,尽管结构的默认参数是为了优化精确的搜索,但是如果您进行了大量的前缀搜索,您可能需要通过burst_threshold方法来降低突发阈值。
参考网址:https://www.5axxw.com/wiki/content/kk9uuf

7.4 jsmn

简介: jsmn是一个简约的C语言JSON解析器。它可以很容易地集成到资源有限或嵌入式项目中。
jsmn的设计是健壮的(即使有错误的数据,它也应该能正常工作)、快速的(它应该在运行中解析数据)、可移植的(没有多余的依赖或非标准的C扩展)。当然,简单性是一个关键特性——简单的代码风格、简单的算法、与其他项目的简单集成。

jsmn is designed to be robust (it should work fine even with erroneous data), fast (it should parse data on the fly), portable (no superfluous dependencies or non-standard C extensions). And of course, simplicity is a key feature - simple code style, simple algorithm, simple integration into other projects.

参考网址:https://github.com/zserge/jsmn

7.5 robin-map

简介:使用循环哈希的快速哈希映射和哈希集的C++实现

A C++ implementation of a fast hash map and hash set using robin hood hashing

循环映射库是一个快速哈希映射和哈希集的C++实现,使用开放寻址和线性循环哈希以及后移删除来解决冲突。

The robin-map library is a C++ implementation of a fast hash map and hash set using open-addressing and linear robin hood hashing with backward shift deletion to resolve collisions.

提供了四个类:tsl::robin_map、tsl::robin_set、tsl::robin_pg_map和tsl::robin_pg _set。前两种速度更快,使用二次幂增长策略,后两种使用主要增长策略,能够更好地应对糟糕的哈希函数。如果有可能在哈希的低位重复模式,请使用prime版本(例如,您使用身份哈希函数存储指针)。有关详细信息,请参见增长策略。

Four classes are provided: tsl::robin_map, tsl::robin_set, tsl::robin_pg_map and tsl::robin_pg_set. The first two are faster and use a power of two growth policy, the last two use a prime growth policy instead and are able to cope better with a poor hash function. Use the prime version if there is a chance of repeating patterns in the lower bits of your hash (e.g. you are storing pointers with an identity hash function). See GrowthPolicy for details.

网传“ tsl::robin_map 的性能基本上能达到 std::unordered_map 的 5-10 倍" , 没有亲自测试过。

参考官网:https://github.com/Tessil/robin-map
参考网址:


8. 一些JS库

8.1 gl-matrix

简介:Javascript已经发展成为一种能够通过WebGL处理实时3D图形和计算密集型任务(如物理模拟)的语言。这些类型的应用程序需要高性能的向量和矩阵数学,这是Javascript默认情况下不提供的。glMatrix去救援!

Javascript has evolved into a language capable of handling realtime 3D graphics, via WebGL, and computationally intensive tasks such as physics simulations. These types of applications demand high performance vector and matrix math, which is something that Javascript doesn’t provide by default. glMatrix to the rescue!

glMatrix旨在快速执行矢量和矩阵运算!通过手动调整每个函数以获得最佳性能,并通过API约定鼓励高效的使用模式,glMatrix将帮助您充分利用浏览器Javascript引擎。

glMatrix is designed to perform vector and matrix operations stupidly fast! By hand-tuning each function for maximum performance and encouraging efficient usage patterns through API conventions, glMatrix will help you get the most out of your browsers Javascript engine.

参考网址:https://glmatrix.net/

8.2 markdeep

简介: Markdeep是一种用于编写纯文本文档的技术,无论是本地还是远程,在任何web浏览器中都很好看。它支持图表、日历、公式和其他作为Markdown语法扩展的功能。

Markdeep is a technology for writing plain text documents that will look good in any web browser, whether local or remote. It supports diagrams, calendars, equations, and other features as extensions of Markdown syntax.

参考网址:https://casual-effects.com/markdeep/


9. 辅助资源

9.1 environments

简介: 一些HDR(High-Dynamic Range) 图像资源

9.2 models

简介: 一些glTF, glb文件

9.3 textures

简介: 一些png纹理图片资源

猜你喜欢

转载自blog.csdn.net/bluebird888/article/details/127592098
今日推荐