Skip to content

Commit

Permalink
Merge pull request #5161 from RibShark/master
Browse files Browse the repository at this point in the history
Pass output dimensions to Direct3D shaders
  • Loading branch information
joncampbell123 authored Aug 9, 2024
2 parents ca2d626 + 503467c commit a0cb4d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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

0 comments on commit a0cb4d3

Please sign in to comment.