XNA Creators Club Online
Page 1 of 1 (10 items)
Sort Posts: Previous Next

D3DX10CreateEffectFromMemory bug?

Last post 03-08-2008 4:18 PM by jogshy. 9 replies.
  • 01-11-2008 3:54 PM

    D3DX10CreateEffectFromMemory bug?

    Hiya,

    i'm trying to use a Dx10 shader compiled from the FXC tool.

    I'm using a shared pool, offline-compiled as:

    fxc /T fx_4_0 /O3 /Zpc /Ges /Fh FXShared.hxx /Vn FXShared FXShared.fxh

    and a child effect compiled as:

    fxc /T fx_4_0 /O3 /Zpc /Ges /Fh FXBillboard.hxx /Vn FXBillboard FXBillboard.fx 

    My first answer is... why I cannot use the /Gch with my FXBillboard shader? FXC gives me this message:

    1>Microsoft (R) D3D10 Shader Compiler 9.19.949.2106
    1>Copyright (C) Microsoft Corporation 2002-2007. All rights reserved.
    1>compilation succeeded; see D:\xn3wi\x86\plugins\DX10Effects\FXGrid.fxo
    1>failed writing d:\DX10GDrv\DX10GDrv\FXBillboard.hxx
    1>Microsoft (R) D3D10 Shader Compiler 9.19.949.2106
    1>Copyright (C) Microsoft Corporation 2002-2007. All rights reserved.
    1>Failed to load effect. Error messages may have been sent to the debug output. Run FXC through a debugger to view.

    It seems the /Gch ( compile as child effect ) is only valid compiling the shader into a FXO file ( /Fo option ).

    Ok... so I removed the /Gch and compiled ok... but now when I call the

    ::D3DX10CreateEffectFromMemory((void*)FXBillboard,sizeof(FXBillboard),NULL,
    NULL,NULL,"fx_4_0",0,D3D10_EFFECT_COMPILE_CHILD_EFFECT,m_pD3DDev,m_pFXPool,NULL,
    &m_pBillboardFX,&l_pBlob,NULL);

    but it fails... ( and no info is returned in the blob ). So my question is... anybody can post a complete code to load from memory an offline-compiled effect + pool and the batch command line to use the /Fh and /Gch together, pls?

    thx

  • 01-12-2008 2:57 PM In reply to

    Re: D3DX10CreateEffectFromMemory bug?

    To create an effect from an precompiled source you need to use D3D10CreateEffectFromMemory instead of D3DX10CreateEffectFromMemory .

     

     

  • 01-12-2008 5:54 PM In reply to

    Re: D3DX10CreateEffectFromMemory bug?

    Well, I tryed with D3D10CreateEffectFromMemory also and got an E_FAIL error when I try to create the pool. Is strange but I found this in the D3D10effect.h file from the DirectX SDK November 2007:

    //----------------------------------------------------------------------------
    // D3D10CreateEffectFromXXXX:
    // --------------------------
    // Creates an effect from a binary effect or file
    //
    // Parameters:
    //
    // [in]
    //
    // TODO: Unicode support
    // TODO: Support for binary (and not just ASCII)

     

    The effect I'm trying to create is "binary", because was offline-precompiled using the FXC.

    My pool was compiled ok using the following command line:

     

    fxc /T fx_4_0 /O3 /Zpc /Ges /Fh FXShared.hxx /Vn FXShared FXShared.fxh
     
     
     
    And the FXShared.fx code is just:
     
     
     
    shared cbuffer cbPerFrame
    {
      float4 g_lightPos;
      float4 g_lightAmbientCol, g_lightDiffCol, g_lightSpecCol;
    };
     
     
     
     
    It fails (E_FAIL) when I try to create the fx pool as:
     
     
     
     
    HRESULT hr = ::D3D10CreateEffectPoolFromMemory ( (void*)FXShared,
     sizeof(FXShared), 0, m_pD3DDev, &m_sPool.pool );

    Is curious too that the debug layer does not emit any information about why that failed. From the docs I can see E_FAIL's description:

    E_FAIL 
    An undetermined error occurred inside the Direct3D subsystem.

    Which leads me to think that the D3D10CreateEffectFromMemory are not implemented to read binary offline-compiled shaders yet?

    The FXC fails also when I try to compile a child effect to a .hxx file using the /Gch option... and without that the D3D10CreateEffectFromMemory() probably will fail if I use the pool...

    I tryed to find some example about all this but seems there are only "load from file" calls in the SDK examples 8(

    thx

  • 01-13-2008 6:56 AM In reply to

    Re: D3DX10CreateEffectFromMemory bug?

    I missed that you try to create an effect pool. In this case you need to use D3D10CreateEffectPoolFromMemory.

  • 01-14-2008 10:36 PM In reply to

    Re: D3DX10CreateEffectFromMemory bug?

    Demirug:

    I missed that you try to create an effect pool. In this case you need to use D3D10CreateEffectPoolFromMemory.

    Well, i'm using

     

    ::D3D10CreateEffectPoolFromMemory ( (void*)FXShared, sizeof(FXShared), 0, 
    m_pD3DDev, &pool );

     

    The supersimple pool is:


    shared cbuffer cbPerFrame
    {
    float4 g_lightPos;
    };

     

    and returns a E_FAIL... i'm starting to thing it's a bug because with .fxo files and D3DX works perfectly...

    And why it does not emit any error on the OutputDebugString window if I enabled the SDK debug device layer with all the error IDs active?


    This is making me crazy! Grrrrrrrrrrrrrrrrrrr bark grrrrrrrrrr!


     

  • 01-15-2008 1:05 PM In reply to

    Re: D3DX10CreateEffectFromMemory bug?

    Answer

    I found the problem.

    The FXC generated data block is invalid. Your compiled shared effect needs only 398 bytes. FXC pads it to 400 bytes. Therefore you provide 2 bytes more than D3D10CreateEffectPoolFromMemory can parse. This causes the E_FAIL.

    As a workaround until FXC is fixed you may use D3DX10CompileFromFile and save the result by your own.

  • 01-15-2008 1:31 PM In reply to

    Re: D3DX10CreateEffectFromMemory bug?

    Demirug:

    I found the problem.

    The FXC generated data block is invalid. Your compiled shared effect needs only 398 bytes. FXC pads it to 400 bytes. Therefore you provide 2 bytes more than D3D10CreateEffectPoolFromMemory can parse. This causes the E_FAIL.

     

    You're right, many thx! It works ok with

     

    ::D3D10CreateEffectPoolFromMemory ( (void*)FXShared, sizeof(FXShared)-3, 
    D3D10_EFFECT_SINGLE_THREADED, m_pD3DDev, &pool );

    also with

     

    D3DX10CreateEffectPoolFromMemory ( (void*)FXShared, 
    sizeof(FXShared)-3, "FXShared", NULL, NULL, "fx_4_0", 0,
    D3D10_EFFECT_SINGLE_THREADED, m_pD3DDev, NULL, &pool,
    &l_pBlobErr, NULL );

     

    The /fo FXO file and the sizeof(The/Fh one) differs by 2 or 3 bytes. 3 bytes with a more complex shared cbuffers and samplers. It's a FXC bug, that's for sure. Did you filled an official bug report in the MVP's channel or wanna me to fill one via Connect?

     

    Btw, now I have other problem... Now I wanna create a child effect to use it with the /Fh pool from memory... This is what I use to compile:

    fxc /T fx_4_0 /O3 /Zpc /Ges /Gch /Fh FXOverlay.hxx /Vi /Vn FXOverlay FXOverlay.fx 

     

    But for some strange reason I'm getting this weird error:

    1>failed writing d:\DX10GDrv\DX10GDrv\FXOverlay.hxx
    1>Microsoft (R) D3D10 Shader Compiler 9.19.949.2106
    1>Copyright (C) Microsoft Corporation 2002-2007. All rights reserved.
    1>Opening file [FXShared.fxh], stack top [1]
    1>Current working dir [d:\DX10GDrv\DX10GDrv\]
    1>Resolved to [d:\DX10GDrv\DX10GDrv\FXShared.fxh]
    1>Failed to load effect. Error messages may have been sent to the debug output.
    Run FXC through a debugger to view.
     

     

    it seems the current FXC version cannot compile childs effects (/Gch) with the /Fh param? Perhaps other nasty FXC bug or do I need to compile it without the /Gch and specify the  D3D10_COMPILE_CHILD_EFFECT in the D3D10CreateEffectFrom memory? Btw, I'm using

     

    #include "FXShared.fxh"

     

    at the start of the FXOverlay.fx

     

     

  • 01-15-2008 2:06 PM In reply to

    Re: D3DX10CreateEffectFromMemory bug?

    Answer

    I fear you found another fxc bug. It looks like that it compiles the effect as a child effect as requested. Then it tries to create the effect but this fails as a child effect needs the pool. The effect creation is done because the Fh option writes the effect not only as tokens but as disassemble code, too.

    I will report this with the other bug. But it may be already a little bit to late for the next SDK release.

    As workaround you may use the Fo option and a Bin2C tool.

  • 01-15-2008 2:17 PM In reply to

    Re: D3DX10CreateEffectFromMemory bug?

    Demirug:

    I fear you found another fxc bug

    Hahahha! It seems i'm an excellent bug tester hahah! :D

     

    Demirug:

    I will report this with the other bug. But it may be already a little bit to late for the next SDK release.

    I think the next SDK gonna be released by March 2008 so perhaps they have time to fix it.

    Well, thanks for all Demi!

  • 03-08-2008 4:18 PM In reply to

    Re: D3DX10CreateEffectFromMemory bug?

    The march 2008 SDK does not solve the problems....
Page 1 of 1 (10 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG