Skip to content

Commit

Permalink
Unlocked framerate, various tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterTh committed Sep 29, 2012
1 parent 2d67d51 commit b844b9d
Show file tree
Hide file tree
Showing 16 changed files with 478 additions and 148 deletions.
11 changes: 9 additions & 2 deletions DATA/DSfix.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ smaaQuality 0
# 3 = high
ssaoStrength 0

# Set the maximum FPS (default 30)
# Enable variable framerate (up to 60)
# NOTE:
# - this requires in-memory modification of game code, and may get you banned from GFWL
# - there may be unintended side-effects in terms of gameplay
# - you need a very powerful system (especially CPU) in order to maintain 60 FPS
# - in some instances, collision detection may fail. Avoid sliding down ladders
# Use this at your own risk!
maxFPS 30
# 0 = no changes to game code
# 1 = unlock the frame rate
unlockFPS 0

# FPS limit, only used with unlocked framerate
# do not set this much higher than 60, this will lead to various issues with the engine
FPSlimit 60

############# Depth of field

Expand Down
31 changes: 17 additions & 14 deletions DATA/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,33 @@ DSfix is a tool developed by me that does just that.

What is it?
===========
It's an interception DINPUT8.dll that you place in the same folder as the game executable. It intercepts the game's calls to the DirectX 9 API and changes them as necessary to enable a higher internal rendering resolution.
It's an interception DINPUT8.dll that you place in the same folder as the game executable. It intercepts the game's calls to the DirectX 9 API and changes them as necessary to enable a higher internal rendering resolution and various other features.

How do I use it?
================
1) Delete previous version of the mod if you have any
2) Place the contents of the .zip into the game's binary directory. (The place where DARKSOULS.exe is)
(this may be something like C:\Program Files (x86)\Steam\steamapps\common\Dark Souls Prepare to Die Edition\DATA)
(this may be something like C:\Program Files (x86)\Steam\steamapps\common\Dark Souls Prepare to Die Edition\DATA)
3) Adjust the settings in DSfix.ini as desired
4) Adjust the keybindings in DSfixKeys.ini as desired
IMPORTANT: turn OFF the in-game AA option, otherwise you *will* get graphical issues
See DSfixKeys.ini for a list of keybindable actions, including screenshots.

Will it work?
=============
As of version 0.4, it seems to work well for many people, however your mileage may vary.
As of version 1.4, it seems to work well for many people, however your mileage may vary.
*I can not and will not guarantee that it will work for anyone else, or not have any adverse effect on your game/computer. Use at your own risk!*

Are there known issues?
=======================
- At vertical resolutions higher than 720 the sun may not be rendered correctly under some circumstances. This is under investigation, any insight is appreciated.
- When using custom HUD settings damage numbers and subtitles are not handled correctly
- When using custom HUD settings some things are still not handled correctly (e.g. curse symbol), and the HUD may revert to default spontaneously
- When using the unlocked framerate feature, collision detection may not work correctly, particularly when sliding down ladders

Will it cause performance problems?
===================================
That depends on your system configuration. Usually, performance scales rather linearly with framebuffer size, and so far this game does not seem different. My 660 maintained a locked 30 FPS throughout ~ 1/2 hour of testing in the starting area of the game at 2560x1440.
AMD cards seem to have more problems than NVidia at this point. Performance problems with the game may not be related to my mod but also CPU power.
That depends on your system configuration. Usually, performance scales rather linearly with framebuffer size, and so far this game does not seem different.
My 660 maintains a locked 30 FPS throughout the majority the game at 2560x1440 with SMAA and SSAO.

Can I donate?
=============
Expand All @@ -43,19 +44,21 @@ Here is my blog post about the fix with a donation link:
http://blog.metaclassofnil.com/?p=92
You can also simply Paypal to [email protected]

Will you release the source code?
=================================
I plan to, once the worst bugs are fixed and it is cleaned up *a lot*.
How can I contribute?
=====================
The source code is now available on github under the terms of the GPL:
https://github.com/PeterTh/dsfix
Read the developer documentation there to find out how you can contribute, or contact me directly.

It crashes, help!
=================
First, make sure that the DSfix.ini file is present in the correct location.
First, make sure that the .ini files are present in the correct location.
Additionally, the "dsfix" folder should be in that same location.
Second, turn off tools such as MSI Afterburner or other overlays that manipulate D3D.
Turn off tools such as MSI Afterburner or other overlays that manipulate D3D.
Then try restoring the default settings in the .ini file
If neither of these help then check if the problem still occurs when you remove/rename DINPUT8.dll
If none of these help then check if the problem still occurs when you remove/rename DINPUT8.dll
Finally, try rebooting
If it still persists, then report the problem, otherwise it has nothing to do with DSfix.
If the issue still persists, then report the problem, otherwise it has nothing to do with DSfix.

How can I uninstall the mod?
============================
Expand All @@ -74,7 +77,7 @@ Thanks to
- The authors of SMAA
- The authors of the OBGE VSSAO effect
- The artists of:
Crow's Claw, Demetori, Silver Forest, Foreground Eclipse, Thousand Leaves, Undead Corporation, Unlucky Morpheus, Dark Phoenix, Aquaelie, TAMUSIC, Riverside, Kissing the Mirror, xi-on, SAVE THE QUEEN, East New Sound and Shinigawa Satellite
Crow's Claw, Demetori, Silver Forest, Foreground Eclipse, Thousand Leaves, Undead Corporation, Unlucky Morpheus, Dark Phoenix, Aquaelie, TAMUSIC, Riverside, Kissing the Mirror, xi-on, SAVE THE QUEEN, East New Sound and Shinigiwa Satellite
for providing the development soundtrack


Expand Down
9 changes: 9 additions & 0 deletions DATA/VERSIONS.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
29-09-1012 -- version 1.6 beta
==============================
- Unlocked framerate. Thanks to the hard work of Cl�ment Barnier, the framerate can now be unlocked entirely.
(look into the .ini for details)
- Fixed the SMAA issue introduced in 1.5 (with edges touching the skybox)
- Fixed the HUD issues with damage numbers and subtitles (other issues remain)
- Various small performance tweaks


22-09-2012 -- version 1.5 beta
==============================
Bugfixes:
Expand Down
Binary file modified DSfix.v11.suo
Binary file not shown.
27 changes: 12 additions & 15 deletions Detouring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

bool timingIntroMode = false;

static DWORD (WINAPI * TrueSleepEx)(DWORD dwMilliseconds, BOOL bAlertable) = SleepEx;
DWORD WINAPI DetouredSleepEx(DWORD dwMilliseconds, BOOL bAlertable) {
SDLOG(12, "T %6lu: Detouring: Sleep for %lu ms\n", GetCurrentThreadId(), dwMilliseconds);
return TrueSleepEx(dwMilliseconds, bAlertable);
//return 0;
//SDLOG(12, "T %6lu: Detouring: Sleep for %lu ms\n", GetCurrentThreadId(), dwMilliseconds);
//return TrueSleepEx(dwMilliseconds, bAlertable);
return 0;
}

#include <mmsystem.h>
Expand Down Expand Up @@ -76,25 +75,23 @@ HRESULT WINAPI DetouredD3DXCompileShader(_In_ LPCSTR pSrcData, _In_ UINT srcData
}

void earlyDetour() {
QueryPerformanceFrequency(&countsPerSec);
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)oDirect3DCreate9, hkDirect3DCreate9);
DetourTransactionCommit();
}

void startDetour() {
DetourRestoreAfterWith();
QueryPerformanceFrequency(&countsPerSec);

void startDetour() {
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)TrueSleepEx, DetouredSleepEx);
DetourAttach(&(PVOID&)TrueTimeGetTime, DetouredTimeGetTime);
//DetourAttach(&(PVOID&)TrueSleepEx, DetouredSleepEx);
//DetourAttach(&(PVOID&)TrueTimeGetTime, DetouredTimeGetTime);
if(Settings::get().getSkipIntro()) DetourAttach(&(PVOID&)TrueQueryPerformanceCounter, DetouredQueryPerformanceCounter);
TrueD3DXCreateTexture = (D3DXCreateTexture_FNType)DetourFindFunction("d3dx9_43.dll", "D3DXCreateTexture");
//TrueD3DXCreateTexture = (D3DXCreateTexture_FNType)DetourFindFunction("d3dx9_43.dll", "D3DXCreateTexture");
TrueD3DXCreateTextureFromFileInMemory = (D3DXCreateTextureFromFileInMemory_FNType)DetourFindFunction("d3dx9_43.dll", "D3DXCreateTextureFromFileInMemory");
TrueD3DXCreateTextureFromFileInMemoryEx = (D3DXCreateTextureFromFileInMemoryEx_FNType)DetourFindFunction("d3dx9_43.dll", "D3DXCreateTextureFromFileInMemoryEx");
DetourAttach(&(PVOID&)TrueD3DXCreateTexture, DetouredD3DXCreateTexture);
//DetourAttach(&(PVOID&)TrueD3DXCreateTexture, DetouredD3DXCreateTexture);
DetourAttach(&(PVOID&)TrueD3DXCreateTextureFromFileInMemory, DetouredD3DXCreateTextureFromFileInMemory);
DetourAttach(&(PVOID&)TrueD3DXCreateTextureFromFileInMemoryEx, DetouredD3DXCreateTextureFromFileInMemoryEx);
//TrueD3DXCompileShader = (D3DXCompileShader_FNType)DetourFindFunction("d3dx9_43.dll", "D3DXCompileShader");
Expand All @@ -112,10 +109,10 @@ void endDetour() {
//if(Settings::get().getSkipIntro()) {
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)TrueSleepEx, DetouredSleepEx);
DetourDetach(&(PVOID&)TrueTimeGetTime, DetouredTimeGetTime);
//DetourDetach(&(PVOID&)TrueSleepEx, DetouredSleepEx);
//DetourDetach(&(PVOID&)TrueTimeGetTime, DetouredTimeGetTime);
if(Settings::get().getSkipIntro()) DetourDetach(&(PVOID&)TrueQueryPerformanceCounter, DetouredQueryPerformanceCounter);
DetourDetach(&(PVOID&)TrueD3DXCreateTexture, DetouredD3DXCreateTexture);
//DetourDetach(&(PVOID&)TrueD3DXCreateTexture, DetouredD3DXCreateTexture);
DetourDetach(&(PVOID&)TrueD3DXCreateTextureFromFileInMemory, DetouredD3DXCreateTextureFromFileInMemory);
DetourDetach(&(PVOID&)TrueD3DXCreateTextureFromFileInMemoryEx, DetouredD3DXCreateTextureFromFileInMemoryEx);
DetourDetach(&(PVOID&)oDirect3DCreate9, hkDirect3DCreate9);
Expand Down
2 changes: 2 additions & 0 deletions Detouring.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <detours.h>

static DWORD (WINAPI * TrueSleepEx)(DWORD dwMilliseconds, BOOL bAlertable) = SleepEx;

typedef HRESULT (WINAPI * D3DXCreateTextureFromFileInMemory_FNType)(_In_ LPDIRECT3DDEVICE9 pDevice, _In_ LPCVOID pSrcData, _In_ UINT SrcDataSize, _Out_ LPDIRECT3DTEXTURE9 *ppTexture);
extern D3DXCreateTextureFromFileInMemory_FNType TrueD3DXCreateTextureFromFileInMemory;

Expand Down
Loading

0 comments on commit b844b9d

Please sign in to comment.