Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/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 外壳着色器中的重叠寄存器?_Directx_Shader_Tessellation - Fatal编程技术网

Directx 外壳着色器中的重叠寄存器?

Directx 外壳着色器中的重叠寄存器?,directx,shader,tessellation,Directx,Shader,Tessellation,我正在进行一些硬件细分,并设法获得了基本的细分效果,因此尝试转到Phong细分(用于圆角边)。现在,当我想在Patch常量函数中添加额外的输出并写入它们时,其中一个会抛出错误 struct ConstantOutputType { float edges[3] : SV_TessFactor; float inside : SV_InsideTessFactor; float3 f3B0 : POSITION0; float3 f3B1 : POSITION1;

我正在进行一些硬件细分,并设法获得了基本的细分效果,因此尝试转到Phong细分(用于圆角边)。现在,当我想在Patch常量函数中添加额外的输出并写入它们时,其中一个会抛出错误

struct ConstantOutputType
{
    float edges[3] : SV_TessFactor;
    float inside : SV_InsideTessFactor;

    float3 f3B0 : POSITION0;
    float3 f3B1 : POSITION1;
    float3 f3B2 : POSITION2;

    float3 f3N0 : NORMAL0;
    float3 f3N1 : NORMAL1;
    float3 f3N2 : NORMAL2;
};

ConstantOutputType PatchConstantFunction(InputPatch<HullInputType, 3> inputPatch, uint patchId : SV_PrimitiveID)
{    
    ConstantOutputType output = (ConstantOutputType)0;


    // Set the tessellation factors for the three edges of the triangle.
    output.edges[0] = inputPatch[0].dep;
    output.edges[1] = inputPatch[1].dep;
    output.edges[2] = inputPatch[2].dep;

    // Set the tessellation factor for tessallating inside the triangle.
    output.inside = (inputPatch[0].dep + inputPatch[1].dep + inputPatch[2].dep)/3.0f;


    output.f3B0 = inputPatch[0].pos.xyz;
    output.f3B1 = inputPatch[1].pos.xyz;
    output.f3B2 = inputPatch[2].pos.xyz;

    //output.f3N0 = inputPatch[0].nor.xyz;  <=====This throws the error (setting the normal)
    output.f3N1 = inputPatch[1].nor.xyz;
    output.f3N2 = inputPatch[2].nor.xyz;

    return output;
} 
好的,看来外壳着色器输入结构中的(float dep:TEXCOORD2;)就是问题所在。可能是因为着色器单元处理float4寄存器,两个float3变量无法合并,但float2和float已合并到float4寄存器。这与两个float2相同,但float2和float3不能连接,也不会重叠。所以我想我将在一个float3变量中用(float2 tex)发送深度(float dep)信息

这很有趣,尽管它对某人有用。在我的域到像素着色器中,不会以这种方式重叠寄存器

更新:它不起作用,错误消失了,我可以编译着色器,但是如果我试图通过从输入结构分配给它来使用该变量,那么整个图形渲染就会停止工作(即使是未安装的调用)。这种情况发生在硬件设备上,在WARP上,它以某种方式工作。


UPDATE2:现在我通过只发送float4来修复它,但我一点也不喜欢。这是非常奇怪的,我不必这样做,在我的顶点和像素着色器,也许这是一个小故障?或者可能是GPU硬件不兼容(Nvidia GT525M)。

请向我们提供
HullInputType
定义感谢您的回复,我已更新。我无法重现您的错误。根据发布的代码,我已经(在某个地方)变得毫无意义。它使用Visual Studio 2012更新3和Visual Studio 2013预览更新1附带的两个HLSL编译器进行编译。您使用什么
fxc
D3DCompiler.dll
版本?首先,我认为
HullInputType
是错误的,可能没有正确对齐。但现在我认为这只是
fxc.exe
bug(有很多)。尝试从链接编译我的代码和/或尝试更改(升级/降级)编译器版本。只需从DirectX SDK尝试旧的
fxc v9.29.952.3111
。没有错误。命令行:
fxc.exe HullShader.hlsl/Zi/E“main”/Od/Fo“HullShader.cso”/Ths_5_0/nologo
struct HullInputType
{
    float3 pos              : POSITION;
    float2 tex              : TEXCOORD0;
    float3 nor              : TEXCOORD1;
    float  dep              : TEXCOORD2;
};