This commit is contained in:
elwrcl committed 2026-06-07 11:42:00 +03:00
1 parent 147f8a57bc
commit 33d0cc9f2a
5 files changed
+59 -41

No files matched your search

@@ -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"
}
}
}
+2 -2
View File
@@ -21,12 +21,12 @@ let
hash = "sha256-tZ1rZ+4bRxarcFQhP8V2Mfz0sJ5rBgHYLu2ulrQwL+U="; hash = "sha256-tZ1rZ+4bRxarcFQhP8V2Mfz0sJ5rBgHYLu2ulrQwL+U=";
}; };
}); });
hasvk13-layer = pkgs.callPackage ./hasvk13-layer {}; hasvk14-layer = pkgs.callPackage ./vk {};
in in
{ {
hardware.graphics = { hardware.graphics = {
extraPackages = [ extraPackages = [
hasvk13-layer hasvk14-layer
wayland-intel-vaapi-driver wayland-intel-vaapi-driver
pkgs.libvdpau-va-gl pkgs.libvdpau-va-gl
pkgs.intel-ocl pkgs.intel-ocl
@@ -1,22 +1,22 @@
{ pkgs }: { pkgs }:
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
name = "vulkan-layer-hasvk13"; name = "vulkan-layer-hasvk14";
src = ./.; src = ./.;
buildInputs = [ pkgs.vulkan-headers ]; buildInputs = [ pkgs.vulkan-headers ];
buildPhase = '' 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 -I${pkgs.vulkan-headers}/include
''; '';
installPhase = '' installPhase = ''
mkdir -p $out/lib $out/share/vulkan/implicit_layer.d 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 \ substitute hasvk14_layer.json \
$out/share/vulkan/implicit_layer.d/hasvk13_layer.json \ $out/share/vulkan/implicit_layer.d/hasvk14_layer.json \
--subst-var out --subst-var out
''; '';
} }
@@ -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 <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@@ -10,25 +10,25 @@ static PFN_vkGetInstanceProcAddr g_next_gipa = NULL;
static PFN_vkGetPhysicalDeviceProperties g_next_gdp = NULL; static PFN_vkGetPhysicalDeviceProperties g_next_gdp = NULL;
static PFN_vkGetPhysicalDeviceProperties2 g_next_gdp2 = 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 #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 return vendorID == INTEL_VENDOR_ID
&& VK_API_VERSION_MAJOR(apiVersion) == 1 && VK_API_VERSION_MAJOR(apiVersion) == 1
&& VK_API_VERSION_MINOR(apiVersion) < 3; && VK_API_VERSION_MINOR(apiVersion) < 4;
} }
VKAPI_ATTR VkResult VKAPI_CALL 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; return VK_SUCCESS;
} }
VKAPI_ATTR VkResult VKAPI_CALL VKAPI_ATTR VkResult VKAPI_CALL
HaVK13_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, HaVK14_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, const VkAllocationCallbacks *pAllocator,
VkInstance *pInstance) VkInstance *pInstance)
{ {
@@ -53,24 +53,34 @@ HaVK13_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
g_next_gdp = (PFN_vkGetPhysicalDeviceProperties) g_next_gdp = (PFN_vkGetPhysicalDeviceProperties)
g_next_gipa(*pInstance, "vkGetPhysicalDeviceProperties"); g_next_gipa(*pInstance, "vkGetPhysicalDeviceProperties");
g_next_gdp2 = (PFN_vkGetPhysicalDeviceProperties2) g_next_gdp2 = (PFN_vkGetPhysicalDeviceProperties2)
g_next_gipa(*pInstance, "vkGetPhysicalDeviceProperties2"); g_next_gipa(*pInstance, "vkGetPhysicalDeviceProperties2");
if (!g_next_gdp2) {
g_next_gdp2 = (PFN_vkGetPhysicalDeviceProperties2)
g_next_gipa(*pInstance, "vkGetPhysicalDeviceProperties2KHR");
}
return VK_SUCCESS; return VK_SUCCESS;
} }
VKAPI_ATTR void VKAPI_CALL VKAPI_ATTR void VKAPI_CALL
HaVK13_GetPhysicalDeviceProperties(VkPhysicalDevice device, HaVK14_GetPhysicalDeviceProperties(VkPhysicalDevice device,
VkPhysicalDeviceProperties *props) VkPhysicalDeviceProperties *props)
{ {
if (g_next_gdp) g_next_gdp(device, props); if (g_next_gdp) g_next_gdp(device, props);
if (props && is_intel_below_13(props->vendorID, props->apiVersion)) if (props && is_intel_below_14(props->vendorID, props->apiVersion)) {
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';
}
} }
VKAPI_ATTR void VKAPI_CALL VKAPI_ATTR void VKAPI_CALL
HaVK13_GetPhysicalDeviceProperties2(VkPhysicalDevice device, HaVK14_GetPhysicalDeviceProperties2(VkPhysicalDevice device,
VkPhysicalDeviceProperties2 *props2) VkPhysicalDeviceProperties2 *props2)
{ {
if (g_next_gdp2) g_next_gdp2(device, props2); if (g_next_gdp2) g_next_gdp2(device, props2);
@@ -78,37 +88,45 @@ HaVK13_GetPhysicalDeviceProperties2(VkPhysicalDevice device,
if (!props2) return; if (!props2) return;
VkPhysicalDeviceProperties *props = &props2->properties; 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; VkBaseOutStructure *s = (VkBaseOutStructure *)props2->pNext;
while (s) { while (s) {
if (s->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES) { if (s->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES) {
VkPhysicalDeviceVulkan12Properties *p12 = VkPhysicalDeviceVulkan12Properties *p12 =
(VkPhysicalDeviceVulkan12Properties *)s; (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) { if (s->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES) {
VkPhysicalDeviceDriverProperties *drv = VkPhysicalDeviceDriverProperties *drv =
(VkPhysicalDeviceDriverProperties *)s; (VkPhysicalDeviceDriverProperties *)s;
drv->conformanceVersion = (VkConformanceVersion){ 1, 3, 0, 0 }; drv->conformanceVersion = (VkConformanceVersion){ 1, 4, 1, 1 };
} }
s = s->pNext; s = s->pNext;
} }
} }
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL
HaVK13_GetInstanceProcAddr(VkInstance instance, const char *pName) HaVK14_GetInstanceProcAddr(VkInstance instance, const char *pName)
{ {
#define INTERCEPT(fn) \ #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(GetInstanceProcAddr)
INTERCEPT(EnumerateInstanceVersion) INTERCEPT(EnumerateInstanceVersion)
INTERCEPT(CreateInstance) INTERCEPT(CreateInstance)
INTERCEPT(GetPhysicalDeviceProperties) INTERCEPT(GetPhysicalDeviceProperties)
INTERCEPT(GetPhysicalDeviceProperties2) INTERCEPT(GetPhysicalDeviceProperties2)
if (strcmp(pName, "vkGetPhysicalDeviceProperties2KHR") == 0) {
return (PFN_vkVoidFunction)HaVK14_GetPhysicalDeviceProperties2;
}
#undef INTERCEPT #undef INTERCEPT
return g_next_gipa ? g_next_gipa(instance, pName) : NULL; return g_next_gipa ? g_next_gipa(instance, pName) : NULL;
@@ -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"
}
}
}