1 Star 10 Fork 1

HarmonyOS_Samples/XEngine-samplecode-GlesDemo-cpp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
readme_en.md 4.89 KB
一键复制 编辑 原始数据 按行查看 历史
weitingting 提交于 3个月前 . GLES

Upscaling and Adaptative VRS (OpenGL ES) Capabilities of XEngine Kit

Overview

In this codelab, you'll learn how to use the GPU spatial upscaling API and AI spatial upscaling API of XEngine Kit to perform texture upscaling and use adaptive VRS API to change the shading rate. The sample code takes drawing the scenes of Sponza Palace as an example, and calls NAPI using XComponent to build up the EGL/OpenGL ES environment. The demo project is created based on the Native C++ template.

Preview

You can tap the drop-down list box to switch between upscaling modes and tap the check box to enable or disable adaptative VRS. The following figure shows the Sponza Palace scene drawn using XComponent.

XEngine Spatial Upscale

Related Concepts

  • EGL (Embedded Graphic Library): EGL is an interface between Khronos rendering APIs (such as OpenGL ES and OpenVG) and the underlying native window system.
  • XComponent: The XComponent can accept and display the EGL/OpenGL ES and media data input.

Instructions

  1. Run the sample code.
  2. Tap the drop-down list box and switch between no upscale (no upscaling), neural upscale (AI spatial upscaling), spatial upscale (GPU spatial upscaling), and fsr upscale (FSR1.0 upscaling) modes.
  3. Tap the check box to enable or disable adaptive VRS.

Project Directory

├── entry/src/main	             // Code area
│  ├── cpp
│  │  ├── types
│  │  │  ├── libnativerender
             └── index.d.ts      // API registration file at the native layer
│  │  │── napi_init.cpp          // Functions of APIs at the native layer
│  │  │── CMakeLists.txt         // Compilation configurations at the native layer
│  │  │── 3rdParty               // Third-party component
│  │  │── common                 // Common APIs
│  │  │── model                  // Model
│  │  │── file                   // File management
│  │  │── libs                   // Third-party dynamic libraries
│  │  │── manager                // native & ArkTS interactions
│  │  │── render                 // Rendering
│  │  │── shader                 // Render shader
│  ├── ets
│  │  ├── entryability
             └── EntryAbility.ts // Entry class
│  │  ├── pages
             └── index.ets       // Home screen display class
│  ├── resources                 // Directory of resource files
│  │  ├── base
│  │  │  ├── media
             └── icon.png        // Image resources
│  │  ├── rawfile/model/Sponza
                         └── sponza.obj    // Model resources

Implementation Details

The sample code uses the following APIs defined in XEngine Kit:

  • const GLubyte* HMS_XEG_GetString(GLenum name);
  • GL_APICALL void GL_APIENTRY HMS_XEG_SpatialUpscaleParameter(GLenum pname, GLvoid *param);
  • GL_APICALL void GL_APIENTRY HMS_XEG_RenderSpatialUpscale(GLuint inputTexture);
  • GL_APICALL void GL_APIENTRY HMS_XEG_NeuralUpscaleParameter(GLenum pname, GLvoid *param);
  • GL_APICALL void GL_APIENTRY HMS_XEG_RenderNeuralUpscale(GLuint inputTexture);
  • GL_APICALL void GL_APIENTRY HMS_XEG_AdaptiveVRSParameter(GLenum pname, GLvoid *param);
  • GL_APICALL void GL_APIENTRY HMS_XEG_DispatchAdaptiveVRS(GLfloat *reprojectionMatrix, GLuint inputColorImage, GLuint inputDepthImage, GLuint shadingRateImage);
  • GL_APICALL void GL_APIENTRY HMS_XEG_ApplyAdaptiveVRS(GLuint shadingRateImage); You can call the APIs listed above to implement GPU spatial upscaling, AI spatial upscaling, and adaptative VRS.

Required Permissions

N/A

Dependency

  • This sample code depends on the Assimp third-party component, In this example, the third-party component has been configured and compiled. If you need to replace the third-party component, compile it based on the system version.
  • 3D model resources: "Crytek Sponza" by Frank Meinl; Crytek is licensed under CC BY 3.0/replace "\" with "/" in the sponza.mtl file.

Constraints

  1. The sample code can only run on devices with a standard system. Supported devices: For details, see Hardware Requirements in the XEngine Development Guide.
  2. This sample demonstrates the stage model, which supports API version 12 or later.
  3. HarmonyOS: HarmonyOS NEXT Developer Beta1 or later.
  4. DevEco Studio: DevEco Studio NEXT Developer Beta1 or later.
  5. HarmonyOS SDK: HarmonyOS NEXT Developer Beta1 SDK or later.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/harmonyos_samples/xengine-samplecode-gles-demo-cpp.git
git@gitee.com:harmonyos_samples/xengine-samplecode-gles-demo-cpp.git
harmonyos_samples
xengine-samplecode-gles-demo-cpp
XEngine-samplecode-GlesDemo-cpp
master

搜索帮助