2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2014-07-29 10:47:56 -06:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-01-17 14:54:31 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-07-29 10:47:56 -06:00
|
|
|
#include "Common/Timer.h"
|
2014-10-18 01:32:24 -06:00
|
|
|
#include "VideoCommon/VideoCommon.h"
|
|
|
|
|
2014-07-29 10:47:56 -06:00
|
|
|
class PostProcessingShaderConfiguration
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
struct ConfigurationOption
|
|
|
|
{
|
|
|
|
enum OptionType
|
|
|
|
{
|
|
|
|
OPTION_BOOL = 0,
|
|
|
|
OPTION_FLOAT,
|
|
|
|
OPTION_INTEGER,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool m_bool_value;
|
|
|
|
|
|
|
|
std::vector<float> m_float_values;
|
|
|
|
std::vector<s32> m_integer_values;
|
|
|
|
|
|
|
|
std::vector<float> m_float_min_values;
|
|
|
|
std::vector<s32> m_integer_min_values;
|
|
|
|
|
|
|
|
std::vector<float> m_float_max_values;
|
|
|
|
std::vector<s32> m_integer_max_values;
|
|
|
|
|
|
|
|
std::vector<float> m_float_step_values;
|
|
|
|
std::vector<s32> m_integer_step_values;
|
|
|
|
|
|
|
|
OptionType m_type;
|
|
|
|
|
|
|
|
std::string m_gui_name;
|
|
|
|
std::string m_option_name;
|
|
|
|
std::string m_dependent_option;
|
|
|
|
bool m_dirty;
|
|
|
|
};
|
|
|
|
|
2018-05-21 09:57:15 -06:00
|
|
|
using ConfigMap = std::map<std::string, ConfigurationOption>;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2018-05-21 09:54:53 -06:00
|
|
|
PostProcessingShaderConfiguration();
|
|
|
|
virtual ~PostProcessingShaderConfiguration();
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Loads the configuration with a shader
|
|
|
|
// If the argument is "" the class will load the shader from the g_activeConfig option.
|
|
|
|
// Returns the loaded shader source from file
|
|
|
|
std::string LoadShader(std::string shader = "");
|
|
|
|
void SaveOptionsConfiguration();
|
|
|
|
void ReloadShader();
|
2018-05-21 10:07:46 -06:00
|
|
|
const std::string& GetShader() const { return m_current_shader; }
|
2018-05-21 09:59:04 -06:00
|
|
|
bool IsDirty() const { return m_any_options_dirty; }
|
2016-06-24 02:43:46 -06:00
|
|
|
void SetDirty(bool dirty) { m_any_options_dirty = dirty; }
|
2018-05-21 09:59:04 -06:00
|
|
|
bool HasOptions() const { return m_options.size() > 0; }
|
2017-04-21 07:33:12 -06:00
|
|
|
const ConfigMap& GetOptions() const { return m_options; }
|
2016-06-24 02:43:46 -06:00
|
|
|
ConfigMap& GetOptions() { return m_options; }
|
|
|
|
const ConfigurationOption& GetOption(const std::string& option) { return m_options[option]; }
|
|
|
|
// For updating option's values
|
|
|
|
void SetOptionf(const std::string& option, int index, float value);
|
|
|
|
void SetOptioni(const std::string& option, int index, s32 value);
|
|
|
|
void SetOptionb(const std::string& option, bool value);
|
2014-07-29 10:47:56 -06:00
|
|
|
|
|
|
|
private:
|
2018-05-21 09:54:53 -06:00
|
|
|
bool m_any_options_dirty = false;
|
2016-06-24 02:43:46 -06:00
|
|
|
std::string m_current_shader;
|
|
|
|
ConfigMap m_options;
|
2014-07-29 10:47:56 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void LoadOptions(const std::string& code);
|
|
|
|
void LoadOptionsConfiguration();
|
2014-07-29 10:47:56 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
class PostProcessingShaderImplementation
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
PostProcessingShaderImplementation();
|
|
|
|
virtual ~PostProcessingShaderImplementation();
|
2014-07-29 10:47:56 -06:00
|
|
|
|
2017-04-21 07:59:45 -06:00
|
|
|
static std::vector<std::string> GetShaderList(APIType api_type);
|
|
|
|
static std::vector<std::string> GetAnaglyphShaderList(APIType api_type);
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
PostProcessingShaderConfiguration* GetConfig() { return &m_config; }
|
2018-04-12 06:18:04 -06:00
|
|
|
|
2014-07-29 10:47:56 -06:00
|
|
|
protected:
|
2016-06-24 02:43:46 -06:00
|
|
|
// Timer for determining our time value
|
|
|
|
Common::Timer m_timer;
|
2014-07-29 10:47:56 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
PostProcessingShaderConfiguration m_config;
|
2014-07-29 10:47:56 -06:00
|
|
|
};
|