D3DXCreateEffectFromFile Problems [solved]

Started by
3 comments, last by chronozphere 16 years, 8 months ago
Hey gamedevelopers. I have a little problem. I want to get started with shaders/effects but i still do not have a working example which allows me to expiriment with effect files. For some reason, the BasicHLSL sample from the SDK doesn't work. So i tried to turn the Meshes tutorial (with the nice tiger) into a shader testing app. But the first thing that didn't work was: D3DXCreateEffectFromFile. It returns E_FAIL wich is a very strange return value for a DX routine. I don't see anything suspicious in the debug-runtime logfile. maybe i can use PIX to determine what the hell is going on, but i don't know how to debug the D3D initialization by using PIX. The PIX tut's only explain stuff like taking screenshots and recording D3D call sequences in a specific frame. I used different effect files. e.g this one: ------------------------------------------------------------------ //===================================== // My first Effect file //===================================== //Variabeles float4x4 g_mWorldViewProjection; texture g_MeshTexture; //structures struct VS_OUTPUT { float4 Position : POSITION; float2 TextureCoords: TEXCOORD1; }; struct PS_OUTPUT { float4 Color : COLOR0; }; //-------------------------------------------------------------------------------------- // Texture samplers //-------------------------------------------------------------------------------------- sampler MeshTextureSampler = sampler_state { Texture = <g_MeshTexture>; MipFilter = LINEAR; MinFilter = LINEAR; MagFilter = LINEAR; }; VS_OUTPUT VS_function( float4 vPos : POSITION, float2 vTexCoord0 : TEXCOORD0 ) { VS_OUTPUT Output; Output.Position = mul( vPos, g_mWorldViewProjection ); Output.TextureCoords = vTexCoord0; return Output; } PS_OUTPUT PS_function(VS_OUTPUT input) { PS_OUTPUT output; output.Color = tex2D(MeshTextureSampler, input.TextureCoords); return output; } //my first technique Technique MyTechnique { Pass FirstPass { VertexShader = compile vs_1_1 VS_function(); PixelShader = compile ps_1_1 PS_function(); } } ----------------------------------------------------------------------- This effect file should compile in FX composer but somehow D3DXCreateEffectFromFile keeps failing. Can someone help me with this. plz.? Thanx in advance [Edited by - chronozphere on August 5, 2007 3:56:36 PM]
Advertisement
If you enable the debug runtimes (Start -> Programs -> DirectX SDK -> Utilities -> DX Control Panel) you should start getting debug output from your application indicating why the function failed.

If you're using VS, this will show in the "Output" window while the program runs. If you're not using VS, you can use DebugView to capture this debug output.

Once you do that, you'll know exactly what D3DX doesn't like about your .fx file.

Another alternative is to compile your .fx file from the command line, using fxc.exe file.fx /tfx_2_0 . This will provide output when an error is encountered.

Hope this helps.
Sirob Yes.» - status: Work-O-Rama.
It could be any number of things, but I'm guessing the EXE is run from a "output/debug" directory or something similar, and it looking for data files from there. It's simply not finding your file. You just need to set the working folder in your project settings and you should be set.
The effect file i pass to the function does exist.

I used this code (pascal):

  str := ExtractFilePath(ParamStr(0))+'effect1.fx';  //check if file exists  if FileExists(str) then  begin    //load the effect    HR := D3DXCreateEffectFromFile(g_pd3ddevice ,pChar(str),nil,nil,0,nil,g_effect,Errors);    if Failed(HR) then    begin       Showmessage('Error occured: '+DXGetErrorString9A(HR)+' while loading: '+str);       Exit;    end;  end;


I check if the file exists so that cant be the problem. I always get the message:

Error Occured: E_FAIL while loading: E:\ **filepath** \effect1.fx

I downloaded debugview but it didn't return ANY debug messages, no matter what kind of capture options i selected.

However i did forget to set a specific compiler directive in D3DX9.pas (which enables D3DX debugging). It delivered the following log-file.

Quote:
Thread Start: Thread ID: 3224. Process Meshes.exe (3356)
Process Start: E:\Delphi\Nasha DX9\Shader sample\V0.1\ZIP\Meshes.exe. Base Address: $00400000. Process Meshes.exe (3356)
Module Load: Meshes.exe. Has Debug Info. Base Address: $00400000. Process Meshes.exe (3356)
Module Load: ntdll.dll. No Debug Info. Base Address: $77C70000. Process Meshes.exe (3356)
Module Load: KERNEL32.dll. No Debug Info. Base Address: $76B40000. Process Meshes.exe (3356)
Module Load: USER32.dll. No Debug Info. Base Address: $76AA0000. Process Meshes.exe (3356)
Module Load: GDI32.dll. No Debug Info. Base Address: $76830000. Process Meshes.exe (3356)
Module Load: ADVAPI32.dll. No Debug Info. Base Address: $769D0000. Process Meshes.exe (3356)
Module Load: RPCRT4.dll. No Debug Info. Base Address: $76D50000. Process Meshes.exe (3356)
Module Load: OLEAUT32.dll. No Debug Info. Base Address: $76EB0000. Process Meshes.exe (3356)
Module Load: ole32.dll. No Debug Info. Base Address: $76880000. Process Meshes.exe (3356)
Module Load: msvcrt.dll. No Debug Info. Base Address: $77E00000. Process Meshes.exe (3356)
Module Load: VERSION.dll. No Debug Info. Base Address: $75CA0000. Process Meshes.exe (3356)
Module Load: WINMM.dll. No Debug Info. Base Address: $74A60000. Process Meshes.exe (3356)
Module Load: OLEACC.dll. No Debug Info. Base Address: $754A0000. Process Meshes.exe (3356)
Module Load: d3d9.dll. No Debug Info. Base Address: $727F0000. Process Meshes.exe (3356)
Module Load: d3d8thk.dll. No Debug Info. Base Address: $73A90000. Process Meshes.exe (3356)
Module Load: dwmapi.dll. No Debug Info. Base Address: $74300000. Process Meshes.exe (3356)
ODS: SXS: Assembly storage resolution trying -1 roots (-1 is ok) Process Meshes.exe (3356)
ODS: SXS: Getting assembly storage root #0 Process Meshes.exe (3356)
ODS: SXS: Storage resolution for root number 0 returned blank root; skipping probing logic and moving to next. Process Meshes.exe (3356)
ODS: SXS: Getting assembly storage root #1 Process Meshes.exe (3356)
ODS: SXS: Assembly storage map probing root C:\Windows\WinSxS\ for assembly directory x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6000.16386_none_87e0cb09378714f1 Process Meshes.exe (3356)
ODS: SXS: Found good storage root for x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6000.16386_none_87e0cb09378714f1 at index 1 Process Meshes.exe (3356)
Module Load: COMCTL32.dll. No Debug Info. Base Address: $74530000. Process Meshes.exe (3356)
Module Load: d3dx9_33.dll. No Debug Info. Base Address: $6A660000. Process Meshes.exe (3356)
Module Load: IMM32.dll. No Debug Info. Base Address: $77D90000. Process Meshes.exe (3356)
Module Load: MSCTF.dll. No Debug Info. Base Address: $77AF0000. Process Meshes.exe (3356)
Module Load: LPK.dll. No Debug Info. Base Address: $765B0000. Process Meshes.exe (3356)
Module Load: USP10.dll. No Debug Info. Base Address: $76530000. Process Meshes.exe (3356)
Module Load: DXerr9ab.DLL. No Debug Info. Base Address: $10000000. Process Meshes.exe (3356)
Module Load: UxTheme.dll. No Debug Info. Base Address: $755B0000. Process Meshes.exe (3356)
Module Load: d3d9.dll. No Debug Info. Base Address: $72E70000. Process Meshes.exe (3356)
ODS: Direct3D9: :====> ENTER: DLLMAIN(72f0a170): Process Attach: 00000d1c, tid=00000c98 Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: Direct3D9: :====> EXIT: DLLMAIN(72f0a170): Process Attach: 00000d1c Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: Direct3D9: (INFO) :Direct3D9 Debug Runtime selected. Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
Module Load: NVD3DUM.dll. No Debug Info. Base Address: $01800000. Process Meshes.exe (3356)
ODS: Direct3D9: (INFO) :======================= Hal SWVP device selected
Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: Direct3D9: (INFO) :HalDevice Driver style b
Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: Direct3D9: :BackBufferCount not specified, considered default 1 Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: Direct3D9: :DoneExclusiveMode Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: Direct3D9: (INFO) :Using FF to PS converter
Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: Direct3D9: (INFO) :Enabling multi-processor optimizations Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
Thread Start: Thread ID: 3816. Process Meshes.exe (3356)
ODS: Direct3D9: (INFO) :Using X3D PSGP
Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
Thread Start: Thread ID: 908. Process Meshes.exe (3356)
ODS: Direct3D9: (INFO) :Using FF to VS converter in software vertex processing
Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 3.58452e-316f. This is ok.
Process Meshes.exe (3356)
ODS: Direct3D9: (WARN) :Ignoring redundant SetRenderState - 7
Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
Source Breakpoint at $00452E58: E:\Delphi\Nasha DX9\Shader sample\V0.1\ZIP\Meshes.dpr line 203. Process Meshes.exe (3356)
ODS: SXS: RtlCreateActivationContext() called with parameters: Flags = 0x00000000 ActivationContextData = 003F0000 ExtraBytes = 0 NotificationRoutine = 76B6137B NotificationContext = 00000000 ActCtx = 0012E720 Process Meshes.exe (3356)
ODS: SXS: Assembly storage resolution trying -1 roots (-1 is ok) Process Meshes.exe (3356)
ODS: SXS: Getting assembly storage root #0 Process Meshes.exe (3356)
ODS: SXS: Storage resolution for root number 0 returned blank root; skipping probing logic and moving to next. Process Meshes.exe (3356)
ODS: SXS: Getting assembly storage root #1 Process Meshes.exe (3356)
ODS: SXS: Assembly storage map probing root C:\Windows\WinSxS\ for assembly directory x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6000.16386_none_5d07289e07e1d100 Process Meshes.exe (3356)
ODS: SXS: Found good storage root for x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6000.16386_none_5d07289e07e1d100 at index 1 Process Meshes.exe (3356)
Module Load: COMCTL32.dll. No Debug Info. Base Address: $750C0000. Process Meshes.exe (3356)
Module Load: SHLWAPI.dll. No Debug Info. Base Address: $76E20000. Process Meshes.exe (3356)
ODS: SXS: RtlCreateActivationContext() called with parameters: Flags = 0x00000000 ActivationContextData = 00CD0000 ExtraBytes = 0 NotificationRoutine = 76B6137B NotificationContext = 00000000 ActCtx = 0012DDAC Process Meshes.exe (3356)
ODS: SXS: Assembly storage resolution trying -1 roots (-1 is ok) Process Meshes.exe (3356)
ODS: SXS: Getting assembly storage root #0 Process Meshes.exe (3356)
ODS: SXS: Storage resolution for root number 0 returned blank root; skipping probing logic and moving to next. Process Meshes.exe (3356)
ODS: SXS: Getting assembly storage root #1 Process Meshes.exe (3356)
ODS: SXS: Assembly storage map probing root C:\Windows\WinSxS\ for assembly directory x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6000.16386_none_5d07289e07e1d100 Process Meshes.exe (3356)
ODS: SXS: Found good storage root for x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6000.16386_none_5d07289e07e1d100 at index 1 Process Meshes.exe (3356)
ODS: SXS: RtlCreateActivationContext() called with parameters: Flags = 0x00000000 ActivationContextData = 00EB0000 ExtraBytes = 0 NotificationRoutine = 76B6137B NotificationContext = 00000000 ActCtx = 0012DDA4 Process Meshes.exe (3356)
ODS: SXS: Assembly storage resolution trying -1 roots (-1 is ok) Process Meshes.exe (3356)
ODS: SXS: Getting assembly storage root #0 Process Meshes.exe (3356)
ODS: SXS: Storage resolution for root number 0 returned blank root; skipping probing logic and moving to next. Process Meshes.exe (3356)
ODS: SXS: Getting assembly storage root #1 Process Meshes.exe (3356)
ODS: SXS: Assembly storage map probing root C:\Windows\WinSxS\ for assembly directory x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_5.82.6000.16386_en-us_9dec13ee642d46de Process Meshes.exe (3356)
ODS: SXS: Found good storage root for x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_5.82.6000.16386_en-us_9dec13ee642d46de at index 1 Process Meshes.exe (3356)
Thread Exit: Thread ID: 908. Process Meshes.exe (3356)
Thread Exit: Thread ID: 3816. Process Meshes.exe (3356)
Module Unload: NVD3DUM.dll. Process Meshes.exe (3356)
Module Unload: DXerr9ab.DLL. Process Meshes.exe (3356)
ODS: Direct3D9: :====> ENTER: DLLMAIN(72f0a170): Process Detach 00000d1c, tid=00000c98 Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: Direct3D9: (INFO) :MemFini! Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)
ODS: Direct3D9: :====> EXIT: DLLMAIN(72f0a170): Process Detach 00000d1c Process Meshes.exe (3356)
ODS: Process Meshes.exe (3356)


De SXS messages are added since i enabled D3DX debugging. I do not understand what those messages mean. Can someone take a look at this?

I have the feeling that i'm missing something, because i expect an error when a DX function doesn't work.
That feeling was correct because i WAS missing something.

The problem was that i used the wrong pascal headers. Another pascal-coder pointed out to me that i should enable D3DX Debugging by setting a compiler directive in the D3DX9 header.
But the headers i was using didn't support D3DX Debugging (it was mentioned in the header itself). So i used the JEDI headers which did support it.

When i solved that it was simply a matter of eliminating 2 errors in the effect file. After that D3DXCreateEffectFromFile was executed succesfully. :)

Thanx anyway for your help ;)

This topic is closed to new replies.

Advertisement