win32: make shader params part of IS9xDisplayOutput, add override

specifier
This commit is contained in:
OV2 2023-03-11 21:49:10 +01:00
parent fcdc865641
commit eaaf1ad779
12 changed files with 70 additions and 62 deletions

View File

@ -81,14 +81,14 @@ private:
public: public:
CDirect3D(); CDirect3D();
~CDirect3D(); ~CDirect3D();
bool Initialize(HWND hWnd); bool Initialize(HWND hWnd) override;
void DeInitialize(); void DeInitialize() override;
void Render(SSurface Src); void Render(SSurface Src) override;
bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight); bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight) override;
bool ApplyDisplayChanges(void); bool ApplyDisplayChanges(void) override;
bool SetFullscreen(bool fullscreen); bool SetFullscreen(bool fullscreen) override;
void SetSnes9xColorFormat(); void SetSnes9xColorFormat() override;
void EnumModes(std::vector<dMode> *modeVector); void EnumModes(std::vector<dMode> *modeVector) override;
}; };
#endif #endif

View File

@ -48,16 +48,16 @@ public:
char pDepth, int pRefreshRate, bool pWindowed, char pDepth, int pRefreshRate, bool pWindowed,
bool pDoubleBuffered); bool pDoubleBuffered);
void GetPixelFormat (); void GetPixelFormat ();
void DeInitialize(); void DeInitialize() override;
bool Initialize (HWND hWnd); bool Initialize (HWND hWnd) override;
void Render(SSurface Src); void Render(SSurface Src) override;
bool ApplyDisplayChanges(void); bool ApplyDisplayChanges(void) override;
bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight); bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight) override;
bool SetFullscreen(bool fullscreen); bool SetFullscreen(bool fullscreen) override;
void SetSnes9xColorFormat(); void SetSnes9xColorFormat() override;
void EnumModes(std::vector<dMode> *modeVector); void EnumModes(std::vector<dMode> *modeVector) override;
CDirectDraw(); CDirectDraw();
virtual ~CDirectDraw(); virtual ~CDirectDraw();

View File

@ -397,10 +397,13 @@ void COpenGL::SetSwapInterval(int frames)
wglSwapIntervalEXT(frames); wglSwapIntervalEXT(frames);
} }
std::vector<GLSLParam>* COpenGL::GetShaderParameters(void) std::vector<ShaderParam>* COpenGL::GetShaderParameters(void)
{ {
if (shader_type == OGL_SHADER_GLSL && initDone) if (shader_type == OGL_SHADER_GLSL && initDone)
return &glslShader->param; {
// GLSLParam currently equal ShaderParam, so no conversion is neccessary
return (std::vector<ShaderParam>*)&glslShader->param;
}
return nullptr; return nullptr;
} }

View File

@ -76,17 +76,17 @@ private:
public: public:
COpenGL(); COpenGL();
~COpenGL(); ~COpenGL();
bool Initialize(HWND hWnd); bool Initialize(HWND hWnd) override;
void DeInitialize(); void DeInitialize() override;
void Render(SSurface Src); void Render(SSurface Src) override;
bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight); bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight) override;
bool ApplyDisplayChanges(void); bool ApplyDisplayChanges(void) override;
bool SetFullscreen(bool fullscreen); bool SetFullscreen(bool fullscreen) override;
void SetSnes9xColorFormat(void); void SetSnes9xColorFormat(void) override;
void EnumModes(std::vector<dMode> *modeVector); void EnumModes(std::vector<dMode> *modeVector) override;
void SetSwapInterval(int frames); void SetSwapInterval(int frames);
std::vector<GLSLParam> *GetShaderParameters(void); std::vector<ShaderParam> *GetShaderParameters(void) override;
std::function<void(const char*)> GetShaderParametersSaveFunction(); std::function<void(const char*)> GetShaderParametersSaveFunction() override;
}; };

View File

@ -143,7 +143,7 @@ void CShaderParamDlg::trackbar_changed(HWND trackbar)
SetWindowText(p.entry, val); SetWindowText(p.entry, val);
} }
CShaderParamDlg::CShaderParamDlg(std::vector<GLSLParam>& parameters_, std::function<void (const char *)> save_function_) CShaderParamDlg::CShaderParamDlg(std::vector<ShaderParam>& parameters_, std::function<void (const char *)> save_function_)
: parameters(parameters_), : parameters(parameters_),
save_function(save_function_) save_function(save_function_)
{ {
@ -288,7 +288,7 @@ void CShaderParamDlg::createContent(HWND hDlg)
parameter_widgets.clear(); parameter_widgets.clear();
for(int i = 0; i < parameters.size(); i++) { for(int i = 0; i < parameters.size(); i++) {
ParameterWidgetSet widgets{}; ParameterWidgetSet widgets{};
GLSLParam &p = parameters[i]; ShaderParam &p = parameters[i];
TCHAR desc[270]; TCHAR desc[270];
_stprintf(desc, TEXT("%s [%g-%g]"), (TCHAR*)_tFromChar(p.name.c_str()), p.min, p.max); _stprintf(desc, TEXT("%s [%g-%g]"), (TCHAR*)_tFromChar(p.name.c_str()), p.min, p.max);
HWND item = CreateWindow(TEXT("STATIC"), desc, SS_LEFTNOWORDWRAP | WS_VISIBLE | WS_CHILD, MARGIN, (INT)(top + avgCharHeight * 0.3), desc_width, avgCharHeight, parent, (HMENU)(UINT_PTR)(IDC_PARAMS_START_STATIC + i), GUI.hInstance, NULL); HWND item = CreateWindow(TEXT("STATIC"), desc, SS_LEFTNOWORDWRAP | WS_VISIBLE | WS_CHILD, MARGIN, (INT)(top + avgCharHeight * 0.3), desc_width, avgCharHeight, parent, (HMENU)(UINT_PTR)(IDC_PARAMS_START_STATIC + i), GUI.hInstance, NULL);
@ -351,7 +351,7 @@ void CShaderParamDlg::handle_up_down(HWND hStatic, int id, int change)
{ {
int param_id = id - IDC_PARAMS_START_UPDOWN; int param_id = id - IDC_PARAMS_START_UPDOWN;
HWND hEdit = GetDlgItem(hStatic, IDC_PARAMS_START_EDIT + param_id); HWND hEdit = GetDlgItem(hStatic, IDC_PARAMS_START_EDIT + param_id);
GLSLParam &p = parameters[param_id]; ShaderParam &p = parameters[param_id];
TCHAR val[100]; TCHAR val[100];
GetWindowText(hEdit, val, 100); GetWindowText(hEdit, val, 100);
p.val = _ttof(val); p.val = _ttof(val);
@ -371,7 +371,7 @@ void CShaderParamDlg::get_changed_parameters(HWND hDlg)
{ {
HWND parent = GetDlgItem(hDlg, IDC_STATIC_CONTAINER); HWND parent = GetDlgItem(hDlg, IDC_STATIC_CONTAINER);
for(int i = 0; i < parameters.size(); i++) { for(int i = 0; i < parameters.size(); i++) {
GLSLParam &p = parameters[i]; ShaderParam &p = parameters[i];
TCHAR val[100]; TCHAR val[100];
HWND hEdit = GetDlgItem(parent, IDC_PARAMS_START_EDIT + i); HWND hEdit = GetDlgItem(parent, IDC_PARAMS_START_EDIT + i);
GetWindowText(hEdit, val, 100); GetWindowText(hEdit, val, 100);

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include "windows.h" #include "windows.h"
#include "../shaders/glsl.h" #include "wsnes9x.h"
#include <functional> #include <functional>
typedef void(*APPLYCALLBACK) (); typedef void(*APPLYCALLBACK) ();
@ -29,8 +29,8 @@ private:
unsigned int avgCharHeight; unsigned int avgCharHeight;
unsigned int maxDescriptionWidth; unsigned int maxDescriptionWidth;
int scrollpos; int scrollpos;
std::vector<GLSLParam>& parameters; std::vector<ShaderParam>& parameters;
std::vector<GLSLParam> saved_parameters; std::vector<ShaderParam> saved_parameters;
std::function<void (const char *)> save_function; std::function<void (const char *)> save_function;
struct ParameterWidgetSet struct ParameterWidgetSet
@ -45,7 +45,7 @@ private:
WNDPROC oldStaticProc; WNDPROC oldStaticProc;
public: public:
CShaderParamDlg(std::vector<GLSLParam> &parameters, std::function<void (const char *)> save_function); CShaderParamDlg(std::vector<ShaderParam> &parameters, std::function<void (const char *)> save_function);
virtual ~CShaderParamDlg(); virtual ~CShaderParamDlg();
bool show(); bool show();

View File

@ -205,11 +205,12 @@ void CVulkan::EnumModes(std::vector<dMode>* modeVector)
} }
} }
std::vector<SlangShader::Parameter> *CVulkan::GetShaderParameters() std::vector<ShaderParam> *CVulkan::GetShaderParameters()
{ {
if (shaderchain) if (shaderchain)
{ {
return &shaderchain->preset->parameters; // SlangShader::Parameter currently equal ShaderParam, so no conversion is neccessary
return (std::vector<ShaderParam>*)&shaderchain->preset->parameters;
} }
else else
return nullptr; return nullptr;

View File

@ -20,15 +20,15 @@ class CVulkan : public IS9xDisplayOutput
int current_height; int current_height;
public: public:
bool Initialize(HWND hWnd); bool Initialize(HWND hWnd) override;
void DeInitialize(); void DeInitialize() override;
void Render(SSurface Src); void Render(SSurface Src) override;
bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight); bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight) override;
bool ApplyDisplayChanges(void); bool ApplyDisplayChanges(void) override;
bool SetFullscreen(bool fullscreen); bool SetFullscreen(bool fullscreen) override;
void SetSnes9xColorFormat(); void SetSnes9xColorFormat() override;
void EnumModes(std::vector<dMode>* modeVector); void EnumModes(std::vector<dMode>* modeVector) override;
std::vector<SlangShader::Parameter> *GetShaderParameters(void); std::vector<ShaderParam> *GetShaderParameters(void) override;
std::function<void(const char *)> GetShaderParametersSaveFunction(); std::function<void(const char *)> GetShaderParametersSaveFunction() override;
}; };

View File

@ -10,6 +10,7 @@
#include "render.h" #include "render.h"
#include "wsnes9x.h" #include "wsnes9x.h"
#include <vector> #include <vector>
#include <functional>
/* IS9xDisplayOutput /* IS9xDisplayOutput
Interface for display driver. Interface for display driver.
@ -27,6 +28,8 @@ public:
virtual bool SetFullscreen(bool fullscreen)=0; virtual bool SetFullscreen(bool fullscreen)=0;
virtual void SetSnes9xColorFormat()=0; virtual void SetSnes9xColorFormat()=0;
virtual void EnumModes(std::vector<dMode> *modeVector)=0; virtual void EnumModes(std::vector<dMode> *modeVector)=0;
virtual std::vector<ShaderParam>* GetShaderParameters(void) { return nullptr; }
virtual std::function<void(const char *)> GetShaderParametersSaveFunction() { return std::function<void(const char*)>(); }
}; };

View File

@ -711,23 +711,14 @@ void WinThrottleFramerate()
PCStart += PCFrameTime; PCStart += PCFrameTime;
} }
std::vector<GLSLParam> *WinGetShaderParameters() std::vector<ShaderParam> *WinGetShaderParameters()
{ {
if (GUI.outputMethod == OPENGL) return S9xDisplayOutput->GetShaderParameters();
return OpenGL.GetShaderParameters();
if (GUI.outputMethod == VULKAN)
return (std::vector<GLSLParam> *)VulkanDriver.GetShaderParameters();
return nullptr;
} }
std::function<void(const char*)> WinGetShaderSaveFunction() std::function<void(const char*)> WinGetShaderSaveFunction()
{ {
if (GUI.outputMethod == OPENGL) return S9xDisplayOutput->GetShaderParametersSaveFunction();
return OpenGL.GetShaderParametersSaveFunction();
else if (GUI.outputMethod == VULKAN)
return VulkanDriver.GetShaderParametersSaveFunction();
else
return std::function<void(const char*)>();
} }
/* Depth conversion functions begin */ /* Depth conversion functions begin */

View File

@ -10,7 +10,6 @@
#include "wsnes9x.h" #include "wsnes9x.h"
#include "port.h" #include "port.h"
#include "render.h" #include "render.h"
#include "../shaders/glsl.h"
#include <vector> #include <vector>
#include <functional> #include <functional>
@ -43,7 +42,7 @@ void ReduceToPath(TCHAR *filename);
double WinGetRefreshRate(); double WinGetRefreshRate();
int WinGetAutomaticInputRate(); int WinGetAutomaticInputRate();
void WinThrottleFramerate(); void WinThrottleFramerate();
std::vector<GLSLParam> *WinGetShaderParameters(); std::vector<ShaderParam> *WinGetShaderParameters();
std::function<void(const char*)> WinGetShaderSaveFunction(); std::function<void(const char*)> WinGetShaderSaveFunction();
#endif #endif

View File

@ -121,6 +121,17 @@ struct dMode
long rate; long rate;
}; };
struct ShaderParam
{
std::string name;
std::string id;
float min;
float max;
float val;
float step;
int significant_digits;
};
struct sCustomRomDlgSettings { struct sCustomRomDlgSettings {
int columnFilename; int columnFilename;
int columnDescription; int columnDescription;