microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
3.1k stars 691 forks source link

Question: Pointer support in HLSL? #2290

Closed MarkIngramUK closed 5 years ago

MarkIngramUK commented 5 years ago

I've had a look at the roadmap, and while I can see a reference to References, there's no mention of Pointers. Use of pointers would be great within compute kernels, as right now I need to have a custom struct that contains a RWStructuredBuffer and an int for the offset into the buffer. Both Metal SL and OpenCL allow pointers, so it would be great to reduce the feature disparity in HLSL.

tristanlabelle commented 5 years ago

Hi Mark, the team is currently focused on hardware-facing features, but we plan to enter full planning phase for the future of HLSL around the end of the year. There's a lot we want to improve and we're keeping an eye on other languages in this space, but we can't give dates for specific language features at this time.

MarkIngramUK commented 5 years ago

Thanks @MrTrillian - Is this the kind of feature that Microsoft would like to decide the future direction of, or is this something that would be accepted via community input?

BitMD commented 5 years ago

We will likely have a prototype here that folks can comment on when its ready. Again, we won't be in planning until later this year.

GamebabyRockSun commented 5 years ago

Hi @MrTrillian If you improve the HLSL language in the future, could you simplify some of the changes to the damn root signature, render pipeline state object, etc., to make it easier to call and understand. Now use ray tracing to render these two things so people can grab them.

loopervfx commented 4 years ago

@MarkIngramUK It's worth mentioning that the in-development WebGPU standard, (poised to succeed WebGL) implements a dialect of HLSL called Secure HLSL, which has "safe" pointers: https://github.com/gpuweb/gpuweb/wiki/Secure-HLSL-Explainer#safe-pointers

I have no insider knowledge, but I can imagine that Microsoft will be compelled to add pointer support to HLSL / DXC in a similar fashion sooner or later. It would be downright anachronistic to have such a desirable GPGPU feature available for use in an otherwise restrained "web" variant of HLSL, yet not have pointers available in HLSL when developing full blown desktop / workstation grade applications with DirectX.

adiblev commented 2 years ago

Any update on this topic? Start addressing with pointers / conversions / safe pointers would be a great addition moving towards full bindless without need to create redundant copy or using offsets and creating overheads due to that.

devshgraphicsprogramming commented 1 year ago

its kind-of possible to spoof your own pointers to data in Device Memory bound as RWByteAddressBuffer[] with the HLSL2021 macros and unholy templates to declare structs

https://godbolt.org/z/KesGq3z44

Theoretically would work both for DXIL and SPIR-V output (and then whatever can be cross compiled by SPIR-V Cross and do non-uniform SSBO indexing)