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:
CDirect3D();
~CDirect3D();
bool Initialize(HWND hWnd);
void DeInitialize();
void Render(SSurface Src);
bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight);
bool ApplyDisplayChanges(void);
bool SetFullscreen(bool fullscreen);
void SetSnes9xColorFormat();
void EnumModes(std::vector<dMode> *modeVector);
bool Initialize(HWND hWnd) override;
void DeInitialize() override;
void Render(SSurface Src) override;
bool ChangeRenderSize(unsigned int newWidth, unsigned int newHeight) override;
bool ApplyDisplayChanges(void) override;
bool SetFullscreen(bool fullscreen) override;
void SetSnes9xColorFormat() override;
void EnumModes(std::vector<dMode> *modeVector) override;
};
#endif

View File

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

View File

@ -397,10 +397,13 @@ void COpenGL::SetSwapInterval(int frames)
wglSwapIntervalEXT(frames);
}
std::vector<GLSLParam>* COpenGL::GetShaderParameters(void)
std::vector<ShaderParam>* COpenGL::GetShaderParameters(void)
{
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;
}

View File

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

View File

@ -143,7 +143,7 @@ void CShaderParamDlg::trackbar_changed(HWND trackbar)
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_),
save_function(save_function_)
{
@ -288,7 +288,7 @@ void CShaderParamDlg::createContent(HWND hDlg)
parameter_widgets.clear();
for(int i = 0; i < parameters.size(); i++) {
ParameterWidgetSet widgets{};
GLSLParam &p = parameters[i];
ShaderParam &p = parameters[i];
TCHAR desc[270];
_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);
@ -351,7 +351,7 @@ void CShaderParamDlg::handle_up_down(HWND hStatic, int id, int change)
{
int param_id = id - IDC_PARAMS_START_UPDOWN;
HWND hEdit = GetDlgItem(hStatic, IDC_PARAMS_START_EDIT + param_id);
GLSLParam &p = parameters[param_id];
ShaderParam &p = parameters[param_id];
TCHAR val[100];
GetWindowText(hEdit, val, 100);
p.val = _ttof(val);
@ -371,7 +371,7 @@ void CShaderParamDlg::get_changed_parameters(HWND hDlg)
{
HWND parent = GetDlgItem(hDlg, IDC_STATIC_CONTAINER);
for(int i = 0; i < parameters.size(); i++) {
GLSLParam &p = parameters[i];
ShaderParam &p = parameters[i];
TCHAR val[100];
HWND hEdit = GetDlgItem(parent, IDC_PARAMS_START_EDIT + i);
GetWindowText(hEdit, val, 100);

View File

@ -6,7 +6,7 @@
#pragma once
#include "windows.h"
#include "../shaders/glsl.h"
#include "wsnes9x.h"
#include <functional>
typedef void(*APPLYCALLBACK) ();
@ -29,8 +29,8 @@ private:
unsigned int avgCharHeight;
unsigned int maxDescriptionWidth;
int scrollpos;
std::vector<GLSLParam>& parameters;
std::vector<GLSLParam> saved_parameters;
std::vector<ShaderParam>& parameters;
std::vector<ShaderParam> saved_parameters;
std::function<void (const char *)> save_function;
struct ParameterWidgetSet
@ -45,7 +45,7 @@ private:
WNDPROC oldStaticProc;
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();
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)
{
return &shaderchain->preset->parameters;
// SlangShader::Parameter currently equal ShaderParam, so no conversion is neccessary
return (std::vector<ShaderParam>*)&shaderchain->preset->parameters;
}
else
return nullptr;

View File

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

View File

@ -10,6 +10,7 @@
#include "render.h"
#include "wsnes9x.h"
#include <vector>
#include <functional>
/* IS9xDisplayOutput
Interface for display driver.
@ -27,6 +28,8 @@ public:
virtual bool SetFullscreen(bool fullscreen)=0;
virtual void SetSnes9xColorFormat()=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;
}
std::vector<GLSLParam> *WinGetShaderParameters()
std::vector<ShaderParam> *WinGetShaderParameters()
{
if (GUI.outputMethod == OPENGL)
return OpenGL.GetShaderParameters();
if (GUI.outputMethod == VULKAN)
return (std::vector<GLSLParam> *)VulkanDriver.GetShaderParameters();
return nullptr;
return S9xDisplayOutput->GetShaderParameters();
}
std::function<void(const char*)> WinGetShaderSaveFunction()
{
if (GUI.outputMethod == OPENGL)
return OpenGL.GetShaderParametersSaveFunction();
else if (GUI.outputMethod == VULKAN)
return VulkanDriver.GetShaderParametersSaveFunction();
else
return std::function<void(const char*)>();
return S9xDisplayOutput->GetShaderParametersSaveFunction();
}
/* Depth conversion functions begin */

View File

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

View File

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