xbmc
shaderpreset.h
1 /*
2  * Copyright (C) 2022 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 #ifndef C_API_ADDONINSTANCE_SHADER_PRESET_H
10 #define C_API_ADDONINSTANCE_SHADER_PRESET_H
11 
12 #include "../addon_base.h"
13 
14 #include <stddef.h> /* size_t */
15 
16 //==============================================================================
19 #define DEFAULT_PORT_ID "1"
20 //------------------------------------------------------------------------------
21 
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif /* __cplusplus */
26  //============================================================================
31  typedef void* preset_file;
32 
43  typedef enum SHADER_SCALE_TYPE
44  {
51  SHADER_SCALE_TYPE_INPUT,
52 
60  SHADER_SCALE_TYPE_ABSOLUTE,
61 
68  SHADER_SCALE_TYPE_VIEWPORT
69  } SHADER_SCALE_TYPE;
70 
71  typedef enum SHADER_FILTER_TYPE
72  {
73  SHADER_FILTER_TYPE_UNSPEC,
74  SHADER_FILTER_TYPE_LINEAR,
75  SHADER_FILTER_TYPE_NEAREST
76  } SHADER_FILTER_TYPE;
77 
81  typedef enum SHADER_WRAP_TYPE
82  {
83  SHADER_WRAP_TYPE_BORDER, /* Deprecated, will be translated to EDGE in GLES */
84  SHADER_WRAP_TYPE_EDGE,
85  SHADER_WRAP_TYPE_REPEAT,
86  SHADER_WRAP_TYPE_MIRRORED_REPEAT
87  } SHADER_WRAP_TYPE;
88 
92  typedef struct fbo_scale_axis
93  {
94  SHADER_SCALE_TYPE type;
95  union
96  {
97  float scale;
98  unsigned abs;
99  };
100  } fbo_scale_axis;
101 
105  typedef struct fbo_scale
106  {
110  bool srgb_fbo;
111 
120  bool fp_fbo;
121 
126 
131  } fbo_scale;
132 
133  typedef struct video_shader_parameter
134  {
135  char* id;
136  char* desc;
137  float current;
138  float minimum;
139  float initial;
140  float maximum;
141  float step;
143 
144  typedef struct video_shader_pass
145  {
149  char* source_path;
150 
155 
161 
166 
172  SHADER_FILTER_TYPE filter;
173 
177  SHADER_WRAP_TYPE wrap;
178 
182  unsigned frame_count_mod;
183 
187  bool mipmap;
189 
190  typedef struct video_shader_lut
191  {
195  char* id;
196 
200  char* path;
201 
205  SHADER_FILTER_TYPE filter;
206 
210  SHADER_WRAP_TYPE wrap;
211 
215  bool mipmap;
217 
218  typedef struct video_shader
219  {
220  unsigned pass_count;
221  video_shader_pass* passes;
222 
223  unsigned lut_count;
224  video_shader_lut* luts;
225 
226  unsigned parameter_count;
227  video_shader_parameter* parameters;
228  } video_shader;
229  //----------------------------------------------------------------------------
230 
232 
233  //--==----==----==----==----==----==----==----==----==----==----==----==----==--
234 
240  typedef struct AddonProps_ShaderPreset
241  {
245  const char* user_path;
246 
250  const char* addon_path;
252 
256 
263  {
264  KODI_HANDLE kodiInstance;
266 
273  {
274  KODI_HANDLE addonInstance;
275 
276  // TODO: Convert function pointers to CamelCase
277  preset_file(__cdecl* preset_file_new)(const AddonInstance_ShaderPreset*, const char*);
278  void(__cdecl* preset_file_free)(const AddonInstance_ShaderPreset*, preset_file);
279 
280  bool(__cdecl* video_shader_read)(const AddonInstance_ShaderPreset*, preset_file, video_shader*);
281  void(__cdecl* video_shader_write)(const AddonInstance_ShaderPreset*,
282  preset_file,
283  const video_shader*);
284  /*
285  void(__cdecl* video_shader_resolve_relative)(const AddonInstance_ShaderPreset*,
286  video_shader*,
287  const char*);
288  bool(__cdecl* video_shader_resolve_current_parameters)(const AddonInstance_ShaderPreset*,
289  preset_file,
290  video_shader*);
291  */
292  bool(__cdecl* video_shader_resolve_parameters)(const AddonInstance_ShaderPreset*,
293  preset_file,
294  video_shader*);
295  void(__cdecl* video_shader_free)(const AddonInstance_ShaderPreset*, video_shader*);
297 
304  {
305  struct AddonProps_ShaderPreset* props;
306  struct AddonToKodiFuncTable_ShaderPreset* toKodi;
307  struct KodiToAddonFuncTable_ShaderPreset* toAddon;
309 
310 #ifdef __cplusplus
311 }
312 #endif /* __cplusplus */
313 
314 #endif /* !C_API_ADDONINSTANCE_SHADER_PRESET_H */
unsigned frame_count_mod
Frame count mod.
Definition: shaderpreset.h:182
fbo_scale fbo
FBO parameters.
Definition: shaderpreset.h:165
SHADER_WRAP_TYPE wrap
Texture wrapping mode.
Definition: shaderpreset.h:210
fbo_scale_axis scale_y
Scaling parameters for Y axis.
Definition: shaderpreset.h:130
Definition: shaderpreset.h:144
char * id
Name of the sampler uniform, e.g. uniform sampler2D foo.
Definition: shaderpreset.h:195
bool mipmap
Mipmapping.
Definition: shaderpreset.h:187
bool fp_fbo
Float framebuffer.
Definition: shaderpreset.h:120
fbo_scale_axis scale_x
Scaling parameters for X axis.
Definition: shaderpreset.h:125
char * path
Path of the texture.
Definition: shaderpreset.h:200
SHADER_FILTER_TYPE filter
Defines how the result of this pass will be filtered.
Definition: shaderpreset.h:172
SHADER_WRAP_TYPE wrap
Wrapping mode.
Definition: shaderpreset.h:177
ShaderPreset instance.
Definition: shaderpreset.h:303
ShaderPreset callbacks.
Definition: shaderpreset.h:262
FBO parameters.
Definition: shaderpreset.h:105
const char * addon_path
The path to this add-on.
Definition: shaderpreset.h:250
Definition: shaderpreset.h:190
const char * user_path
The path to the user profile.
Definition: shaderpreset.h:245
Definition: shaderpreset.h:218
char * fragment_source
The fragment shader source, if separate from the vertex source, or NULL otherwise.
Definition: shaderpreset.h:160
bool srgb_fbo
sRGB framebuffer
Definition: shaderpreset.h:110
SHADER_FILTER_TYPE filter
Filtering for the texture.
Definition: shaderpreset.h:205
bool mipmap
Use mipmapping for the texture.
Definition: shaderpreset.h:215
ShaderPreset function hooks.
Definition: shaderpreset.h:272
char * source_path
Path to the shader pass source.
Definition: shaderpreset.h:149
char * vertex_source
The vertex shader source.
Definition: shaderpreset.h:154
FBO scaling parameters for a single axis.
Definition: shaderpreset.h:92
Definition: shaderpreset.h:133
ShaderPreset properties.
Definition: shaderpreset.h:240