Précédent   Forum des professionnels en informatique > Applications > Développement 2D, 3D et Jeux > API graphiques > DirectX
DirectX Forum d'entraide sur le développement avec DirectX. Avant de poster -> FAQ DirectX
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 02/11/2011, 22h01   #1
Invité régulier
 
Inscription : août 2009
Messages : 42
Détails du profil
Informations forums :
Inscription : août 2009
Messages : 42
Points : 6
Points : 6
Par défaut debug shader (directx11)

bonjour a tous j'aimerais savoir comment faire pour debuger mes shaders. Ils m'arrive souvent de rester bloqué une journée entière et que rien ne s'affiche et j'aimerais bien pouvoir observer le comportement de mes shaders pour comprendre d'où viennes mes erreurs.

Je voudrais savoir quels outils existent pour cela.

ps: j'utilise directx11 et le shader model 5.0
kev753 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/11/2011, 22h57   #2
Membre Expert
 
Programmeur
Inscription : août 2002
Messages : 1 034
Détails du profil
Informations personnelles :
Localisation : Etats-Unis

Informations professionnelles :
Activité : Programmeur

Informations forums :
Inscription : août 2002
Messages : 1 034
Points : 1 310
Points : 1 310
Envoyer un message via ICQ à LeGreg
Citation:
Envoyé par kev753 Voir le message
bonjour a tous j'aimerais savoir comment faire pour debuger mes shaders. Ils m'arrive souvent de rester bloqué une journée entière et que rien ne s'affiche et j'aimerais bien pouvoir observer le comportement de mes shaders pour comprendre d'où viennes mes erreurs.

Je voudrais savoir quels outils existent pour cela.

ps: j'utilise directx11 et le shader model 5.0
Tu as PIX (dispo dans le SDK microsoft), mais surtout NVIDIA parallel nsight :
http://developer.nvidia.com/nvidia-parallel-nsight

Ceci dit si ces outils sont pratiques ce sont surtout pour des problèmes "avancés", avant qu'ils n'existent il y a la bonne vieille méthode de partir de quelque chose qui marche et trouver de manière systématique à partir de quand tu as introduit quelque chose qui a fait que ça ne marche pas.
__________________

Mon site web | Mon blog | Mes photos | Groupe USA
> BONJOUR, JE SUIS NOUVEAU SUR CE FORUM
> presse la touche caps lock, stp
> OH.. MERCI C EST BEAUCOUP PLUS FACILE COMME CA
LeGreg est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 02/11/2011, 23h29   #3
Invité régulier
 
Inscription : août 2009
Messages : 42
Détails du profil
Informations forums :
Inscription : août 2009
Messages : 42
Points : 6
Points : 6
Citation:
Envoyé par LeGreg Voir le message
Tu as PIX (dispo dans le SDK microsoft), mais surtout NVIDIA parallel nsight :
http://developer.nvidia.com/nvidia-parallel-nsight
j'ai un peu de mal a comprendre l'utilité de nsight.

ici par exemple j'ai un shader qui a pour but de "smoother" un mesh, j'ai démaré d'un shader qui fonctionne je n'ai chagé que le domain shader :

Domain shader
voici la seule ligne que j'ai changé :
Code :
output.positionWS = uv.y * (inputPatch[0].position * uv.x + inputPatch[1].position * (1 - uv.x)) + (1 - uv.y) * (inputPatch[3].position * uv.x + inputPatch[2].position * (1 - uv.x));
en ça :
Code :
output.positionWS = caluculateUVSpline( inputPatch[0].position, inputPatch[1].position, inputPatch[3].position, inputPatch[2].position, inputPatch[0].normal, inputPatch[1].normal, inputPatch[3].normal, inputPatch[2].normal, uv.x, uv.y);
et voicis les fonctions qui permettent de calculer les points :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
float4x4 getMatrixByAxisRot(float3 Axis, float angle)
{
    double _11 = 0, _12 = 0, _13 = 0;
    double _21 = 0, _22 = 0, _23 = 0;
    double _31 = 0, _32 = 0, _33 = 0;
    angle *= PI / 180;
 
    float c = floor(cos(angle) * 100000000) / 100000000;
    float s = floor(sin(angle) * 100000000) / 100000000;
    float t = 1 - c;
    float x = Axis.x;
    float y = Axis.y;
    float z = Axis.z;
 
    _11 = t * x * x + c;
    _12 = t * x * y - (z * s);
    _13 = t * x * z + (y * s);
    _21 = t * x * y + (z * s);
    _22 = t * y * y + c;
    _23 = t * y * z - (x * s);
    _31 = t * x * z - (y * s);
    _32 = t * y * z + (x * s);
    _33 = t * z * z + c;
 
    float4x4 m = float4x4 (_11, _12, _13, 0, _21, _22, _23, 0, _31, _32, _33, 0,   0,   0,   0, 1);
    m = float4x4 (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,   0,   0,   0, 1);
 
    return m;
}
float3 getRotAlongAxis(float3 norm, float3 axis, float angle)
{
    float4x4 rotMat = getMatrixByAxisRot(axis, angle);
    return (mul(rotMat, float4(norm,0))).xyz;
}
float3 straightNormals(float3 p1, float3 p2, float3 p3, float3 p4)
{
    float3 v1 = p2 - p1;
    float3 v2 = p3 - p1;
    float3 normal1 = cross(v1,v2);
 
    float3 v3 = p3 - p4;
    float3 v4 = p2 - p4;
    float3 normal2 = cross(v3,v4);
 
    return normalize(normalize(normal1) + normalize(normal2));
}
float3 CalculateBezierPoint(float3 pt1, float3 pt2, float3 N1, float3 N2, float amount)
{
    amount /= 100.0f;
 
    float3 func1 = cube(1-amount) * pt1; //first term
    float3 func2 = 3 * care(1-amount) * amount * N1; //second term
    float3 func3 = 3 * (1-amount) * care(amount) * N2; //third term
    float3 func4 = cube(amount) * pt2; //fourth term
 
    return func1 + func2 + func3 + func4;
}
 
float3 caluculateUVSpline(float3 pt1, float3 pt2, float3 pt3, float3 pt4, float3 N1, float3 N2, float3 N3, float3 N4, float U, float V)
{
    float3 UA, UB, UNA, UNB, axis;
	axis = straightNormals(pt1, pt2, pt3, pt4);
	axis = float3(0,0,0);
    UNA = lerp(getRotAlongAxis(N1, axis, 90), getRotAlongAxis(N2, axis, -90), U / 100);
    UNB = lerp(getRotAlongAxis(N3, axis, -90), getRotAlongAxis(N4, axis, 90), U / 100);
 
    UA = CalculateBezierPoint(pt1, pt2, getRotAlongAxis(N1, axis, -90) + pt1, getRotAlongAxis(N2, axis, 90) + pt2, U);
    UB = CalculateBezierPoint(pt3, pt4, getRotAlongAxis(N3, axis, 90) + pt3, getRotAlongAxis(N4, axis, -90) + pt4, U);
 
    return CalculateBezierPoint(UA, UB, UNA + UA, UNB + UB, V);
}
j'ai testé ces fonctions en csharp (avec une petite adaptation evidement)
et là, ça fonctionne très bien ! je ne comprend pas d'où vient mon erreur

ce serais génial si je pouvais analisé ligne par ligne la valeur des variables ....

PS: je sais qu'il y a certaines parties qui ne sont pas très optimisées mais j’essaie d’abord de faire fonctionner ce shader je m'occuperais après des performances
kev753 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/11/2011, 09h27   #4
Membre Expert
 
Inscription : février 2006
Messages : 1 395
Détails du profil
Informations forums :
Inscription : février 2006
Messages : 1 395
Points : 2 074
Points : 2 074
à première vue, je dirai qu'il faut faire doublement attention aux casts implicites de fxc, ie, si a une place on a besoin d'un float alors on ajoute le suffixe pour les floats, etc.

donc par exemple il ne faut pas mettre U / 100 mais U / 100.0f .



ça évite bien souvent des surprises. et pour être sur de ce que fait le shader, il faut regarder le code en assembleur en sortie du compilateur, ça permet d'identifier par exemple des casts non souhaités ou autre.
stardeath est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/11/2011, 12h54   #5
Invité régulier
 
Inscription : août 2009
Messages : 42
Détails du profil
Informations forums :
Inscription : août 2009
Messages : 42
Points : 6
Points : 6
merci pour la réponse j'ai repéré ces erreurs apres avoir poster le message, maintenant ca s'affiche mais il y a quand meme de tres gros bug voicis mon shader maintenant :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 
 
float3 getRotAlongAxis(float3 norm, float3 axis, float angle)
{
	float3 retour ;
    float _11, _12, _13;
    float _21, _22, _23;
    float _31, _32, _33;
	float c, s, t, x, y, z;
    angle *= PI / 180;
 
    c = floor(cos(angle) * 100000000) / 100000000;
    s = floor(sin(angle) * 100000000) / 100000000;
    t = 1 - c;
    x = axis.x;
    y = axis.y;
    z = axis.z;
 
    _11 = t * x * x + c;
    _12 = t * x * y - (z * s);
    _13 = t * x * z + (y * s);
    _21 = t * x * y + (z * s);
    _22 = t * y * y + c;
    _23 = t * y * z - (x * s);
    _31 = t * x * z - (y * s);
    _32 = t * y * z + (x * s);
    _33 = t * z * z + c;
 
    retour.x = norm.x * _11 + norm.y * _21 + norm.z * _31;
    retour.y = norm.x * _12 + norm.y * _22 + norm.z * _32;
    retour.z = norm.x * _13 + norm.y * _23 + norm.z * _33;
 
    return retour;
}
float3 straightNormals(float3 p1, float3 p2, float3 p3, float3 p4)
{
	float3 v1, v2, normal1, normal2;
    v1 = p2 - p1;
    v2 = p3 - p1;
    normal1 = cross(v1,v2);
 
    v1 = p3 - p4;
    v2 = p2 - p4;
    normal2 = cross(v1,v2);
 
    return normalize(normalize(normal1) + normalize(normal2));
}
float3 CalculateBezierPoint(float3 pt1, float3 pt2, float3 N1, float3 N2, float amount)
{
	float func1, func2, func3, func4;
 
    func1 = cube(1-amount) * pt1; //first term
    func2 = 3 * care(1-amount) * amount * N1; //second term
    func3 = 3 * (1-amount) * care(amount) * N2; //third term
    func4 = cube(amount) * pt2; //fourth term
 
    return func1 + func2 + func3 + func4;
}
 
float3 caluculateUVSpline(float3 pt1, float3 pt2, float3 pt3, float3 pt4, float3 N1, float3 N2, float3 N3, float3 N4, float U, float V)
{//*
    float3 UA, UB, UNA, UNB, axis;
	axis = straightNormals(pt1, pt2, pt3, pt4);
	//axis = float3(0,0,0);
    UNA = lerp(getRotAlongAxis(N1, axis, 90), getRotAlongAxis(N2, axis, -90), U);
    UNB = lerp(getRotAlongAxis(N3, axis, -90), getRotAlongAxis(N4, axis, 90), U);
 
    UA = CalculateBezierPoint(pt1, pt2, getRotAlongAxis(N1, axis, -90) + pt1, getRotAlongAxis(N2, axis, 90) + pt2, U);
    UB = CalculateBezierPoint(pt3, pt4, getRotAlongAxis(N3, axis, 90) + pt3, getRotAlongAxis(N4, axis, -90) + pt4, U);//*/
	//return V * (pt1 * U + pt2 * (1 - U)) + (1 - V) * (pt4 * U + pt3 * (1 - U));
    return CalculateBezierPoint(UA, UB, UNA + UA, UNB + UB, V);
	//return CalculateBezierPoint(UA, UB, UNA + UA, UNB + UB, V);
	//return Bilerp(pt1, pt2, pt3, pt4, float2(U,V));
}
et pour l'assembleur vous auriez des tuto qui permettent d'analyser le code ?
kev753 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/11/2011, 15h38   #6
Membre Expert
 
Programmeur
Inscription : août 2002
Messages : 1 034
Détails du profil
Informations personnelles :
Localisation : Etats-Unis

Informations professionnelles :
Activité : Programmeur

Informations forums :
Inscription : août 2002
Messages : 1 034
Points : 1 310
Points : 1 310
Envoyer un message via ICQ à LeGreg
Citation:
Envoyé par kev753 Voir le message
j'ai un peu de mal a comprendre l'utilité de nsight.
ben regarde les videos et installe le logiciel, il est disponible gratuitement.
__________________

Mon site web | Mon blog | Mes photos | Groupe USA
> BONJOUR, JE SUIS NOUVEAU SUR CE FORUM
> presse la touche caps lock, stp
> OH.. MERCI C EST BEAUCOUP PLUS FACILE COMME CA
LeGreg est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 12h57.


 
 
 
 
Partenaires

Hébergement Web