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

Make d3dx9_xx.dll load dynamically #16

Merged
merged 3 commits into from
Apr 30, 2017
Merged

Conversation

elishacloud
Copy link
Contributor

d3dx8_43.dll was loaded statically before. Some systems have different versions of this dll. Changed it to load dynamically based on the version available on the system.

Note: This is also done by other programs. Check out the log from ts3overlay here.

d3dx8_43.dll was loaded statically before.  Some systems have different
versions of this dll.  Change it to load dynamically based on the
version available on the system.
@crosire
Copy link
Owner

crosire commented Apr 29, 2017

I don't think this is necessary. D3DX is deprecated and won't be updated anymore (https://blogs.msdn.microsoft.com/chuckw/2013/08/20/living-without-d3dx/), meaning d3dx9_43.dll is the last version of that DLL that will ever exist. It's also the version that is installed by the last available DirectSetup. From Windows 8 onward DirectX is part of the operating system and does not include D3DX, so the only way to get that DLL is to install via the DirectSetup from 2010 which contains this specific version of the DLL.
Unfortunately there don't seem to be any alternatives to assemble D3D8 shaders from assembler code, other than the deprecated D3DX, which is why it's in use here.

@elishacloud
Copy link
Contributor Author

Yes, you are probably right. However I use this project inside a larger project and I did not want this dll to be static because the dll is not always needed for me. I suspect others may do the same thing.

Also on my test system (Windows 7) I only have d3dx9_32.dll and other users who use my project my not have the latest dll also. I don't want them to be required to update their DirectX libraries to use my project.

If you want I can change the number to start counting down at a smaller number rather than 99, like we can start at 50. I did see some references to d3dx9_47.dll on the web, but they could be bogus.

@crosire
Copy link
Owner

crosire commented Apr 29, 2017

As soon as you install a DirectX game via Steam it will almost always install the DirectX libraries including d3dx9_43.dll too. The only systems I saw without that file were usually freshly set up.
I don't feel like merging this. It adds complexity that is rarely required. But that doesn't have to stop you from using this change in your own fork.

@elishacloud
Copy link
Contributor Author

Ok, understood. Thanks for looking at it. I will just have this on my branch.

@CookiePLMonster
Copy link
Contributor

While I don't like the way this is trying for different DLL versions, loading it dynamically could still be beneficial since not everyone has DX redists installed (you'd be surprised how many people do not have them!) and I don't think shaders were a common thing in d3d8 days - so most games would be unaffected.

@elishacloud
Copy link
Contributor Author

Ok, let me change that to dynamically load d3dx9_43.dll.

@elishacloud elishacloud reopened this Apr 29, 2017
Removed the code to search for different versions of "d3dx9_43.dll"
// Load dll
dllHandle = LoadLibrary(d3dx9name);
}
dllHandle = LoadLibrary("d3dx9_43.dll");
Copy link
Contributor

Choose a reason for hiding this comment

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

Unicode please? =) This is the first ever line which will be affected by multibyte/Unicode switch so while I'm not a fan of using MS macroes for multibyte/Unicode, ideally you could replace those two lines with

HMODULE dllHandle = LoadLibrary(TEXT("d3dx9_43.dll"));

and support both character encodings at once. Still, project should probably end up being switched to Unicode as it's the way Windows-only projects should be handled these days to be honest.

Using MS macro for multibyte/Unicode.  Also made minor updates to the
comments to fix the dll name.
@elishacloud
Copy link
Contributor Author

Ok, good call. Just updated this to support Unicode, as requested.

@crosire
Copy link
Owner

crosire commented Apr 30, 2017

Alright. You got me convinced. I'll clean this up a little in a follow-up commit though.

@crosire crosire merged commit 07909b7 into crosire:master Apr 30, 2017
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