Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 2 (27 posts) 1 2 Next >

I can't find the d3dx11 effect framework

Last post 3/3/2010 2:00 AM by pisiiki. 26 replies.
  • 9/11/2009 10:21 PM

    I can't find the d3dx11 effect framework

    I have just updated the sdk to aug09 but it seems that the d3dx11 effect framework is not included with this release (but referenced in the help files). I am a bit confused, please clarity me what is going on.

    Isaac.
  • 9/11/2009 10:30 PM In reply to

    Re: I can't find the d3dx11 effect framework

    Answer
    Reply Quote
    It's provided as source in Utilities\Source\Effects11.
  • 9/12/2009 2:25 PM In reply to

    Re: I can't find the d3dx11 effect framework

    Built and working :)

    thank you,

    Isaac Lascasas.
  • 9/12/2009 5:46 PM In reply to

    Re: I can't find the d3dx11 effect framework

    All good and well but still I don't see how I can compile an Effect with it. An anlalog to D3DX10CreateEffectFromFile is absent, and looks like you're supposed to use first D3DX11CompileFromFile and then D3DX11CreateEffectFromMemory (?).
    Not sure about the parameter values to pass to those, though (like what is the entry point funktion if it's not a single shader but an effect?)

    I'd be most thankful if anybody could post a working code snippet.
  • 9/15/2009 5:48 PM In reply to

    Re: I can't find the d3dx11 effect framework

    i got here the same problem. with help of the debug layer i gain following line:
    "Effects11: Effect version is unrecognized.  This runtime supports fx_5_0 to fx_5_0."
    question now, how can a reach such a version and it is possible to create such a version on dx10 hardware (fx_4_0 is needed)?
    very confusing...
  • 9/15/2009 7:34 PM In reply to

    Re: I can't find the d3dx11 effect framework

    i think i have a solution. here the code:

    -> c++
        // Compile effect 
        if(FAILED(D3DX11CompileFromMemory((const bWcharP)_file->getContent(), _file->getSize(), wideCharToMultiByte(_file->getSourcePath()).c_str(), dxMacro, include, """fx_5_0", D3D10_SHADER_OPTIMIZATION_LEVEL0 | D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY | D3D10_SHADER_DEBUG, 0, 0, &shaderCode, &error, 0))) 
        { 
            if(error) 
            { 
                std::string test = reinterpret_cast<char*>(error->GetBufferPointer()); 
                MessageBoxA(windowData.windowHandle, test.c_str(), "Effect_Error", MB_OK); 
                error->Release(); 
            } 
     
            if(dxMacro) 
            { 
                deleteMemory(dxMacro); 
                dxMacro = 0; 
            } 
            if(include) 
            { 
                deleteMemory(include); 
                include = 0; 
            } 
     
            logTemplate(eResult_Error, L"compile effect", D_BLUEW_FILE, D_BLUEW_FUNCTION, D_BLUEW_LINE, (const bWwcharP)_file->getSourcePath().c_str()); 
            return eResult_CreateEffect; 
        } 
     
        // Create effect 
        if(FAILED(D3DX11CreateEffectFromMemory(shaderCode->GetBufferPointer(), shaderCode->GetBufferSize(), 0, d3d11Device, &dxEffect))) 
        { 
            if(dxMacro) 
            { 
                deleteMemory(dxMacro); 
                dxMacro = 0; 
            } 
            if(include) 
            { 
                deleteMemory(include); 
                include = 0; 
            } 
     
            logTemplate(eResult_Error, L"create effect", D_BLUEW_FILE, D_BLUEW_FUNCTION, D_BLUEW_LINE, (const bWwcharP)_file->getSourcePath().c_str()); 
            return eResult_CreateEffect; 
        } 

    -> shader - technique
    technique11 Test 
        pass P0 
        { 
            SetVertexShader(CompileShader(vs_4_0, vShader())); 
            SetGeometryShader(0); 
            SetPixelShader(CompileShader(ps_4_0, pShader()));    
        SetRasterizerState(rState); 
        SetDepthStencilState(dStencil, 0); 
        } 

    it has to be "fx_5_0" in the d3dx11 function and technique11 in the shader, but you have to declare the functions "pixelShader", "vertexShader"... as ps_4_0, vs_4_0 and so on (if required .._4_1...)

    i'm hoping i could help a little bit :)

    EDIT (22.23):
    An effect is created by loading the compiled effect bytecode into the effects framework. Unlike Effects 10, the effect must be compiled before creating the effect. Effects loaded into memory can be created by calling D3DX11CreateEffectFromMemory"
  • 9/20/2009 11:01 PM In reply to

    Re: I can't find the d3dx11 effect framework

    Ive gotten the effects to compile and create, but any technique that includes a shader, even a trivial one, comes back as invalid (all techniques and passes returning false for IsValid()).  The D3DX11CreateEffectFromMemory function also causes a first-chance exception "Microsoft C++ exception: _com_error at memory location 0x060df3e4.." to get logged into the debug output.  I stepped through the source of the effects framework and traced it to line 1272 of EffectNonRuntime.cpp, which is a call to a pCreateShader function pointer that is returning HR_INVALIDARGS.  Thats all the information I can get, it seems the exception is being caught and logged internally by the DirectX runtime so I can't access its contents.

    Compiling the same shaders by themselves causes no problem, and my technique code is identical to yours.  The only difference in my app code is that I use D3DX11CompileFromFile, and everything returns S_OK.

    Any ideas?
  • 9/21/2009 4:25 PM In reply to

    Re: I can't find the d3dx11 effect framework

    yep, there are errors concerning the creation of the different shader (vertex, pixel)
    debug layer gives me following out:

    D3D11: ERROR: ID3D11Device::CreatePixelShader: The pClassLinkage parameter must be NULL, unless GetFeatureLevel returns D3D_FEATURE_LEVEL_11_0 or greater. [ STATE_CREATION ERROR #2097160: CREATEPIXELSHADER_INVALIDCLASSLINKAGE ]

    D3D11: ERROR: ID3D11Device::CreateVertexShader: The pClassLinkage parameter must be NULL, unless GetFeatureLevel returns D3D_FEATURE_LEVEL_11_0 or greater. [ STATE_CREATION ERROR #2097154: CREATEVERTEXSHADER_INVALIDCLASSLINKAGE ]

    I'm looking out for a good solution. i thing, i'll modify the methods "D3DX11CreateEffectFromMemory" with an extra parameter, which control the feature level internally...
    if you got i better idea, i would be glad to hear it ;). if i got it working, i'wll post my solution...
  • 9/21/2009 7:11 PM In reply to

    Re: I can't find the d3dx11 effect framework

    i modified the method now so that i'm able to create a shader and obtain the techniques/passes.... successfully.
    here the code, i've changed:

    File: d3dx11Effect.h
    Modified: the forward declaration (the new parameter is: "const D3D_FEATURE_LEVEL& eFeatureLevel")
    HRESULT WINAPI D3DX11CreateEffectFromMemory(void *pData, SIZE_T DataLength, UINT FXFlags, ID3D11Device *pDevice, const D3D_FEATURE_LEVEL& eFeatureLevel, ID3DX11Effect **ppEffect); 

    File: Effect.h
    Modified: the declaration (the new parameter is: "const D3D_FEATURE_LEVEL& eFeatureLevel")
    HRESULT BindToDevice(ID3D11Device *pDevice, const D3D_FEATURE_LEVEL& eFeatureLevel); 

    File: EffectNonRuntime.cpp
    Modified: the methods header (the new parameter is: "const D3D_FEATURE_LEVEL& eFeatureLevel")
    HRESULT CEffect::BindToDevice(ID3D11Device *pDevice, const D3D_FEATURE_LEVEL& eFeatureLevel) 

    Modified: the creation of a regular shader (if/else interrogation was adjusted)
                // This is a regular shader 
                if(pShader->pReflectionData->RasterizedStream == D3D11_SO_NO_RASTERIZED_STREAM) 
                    pShader->IsValid = FALSE; 
                else if(eFeatureLevel == D3D_FEATURE_LEVEL_11_0) 
                { 
                    if(FAILED((m_pDevice->*(pShader->pVT->pCreateShader))( (UINT *) pShader->pReflectionData->pBytecode, pShader->pReflectionData->BytecodeLength, m_pClassLinkage, &pShader->pD3DObject) ) ) 
                        pShader->IsValid = FALSE; 
                } 
                else 
                { 
                    if(FAILED((m_pDevice->*(pShader->pVT->pCreateShader))( (UINT *) pShader->pReflectionData->pBytecode, pShader->pReflectionData->BytecodeLength, 0, &pShader->pD3DObject) ) ) 
                        pShader->IsValid = FALSE; 
                } 

    Test
        ID3DX11EffectGroup* a = 0; 
        a = dxEffect->GetGroupByIndex(0); 
        if(!a->IsValid()) 
            MessageBox(0, L"a", L"", MB_OK); 
        ID3DX11EffectTechnique* b = 0; 
        b = a->GetTechniqueByIndex(0); 
        if(!b->IsValid()) 
            MessageBox(0, L"b", L"", MB_OK); 

    no message box appears :)

    if you find a better solution, i'm all ears ;)

    EDIT (21.09.2009 :: 22.35)
    here is a little image demonstrating d3d11 rendering with use of the accurately working "d3dx11effect"-interface
    Image
  • 9/22/2009 5:54 AM In reply to

    Re: I can't find the d3dx11 effect framework

    Nice find.  Unless nvidia and ati add dynamic linking to their directx10 drivers thats probably the only solution.

    Edit:
    I hesitate to suggest this because I have no idea what kind of overhead it might introduce, but you could just call it with the class linkage set to 0 when the existing if statement fails like so:
     // This is a regular shader  
                if(pShader->pReflectionData->RasterizedStream == D3D11_SO_NO_RASTERIZED_STREAM)  
                    pShader->IsValid = FALSE;  
                else if(FAILED((m_pDevice->*(pShader->pVT->pCreateShader))( (UINT *) pShader->pReflectionData->pBytecode, pShader->pReflectionData->BytecodeLength, m_pClassLinkage, &pShader->pD3DObject) ) )  
                { 
                         if(FAILED((m_pDevice->*(pShader->pVT->pCreateShader))( (UINT *) pShader->pReflectionData->pBytecode, pShader->pReflectionData->BytecodeLength, 0, &pShader->pD3DObject) ) )  
                               pShader->IsValid = FALSE;  
                }  
    I'm not at my windows 7 computer right now so I can't be sure that it won't cause problems, but since it seemed to be failing gracefully before, I don't see why this wouldn't work.
  • 9/22/2009 3:26 PM In reply to

    Re: I can't find the d3dx11 effect framework

    yep, your solution is the better one and i take it :) (whether my way or yours, essentially it's working;))
  • 9/22/2009 11:36 PM In reply to

    Re: I can't find the d3dx11 effect framework

    Also, technique10 blocks work for me, but fxgroup blocks cause an out of memory error in the shader compiler.
  • 9/23/2009 8:08 PM In reply to

    Re: I can't find the d3dx11 effect framework

    I discovered a new feature that is only partially documented and figured I may as well share it here.  There are currently undocumented data types "RenderTargetView" and "DepthStencilView" in fx_5_0.  You can access them with effects variable AsRenderTargetView() and AsDepthStencilView().  Then in your technique block (works with technique10 just fine) you can use "SetRenderTargets( target1, ... , depthStencil );".  The function takes as arguments any number of RenderTargetView variables followed by one DepthStencilView variable (or zero).  Seems pretty useful, in theory you could put an entire post-filtering pipeline into a single multi-pass technique without any additional application code.
  • 9/23/2009 8:13 PM In reply to

    Re: I can't find the d3dx11 effect framework

    yeah, technique10 is also working.

    EDIT:
    the solution is to leave "D3D10_SHADER_DEBUG" out. when i do that, it works^^

  • 9/25/2009 9:08 PM In reply to

    Re: I can't find the d3dx11 effect framework

    nice feature, you gotta create the rendertargetsview / depthstencilviews normal in your normal application code and transfer these into your shader with help of the effectvariables? the shader is multipassed und in every pass, you set a different target? as source you got to use the previous rendertarget, is that possible, do you know something about it or did you even try it out?
  • 9/29/2009 6:21 AM In reply to

    Re: I can't find the d3dx11 effect framework

    i've changed the creation code once again. your offer was already quite nice, but it was producing always notifications while debugging with enabled debug-layer. that is al little bit annoying, if you are creating several effects ;). this solution, how simple it is, produces neither notifications nor first-chance exceptions.
    don't ask, why we haven't found this solution at first:)

                // This is a regular shader 
                D3D_FEATURE_LEVEL level = m_pDevice->GetFeatureLevel(); 
                if(pShader->pReflectionData->RasterizedStream == D3D11_SO_NO_RASTERIZED_STREAM) 
                { 
                    pShader->IsValid = FALSE; 
                } 
                else if(level == D3D_FEATURE_LEVEL_11_0) 
                { 
                    if(FAILED((m_pDevice->*(pShader->pVT->pCreateShader))( (UINT *) pShader->pReflectionData->pBytecode, pShader->pReflectionData->BytecodeLength, m_pClassLinkage, &pShader->pD3DObject) ) ) 
                        pShader->IsValid = FALSE; 
                } 
                else 
                { 
                    if(FAILED((m_pDevice->*(pShader->pVT->pCreateShader))( (UINT *) pShader->pReflectionData->pBytecode, pShader->pReflectionData->BytecodeLength, 0, &pShader->pD3DObject) ) ) 
                        pShader->IsValid = FALSE; 
                } 

  • 9/30/2009 6:58 AM In reply to

    Re: I can't find the d3dx11 effect framework

    You pass render target views into your shader the same way you would any other variable.  Each pass can then reference those views, and of course you can have shader resource views for the same textures you use as render targets (this is valid, the results are just undefined if you try to read and write the same texture in one shader).  As for creating these views, my solution is to add shader variable annotations indicating which render targets should be created at load time, and the name of the resource view variable to bind to.  My application code then loops over all shader variables looking for these annotations, creating all the needed views.  I then also have an "output" render target view variable which my render pipeline sets.

    An example of my shader code:
    texture2D tempTexture; 
     
    RenderTargetView tempTarget 
        string format = "rgba32"
        float size = 1; 
        string resource = "tempTexture"
    >; 
    This tells my application to make a texture of format DXGI_FORMAT_R8G8B8A8_UNORM, at the same size as the backbuffer, and to assign the resource view of the texture to the shader variable tempTexture.  My first pass writes to tempTarget, and my second pass reads from tempTexture.  Once this is done, I can have a generic filter class which only needs to know about the shader's inputs and output, which I define in a common shader include file.
  • 10/3/2009 10:19 PM In reply to

    Re: I can't find the d3dx11 effect framework

    i got a very strange problem wiht the compute shader. i got one input buffer and one output buffer
    struct dataIn 
        float3 position; 
        float3 rotationAxes; 
        float  rotationAngle; 
        float3 scalation; 
    }; 
     
    struct dataOut 
        float3 b; 
    }; 
     
    StructuredBuffer<dataIn>    bufferIn; 
    RWStructuredBuffer<dataOut>     bufferOut; 
    i'm testing it with simple math. if i write the content directly to the output, all works fine:
    bufferOut[id.x].b = bufferIn[id.x].position; 
    but as far as i'm writing data manually, i got wrong results:
    bufferOut[id.x].b = float3(1.0f, 0.0f, 0.0f); 
    the re-read values are not (1.0f, 0.0f, 0.0f), but they are (1.0f, 1.0f, 1.0f). sometimes they are totally strange (132.3423, 232432.0, 12.0)

    is someone familiar with this kind of problem? (thanks for any help)
  • 10/20/2009 12:21 PM In reply to

    Re: I can't find the d3dx11 effect framework

    Hi, I built the effect11 project, got d3dx11effects.lib
    Then I copy it and d3dx11effect.h to my VC lib/include folder.
    But when I use it in my program (#include<d3dx11effect.h> #pragma comment(lib,"d3dx11effects.lib")),
    it reports link error, which shows below:

    1>d3dx11effects.lib(EffectLoad.obj) : error LNK2001: unresolved external symbol _D3DGetInputSignatureBlob@12
    1>d3dx11effects.lib(EffectLoad.obj) : error LNK2001: unresolved external symbol _D3DReflect@16

    How could I solve it?

    Thanks a lot.
  • 10/20/2009 5:19 PM In reply to

    Re: I can't find the d3dx11 effect framework

    Link to d3dcompiler.lib as well.

    -Mike
  • 10/22/2009 3:18 PM In reply to

    Re: I can't find the d3dx11 effect framework

    AxeEugene:
    Link to d3dcompiler.lib as well.

    -Mike


    Thanks!

    BTW, current version PIX seems not support D3D11 very well...- - I found my program using effect system failed to run with PIX ( may caused by some calls in D3DX11CreateEffectFromFile which are not supported by PIX), Any solutions?
  • 10/22/2009 4:53 PM In reply to

    Re: I can't find the d3dx11 effect framework

    I'm working on improving PIX's D3D11 support right now, in fact.  The next version should work much better -- be sure to try it when it is released (not sure if I can reveal a date at this time, sorry).

    -Mike
  • 10/29/2009 12:58 PM In reply to

    Re: I can't find the d3dx11 effect framework

    Answer
    Reply Quote
    ByOrms:
    i've changed the creation code once again. your offer was already quite nice, but it was producing always notifications while debugging with enabled debug-layer. that is al little bit annoying, if you are creating several effects ;). this solution, how simple it is, produces neither notifications nor first-chance exceptions.
    don't ask, why we haven't found this solution at first:)

                // This is a regular shader 
                D3D_FEATURE_LEVEL level = m_pDevice->GetFeatureLevel(); 
                if(pShader->pReflectionData->RasterizedStream == D3D11_SO_NO_RASTERIZED_STREAM) 
                { 
                    pShader->IsValid = FALSE; 
                } 
                else if(level == D3D_FEATURE_LEVEL_11_0) 
                { 
                    if(FAILED((m_pDevice->*(pShader->pVT->pCreateShader))( (UINT *) pShader->pReflectionData->pBytecode, pShader->pReflectionData->BytecodeLength, m_pClassLinkage, &pShader->pD3DObject) ) ) 
                        pShader->IsValid = FALSE; 
                } 
                else 
                { 
                    if(FAILED((m_pDevice->*(pShader->pVT->pCreateShader))( (UINT *) pShader->pReflectionData->pBytecode, pShader->pReflectionData->BytecodeLength, 0, &pShader->pD3DObject) ) ) 
                        pShader->IsValid = FALSE; 
                } 


    Thanks a bunch! This works very well for me!
    Paul

  • 10/31/2009 12:23 AM In reply to

    Re: I can't find the d3dx11 effect framework

    Looks like we can finally do something with the d3dx11 effect framework, lets see if microsoft finishes all with the next sdk release. Thanks for the tips, I also got my .fx working in d3d9/d3d10 hardware.

    Isaac.
  • 11/18/2009 8:30 PM In reply to

    Re: I can't find the d3dx11 effect framework

    That's a pretty good solution but has the problem of silently failing, MS might enable class linkage for features < 11 at some point, this is the code I finally have:

                ID3D11ClassLinkage* classLinkage;
                if    (m_pDevice->GetFeatureLevel() >= D3D_FEATURE_LEVEL_11_0)
                    classLinkage = m_pClassLinkage;
                else
                {
                    classLinkage = NULL;
                    DPF(0, "ID3DX11Effect::Load - Disabling class linkage on shader creation, device feature level < 11");
                }
                // This is a regular shader  
                if(pShader->pReflectionData->RasterizedStream == D3D11_SO_NO_RASTERIZED_STREAM)  
                    pShader->IsValid = FALSE;
                else if(FAILED((m_pDevice->*(pShader->pVT->pCreateShader))( (UINT *) pShader->pReflectionData->pBytecode, pShader->pReflectionData->BytecodeLength, classLinkage, &pShader->pD3DObject) ) )  
                {
                    pShader->IsValid = FALSE;
                } 

Page 1 of 2 (27 posts) 1 2 Next > Previous Discussion Next Discussion