mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 14:40:56 +00:00
Use D3D11_COPY_DISCARD when updating our video texture
This ensures the driver knows it doesn't have to synchronize with the previous texture data.
This commit is contained in:
@@ -129,6 +129,7 @@ bool D3D11VARenderer::createDeviceByAdapterIndex(int adapterIndex, bool* adapter
|
|||||||
DXGI_ADAPTER_DESC1 adapterDesc;
|
DXGI_ADAPTER_DESC1 adapterDesc;
|
||||||
D3D_FEATURE_LEVEL featureLevel;
|
D3D_FEATURE_LEVEL featureLevel;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
ComPtr<ID3D11DeviceContext> deviceContext;
|
||||||
|
|
||||||
SDL_assert(!m_Device);
|
SDL_assert(!m_Device);
|
||||||
SDL_assert(!m_DeviceContext);
|
SDL_assert(!m_DeviceContext);
|
||||||
@@ -178,7 +179,7 @@ bool D3D11VARenderer::createDeviceByAdapterIndex(int adapterIndex, bool* adapter
|
|||||||
D3D11_SDK_VERSION,
|
D3D11_SDK_VERSION,
|
||||||
&m_Device,
|
&m_Device,
|
||||||
&featureLevel,
|
&featureLevel,
|
||||||
&m_DeviceContext);
|
&deviceContext);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"D3D11CreateDevice() failed: %x",
|
"D3D11CreateDevice() failed: %x",
|
||||||
@@ -198,6 +199,16 @@ bool D3D11VARenderer::createDeviceByAdapterIndex(int adapterIndex, bool* adapter
|
|||||||
m_DevicesWithFL11Support++;
|
m_DevicesWithFL11Support++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hr = deviceContext.As(&m_DeviceContext);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"ID3D11DeviceContext::QueryInterface(ID3D11DeviceContext1) failed: %x",
|
||||||
|
hr);
|
||||||
|
m_DeviceContext.Reset();
|
||||||
|
m_Device.Reset();
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
m_BindDecoderOutputTextures = !!qEnvironmentVariableIntValue("D3D11VA_FORCE_BIND", &ok);
|
m_BindDecoderOutputTextures = !!qEnvironmentVariableIntValue("D3D11VA_FORCE_BIND", &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@@ -805,7 +816,9 @@ void D3D11VARenderer::renderVideo(AVFrame* frame)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Copy this frame into our video texture
|
// Copy this frame into our video texture
|
||||||
m_DeviceContext->CopySubresourceRegion(m_VideoTexture.Get(), 0, 0, 0, 0, (ID3D11Resource*)frame->data[0], (int)(intptr_t)frame->data[1], nullptr);
|
m_DeviceContext->CopySubresourceRegion1(m_VideoTexture.Get(), 0, 0, 0, 0,
|
||||||
|
(ID3D11Resource*)frame->data[0], (int)(intptr_t)frame->data[1],
|
||||||
|
nullptr, D3D11_COPY_DISCARD);
|
||||||
|
|
||||||
// SRV 0 is always mapped to the video texture
|
// SRV 0 is always mapped to the video texture
|
||||||
srvIndex = 0;
|
srvIndex = 0;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ private:
|
|||||||
Microsoft::WRL::ComPtr<IDXGIFactory5> m_Factory;
|
Microsoft::WRL::ComPtr<IDXGIFactory5> m_Factory;
|
||||||
Microsoft::WRL::ComPtr<ID3D11Device> m_Device;
|
Microsoft::WRL::ComPtr<ID3D11Device> m_Device;
|
||||||
Microsoft::WRL::ComPtr<IDXGISwapChain4> m_SwapChain;
|
Microsoft::WRL::ComPtr<IDXGISwapChain4> m_SwapChain;
|
||||||
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_DeviceContext;
|
Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_DeviceContext;
|
||||||
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_RenderTargetView;
|
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_RenderTargetView;
|
||||||
SupportedFenceType m_FenceType;
|
SupportedFenceType m_FenceType;
|
||||||
SDL_mutex* m_ContextLock;
|
SDL_mutex* m_ContextLock;
|
||||||
|
|||||||
Reference in New Issue
Block a user