Skip to content

Start introducing SDL3 and DXVK#100

Merged
rm5248 merged 20 commits intow3dhub:mainfrom
madebr:introduce-sdl3-and-dxvk
Mar 5, 2026
Merged

Start introducing SDL3 and DXVK#100
rm5248 merged 20 commits intow3dhub:mainfrom
madebr:introduce-sdl3-and-dxvk

Conversation

@madebr
Copy link
Copy Markdown

@madebr madebr commented Feb 21, 2026

This PR starts introducing SDL3 and DXVK by replacing win32-only function calls with abstractions on top of either win32 or SDL3.

Testing on Windows is limited.

Copy link
Copy Markdown
Collaborator

@rm5248 rm5248 left a comment

Choose a reason for hiding this comment

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

This looks pretty good to me, I have no real concerns.

Comment thread Code/wwlib/thread.h
#if defined(OPENW3D_WIN32)
#include <windows.h>
#elif defined(OPENW3D_SDL3)
#include <SDL3/SDL_thread.h>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

any preference on using std::thread vs the SDL thread? It probably doesn't matter that much which one we use.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

std::thread does not support thread priorities and, std::thread::id has an awkward way to convert to an integer (std::hash<std::thread::id>{}(std::this_thread::get_id())).

I'd prefer to use win32/SDL3, and perhaps switch later to c++ threads when we actually have the thing working on Linux: change 1 thing per commit.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do priorities even work correctly on Linux? A process needs to have root permissions to elevate its own priority, it can only reduce them IIRC and does Renegade really make use of them? Also, why SDL3 threads rather than native pthreads which are supported pretty much everywhere none windows (except getting integer thread IDs which seems oddly platform specific)? I only ask as I've attempted to write a pthread versions previously when reversing Zero Hour https://github.com/TheAssemblyArmada/Thyme/blob/develop/src/w3d/lib/thread.cpp

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

posix pthreads provides a pthread_setschedprio.
It's probably used as a suggestion for the scheduler.

disclaimer: I am a SDL contributor so I am probably a bit biased.

I chose SDL3 to limit the number of dependencies as we'll already need it for creating windows and input handling. SDL uses the optimal threading libraries for each platform. Looking at SDL3's `src/thread directory, it contains implementations for n3ds, ps2, psp, pthreads, vita and windows.

I also remember this SDL timer pr wanting to replace ps2-specific code with generic code. The penalty would've been 25x.

I don't think we should reinvent the wheel here.

Comment thread Code/wwutil/soutil.h
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I came across this project a while ago, perhaps it would be useful for loading DLLs? What you have here is good, I'm just thinking of the future.

@caseychaos1212 caseychaos1212 self-requested a review February 23, 2026 21:41
Comment thread Code/Commando/mainloop.cpp Outdated
Comment thread Code/wwutil/soutil.cpp Outdated
Comment thread Code/wwlib/thread.cpp Outdated
Comment thread Code/wwutil/ProcessManager.cpp Outdated
Comment thread Code/wwutil/ProcessManager.cpp Outdated
Comment thread Code/Commando/WINMAIN.CPP
Comment thread Code/ww3d2/dx8wrapper.cpp Outdated
Comment thread Code/Commando/init.cpp Outdated
Comment thread Code/wwutil/pathutil.cpp
Comment on lines +5 to +17
StringClass cPathUtil::GetWorkingDirectory(bool trailing_separator)
{
std::error_code ec;
auto path = std::filesystem::current_path(ec);
if (!ec) {
path = ".";
}
if (trailing_separator) {
path += std::filesystem::path::preferred_separator;
}
return StringClass{path.generic_string().c_str()};
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CODEX:

Medium: Working-directory helper always collapses to ["."] on success.
[pathutil.cpp (line 9)] uses [if (!ec) path = ".";] (likely meant if (ec)), so successful current_path is discarded.

Copy link
Copy Markdown
Collaborator

@caseychaos1212 caseychaos1212 left a comment

Choose a reason for hiding this comment

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

I had CODEX take a look.

Let me know if any of this is hallucinations or just missing context. It's a good learning experience for me.

Comment thread Code/wwlib/thread.h
#if defined(OPENW3D_WIN32)
#include <windows.h>
#elif defined(OPENW3D_SDL3)
#include <SDL3/SDL_thread.h>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do priorities even work correctly on Linux? A process needs to have root permissions to elevate its own priority, it can only reduce them IIRC and does Renegade really make use of them? Also, why SDL3 threads rather than native pthreads which are supported pretty much everywhere none windows (except getting integer thread IDs which seems oddly platform specific)? I only ask as I've attempted to write a pthread versions previously when reversing Zero Hour https://github.com/TheAssemblyArmada/Thyme/blob/develop/src/w3d/lib/thread.cpp

Comment thread Code/wwlib/thread.h Outdated
Comment thread Code/Commando/WebBrowser.h Outdated
@madebr madebr force-pushed the introduce-sdl3-and-dxvk branch 5 times, most recently from b2b617a to 2abc833 Compare February 28, 2026 03:40
Copy link
Copy Markdown
Collaborator

@OmniBlade OmniBlade left a comment

Choose a reason for hiding this comment

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

I think sdl3 should be added to the vcpkg config as well as part of this PR, but other than that I don't have any other concerns.

@madebr madebr force-pushed the introduce-sdl3-and-dxvk branch from 2abc833 to a3052b5 Compare March 2, 2026 15:59
@madebr
Copy link
Copy Markdown
Author

madebr commented Mar 2, 2026

I think sdl3 should be added to the vcpkg config as well as part of this PR, but other than that I don't have any other concerns.

I added sdl3 to vcpk.json.
Since DXVK requires a shared SDL3 library, I also forced usage of a shared SDL3 library.

Copy link
Copy Markdown
Collaborator

@caseychaos1212 caseychaos1212 left a comment

Choose a reason for hiding this comment

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

I'm good with this.

@rm5248 rm5248 merged commit 31556fc into w3dhub:main Mar 5, 2026
6 checks passed
@madebr madebr deleted the introduce-sdl3-and-dxvk branch March 5, 2026 22:06
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.

4 participants