Refresh rate control on IDXGISwapChain1

Marek 0 Reputation points
2025-01-09T15:01:37.3+00:00

I play video on my application on xbox with 120Hz, but it seems to be played with 60Hz. Interval between time samples is ~16ms instead of 8ms. I checked few different videos with different fps and the result is the same (I thought that the problem is vsync but not bcs if I set 60Hz and 30fps time sample is ~16ms anyways -> so each frame is played twice like expected).

(interval between time samples == ~time of m_swap_chain1->Present1)


RECT rect = {static_cast<LONG>(x), static_cast<LONG>(m_height - y - height),
             static_cast<LONG>(x + width), static_cast<LONG>(m_height - y)};
DXGI_PRESENT_PARAMETERS params = {1, &rect, nullptr, nullptr};
result = m_swap_chain->Present1(swap_interval, 0, &params);

So the question is how can I force to use swap chain with 120Hz? In DXGI_SWAP_CHAIN_DESC we have DXGI_MODE_DESC where it is possible to set refresh rate.. but for DXGI_SWAP_CHAIN_DESC1 I don't have option like that.

I also found IDXGISwapChainMedia but it is dxgi1_3.h.. I am using dxgi1_2.h.

and the second question:
how can I check which refresh rate is currently played. Does any method like that exist?

I tried in this way:


IDXGIOutput* dxgiOutput;
auto hr = dxgiAdapter->EnumOutputs(output, &dxgiOutput);
if (FAILED(hr))
{
    std::cout << "Failed to enumerate output. HRESULT: " << hr << " " << output;
    return;
}

IDXGIOutput1* dxgiOutput1 = my_dynamic_cast<IDXGIOutput1>(dxgiOutput);
// Step 4: Fallback to enumerate available modes
UINT modeCount = 0;
UINT flags     = DXGI_ENUM_MODES_INTERLACED;
hr             = dxgiOutput1->GetDisplayModeList1(format, flags, &modeCount, nullptr);
if (FAILED(hr))
{
    std::cout << "Failed to get display mode list1. HRESULT: " << hr << " " << output;
    return;
}

std::vector<DXGI_MODE_DESC1> modes(modeCount);
hr = dxgiOutput1->GetDisplayModeList1(format, flags, &modeCount, modes.data());
if (FAILED(hr))
{
    std::cout << "Failed to retrieve display modes1. HRESULT: " << hr;
    return;
}

std::cout << "Available display modes:";
for (const auto &mode : modes)
{
    std::cout << "Resolution: " << mode.Width << "x" << mode.Height
               << ", Refresh rate: "
               << mode.RefreshRate.Numerator / mode.RefreshRate.Denominator << " Hz";
}

but it failed here:

Failed to get display mode list1. HRESULT: -2005270494

and it probably receive all modes instead of currently used.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,704 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.