Overview

A simple demo is provided to make HUAWEI GPU Extensions more accessible to developers. You need to:

What You Will Create

In this codelab, you will use the demo project to call GPU Extensionss APIs. Through the demo project, you will:

What You Will Learn

Hardware Requirements

Software Requirements

Required Knowledge

Smart Cache for GLES

  1. Check if Smart Cache is supported by calling glGetstring. If GL_HUAWEI_smart_cache is returned, GLES supports Smart Cache. Otherwise, Smart Cache is not supported.
    const char* extensions = (const char*) glGetString(GL_EXTENSIONS); if (strstr(extensions, "GL_HUAWEI_smart_cache")) { gSmartCache = true; }
  2. Define the flag bit of Smart Cache.
    #define GL_SMART_CACHE_TEXTURE 0x40000 #define GL_SMART_CACHE_FBO 0x80000
  3. Bit-wise OR the macros in step 2 based on the memory type to obtain memory for the corresponding attribute.
    glTexImage2D(GL_TEXTURE_2D | GL_TEXTURE_SMART_CACHE_xxx, …) glTexStorage2D(GL_TEXTURE_2D | GL_TEXTURE_SMART_CACHE_xxx, …)

Smart Cache for Vulkan

  1. Call the vkEnumerateDeviceExtensionProperties function to query the extensions provided by the platform. If VK_HUAWEI_smart_cache is among the returns, Vulkan-based Smart Cache is supported.
    vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extCount, &extensions.front())
  2. Add VK_HUAWEI_smart_cache to the extension list when you create a device using vkCreateDevice.
    supportedExtensions.push_back(ext.extensionName);
  3. Set memoryTypeIndex to 3, 4, or 5 based on the memory type. The three values indicate corresponding purposes of memory allocation: frame buffer attachment, normal textures, and textures.
    //Memory type is FBO. if(smartCacheSupported) { memAllloc.memoryTypeIndex = 3; }

Pre-rotation

  1. Call the vkEnumerateDeviceExtensionProperties function to check if pre-rotation is supported.
    vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extCount, &extensions.front())
  2. Add VK_ HUAWEI _prerotation to the extension list when you create a device using vkCreateDevice. Add the extension name VK_HUAWEI _prerotation to VkDeviceCreateInfo.ppEnabledExtensionNames.
    supportedExtensions.push_back(ext.extensionName);

Well done. You have successfully completed this codelab and learned how to:

For more information, please click the following link:

Related documents
Download the demo source code used in this codelab from the following address:

Download source code

Code copied