Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: problem with DEVICE.PRESENT method in Delhi8

  1. #1

    problem with DEVICE.PRESENT method in Delhi8

    Greetings, fellow programmers.

    Recently I?¢_Tve started learning Delphi 8 and .NET framework. I have downloaded DirectX SDK for managed code with examples and also found samples converted into Delphi. I managed to compile and run most of them, but I?¢_Tve noticed that DEVICE.PRESENT method decreases FPS down to around 30 even on the simplest program. When I take the line out, of course there is no buffer flip and nothing is displayed, but FPS jumps up to around 7000. My question is, has anybody encountered anything like this? And if so, what am I doing wrong?

    Thanks in advance.
    Alex

    p.s. Clootie, how are you doing, man? It?¢_Ts been a while.

  2. #2

    problem with DEVICE.PRESENT method in Delhi8

    maybe you have choosen a wrong backbuffer format?
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #3

    problem with DEVICE.PRESENT method in Delhi8

    VSync ?
    There are only 10 types of people in this world; those who understand binary and those who don't.

  4. #4

    problem with DEVICE.PRESENT method in Delhi8

    Thanks for your comments.

    maybe you have chosen a wrong backbuffer format?
    No, I've tried that too. I tried it with default format (presumably the same as desktop format). and then I've tried to set backbuffer format to a number of different values. No effect whatsoever.

    VSync ?
    Swapeffect is set to discard. But even if VSync is on, refresh rate of my monitor is 60 and the application is very simple. But I get around 30FPS.

  5. #5

    problem with DEVICE.PRESENT method in Delhi8

    may we see your rendering code and d3d init code?
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  6. #6

    problem with DEVICE.PRESENT method in Delhi8

    30 == 60 / 2

    So if your app requires more than 17ms to render single frame - you'll be getting 30 FPS. This is common issue with games for example.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  7. #7

    problem with DEVICE.PRESENT method in Delhi8

    may we see your rendering code and d3d init code?
    here it is:
    Code:
    {$REGION 'Direct3D procedures'}
    procedure twinform.initd3d();
    var presentParams:presentparameters;
    begin
      presentParams := PresentParameters.Create;
      presentParams.Windowed:=true;
      presentParams.SwapEffect:=SwapEffect.Discard;
      presentparams.BackBufferCount:=1;
      presentparams.BackBufferWidth:=self.ClientSize.width;
      presentparams.BackBufferHeight:=self.ClientSize.height;
    
      device1 := Device.Create(0, DeviceType.Hardware, self, CreateFlags.HardwareVertexProcessing, [presentParams]);
    end;
    
    procedure twinform.render1();
    begin
      device1.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1, 0);
      device1.BeginScene();
    
      device1.EndScene();
      device1.Present();
    end;
    {$ENDREGION}
    30 == 60 / 2

    So if your app requires more than 17ms to render single frame - you'll be getting 30 FPS. This is common issue with games for example.
    That is true (I hate VSYNC for that), but I have a very fast machine and the application is very simple. And also when I comment the line "device1.present();" out, FPS increases substentially.

    Actually, I've just ran the this thing again with "device1.present();" commented out. FPS jumps wierdly between 17 and 80000. When I comment "device1.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1, 0);" line FPS stays stady around 500000. Here is the piece of code where I count FPS

    Code:
    var thistick,lasttick,frames:integer;
         fps:single;
    
    //counting FPS
      inc(frames);
      thistick:=environment.get_TickCount;
      if thistick-lasttick>100 then begin
        fps:=frames*1000/(thistick-lasttick);
        label1.Text:=system.String.Format('FPS: {0}',[fps.tostring('00000000.00')]);
        frames:=0;
        lasttick:=environment.get_TickCount;
      end;
    Thanks

  8. #8

    problem with DEVICE.PRESENT method in Delhi8

    [pascal] thistick:=environment.get_TickCount;
    if thistick-lasttick>100 then begin
    fps:=frames*1000/(thistick-lasttick);
    label1.Text:=system.String.Format('FPS: {0}',[fps.tostring('00000000.00')]);
    frames:=0;
    lasttick:=environment.get_TickCount;
    end;[/pascal]

    try the safe way of doing it:

    [pascal] thistick:=environment.get_TickCount;
    if thistick-lasttick>1000 then begin
    fps:=frames;
    label1.Text:=system.String.Format('FPS: {0}',[fps.tostring('00000000.00')]);
    frames:=0;
    lasttick:=thistick;
    end;[/pascal]
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  9. #9

    problem with DEVICE.PRESENT method in Delhi8

    1) Did I understood right that there is no code between:
    [pascal] device1.BeginScene();

    device1.EndScene(); [/pascal]
    ?

    2) With "Present" commented out no work will be acually done to render anything (I mean videocard driver will not even start rendering current frame until you call Present).

    3) From MSDN (btw, why are you using "get_TickCount" and not just "TickCount" in Delphi.net?)
    The resolution of the TickCount property cannot be less than 500 milliseconds.
    So it's really bad idea to you it as high precision counter. Probably something like Date.Ticks will be much better, but I actually don't know details of CLR.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  10. #10

    problem with DEVICE.PRESENT method in Delhi8

    the windows gettickcount is very precise down to 5milliseconds i read this in an article somewhere where they were comparing different timing methods. ofcourse frequency counter was the most precise but gettickcount was enough precise too. i don't know is that .net stuff you are using there?
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •