Skip to content
Merged
126 changes: 52 additions & 74 deletions Engines/Wine/Verbs/vulkanSDK/script.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,52 @@
include(["engines", "wine", "engine", "object"]);
include(["engines", "wine", "plugins", "regedit"]);
include(["utils", "functions", "net", "resource"]);
include(["utils", "functions", "filesystem", "files"]);

/**
* Verb to install all the necessary things to run winevulkan (even inside wine mainline or newest wine-staging)
* see: https://github.com/roderickc/wine-vulkan
* @returns {Wine} Wine object
*/
Wine.prototype.vulkanSDK = function () {
print("NOTE: you need a graphic driver that supports Vulkan to run winevulkan");
print("NOTE: Vulkan works in wine from version 3.3 (if compiled with vulkan support)");

var sdkVersion = "1.1.73.0";

var setupFile = new Resource()
.wizard(this.wizard())
.url("https://sdk.lunarg.com/sdk/download/" + sdkVersion +"/windows/VulkanSDK-" + sdkVersion + "-Installer.exe")
.checksum("ac34f732818c409bcb283b5c6100b373ab6a2404")
.name("VulkanSDK-" + sdkVersion + "-Installer.exe")
.get();

this.run(setupFile, "/S");

var pathVulkanJSON = this.prefixDirectory() + "drive_c/windows/winevulkan.json"
var contentVulkanJSON = '{\n' +
' "file_format_version": "1.0.0",\n' +
' "ICD": {\n' +
' "library_path": "c:\\windows\\system32\\winevulkan.dll",\n' +
' "api_version": "' + sdkVersion +'"\n' +
' }\n' +
'}'

writeToFile(pathVulkanJSON, contentVulkanJSON);

var regeditFileContent32 =
"REGEDIT4\n" +
"\n" +
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\Drivers\\]\n" +
"\"C:\\\\Windows\\\\winevulkan.json\"=dword:00000000" ;

this.regedit().patch(regeditFileContent32);

if (this.architecture() == "amd64") {
var regeditFileContent64 =
"REGEDIT4\n" +
"\n" +
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Khronos\\Vulkan\\Drivers\\]n" +
"\"C:\\\\Windows\\\\winevulkan.json\"=dword:00000000" ;

this.regedit().patch(regeditFileContent64);
}

return this;
}

/**
* Verb to install all the necessary things to run winevulkan (even inside wine mainline or newest wine-staging)
*/
var verbImplementation = {
install: function (container) {
var wine = new Wine();
wine.prefix(container);
var wizard = SetupWizard(InstallationType.VERBS, "vulkanSDK", java.util.Optional.empty());
wine.wizard(wizard);
wine.vulkanSDK();
wizard.close();
}
};

/* exported Verb */
var Verb = Java.extend(org.phoenicis.engines.Verb, verbImplementation);

include(["engines", "wine", "engine", "object"]);
include(["engines", "wine", "plugins", "regedit"]);
include(["utils", "functions", "net", "resource"]);
include(["utils", "functions", "filesystem", "files"]);

/**
* All the necessary things to run winevulkan (even inside wine mainline or newest wine-staging)
* -> https://github.com/roderickc/wine-vulkan
* @returns {Wine} Wine object
*/
Wine.prototype.vulkanSDK = function () {
print("NOTE: you need a graphic driver that supports Vulkan to run winevulkan");
print("NOTE: Vulkan works in wine from version 3.3 (if compiled with vulkan support)");

var setupFile = new Resource()
.wizard(this.wizard())
.url("https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe?u=")
//checksum changes everytime a new version is released
.name("vulkan-sdk.exe")
.get();

this.run(setupFile, "/S");

var patchVulkanJSON = this.prefixDirectory() + "drive_c/windows/winevulkan.json";
touch(patchVulkanJSON);
writeToFile(patchVulkanJSON, "{\n \"file_format_version\": \"1.0.0\",\n \"ICD\": {\n \"library_path\": \"c:\windows\system32\winevulkan.dll\",\n \"api_version\": \"1.1.92.1\"\n }\n}");
this.run("reg", ["add", "HKLM\Software\Khronos\Vulkan\Drivers", "/v", "C:\Windows\winevulkan.json", "/t", "REG_DWORD", "/d", "00000000", "/f"], null, false, true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be possible to use the regedit plugin. If you explicitly want to use add instead of regedit.patch, you should add an according method to the plugin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can create a ticket to fix this later

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.


if (this.architecture() == "amd64") {
this.run("reg", ["add", "HKLM\Software\Wow6432Node\Khronos\Vulkan\Drivers", "/v", "C:\Windows\winevulkan.json", "/t", "REG_DWORD", "/d", "00000000", "/f"], null, false, true);
}

return this;

}

/**
* Verb to install all the necessary things to run winevulkan (even inside wine mainline or newest wine-staging)
*/
var verbImplementation = {
install: function (container) {
var wine = new Wine();
wine.prefix(container);
var wizard = SetupWizard(InstallationType.VERBS, "vulkanSDK", java.util.Optional.empty());
wine.wizard(wizard);
wine.vulkanSDK();
wizard.close();
}
};

/* exported Verb */
var Verb = Java.extend(org.phoenicis.engines.Verb, verbImplementation);