error: llvm::cast<X>() argument of incompatible type! only with ShaderModel 6.6 and above

Ouverte
#9,028 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
30/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
cpp
Domaine
compilers

Piste de recherche

Reproduce the crash by compiling the attached compute shader with -T cs_6_6 and comparing against -T cs_6_5 to confirm the shader-model gate. The llvm::cast assertion means the backtrace from a debug build should point to the pass that fails. Done means the shader compiles at 6.6 without the error, with a regression test added. The issue names no source files, so locating the pass is the first real task.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug needs-triage

Description
Getting a llvm::cast error when compiling a shader with shader model 6.6 or above.

Steps to Reproduce
Please visit https://godbolt.org/z/nKMbf1xqr
or compile the following compute shader (with "-T cs_6_6")

`struct SourceInfo__Constants
{
float2 textureOffsets;
};
struct SourceInfo
{
SourceInfo__Constants constants;
};
SourceInfo CreateSourceInfo_(SourceInfo__Constants constants)
{
SourceInfo i;
i.constants = constants;
return i;
}
struct CommonParams__Constants
{
SourceInfo__Constants depthSepthSourceInfo;
};
cbuffer CommonParams_cbuffer { CommonParams__Constants CommonParams__constants; };
Texture2D tex_test;
SamplerState pointClamp;

[numthreads(64, 1, 1)]
void main()
{
uint depthTextureCount = 10;
const uint flags = asuint(depthTextureCount);
float3 startParams;
uint textureID = ~0;

for (uint i = 0; i < depthTextureCount; ++i)
{
	startParams.x = 0;
	if (startParams.z > 0.0f)
		textureID = 0;
}

if (textureID == 0)
{
	bool collideWithStaticDisabled = !((flags >> 15) & 1);

	if (collideWithStaticDisabled )
	{
		bool isCharacter = false;
		if (collideWithStaticDisabled && !(isCharacter))
			return;
	}
}

SourceInfo sourceInfo = CreateSourceInfo_(CommonParams__constants.depthSepthSourceInfo);

if (textureID == 0)
    float3 normal = float3(0,0,0);

float4 p = tex_test.SampleLevel(pointClamp, sourceInfo.constants.textureOffsets.xy, 0);

}
`

Actual Behavior
The following error is reported:
error: llvm::cast() argument of incompatible type!

Note that the provided shader is completely bogus and is a massive simplification from a much larger shader.
Also note that there are all kinds of changes that can be done to the provided shader that "fix" the problem:
-Moving textureOffsets directly in SourceInfo
-Moving the declaration of SourceInfo sourceInfo to after the following "if"
-Removing "if (textureID == 0)" statements
-and others

Environment

  • DXC versions:
    official release: dxcompiler.dll: 1.9(5512-01b62ad4)(1.9.2609.5) - 1.9.2609.5 (01b62ad47)
    locally built trunk version: dxcompiler.dll: 1.11(1-78d896ef)(1.10.0.10001) - 1.10.0.10001 (main, 78d896ef)
  • Host Operating System Windows 11 24h2
Langage dominant
C++
Étoiles
3.7k
Forks
926
Merge moyen
3 j 22 h
PR mergées (30 j)
45

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/DirectXShaderCompiler

Toutes les issues de microsoft/DirectXShaderCompiler

Issues similaires

Plus d'issues C++

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.