We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
Tools GuidesGraphics ProfilerGraphics Profiler InstructionsFrame Profiler UsageExtensionGraphics Profiler In-application API

Graphics Profiler In-application API

Method 1:

Vulkan Application

  1. Encapsulate the DebugUtilsLable_Start and DebugUtilsLable_End functions in the .cpp file of the HAP demo.

    void DebugUtilsLable_Start()
    {
    VkDebugUtilsLabelEXT label = {};
    label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
    label.pLabelName = "capture-marker,begin_capture";  // Label name, which is used for command or status identification during tool debugging.
    // You can set other attributes such as the color as needed.
    if (!vk::vkQueueInsertDebugUtilsLabelEXT) {
    LOGE("vkQueueInsertDebugUtilsLabelEXT is nullptr");
    }
    vk::vkQueueInsertDebugUtilsLabelEXT(globalNS::getvk_queue(), &label);
    }
    void DebugUtilsLable_End()
    {
    VkDebugUtilsLabelEXT label = {};
    label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
    label.pLabelName = "capture-marker,end_capture";  // Label name, which is used for command or status identification during tool debugging.
    vk::vkQueueInsertDebugUtilsLabelEXT(globalNS::getvk_queue(), &label);
    }

    Example of the insertion position:

  2. Configure environment variables.

    hdc shell param set debug.graphic.system_layer_flag 1

    hdc shell param set debug.graphic.debug_layer squid

    hdc shell param set debug.graphic.debug_hap com.huawei.ndkVulkanExample (HAP name)

  3. Run the demo source code on DevEco Studio to generate an .rdc file.

  4. Connect to the tool, choose Tools > Manage Remote Servers, click the corresponding process, and obtain the .rdc file.

  5. Play the .rdc file and check whether the API information is correct.

GLES Application

  1. Insert labels before and after frame capturing in the .cpp file of the HAP demo.

  2. Configure environment variables.

    hdc shell param set debug.graphic.debug_layer squid

    hdc shell param set debug.graphic.debug_hap com.samples.ndkopengl (HAP name)

  3. Run the demo source code on DevEco Studio to generate an .rdc file.

  4. Connect to the tool, choose Tools > Manage Remote Servers, click the corresponding process, and obtain the .rdc file.

  5. Play the .rdc file and check whether the API information is correct.

Method 2:

GLES Application

  1. Copy the libsquid.so file under <installation_folder>/frame_profiler/plugins/ohos/arm64 to the libs/arm64-v8a directory of the HAP.
  2. Encapsulate the InitRenderDoc(), BeginCapture(), and EndCapture() functions in the .cpp file of the HAP demo. Insert InitRenderDoc() before initialization, insert BeginCapture() before resource capturing, and insert EndCapture() after resource capturing. Add the local path of renderdoc.h to the CMakeLists file, for example, D:/addglesapi/open_source/renderdoc/renderdoc/api/app.

    #include "renderdoc_app.h"
    RENDERDOC_API_1_1_2* rdoc_api = nullptr;
    void InitRenderDoc()
    {
    void *mod = dlopen("libsquid.so", RTLD_NOW | RTLD_NOLOAD);
    if (mod) {
    LOGI("[ZT]InitRenderDoc: RenderDoc library loaded");
    pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod, "RENDERDOC_GetAPI");
    if (!RENDERDOC_GetAPI) {
    LOGE("[ZT]dlsym failed: %s", dlerror());
    return;
    }
    int ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_1_2, (void **)&rdoc_api);
    if (ret != 1) {
    LOGE("[ZT]RENDERDOC_GetAPI failed");
    rdoc_api = nullptr;
    }
    } else {
    LOGE("[ZT]InitRenderDoc failed: %s", dlerror());
    }
    }
    void BeginCapture()
    {
    if(rdoc_api) {
    rdoc_api->StartFrameCapture(NULL, NULL);
    }else{
    LOGE("[ZT]NOT BEGINCAPTURE");
    }
    }
    void EndCapture()
    {
    if(rdoc_api) {
    rdoc_api->EndFrameCapture(NULL, NULL);
    }else{
    LOGE("[ZT]NOT  ENDCAPTURE");
    }
    }

    Example of the insertion position:

  3. Configure environment variables.

    hdc shell param set debug.graphic.debug_layer squid

    hdc shell param set debug.graphic.debug_hap com.samples.ndkopengl (HAP name)

  4. Run the demo source code on DevEco Studio to generate an .rdc file.

  5. Connect to the tool, choose Tools > Manage Remote Servers, click the corresponding process, and obtain the .rdc file.

  6. Play the .rdc file and check whether the API information is correct.

Vulkan Application

  1. 1. Copy the libsquid.so file under <installation_folder>/frame_profiler/plugins/ohos/arm64 to the libs/arm64-v8a directory of the HAP.

    2. Copy the squid.json file in the <installation_folder>/frame_profiler/plugins/ohos/sdk directory to the src/main/resource/rawfile directory of the HAP.

    3. Copy the JSON file to the sandbox path of the application through the JS layer. Add the local path of renderdoc.h to the CMakeLists file, for example, D:/addglesapi/open_source/renderdoc/renderdoc/api/app.

    import fs from '@ohos.file.fs';
    uiContext = this.getUIContext();
    aboutToAppear(): void {
        let path = this.uiContext?.getHostContext()?.filesDir;
        let buffer	= this.uiContext?.getHostContext()?.resourceManager.getRawFileContentSync('squid.json') ;
        let file = fs.openSync(path + '/squid.json', fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
        fs.writeSync(file.fd, buffer?.buffer);
      }

  2. Encapsulate the InitRenderDoc(), BeginCapture(), and EndCapture() functions in the .cpp file of the HAP demo. Insert InitRenderDoc() before initialization, insert BeginCapture() before resource capturing, and insert EndCapture() after resource capturing.

    #include "renderdoc_app.h"
    RENDERDOC_API_1_1_2* rdoc_api = nullptr;
    void InitRenderDoc()
    {
    void *mod = dlopen("libsquid.so", RTLD_NOW | RTLD_NOLOAD);
    if (mod) {
    LOGI("[ZT]InitRenderDoc: RenderDoc library loaded");
    pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod, "RENDERDOC_GetAPI");
    if (!RENDERDOC_GetAPI) {
    LOGE("[ZT]dlsym failed: %s", dlerror());
    return;
    }
    int ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_1_2, (void **)&rdoc_api);
    if (ret != 1) {
    LOGE("[ZT]RENDERDOC_GetAPI failed");
    rdoc_api = nullptr;
    }
    } else {
    LOGE("[ZT]InitRenderDoc failed: %s", dlerror());
    }
    }
    void BeginCapture()
    {
    if(rdoc_api) {
    rdoc_api->StartFrameCapture(NULL, NULL);
    }else{
    LOGE("[ZT]NOT BEGINCAPTURE");
    }
    }
    void EndCapture()
    {
    if(rdoc_api) {
    rdoc_api->EndFrameCapture(NULL, NULL);
    }else{
    LOGE("[ZT]NOT  ENDCAPTURE");
    }
    }

    Example of the insertion position:

  3. Configure environment variables.

    hdc shell param set debug.graphic.system_layer_flag 0

    hdc shell param set debug.graphic.debug_layer squid

    hdc shell param set debug.graphic.debug_hap com.huawei.ndkVulkanExample (HAP name)

  4. Run the demo source code on DevEco Studio to generate an .rdc file.

  5. Connect to the tool, choose Tools > Manage Remote Servers, click the corresponding process, and obtain the .rdc file.

  6. Play the .rdc file and check whether the API information is correct.

Search in Operation Guide
Enter a keyword.