[SPIR-V] vk::static_pointer_cast and vk::reinterpret_pointer_cast fail to compile
Description Currently these two casting functions for buffer pointers don't seem to cast at all - they behave as if their return type is the same as the input type:
<source>:17:29: error: cannot initialize a variable of type 'BufferPointer<Base>' with an rvalue of type 'BufferPointer<Derived>'
vk::BufferPointer<Base> derivedBufAsBase = vk::static_pointer_cast<Base>(derivedBuf);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:19:30: error: cannot initialize a variable of type 'BufferPointer<float>' with an rvalue of type 'BufferPointer<int>'
vk::BufferPointer<float> intBufAsFloat = vk::reinterpret_pointer_cast<float>(intBuf);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Steps to Reproduce https://godbolt.org/z/vTos39Wcx
Environment
- DXC version: trunk
- Host Operating System: Windows 11
@danbrown-amd Are you able to look into this? Let me know if you cannot.
Could we get __is_base_of btw ?
@Dolkar as for the reinterpret cast, you can steal our inline Spir-V OpBitcast and literally use that to cast between vk:: BufferPointer and any other 8 byte scalar or vector integer type
Took a look at this today, seems like we have 2 things to solve:
-
Support reinterpret/static pointer casts in SemaHLSL This part is straightforward, add code to check the few rules listed in the spec to correctly allow those casts.
-
fixup the intrinsic template. This cast is implemented as an HLSL specific intrinsic, but as-is, the return type is wrongly set to the source type. I need to fix this. Looking into this second part.