Jump to content
  • Advertisement
Sign in to follow this  
_dm

Two questions: PS D3DXCreateEffectFromFile

This topic is 4582 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi:), please examine for some minutes the following text, I have some troubles with shaders :(, and hope to get some help.. (sorry for my eng))
///////////////////////////////////////////////////////////////////////////
// Q#1 : HLSL pixel shader (2.0 model)
//  MAX_PS_LIGHTS is defined as 3
//  I use psLights[2].w param to determine whether light is on or off
//  (actually it is max light range), but cannot get speedup  when pass
//  1 light to shader 'on' and other 2 'off' or all 3 as 'on'. Why FPS
//  rate is the same? Obviously there are less calculations shader should
//  perform in first case :|

float4 PS_20(VS_OUTPUT IN): Color
{
    float4 diffuseTexture = tex2D(TextureSampler, IN.tex);
    if (length(diffuseTexture) == 0)
        diffuseTexture = materialDiffuse;

    float4 diff = IN.plight;
    
    for (int i = 0; i < MAX_PS_LIGHTS; i++)
    if (psLights[2].w > 0)
    {
        float3 L = IN.wpos - psLights[1].xyz;
        L = normalize(L);
        
        if (dot(L, psLights[2].xyz) >= psLights[3].z)
            {
            diff += max(0, dot(IN.wnor, -L)) * 
                float4(psLights[0].xyz, 1) * psLights[0].w;  
         }
    }
    return materialDiffuse * diffuseTexture * diff;
}


///////////////////////////////////////////////////////////////////////////
// Q#2 : D3d9
//  Some time ago everything was perfect:). But suddenly (right after I'd
//  integrated new shader (above)) this call begane to throw unknown
//  exceptions. The most interesting thing is that exceptions are not thrown
//  in debug mode (however once I faced with this too). I see no reason for
//  such behaviour:(, what do you think, can shader be guilty?

D3DXCreateEffectFromFile(pd3dDevice, path, NULL, NULL, 0, NULL, &effect, NULL)))

Share this post


Link to post
Share on other sites
Advertisement
For question 1 it's most likely that you're just over-estimating the ability of ps_2_0 [smile]

True dynamic branching is a bit of a grey area pre-SM3, such that the compiler plays a number of tricks to get functionally identical results - but if you examine the assembly (try using fxc.exe from the command line) you'll see there aren't multiple paths...

For question 2 we need more details. You saying that the line you've quoted is throwing exceptions? Do you mean it works in a debug build through visual studio, or using the debug DirectX runtimes? If there is anything wrong with that function call then the DirectX debug runtimes should output a friendly message to the debug-output indicating what the problem is. See the link in my signiture if you're not familiar with using this part of DirectX [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Ok:) so it is one more reason to change gpu asap:)

As for second question,
I've just realized, I used to program without directx developer runtime being installed :(, and the more bad news for me - it cannot be installed at all. I don't think that I have a corrupted version of sdk, but a troubleful os... (one more reason to change os...)

So. The sequence is the following:

1. everyth ok
2. developing of new shader
3. VS - Ctrl+F5 - "unhandled exception..."
4. VS - F5 - load succeded
5. determining of source of ex. by using trace messages
6. some changes to shader, full solution rebuild
7. VS - Ctrl+F5 - "unhandled exception..."
8. VS - F5 - (program loads the same shader 3 times) - "unhandled exception..." on the 3rd load call
9. reboot computer
10. VS - Ctrl+F5 - "unhandled exception..."
11. VS - F5 - load succeded

I understand, there is no information at all and I need in deep exploration using specialized tools..., but possibly someone had a similar problem.
And, generally, what can lead to such horror?

Share this post


Link to post
Share on other sites

VS_OUTPUT VS_20(VS_INPUT IN)
{
VS_OUTPUT OUT;
OUT.hpos = mul(float4(IN.position.xyz, 1.0), WorldViewProjection);
OUT.tex = IN.tex;
OUT.wnor = normalize(mul(IN.normal, World));
OUT.weye = normalize(ViewInverse[3].xyz);
OUT.wpos = mul(float4(IN.position.xyz, 1.0), World);

OUT.plight = Ambient;

for (int i = 0; i < MAX_VS_LIGHTS; i++)
if (vsLights[2].w > 0)
{
// OUT.plight += max(0, dot(OUT.wnor, -vsLights[2].xyz)) *
// float4(vsLights[0].xyz, 1) * vsLights[0].w;
OUT.plight += vsLights[0].w * max(0, dot(OUT.wnor, -vsLights[2].xyz)) *
float4(vsLights[0].xyz, 1);
}

return OUT;
}


Unbelieveble, I has replaced 2 commented lines and D3DXCreateEffectFromFile stopped throw anything.. FXComposer has no strange reactions either on 1st or 2nd shader.

Internal compiler error? ;)

Share this post


Link to post
Share on other sites
Did you try running your shader through fxc.exe? I'm surprised it's tripping up, but the code you've commented out might just be causing it to choke when it comes to fitting it into the limitations of your chosen shader model. In which case it'll provide you with a nice friendly compiler message as to what it doesn't like [smile]

Internal compiler errors can happen, but they are rare. If you suspect an internal error then you should try using the latest-n-greatest fxc.exe and fxc10.exe from the Feb '06 SDK and see if a bug-fix has solved it ...

hth
Jack

Share this post


Link to post
Share on other sites
fxc successfully compiled VS.
But there is a difference: in my program I load text .fx at once.

I've install developer runtime and will try to trace the problem.

Anyway, thank you very much:). It was a pleasure to talk with you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!