[PATCH] D124790: [HLSL] Enable half type for hlsl.

Xiang Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 3 12:27:20 PDT 2022


python3kgae marked 2 inline comments as done.
python3kgae added inline comments.


================
Comment at: clang/lib/Basic/LangOptions.cpp:197
 
-  // OpenCL has half keyword
-  Opts.Half = Opts.OpenCL;
+  // OpenCL and HLSL have half keyword
+  Opts.Half = Opts.OpenCL || Opts.HLSL;
----------------
aaron.ballman wrote:
> python3kgae wrote:
> > aaron.ballman wrote:
> > > Shouldn't this be looking for HLSL 2018? Or shader model 6.2?
> > half keyword is always available.
> > Without enable_16bit_types, half will be like using half=float.
> > With enable_16bit_types, half will be real half.
> > 
> > The check for HLSL 2018 and shader model 6.2 will be in another PR, still WIP. I'll add FIXME about it.
> > half keyword is always available.
> > Without enable_16bit_types, half will be like using half=float.
> > With enable_16bit_types, half will be real half.
> 
> Is there room for change here, or is this strictly required by HLSL? This strikes me as just begging to confuse users into creating ODR violations. CC @beanz 
Here's the doc about half for dxc.
https://github.com/microsoft/DirectXShaderCompiler/wiki/16-Bit-Scalar-Types

Old doc for fxc (the old shader compiler for shader model <= 5.1) is here
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-scalar

Change the behavior might affect a lot of existing shaders.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124790/new/

https://reviews.llvm.org/D124790



More information about the cfe-commits mailing list