Jump to content

GPU Rendering Optimazation + FPS


J95

Recommended Posts




Timer Resolution (NtSetTimerResolution)interferes with in-game sleep functions, in most cases speeding up CPU frame preparation process for the GPU. Crysis 3 +6-9 fps - FXAA - Highest settings - VSync disabled - Motion Blur off - GTX 680M. Sets timer resolution to 0.500 milliseconds. Thanks to mbk1969 Guru3D.com Forums.



TimerResolution_2.exe enhanced + batch file (taskkill) compiled C# source myself using .NET csc.exe. Console app, run .exe and check current max resolution (console window), minimize button.
Hidden start : create TimerResolution_2.exe shortcut>right click>properties>select run minimized>apply>pin shortcut to taskbar (select icon).


Current 5000 = 0.500 ms.
<img src="http://imageshack.us/a/img401/7189/timerresolution2execons.jpg" alt="Image Hosted by ImageShack.us"/>


Killing it w/ task manager or .bat restores defaults.

@echo off
taskkill /f /IM TimerResolution_2.exe




Pin batch file to toolbar : create .bat (I) shortcut>create folder>name it "batch_folder">copy .bat shortcut>properties>select run minimized>change icon>select icon>apply>right click taskbar>unlock taskbar>toolbars>new toolbar>select batch_folder>right click taskbar set no text/title>lock taskbar.






using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace SetTimerRes
{
class TimerRes
{

[DllImport("ntdll.dll", SetLastError=true)]
public static extern int NtSetTimerResolution(uint DesiredResolution, bool SetResolution, out uint CurrentResolution);

[DllImport("ntdll.dll", SetLastError=true)]
static extern int NtQueryTimerResolution(out uint MinimumResolution, out uint MaximumResolution, out uint ActualResolution);

static void Main(string[] args)
{
var tb = new Taskbar();
tb.DeleteTab();

uint CurrentResolution = 0;
uint MininumResolution = 0;
uint MaximumResolution = 0;

NtQueryTimerResolution(out MininumResolution, out MaximumResolution, out CurrentResolution);

bool SetResolution = true;
uint DesiredResolution = MaximumResolution;

NtSetTimerResolution(DesiredResolution, SetResolution, out CurrentResolution);

Console.WriteLine("Minimum={0}; Maximum={1}; Current={2}", MininumResolution, MaximumResolution, CurrentResolution);
Console.WriteLine("Press <Enter> to exit...");
Console.ReadLine();
}
}

class Taskbar
{
public void AddTab()
{
GetTaskbarList().AddTab(GetMainWindowHandle());
}

public void DeleteTab()
{
GetTaskbarList().DeleteTab(GetMainWindowHandle());
}

ITaskbarList GetTaskbarList()
{
var taskbarList = (ITaskbarList)new CoTaskbarList();
taskbarList.HrInit();
return taskbarList;
}

IntPtr GetMainWindowHandle()
{
return Process.GetCurrentProcess().MainWindowHandle;
}

[ComImport]
[Guid("56fdf344-fd6d-11d0-958a-006097c9a090")]
class CoTaskbarList
{
}

[ComImport,
Guid("56fdf342-fd6d-11d0-958a-006097c9a090"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface ITaskbarList
{
/// <summary>
/// Initializes the taskbar list object. This method must be called before any other ITaskbarList methods can be called.
/// </summary>
void HrInit();

/// <summary>
/// Adds an item to the taskbar.
/// </summary>
/// <param name="hWnd">A handle to the window to be added to the taskbar.</param>
void AddTab([In] IntPtr hWnd);

/// <summary>
/// Deletes an item from the taskbar.
/// </summary>
/// <param name="hWnd">A handle to the window to be deleted from the taskbar.</param>
void DeleteTab([In] IntPtr hWnd);

/// <summary>
/// Activates an item on the taskbar. The window is not actually activated; the window's item on the taskbar is merely displayed as active.
/// </summary>
/// <param name="hWnd">A handle to the window on the taskbar to be displayed as active.</param>
void ActivateTab([In] IntPtr hWnd);

/// <summary>
/// Marks a taskbar item as active but does not visually activate it.
/// </summary>
/// <param name="hWnd">A handle to the window to be marked as active.</param>
void SetActiveAlt([In] IntPtr hWnd);
}
}
}



updated - without cycle
updated - without thread sleep
updated - with info output
C# source Guru3D.com Forums - View Single Post - Another look at HPET High Precision Event Timer

TimerResolution_2.zip

TimerResolution_3.zip

Link to comment
Share on other sites

  • 4 weeks later...

Crysis 3 default 10 ms this sets to 0.500 ms run and minimize it; closing or pressing enter restores defaults.

Crysis 3 10.001 ms

3DMark11 1.001 ms

Dragon Chromium 1.001 ms

Monitor CPU usage in demanding scenes>check fps, alt/tab taskkill (batch file) and compare results.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
  • 3 weeks later...
  • 10 months later...
  • 3 months later...
  • 5 weeks later...

I'd say probably yes, but only in games were the timer hasn't been set lower already, I would assume Unreal Engine already does this to max performance so that would rule out and Unreal Engine games (Though this is only a thought, not a fact). Feel free to try though, It won't break anything and you could report this back to us. See it as a little experiment :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.