【问题标题】:error X8000 : D3D11 Internal Compiler error : Invalid Bytecode: Invalid operand type for operand #1 of opcode #86 (counts are 1-based)错误 X8000:D3D11 内部编译器错误:无效字节码:操作码 #86 的操作数 #1 的操作数类型无效(计数从 1 开始)
【发布时间】:2014-10-24 00:15:05
【问题描述】:

我和我的导师/实验室助理都被难住了。

由于某种原因,以下 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

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

我完全被难住了,我需要帮助才能完成这项任务,请帮忙。

【问题讨论】:

  • 我不知道工具链在这里是如何工作的,但是如果 HLSL 是由外部编译器编译的,然后读入 DirectX,那么单独的 HLSL 编译器是否太旧或太新?如果这是由 Microsoft 编译器编译的,是否值得启动支持事件以查明这是否是他们的编译器中的错误 - 特别是如果您可以证明它不会编译 NVidia 的示例代码?
  • 我的选择已经不多了,所以我可能不得不开始支持它。我正在使用最新的 HLSL 和 5.0 的着色器模型,所以我认为过时的东西不会成为问题。感谢您的帮助^^
  • 问题可能出在调用它的着色器中。我猜你正在制作一个船体着色器?我发现外壳着色器中的 'out' 参数通常会导致内部编译器错误,但返回具有语义的结构是可以的。

标签: c++ hlsl opcode operand


【解决方案1】:

看看这一行:

point0ClipSpace.xy *= gScreenSize;

gScreenSize 是 float2 吗?我不相信您可以将 vec 与任何 vec 类型进行标量相乘。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-25
    • 2013-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多