protonscr

DxvkShaderKey is incorrect when stream-out is used

dxvkclosed bug
doitsujin/dxvk#733 · opened 2018-10-25 by AnzhongHuang · updated 2018-10-26 · 5 comments · github
AAnzhongHuang 2018-10-25 github

There is a scenario when create two GS shaders with the same dxasm code, but with different DxbcXfbInfo. The two GS should be considered as different shader, because they will generate two different spirv or hardware shaders.
But now in D3D11ShaderModuleSet::GetShaderModule() method, when creating the second shader, it just return the cache of the first one. I think the DxbcXfbInfo should be a part of the ShaderKey.

Ddoitsujin maintainer 2018-10-25 github

While true, is there a scenario where the same shader is used with different xfb infos?

AAnzhongHuang 2018-10-25 github

Yes, it's happened on an internal d3d11 test case, it's used to test corner cases I guess. The two shaders use the different SoEntries. I've work-round it on local.
` size_t cacheSize = BytecodeLength;
if ((pDxbcModuleInfo != nullptr) && (pDxbcModuleInfo->xfb != nullptr))
{
cacheSize += sizeof(DxbcXfbInfo);
}
std::vector cachedata(cacheSize);

  memcpy(&cachedata[0], pShaderBytecode, BytecodeLength);
  if ((pDxbcModuleInfo != nullptr) && (pDxbcModuleInfo->xfb != nullptr))
  {
      memcpy(&cachedata[BytecodeLength], pDxbcModuleInfo->xfb, sizeof(DxbcXfbInfo));
  }

// Compute the shader's unique key so that we can perform a lookup
DxvkShaderKey key(GetShaderStage(ProgramType), cachedata.data(), cachedata.size());`
Ddoitsujin maintainer 2018-10-25 github

I guess hashing the XFB state vector along with the shader code should be enough to resolve this without blowing the shader key structure out of proportion (and more importantly, without invalidating existing state caches).

Ddoitsujin maintainer 2018-10-25 github

Should be fixed now.

AAnzhongHuang 2018-10-26 github

It works, thanks.

Nothing extracted yet.