package com.xyzshell.andinfo.libs

import android.content.Context
import com.xyzshell.andinfo.libs.gpu.models.EglInformation
import com.xyzshell.andinfo.libs.gpu.models.GlInformation
import com.xyzshell.andinfo.libs.gpu.models.VkPhysicalDevice
import com.xyzshell.andinfo.libs.gpu.models.VkPhysicalDeviceType
import com.xyzshell.andinfo.libs.gpu.models.VkVendorId
import com.xyzshell.andinfo.libs.gpu.utils.EglUtils
import com.xyzshell.andinfo.libs.gpu.utils.VkUtils

class GpuInfo(private val context: Context) {

    init {
        System.loadLibrary("andinfo")
    }

    fun getGpuInformation(): GpuInformationData {
        val vkPhysicalDevices = VkUtils.getVkInfo()
        val eglInformation = EglUtils.getEglInformation()
        return GpuInformationData(vkPhysicalDevices, eglInformation)
    }

    data class GpuInformationData(
        val vkPhysicalDevices: List<VkPhysicalDevice>?,
        val eglInformation: EglInformation?
    )

    companion object {
        val vkPhysicalDeviceTypeToString = mapOf(
            VkPhysicalDeviceType.OTHER.value to "Other",
            VkPhysicalDeviceType.INTEGRATED_GPU.value to "Integrated GPU",
            VkPhysicalDeviceType.DISCRETE_GPU.value to "Discrete GPU",
            VkPhysicalDeviceType.VIRTUAL_GPU.value to "Virtual GPU",
            VkPhysicalDeviceType.CPU.value to "CPU",
        )

        val vkVendorIdToString = mapOf(
            VkVendorId.KHRONOS to "Khronos",
            VkVendorId.VIV to "Vivante",
            VkVendorId.VSI to "VeriSilicon",
            VkVendorId.KAZAN to "Kazan",
            VkVendorId.CODEPLAY to "Codeplay",
            VkVendorId.MESA to "Mesa",
            VkVendorId.POCL to "POCL",
            VkVendorId.MOBILEYE to "Mobileye",
        )
    }
}
