Open utterances-bot opened 7 months ago
Awesome write up! Definitely going to take a closer look into this!
Thanks for the article! I am trying to implement this in my engine, however I get compiler errors when trying to use indexing to string literal: bool b = ("Hello"[2] == 'l'); //error: type mismatch I was wondering what dxc version you are using because I tried with both latest official release (v1.7.2308) and with the latest successful build's artifacts from Github but it didnt work.
Slightly less cursed(?) way to get the char code
template<typename T> int CharToUint(in T c) {
int charCode = -1;
uint charMapLen = StrLen("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
for (int i = 0; i < charMapLen; i++) {
if (c == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i]) {
charCode = LettersStart + i;
return charCode;
}
}
}
Hey @mateeeeeee, yeah it looks like you need to pass the character to a templated function first for the comparison to work. I imagine that's a side effect of how char
and other 8-bit types were disabled in clang/LLVM.
@gevahn ha nice, I didn't think of that! I guess that's at least more compact than what I came up with.
Shader Printf in HLSL and DX12
https://therealmjp.github.io/posts/hlsl-printf/