Skip to content

Commit 9659012

Browse files
authored
Update d3d11_screen_capture.cpp
1 parent 819d175 commit 9659012

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/qsv_codec/d3d11_screen_capture.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "d3d11_screen_capture.h"
66
#include <fstream>
77

8+
#define MSDK_ALIGN16(value) (((value + 15) >> 4) << 4)
9+
810
using namespace DX;
911

1012
D3D11ScreenCapture::D3D11ScreenCapture()
@@ -106,12 +108,14 @@ bool D3D11ScreenCapture::InitD3D11()
106108

107109
hr = dxgi_output1->DuplicateOutput(d3d11_device_.Get(), dxgi_output_duplication_.GetAddressOf());
108110
if (FAILED(hr)) {
109-
/* 0x887a0004: NVIDIA控制面板-->全局设置--首选图形处理器(自动选择) */
111+
/* 0x887a0004: NVIDIA控制面板-->全局设置--首选图形处理器(自动选择) */
110112
printf("[D3D11ScreenCapture] Failed to get duplicate output.\n");
111113
return false;
112114
}
113115

114116
dxgi_output_duplication_->GetDesc(&dxgi_desc_);
117+
dxgi_desc_.ModeDesc.Width = MSDK_ALIGN16(dxgi_desc_.ModeDesc.Width);
118+
dxgi_desc_.ModeDesc.Height = MSDK_ALIGN16(dxgi_desc_.ModeDesc.Height);
115119

116120
if (!CreateTexture()) {
117121
return false;
@@ -242,7 +246,15 @@ int D3D11ScreenCapture::AcquireFrame()
242246
return -1;
243247
}
244248

245-
d3d11_context_->CopyResource(gdi_texture_.Get(), output_texture.Get());
249+
d3d11_context_->CopySubresourceRegion(
250+
gdi_texture_.Get(),
251+
0,
252+
0,
253+
0,
254+
0,
255+
output_texture.Get(),
256+
0,
257+
NULL);
246258

247259
Microsoft::WRL::ComPtr<IDXGISurface1> surface1;
248260
hr = gdi_texture_->QueryInterface(__uuidof(IDXGISurface1), reinterpret_cast<void**>(surface1.GetAddressOf()));
@@ -332,4 +344,4 @@ bool D3D11ScreenCapture::Capture(Image& image)
332344
}
333345

334346
return true;
335-
}
347+
}

0 commit comments

Comments
 (0)