As of fd1fd40ad6f6fb01e9d37611215aca5496d79c1f, the game no longer crashes upon start (yay!), but it seems to freeze before reaching the main menu. CPU load is pretty low. This is without the shader fix trick mentioned by OP.
@volca02 what's your hardware / driver? I've seen the same behaviour on RADV in mesa-git, not sure what causes it though.
As for the game not rendering correctly, that is to be expected.
Oh sorry, should've mentioned that. I have GTX 1080 with driver version 390.25-10 on arch with 4.15.1-2-ARCH kernel.
Edit: Update. Apparently the game writes a crash log before freezing, so there still is some unwanted behavior that causes crashes.
witcher3.exe_crash_20180115_122116073.crashinfo.log
Edit: With DXVK_DEBUG_LAYERS=1 (and an appropriate vk_layer_settings.txt), the crash log is not produced, the game still freezes on black screen (before getting into main menu), and this vulkan log is produced:
I finally got bored with fixing shaders by hand and now I have new game called "Collect full Geralt". No crashes for 5 min. ingame with this hack:
diff --git a/src/d3d11/d3d11_shader.cpp b/src/d3d11/d3d11_shader.cpp
index fa91c27..44086b4 100644
--- a/src/d3d11/d3d11_shader.cpp
+++ b/src/d3d11/d3d11_shader.cpp
@@ -1,12 +1,61 @@
#include "d3d11_device.h"
#include "d3d11_shader.h"
+#include "spirv-tools/optimizer.hpp"
+
namespace dxvk {
-
+ spvtools::Optimizer spirv_opt(SPV_ENV_VULKAN_1_0);
+
D3D11ShaderModule:: D3D11ShaderModule() { }
D3D11ShaderModule::~D3D11ShaderModule() { }
-
+ template <typename T>
+ bool ReadSpvFile(const char* filename, const char* mode, std::vector<T>* data) {
+ const int buf_size = 1024;
+ const bool use_file = filename && strcmp("-", filename);
+ if (FILE* fp = (use_file ? fopen(filename, mode) : stdin)) {
+ T buf[buf_size];
+ while (size_t len = fread(buf, sizeof(T), buf_size, fp)) {
+ data->insert(data->end(), buf, buf + len);
+ }
+ if (ftell(fp) == -1L) {
+ if (ferror(fp)) {
+ fprintf(stderr, "error: error reading file '%s'\n", filename);
+ return false;
+ }
+ } else {
+ if (sizeof(T) != 1 && (ftell(fp) % sizeof(T))) {
+ fprintf(stderr, "error: corrupted word found in file '%s'\n", filename);
+ return false;
+ }
+ }
+ if (use_file) fclose(fp);
+ } else {
+ fprintf(stderr, "error: file does not exist '%s'\n", filename);
+ return false;
+ }
+ return true;
+ }
+
+ template <typename T>
+ bool WriteFile(const char* filename, const char* mode, const T* data,
+ size_t count) {
+ const bool use_stdout =
+ !filename || (filename[0] == '-' && filename[1] == '\0');
+ if (FILE* fp = (use_stdout ? stdout : fopen(filename, mode))) {
+ size_t written = fwrite(data, sizeof(T), count, fp);
+ if (count != written) {
+ fprintf(stderr, "error: could not write to file '%s'\n", filename);
+ return false;
+ }
+ if (!use_stdout) fclose(fp);
+ } else {
+ fprintf(stderr, "error: could not open file '%s'\n", filename);
+ return false;
+ }
+ return true;
+ }
+
D3D11ShaderModule::D3D11ShaderModule(
const DxbcOptions* pDxbcOptions,
D3D11Device* pDevice,
@@ -48,6 +97,24 @@ namespace dxvk {
std::ios_base::binary | std::ios_base::trunc));
}
+
+ spirv_opt.RegisterLegalizationPasses();
+
+ std::vector<uint32_t> spirv_dump_data;
+ std::vector<uint32_t> spirv_fixed_data;
+
+ if (ReadSpvFile<uint32_t>(str::format("./", dumpPath, "/", m_name, ".spv").c_str(), "rb", &spirv_dump_data)) {
+ if (!spirv_opt.Run(spirv_dump_data.data(), spirv_dump_data.size(), &spirv_fixed_data)) {
+ Logger::err(str::format("Shader NOT optimized ", m_name));
+ } else {
+ if (!WriteFile<uint32_t>(str::format("./", readPath, "/", m_name, ".spv").c_str(), "wb",
+ spirv_fixed_data.data(), spirv_fixed_data.size())) {
+ Logger::err(str::format("File not saved ", str::format("./", readPath, "/", m_name, ".spv")));
+ }
+ }
+ } else {
+ Logger::err(str::format("File not found ", str::format("./", dumpPath, "/", m_name, ".spv")));
+ }
// If requested by the user, replace
// the shader with another file.
if (readPath.size() != 0) {
@@ -56,8 +123,10 @@ namespace dxvk {
str::format(readPath, "/", m_name, ".spv"),
std::ios_base::binary);
- if (readStream)
+ if (readStream) {
m_shader->read(std::move(readStream));
+ Logger::trace(str::format("Shader overrided ", m_name));
+ }
}
}
ReadFile and WriteFile are stolen from spirv-tools io.h
Some transparent textures became visible and normal when I moving around now.
On High settings it looks more accurate, but crashed as soon as GPU memory became full (maybe this is partially Nvidia fault: https://devtalk.nvidia.com/default/topic/1026874/).
terminate called after throwing an instance of 'dxvk::DxvkError'
fixme:seh:dwarf_get_ptr unsupported encoding 9b
...
I noticed some shaders compiled more than once. Is it ok?
Here is top >2:
89 debug: Compiling shader VS_ce8f5bfde13924bc08ecbbb615a50f7b72dce93e
29 debug: Compiling shader VS_29d1353d7dec12eef804bd0825ebf18e7851da81
12 debug: Compiling shader PS_f8ca366fc398385db2bf00f63e3807aa0f10b55e
12 debug: Compiling shader PS_f7700f2339e74aace080d67a43afaede969bd637
12 debug: Compiling shader GS_4bf0ed14ba0c96bb2ee0b03d40fcf760c73718d6
10 debug: Compiling shader VS_259b1bf0449c05edb75a2f71c2c54e1bb9668e05
8 debug: Compiling shader VS_aef33f45ccc7a7ce3b8f7b3d708e55eb0f6432e3
8 debug: Compiling shader VS_7de085928768c966ad3d58aa9ebef1e0f767bb16
8 debug: Compiling shader VS_17ec1cc54841f3bf05e9a8b7b420f3d31f4c43d6
8 debug: Compiling shader VS_0d3f59fbd84cdd255dd90c08a5e380985268df22
7 debug: Compiling shader VS_dc76e9bfb157d62019f68a7e60e8a4fb762b57cb
6 debug: Compiling shader VS_e0298fd8c1874484d015533d278afcae59ed6966
6 debug: Compiling shader VS_dcfa269ad23df71449ce60a92afbd5761acd7651
6 debug: Compiling shader VS_3b2a0d08e83c69e24265634974803e6faee08d93
6 debug: Compiling shader PS_a1fbfe2404867231a4d49c53bb1bd204d49dbf8f
5 debug: Compiling shader VS_5b089da49390f0d75d1aa3f62452646f4a63452b
5 debug: Compiling shader VS_3b626a33c637292c60d0b1fe4311a3268d93bd9e
5 debug: Compiling shader VS_0eece8010698c11d97fb3f96c0aecea76f169000
4 debug: Compiling shader VS_8eea0a1f89dacfa50ef4b0d08e2031c8524ac481
4 debug: Compiling shader VS_41f1ce2ee3c93a4062202ed30bbebd3e3f9455c5
4 debug: Compiling shader VS_356502ef0ecaa1649ca24270b8137dcdad9525dc
4 debug: Compiling shader PS_ec0fa763dddc20ab2beb51510793acec63408de8
4 debug: Compiling shader PS_6b07f097b1a9eb9052d95d4adb84b2731dea0701
3 debug: Compiling shader VS_f034cf3f0d7abc3ced3db241e492ebd1e3652838
3 debug: Compiling shader VS_a9571bada622417601d856047fe71d302461e463
3 debug: Compiling shader VS_8b1390e50032f5455a581586db5925bd6d505d4d
3 debug: Compiling shader VS_3a88e0ce4f8f7d3a5bd2a2e9fdbc523040692569
3 debug: Compiling shader GS_29373985276080f759d812e6a9d5cb0f31e5f054
twice: 55
once: 357
It's on launch and before fail with disabled shader read dir. Max. saved shaders count I noticed after some time in game was >1k .
Is there a point in fixing shaders for invisible surfaces, without adding tesselation support first?
I think this is related to #93
Yes.
This ghost reverted scene caused by AO enabled when saved game was loaded. Re-enabling or disabling SSAO or HBAO+ fixes this.
Except transparent head, missing ground (like in https://bugs.winehq.org/show_bug.cgi?id=43131), distorted or invisible monsters everything else looks ok.
Game requires shader fix trick all over the time when new buggy shaders upcoming. Now I did dozen rounds and it keep crashing when I moving around.
Software information
The Witcher 3: Wild Hunt
System information
Apitrace file(s)
N/A
Log files
tl;dr: