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

Compile for Linux like dxvk-native #15

Closed
Beyley opened this issue Jul 24, 2022 · 22 comments
Closed

Compile for Linux like dxvk-native #15

Beyley opened this issue Jul 24, 2022 · 22 comments
Labels
build enhancement New feature or request

Comments

@Beyley
Copy link

Beyley commented Jul 24, 2022

would it be possible to compile this for linux, similar to what DXVK-Native does?

@AlpyneDreams
Copy link
Owner

Hypothetically, yes. However I'm not sure why you'd need that. Do you have a lot of D3D8 code you want to run on Linux?

@Beyley
Copy link
Author

Beyley commented Oct 29, 2022

Hypothetically, yes. However I'm not sure why you'd need that. Do you have a lot of D3D8 code you want to run on Linux?

I need to develop an app for a very old system, and i mainly use linux for development, i could just use a windows VM, but thats quite inconvenient

@AlpyneDreams
Copy link
Owner

Hypothetically, yes. However I'm not sure why you'd need that. Do you have a lot of D3D8 code you want to run on Linux?

I need to develop an app for a very old system, and i mainly use linux for development, i could just use a windows VM, but thats quite inconvenient

If it can run Vulkan then it can probably run d9vk. If it can't run d9vk, then it won't run d8vk. So I would suggest using dxvk-native in d3d9 mode. The API is extremely similar but easier to use than d3d8.

@AlpyneDreams AlpyneDreams closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2022
@AlpyneDreams AlpyneDreams changed the title Compile for Linux Compile for Linux like dxvk-native Nov 3, 2022
@AlpyneDreams
Copy link
Owner

I will leave this open because we might support this down the line. But I would still suggest using d3d9.

@AlpyneDreams AlpyneDreams reopened this Nov 3, 2022
@AlpyneDreams AlpyneDreams added enhancement New feature or request build labels Nov 3, 2022
@Beyley
Copy link
Author

Beyley commented Nov 3, 2022

Hypothetically, yes. However I'm not sure why you'd need that. Do you have a lot of D3D8 code you want to run on Linux?

I need to develop an app for a very old system, and i mainly use linux for development, i could just use a windows VM, but thats quite inconvenient

If it can run Vulkan then it can probably run d9vk. If it can't run d9vk, then it won't run d8vk. So I would suggest using dxvk-native in d3d9 mode. The API is extremely similar but easier to use than d3d8.

I meant using d8vk on my linux desktop to develop, then normal dx8 on the machine

@AlpyneDreams
Copy link
Owner

Hypothetically, yes. However I'm not sure why you'd need that. Do you have a lot of D3D8 code you want to run on Linux?

I need to develop an app for a very old system, and i mainly use linux for development, i could just use a windows VM, but thats quite inconvenient

If it can run Vulkan then it can probably run d9vk. If it can't run d9vk, then it won't run d8vk. So I would suggest using dxvk-native in d3d9 mode. The API is extremely similar but easier to use than d3d8.

I meant using d8vk on my linux desktop to develop, then normal dx8 on the machine

Oh I see. The machine is Windows and can't run d3d9? How old are we talking here?

I will look into the possibility of a native build and get back to you shortly.

@Beyley
Copy link
Author

Beyley commented Nov 4, 2022

Hypothetically, yes. However I'm not sure why you'd need that. Do you have a lot of D3D8 code you want to run on Linux?

I need to develop an app for a very old system, and i mainly use linux for development, i could just use a windows VM, but thats quite inconvenient

If it can run Vulkan then it can probably run d9vk. If it can't run d9vk, then it won't run d8vk. So I would suggest using dxvk-native in d3d9 mode. The API is extremely similar but easier to use than d3d8.

I meant using d8vk on my linux desktop to develop, then normal dx8 on the machine

Oh I see. The machine is Windows and can't run d3d9? How old are we talking here?

I will look into the possibility of a native build and get back to you shortly.

machine is an old windows box with a ti4200 iirc, no dx9

@AlpyneDreams
Copy link
Owner

AlpyneDreams commented Nov 4, 2022

machine is an old windows box with a ti4200 iirc, no dx9

Interesting lmao

Looks like a native build is possible. I have pushed a commit that makes it possible to complete a GCC build. Try the following command if you want to only build d8vk. Note that d3d9.dll is still required to be present as of now.

meson --buildtype "release" -Denable_d3d10=false -Denable_d3d11=false -Denable_dxgi=false -Denable_d3d9=true -Denable_d3d8=true native

Change native to your desired build dir ofc.

Note that there will be a lot of macro redefinition warnings still but that shouldn't stop it compiling.

@AlpyneDreams
Copy link
Owner

Let me know if it works or not. There may be some more tweaking required but I expect this ought to work.

@Beyley
Copy link
Author

Beyley commented Nov 7, 2022

It compiled! im going to try to test it now

@Beyley
Copy link
Author

Beyley commented Nov 7, 2022

warn:  D3D9InterfaceEx::QueryInterface: Unknown interface query
warn:  d3d9acab-a407-773e-18e9-cafebeef2000
err:   GetD3D9Bridge: ERROR! Failed to get D3D9 Bridge. d3d9.dll might be DXVK, but not a version built for D8VK!
err:   Please install the d3d9.dll that came with d3d8.dll

the libdxvk_d3d9.so was taken directly from the same output dir as the d8vk, eg. /d8vk/native/src/d3d9

@AlpyneDreams
Copy link
Owner

warn:  D3D9InterfaceEx::QueryInterface: Unknown interface query
warn:  d3d9acab-a407-773e-18e9-cafebeef2000
err:   GetD3D9Bridge: ERROR! Failed to get D3D9 Bridge. d3d9.dll might be DXVK, but not a version built for D8VK!
err:   Please install the d3d9.dll that came with d3d8.dll

the libdxvk_d3d9.so was taken directly from the same output dir as the d8vk, eg. /d8vk/native/src/d3d9

Interesting. I'll look into this more later. I expect it's a simple fix.

@AlpyneDreams
Copy link
Owner

@Beyley
I am not able to reproduce this issue when compiling. Are you sure that both d3d8.so and libdxvk_d3d9.so are on your LD_LIBRARY_PATH or in your sytem lib dir (e.g. /usr/lib on Arch)

Try setting LD_LIBRARY_PATH to a folder containing the right libs. If it works fine with that then it's an issue with installing the libs correctly.

Note: By default, Meson installs to /usr/local which won't work on many distros (like Arch). So you could try running the following

meson configure --prefix /usr native
meson install -C native

To install the libs to /usr/lib/ on your system.

@Beyley
Copy link
Author

Beyley commented Nov 7, 2022

aha yeah it was path problem, now i get further, but still failing, specifically when trying to create a device, i get
image

full log:

info:  Game: Furball.Lanugo.TestApplication
info:  DXVK: v1.7.1-1883-g0cd0e577
info:  Built-in extension providers:
info:    SDL2 WSI
info:  Enabled instance extensions:
info:    VK_KHR_get_surface_capabilities2
info:    VK_KHR_surface
info:    VK_KHR_xlib_surface
info:  D3D9: VK_FORMAT_D24_UNORM_S8_UINT -> VK_FORMAT_D32_SFLOAT_S8_UINT
info:  AMD Radeon RX 6900 XT (RADV NAVI21):
info:    Driver: 22.2.1
info:    Vulkan: 1.3.224
info:    Memory Heap[0]: 
info:      Size: 32065 MiB
info:      Flags: 0x0
info:      Memory Type[2]: Property Flags = 0x6
info:      Memory Type[4]: Property Flags = 0xe
info:      Memory Type[6]: Property Flags = 0xc6
info:      Memory Type[8]: Property Flags = 0xce
info:    Memory Heap[1]: 
info:      Size: 16368 MiB
info:      Flags: 0x1
info:      Memory Type[0]: Property Flags = 0x1
info:      Memory Type[1]: Property Flags = 0x1
info:      Memory Type[3]: Property Flags = 0x7
info:      Memory Type[5]: Property Flags = 0xc1
info:      Memory Type[7]: Property Flags = 0xc7
[Direct3D8] Running on aticfx64.dll
[Direct3D8] Adapter Description: AMD Radeon RX 6900 XT (RADV NAVI21)
info:  Device properties:
info:    Device name:     : AMD Radeon RX 6900 XT (RADV NAVI21)
info:    Driver version   : 22.2.1
info:  Enabled device extensions:
info:    VK_AMD_memory_overallocation_behavior
info:    VK_AMD_shader_fragment_mask
info:    VK_EXT_attachment_feedback_loop_layout
info:    VK_EXT_conservative_rasterization
info:    VK_EXT_custom_border_color
info:    VK_EXT_depth_clip_enable
info:    VK_EXT_memory_priority
info:    VK_EXT_non_seamless_cube_map
info:    VK_EXT_robustness2
info:    VK_EXT_shader_module_identifier
info:    VK_EXT_shader_stencil_export
info:    VK_EXT_transform_feedback
info:    VK_EXT_vertex_attribute_divisor
info:    VK_KHR_pipeline_library
info:    VK_KHR_swapchain
info:  Device features:
info:    robustBufferAccess                     : 1
info:    fullDrawIndexUint32                    : 1
info:    imageCubeArray                         : 1
info:    independentBlend                       : 1
info:    geometryShader                         : 1
info:    tessellationShader                     : 0
info:    sampleRateShading                      : 1
info:    dualSrcBlend                           : 0
info:    logicOp                                : 0
info:    multiDrawIndirect                      : 0
info:    drawIndirectFirstInstance              : 0
info:    depthClamp                             : 1
info:    depthBiasClamp                         : 1
info:    fillModeNonSolid                       : 1
info:    depthBounds                            : 1
info:    multiViewport                          : 1
info:    samplerAnisotropy                      : 1
info:    textureCompressionBC                   : 1
info:    occlusionQueryPrecise                  : 1
info:    pipelineStatisticsQuery                : 1
info:    vertexPipelineStoresAndAtomics         : 1
info:    fragmentStoresAndAtomics               : 0
info:    shaderImageGatherExtended              : 0
info:    shaderClipDistance                     : 1
info:    shaderCullDistance                     : 1
info:    shaderFloat64                          : 0
info:    shaderInt64                            : 0
info:    variableMultisampleRate                : 1
info:    shaderResourceResidency                : 0
info:    shaderResourceMinLod                   : 0
info:    sparseBinding                          : 0
info:    sparseResidencyBuffer                  : 0
info:    sparseResidencyImage2D                 : 0
info:    sparseResidencyImage3D                 : 0
info:    sparseResidency2Samples                : 0
info:    sparseResidency4Samples                : 0
info:    sparseResidency8Samples                : 0
info:    sparseResidency16Samples               : 0
info:    sparseResidencyAliased                 : 0
info:  Vulkan 1.1
info:    shaderDrawParameters                   : 0
info:  Vulkan 1.2
info:    samplerMirrorClampToEdge               : 1
info:    drawIndirectCount                      : 1
info:    samplerFilterMinmax                    : 0
info:    hostQueryReset                         : 1
info:    timelineSemaphore                      : 1
info:    bufferDeviceAddress                    : 0
info:    shaderOutputViewportIndex              : 1
info:    shaderOutputLayer                      : 1
info:    vulkanMemoryModel                      : 1
info:  Vulkan 1.3
info:    robustImageAccess                      : 0
info:    pipelineCreationCacheControl           : 1
info:    shaderDemoteToHelperInvocation         : 1
info:    shaderZeroInitializeWorkgroupMemory    : 0
info:    synchronization2                       : 1
info:    dynamicRendering                       : 1
info:  VK_AMD_shader_fragment_mask
info:    extension supported                    : 1
info:  VK_EXT_attachment_feedback_loop_layout
info:    attachmentFeedbackLoopLayout           : 1
info:  VK_EXT_conservative_rasterization
info:    extension supported                    : 1
info:  VK_EXT_custom_border_color
info:    customBorderColors                     : 1
info:    customBorderColorWithoutFormat         : 1
info:  VK_EXT_depth_clip_enable
info:    depthClipEnable                        : 1
info:  VK_EXT_extended_dynamic_state3
info:    extendedDynamicState3DepthClipEnable   : 0
info:  VK_EXT_fragment_shader_interlock
info:    fragmentShaderSampleInterlock          : 0
info:    fragmentShaderPixelInterlock           : 0
info:  VK_EXT_full_screen_exclusive
info:    extension supported                    : 0
info:  VK_EXT_graphics_pipeline_library
info:    graphicsPipelineLibrary                : 0
info:  VK_EXT_memory_budget
info:    extension supported                    : 1
info:  VK_EXT_memory_priority
info:    memoryPriority                         : 1
info:  VK_EXT_non_seamless_cube_map
info:    nonSeamlessCubeMap                     : 1
info:  VK_EXT_robustness2
info:    robustBufferAccess2                    : 1
info:    robustImageAccess2                     : 1
info:    nullDescriptor                         : 1
info:  VK_EXT_shader_module_identifier
info:    shaderModuleIdentifier                 : 1
info:  VK_EXT_shader_stencil_export
info:    extension supported                    : 1
info:  VK_EXT_transform_feedback
info:    transformFeedback                      : 0
info:    geometryStreams                        : 0
info:  VK_EXT_vertex_attribute_divisor
info:    vertexAttributeInstanceRateDivisor     : 1
info:    vertexAttributeInstanceRateZeroDivisor : 1
info:  VK_KHR_external_memory_win32
info:    extension supported                    : 0
info:  VK_KHR_external_semaphore_win32
info:    extension supported                    : 0
info:  VK_NVX_binary_import
info:    extension supported                    : 0
info:  VK_NVX_image_view_handle
info:    extension supported                    : 0
info:  Queue families:
info:    Graphics : 0
info:    Transfer : 1
info:    Sparse   : 0
info:  DXVK: Read 0 valid state cache entries
info:  DXVK: Graphics pipeline libraries not supported
info:  D3D9DeviceEx::ResetSwapChain:
info:    Requested Presentation Parameters
info:      - Width:              1280
info:      - Height:             720
info:      - Format:             D3D9Format::A8R8G8B8
info:      - Auto Depth Stencil: false
info:                  ^ Format: D3D9Format::Unknown
info:      - Windowed:           true
err:   Failed to create surface

@AlpyneDreams
Copy link
Owner

AlpyneDreams commented Nov 10, 2022

Interesting. I'll take a look at this when I can.

@AlpyneDreams
Copy link
Owner

@Beyley is this still an issue?

@orowith2os
Copy link

Hi, I don't have much of a stake here, but I'd like to toss my thoughts into the ring.

Not a lot of software will, realistically, use a d8vk-native, but some will, somewhere. For reference, Valve uses dxvk-native for their Source games. It's possible that someone else will come along with the same desires.

I came here from the upstream DXVK PR, and this was a checkbox, so I think this'll be a must-have anyways.

I'll make a note that I should look at FOSS DX8 users somewhere, and see if I can get them going with D8VK if desired.

@flibitijibibo
Copy link

After some work upstream, dxvk-native is now more suited for including in distributions and runtimes like the Steam Linux Runtime - this does give some added incentive to make sure d3d8 works, since it simply means that it will be included on the system like the other supported D3D versions.

The only real change that d8vk would care about is this one where we tweaked the DLL-specific meson.build files to properly handle prefix/suffix stuff for the soname; aside from that it shouldn't need any special treatment (if anything it should be easier now, since system/runtime packages can guarantee that everything will be included in the right library path).

@flibitijibibo
Copy link

Slapped together the changes needed for d3d8's meson.build:

diff --git a/src/d3d8/meson.build b/src/d3d8/meson.build
index 9153e338..7b1247a0 100644
--- a/src/d3d8/meson.build
+++ b/src/d3d8/meson.build
@@ -19,8 +19,7 @@ if platform != 'windows'
   d3d8_link_depends += files('d3d8.sym')
 endif
 
-d3d8_dll = shared_library('d3d8'+dll_ext, d3d8_src, d3d8_res,
-  name_prefix         : dxvk_name_prefix,
+d3d8_dll = shared_library(dxvk_name_prefix+'d3d8', d3d8_src, d3d8_res,
   dependencies        : [ lib_d3d9, util_dep, dxso_dep, dxvk_dep ],
   include_directories : dxvk_include_path,
   install             : true,
@@ -28,5 +27,12 @@ d3d8_dll = shared_library('d3d8'+dll_ext, d3d8_src, d3d8_res,
   vs_module_defs      : 'd3d8'+def_spec_ext,
   link_args           : d3d8_ld_args,
   link_depends        : [ d3d8_link_depends ],
+  kwargs              : dxvk_so_version,
 )
 
+if platform != 'windows'
+  pkg.generate(d3d8_dll,
+    filebase: dxvk_pkg_prefix + 'd3d8',
+    subdirs:  'dxvk',
+  )
+endif

This can't be applied until the PR branch is rebased, but it should work after that...?

@WinterSnowfall
Copy link

WinterSnowfall commented May 24, 2024

This can't be applied until the PR branch is rebased, but it should work after that...?

Thanks for putting in the time. We'd most likely need to do this before merging upstream anyway. Feel free to open a PR and wait for a rebase (I already have 9 patiently doing so 😅 ).

@flibitijibibo
Copy link

Done: #211

@flibitijibibo
Copy link

flibitijibibo commented May 24, 2024

For laughs I ended up doing the rebase myself, was mostly just addressing conflicts in the workaround files:

https://github.com/flibitijibibo/dxvk/tree/d8vk

EDIT: CI is green, enjoy the artifacts: https://github.com/flibitijibibo/dxvk/actions/runs/9227588888

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants