In a DirectCompute shader, having a function taking an string type argument, how to access individual characters ?
Example:
uint TestFunc(string S, uint I)
{
return uint(S[I]);
}
The compiler complain about S[I]: "error X3121: array, matrix, vector, or indexable object type expected in index expression".
Any idea?
From MS docs:
Strings exist in HLSL, but there’s very little you can do with them. Depending on your needs, you might want to pass the string to the shader as an array of instead of a string, or as a
RWStructuredBufferof bytes, then perform the conversion to/from ASCII.