We are implementing Multi View Rendering in our In-House engine.
When adding custom semantics to our Pixelshader the Device Hangs.
We are using DirectX 11. If the shaders do not use the semantic it works. If they start using it Hangs.
This is the PixelShader Create code.
wil::com_ptr pixelShader = nullptr;
// Create the pixel shader
NvAPI_D3D11_CREATE_PIXEL_SHADER_EX PSExArgs = {0};
NV_CUSTOM_SEMANTIC semantics[] = {
{NV_CUSTOM_SEMANTIC_VERSION, NV_POSITION_SEMANTIC, "NV_POSITION", false, 0, 0, 0},
{NV_CUSTOM_SEMANTIC_VERSION, NV_GENERIC_ATTRIBUTE_SEMANTIC, "NV_DEPTH", false, 0, 0, 0},
{NV_CUSTOM_SEMANTIC_VERSION, NV_GENERIC_ATTRIBUTE_SEMANTIC, "NV_SCREENPOS", false, 0, 0, 0},
{NV_CUSTOM_SEMANTIC_VERSION, NV_GENERIC_ATTRIBUTE_SEMANTIC, "NV_PIXELWORLDPOS", false, 0, 0, 0},
{NV_CUSTOM_SEMANTIC_VERSION, NV_VIEWPORT_MASK_SEMANTIC, "NV_VIEWPORT_MASK", false, 0, 0, 0},
{NV_CUSTOM_SEMANTIC_VERSION, NV_VIEWPORT_MASK_2_SEMANTIC, "NV_VIEWPORT_MASK_2_SEMANTIC", false, 0, 0, 0}};
static_assert(ARRAYSIZE(semantics) < NV_CUSTOM_SEMANTIC_MAX);
// create pixel shader with NVAPI
PSExArgs.version = NVAPI_D3D11_CREATEPIXELSHADEREX_VERSION;
PSExArgs.NumCustomSemantics = ARRAYSIZE(semantics);
PSExArgs.pCustomSemantics = semantics;
NvAPI_Status result = NvAPI_D3D11_CreatePixelShaderEx_2(device, shaderBuffer->GetBufferPointer(),
shaderBuffer->GetBufferSize(), nullptr, &PSExArgs, &pixelShader);
Here are the structs used in the HLSL shader.
struct VS_OUTPUT
{
float4 position_view0 : SV_POSITION;
#ifdef MVR
float4 position_view1 : NV_POSITION_VIEW_1_SEMANTIC;
#endif
#ifdef MVR_FOUR_SCREEN
float4 position_view2 : NV_POSITION_VIEW_2_SEMANTIC;
float4 position_view3 : NV_POSITION_VIEW_3_SEMANTIC;
#endif
float2 tex : TEXCOORD0;
float2 tex2 : TEXCOORD1;
float4 color : TEXCOORD2;
float3 normal : NORMAL;
float3 tangent : TANGENT;
float3 binormal : BINORMAL;
#ifndef MVR
float4 screenPosition_view0 : TEXCOORD3;
#endif
#ifdef MVR
float4 screenPosition_view0 : NV_SCREENPOS_VIEW_0_SEMANTIC;
float4 screenPosition_view1 : NV_SCREENPOS_VIEW_1_SEMANTIC;
#endif
#ifdef MVR_FOUR_SCREEN
float4 screenPosition_view2 : NV_SCREENPOS_VIEW_2_SEMANTIC;
float4 screenPosition_view3 : NV_SCREENPOS_VIEW_3_SEMANTIC;
#endif
float4 instancecolor : TEXCOORD4;
float4 worldPos : TEXCOORD5;
};
struct GS_OUTPUT
{
VS_OUTPUT Passthrough;
uint4 viewportMask : NV_VIEWPORT_MASK;
#ifdef MVR_FOUR_SCREEN
uint4 viewportMask2 : NV_VIEWPORT_MASK_2_SEMANTIC;
#endif
uint viewportIndex : SV_ViewportArrayIndex;
};