gsdx-d3d11: Store shader resource textures on GSDevice11

This commit is contained in:
Kojin 2018-12-15 13:44:45 -05:00 committed by lightningterror
parent a743707728
commit 1427d55b08
2 changed files with 11 additions and 9 deletions

View File

@ -1181,7 +1181,7 @@ void GSDevice11::PSSetShaderResources(GSTexture* sr0, GSTexture* sr1)
PSSetShaderResource(0, sr0); PSSetShaderResource(0, sr0);
PSSetShaderResource(1, sr1); PSSetShaderResource(1, sr1);
for(size_t i = 2; i < countof(m_state.ps_srv); i++) for(size_t i = 2; i < m_state.ps_sr_views.size(); i++)
{ {
PSSetShaderResource(i, NULL); PSSetShaderResource(i, NULL);
} }
@ -1193,16 +1193,17 @@ void GSDevice11::PSSetShaderResource(int i, GSTexture* sr)
if(sr) srv = *(GSTexture11*)sr; if(sr) srv = *(GSTexture11*)sr;
PSSetShaderResourceView(i, srv); PSSetShaderResourceView(i, srv, sr);
} }
void GSDevice11::PSSetShaderResourceView(int i, ID3D11ShaderResourceView* srv) void GSDevice11::PSSetShaderResourceView(int i, ID3D11ShaderResourceView* srv, GSTexture* sr)
{ {
ASSERT(i < countof(m_state.ps_srv)); ASSERT(i < m_state.ps_sr_views.size());
if(m_state.ps_srv[i] != srv) if(m_state.ps_sr_views[i] != srv)
{ {
m_state.ps_srv[i] = srv; m_state.ps_sr_views[i] = srv;
m_state.ps_sr_texture[i] = (GSTexture11*)sr;
m_srv_changed = true; m_srv_changed = true;
} }
@ -1231,7 +1232,7 @@ void GSDevice11::PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb)
if(m_srv_changed) if(m_srv_changed)
{ {
m_ctx->PSSetShaderResources(0, countof(m_state.ps_srv), m_state.ps_srv); m_ctx->PSSetShaderResources(0, m_state.ps_sr_views.size(), m_state.ps_sr_views.data());
m_srv_changed = false; m_srv_changed = false;
} }

View File

@ -69,7 +69,8 @@ class GSDevice11 : public GSDeviceDX
ID3D11Buffer* vs_cb; ID3D11Buffer* vs_cb;
ID3D11GeometryShader* gs; ID3D11GeometryShader* gs;
ID3D11Buffer* gs_cb; ID3D11Buffer* gs_cb;
ID3D11ShaderResourceView* ps_srv[16]; std::array<ID3D11ShaderResourceView*, 16> ps_sr_views;
std::array<GSTexture11*, 16> ps_sr_texture;
ID3D11PixelShader* ps; ID3D11PixelShader* ps;
ID3D11Buffer* ps_cb; ID3D11Buffer* ps_cb;
ID3D11SamplerState* ps_ss[3]; ID3D11SamplerState* ps_ss[3];
@ -209,7 +210,7 @@ public:
void GSSetShader(ID3D11GeometryShader* gs, ID3D11Buffer* gs_cb = NULL); void GSSetShader(ID3D11GeometryShader* gs, ID3D11Buffer* gs_cb = NULL);
void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1); void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1);
void PSSetShaderResource(int i, GSTexture* sr); void PSSetShaderResource(int i, GSTexture* sr);
void PSSetShaderResourceView(int i, ID3D11ShaderResourceView* srv); void PSSetShaderResourceView(int i, ID3D11ShaderResourceView* srv, GSTexture* sr);
void PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb); void PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb);
void PSSetSamplerState(ID3D11SamplerState* ss0, ID3D11SamplerState* ss1, ID3D11SamplerState* ss2 = NULL); void PSSetSamplerState(ID3D11SamplerState* ss0, ID3D11SamplerState* ss1, ID3D11SamplerState* ss2 = NULL);
void OMSetDepthStencilState(ID3D11DepthStencilState* dss, uint8 sref); void OMSetDepthStencilState(ID3D11DepthStencilState* dss, uint8 sref);