protonscr

amdvlk: Attempt to redefine function

dxvkclosed bughelp wantedamd amdvlk
doitsujin/dxvk#43 · opened 2018-01-31 by notaz · updated 2018-02-01 · 5 comments · github
Nnotaz 2018-01-31 github

I think it would useful to get open amdvlk working for comparisons against radv. It currently fails while handling SPIRV while running witness trace:

Error: Attempt to redefine function: 
; Function Attrs: nounwind
declare spir_func
%spirv.SampledImage.float_1_0_0_0_1_0_0 addrspace(1)* @_Z12SampledImagePU3AS140__spirv_SampledImage_float_1_0_0_0_1_0_0i(%spirv.SampledImage.float_1_0_0_0_1_0_0 addrspace(1)*, i32) #0
 =>
%spirv.SampledImage.float_1_1_0_0_1_0_0 addrspace(1)* (%spirv.SampledImage.float_1_0_0_0_1_0_0 addrspace(1)*, i32)

Here is a snip from amdvlk icd/api/llpc/translator/SPIRVUtil.cpp , it looks like it doesn't like some type mismatch:

  FunctionType *FT = FunctionType::get(RetTy, ArgTypes, isVarArg);
  Function *F = M->getFunction(MangledName);
  if (!takeName && F && F->getFunctionType() != FT && Mangle != nullptr) {
    std::string S;
    raw_string_ostream SS(S);
    SS << "Error: Attempt to redefine function: " << *F << " => " <<
        *FT << '\n';
    report_fatal_error(SS.str(), false);
  }

Ddoitsujin maintainer 2018-01-31 github

Well, if it was easy to support other drivers, I'd have done it ages ago. These issues are insanely hard to debug (or straight-up impossible in case of closed-source drivers) and even the information you gave doesn't really tell me anything. Unless there's a way to find out which SPIR-V instruction in the source shader causes the error, there's nothing I can do.

How did you get amdvlk to display those messages at all? I've tried various things and even with a debug build, it just exits the application without any sort of information on what is actually wrong.

Anyway, I talked to vkd3d devs and apparently their plan is to make their shader compiler a standalone library at some point. Once that happens I might start using it for dxvk as well.

Nnotaz 2018-01-31 github

Well there are some "SampledImage" strings in dxvk, so I thought you might be using them while building SPIR-V (functions?) somehow. I'll admit my understanding about how things work here in general is still poor.

To get amdvlk output, I had to patch report_fatal_error() in amdvlk/drivers/llvm/lib/Support/ErrorHandling.cpp to ignore any registered callbacks and always write to stderr.

Ddoitsujin maintainer 2018-01-31 github

SampledImage is a thing in SPIR-V, but ultimately I still don't know under which circumstances this is problematic and why, and if it is OpSampledImage itself that causes the issue or a consumer of that instruction.

Also, with the error occuring deep down in LLVM rather than an earlier stage, a lot of noise is added while relevant information may be lost. A "function" could be anything in this context.

Ddoitsujin maintainer 2018-01-31 github

Might be a driver bug, reported this here: https://github.com/GPUOpen-Drivers/xgl/issues/5

Ddoitsujin maintainer 2018-02-01 github

This particular issue should be fixed when applying GPUOpen-Drivers/xgl#6.

Nothing extracted yet.