PDA

View Full Version : [D3D] Effect file problems



chronozphere
03-08-2007, 08:10 PM
Hey everyone.

I'm trying to make a little sample that uses *.fx files. Unfortunatly i cannot run the BasicHLSL sample from the SDK because D3D somehow keeps failing because of a non-zero reference count. :(

So i started writing a very simple effect file, which does nothing special:



//=====================================
// 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 in)
{
PS_OUTPUT Output;

Output.RGBColor = tex2D(MeshTextureSampler, In.TextureCoords);

Return Output;
}


//my first technique
Technique MyTechnique
{
Pass FirstPass
{
VertexShader = compile vs_2_0 VS_function();
PixelShader = compile ps_2_0 PS_function();
}
}


As far as i know, this should work.

But when i run this code:


HR := D3DXCreateEffectFromFile(g_pd3ddevice ,pChar(ExtractFilePath(ParamStr(0))+'effect.fx'),n il,nil,D3DXFX_NOT_CLONEABLE,nil,g_effect,nil);
if Failed(HR) then
begin
//report error....
Exit;
end;


It returns E_FAIL, which is a weird DX error code.
I usually get something like D3DERR_INVALIDCALL.
The filepath passed to the function is correct.

The weird thing is that the debug runtimes don't report an error. :? :cry:
maybe i can debug it by using PIX but i don't know how it works yet.
I guess the problem has to do with the contents of the fx file, but i realy have no idea what could
be wrong. :?

Can someone help me to get this working. plz??

Thanx in advance.

LP
04-08-2007, 03:42 PM
You can try to compile your shader with DX shader compiler. I generally use this:


fxc /T fx_2_0 /Fc myfile.fxc myfile.fx

The above generates code with assembly instructions useful for optimizing the high-level code.

If you can get your program to compile just fine, then it's most likely the wrong usage of D3DX calls. Remember that you enable D3DX debugging separately in "d3dx9.pas". It probably doesn't say anything because you haven't enabled debug run-time for D3DX.

chronozphere
04-08-2007, 11:19 PM
I discovered that my shader contained bugs. I debugged it using FX Composer. :)
But it didn't solve the problem. :(



If you can get your program to compile just fine, then it's most likely the wrong usage of D3DX calls. Remember that you enable D3DX debugging separately in "d3dx9.pas". It probably doesn't say anything because you haven't enabled debug run-time for D3DX.


ah.. that's a nice hint :D I didn't know that D3DX debug runtimes are to be enabled in the D3DX9 header.

I removed the dot in this line:

{.$DEFINE DEBUG}


Hope that's enough to get ALL the D3DX messages.

This gave me the following log file (now a lot of SXS messages are added):



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_87e 0cb09378714f1 Process Meshes.exe (3356)
ODS: SXS: Found good storage root for x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6000.16386_none_87e 0cb09378714f1 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_5d07 289e07e1d100 Process Meshes.exe (3356)
ODS: SXS: Found good storage root for x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6000.16386_none_5d07 289e07e1d100 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_5d07 289e07e1d100 Process Meshes.exe (3356)
ODS: SXS: Found good storage root for x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6000.16386_none_5d07 289e07e1d100 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.1638 6_en-us_9dec13ee642d46de Process Meshes.exe (3356)
ODS: SXS: Found good storage root for x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_5.82.6000.1638 6_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)


I don't know whether the additional messages mean good things or bad things. I cannot find any error related things. :?

The weird thing is that when i call D3DXCreateEffectFromFile with the Direct3D Device set to NIL, the log looks the same, and i cannot find any errors while it's clearly an invalid call.
(when device=nil, it returns E_INVALIDCALL instead of E_FAIL)

Can someone tell me how to get more info out of D3D because it feels like i'm missing something?

Thanx in advance

LP
05-08-2007, 02:56 PM
In DirectX Control Panel set "Debug Output Level" to one less "More", to avoid unnecessary output.

Are you sure your video card supports SM2?

chronozphere
05-08-2007, 09:09 PM
YAY!... i just solved it :)

It was infact a combination of multiple bugs/mistakes. The most important one was that i didn't use the JEDI headers. Only the JEDI headers had support for D3DX debug output. That's why i was getting no proper error messages. (dont know where the other SXS messeages came from).
I had to modify the library path so the correct headers were used.

So now i was ready to solve the actual bug. The first one was an invalid subset (i thought i could acces a color's alpha component by doing "COLOR.A" but that was obviously a mistake).



Are you sure your video card supports SM2?


Whaha.. LOL :lol: .... the second error had (indeed) something to do with the shader model.
I changed the effect file so vs and ps 1.1 were used (to be sure that it was supported) but D3DX told me that shader model 1.1 wasn't supported anymore on my ultra DX10 card :mrgreen:
Infact ALL shader models lower than 2.0 are not supported.

I simply changed it to vs_2_0 to solve the whole problem.

Thanx again for your extremely usefull tip about D3DX debugging, i couldn't kill this bug without it.
;)