xbmc
IShader.h
1 /*
2  * Copyright (C) 2017-2020 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 
9 #pragma once
10 
11 #include "ShaderTypes.h"
12 #include "utils/Geometry.h"
13 
14 #include <map>
15 #include <stdint.h>
16 #include <string>
17 
18 namespace KODI
19 {
20 namespace SHADER
21 {
22 class IShaderSampler;
23 class IShaderTexture;
24 
25 class IShader
26 {
27 public:
39  virtual bool Create(const std::string& shaderSource,
40  const std::string& shaderPath,
41  ShaderParameterMap shaderParameters,
42  IShaderSampler* sampler,
43  ShaderLutVec luts,
44  float2 viewPortSize,
45  unsigned frameCountMod = 0) = 0;
46 
52  virtual void Render(IShaderTexture* source, IShaderTexture* target) = 0;
53 
59  virtual void SetSizes(const float2& prevSize, const float2& nextSize) = 0;
60 
67  virtual bool CreateVertexBuffer(unsigned vertCount, unsigned vertSize) = 0;
68 
73  virtual bool CreateInputBuffer() = 0;
74 
83  virtual void PrepareParameters(CPoint dest[4], bool isLastPass, uint64_t frameCount) = 0;
84 
89  virtual void UpdateMVP() = 0;
90 
91  virtual ~IShader() = default;
92 };
93 } // namespace SHADER
94 } // namespace KODI
virtual void UpdateMVP()=0
Updates the model view projection matrix. Should usually only be called when the viewport/window size...
virtual void SetSizes(const float2 &prevSize, const float2 &nextSize)=0
Sets the input and output sizes in pixels.
Definition: AudioDecoder.h:18
virtual void Render(IShaderTexture *source, IShaderTexture *target)=0
Renders the video shader to the target texture.
virtual bool CreateInputBuffer()=0
Creates the buffer that will be used to send "input" (as per the spec) data to the shader...
Definition: IShader.h:25
Definition: IShaderTexture.h:15
Definition: ShaderTypes.h:108
Definition: IShaderSampler.h:15
virtual bool CreateVertexBuffer(unsigned vertCount, unsigned vertSize)=0
Construct the vertex buffer that will be used to render the shader.
virtual void PrepareParameters(CPoint dest[4], bool isLastPass, uint64_t frameCount)=0
Called before rendering. Updates any internal state needed to ensure that correct data is passed to t...
virtual bool Create(const std::string &shaderSource, const std::string &shaderPath, ShaderParameterMap shaderParameters, IShaderSampler *sampler, ShaderLutVec luts, float2 viewPortSize, unsigned frameCountMod=0)=0
Construct the vidoe shader instance.