IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

DirectX Discussion :

debug shader


Sujet :

DirectX

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Août 2009
    Messages
    42
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Août 2009
    Messages : 42
    Par défaut debug shader
    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

  2. #2
    Membre Expert

    Profil pro
    Programmeur
    Inscrit en
    Août 2002
    Messages
    1 091
    Détails du profil
    Informations personnelles :
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Programmeur

    Informations forums :
    Inscription : Août 2002
    Messages : 1 091
    Par défaut
    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

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Août 2009
    Messages
    42
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Août 2009
    Messages : 42
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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

  4. #4
    Membre extrêmement actif

    Profil pro
    Inscrit en
    Février 2006
    Messages
    2 408
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 2 408
    Par défaut
    à 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.

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Août 2009
    Messages
    42
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Août 2009
    Messages : 42
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 ?

  6. #6
    Membre Expert

    Profil pro
    Programmeur
    Inscrit en
    Août 2002
    Messages
    1 091
    Détails du profil
    Informations personnelles :
    Localisation : Etats-Unis

    Informations professionnelles :
    Activité : Programmeur

    Informations forums :
    Inscription : Août 2002
    Messages : 1 091
    Par défaut
    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

Discussions similaires

  1. Doc sur Debug de Ms-Dos
    Par gtr dans le forum Assembleur
    Réponses: 13
    Dernier message: 23/09/2003, 09h06
  2. [debug] fuites mémoires
    Par tmonjalo dans le forum C
    Réponses: 3
    Dernier message: 28/07/2003, 17h20
  3. Vertex et Pixel Shader
    Par Riko dans le forum OpenGL
    Réponses: 2
    Dernier message: 06/06/2003, 16h45
  4. carte graphique et pixels shader
    Par yeeep dans le forum DirectX
    Réponses: 2
    Dernier message: 26/04/2003, 10h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo