8

私はインストラクター/ラボアシスタントと同様に完全に困惑しています。

何らかの理由で、次の 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

変数を上記のものに置き換えてソリューションをコピーして貼り付けようとしましたが、リストされているのと同じエラーが発生します。

私はまったく困惑しており、この任務を遂行するために助けが必要です。助けてください。

4

1 に答える 1

0

この行をチェックしてください:

point0ClipSpace.xy *= gScreenSize;

gScreenSize は float2 ですか? vec を任意の vec タイプでスカラー乗算できるとは思いません。

于 2014-10-24T02:59:43.350 に答える