-
Notifications
You must be signed in to change notification settings - Fork 35
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] Begin Review Period #84
Comments
This starts the review period for the spec. See issue microsoft#84 for more details.
This starts the review period for the spec. See issue #84 for more details.
FYI I think the proposal link is a bad link? I think this might have been what was intended? |
I have a need for clarification w.r.t. the Ideally I'd like it to return the Original issue: This is basically so I can use things like atomics and other weird things like Also I guess it "could" possibly allow me to fix #57 if there's some way to form a new clean Basically I could wrap all the above into a small-ish utility function |
You have a method to construct a I understand you wish to prevent/ban pointer arithmetic on a Another route would be to allow
Without a way to do I don't think SPIR-V Validator will like me doing this struct block_s
{
float4 x;
uint16_t histogram[1];
}; and then reading past the end of the array. And neither will it like me declaring a I don't think you will want to support the syntax abomination which is |
EDIT: Addressed in #86
But I thought that later on you accepted a PR which allowed pointees to be writable (Appendix D of proposal explicitly talks about assigning to |
We should get a
P.S. Cool, so do we get a |
I'd like some examples of this in code in an Appendix, I also don't understand if I can turn an aliased pointer to a non-aliased, etc. |
Was there any mention of coherent memory access and or atomic access to memory via buffer pointers yet? |
I'd expect For coherent memory access ( and SPV- atomics i.e. float, and other weird ones) you'd need what I'm alluding to here: #84 (comment) Because with Vulkan Memory Model (and in C++11), you don't really declare a pointer/reference coherent/volatile but the actual memory read/write as needing a memory barrier. SPV Mind you this can be all done with current inline SPIR-V without the need for #59 , if only |
I think by |
Well at the end of the day I'm thinking of a way to connect a template<typename T>
[[vk::ext_instruction(/* OpLoad */ 61)]]
T special_load([[vk::ext_reference]] T arg, [[vk::ext_literal]] int aligned, , [[vk::ext_literal]] int alignment, [[vk::ext_literal]] int memoryOperand);
template<typename T, uint16_t Alignment>
T volatile_load(inout vk::BufferPointer<T,Alignment> mypointer)
{
return special_load(mypointer.Get(),/*Aligned*/0x2,Alignment,/*Volatile*/0x1);
} |
doesn't matter if you give me a pseudo-intrinsic method like template<typename T, uint16_t Alignment>
vk::result_id<vk::BufferPointer<T,Alignment>::__get_t> accessChain([[vk::ext_reference]] vk::BufferPointer<T,Alignment> ptr); which I can then use as a Or whether I can pass the |
@s-perron, I think I'd like your opinion on how |
Would something like GetCoherent() work? Sytntactically that would be clean and its still generic and easy to use. |
The result |
Ok final question @s-perron, what about? struct MyStruct
{
float somefloat;
uint32_t someint;
};
vk::BufferPointer<MyStruct> mypointer(pushConstants.someuint64t);
special_load(mypointer.Get().someint,/*Aligned*/0x2,Alignment,/*Volatile*/0x1); basically will "member access operator" applied to the reference obtained via |
There seem to be 3 classes/cases of
for 1 and 2 I'm assuming no temporaries, copies, etc. that would require references to work in HLSL-the-language as opposed to the AST (where they must be references for anything to work really). |
I second that without pointer arithmetic or the ability to have pointers to a dynamically sized array, this feature will be of limited usefulness. |
You can pass any lvalue to the spir-v intrinsic parameters annotated with
is legal. That means that |
@s-perron last question, what about case (3) which is slapping the pointer itself into the intrinsic ( |
Sorry forgot to get back to you about that one. Given the current spec you should be able to do:
The idea is that you want to pass the value of the pointer, which is the address of |
okay, so this seems like all my usages would be 100% covered. P.S. Just for completeness, can you think of any case for which I'd need the address of the pointer itself? |
Here is an simple example with a local variable: https://godbolt.org/z/hWYbnavbP. Note that this will fail validation because this convert is illegal. However, with a buffer pointer object it should be legal.
I can't think of one, but someone probably will. :) |
shouldn't we then define how this can be achieved? |
I'm just thinking out loud, if |
This would not be legal generally. I would expect |
I don't think its desirable for I'm just wondering if there's any SPIR-V opcode where passing the address to the pointer itself would make sense. |
Taking the address of a pointer in device-local memory is out of scope for this proposal. This proposal explicitly states that all addresses that vk::BufferPointer can refer to are host-local memory, but the pointer would be device-local. I don't think we should support address-of or other more complex pointer scenarios until we add actual pointers and references to the language. |
I'm fine with that as long as the cases we discussed with s-perron work. Howver I'd advise to define what happens when you try to pass a |
Are you confusing host-local and device-local here? I’d rarely if ever want want to fetch data clear across the PCI-E bus into CPU (aka host) memory, but you make this sound like it’s a requirement… vulkan’s device addresses almost always refer to device local memory… |
The obvious application would be a two-dimensional array, with each entry having variable size. For example, an array of buffer pointers to individual mesh indices. First dimension would be the mesh ID, second would be the triangle of that mesh. In a game with many emissive meshes, one might want to trace rays to a random triangle of a random mesh. Fortunately, if a vk::BufferPointer can be constructed from a uint64_t, I think this is mostly a matter of syntax sugar. |
Iiuc, vk::BufferPointer construction from uint64_t would allow pointer arithmetic to be done with one level of indirection. You start slipping into out-of-spec behavioral issues like with vk::RawBufferLoad/Store though. Still, it seems obvious to me that developers will do exactly this arithmetic on uint64_t, then vk::BufferPointer construction to skirt around the currently imposed limitations. I’m guessing that issues will arise from that, which will require a subsequent spec proposal involving dereferencing. I can understand why that might deserve its own proposal. |
as it stands you can't go back from a |
The spec (as written) says “All buffer pointers are presumed to point into the host memory address space. No new address space attributes are proposed.”. If these are intended to be device-local memory, that wording needs to be changed. |
In my opinion we should change it, unless I’m missing something important. Really, it shouldn’t matter if the Vulkan device address refers to device or host local memory. Indeed, I use both with raw buffer store/load. It just needs to be a valid Vulkan device address. |
You're right this should change. It should match the language in the vulkan spec. It is just the device address for a buffer. It does not know or care about anything else. The address are suppose to come from a call to vkGetBufferDeviceAddress on the host and passed to the shader as a parameter. There are no restrictions on the type of the device memory. It could have any of these properties. |
@llvm-beanz All 0010 issues are now closed. Can this feature's review period now be closed? |
The feature has been marked as accepted. Closing as we will file additional issues if any further changes arise. |
Which document does this relate to?
Proposal 0010: vk::BufferPointer
Review Period
With all outstanding issues resolved, the vk::BufferPointer spec is now entering a final review period. This period is a final call for feedback on the proposal. All feedback is due 9/15. If there is no outstanding feedback at EOD 9/15, the spec will be accepted on 9/18.
If you have feedback please either comment on this issue or file an issue against this repository.
The text was updated successfully, but these errors were encountered: