From f9e56c97cfc25e535306c0122462d328136a3708 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 15 Apr 2019 03:09:31 +0200 Subject: [PATCH] [d3d11] Fix hasing of geometry shaders with stream output The xfb struct contains pointers, but we should hash the strings instead, otherwise the hash changes between runs. --- src/d3d11/d3d11_device.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index cc2fdb712..5bfffbde3 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -676,11 +676,22 @@ namespace dxvk { // Compute hash from both the xfb info and the source // code, because both influence the generated code - std::array chunks = {{ - { pShaderBytecode, BytecodeLength }, - { &xfb, sizeof(xfb) }, + DxbcXfbInfo hashXfb = xfb; + + std::vector chunks = {{ + { pShaderBytecode, BytecodeLength }, + { &hashXfb, sizeof(hashXfb) }, }}; + for (uint32_t i = 0; i < hashXfb.entryCount; i++) { + const char* semantic = hashXfb.entries[i].semanticName; + + if (semantic) { + chunks.push_back({ semantic, std::strlen(semantic) }); + hashXfb.entries[i].semanticName = nullptr; + } + } + Sha1Hash hash = Sha1Hash::compute(chunks.size(), chunks.data()); // Create the actual shader module