GS/DX11: Don't bind 16 SRVs every draw

That's just silly.
This commit is contained in:
Connor McLaughlin 2022-01-30 22:39:39 +10:00 committed by refractionpcsx2
parent 0a45385d48
commit dbc176fe25
2 changed files with 10 additions and 32 deletions

View File

@ -1074,41 +1074,18 @@ void GSDevice11::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1)
{
PSSetShaderResource(0, sr0);
PSSetShaderResource(1, sr1);
for (size_t i = 2; i < m_state.ps_sr_views.size(); i++)
{
PSSetShaderResource(i, nullptr);
}
PSSetShaderResource(2, nullptr);
}
void GSDevice11::PSSetShaderResource(int i, GSTexture* sr)
{
ID3D11ShaderResourceView* srv = nullptr;
if (sr)
srv = *(GSTexture11*)sr;
PSSetShaderResourceView(i, srv, sr);
}
void GSDevice11::PSSetShaderResourceView(int i, ID3D11ShaderResourceView* srv, GSTexture* sr)
{
ASSERT(i < (int)m_state.ps_sr_views.size());
if (m_state.ps_sr_views[i] != srv)
{
m_state.ps_sr_views[i] = srv;
m_state.ps_sr_texture[i] = (GSTexture11*)sr;
}
m_state.ps_sr_views[i] = sr ? static_cast<ID3D11ShaderResourceView*>(*static_cast<GSTexture11*>(sr)) : nullptr;
}
void GSDevice11::PSSetSamplerState(ID3D11SamplerState* ss0, ID3D11SamplerState* ss1)
{
if (m_state.ps_ss[0] != ss0 || m_state.ps_ss[1] != ss1)
{
m_state.ps_ss[0] = ss0;
m_state.ps_ss[1] = ss1;
}
m_state.ps_ss[0] = ss0;
m_state.ps_ss[1] = ss1;
}
void GSDevice11::PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb)
@ -1131,7 +1108,7 @@ void GSDevice11::PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb)
void GSDevice11::PSUpdateShaderState()
{
m_ctx->PSSetShaderResources(0, m_state.ps_sr_views.size(), m_state.ps_sr_views.data());
m_ctx->PSSetSamplers(0, std::size(m_state.ps_ss), m_state.ps_ss);
m_ctx->PSSetSamplers(0, m_state.ps_ss.size(), m_state.ps_ss.data());
}
void GSDevice11::OMSetDepthStencilState(ID3D11DepthStencilState* dss, u8 sref)

View File

@ -111,6 +111,9 @@ private:
// Increment this constant whenever shaders change, to invalidate user's shader cache.
static constexpr u32 SHADER_VERSION = 1;
static constexpr u32 MAX_TEXTURES = 3;
static constexpr u32 MAX_SAMPLERS = 2;
float m_hack_topleft_offset;
int m_d3d_texsize;
@ -141,11 +144,10 @@ private:
ID3D11Buffer* vs_cb;
ID3D11GeometryShader* gs;
ID3D11Buffer* gs_cb;
std::array<ID3D11ShaderResourceView*, 16> ps_sr_views;
std::array<GSTexture11*, 16> ps_sr_texture;
std::array<ID3D11ShaderResourceView*, MAX_TEXTURES> ps_sr_views;
ID3D11PixelShader* ps;
ID3D11Buffer* ps_cb;
ID3D11SamplerState* ps_ss[3];
std::array<ID3D11SamplerState*, MAX_SAMPLERS> ps_ss;
GSVector2i viewport;
GSVector4i scissor;
ID3D11DepthStencilState* dss;
@ -276,7 +278,6 @@ public:
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
void PSSetShaderResource(int i, GSTexture* sr);
void PSSetShaderResourceView(int i, ID3D11ShaderResourceView* srv, GSTexture* sr);
void PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb);
void PSUpdateShaderState();
void PSSetSamplerState(ID3D11SamplerState* ss0, ID3D11SamplerState* ss1);