@@ -10,7 +10,6 @@ dx10SamplerStateCache::dx10SamplerStateCache() : m_uiMaxAnisotropy(1)
1010{
1111 static const int iMaxRSStates = 10 ;
1212 m_StateArray.reserve (iMaxRSStates);
13- ResetDeviceState ();
1413}
1514
1615dx10SamplerStateCache::~dx10SamplerStateCache () { ClearStateArray (); }
@@ -85,12 +84,8 @@ void dx10SamplerStateCache::ClearStateArray()
8584}
8685
8786void dx10SamplerStateCache::PrepareSamplerStates (HArray& samplers,
88- ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT],
89- SHandle pCurrentState[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT], u32 & uiMin, u32 & uiMax) const
87+ ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT]) const
9088{
91- // It seems that sizeof pSS is 4 wor win32!
92- ZeroMemory (pSS, sizeof (pSS[0 ]) * D3D_COMMONSHADER_SAMPLER_SLOT_COUNT);
93-
9489 for (u32 i = 0 ; i < samplers.size (); ++i)
9590 {
9691 if (samplers[i] != hInvalidHandle)
@@ -99,64 +94,49 @@ void dx10SamplerStateCache::PrepareSamplerStates(HArray& samplers,
9994 pSS[i] = m_StateArray[samplers[i]].m_pState ;
10095 }
10196 }
102-
103- uiMin = 0 ;
104- uiMax = D3D_COMMONSHADER_SAMPLER_SLOT_COUNT - 1 ;
10597}
10698
10799void dx10SamplerStateCache::VSApplySamplers (HArray& samplers)
108100{
109- ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT];
110- u32 uiMin;
111- u32 uiMax;
112- PrepareSamplerStates (samplers, pSS, m_aVSSamplers, uiMin, uiMax);
113- HW.pContext ->VSSetSamplers (uiMin, uiMax - uiMin + 1 , &pSS[uiMin]);
101+ ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr };
102+ PrepareSamplerStates (samplers, pSS);
103+ HW.pContext ->VSSetSamplers (0 , D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS);
114104}
115105
116106void dx10SamplerStateCache::PSApplySamplers (HArray& samplers)
117107{
118- ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT];
119- u32 uiMin;
120- u32 uiMax;
121- PrepareSamplerStates (samplers, pSS, m_aPSSamplers, uiMin, uiMax);
122- HW.pContext ->PSSetSamplers (uiMin, uiMax - uiMin + 1 , &pSS[uiMin]);
108+ ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr };
109+ PrepareSamplerStates (samplers, pSS);
110+ HW.pContext ->PSSetSamplers (0 , D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS);
123111}
124112
125113void dx10SamplerStateCache::GSApplySamplers (HArray& samplers)
126114{
127- ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT];
128- u32 uiMin;
129- u32 uiMax;
130- PrepareSamplerStates (samplers, pSS, m_aGSSamplers, uiMin, uiMax);
131- HW.pContext ->GSSetSamplers (uiMin, uiMax - uiMin + 1 , &pSS[uiMin]);
115+ ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr };
116+ PrepareSamplerStates (samplers, pSS);
117+ HW.pContext ->GSSetSamplers (0 , D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS);
132118}
133119
134120#ifdef USE_DX11
135121void dx10SamplerStateCache::HSApplySamplers (HArray& samplers)
136122{
137- ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT];
138- u32 uiMin;
139- u32 uiMax;
140- PrepareSamplerStates (samplers, pSS, m_aHSSamplers, uiMin, uiMax);
141- HW.pContext ->HSSetSamplers (uiMin, uiMax - uiMin + 1 , &pSS[uiMin]);
123+ ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr };
124+ PrepareSamplerStates (samplers, pSS);
125+ HW.pContext ->HSSetSamplers (0 , D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS);
142126}
143127
144128void dx10SamplerStateCache::DSApplySamplers (HArray& samplers)
145129{
146- ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT];
147- u32 uiMin;
148- u32 uiMax;
149- PrepareSamplerStates (samplers, pSS, m_aDSSamplers, uiMin, uiMax);
150- HW.pContext ->DSSetSamplers (uiMin, uiMax - uiMin + 1 , &pSS[uiMin]);
130+ ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr };
131+ PrepareSamplerStates (samplers, pSS);
132+ HW.pContext ->DSSetSamplers (0 , D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS);
151133}
152134
153135void dx10SamplerStateCache::CSApplySamplers (HArray& samplers)
154136{
155- ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT];
156- u32 uiMin;
157- u32 uiMax;
158- PrepareSamplerStates (samplers, pSS, m_aCSSamplers, uiMin, uiMax);
159- HW.pContext ->CSSetSamplers (uiMin, uiMax - uiMin + 1 , &pSS[uiMin]);
137+ ID3DSamplerState* pSS[D3D_COMMONSHADER_SAMPLER_SLOT_COUNT] = { nullptr };
138+ PrepareSamplerStates (samplers, pSS);
139+ HW.pContext ->CSSetSamplers (0 , D3D_COMMONSHADER_SAMPLER_SLOT_COUNT, pSS);
160140}
161141#endif
162142
@@ -188,18 +168,3 @@ void dx10SamplerStateCache::SetMaxAnisotropy(UINT uiMaxAniso)
188168 CreateState (desc, &rec.m_pState );
189169 }
190170}
191-
192- void dx10SamplerStateCache::ResetDeviceState ()
193- {
194- for (int i = 0 ; i < sizeof (m_aPSSamplers) / sizeof (m_aPSSamplers[0 ]); ++i)
195- {
196- m_aPSSamplers[i] = (SHandle)hInvalidHandle;
197- m_aVSSamplers[i] = (SHandle)hInvalidHandle;
198- m_aGSSamplers[i] = (SHandle)hInvalidHandle;
199- #ifdef USE_DX11
200- m_aHSSamplers[i] = (SHandle)hInvalidHandle;
201- m_aDSSamplers[i] = (SHandle)hInvalidHandle;
202- m_aCSSamplers[i] = (SHandle)hInvalidHandle;
203- #endif
204- }
205- }
0 commit comments