You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code works as expected. If I have a kamel::Ptr<i32>, I can call the [] operator. But If I change the kamel::Ptr<i32> to be a const kamel::Ptr<i32, it does not work anymore:
example.hlsl:8:27: error: no viable overloaded operator[] for type 'const kamel::Ptr<i32>'
output_buffer[0] = ptr[0];
~~~^~
./ptr.hlsl:27:11: note: candidate function not viable: 'this' argument has type 'const kamel::Ptr<i32>', but method is not marked const
T operator [](u64 index) {
^
It makes sense, since T operator [](u64 address) is not marked as const und therefore cannot be called! But adding const to the function like you usually do in C++ does not solve this issue:
./ptr.hlsl:27:33: error: expected ';' at end of declaration list
T operator [](u64 index) const {
^
;
I don't know if const is supported with HLSL 2021 or if it is a bug, but If not, the compiler message that the method is not marked const is missleading as it implies that there is a way to add const to the function.
The text was updated successfully, but these errors were encountered:
The underlying issue is that HLSL doesn't support constant instance methods. We are aware of the issues caused by the missing feature and we are looking at adding the feature to a future version of HLSL.
I have the following structure, which is an abstraction to load data from a spirv physical storage buffer.
Lets say I create a
Ptr<i32>
and call the[]
operator to retrieve an element from the physical address buffer:This code works as expected. If I have a
kamel::Ptr<i32>
, I can call the[]
operator. But If I change thekamel::Ptr<i32>
to be aconst kamel::Ptr<i32
, it does not work anymore:It makes sense, since
T operator [](u64 address)
is not marked asconst
und therefore cannot be called! But addingconst
to the function like you usually do in C++ does not solve this issue:It complains that
const
is not valid:I don't know if
const
is supported with HLSL 2021 or if it is a bug, but If not, the compiler message that the method is not marked const is missleading as it implies that there is a way to addconst
to the function.The text was updated successfully, but these errors were encountered: