Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amdvlk: Attempt to redefine function #43

Closed
notaz opened this issue Jan 31, 2018 · 5 comments
Closed

amdvlk: Attempt to redefine function #43

notaz opened this issue Jan 31, 2018 · 5 comments

Comments

@notaz
Copy link
Contributor

notaz commented Jan 31, 2018

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);
  }

@doitsujin
Copy link
Owner

doitsujin commented Jan 31, 2018

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.

@notaz
Copy link
Contributor Author

notaz commented Jan 31, 2018

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.

@doitsujin
Copy link
Owner

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.

@doitsujin
Copy link
Owner

Might be a driver bug, reported this here: GPUOpen-Drivers/xgl#5

@doitsujin
Copy link
Owner

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

Blisto91 pushed a commit to Blisto91/dxvk that referenced this issue Feb 1, 2023
WinterSnowfall pushed a commit to WinterSnowfall/dxvk that referenced this issue Jul 3, 2023
tobiasjakobi pushed a commit to tobiasjakobi/dxvk that referenced this issue Sep 24, 2023
AlpyneDreams added a commit to WinterSnowfall/dxvk that referenced this issue Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants