================ @@ -41,6 +41,14 @@ constexpr enable_if_t<sizeof(U) == sizeof(T), U> bit_cast(T F) { return __builtin_bit_cast(U, F); } +constexpr vector<uint, 4> d3d_color_to_ubyte4_impl(vector<float, 4> V) { + // Use the same scaling factor used by FXC (i.e., 255.001953) + // Excerpt from stackoverflow discussion: + // "Built-in rounding, necessary because of truncation. 0.001953 * 256 = 0.5" + // https://stackoverflow.com/questions/52103720/why-does-d3dcolortoubyte4-multiplies-components-by-255-001953f ---------------- Icohedron wrote:
I revised the comment to mention that the scaling factor is the same as FXC and also the DXC DXIL implementation. I also kept the link to the stackoverflow discussion, as the comments in the DXC DXIL implementation referred to it but did not provide a link, which I think is kind of important. Are these new comments more suitable? Or should I just simply just provide a link to the DXC implementation and cut out the repetition? https://github.com/llvm/llvm-project/pull/122202 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits