错误 X3503:'main_Impl':函数 return 值缺少 "d2d1effecthelpers.hlsli" 的语义

error X3503: 'main_Impl': function return value missing semantics with "d2d1effecthelpers.hlsli"

我是 HLSL 的新手,正在尝试使用 HLSL Helpers 编译一个简单的测试,但是,它无法编译。我想为我的 Win2D UWP 应用程序编译着色器。

代码:

#define D2D_INPUT_COUNT 1
#define D2D_INPUT0_SIMPLE
#include "d2d1effecthelpers.hlsli"

D2D_PS_ENTRY(main)
{
    float4 color1 = D2DGetInput(0);

    return color1;
}

用命令行编译时:

fxc /T ps_4_0 /E main_Impl /Fo testShader.ps testShader.hlsl

它给我这个编译错误

error X3503: 'main_Impl': function return value missing semantics

我这里做错了什么?

应该是fxc /T ps_4_0 /D D2D_ENTRY=main /Fo testShader.ps testShader.hlsl.

您 could/should 使用 Visual Studio,它将为您做好基础工作。或者只是打开“d2d1effecthelpers.hlsli”,它会这样说:

// To use these helpers, the following values must be defined before inclusion:

// D2D_INPUT_COUNT - The number of texture inputs to the effect.

// D2D_INPUT[N]_SIMPLE or D2D_INPUT[N]_COMPLEX - How the effect will sample each input. (If unspecificed, defaults to _COMPLEX.)

// D2D_ENTRY - The name of the entry point being compiled. This will usually be defined on the command line at compilation time.