-
Notifications
You must be signed in to change notification settings - Fork 721
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
An issue with template type deduction and globallycoherent? #5999
Comments
Just wanted to check on the status of this. Thanks |
+1 For this. Another example in shader playground https://shader-playground.timjones.io/b050891fa1644437bf69e0ccc655801f. I would expect "globallycoherent RWBuffer" to be a different type from "RWBuffer" considering how you can't assign a globallycoherent RWBuffer to a regular RWBuffer. |
Good find. Your example would probably help narrow down the source of the compiler's confusion. It looks like a different issue on the surface, but probably points to something related. eg something(s) does not recognize 'globallycoherent' as a keyword. |
Compiler Explorer Link (because shader playground is really slow to load). |
Thanks Chris, I was about to send the same link. Also worth noting, this link uses the trunk compiler which has made the warning message more helpful. In this, a warning is produced, which isn't explicitly said in this bug. I know @simonwongms said that they didn't know if the codegen was right. Given that this example passes a globallycoherent object into a parameter that isn't, I expect the qualifier is getting stripped. I think that's correct. If there are codegen issues elsewhere, we'll need an example to consider them. The test @KStocky added is appreciated and we should incorporate some testing for this. Otherwise, I don't see any action needed here. Am I missing something? |
I think @KStocky's example here shows how this can become an error: https://godbolt.org/z/sP6rKvYov We do need to figure out how we want to resolve this properly. This especially becomes a problem if we support cross-translation unit linking. In that scenario we'll need I think we get lucky today that the codegen is correct in most cases because we just propagate |
Hi,
Greg, you mentioned: "Given that this example passes a globallycoherent object into a parameter that isn't, I expect the qualifier is getting stripped. I think that's correct. If there are codegen issues elsewhere, we'll need an example to consider them."
That's not exactly the issue here though. It's not as if we have a function that is explicitly written to expect a non globallycoherent RWBuffer, and the calling code is passing one. The bug here is that the function is a templated function, and the type should be getting auto-deduced to be a globallycoherent RWBuffer. In which case, it should maintain the qualifier.
When I dug into the disasm in PIX, I can see that the generated code does seem correct. For example, this loading code
template
uint TemplateFunctionR(BufferType AutoParam)
{
return AutoParam.Load(1);
}
generates this:
buffer_load_dword v0, v0, s[0:3], 0 offset:1 dlc glc // 000000000030: E030C001 80000000
So it does seem to generate the correct code in this example, which would mean that the error/warning is a false positive.
(Edited by @llvm-beanz to remove email thread text)
|
The warning isn't a false positive. The code is converting between The problem is that because of how We've had a bunch of issues relating to type annotations like |
Would this be the same bug as something like |
Yes, same basic problem different attribute. The matrix orientation and globallycoherent keywords are implemented as attributes, so whenever we need a "canonical type" we lose them. Canonical type resolutions occur in a bunch of places whenever the compiler needs to de-sugar or fully resolve a type. We really need these keywords to be implemented as type qualifiers (which in clang are effectively just special attributes, that stick around during canonicalization). |
We have a variable of type ‘globallycoherent RWByteAddressBuffer’. When this is passed to a templated function where the buffer is a templated parameter, the globallycoherent part seems to be missed?
Now, I don’t know if the compiled out dxil is actually correct and the warning/error is a false positive. We hadn’t noticed any visual artifacts in the June GDK.
I’ve distilled the hlsl into bare bones to repro this issue. This is obviously not a shader that does anything. It’s just stripped down to illustrate the issue and trigger the error/warning.
I am able to reproduce this in shader playground:
https://shader-playground.timjones.io/98b958c232fe4b88326d5be6b2570013
The error output there matches the ones I get in the GDK
Environment
dxcompiler_xs.dll!DxcCreateInstance: 1.7 - 2310.2310.11301.10016
The text was updated successfully, but these errors were encountered: