diff --git a/driver/common.h b/driver/common.h index 061497e..88d5399 100644 --- a/driver/common.h +++ b/driver/common.h @@ -100,12 +100,25 @@ typedef struct VkInstance_T //supposedly this should contain all the enabled layers? int enabledExtensions[numInstanceExtensions]; int numEnabledExtensions; - int chipVersion; - int hasTiling; - int hasControlFlow; - int hasEtc1; - int hasThreadedFs; - int hasMadvise; + uint32_t technologyVersion; + uint32_t IDstrUINT; + uint32_t vpmMemorySize; + uint32_t hdrSupported; + uint32_t numSemaphores; + uint32_t numTMUperSlice; + uint32_t numQPUperSlice; + uint32_t numSlices; + uint32_t v3dRevision; + uint32_t tileBufferDoubleBufferModeSupported; + uint32_t tileBufferSize; + uint32_t vriMemorySize; + uint32_t hasTiling; + uint32_t hasControlFlow; + uint32_t hasEtc1; + uint32_t hasThreadedFs; + uint32_t hasMadvise; + uint32_t hasPerfmon; + uint32_t hasFixedRCLorder; } _instance; typedef struct VkDevice_T diff --git a/driver/instance.c b/driver/instance.c index 19006f4..1596336 100644 --- a/driver/instance.c +++ b/driver/instance.c @@ -156,18 +156,63 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateInstance( int ret = openIoctl(); assert(ret != -1); - (*pInstance)->chipVersion = vc4_get_chip_info(controlFd); + assert(vc4_get_chip_info(controlFd, + &(*pInstance)->technologyVersion, + &(*pInstance)->IDstrUINT, + &(*pInstance)->vpmMemorySize, + &(*pInstance)->hdrSupported, + &(*pInstance)->numSemaphores, + &(*pInstance)->numTMUperSlice, + &(*pInstance)->numQPUperSlice, + &(*pInstance)->numSlices, + &(*pInstance)->v3dRevision, + &(*pInstance)-> tileBufferDoubleBufferModeSupported, + &(*pInstance)->tileBufferSize, + &(*pInstance)->vriMemorySize)); + (*pInstance)->hasTiling = vc4_test_tiling(controlFd); (*pInstance)->hasControlFlow = vc4_has_feature(controlFd, DRM_VC4_PARAM_SUPPORTS_BRANCHES); (*pInstance)->hasEtc1 = vc4_has_feature(controlFd, DRM_VC4_PARAM_SUPPORTS_ETC1); (*pInstance)->hasThreadedFs = vc4_has_feature(controlFd, DRM_VC4_PARAM_SUPPORTS_THREADED_FS); (*pInstance)->hasMadvise = vc4_has_feature(controlFd, DRM_VC4_PARAM_SUPPORTS_MADVISE); + (*pInstance)->hasPerfmon = vc4_has_feature(controlFd, DRM_VC4_PARAM_SUPPORTS_PERFMON); + (*pInstance)->hasFixedRCLorder = vc4_has_feature(controlFd, DRM_VC4_PARAM_SUPPORTS_FIXED_RCL_ORDER); + + char IDstring[] = { 0, 0, 0, 0 }; + memcpy(IDstring, &(*pInstance)->IDstrUINT, 3); + + printf("------------------------------------------\n"); + printf("------------------------------------------\n"); + printf("V3D chip info: \n"); + printf("IDstring %s\n", IDstring); + printf("technologyVersion: %u\n", (*pInstance)->technologyVersion); + printf("v3dRevision %u\n", (*pInstance)->v3dRevision); + printf("vpmMemorySize %u\n", (*pInstance)->vpmMemorySize); + printf("numSemaphores %u\n", (*pInstance)->numSemaphores); + printf("numTMUperSlice %u\n", (*pInstance)->numTMUperSlice); + printf("numQPUperSlice %u\n", (*pInstance)->numQPUperSlice); + printf("numSlices %u\n", (*pInstance)->numSlices); + printf("tileBufferSize %s\n", (*pInstance)->tileBufferSize > 0 ? + (*pInstance)->tileBufferSize > 1 ? "full" : "half" : "quarter"); + printf("vriMemorySize %s\n", (*pInstance)->vriMemorySize ? "full" : "half"); + printf("hdrSupported %u\n", (*pInstance)->hdrSupported); + printf("tileBufferDoubleBufferModeSupported %u\n", (*pInstance)-> tileBufferDoubleBufferModeSupported); + printf("hasTiling %u\n", (*pInstance)->hasTiling); + printf("hasControlFlow %u\n", (*pInstance)->hasControlFlow); + printf("hasEtc1 %u\n", (*pInstance)->hasEtc1); + printf("hasThreadedFs %u\n", (*pInstance)->hasThreadedFs); + printf("hasMadvise %u\n", (*pInstance)->hasMadvise); + printf("hasPerfmon %u\n", (*pInstance)->hasPerfmon); + printf("hasFixedRCLorder %u\n", (*pInstance)->hasFixedRCLorder); + printf("------------------------------------------\n"); + printf("------------------------------------------\n"); assert((*pInstance)->hasTiling); assert((*pInstance)->hasControlFlow); assert((*pInstance)->hasEtc1); assert((*pInstance)->hasThreadedFs); + assert((*pInstance)->hasPerfmon); return VK_SUCCESS; } diff --git a/driver/kernelInterface.c b/driver/kernelInterface.c index a96cb22..7404ca0 100644 --- a/driver/kernelInterface.c +++ b/driver/kernelInterface.c @@ -52,9 +52,33 @@ static uint32_t align(uint32_t num, uint32_t alignment) } } -int vc4_get_chip_info(int fd) +int vc4_get_chip_info(int fd, + uint32_t* technologyVersion, + uint32_t* IDstrUINT, + uint32_t* vpmMemorySize, + uint32_t* hdrSupported, + uint32_t* numSemaphores, + uint32_t* numTMUperSlice, + uint32_t* numQPUperSlice, + uint32_t* numSlices, + uint32_t* v3dRevision, + uint32_t* tileBufferDoubleBufferModeSupported, + uint32_t* tileBufferSize, + uint32_t* vriMemorySize) { assert(fd); + assert(technologyVersion); + assert(IDstrUINT); + assert(vpmMemorySize); + assert(hdrSupported); + assert(numSemaphores); + assert(numTMUperSlice); + assert(numQPUperSlice); + assert(numSlices); + assert(v3dRevision); + assert(tileBufferDoubleBufferModeSupported); + assert(tileBufferSize); + assert(vriMemorySize); struct drm_vc4_get_param ident0 = { .param = DRM_VC4_PARAM_V3D_IDENT0, @@ -62,6 +86,9 @@ int vc4_get_chip_info(int fd) struct drm_vc4_get_param ident1 = { .param = DRM_VC4_PARAM_V3D_IDENT1, }; + struct drm_vc4_get_param ident2 = { + .param = DRM_VC4_PARAM_V3D_IDENT2, + }; int ret; ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_PARAM, &ident0); @@ -70,7 +97,7 @@ int vc4_get_chip_info(int fd) /* Backwards compatibility with 2835 kernels which * only do V3D 2.1. */ - return 21; + return 0; //21 } else { fprintf(stderr, "Couldn't get V3D IDENT0: %s\n", strerror(errno)); @@ -83,19 +110,37 @@ int vc4_get_chip_info(int fd) strerror(errno)); return 0; } - - uint32_t major = (ident0.value >> 24) & 0xff; - uint32_t minor = (ident1.value >> 0) & 0xf; - uint32_t v3d_ver = major * 10 + minor; - - if (v3d_ver != 21 && v3d_ver != 26) { - fprintf(stderr, "V3D %d.%d not supported.\n", - v3d_ver / 10, - v3d_ver % 10); + ret = drmIoctl(fd, DRM_IOCTL_VC4_GET_PARAM, &ident2); + if (ret != 0) { + fprintf(stderr, "Couldn't get V3D IDENT2: %s\n", + strerror(errno)); return 0; } - return v3d_ver; + *technologyVersion = (ident0.value >> 24) & 0xff; + *IDstrUINT = (ident0.value >> 0) & 0x00ffffff; + + *vpmMemorySize = ((ident1.value >> 28) & 0xf) * 1024; //multiples of 1K + *hdrSupported = (ident1.value >> 24) & 0xf; + *numSemaphores = (ident1.value >> 16) & 0xff; + *numTMUperSlice = (ident1.value >> 12) & 0xf; + *numQPUperSlice = (ident1.value >> 8) & 0xf; + *numSlices = (ident1.value >> 4) & 0xf; + *v3dRevision = (ident1.value >> 0) & 0xf; + + *tileBufferDoubleBufferModeSupported = (ident2.value >> 8) & 0xf; + *tileBufferSize = (ident2.value >> 4) & 0xf; + *vriMemorySize = (ident2.value >> 0) & 0xf; + + uint32_t v3d_ver = (*technologyVersion) * 10 + (*v3dRevision); + + if(v3d_ver != 21 && v3d_ver != 26) + { + printf("v3d_ver unsupported: %u\n", v3d_ver); + return 0; + } + + return 1; } int vc4_has_feature(int fd, uint32_t feature) diff --git a/driver/kernelInterface.h b/driver/kernelInterface.h index 91071ed..740a165 100644 --- a/driver/kernelInterface.h +++ b/driver/kernelInterface.h @@ -40,7 +40,19 @@ extern int controlFd; int openIoctl(); void closeIoctl(); -int vc4_get_chip_info(int fd); +int vc4_get_chip_info(int fd, + uint32_t* technologyVersion, + uint32_t* IDstrUINT, + uint32_t* vpmMemorySize, + uint32_t* hdrSupported, + uint32_t* numSemaphores, + uint32_t* numTMUperSlice, + uint32_t* numQPUperSlice, + uint32_t* numSlices, + uint32_t* v3dRevision, + uint32_t* tileBufferDoubleBufferModeSupported, + uint32_t* tileBufferSize, + uint32_t* vriMemorySize); int vc4_has_feature(int fd, uint32_t feature); int vc4_test_tiling(int fd); uint64_t vc4_bo_get_tiling(int fd, uint32_t bo, uint64_t mod);