-
Notifications
You must be signed in to change notification settings - Fork 34
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
[0010] Method to obtain uint64_t
from BufferPointer
#93
Comments
uint64_t
from BufferPointer
btw in case I wasn't clear, this is not about having any implicit casts. I'd find |
Another acceptable solution would be for the SPIR-V intrinsics to interact with template<typename T, uint16_t A>
[[vk::ext_capability(/*PhysicalStorageBufferAddresses*/ 5347)]]
[[vk::instruction(/*OpConvertPtrToU*/117)]]
uint64_t uint64_t_cast([[vk::ext_reference]] vk::BufferPointer<T,A> p); |
Hmm in order to keep your aliasing analysis intact, I think my suggestion would be to add the following to an
and keep everything "as is" for restrict pointers.
And frankly I think |
I believe it is important for aliased pointers to allow for ptr arithmetic. I agree with devsh here. As aliased pointers have sound semantics for ptr arithmetic, i dont see why it wouldnt be supoorted for them, that would be quite sad that was missing. I also think aliased pointers should be the default as they generally would then allow for more convenient an generalized use, hence be a better default. In other languages restrict is also not the default but opt in, i believe it should be the same for hlsl. I also agree with devsh on the alias beeing part of the type. |
As stated #84 (comment), you can create your own cast to uint64_t using inline spir-v. Can this issue be closed now? |
Doing that will probably mess up the compilers "leak analysis" and produce weird issues if we don't cast In principle we could close this issue, but a new one should be opened about whether aliase should be the default and |
@devshgraphicsprogramming I am sympathetic with the desire for a much richer feature that I am proposing here. But my charter is to design something with a more limited capability. By definition it will not meet everyone's needs. I am fairly certain vk::RawBufferLoad and vk::RawBufferStore are not going away, so this proposal will not take capability away. So I think this can be closed. As for this comment:
@llvm-beanz has endorsed restrict as the default, noting it is most consistent with HLSL. Also, as a Vulkan feature, restrict default is consistent with SPIR-V rules. |
We have decided to allow casting to uint64_t. It will make create more opportunities for developers to make mistakes, but they do not have to use it. The implementation cost does not seem too high. Fixes microsoft#93
We have decided to allow casting to uint64_t. It will make create more opportunities for developers to make mistakes, but they do not have to use it. The implementation cost does not seem too high. Fixes microsoft#93
We have decided to allow casting to uint64_t. It will make create more opportunities for developers to make mistakes, but they do not have to use it. The implementation cost does not seem too high. Fixes microsoft#93
* [0010] Allow casting to uint64_t We have decided to allow casting to uint64_t. It will make create more opportunities for developers to make mistakes, but they do not have to use it. The implementation cost does not seem too high. Fixes #93 * Remove cast to bool As Greg suggested, the cast to bool is no longer needed if we can cast to an int, so we removed it. This commit also adds the uint64_t cast to the pseudo class definition for BufferPointers. * Fix linked list example after rebaseing.
Which proposal does this relate to?
0010 - Buffer Pointers
Describe the issue or outstanding question.
In my opinion we need a function/method to convert
vk::BufferPointer<T,A>
touint64_t
.This is because the proposal explicitly disallows arithmetic operators on
BufferPointer
and doesn't mention there beingoperator[]
.Furthermore indexing past the end of an array in a struct is Invalid/UB in SPIR-V, and
OpTypeRuntimeArray
cannot be slapped onto any odd struct member outside of an StorageBuffer block.KhronosGroup/SPIRV-Tools#1458
This means that in order to implement the following design pattern from C/C++
we cannot simply declare in HLSL202x
Even if I didn't need to work around #57 and could get the address of
ptr.Get().value[1]
without helper structs/code, I'd still need to be able to perform some form of arithmetic/indexing.Also I guess
vk::BufferPointer<T[]>
is not the syntax you want to deal with.Finally being able to just get the
uint64_t
address value is a matter of control, we currently have this level of control withRawBufferLoad
andRawBufferStore
and its not nice for it to go away.Additional context
See this comment: #84 (comment)
The text was updated successfully, but these errors were encountered: