ReShade
A generic post-processing injector for games and video software.
reshade_api.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Patrick Mours
3  * SPDX-License-Identifier: BSD-3-Clause OR MIT
4  */
5 
6 #pragma once
7 
8 #include "reshade_api_device.hpp"
9 
10 namespace reshade::api
11 {
33 
39  {
45 
58  virtual void render_effects(command_list *cmd_list, resource_view rtv, resource_view rtv_srgb = { 0 }) = 0;
59 
64  virtual bool capture_screenshot(uint8_t *pixels) = 0;
65 
70  virtual void get_screenshot_width_and_height(uint32_t *out_width, uint32_t *out_height) const = 0;
71 
77  virtual bool is_key_down(uint32_t keycode) const = 0;
83  virtual bool is_key_pressed(uint32_t keycode) const = 0;
89  virtual bool is_key_released(uint32_t keycode) const = 0;
95  virtual bool is_mouse_button_down(uint32_t button) const = 0;
101  virtual bool is_mouse_button_pressed(uint32_t button) const = 0;
107  virtual bool is_mouse_button_released(uint32_t button) const = 0;
108 
115  virtual void get_mouse_cursor_position(uint32_t *out_x, uint32_t *out_y, int16_t *out_wheel_delta = nullptr) const = 0;
116 
123  virtual void enumerate_uniform_variables(const char *effect_name, void(*callback)(effect_runtime *runtime, effect_uniform_variable variable, void *user_data), void *user_data) = 0;
129  template <typename F>
130  inline void enumerate_uniform_variables(const char *effect_name, F lambda) {
131  enumerate_uniform_variables(effect_name, [](effect_runtime *runtime, effect_uniform_variable variable, void *user_data) { static_cast<F *>(user_data)->operator()(runtime, variable); }, &lambda);
132  }
133 
140  virtual effect_uniform_variable find_uniform_variable(const char *effect_name, const char *variable_name) const = 0;
141 
150  virtual void get_uniform_variable_type(effect_uniform_variable variable, format *out_base_type, uint32_t *out_rows = nullptr, uint32_t *out_columns = nullptr, uint32_t *out_array_length = nullptr) const = 0;
151 
158  virtual void get_uniform_variable_name(effect_uniform_variable variable, char *name, size_t *length) const = 0;
159  template <size_t SIZE>
160  inline void get_uniform_variable_name(effect_uniform_variable variable, char(&name)[SIZE]) const {
161  size_t length = SIZE;
162  get_uniform_variable_name(variable, name, &length);
163  }
164 
173  virtual bool get_annotation_bool_from_uniform_variable(effect_uniform_variable variable, const char *name, bool *values, size_t count, size_t array_index = 0) const = 0;
182  virtual bool get_annotation_float_from_uniform_variable(effect_uniform_variable variable, const char *name, float *values, size_t count, size_t array_index = 0) const = 0;
191  virtual bool get_annotation_int_from_uniform_variable(effect_uniform_variable variable, const char *name, int32_t *values, size_t count, size_t array_index = 0) const = 0;
200  virtual bool get_annotation_uint_from_uniform_variable(effect_uniform_variable variable, const char *name, uint32_t *values, size_t count, size_t array_index = 0) const = 0;
208  virtual bool get_annotation_string_from_uniform_variable(effect_uniform_variable variable, const char *name, char *value, size_t *length) const = 0;
209  template <size_t SIZE>
210  inline bool get_annotation_string_from_uniform_variable(effect_uniform_variable variable, const char *name, char(&value)[SIZE]) const {
211  size_t length = SIZE;
212  return get_annotation_string_from_uniform_variable(variable, name, value, &length);
213  }
214 
222  virtual void get_uniform_value_bool(effect_uniform_variable variable, bool *values, size_t count, size_t array_index = 0) const = 0;
230  virtual void get_uniform_value_float(effect_uniform_variable variable, float *values, size_t count, size_t array_index = 0) const = 0;
238  virtual void get_uniform_value_int(effect_uniform_variable variable, int32_t *values, size_t count, size_t array_index = 0) const = 0;
246  virtual void get_uniform_value_uint(effect_uniform_variable variable, uint32_t *values, size_t count, size_t array_index = 0) const = 0;
247 
255  virtual void set_uniform_value_bool(effect_uniform_variable variable, const bool *values, size_t count, size_t array_index = 0) = 0;
264  inline void set_uniform_value_bool(effect_uniform_variable variable, bool x, bool y = bool(0), bool z = bool(0), bool w = bool(0)) {
265  const bool values[4] = { x, y, z, w };
266  set_uniform_value_bool(variable, values, 4);
267  }
275  virtual void set_uniform_value_float(effect_uniform_variable variable, const float *values, size_t count, size_t array_index = 0) = 0;
284  inline void set_uniform_value_float(effect_uniform_variable variable, float x, float y = float(0), float z = float(0), float w = float(0)) {
285  const float values[4] = { x, y, z, w };
286  set_uniform_value_float(variable, values, 4);
287  }
295  virtual void set_uniform_value_int(effect_uniform_variable variable, const int32_t *values, size_t count, size_t array_index = 0) = 0;
304  inline void set_uniform_value_int(effect_uniform_variable variable, int32_t x, int32_t y = int32_t(0), int32_t z = int32_t(0), int32_t w = int32_t(0)) {
305  const int32_t values[4] = { x, y, z, w };
306  set_uniform_value_int(variable, values, 4);
307  }
315  virtual void set_uniform_value_uint(effect_uniform_variable variable, const uint32_t *values, size_t count, size_t array_index = 0) = 0;
324  inline void set_uniform_value_uint(effect_uniform_variable variable, uint32_t x, uint32_t y = uint32_t(0), uint32_t z = uint32_t(0), uint32_t w = uint32_t(0)) {
325  const uint32_t values[4] = { x, y, z, w };
326  set_uniform_value_uint(variable, values, 4);
327  }
328 
335  virtual void enumerate_texture_variables(const char *effect_name, void(*callback)(effect_runtime *runtime, effect_texture_variable variable, void *user_data), void *user_data) = 0;
341  template <typename F>
342  inline void enumerate_texture_variables(const char *effect_name, F lambda) {
343  enumerate_texture_variables(effect_name, [](effect_runtime *runtime, effect_texture_variable variable, void *user_data) { static_cast<F *>(user_data)->operator()(runtime, variable); }, &lambda);
344  }
345 
352  virtual effect_texture_variable find_texture_variable(const char *effect_name, const char *variable_name) const = 0;
353 
360  virtual void get_texture_variable_name(effect_texture_variable variable, char *name, size_t *length) const = 0;
361  template <size_t SIZE>
362  inline void get_texture_variable_name(effect_texture_variable variable, char(&name)[SIZE]) const {
363  size_t length = SIZE;
364  get_texture_variable_name(variable, name, &length);
365  }
366 
375  virtual bool get_annotation_bool_from_texture_variable(effect_texture_variable variable, const char *name, bool *values, size_t count, size_t array_index = 0) const = 0;
384  virtual bool get_annotation_float_from_texture_variable(effect_texture_variable variable, const char *name, float *values, size_t count, size_t array_index = 0) const = 0;
393  virtual bool get_annotation_int_from_texture_variable(effect_texture_variable variable, const char *name, int32_t *values, size_t count, size_t array_index = 0) const = 0;
402  virtual bool get_annotation_uint_from_texture_variable(effect_texture_variable variable, const char *name, uint32_t *values, size_t count, size_t array_index = 0) const = 0;
410  virtual bool get_annotation_string_from_texture_variable(effect_texture_variable variable, const char *name, char *value, size_t *length) const = 0;
411  template <size_t SIZE>
412  inline bool get_annotation_string_from_texture_variable(effect_texture_variable variable, const char *name, char(&value)[SIZE]) const {
413  size_t length = SIZE;
414  return get_annotation_string_from_texture_variable(variable, name, value, &length);
415  }
416 
424  virtual void update_texture(effect_texture_variable variable, const uint32_t width, const uint32_t height, const uint8_t *pixels) = 0;
425 
432  virtual void get_texture_binding(effect_texture_variable variable, resource_view *out_srv, resource_view *out_srv_srgb = nullptr) const = 0;
433 
443  virtual void update_texture_bindings(const char *semantic, resource_view srv, resource_view srv_srgb = { 0 }) = 0;
444 
451  virtual void enumerate_techniques(const char *effect_name, void(*callback)(effect_runtime *runtime, effect_technique technique, void *user_data), void *user_data) = 0;
457  template <typename F>
458  inline void enumerate_techniques(const char *effect_name, F lambda) {
459  enumerate_techniques(effect_name, [](effect_runtime *runtime, effect_technique technique, void *user_data) { static_cast<F *>(user_data)->operator()(runtime, technique); }, &lambda);
460  }
461 
468  virtual effect_technique find_technique(const char *effect_name, const char *technique_name) = 0;
469 
476  virtual void get_technique_name(effect_technique technique, char *name, size_t *length) const = 0;
477  template <size_t SIZE>
478  inline void get_technique_name(effect_technique technique, char(&name)[SIZE]) const {
479  size_t length = SIZE;
480  get_technique_name(technique, name, &length);
481  }
482 
491  virtual bool get_annotation_bool_from_technique(effect_technique technique, const char *name, bool *values, size_t count, size_t array_index = 0) const = 0;
500  virtual bool get_annotation_float_from_technique(effect_technique technique, const char *name, float *values, size_t count, size_t array_index = 0) const = 0;
509  virtual bool get_annotation_int_from_technique(effect_technique technique, const char *name, int32_t *values, size_t count, size_t array_index = 0) const = 0;
518  virtual bool get_annotation_uint_from_technique(effect_technique technique, const char *name, uint32_t *values, size_t count, size_t array_index = 0) const = 0;
526  virtual bool get_annotation_string_from_technique(effect_technique technique, const char *name, char *value, size_t *length) const = 0;
527  template <size_t SIZE>
528  inline bool get_annotation_string_from_technique(effect_technique technique, const char *name, char(&value)[SIZE]) const {
529  size_t length = SIZE;
530  return get_annotation_string_from_technique(technique, name, value, &length);
531  }
532 
537  virtual bool get_technique_state(effect_technique technique) const = 0;
543  virtual void set_technique_state(effect_technique technique, bool enabled) = 0;
544 
551  virtual bool get_preprocessor_definition(const char *name, char *value, size_t *length) const = 0;
552  template <size_t SIZE>
553  inline bool get_preprocessor_definition(const char *name, char(&value)[SIZE]) const {
554  size_t length = SIZE;
555  return get_preprocessor_definition(name, value, &length);
556  }
562  virtual void set_preprocessor_definition(const char *name, const char *value) = 0;
563 
576  virtual void render_technique(effect_technique technique, command_list *cmd_list, resource_view rtv, resource_view rtv_srgb = { 0 }) = 0;
577 
581  virtual bool get_effects_state() const = 0;
586  virtual void set_effects_state(bool enabled) = 0;
587 
593  virtual void get_current_preset_path(char *path, size_t *length) const = 0;
594  template <size_t SIZE>
595  inline void get_current_preset_path(char(&path)[SIZE]) const {
596  size_t length = SIZE;
597  get_current_preset_path(path, &length);
598  }
603  virtual void set_current_preset_path(const char *path) = 0;
604  };
605 }
Definition: reshade_api.hpp:11
format
The available data and texture formats. This is mostly compatible with 'DXGI_FORMAT'.
Definition: reshade_api_format.hpp:18
#define RESHADE_DEFINE_INTERFACE_WITH_BASE(name, base)
Definition: reshade_api_device.hpp:10
#define RESHADE_DEFINE_HANDLE(name)
Definition: reshade_api_resource.hpp:8
A command list, used to enqueue render commands on the CPU, before later executing them in a command ...
Definition: reshade_api_device.hpp:513
A command queue, used to execute command lists on the GPU.
Definition: reshade_api_device.hpp:919
A ReShade effect runtime, used to control effects.
Definition: reshade_api.hpp:39
virtual void set_uniform_value_float(effect_uniform_variable variable, const float *values, size_t count, size_t array_index=0)=0
Sets the value of the specified uniform variable as floating-point values.
void enumerate_uniform_variables(const char *effect_name, F lambda)
Enumerates all uniform variables of loaded effects and calls the specified callback function with a h...
Definition: reshade_api.hpp:130
virtual bool get_annotation_string_from_texture_variable(effect_texture_variable variable, const char *name, char *value, size_t *length) const =0
Gets the value from a string annotation attached to the specified texture variable .
bool get_annotation_string_from_technique(effect_technique technique, const char *name, char(&value)[SIZE]) const
Definition: reshade_api.hpp:528
virtual void get_texture_binding(effect_texture_variable variable, resource_view *out_srv, resource_view *out_srv_srgb=nullptr) const =0
Gets the shader resource view that is bound to the specified texture variable .
virtual bool get_annotation_bool_from_technique(effect_technique technique, const char *name, bool *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified technique as boolean values.
void set_uniform_value_int(effect_uniform_variable variable, int32_t x, int32_t y=int32_t(0), int32_t z=int32_t(0), int32_t w=int32_t(0))
Sets the value of the specified uniform variable as a vector of signed integer values.
Definition: reshade_api.hpp:304
virtual bool is_key_down(uint32_t keycode) const =0
Gets the current status of the specified key.
void get_technique_name(effect_technique technique, char(&name)[SIZE]) const
Definition: reshade_api.hpp:478
virtual bool get_annotation_bool_from_texture_variable(effect_texture_variable variable, const char *name, bool *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified texture variable as boolean values.
void enumerate_texture_variables(const char *effect_name, F lambda)
Enumerates all texture variables of loaded effects and calls the specified callback function with a h...
Definition: reshade_api.hpp:342
virtual effect_uniform_variable find_uniform_variable(const char *effect_name, const char *variable_name) const =0
Finds a specific uniform variable in the loaded effects and returns a handle to it.
virtual bool is_mouse_button_released(uint32_t button) const =0
Gets whether the specified mouse button was released this frame.
virtual bool is_mouse_button_pressed(uint32_t button) const =0
Gets whether the specified mouse button was pressed this frame.
virtual bool get_effects_state() const =0
Gets whether effects are enabled or disabled.
bool get_preprocessor_definition(const char *name, char(&value)[SIZE]) const
Definition: reshade_api.hpp:553
bool get_annotation_string_from_texture_variable(effect_texture_variable variable, const char *name, char(&value)[SIZE]) const
Definition: reshade_api.hpp:412
virtual void get_screenshot_width_and_height(uint32_t *out_width, uint32_t *out_height) const =0
Gets the current buffer dimensions of the swap chain as used with effect rendering....
virtual void get_uniform_value_bool(effect_uniform_variable variable, bool *values, size_t count, size_t array_index=0) const =0
Gets the value of the specified uniform variable as boolean values.
void set_uniform_value_bool(effect_uniform_variable variable, bool x, bool y=bool(0), bool z=bool(0), bool w=bool(0))
Sets the value of the specified uniform variable as a vector of boolean values.
Definition: reshade_api.hpp:264
virtual bool get_annotation_float_from_uniform_variable(effect_uniform_variable variable, const char *name, float *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified uniform variable as floating-point value...
virtual void update_texture_bindings(const char *semantic, resource_view srv, resource_view srv_srgb={ 0 })=0
Binds a new shader resource view to all texture variables that use the specified semantic .
virtual void set_technique_state(effect_technique technique, bool enabled)=0
Enables or disables the specified technique .
virtual void set_uniform_value_int(effect_uniform_variable variable, const int32_t *values, size_t count, size_t array_index=0)=0
Sets the value of the specified uniform variable as signed integer values.
virtual void get_uniform_value_uint(effect_uniform_variable variable, uint32_t *values, size_t count, size_t array_index=0) const =0
Gets the value of the specified uniform variable as unsigned integer values.
void get_current_preset_path(char(&path)[SIZE]) const
Definition: reshade_api.hpp:595
virtual void set_uniform_value_uint(effect_uniform_variable variable, const uint32_t *values, size_t count, size_t array_index=0)=0
Sets the value of the specified uniform variable as unsigned integer values.
virtual void set_uniform_value_bool(effect_uniform_variable variable, const bool *values, size_t count, size_t array_index=0)=0
Sets the value of the specified uniform variable as boolean values.
void set_uniform_value_float(effect_uniform_variable variable, float x, float y=float(0), float z=float(0), float w=float(0))
Sets the value of the specified uniform variable as a vector of floating-point values.
Definition: reshade_api.hpp:284
void set_uniform_value_uint(effect_uniform_variable variable, uint32_t x, uint32_t y=uint32_t(0), uint32_t z=uint32_t(0), uint32_t w=uint32_t(0))
Sets the value of the specified uniform variable as a vector of unsigned integer values.
Definition: reshade_api.hpp:324
virtual void update_texture(effect_texture_variable variable, const uint32_t width, const uint32_t height, const uint8_t *pixels)=0
Uploads 32 bits-per-pixel RGBA image data to the specified texture variable .
virtual void enumerate_techniques(const char *effect_name, void(*callback)(effect_runtime *runtime, effect_technique technique, void *user_data), void *user_data)=0
Enumerates all techniques of loaded effects and calls the specified callback function with a handle ...
virtual void enumerate_uniform_variables(const char *effect_name, void(*callback)(effect_runtime *runtime, effect_uniform_variable variable, void *user_data), void *user_data)=0
Enumerates all uniform variables of loaded effects and calls the specified callback function with a ...
virtual bool get_annotation_string_from_uniform_variable(effect_uniform_variable variable, const char *name, char *value, size_t *length) const =0
Gets the value from a string annotation attached to the specified uniform variable .
virtual bool get_technique_state(effect_technique technique) const =0
Gets the state of a technique .
virtual void set_preprocessor_definition(const char *name, const char *value)=0
Defines a global preprocessor definition to the specified value .
virtual void get_uniform_variable_type(effect_uniform_variable variable, format *out_base_type, uint32_t *out_rows=nullptr, uint32_t *out_columns=nullptr, uint32_t *out_array_length=nullptr) const =0
Gets information about the data type of a uniform variable .
virtual bool get_annotation_uint_from_technique(effect_technique technique, const char *name, uint32_t *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified technique as unsigned integer values.
virtual bool get_annotation_uint_from_texture_variable(effect_texture_variable variable, const char *name, uint32_t *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified texture variable as unsigned integer val...
virtual void get_current_preset_path(char *path, size_t *length) const =0
Gets the file path to the currently active preset.
virtual void get_uniform_value_int(effect_uniform_variable variable, int32_t *values, size_t count, size_t array_index=0) const =0
Gets the value of the specified uniform variable as signed integer values.
virtual void get_uniform_value_float(effect_uniform_variable variable, float *values, size_t count, size_t array_index=0) const =0
Gets the value of the specified uniform variable as floating-point values.
virtual bool get_annotation_bool_from_uniform_variable(effect_uniform_variable variable, const char *name, bool *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified uniform variable as boolean values.
virtual void get_uniform_variable_name(effect_uniform_variable variable, char *name, size_t *length) const =0
Gets the name of a uniform variable .
virtual void render_technique(effect_technique technique, command_list *cmd_list, resource_view rtv, resource_view rtv_srgb={ 0 })=0
Applies a technique to the specified render targets (regardless of the state of this technique).
void enumerate_techniques(const char *effect_name, F lambda)
Enumerates all techniques of loaded effects and calls the specified callback function with a handle f...
Definition: reshade_api.hpp:458
virtual bool is_mouse_button_down(uint32_t button) const =0
Gets the current status of the specified mouse button.
virtual bool get_annotation_int_from_technique(effect_technique technique, const char *name, int32_t *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified technique as signed integer values.
bool get_annotation_string_from_uniform_variable(effect_uniform_variable variable, const char *name, char(&value)[SIZE]) const
Definition: reshade_api.hpp:210
virtual bool is_key_pressed(uint32_t keycode) const =0
Gets whether the specified key was pressed this frame.
virtual void enumerate_texture_variables(const char *effect_name, void(*callback)(effect_runtime *runtime, effect_texture_variable variable, void *user_data), void *user_data)=0
Enumerates all texture variables of loaded effects and calls the specified callback function with a ...
virtual command_queue * get_command_queue()=0
Gets the main graphics command queue associated with this effect runtime. This may potentially be dif...
virtual bool get_annotation_int_from_texture_variable(effect_texture_variable variable, const char *name, int32_t *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified texture variable as signed integer value...
virtual bool get_annotation_uint_from_uniform_variable(effect_uniform_variable variable, const char *name, uint32_t *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified uniform variable as unsigned integer val...
virtual void get_texture_variable_name(effect_texture_variable variable, char *name, size_t *length) const =0
Gets the name of a texture variable .
virtual bool capture_screenshot(uint8_t *pixels)=0
Captures a screenshot of the current back buffer resource and returns its image data in 32 bits-per-p...
virtual bool get_annotation_int_from_uniform_variable(effect_uniform_variable variable, const char *name, int32_t *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified uniform variable as signed integer value...
virtual void set_current_preset_path(const char *path)=0
Saves the currently active preset and then switches to the specified new preset.
virtual bool is_key_released(uint32_t keycode) const =0
Gets whether the specified key was released this frame.
void get_texture_variable_name(effect_texture_variable variable, char(&name)[SIZE]) const
Definition: reshade_api.hpp:362
void get_uniform_variable_name(effect_uniform_variable variable, char(&name)[SIZE]) const
Definition: reshade_api.hpp:160
virtual effect_technique find_technique(const char *effect_name, const char *technique_name)=0
Finds a specific technique in the loaded effects and returns a handle to it.
virtual bool get_preprocessor_definition(const char *name, char *value, size_t *length) const =0
Gets the value of global preprocessor definition.
virtual void render_effects(command_list *cmd_list, resource_view rtv, resource_view rtv_srgb={ 0 })=0
Applies post-processing effects to the specified render targets and prevents the usual rendering of e...
virtual bool get_annotation_float_from_technique(effect_technique technique, const char *name, float *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified technique as floating-point values.
virtual effect_texture_variable find_texture_variable(const char *effect_name, const char *variable_name) const =0
Finds a specific texture variable in the loaded effects and returns a handle to it.
virtual bool get_annotation_string_from_technique(effect_technique technique, const char *name, char *value, size_t *length) const =0
Gets the value from a string annotation attached to the specified technique .
virtual void get_technique_name(effect_technique technique, char *name, size_t *length) const =0
Gets the name of a technique .
virtual bool get_annotation_float_from_texture_variable(effect_texture_variable variable, const char *name, float *values, size_t count, size_t array_index=0) const =0
Gets the value from an annotation attached to the specified texture variable as floating-point value...
virtual void set_effects_state(bool enabled)=0
Enables or disables all effects.
virtual void get_mouse_cursor_position(uint32_t *out_x, uint32_t *out_y, int16_t *out_wheel_delta=nullptr) const =0
Gets the current absolute position of the mouse cursor in screen coordinates.
An opaque handle to a technique in an effect.
Definition: reshade_api.hpp:18
An opaque handle to a texture variable in an effect.
Definition: reshade_api.hpp:25
An opaque handle to a uniform variable in an effect.
Definition: reshade_api.hpp:32
An opaque handle to a resource view object (depth-stencil, render target, shader resource view,...
Definition: reshade_api_resource.hpp:408
A swap chain, used to present images to the screen.
Definition: reshade_api_device.hpp:987