1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2024-11-28 10:24:15 +01:00

added hardware check

This commit is contained in:
Unknown 2020-04-10 14:02:44 +01:00
parent 0a1a2a2ef1
commit c073f6607c

View File

@ -146,6 +146,32 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateInstance(
//TODO ignored for now
//pCreateInfo->pApplicationInfo
{ //Simple check to make sure we only support RPi 0, 1, 2, 3
FILE* f = fopen("/proc/cpuinfo", "r");
if(!f)
{
return VK_ERROR_INITIALIZATION_FAILED;
}
char* str = malloc(4096);
int n = fread(str, 1, 4096, f);
str[n] = '\0';
str = strstr(str, "Hardware");
str = strstr(str, "BCM");
str[7] = '\0';
if(strcmp(str, "BCM2835") &&
strcmp(str, "BCM2836") &&
strcmp(str, "BCM2837"))
{
return VK_ERROR_INITIALIZATION_FAILED;
}
}
//we assume we are on the RPi and the GPU exists...
int gpuExists = access( "/dev/dri/card0", F_OK ) != -1; assert(gpuExists);