Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass output dimensions to Direct3D shaders #5161

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/output/direct3d/ScalingEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
ScalingEffect::ScalingEffect(LPDIRECT3DDEVICE9 pd3dDevice) :
m_scale(0.0f), m_forceupdate(false), m_pd3dDevice(pd3dDevice), m_pEffect(0)
{
m_iDim[0] = m_iDim[1] = 256.0f; // Some sane default
m_iDim[0] = m_iDim[1] = m_oDim[0] = m_oDim[1] = 256.0f; // Some sane default
m_strName = "Unnamed";
KillThis();
}
Expand Down Expand Up @@ -195,6 +195,12 @@ HRESULT ScalingEffect::ParseParameters(LPD3DXEFFECTCOMPILER lpEffectCompiler)
return hr;
}
}
else if(strcmpi(ParamDesc.Semantic, "outputdims") == 0) {
if(m_oDim[0] && m_oDim[1] && ((hr = m_pEffect->SetFloatArray(hParam, m_oDim, 2)) != D3D_OK)) {
m_strErrors += "Could not set outputdims parameter!";
return hr;
}
}
}

else if(ParamDesc.Class == D3DXPC_SCALAR && ParamDesc.Type == D3DXPT_FLOAT) {
Expand Down
2 changes: 2 additions & 0 deletions src/output/direct3d/ScalingEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ScalingEffect
{
float m_scale;
float m_iDim[2];
float m_oDim[2];
BOOL m_forceupdate;
LPCSTR m_strName;
std::string m_strErrors;
Expand Down Expand Up @@ -73,6 +74,7 @@ class ScalingEffect
float getScale() { return m_scale; }
bool getForceUpdate() { return m_forceupdate != FALSE; }
void setinputDim(float w, float h) { m_iDim[0] = w; m_iDim[1] = h; }
void setoutputDim(float w, float h) { m_oDim[0] = w; m_oDim[1] = h; }

// Does it have a preprocess step
BOOL hasPreprocess() { return m_PreprocessTechnique1EffectHandle!=0; }
Expand Down
1 change: 1 addition & 0 deletions src/output/direct3d/direct3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ HRESULT CDirect3D::LoadPixelShader(void)
#endif

psEffect->setinputDim((float)dwWidth, (float)dwHeight);
psEffect->setoutputDim((float)dwScaledWidth, (float)dwScaledHeight);
if(FAILED(psEffect->LoadEffect(shader_translate_directory(pshader).c_str())) || FAILED(psEffect->Validate())) {
LOG_MSG("D3D:Pixel shader error:");

Expand Down
Loading