microsoft / microsoft/DirectXShaderCompiler

Have a more explicit error when trying to use a struct member output interpolator as an input

Open
#4,307 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

diagnostic
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Hello
This is a suggestion because I founded that the error given by the compiler was not really explicit when trying a compile a mesh shader.
I made a very minimal repro here, try to compile this file:

// compile with :
// dxc.exe main.hlsl /Zi /E"main" /Od /Fo test.mso /Tms_6_6 -Qembed_debug

struct Vertex {
	float4 m_sv_position : SV_POSITION;
	float m_value : VALUE;
};

[numthreads(128, 1, 1)]
[OutputTopology("triangle")]
void main( out vertices Vertex _vertices[ 64 ] 
	, out indices uint3 _triangles[ 126 ]
	, in uint3 _sv_groupthreadid : SV_GROUPTHREADID )
{
	const float toto = -1.0;

	SetMeshOutputCounts( 64, 126 );

	if ( _sv_groupthreadid.x < 64 ) {
		_vertices[ _sv_groupthreadid.x ].m_sv_position = float4( 0.0, 0.0, 0.0, 0.0 );
		_vertices[ _sv_groupthreadid.x ].m_value = 0;
		_vertices[ _sv_groupthreadid.x ].m_value *= sign( toto );
	}


	if ( _sv_groupthreadid.x < 126 )
	{
		_triangles[ _sv_groupthreadid.x ] = uint3( 1, 2, 3 );
	}
}

With

dxc.exe main.hlsl /Zi /E"main" /Od /Fo test.mso /Tms_6_6 -Qembed_debug

You will get the following error:

main.hlsl:11: error: Function main with parameter is not permitted, it should be inlined. Validation failed.

Which is not very explicit, in a huge shader I would really appreciate to have something like:

main.hlsl:22: error: you use semantic output member m_value as an input which is forbbiden

The same kind of error happen when you use for instance _vertices[ _sv_groupthreadid.x ].m_value as a function parameter even if the parameter of the function is marked as out

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with main.hlsl using the provided dxc.exe mesh-shader command, then trace the validation failure reported as “Function main with parameter is not permitted.” Done means the compiler emits a diagnostic identifying the struct member output interpolator used as an input, including the relevant member or source location, with coverage for the shown repro and function-parameter case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.