duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

postprocessing_shader.h (2005B)


      1 // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
      2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
      3 
      4 #pragma once
      5 
      6 #include "postprocessing.h"
      7 
      8 #include "gpu_texture.h"
      9 
     10 #include "common/gsvector.h"
     11 #include "common/settings_interface.h"
     12 #include "common/timer.h"
     13 #include "common/types.h"
     14 #include "gpu_device.h"
     15 
     16 #include <array>
     17 #include <string>
     18 #include <string_view>
     19 #include <vector>
     20 
     21 class GPUPipeline;
     22 class GPUTexture;
     23 class ProgressCallback;
     24 
     25 namespace PostProcessing {
     26 
     27 class Shader
     28 {
     29 public:
     30   Shader();
     31   Shader(std::string name);
     32   virtual ~Shader();
     33 
     34   ALWAYS_INLINE const std::string& GetName() const { return m_name; }
     35   ALWAYS_INLINE const std::vector<ShaderOption>& GetOptions() const { return m_options; }
     36   ALWAYS_INLINE std::vector<ShaderOption>& GetOptions() { return m_options; }
     37   ALWAYS_INLINE bool HasOptions() const { return !m_options.empty(); }
     38 
     39   virtual bool IsValid() const = 0;
     40   virtual bool WantsDepthBuffer() const = 0;
     41 
     42   std::vector<ShaderOption> TakeOptions();
     43   void LoadOptions(const SettingsInterface& si, const char* section);
     44 
     45   const ShaderOption* GetOptionByName(std::string_view name) const;
     46   ShaderOption* GetOptionByName(std::string_view name);
     47 
     48   virtual bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height) = 0;
     49 
     50   virtual bool CompilePipeline(GPUTexture::Format format, u32 width, u32 height, ProgressCallback* progress) = 0;
     51 
     52   virtual bool Apply(GPUTexture* input_color, GPUTexture* input_depth, GPUTexture* final_target, GSVector4i final_rect,
     53                      s32 orig_width, s32 orig_height, s32 native_width, s32 native_height, u32 target_width,
     54                      u32 target_height) = 0;
     55 
     56 protected:
     57   using OptionList = std::vector<ShaderOption>;
     58 
     59   static void ParseKeyValue(std::string_view line, std::string_view* key, std::string_view* value);
     60 
     61   virtual void OnOptionChanged(const ShaderOption& option);
     62 
     63   std::string m_name;
     64   OptionList m_options;
     65 };
     66 
     67 } // namespace PostProcessing