错误X8000:D3D11内部编译器错误:无效字节码:操作码#86的操作数#1的操作数类型无效(计数从1开始)

时间:2014-10-24 00:15:05

标签: c++ hlsl opcode operand

我和我的导师/实验室助理一样难以接受。

由于某种原因,以下HLSL代码在输出窗口中返回:

error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Invalid operand type for operand #1 of opcode #86 (counts are 1-based).

这是HLSL中导致问题的功能:

// Projects a sphere diameter large in screen space to calculate desired tesselation factor
float SphereToScreenSpaceTessellation(float3 p0, float3 p1, float diameter)
{
float3 centerPoint = (p0 + p1) * 0.5f;

float4 point0 = mul( float4(centerPoint,1.0f) , gTileWorldView);

float4 point1 = point0;
point1.x += diameter;

float4 point0ClipSpace = mul(point0, gTileProj);
float4 point1ClipSpace = mul(point1, gTileProj);

point0ClipSpace /= point0ClipSpace.w;
point1ClipSpace /= point1ClipSpace.w;

point0ClipSpace.xy *= gScreenSize;
point1ClipSpace.xy *= gScreenSize;

float projSizeOfEdge = distance(point0ClipSpace, point1ClipSpace);

float result = projSizeOfEdge / gTessellatedTriWidth;

return clamp(result, 0, 64);
}

我已将它缩小到可能是" mul"固有。我们从代码中取出所有内容并试图返回一个像这样的临时变量,并且它工作正常:

float SphereToScreenSpaceTessellation(float3 p0, float3 p1, float diameter)
{

float temp = 0;

float3 centerPoint = (p0 + p1) * 0.5f;

float4 point0 = mul( float4(centerPoint,1.0f) , gTileWorldView);

float4 point1 = point0;
point1.x += diameter;

float4 point0ClipSpace = mul(point0, gTileProj);
float4 point1ClipSpace = mul(point1, gTileProj);

point0ClipSpace /= point0ClipSpace.w;
point1ClipSpace /= point1ClipSpace.w;

point0ClipSpace.xy *= gScreenSize;
point1ClipSpace.xy *= gScreenSize;

float projSizeOfEdge = distance(point0ClipSpace, point1ClipSpace);

float result = projSizeOfEdge / gTessellatedTriWidth;

return temp;
//return clamp(result, 0, 64);
}

如果有人想知道:

gTileWorldView, gTileProj are float4x4's in a .hlsli file
gScreenSize is a float2 in a .hlsli file.
gTessellatedTriWidth is a float in a .hlsli file.

以下功能与2011年NVidia着色器中的状态一样:http://dx11-xpr.googlecode.com/svn/trunk/XPR/Media/Effects/TerrainTessellation.fx

我尝试复制并粘贴他们的解决方案,用上面的变量替换他们的变量,并且列出了相同的错误。

我绝对难过,我需要帮助才能完成这项任务,请帮忙。

1 个答案:

答案 0 :(得分:0)

查看此行:

point0ClipSpace.xy * = gScreenSize;

gScreenSize是浮动2吗?我不相信你可以通过任何vec类型标量乘以vec。