Add support for decoding NV12 into RGB image

This commit is contained in:
Wojtek Figat
2024-05-15 11:15:19 +02:00
parent 9d2dc91920
commit 82bf4238df
6 changed files with 75 additions and 15 deletions

View File

@@ -297,6 +297,7 @@ struct GPUDevice::PrivateData
GPUPipelineState* PS_CopyLinear = nullptr;
GPUPipelineState* PS_Clear = nullptr;
GPUPipelineState* PS_DecodeYUY2 = nullptr;
GPUPipelineState* PS_DecodeNV12 = nullptr;
GPUBuffer* FullscreenTriangleVB = nullptr;
AssetReference<Material> DefaultMaterial;
SoftAssetReference<Material> DefaultDeformableMaterial;
@@ -715,6 +716,18 @@ GPUPipelineState* GPUDevice::GetDecodeYUY2PS() const
return _res->PS_DecodeYUY2;
}
GPUPipelineState* GPUDevice::GetDecodeNV12PS() const
{
if (_res->PS_DecodeNV12 == nullptr)
{
auto psDesc = GPUPipelineState::Description::DefaultFullscreenTriangle;
psDesc.PS = QuadShader->GetPS("PS_DecodeNV12");
_res->PS_DecodeNV12 = const_cast<GPUDevice*>(this)->CreatePipelineState();
_res->PS_DecodeNV12->Init(psDesc);
}
return _res->PS_DecodeNV12;
}
GPUBuffer* GPUDevice::GetFullscreenTriangleVB() const
{
return _res->FullscreenTriangleVB;

View File

@@ -275,6 +275,11 @@ public:
/// </summary>
GPUPipelineState* GetDecodeYUY2PS() const;
/// <summary>
/// Gets the shader pipeline state object for NV12 frame decoding to RGBA.
/// </summary>
GPUPipelineState* GetDecodeNV12PS() const;
/// <summary>
/// Gets the fullscreen-triangle vertex buffer.
/// </summary>