No type inference when calling std::rotl and std::rotr.

This commit is contained in:
Tom Lally 2022-09-01 19:01:47 +01:00
parent 53e3ed946e
commit e2eedc7b2c
11 changed files with 54 additions and 54 deletions

View file

@ -81,31 +81,31 @@ void LatteShader_calculateFSKey(LatteFetchShader* fetchShader)
{ {
LatteParsedFetchShaderAttribute_t* attrib = group.attrib + f; LatteParsedFetchShaderAttribute_t* attrib = group.attrib + f;
key += (uint64)attrib->endianSwap; key += (uint64)attrib->endianSwap;
key = std::rotl(key, 3); key = std::rotl<uint64>(key, 3);
key += (uint64)attrib->nfa; key += (uint64)attrib->nfa;
key = std::rotl(key, 3); key = std::rotl<uint64>(key, 3);
key += (uint64)(attrib->isSigned?1:0); key += (uint64)(attrib->isSigned?1:0);
key = std::rotl(key, 1); key = std::rotl<uint64>(key, 1);
key += (uint64)attrib->format; key += (uint64)attrib->format;
key = std::rotl(key, 7); key = std::rotl<uint64>(key, 7);
key += (uint64)attrib->fetchType; key += (uint64)attrib->fetchType;
key = std::rotl(key, 8); key = std::rotl<uint64>(key, 8);
key += (uint64)attrib->ds[0]; key += (uint64)attrib->ds[0];
key = std::rotl(key, 2); key = std::rotl<uint64>(key, 2);
key += (uint64)attrib->ds[1]; key += (uint64)attrib->ds[1];
key = std::rotl(key, 2); key = std::rotl<uint64>(key, 2);
key += (uint64)attrib->ds[2]; key += (uint64)attrib->ds[2];
key = std::rotl(key, 2); key = std::rotl<uint64>(key, 2);
key += (uint64)attrib->ds[3]; key += (uint64)attrib->ds[3];
key = std::rotl(key, 2); key = std::rotl<uint64>(key, 2);
key += (uint64)(attrib->aluDivisor+1); key += (uint64)(attrib->aluDivisor+1);
key = std::rotl(key, 2); key = std::rotl<uint64>(key, 2);
key += (uint64)attrib->attributeBufferIndex; key += (uint64)attrib->attributeBufferIndex;
key = std::rotl(key, 8); key = std::rotl<uint64>(key, 8);
key += (uint64)attrib->semanticId; key += (uint64)attrib->semanticId;
key = std::rotl(key, 8); key = std::rotl<uint64>(key, 8);
key += (uint64)(attrib->offset & 3); key += (uint64)(attrib->offset & 3);
key = std::rotl(key, 2); key = std::rotl<uint64>(key, 2);
} }
} }
// todo - also hash invalid buffer groups? // todo - also hash invalid buffer groups?

View file

@ -743,7 +743,7 @@ private:
//h ^= *memU64; //h ^= *memU64;
//memU64++; //memU64++;
h = std::rotr(h, 7); h = std::rotr<uint64>(h, 7);
h += (*memU64 + (uint64)i); h += (*memU64 + (uint64)i);
memU64++; memU64++;
} }

View file

@ -158,15 +158,15 @@ void LatteMRT::ApplyCurrentState()
if (colorView) if (colorView)
{ {
key += ((uint64)colorView); key += ((uint64)colorView);
key = std::rotl(key, 5); key = std::rotl<uint64>(key, 5);
fboLookupView = colorView; fboLookupView = colorView;
} }
key = std::rotl(key, 7); key = std::rotl<uint64>(key, 7);
} }
if (sLatteCurrentRendertargets.depthBuffer.view) if (sLatteCurrentRendertargets.depthBuffer.view)
{ {
key += ((uint64)sLatteCurrentRendertargets.depthBuffer.view); key += ((uint64)sLatteCurrentRendertargets.depthBuffer.view);
key = std::rotl(key, 5); key = std::rotl<uint64>(key, 5);
key += (sLatteCurrentRendertargets.depthBuffer.hasStencil); key += (sLatteCurrentRendertargets.depthBuffer.hasStencil);
if (fboLookupView == NULL) if (fboLookupView == NULL)
{ {

View file

@ -263,7 +263,7 @@ void LatteShader_UpdatePSInputs(uint32* contextRegisters)
cemu_assert_debug(psSemanticId != 0xFF); cemu_assert_debug(psSemanticId != 0xFF);
key += (uint64)psInputControl; key += (uint64)psInputControl;
key = std::rotl(key, 7); key = std::rotl<uint64>(key, 7);
if (spi0_positionEnable && f == spi0_positionAddr) if (spi0_positionEnable && f == spi0_positionAddr)
{ {
_activePSImportTable.import[f].semanticId = LATTE_ANALYZER_IMPORT_INDEX_SPIPOSITION; _activePSImportTable.import[f].semanticId = LATTE_ANALYZER_IMPORT_INDEX_SPIPOSITION;
@ -546,7 +546,7 @@ uint64 LatteSHRC_CalcVSAuxHash(LatteDecompilerShader* vertexShader, uint32* cont
if(!vertexShader->streamoutBufferWriteMask2[i]) if(!vertexShader->streamoutBufferWriteMask2[i])
continue; continue;
uint32 bufferStride = contextRegisters[mmVGT_STRMOUT_VTX_STRIDE_0 + i * 4]; uint32 bufferStride = contextRegisters[mmVGT_STRMOUT_VTX_STRIDE_0 + i * 4];
auxHash = std::rotl(auxHash, 7); auxHash = std::rotl<uint64>(auxHash, 7);
auxHash += (uint64)bufferStride; auxHash += (uint64)bufferStride;
} }
} }
@ -559,7 +559,7 @@ uint64 LatteSHRC_CalcVSAuxHash(LatteDecompilerShader* vertexShader, uint32* cont
if ((word4 & 0x300) == 0x100) if ((word4 & 0x300) == 0x100)
{ {
// integer format // integer format
auxHashTex = std::rotl(auxHashTex, 7); auxHashTex = std::rotl<uint64>(auxHashTex, 7);
auxHashTex += 0x333; auxHashTex += 0x333;
} }
} }

View file

@ -44,9 +44,9 @@ void OpenGLRenderer::uniformData_update()
for (sint32 f = 0; f < remappedArraySize; f++) for (sint32 f = 0; f < remappedArraySize; f++)
{ {
uniformDataHash[0] ^= remappedUniformData64[0]; uniformDataHash[0] ^= remappedUniformData64[0];
uniformDataHash[0] = std::rotl(uniformDataHash[0], 11); uniformDataHash[0] = std::rotl<uint64>(uniformDataHash[0], 11);
uniformDataHash[1] ^= remappedUniformData64[1]; uniformDataHash[1] ^= remappedUniformData64[1];
uniformDataHash[1] = std::rotl(uniformDataHash[1], 11); uniformDataHash[1] = std::rotl<uint64>(uniformDataHash[1], 11);
remappedUniformData64 += 2; remappedUniformData64 += 2;
} }
if (shader->uniformDataHash64[0] != uniformDataHash[0] || shader->uniformDataHash64[1] != uniformDataHash[1]) if (shader->uniformDataHash64[0] != uniformDataHash[0] || shader->uniformDataHash64[1] != uniformDataHash[1])

View file

@ -8,7 +8,7 @@ uint32 RendererShader::GeneratePrecompiledCacheId()
const char* s = EMULATOR_VERSION_SUFFIX; const char* s = EMULATOR_VERSION_SUFFIX;
while (*s) while (*s)
{ {
v = std::rotl(v, 7); v = std::rotl<uint32>(v, 7);
v += (uint32)(*s); v += (uint32)(*s);
s++; s++;
} }

View file

@ -4050,13 +4050,13 @@ VKRObjectRenderPass::VKRObjectRenderPass(AttachmentInfo_t& attachmentInfo, sint3
if (attachmentInfo.colorAttachment[i].isPresent || attachmentInfo.colorAttachment[i].viewObj) if (attachmentInfo.colorAttachment[i].isPresent || attachmentInfo.colorAttachment[i].viewObj)
{ {
stateHash += attachmentInfo.colorAttachment[i].format + i * 31; stateHash += attachmentInfo.colorAttachment[i].format + i * 31;
stateHash = std::rotl(stateHash, 7); stateHash = std::rotl<uint64>(stateHash, 7);
} }
} }
if (attachmentInfo.depthAttachment.isPresent || attachmentInfo.depthAttachment.viewObj) if (attachmentInfo.depthAttachment.isPresent || attachmentInfo.depthAttachment.viewObj)
{ {
stateHash += attachmentInfo.depthAttachment.format; stateHash += attachmentInfo.depthAttachment.format;
stateHash = std::rotl(stateHash, 7); stateHash = std::rotl<uint64>(stateHash, 7);
} }
m_hashForPipeline = stateHash; m_hashForPipeline = stateHash;

View file

@ -24,18 +24,18 @@ uint64 VulkanRenderer::draw_calculateMinimalGraphicsPipelineHash(const LatteFetc
for (auto& group : fetchShader->bufferGroups) for (auto& group : fetchShader->bufferGroups)
{ {
uint32 bufferStride = group.getCurrentBufferStride(lcr.GetRawView()); uint32 bufferStride = group.getCurrentBufferStride(lcr.GetRawView());
stateHash = std::rotl(stateHash, 7); stateHash = std::rotl<uint64>(stateHash, 7);
stateHash += bufferStride * 3; stateHash += bufferStride * 3;
} }
stateHash += fetchShader->getVkPipelineHashFragment(); stateHash += fetchShader->getVkPipelineHashFragment();
stateHash = std::rotl(stateHash, 7); stateHash = std::rotl<uint64>(stateHash, 7);
stateHash += lcr.GetRawView()[mmVGT_PRIMITIVE_TYPE]; stateHash += lcr.GetRawView()[mmVGT_PRIMITIVE_TYPE];
stateHash = std::rotl(stateHash, 7); stateHash = std::rotl<uint64>(stateHash, 7);
stateHash += lcr.GetRawView()[mmVGT_STRMOUT_EN]; stateHash += lcr.GetRawView()[mmVGT_STRMOUT_EN];
stateHash = std::rotl(stateHash, 7); stateHash = std::rotl<uint64>(stateHash, 7);
if(lcr.PA_CL_CLIP_CNTL.get_DX_RASTERIZATION_KILL()) if(lcr.PA_CL_CLIP_CNTL.get_DX_RASTERIZATION_KILL())
stateHash += 0x333333; stateHash += 0x333333;
@ -66,24 +66,24 @@ uint64 VulkanRenderer::draw_calculateGraphicsPipelineHash(const LatteFetchShader
if (vertexShader) if (vertexShader)
stateHash += vertexShader->baseHash; stateHash += vertexShader->baseHash;
stateHash = std::rotl(stateHash, 13); stateHash = std::rotl<uint64>(stateHash, 13);
if (geometryShader) if (geometryShader)
stateHash += geometryShader->baseHash; stateHash += geometryShader->baseHash;
stateHash = std::rotl(stateHash, 13); stateHash = std::rotl<uint64>(stateHash, 13);
if (pixelShader) if (pixelShader)
stateHash += pixelShader->baseHash + pixelShader->auxHash; stateHash += pixelShader->baseHash + pixelShader->auxHash;
stateHash = std::rotl(stateHash, 13); stateHash = std::rotl<uint64>(stateHash, 13);
uint32 polygonCtrl = lcr.PA_SU_SC_MODE_CNTL.getRawValue(); uint32 polygonCtrl = lcr.PA_SU_SC_MODE_CNTL.getRawValue();
stateHash += polygonCtrl; stateHash += polygonCtrl;
stateHash = std::rotl(stateHash, 7); stateHash = std::rotl<uint64>(stateHash, 7);
stateHash += ctxRegister[Latte::REGADDR::PA_CL_CLIP_CNTL]; stateHash += ctxRegister[Latte::REGADDR::PA_CL_CLIP_CNTL];
stateHash = std::rotl(stateHash, 7); stateHash = std::rotl<uint64>(stateHash, 7);
const auto colorControlReg = ctxRegister[Latte::REGADDR::CB_COLOR_CONTROL]; const auto colorControlReg = ctxRegister[Latte::REGADDR::CB_COLOR_CONTROL];
stateHash += colorControlReg; stateHash += colorControlReg;
@ -97,7 +97,7 @@ uint64 VulkanRenderer::draw_calculateGraphicsPipelineHash(const LatteFetchShader
{ {
if (((blendEnableMask & (1 << i))) == 0) if (((blendEnableMask & (1 << i))) == 0)
continue; continue;
stateHash = std::rotl(stateHash, 7); stateHash = std::rotl<uint64>(stateHash, 7);
stateHash += ctxRegister[Latte::REGADDR::CB_BLEND0_CONTROL + i]; stateHash += ctxRegister[Latte::REGADDR::CB_BLEND0_CONTROL + i];
} }
} }
@ -109,11 +109,11 @@ uint64 VulkanRenderer::draw_calculateGraphicsPipelineHash(const LatteFetchShader
if (stencilTestEnable) if (stencilTestEnable)
{ {
stateHash += ctxRegister[mmDB_STENCILREFMASK]; stateHash += ctxRegister[mmDB_STENCILREFMASK];
stateHash = std::rotl(stateHash, 17); stateHash = std::rotl<uint64>(stateHash, 17);
if(depthControl & (1<<7)) // back stencil enable if(depthControl & (1<<7)) // back stencil enable
{ {
stateHash += ctxRegister[mmDB_STENCILREFMASK_BF]; stateHash += ctxRegister[mmDB_STENCILREFMASK_BF];
stateHash = std::rotl(stateHash, 13); stateHash = std::rotl<uint64>(stateHash, 13);
} }
} }
else else
@ -122,7 +122,7 @@ uint64 VulkanRenderer::draw_calculateGraphicsPipelineHash(const LatteFetchShader
depthControl &= 0xFF; depthControl &= 0xFF;
} }
stateHash = std::rotl(stateHash, 17); stateHash = std::rotl<uint64>(stateHash, 17);
stateHash += depthControl; stateHash += depthControl;
// polygon offset // polygon offset
@ -542,16 +542,16 @@ uint64 VulkanRenderer::GetDescriptorSetStateHash(LatteDecompilerShader* shader)
{ {
samplerIndex += LatteDecompiler_getTextureSamplerBaseIndex(shader->shaderType); samplerIndex += LatteDecompiler_getTextureSamplerBaseIndex(shader->shaderType);
hash += LatteGPUState.contextRegister[Latte::REGADDR::SQ_TEX_SAMPLER_WORD0_0 + samplerIndex * 3 + 0]; hash += LatteGPUState.contextRegister[Latte::REGADDR::SQ_TEX_SAMPLER_WORD0_0 + samplerIndex * 3 + 0];
hash = std::rotl(hash, 7); hash = std::rotl<uint64>(hash, 7);
hash += LatteGPUState.contextRegister[Latte::REGADDR::SQ_TEX_SAMPLER_WORD0_0 + samplerIndex * 3 + 1]; hash += LatteGPUState.contextRegister[Latte::REGADDR::SQ_TEX_SAMPLER_WORD0_0 + samplerIndex * 3 + 1];
hash = std::rotl(hash, 7); hash = std::rotl<uint64>(hash, 7);
hash += LatteGPUState.contextRegister[Latte::REGADDR::SQ_TEX_SAMPLER_WORD0_0 + samplerIndex * 3 + 2]; hash += LatteGPUState.contextRegister[Latte::REGADDR::SQ_TEX_SAMPLER_WORD0_0 + samplerIndex * 3 + 2];
hash = std::rotl(hash, 7); hash = std::rotl<uint64>(hash, 7);
} }
hash = std::rotl(hash, 7); hash = std::rotl<uint64>(hash, 7);
// hash view id + swizzle mask // hash view id + swizzle mask
hash += (uint64)texture->GetUniqueId(); hash += (uint64)texture->GetUniqueId();
hash = std::rotr(hash, 21); hash = std::rotr<uint64>(hash, 21);
hash += (uint64)(word4 & 0x0FFF0000); hash += (uint64)(word4 & 0x0FFF0000);
} }

View file

@ -108,12 +108,12 @@ uint64 VulkanRenderer::copySurface_getPipelineStateHash(VkCopySurfaceState_t& st
uint64 h = 0; uint64 h = 0;
h += (uintptr_t)state.destinationTexture->GetFormat(); h += (uintptr_t)state.destinationTexture->GetFormat();
h = std::rotr(h, 7); h = std::rotr<uint64>(h, 7);
h += state.sourceTexture->isDepth ? 0x1111ull : 0; h += state.sourceTexture->isDepth ? 0x1111ull : 0;
h = std::rotr(h, 7); h = std::rotr<uint64>(h, 7);
h += state.destinationTexture->isDepth ? 0x1112ull : 0; h += state.destinationTexture->isDepth ? 0x1112ull : 0;
h = std::rotr(h, 7); h = std::rotr<uint64>(h, 7);
return h; return h;
} }

View file

@ -713,8 +713,8 @@ void _calculateMappedImportNameHash(const char* rplName, const char* funcName, u
uint64 v = (uint64)*rplName; uint64 v = (uint64)*rplName;
h1 += v; h1 += v;
h2 ^= v; h2 ^= v;
h1 = std::rotl(h1, 3); h1 = std::rotl<uint64>(h1, 3);
h2 = std::rotl(h2, 7); h2 = std::rotl<uint64>(h2, 7);
rplName++; rplName++;
} }
// funcName // funcName
@ -723,8 +723,8 @@ void _calculateMappedImportNameHash(const char* rplName, const char* funcName, u
uint64 v = (uint64)*funcName; uint64 v = (uint64)*funcName;
h1 += v; h1 += v;
h2 ^= v; h2 ^= v;
h1 = std::rotl(h1, 3); h1 = std::rotl<uint64>(h1, 3);
h2 = std::rotl(h2, 7); h2 = std::rotl<uint64>(h2, 7);
funcName++; funcName++;
} }
*h1Out = h1; *h1Out = h1;

View file

@ -332,25 +332,25 @@ void InvMixColumns(aes128Ctx_t* aesCtx)
b = stateVal(0, 1); b = stateVal(0, 1);
c = stateVal(0, 2); c = stateVal(0, 2);
d = stateVal(0, 3); d = stateVal(0, 3);
stateValU32(0) = lookupTable_multiply[a] ^ std::rotl(lookupTable_multiply[b], 8) ^ std::rotl(lookupTable_multiply[c], 16) ^ std::rotl(lookupTable_multiply[d], 24); stateValU32(0) = lookupTable_multiply[a] ^ std::rotl<uint32>(lookupTable_multiply[b], 8) ^ std::rotl<uint32>(lookupTable_multiply[c], 16) ^ std::rotl<uint32>(lookupTable_multiply[d], 24);
// i1 // i1
a = stateVal(1, 0); a = stateVal(1, 0);
b = stateVal(1, 1); b = stateVal(1, 1);
c = stateVal(1, 2); c = stateVal(1, 2);
d = stateVal(1, 3); d = stateVal(1, 3);
stateValU32(1) = lookupTable_multiply[a] ^ std::rotl(lookupTable_multiply[b], 8) ^ std::rotl(lookupTable_multiply[c], 16) ^ std::rotl(lookupTable_multiply[d], 24); stateValU32(1) = lookupTable_multiply[a] ^ std::rotl<uint32>(lookupTable_multiply[b], 8) ^ std::rotl<uint32>(lookupTable_multiply[c], 16) ^ std::rotl<uint32>(lookupTable_multiply[d], 24);
// i2 // i2
a = stateVal(2, 0); a = stateVal(2, 0);
b = stateVal(2, 1); b = stateVal(2, 1);
c = stateVal(2, 2); c = stateVal(2, 2);
d = stateVal(2, 3); d = stateVal(2, 3);
stateValU32(2) = lookupTable_multiply[a] ^ std::rotl(lookupTable_multiply[b], 8) ^ std::rotl(lookupTable_multiply[c], 16) ^ std::rotl(lookupTable_multiply[d], 24); stateValU32(2) = lookupTable_multiply[a] ^ std::rotl<uint32>(lookupTable_multiply[b], 8) ^ std::rotl<uint32>(lookupTable_multiply[c], 16) ^ std::rotl<uint32>(lookupTable_multiply[d], 24);
// i3 // i3
a = stateVal(3, 0); a = stateVal(3, 0);
b = stateVal(3, 1); b = stateVal(3, 1);
c = stateVal(3, 2); c = stateVal(3, 2);
d = stateVal(3, 3); d = stateVal(3, 3);
stateValU32(3) = lookupTable_multiply[a] ^ std::rotl(lookupTable_multiply[b], 8) ^ std::rotl(lookupTable_multiply[c], 16) ^ std::rotl(lookupTable_multiply[d], 24); stateValU32(3) = lookupTable_multiply[a] ^ std::rotl<uint32>(lookupTable_multiply[b], 8) ^ std::rotl<uint32>(lookupTable_multiply[c], 16) ^ std::rotl<uint32>(lookupTable_multiply[d], 24);
} }
// The SubBytes Function Substitutes the values in the // The SubBytes Function Substitutes the values in the