Skip to content

Commit 8e4d030

Browse files
committed
fix high refresh capture
(cherry picked from commit 9b7a12a)
1 parent f8328f1 commit 8e4d030

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

ShaderGlass/CaptureSession.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ void CaptureSession::ProcessInput()
112112
{
113113
if(m_inputImage.get())
114114
{
115-
m_shaderGlass.Process(m_inputImage, 0);
115+
m_shaderGlass.Process(m_inputImage, 0, 1);
116116
}
117117
else
118118
{
119-
m_shaderGlass.Process(m_inputFrame, m_frameTicks);
119+
m_shaderGlass.Process(m_inputFrame, m_frameTicks, m_numInputFrames);
120120
}
121121
}
122122

ShaderGlass/ShaderGlass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,14 @@ void ShaderGlass::PresentFrame()
393393
PostMessage(m_outputWindow, WM_PAINT, 0, 0); // necessary for click-through
394394
}
395395

396-
void ShaderGlass::Process(winrt::com_ptr<ID3D11Texture2D> texture, ULONGLONG frameTicks)
396+
void ShaderGlass::Process(winrt::com_ptr<ID3D11Texture2D> texture, ULONGLONG frameTicks, int inputFrameNo)
397397
{
398398
auto nowTicks = GetTickCount64();
399399
auto timeSinceLastRender = nowTicks - m_prevRenderTicks;
400400
auto logicalFrameNo = (int)roundf((nowTicks - m_startTicks) / 16.6666666f); // fix shaders at 60 fps
401401

402402
// same input
403-
if(frameTicks == m_prevFrameTicks)
403+
if(inputFrameNo == m_prevInputFrameNo)
404404
{
405405
if(logicalFrameNo == m_prevLogicalFrameNo)
406406
return;
@@ -421,6 +421,7 @@ void ShaderGlass::Process(winrt::com_ptr<ID3D11Texture2D> texture, ULONGLONG fra
421421

422422
m_frameCounter++;
423423
m_prevFrameTicks = frameTicks;
424+
m_prevInputFrameNo = inputFrameNo;
424425
m_prevLogicalFrameNo = logicalFrameNo;
425426

426427
if(!m_running || !texture)

ShaderGlass/ShaderGlass.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ShaderGlass
2727
bool allowTearing,
2828
winrt::com_ptr<ID3D11Device> device,
2929
winrt::com_ptr<ID3D11DeviceContext> context);
30-
void Process(winrt::com_ptr<ID3D11Texture2D> texture, ULONGLONG frameTicks);
30+
void Process(winrt::com_ptr<ID3D11Texture2D> texture, ULONGLONG frameTicks, int inputFrameNo);
3131
void SetInputScale(float w, float h);
3232
void SetOutputScale(float w, float h);
3333
void SetOutputFlip(bool h, bool v);
@@ -93,6 +93,7 @@ class ShaderGlass
9393
ULONGLONG m_prevRenderTicks {0};
9494
ULONGLONG m_prevTicks {0};
9595
ULONGLONG m_prevFrameTicks {0};
96+
int m_prevInputFrameNo {0};
9697
int m_prevLogicalFrameNo {0};
9798
float m_fps {0};
9899
bool m_requiresFeedback {false};

0 commit comments

Comments
 (0)