Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First class DXVK support #1201

Merged
merged 91 commits into from
Apr 1, 2023
Merged

First class DXVK support #1201

merged 91 commits into from
Apr 1, 2023

Conversation

Beyley
Copy link
Contributor

@Beyley Beyley commented Jan 9, 2023

Summary of the PR

  • Windows native libraries
  • Linux SDL native libraries
  • Linux GLFW native libaries
  • Add overload on functions like D3D11.GetApi() to force DXVK and to let the user pass in an IWindow so we pick the right native libraries on Linux (there are entirely different versions of the binary for SDL and GLFW)
  • Test D3D11 example on DXVK on windows
  • Get D3D11 example working under Linux natively using DXVK
  • D3DCompile replacement

Further Comments

I need to contact the DXVK developers about best practices with packaging DXVK (both Windows and Linux versions), so we dont pull a Manjaro

@Beyley Beyley requested a review from a team as a code owner January 9, 2023 05:27
@Perksey Perksey marked this pull request as draft January 9, 2023 14:25
@Beyley
Copy link
Contributor Author

Beyley commented Jan 13, 2023

Current blocker: we need to provide a modified version of vkd3d, and getting that to load seems to require LD_LIBRARY_PATH modifications, due to cross-library dependencies

diff --git a/include/vkd3d_windows.h b/include/vkd3d_windows.h
index 002ff667..097a4787 100644
--- a/include/vkd3d_windows.h
+++ b/include/vkd3d_windows.h
@@ -186,7 +186,7 @@ typedef struct SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
         ((type *)((char *)(address) - offsetof(type, field)))
 
 # ifdef __x86_64__
-#  define __stdcall __attribute__((ms_abi))
+#  define __stdcall 
 # else
 #  if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
 #   define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))

@Beyley
Copy link
Contributor Author

Beyley commented Jan 20, 2023

Current blocker: we need to provide a modified version of vkd3d, and getting that to load seems to require LD_LIBRARY_PATH modifications, due to cross-library dependencies

diff --git a/include/vkd3d_windows.h b/include/vkd3d_windows.h
index 002ff667..097a4787 100644
--- a/include/vkd3d_windows.h
+++ b/include/vkd3d_windows.h
@@ -186,7 +186,7 @@ typedef struct SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
         ((type *)((char *)(address) - offsetof(type, field)))
 
 # ifdef __x86_64__
-#  define __stdcall __attribute__((ms_abi))
+#  define __stdcall 
 # else
 #  if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
 #   define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))

Thinking about it, if we load the dependencies of vkd3d-utils using dlopen before doing dlopen on vkd3d-utils, it should work, so perhaps a params string[] parameter on CreateDefaultContext to specify pre-load dependencies would work? itd be something like CreateDefaultContext("vkd3d-utils", "vkd3d", "vkd3d-shader") to specify to load vkd3d, then vkd3d-shader as dependencies, then load vkd3d-utils

@Perksey
Copy link
Member

Perksey commented Jan 20, 2023

Plumbing it into CreateDefaultContext probably isn't the best. Maybe something like:

partial class D3DCompiler
{
    static D3DCompiler()
    {
        // static method
        LibraryLoader.RegisterDependency("vkd3d-utils", "vkd3d", "vkd3d-shader");
    }
}

and plumb it into LibraryLoader directly. SilkTouch probably shouldn't know about intercepting the load calls to do extra work beforehand, and should probably just be a loader specific task.

@Beyley
Copy link
Contributor Author

Beyley commented Jan 20, 2023

Plumbing it into CreateDefaultContext probably isn't the best. Maybe something like:

partial class D3DCompiler
{
    static D3DCompiler()
    {
        // static method
        LibraryLoader.RegisterDependency("vkd3d-utils", "vkd3d", "vkd3d-shader");
    }
}

and plumb it into LibraryLoader directly. SilkTouch probably shouldn't know about intercepting the load calls to do extra work beforehand, and should probably just be a loader specific task.

makes sense

@Beyley
Copy link
Contributor Author

Beyley commented Jan 20, 2023

oh my i just saw the CI what

@Beyley Beyley force-pushed the dxvk-native-packagse branch 2 times, most recently from f6f1c65 to c4cf564 Compare January 22, 2023 21:55
@Beyley Beyley marked this pull request as ready for review February 7, 2023 00:35
@Beyley
Copy link
Contributor Author

Beyley commented Feb 7, 2023

ready for review, but not ready for merge until i can get in contact with the dxvk/vkd3d people, i dont want to push broken libs

@Beyley Beyley force-pushed the dxvk-native-packagse branch 2 times, most recently from f8df5fc to 0686395 Compare February 11, 2023 03:20
@Perksey
Copy link
Member

Perksey commented Feb 17, 2023

Status update?

@Beyley
Copy link
Contributor Author

Beyley commented Feb 17, 2023

Status update?

DXVK on windows needs testing, but aside from that, it's ready for review

@Perksey
Copy link
Member

Perksey commented Feb 17, 2023

Did you want it merged without that though?

@Beyley
Copy link
Contributor Author

Beyley commented Feb 17, 2023

Did you want it merged without that though?

it's fine to wait until someone can test, this PR shouldnt block releases, and i dont want to be merging in like 15mb of native libs that dont even work

@Perksey
Copy link
Member

Perksey commented Mar 29, 2023

This needs a rebase.

If you can give me binaries and exact instructions I can test on Windows.

Beyley and others added 19 commits March 29, 2023 03:57
…Jan 9 12:49:59 UTC 2023 (#1285)

Co-authored-by: The Silk.NET Automaton <[email protected]>
…an 9 12:49:59 UTC 2023 (#1286)

Co-authored-by: The Silk.NET Automaton <[email protected]>
…Jan 9 12:49:59 UTC 2023 (#1287)

Co-authored-by: The Silk.NET Automaton <[email protected]>
* New binaries for Vulkan Loader on Linux 5.15.0-1034-azure #41-Ubuntu SMP Fri Feb 10 19:59:45 UTC 2023

* New binaries for Vulkan Loader on Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64

* New binaries for Vulkan Loader on Microsoft Windows 10.0.20348

---------

Co-authored-by: The Silk.NET Automaton <[email protected]>
* New binaries for GLFW on Linux 5.15.0-1034-azure #41-Ubuntu SMP Fri Feb 10 19:59:45 UTC 2023

* New binaries for GLFW on Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64

* New binaries for GLFW on Microsoft Windows 10.0.20348

---------

Co-authored-by: The Silk.NET Automaton <[email protected]>
…Feb 10 19:59:45 UTC 2023 (#1327)

Co-authored-by: The Silk.NET Automaton <[email protected]>
* New binaries for Assimp on Linux 5.15.0-1034-azure #41-Ubuntu SMP Fri Feb 10 19:59:45 UTC 2023

* New binaries for Assimp on Microsoft Windows 10.0.20348

* New binaries for Assimp on Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64

---------

Co-authored-by: The Silk.NET Automaton <[email protected]>
…eb 10 19:59:45 UTC 2023 (#1329)

Co-authored-by: The Silk.NET Automaton <[email protected]>
@Beyley
Copy link
Contributor Author

Beyley commented Mar 29, 2023

This needs a rebase.

If you can give me binaries and exact instructions I can test on Windows.

@Perksey

All you need to do is go into the src/Native/Silk.NET.Vkd3d.Native, run a dotnet pack, do the same with the DXVK native package, then you want to add the nuget source, then apply this patch:

diff --git a/examples/CSharp/Direct3D11 Tutorials/Tutorial 1.2 - Hello quad/Program.cs b/examples/CSharp/Direct3D11 Tutorials/Tutorial 1.2 - Hello quad/Program.cs
index 3ba233a72..4451f27a7 100644
--- a/examples/CSharp/Direct3D11 Tutorials/Tutorial 1.2 - Hello quad/Program.cs	
+++ b/examples/CSharp/Direct3D11 Tutorials/Tutorial 1.2 - Hello quad/Program.cs	
@@ -113,7 +113,7 @@ window.Dispose();
 unsafe void OnLoad()
 {
     //Whether or not to force use of DXVK on platforms where native DirectX implementations are available
-    const bool forceDxvk = false;
+    const bool forceDxvk = true;
 
     dxgi = DXGI.GetApi(window, forceDxvk);
     d3d11 = D3D11.GetApi(window, forceDxvk);
diff --git a/examples/CSharp/Direct3D11 Tutorials/Tutorial 1.2 - Hello quad/Tutorial 1.2 - Hello quad.csproj b/examples/CSharp/Direct3D11 Tutorials/Tutorial 1.2 - Hello quad/Tutorial 1.2 - Hello quad.csproj
index eddc35792..dfc1d4d7d 100644
--- a/examples/CSharp/Direct3D11 Tutorials/Tutorial 1.2 - Hello quad/Tutorial 1.2 - Hello quad.csproj	
+++ b/examples/CSharp/Direct3D11 Tutorials/Tutorial 1.2 - Hello quad/Tutorial 1.2 - Hello quad.csproj	
@@ -16,6 +16,9 @@
       <ProjectReference Include="..\..\..\..\src\Microsoft\Silk.NET.Direct3D11\Silk.NET.Direct3D11.csproj" />
       <ProjectReference Include="..\..\..\..\src\Microsoft\Silk.NET.DXGI\Silk.NET.DXGI.csproj" />
       <ProjectReference Include="..\..\..\..\src\Windowing\Silk.NET.Windowing\Silk.NET.Windowing.csproj" />
+
+      <PackageReference Include="Silk.NET.Vkd3d.Native" Version="2.17.0" />
+      <PackageReference Include="Silk.NET.DXVK.Native" Version="2.17.0" />
     </ItemGroup>
 
 </Project>

then when running the d3d11 tutorial, it should use DXVK (you can look at console output, there should be a bunch of stuff printed from DXVK)

@Perksey Perksey enabled auto-merge (squash) April 1, 2023 00:29
@Beyley Beyley disabled auto-merge April 1, 2023 03:51
@Beyley Beyley merged commit 1c59ebe into main Apr 1, 2023
@Beyley Beyley deleted the dxvk-native-packagse branch April 1, 2023 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants