Directx bool中的着色器内部asfloat消失了?
编译此像素着色器:Directx bool中的着色器内部asfloat消失了?,directx,shader,direct3d,hlsl,Directx,Shader,Direct3d,Hlsl,编译此像素着色器: float4 main() : SV_TARGET { bool4 b = bool4(true, false, true, false); return asfloat(b); } 使用命令fxc.exe test.hlsl/T ps_5_0失败: Microsoft (R) Direct3D Shader Compiler 6.3.9600.16384 (using C:\Program Files (x86)\Windows Kits\8.1\bin\
float4 main() : SV_TARGET
{
bool4 b = bool4(true, false, true, false);
return asfloat(b);
}
使用命令fxc.exe test.hlsl/T ps_5_0
失败:
Microsoft (R) Direct3D Shader Compiler 6.3.9600.16384 (using C:\Program Files (x86)\Windows Kits\8.1\bin\x64\D3DCOMPILER_47.dll)
Copyright (C) 2013 Microsoft. All rights reserved.
test.hlsl(13,12-21): error X3013: 'asfloat': no matching 1 parameter intrinsic function
test.hlsl(13,12-21): error X3013: Possible intrinsic functions are:
test.hlsl(13,12-21): error X3013: asfloat(float|half|int|uint)
compilation failed; no code produced
它与较旧版本的着色器编译器配合使用,但:
"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Utilities\bin\x64\fxc.exe" /T ps_5_0 test.hlsl
Microsoft (R) Direct3D Shader Compiler 9.29.952.3111
Copyright (C) Microsoft Corporation 2002-2009. All rights reserved.
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc /T ps_5_0 a.hlsl
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// no Input
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_TARGET 0 xyzw 0 TARGET float xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_output o0.xyzw
mov o0.xyzw, l(1.000000,0,1.000000,0)
ret
// Approximately 2 instruction slots used
未提及此更改,并列出了bool
重载
这是虫子吗?我做错什么了吗?这是故意删除的吗?我应该用什么来代替?(实际上,我将它与asfloat(all(…)
)结合使用)asfloat(bool)
不应该起作用asfloat
(和asdouble
)本质上是与*reinterpret_cast(&x)
相当的HLSL。这对整数数据有一定意义,但bool是有问题的。布尔的位场模式在HLSL中定义不清,因此理论上它可以是任何东西
编译器在Windows 8时代的某个地方进行了更新(即,将DirectX SDK声明为legacy per后),以“修复”此行为。D3DCompiler DLL的#43遗留DirectX SDK版本是最后一个在bool上接受asfloat
的编译器
MSDN页面从未更新过以反映这一点,因此我已提交了一个文档错误以更正此问题。VS 2013 Update 5和VS 2015随Windows 8.1 SDK Spring 2015更新而来,因此您可能有一个更新的编译器
asfloat
对于bool
来说没有什么意义,所以我怀疑它最初接受它是一个bug。它也无法使用Windows 10 SDK版本生成。@ChuckWalbourn是的,我想这是关于较新的编译器的。为什么说不通呢?我应该用什么来代替呢?bool是一个逻辑真/假值,asfloat将数字转换为float。你到底想做什么?@ChuckWalbourn:我使用的是函数重载float asfloat(bool value)在MSDN上记录并在旧编译器中工作的代码>。(特别是我使用clip(asfloat(all(b4)))
来组合四个剪辑操作。)如果您可以确认这不再受支持,我想在我的情况下,我可以简单地将其更改为clip(all(b4)?1.0:-1.0)
,所以没什么大不了的。我只是想知道为什么它消失了,为什么没有记录。或者我误解了什么?我只是提交了一个文档错误来修复它。