diff --git a/modules/nixos/hardware/graphics/hasvk13-layer/hasvk13_layer.json b/modules/nixos/hardware/graphics/hasvk13-layer/hasvk13_layer.json deleted file mode 100644 index f46e4af..0000000 --- a/modules/nixos/hardware/graphics/hasvk13-layer/hasvk13_layer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "file_format_version": "1.1.2", - "layer": { - "name": "VK_LAYER_hasvk13_version_override", - "type": "GLOBAL", - "library_path": "@out@/lib/libVkLayer_hasvk13.so", - "api_version": "1.3.0", - "implementation_version": "1", - "description": "Force Intel HD 4000 (hasvk) to report Vulkan 1.3", - "functions": { - "vkGetInstanceProcAddr": "HaVK13_GetInstanceProcAddr" - }, - "disable_environment": { - "DISABLE_HASVK13_LAYER": "1" - } - } -} \ No newline at end of file diff --git a/modules/nixos/hardware/graphics/intel.nix b/modules/nixos/hardware/graphics/intel.nix index 4a37651..ffd369f 100755 --- a/modules/nixos/hardware/graphics/intel.nix +++ b/modules/nixos/hardware/graphics/intel.nix @@ -21,12 +21,12 @@ let hash = "sha256-tZ1rZ+4bRxarcFQhP8V2Mfz0sJ5rBgHYLu2ulrQwL+U="; }; }); - hasvk13-layer = pkgs.callPackage ./hasvk13-layer {}; + hasvk14-layer = pkgs.callPackage ./vk {}; in { hardware.graphics = { extraPackages = [ - hasvk13-layer + hasvk14-layer wayland-intel-vaapi-driver pkgs.libvdpau-va-gl pkgs.intel-ocl diff --git a/modules/nixos/hardware/graphics/hasvk13-layer/default.nix b/modules/nixos/hardware/graphics/vk/default.nix similarity index 53% rename from modules/nixos/hardware/graphics/hasvk13-layer/default.nix rename to modules/nixos/hardware/graphics/vk/default.nix index 09cfa86..2ccdd57 100644 --- a/modules/nixos/hardware/graphics/hasvk13-layer/default.nix +++ b/modules/nixos/hardware/graphics/vk/default.nix @@ -1,22 +1,22 @@ { pkgs }: pkgs.stdenv.mkDerivation { - name = "vulkan-layer-hasvk13"; + name = "vulkan-layer-hasvk14"; src = ./.; buildInputs = [ pkgs.vulkan-headers ]; buildPhase = '' - $CC -shared -fPIC -O2 -o libVkLayer_hasvk13.so hasvk13_layer.c \ + $CC -shared -fPIC -O2 -o libVkLayer_hasvk14.so hasvk14_layer.c \ -I${pkgs.vulkan-headers}/include ''; installPhase = '' mkdir -p $out/lib $out/share/vulkan/implicit_layer.d - cp libVkLayer_hasvk13.so $out/lib/ + cp libVkLayer_hasvk14.so $out/lib/ - substitute hasvk13_layer.json \ - $out/share/vulkan/implicit_layer.d/hasvk13_layer.json \ + substitute hasvk14_layer.json \ + $out/share/vulkan/implicit_layer.d/hasvk14_layer.json \ --subst-var out ''; } diff --git a/modules/nixos/hardware/graphics/hasvk13-layer/hasvk13_layer.c b/modules/nixos/hardware/graphics/vk/hasvk14_layer.c similarity index 64% rename from modules/nixos/hardware/graphics/hasvk13-layer/hasvk13_layer.c rename to modules/nixos/hardware/graphics/vk/hasvk14_layer.c index dc61b62..afb8121 100644 --- a/modules/nixos/hardware/graphics/hasvk13-layer/hasvk13_layer.c +++ b/modules/nixos/hardware/graphics/vk/hasvk14_layer.c @@ -1,5 +1,5 @@ /* - * Vulkan implicit layer forces VK 1.3.348 + * Vulkan implicit layer forces VK 1.4.x (e.g. 1.4.348 via headers) */ #include @@ -10,25 +10,25 @@ static PFN_vkGetInstanceProcAddr g_next_gipa = NULL; static PFN_vkGetPhysicalDeviceProperties g_next_gdp = NULL; static PFN_vkGetPhysicalDeviceProperties2 g_next_gdp2 = NULL; -#define HASVK13_API_VERSION VK_MAKE_API_VERSION(0, 1, 3, VK_HEADER_VERSION) +#define HASVK14_API_VERSION VK_MAKE_API_VERSION(0, 1, 4, VK_HEADER_VERSION) #define INTEL_VENDOR_ID 0x8086 -static int is_intel_below_13(uint32_t vendorID, uint32_t apiVersion) +static int is_intel_below_14(uint32_t vendorID, uint32_t apiVersion) { return vendorID == INTEL_VENDOR_ID && VK_API_VERSION_MAJOR(apiVersion) == 1 - && VK_API_VERSION_MINOR(apiVersion) < 3; + && VK_API_VERSION_MINOR(apiVersion) < 4; } VKAPI_ATTR VkResult VKAPI_CALL -HaVK13_EnumerateInstanceVersion(uint32_t *pApiVersion) +HaVK14_EnumerateInstanceVersion(uint32_t *pApiVersion) { - *pApiVersion = HASVK13_API_VERSION; + *pApiVersion = HASVK14_API_VERSION; return VK_SUCCESS; } VKAPI_ATTR VkResult VKAPI_CALL -HaVK13_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, +HaVK14_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) { @@ -53,24 +53,34 @@ HaVK13_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, g_next_gdp = (PFN_vkGetPhysicalDeviceProperties) g_next_gipa(*pInstance, "vkGetPhysicalDeviceProperties"); + g_next_gdp2 = (PFN_vkGetPhysicalDeviceProperties2) g_next_gipa(*pInstance, "vkGetPhysicalDeviceProperties2"); + + if (!g_next_gdp2) { + g_next_gdp2 = (PFN_vkGetPhysicalDeviceProperties2) + g_next_gipa(*pInstance, "vkGetPhysicalDeviceProperties2KHR"); + } return VK_SUCCESS; } VKAPI_ATTR void VKAPI_CALL -HaVK13_GetPhysicalDeviceProperties(VkPhysicalDevice device, +HaVK14_GetPhysicalDeviceProperties(VkPhysicalDevice device, VkPhysicalDeviceProperties *props) { if (g_next_gdp) g_next_gdp(device, props); - if (props && is_intel_below_13(props->vendorID, props->apiVersion)) - props->apiVersion = HASVK13_API_VERSION; + if (props && is_intel_below_14(props->vendorID, props->apiVersion)) { + props->apiVersion = HASVK14_API_VERSION; + + strncpy(props->deviceName, "Intel(R) HD 4000 (Copland VK 1.4)", VK_MAX_PHYSICAL_DEVICE_NAME_SIZE - 1); + props->deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE - 1] = '\0'; + } } VKAPI_ATTR void VKAPI_CALL -HaVK13_GetPhysicalDeviceProperties2(VkPhysicalDevice device, +HaVK14_GetPhysicalDeviceProperties2(VkPhysicalDevice device, VkPhysicalDeviceProperties2 *props2) { if (g_next_gdp2) g_next_gdp2(device, props2); @@ -78,38 +88,46 @@ HaVK13_GetPhysicalDeviceProperties2(VkPhysicalDevice device, if (!props2) return; VkPhysicalDeviceProperties *props = &props2->properties; - if (!is_intel_below_13(props->vendorID, props->apiVersion)) return; + if (!is_intel_below_14(props->vendorID, props->apiVersion)) return; - props->apiVersion = HASVK13_API_VERSION; + props->apiVersion = HASVK14_API_VERSION; + + strncpy(props->deviceName, "Intel(R) HD 4000 (Copland VK 1.4)", VK_MAX_PHYSICAL_DEVICE_NAME_SIZE - 1); + props->deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE - 1] = '\0'; VkBaseOutStructure *s = (VkBaseOutStructure *)props2->pNext; while (s) { if (s->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES) { VkPhysicalDeviceVulkan12Properties *p12 = (VkPhysicalDeviceVulkan12Properties *)s; - p12->conformanceVersion = (VkConformanceVersion){ 1, 3, 0, 0 }; + p12->conformanceVersion = (VkConformanceVersion){ 1, 4, 1, 1 }; } if (s->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES) { VkPhysicalDeviceDriverProperties *drv = (VkPhysicalDeviceDriverProperties *)s; - drv->conformanceVersion = (VkConformanceVersion){ 1, 3, 0, 0 }; + drv->conformanceVersion = (VkConformanceVersion){ 1, 4, 1, 1 }; } s = s->pNext; } } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL -HaVK13_GetInstanceProcAddr(VkInstance instance, const char *pName) +HaVK14_GetInstanceProcAddr(VkInstance instance, const char *pName) { #define INTERCEPT(fn) \ - if (strcmp(pName, #fn) == 0) return (PFN_vkVoidFunction)HaVK13_##fn; + if (strcmp(pName, "vk" #fn) == 0) return (PFN_vkVoidFunction)HaVK14_##fn; INTERCEPT(GetInstanceProcAddr) INTERCEPT(EnumerateInstanceVersion) INTERCEPT(CreateInstance) INTERCEPT(GetPhysicalDeviceProperties) INTERCEPT(GetPhysicalDeviceProperties2) + + if (strcmp(pName, "vkGetPhysicalDeviceProperties2KHR") == 0) { + return (PFN_vkVoidFunction)HaVK14_GetPhysicalDeviceProperties2; + } + #undef INTERCEPT return g_next_gipa ? g_next_gipa(instance, pName) : NULL; -} +} \ No newline at end of file diff --git a/modules/nixos/hardware/graphics/vk/hasvk14_layer.json b/modules/nixos/hardware/graphics/vk/hasvk14_layer.json new file mode 100644 index 0000000..b82a691 --- /dev/null +++ b/modules/nixos/hardware/graphics/vk/hasvk14_layer.json @@ -0,0 +1,17 @@ +{ + "file_format_version": "1.1.2", + "layer": { + "name": "VK_LAYER_hasvk14_version_override", + "type": "GLOBAL", + "library_path": "@out@/lib/libVkLayer_hasvk14.so", + "api_version": "1.4.0", + "implementation_version": "1", + "description": "Intel Hard Graphics", + "functions": { + "vkGetInstanceProcAddr": "HaVK14_GetInstanceProcAddr" + }, + "disable_environment": { + "DISABLE_HASVK14_LAYER": "1" + } + } +} \ No newline at end of file