mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 14:11:33 +00:00
Only bind the constant buffer once
This commit is contained in:
@@ -17,7 +17,7 @@ struct ShaderInput
|
|||||||
min16float4 main(ShaderInput input) : SV_TARGET
|
min16float4 main(ShaderInput input) : SV_TARGET
|
||||||
{
|
{
|
||||||
float y = luminancePlane.Sample(theSampler, input.tex);
|
float y = luminancePlane.Sample(theSampler, input.tex);
|
||||||
float2 uv = chrominancePlane.Sample(theSampler, input.tex);
|
float2 uv = chrominancePlane.Sample(theSampler, input.tex);
|
||||||
float3 yuv = float3(y, uv);
|
float3 yuv = float3(y, uv);
|
||||||
|
|
||||||
// Subtract the YUV offset for limited vs full range
|
// Subtract the YUV offset for limited vs full range
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ D3D11VARenderer::D3D11VARenderer()
|
|||||||
m_FrameWaitableObject(nullptr),
|
m_FrameWaitableObject(nullptr),
|
||||||
m_VideoPixelShader(nullptr),
|
m_VideoPixelShader(nullptr),
|
||||||
m_VideoVertexBuffer(nullptr),
|
m_VideoVertexBuffer(nullptr),
|
||||||
m_VideoConstantBuffer(nullptr),
|
|
||||||
m_OverlayLock(0),
|
m_OverlayLock(0),
|
||||||
m_OverlayPixelShader(nullptr),
|
m_OverlayPixelShader(nullptr),
|
||||||
m_HwDeviceContext(nullptr),
|
m_HwDeviceContext(nullptr),
|
||||||
@@ -100,7 +99,6 @@ D3D11VARenderer::~D3D11VARenderer()
|
|||||||
{
|
{
|
||||||
SDL_DestroyMutex(m_ContextLock);
|
SDL_DestroyMutex(m_ContextLock);
|
||||||
|
|
||||||
SAFE_COM_RELEASE(m_VideoConstantBuffer);
|
|
||||||
SAFE_COM_RELEASE(m_VideoVertexBuffer);
|
SAFE_COM_RELEASE(m_VideoVertexBuffer);
|
||||||
SAFE_COM_RELEASE(m_VideoPixelShader);
|
SAFE_COM_RELEASE(m_VideoPixelShader);
|
||||||
|
|
||||||
@@ -739,9 +737,6 @@ void D3D11VARenderer::updateColorConversionConstants(AVFrame* frame)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free any existing buffer
|
|
||||||
SAFE_COM_RELEASE(m_VideoConstantBuffer);
|
|
||||||
|
|
||||||
D3D11_BUFFER_DESC constDesc = {};
|
D3D11_BUFFER_DESC constDesc = {};
|
||||||
constDesc.ByteWidth = sizeof(CSC_CONST_BUF);
|
constDesc.ByteWidth = sizeof(CSC_CONST_BUF);
|
||||||
constDesc.Usage = D3D11_USAGE_IMMUTABLE;
|
constDesc.Usage = D3D11_USAGE_IMMUTABLE;
|
||||||
@@ -789,9 +784,13 @@ void D3D11VARenderer::updateColorConversionConstants(AVFrame* frame)
|
|||||||
D3D11_SUBRESOURCE_DATA constData = {};
|
D3D11_SUBRESOURCE_DATA constData = {};
|
||||||
constData.pSysMem = &constBuf;
|
constData.pSysMem = &constBuf;
|
||||||
|
|
||||||
HRESULT hr = m_Device->CreateBuffer(&constDesc, &constData, &m_VideoConstantBuffer);
|
ID3D11Buffer* constantBuffer;
|
||||||
if (FAILED(hr)) {
|
HRESULT hr = m_Device->CreateBuffer(&constDesc, &constData, &constantBuffer);
|
||||||
m_VideoConstantBuffer = nullptr;
|
if (SUCCEEDED(hr)) {
|
||||||
|
m_DeviceContext->PSSetConstantBuffers(0, 1, &constantBuffer);
|
||||||
|
constantBuffer->Release();
|
||||||
|
}
|
||||||
|
else {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"ID3D11Device::CreateBuffer() failed: %x",
|
"ID3D11Device::CreateBuffer() failed: %x",
|
||||||
hr);
|
hr);
|
||||||
@@ -849,9 +848,8 @@ void D3D11VARenderer::renderVideo(AVFrame* frame)
|
|||||||
m_DeviceContext->PSSetShaderResources(1, 1, &chrominanceTextureView);
|
m_DeviceContext->PSSetShaderResources(1, 1, &chrominanceTextureView);
|
||||||
chrominanceTextureView->Release();
|
chrominanceTextureView->Release();
|
||||||
|
|
||||||
// Bind video pixel shader and CSC constants
|
// Bind video pixel shader
|
||||||
m_DeviceContext->PSSetShader(m_VideoPixelShader, nullptr, 0);
|
m_DeviceContext->PSSetShader(m_VideoPixelShader, nullptr, 0);
|
||||||
m_DeviceContext->PSSetConstantBuffers(0, 1, &m_VideoConstantBuffer);
|
|
||||||
|
|
||||||
// Draw the video
|
// Draw the video
|
||||||
m_DeviceContext->DrawIndexed(6, 0, 0);
|
m_DeviceContext->DrawIndexed(6, 0, 0);
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ private:
|
|||||||
|
|
||||||
ID3D11PixelShader* m_VideoPixelShader;
|
ID3D11PixelShader* m_VideoPixelShader;
|
||||||
ID3D11Buffer* m_VideoVertexBuffer;
|
ID3D11Buffer* m_VideoVertexBuffer;
|
||||||
ID3D11Buffer* m_VideoConstantBuffer;
|
|
||||||
|
|
||||||
SDL_SpinLock m_OverlayLock;
|
SDL_SpinLock m_OverlayLock;
|
||||||
ID3D11Buffer* m_OverlayVertexBuffers[Overlay::OverlayMax];
|
ID3D11Buffer* m_OverlayVertexBuffers[Overlay::OverlayMax];
|
||||||
|
|||||||
Reference in New Issue
Block a user