@@ -86,32 +86,22 @@ MetalSamplerCache::~MetalSamplerCache()
86
86
m_samplerCache.clear ();
87
87
}
88
88
89
- MTL::SamplerState* MetalSamplerCache::GetSamplerState (const LatteContextRegister& lcr, LatteConst::ShaderType shaderType, uint32 stageSamplerIndex)
89
+ MTL::SamplerState* MetalSamplerCache::GetSamplerState (const LatteContextRegister& lcr, LatteConst::ShaderType shaderType, uint32 stageSamplerIndex, const _LatteRegisterSetSampler* samplerWords )
90
90
{
91
- uint32 samplerIndex = stageSamplerIndex + LatteDecompiler_getTextureSamplerBaseIndex (shaderType);
92
-
93
- uint64 stateHash = CalculateSamplerHash (lcr, shaderType, stageSamplerIndex, samplerIndex);
91
+ uint64 stateHash = CalculateSamplerHash (lcr, shaderType, stageSamplerIndex, samplerWords);
94
92
auto & samplerState = m_samplerCache[stateHash];
95
93
if (samplerState)
96
94
return samplerState;
97
95
98
96
// Sampler state
99
- const _LatteRegisterSetSampler* samplerWords = lcr. SQ_TEX_SAMPLER + samplerIndex;
97
+
100
98
101
99
NS_STACK_SCOPED MTL::SamplerDescriptor* samplerDescriptor = MTL::SamplerDescriptor::alloc ()->init ();
102
100
103
101
// lod
104
102
uint32 iMinLOD = samplerWords->WORD1 .get_MIN_LOD ();
105
103
uint32 iMaxLOD = samplerWords->WORD1 .get_MAX_LOD ();
106
- sint32 iLodBias = samplerWords->WORD1 .get_LOD_BIAS ();
107
-
108
- // TODO: uncomment
109
- // apply relative lod bias from graphic pack
110
- // if (baseTexture->overwriteInfo.hasRelativeLodBias)
111
- // iLodBias += baseTexture->overwriteInfo.relativeLodBias;
112
- // apply absolute lod bias from graphic pack
113
- // if (baseTexture->overwriteInfo.hasLodBias)
114
- // iLodBias = baseTexture->overwriteInfo.lodBias;
104
+ // sint32 iLodBias = samplerWords->WORD1.get_LOD_BIAS();
115
105
116
106
auto filterMip = samplerWords->WORD0 .get_MIP_FILTER ();
117
107
if (filterMip == Latte::LATTE_SQ_TEX_SAMPLER_WORD0_0::E_Z_FILTER::NONE)
@@ -160,10 +150,6 @@ MTL::SamplerState* MetalSamplerCache::GetSamplerState(const LatteContextRegister
160
150
161
151
auto maxAniso = samplerWords->WORD0 .get_MAX_ANISO_RATIO ();
162
152
163
- // TODO: uncomment
164
- // if (baseTexture->overwriteInfo.anisotropicLevel >= 0)
165
- // maxAniso = baseTexture->overwriteInfo.anisotropicLevel;
166
-
167
153
if (maxAniso > 0 )
168
154
samplerDescriptor->setMaxAnisotropy (1 << maxAniso);
169
155
@@ -184,10 +170,8 @@ MTL::SamplerState* MetalSamplerCache::GetSamplerState(const LatteContextRegister
184
170
return samplerState;
185
171
}
186
172
187
- uint64 MetalSamplerCache::CalculateSamplerHash (const LatteContextRegister& lcr, LatteConst::ShaderType shaderType, uint32 stageSamplerIndex, uint32 samplerIndex )
173
+ uint64 MetalSamplerCache::CalculateSamplerHash (const LatteContextRegister& lcr, LatteConst::ShaderType shaderType, uint32 stageSamplerIndex, const _LatteRegisterSetSampler* samplerWords )
188
174
{
189
- const _LatteRegisterSetSampler* samplerWords = lcr.SQ_TEX_SAMPLER + samplerIndex;
190
-
191
175
uint64 hash = 0 ;
192
176
hash = std::rotl<uint64>(hash, 17 );
193
177
hash += (uint64)samplerWords->WORD0 .getRawValue ();
0 commit comments