kodi
RendererShaders.h
1 /*
2  * Copyright (C) 2017-2019 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 #pragma once
9 
10 #include "RendererHQ.h"
11 #include "cores/VideoPlayer/Buffers/VideoBuffer.h"
12 
13 #include <map>
14 
15 #include <d3d11_4.h>
16 
17 extern "C"
18 {
19 #include <libavutil/pixfmt.h>
20 }
21 
22 #define PLANE_Y 0
23 #define PLANE_U 1
24 #define PLANE_V 2
25 #define PLANE_UV 1
26 
27 enum RenderMethod;
28 
30 {
31  class CRenderBufferImpl;
32 public:
33  ~CRendererShaders() = default;
34 
35  bool Supports(ESCALINGMETHOD method) const override;
36  bool Configure(const VideoPicture& picture, float fps, unsigned orientation) override;
37 
38  static CRendererBase* Create(CVideoSettings& videoSettings);
39  static void GetWeight(std::map<RenderMethod, int>& weights, const VideoPicture& picture);
40 
41 protected:
42  explicit CRendererShaders(CVideoSettings& videoSettings);
43  void RenderImpl(CD3DTexture& target, CRect& sourceRect, CPoint(&destPoints)[4], uint32_t flags) override;
44  void CheckVideoParameters() override;
45  void UpdateVideoFilters() override;
46  CRenderBuffer* CreateBuffer() override;
47  static bool IsHWPicSupported(const VideoPicture& picture);
48 
49 private:
50  static AVColorPrimaries GetSrcPrimaries(AVColorPrimaries srcPrimaries, unsigned int width, unsigned int height);
51  DXGI_FORMAT CalcIntermediateTargetFormat() const;
52 
53  AVColorPrimaries m_srcPrimaries = AVCOL_PRI_BT709;
54  std::unique_ptr<CYUV2RGBShader> m_colorShader;
55 };
56 
58 {
59 public:
60  explicit CRenderBufferImpl(AVPixelFormat av_pix_format, unsigned width, unsigned height);
62 
63  void AppendPicture(const VideoPicture& picture) override;
64  bool UploadBuffer() override;
65  unsigned GetViewCount() const override;
66  ID3D11View* GetView(unsigned viewIdx) override;
67  void ReleasePicture() override;
68 
69 private:
70  bool UploadFromGPU();
71  bool UploadFromBuffer() const;
72 
73  unsigned m_viewCount = 0;
74  CD3DTexture m_textures[YuvImage::MAX_PLANES];
75  Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_planes[2];
76 };
Definition: D3DResource.h:90
Definition: RendererBase.h:57
Definition: RendererHQ.h:12
Definition: RendererShaders.h:29
Definition: DVDVideoCodec.h:36
Definition: RendererShaders.h:57
Definition: VideoSettings.h:194
Definition: RendererBase.h:111