Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Directx bool中的着色器内部asfloat消失了?_Directx_Shader_Direct3d_Hlsl - Fatal编程技术网

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)。(特别是我使用
clip(asfloat(all(b4)))
来组合四个剪辑操作。)如果您可以确认这不再受支持,我想在我的情况下,我可以简单地将其更改为
clip(all(b4)?1.0:-1.0)
,所以没什么大不了的。我只是想知道为什么它消失了,为什么没有记录。或者我误解了什么?我只是提交了一个文档错误来修复它。