-
Notifications
You must be signed in to change notification settings - Fork 89
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
Default MaximumFrameLatency increased #812
Conversation
Defaults jitter fix to be on, instead of off, if nothing is set by a port.
Digging into this a bit https://github.com/search?q=repo%3AKenix3%2Flibultraship%20maximum_frame_latency&type=code "apply"libultraship/src/graphic/Fast3D/gfx_dxgi.cpp Lines 111 to 129 in b704048
the line being changed in this PRlibultraship/src/graphic/Fast3D/gfx_dxgi.cpp Line 465 in b704048
a bunch of logic in swap buffers endlibultraship/src/graphic/Fast3D/gfx_dxgi.cpp Lines 866 to 909 in b704048
what is called when ports set this using
|
static void gfx_dxgi_set_maximum_frame_latency(int latency) { | |
dxgi.maximum_frame_latency = latency; | |
} |
a call to apply when creating swapchain
libultraship/src/graphic/Fast3D/gfx_dxgi.cpp
Lines 966 to 996 in b704048
void gfx_dxgi_create_swap_chain(IUnknown* device, std::function<void()>&& before_destroy_fn) { | |
bool win8 = IsWindows8OrGreater(); // DXGI_SCALING_NONE is only supported on Win8 and beyond | |
bool dxgi_13 = dxgi.CreateDXGIFactory2 != nullptr; // DXGI 1.3 introduced waitable object | |
DXGI_SWAP_CHAIN_DESC1 swap_chain_desc = {}; | |
swap_chain_desc.BufferCount = 3; | |
swap_chain_desc.Width = 0; | |
swap_chain_desc.Height = 0; | |
swap_chain_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; | |
swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; | |
swap_chain_desc.Scaling = win8 ? DXGI_SCALING_NONE : DXGI_SCALING_STRETCH; | |
swap_chain_desc.SwapEffect = | |
dxgi.dxgi1_4 ? DXGI_SWAP_EFFECT_FLIP_DISCARD : // Introduced in DXGI 1.4 and Windows 10 | |
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // Apparently flip sequential was also backported to Win 7 Platform Update | |
swap_chain_desc.Flags = dxgi_13 ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0; | |
if (dxgi.tearing_support) { | |
swap_chain_desc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; // Now we can use DXGI_PRESENT_ALLOW_TEARING | |
} | |
swap_chain_desc.SampleDesc.Count = 1; | |
ThrowIfFailed( | |
dxgi.factory->CreateSwapChainForHwnd(device, dxgi.h_wnd, &swap_chain_desc, nullptr, nullptr, &dxgi.swap_chain)); | |
ThrowIfFailed(dxgi.factory->MakeWindowAssociation(dxgi.h_wnd, DXGI_MWA_NO_ALT_ENTER)); | |
apply_maximum_frame_latency(true); | |
ThrowIfFailed(dxgi.swap_chain->GetDesc1(&swap_chain_desc)); | |
dxgi.swap_chain_device = device; | |
dxgi.before_destroy_swap_chain_fn = std::move(before_destroy_fn); | |
} |
there seems to be a lot here - if nothing else
libultraship/src/graphic/Fast3D/gfx_dxgi.cpp
Line 875 in b704048
dxgi.maximum_frame_latency = 1; |
probably needs to be updated to 2
as well, but any explanation of why so much logic is needed for what seems like something we should just set and forget would be really helpful
after rereading this
it seems that spot can stay breaking down libultraship/src/graphic/Fast3D/gfx_dxgi.cpp Lines 871 to 887 in b704048
current latency value is stored in local var libultraship/src/graphic/Fast3D/gfx_dxgi.cpp Lines 871 to 874 in b704048
it's set to 1 to "run out" the existing latency frames or something? libultraship/src/graphic/Fast3D/gfx_dxgi.cpp Lines 875 to 882 in b704048
it is set back to the new applied latency value (which was stored in the local var) libultraship/src/graphic/Fast3D/gfx_dxgi.cpp Lines 883 to 886 in b704048
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i still feel the ability to change this at runtime is adding a ton of complexity we likely don't need, but from a "minimal change maximum impact" perspective this seems like a good one
Yes, setting it to 1 and than waiting in a loop is to get the latency down again. This is the "undocumented stuff" I talked about. It's never mentioned in the official docs, that you can't just set it at runtime and latency will stay up instead. |
Defaults jitter fix (MaximumFrameLatency) to be on (2), instead of off (1), if nothing is set by a port. Keeping it at 1 has a lower latency, but I think it's more sensible to get a smoother experience by default.