Jump to content
  • Advertisement

directx user

Member
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

155 Neutral

About directx user

  • Rank
    Member
  1. directx user

    X3000 using enum in hlsl shader

    Well thats unfortunate, I dont know why enum is listed in the msdn then.  http://msdn.microsoft.com/en-us/library/windows/desktop/bb509569(v=vs.85).aspx   Maybe they are only reserving it to implement it later.But anyway thx for the quick explanation.   But anyway I dont know, why it would be so difficult to implement something simple as enums, which is only a mater of replacing strings with numbers.
  2. Hi,   I am building an Algorithm, which is suposed to run on both, the cpu and the gpu. It would be really usefull if I could just use my enum in the shaders header file and could just include it in both, my cpp and the hlsl shader itself (enum determines which function is going to be executed). But Unluckily I always get the error X3000 unexspected token when i try to use enums in my shader.   On the internet I read that enum is a reserved keyword for HLSL though I found very few examples of HLSL Code using enums, it should be possible or am I wrong?   Not even this hlsl file compiles: enum { test1, test2}; [numthreads(8, 1, 1)] void CS_NEW( uint ID : SV_DispatchThreadID ) { } I am using the Inbuild HLSL Compiler from Visual Studio 2012, am I the only one having this Issue?
  3. directx user

    Exceptions using createcomputeshader

    Thank you very much, I didn´t even validated the device pointer, as I knew my other Shaders compiled fine with the device. I unluckily forgot there to be another device declared inside the class overwriting the definition of the one outside the scope of the class. The devicepointer was not assigned to that one yet and was a zero pointer...   Thank you very much for that hint, now I feel really bad having bothered you two with this laughable problem .       Besides from that, does anyone has a clue why I end up getting those redefinition warnings after transfering visual c++ 2010 projects to visual studio 2012?
  4. directx user

    Exceptions using createcomputeshader

    Unluckily even when everything except the naked function body is commented i get the same results (the compiled length decreased so I guess its updating the file), even though the array is still pretty large with 1000 lines of code, while everything thats left is: [numthreads(128, 1, 1)] void BACKPROPAGATE( uint ID : SV_DispatchThreadID  ) { } There are no erros or warnings being displayed about the shader file.   But I have extremly many warnings about makro redefinitions in the context of directx(80) which could eventually aflict that case (I have those warnings since I exported my project from visual c++ 2010 to visual studio 2012). I dont really knwo why.
  5. directx user

    Exceptions using createcomputeshader

    I added the shader definition. I thought the Array would be fixed size, since its getting written into the header file while compiling the project, its definition is const BYTE backpropshader[] = { ...... tons of code...... } so I thought I could just use its size to feed the function, relying on the msdn:   http://msdn.microsoft.com/en-us/library/windows/desktop/bb509633%28v=vs.85%29.aspx#compiling_at_build_time_to_header_files   I thought the blob method would only be used when creating the shader at runtime using compileshaderfromfile for example?
  6. Hi guys,   I am working in Visual Studio 2012 and I need to create a computeshader, which is with its 250 lines quite big, so i decided to precreate it with the inbuild HLSL compiler by generating a header file. The compiler didnt complained at all and the binary Array just got created, but if i want to bind the data to a shader object uisng the line: device->CreateComputeShader(backpropshader, sizeof(backpropshader), NULL, &berechner); backpropshader being the binary buffer in the header file, the Application raises an acess violation Exception. Does anyone know how this Exception could arise? I am also concerned about the binary array to be 23 thousand lines long, is that normal?   the Shader is suposed to use the Backpropagation algorithm on several neuronal systems parallely: This is the Shader reduced to a few lines, I hope its understandable though many of the variablenames are german.   cbuffer konstanten : register(b0) {     uint systemcount;     uint neuronencount;     uint ausgaenge;     uint eingaenge;     uint vorgabensegment;     uint vorgabencount;     uint aufgabencount;     uint lernschritte;     uint lernstaerke; }; struct Verbindung {     uint start;     uint ende;     float gewicht; }; struct neurondaten {     float eingabe;     float ausgabe;     uint transfermodus;     float fehler; }; StructuredBuffer<float> Vorgabentemplate : register(u0); RWStructuredBuffer<Verbindung> Verbindungen : register(u1); RWStructuredBuffer<neurondaten> Neurone : register(u2); void PROPAGATE(uint basisvorgabe, uint basisneuron, uint basisverbindung, uint endverbindung) {     Neurone[basisneuron].ausgabe = 1.0f; //Biasneuron gleich setzen     for (unsigned int einschreib1 = 1; einschreib1 < eingaenge; einschreib1++)     {         Neurone[basisneuron + einschreib1].ausgabe = Vorgabentemplate[basisvorgabe + einschreib1 - 1];     }     for (unsigned int einschreib2 = 1 + eingaenge; einschreib2 < neuronencount; einschreib2++)     {         Neurone[basisneuron + einschreib2].eingabe = 0;         Neurone[basisneuron + einschreib2].fehler = 0;     }     //Neurone sind im Grundzustand     for (unsigned int i = basisverbindung; i < endverbindung; i++)     {         if (Verbindungen[i].start == Verbindungen[i].ende)         {             switch (Neurone[Verbindungen[i].start].transfermodus)             {                  ....................             }         }         else         {             Neurone[Verbindungen[i].ende].eingabe += Neurone[Verbindungen[i].start].ausgabe * Verbindungen[i].gewicht;         }     } } [numthreads(128, 1, 1)] void BACKPROPAGATE( uint ID : SV_DispatchThreadID  ) {     if (ID < systemcount)     {         float restfehler = 0;         uint basisneuron = neuronencount * ID;         uint basisverbindung = aufgabencount * ID;         uint endbasisverbindung = aufgabencount * (ID + 1);         for (unsigned int durchgang = 0; durchgang < lernschritte; durchgang++)         {             restfehler = 0;             uint basisvorgabe = 0;             for (unsigned int vorgabenzaehler = 0; vorgabenzaehler < vorgabencount; vorgabenzaehler++)             {                 PROPAGATE(basisvorgabe,basisneuron,basisverbindung, endbasisverbindung);                 for (unsigned int fehlerstart = neuronencount - ausgaenge; fehlerstart < neuronencount; fehlerstart++)                 {                     Neurone[basisneuron + fehlerstart].fehler = Neurone[basisneuron + fehlerstart].eingabe - Vorgabentemplate[basisvorgabe + eingaenge];                     restfehler += Neurone[basisneuron + fehlerstart].fehler * Neurone[basisneuron + fehlerstart].fehler;                 }                                for (unsigned int i = endbasisverbindung - 1; i-- > basisverbindung;)                 {                     if (Verbindungen[i].start == Verbindungen[i].ende) //refreshe den fehler                     {                         switch (Neurone[Verbindungen[i].start].transfermodus)                         {                             ..........                         }                     }                     else                     {                         Verbindungen[i].gewicht -= lernschritte * Neurone[Verbindungen[i].ende].fehler * Neurone[Verbindungen[i].start].ausgabe;                         Neurone[Verbindungen[i].start].fehler += Neurone[Verbindungen[i].ende].fehler * Verbindungen[i].gewicht;                     }                 }                 basisvorgabe += vorgabensegment;             }         }           } }  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!