🔒 Locked
directX performance
Advertisement
Original Post
Hello !
I want to be sure that the performance I obtain with DirectX are the best.
With Direct Draw 7 I obtain 175 fps in 640*480*32 in an Ahtlon 1800+ and gforce 2, when I just writte all the screen's pixel.
Is it good performance ?
And what can I do for have better performance? Work with 16 bits per color ?
Thank You very much.
!o)
[edited by - Chuck3d on July 21, 2003 4:46:18 PM]
[edited by - Chuck3d on September 1, 2003 11:04:26 AM]
Thank You very much for your answer, but ... i use
primary_surf->Flip(0,DDFLIP_NOVSYNC);
and then the page''s flipping is done when its necessary ,
and i can obtain 175 loop per second of my program ! yes you have
right its not frame per second ...
then my question is : 175 loops per second is good performance ?
(in the loop, i just writte all the screen''s pixels)
Thank you for your answers.
!o)
primary_surf->Flip(0,DDFLIP_NOVSYNC);
and then the page''s flipping is done when its necessary ,
and i can obtain 175 loop per second of my program ! yes you have
right its not frame per second ...
then my question is : 175 loops per second is good performance ?
(in the loop, i just writte all the screen''s pixels)
Thank you for your answers.
!o)
quote:
Original post by Chuck3d
Thank You very much for your answer, but ... i use
primary_surf->Flip(0,DDFLIP_NOVSYNC);
This is good for testing performance, but can sometimes cause tearing in your graphics. Just a little warning, in case you didn''t know.
quote:
Original post by Chuck3d
(in the loop, i just writte all the screen''s pixels)
If this is what you do in the loop, then you must flip the back buffer each frame which means that your 175 loops per second = 175 frames per second.
Generally, 60 fps or above is considered good performance.
Also, you will get better performance with 16 bit color.
digital radiation
directrix quote about primary_surf->Flip(0,DDFLIP_NOVSYNC):
This is good for testing performance, but can sometimes cause tearing in your graphics.
------
Yes ! I see. That''s why ( I suppose ) , we can choose "sync every frame in some First Person Shooter like Quake". This cause graphical artifacs you''re right. I like it , I have the impression that the program is too fast for the screen
well... ( how do you do quote like in your reply ?
directrix quote about "Original post by Chuck3d
(in the loop, i just writte all the screen''s pixels)":
If this is what you do in the loop, then you must flip the back buffer each frame which means that your 175 loops per second = 175 frames per second.
-----
In fact, ... I have two surfaces, a primary and a back one.
In each loop, I write all the pixels in the back surface,
and I use the flipping function.
Then with my timer ( a classical performance counter ), I can measure 175 loops per second but it is not frames per second because the flipping function do the surface exchange when it is necessary (if not I would measure 60 ). Sometimes ( often in fact
I write the pixels but it are not display !
It is either the surface flipping operation or the pixels writing one that kill the performance of my program.
For "the writing operation", I lock the back surface, and I do 2 loop for write a little 255 ( not so little , it''s 4 bytes because it''s 32bits video mode ), in the surface''s RAM.
I unlock it and I do the surface flipping.
I was surprised by the performance, but I really dont know what I can do for increase it. If anyone knows we can do better, please say it to me !
I made some tests with 16 bits per colors, but I obtain the same performance. I deduce that was the number of writing that was the reason of that. Maybe I can use a memory buffer for store my pixels and at the last moment write directly double words (or qword) in the back surface for decrease the number of pixel writing ( wich are very slow ) ? I dont know if this is a good solution because that made twice more loop knowing that 16bits mode are ugly
I see that I can lock the surfaces with the DDSLOCK_SYSTEMMEMORY flag but it doesn''t increase the performance.
There is a lots of way, that ''s why I need help.
Thank you very much for your answers.
ps: sorry for my bad english but I am french, it''s very hard for me
!o)
This is good for testing performance, but can sometimes cause tearing in your graphics.
------
Yes ! I see. That''s why ( I suppose ) , we can choose "sync every frame in some First Person Shooter like Quake". This cause graphical artifacs you''re right. I like it , I have the impression that the program is too fast for the screen
well... ( how do you do quote like in your reply ?
directrix quote about "Original post by Chuck3d
(in the loop, i just writte all the screen''s pixels)":
If this is what you do in the loop, then you must flip the back buffer each frame which means that your 175 loops per second = 175 frames per second.
-----
In fact, ... I have two surfaces, a primary and a back one.
In each loop, I write all the pixels in the back surface,
and I use the flipping function.
Then with my timer ( a classical performance counter ), I can measure 175 loops per second but it is not frames per second because the flipping function do the surface exchange when it is necessary (if not I would measure 60 ). Sometimes ( often in fact
It is either the surface flipping operation or the pixels writing one that kill the performance of my program.
For "the writing operation", I lock the back surface, and I do 2 loop for write a little 255 ( not so little , it''s 4 bytes because it''s 32bits video mode ), in the surface''s RAM.
I unlock it and I do the surface flipping.
I was surprised by the performance, but I really dont know what I can do for increase it. If anyone knows we can do better, please say it to me !
I made some tests with 16 bits per colors, but I obtain the same performance. I deduce that was the number of writing that was the reason of that. Maybe I can use a memory buffer for store my pixels and at the last moment write directly double words (or qword) in the back surface for decrease the number of pixel writing ( wich are very slow ) ? I dont know if this is a good solution because that made twice more loop knowing that 16bits mode are ugly
I see that I can lock the surfaces with the DDSLOCK_SYSTEMMEMORY flag but it doesn''t increase the performance.
There is a lots of way, that ''s why I need help.
Thank you very much for your answers.
ps: sorry for my bad english but I am french, it''s very hard for me
!o)
I don''t really like putting ''performance'' and ''directdraw'' in the same sentence if there isn''t also a ''lacks'' thrown in there.
James Simmons
MindEngine Development
http://medev.sourceforge.net
James Simmons
MindEngine Development
http://medev.sourceforge.net
some thing that you might want to try:
-create the back buffer in system memory. This reduces performance when flipping it, but increases performance when directly plotting pixels to it.
-if possible, inline your pixel plotting function.
-you an assembly routine to plot the pixels. I think there's an article on this in the "Articles & Resources" section.
Assuming you don't want to do an assembly routine...
-here's the standard way to plot pixels:
If your looping, y*(ddsd.lPitch/4) only changes when the y coordinate changes.
So do something like this:
This way, you only do the multiplication and division when the y coordinate changes.
digital radiation
[edited by - directrix on July 21, 2003 6:41:50 PM]
-create the back buffer in system memory. This reduces performance when flipping it, but increases performance when directly plotting pixels to it.
-if possible, inline your pixel plotting function.
-you an assembly routine to plot the pixels. I think there's an article on this in the "Articles & Resources" section.
Assuming you don't want to do an assembly routine...
-here's the standard way to plot pixels:
// surface is a locked surface passed in
// buffer = (DWORD *)ddsd.lpSurface
buffer[x + y*(ddsd.lPitch/4)] = RGB32(r,g,b);
If your looping, y*(ddsd.lPitch/4) only changes when the y coordinate changes.
So do something like this:
for(int y=0; y<64; y++)
{
int offset = y*(ddsd.lPitch/4);
for(int x=0; x<64; x++)
{
buffer[x + offset] = RGB32(r,g,b);
}
}
This way, you only do the multiplication and division when the y coordinate changes.
digital radiation
[edited by - directrix on July 21, 2003 6:41:50 PM]
directriX: I preferre
//---------------------------------------------
buffer = videoram ...
for(int y=0; y<64; y++)
{
buffer2 = buffer;
for(int x=0; x<64; x++)
{
*(buffer2++) = RGB32(r,g,b);
}
buffer+=PitchDiv4;
}
//----------------------------------------------
Why do you divide the pitch by four? It is always like that ?
neurokaotix: Can I find something better than DD in this page ?!
Or can you explain what do you think more ... usefull
.
Thanks.
Chuck
//---------------------------------------------
buffer = videoram ...
for(int y=0; y<64; y++)
{
buffer2 = buffer;
for(int x=0; x<64; x++)
{
*(buffer2++) = RGB32(r,g,b);
}
buffer+=PitchDiv4;
}
//----------------------------------------------
Why do you divide the pitch by four? It is always like that ?
neurokaotix: Can I find something better than DD in this page ?!
Or can you explain what do you think more ... usefull
Thanks.
Chuck
Let us take an example.
You want to create a 3d software engine. You want absolutely the highest performance of the world. You read and eat all the book of M.Abrash. You begin. And after have drawing a simple image on the screen, you can see that the performance are not higher than Quake3 in 3000*2000 with anisotropic filtering 64x and the NT excessive mod, that I advised to you: there's between 300 and 400 rockets per second ( yes almost the number of frame I want ) !

Please, just want to know if that's high performance ( not Q3 grrr ) to obtain 175 fps with just drawing an image in 640*480*32 with an Athlon 1800+ and a gforcepower2.
Thanks.
Chucky
!o)
[edited by - Chuck3d on July 21, 2003 7:55:26 PM]
You want to create a 3d software engine. You want absolutely the highest performance of the world. You read and eat all the book of M.Abrash. You begin. And after have drawing a simple image on the screen, you can see that the performance are not higher than Quake3 in 3000*2000 with anisotropic filtering 64x and the NT excessive mod, that I advised to you: there's between 300 and 400 rockets per second ( yes almost the number of frame I want ) !
Please, just want to know if that's high performance ( not Q3 grrr ) to obtain 175 fps with just drawing an image in 640*480*32 with an Athlon 1800+ and a gforcepower2.
Thanks.
Chucky
!o)
[edited by - Chuck3d on July 21, 2003 7:55:26 PM]
quote:
Original post by Chuck3d
directriX: I preferre
//---------------------------------------------
buffer = videoram ...
for(int y=0; y<64; y++)
{
buffer2 = buffer;
for(int x=0; x<64; x++)
{
*(buffer2++) = RGB32(r,g,b);
}
buffer+=PitchDiv4;
}
//----------------------------------------------
Why do you divide the pitch by four? It is always like that ?
ok, same thing. When plotting 32 bit color pixels you have to divide the pitch by 4 (divide by 2 for 16 bits). It''s b/c the pitch gives the number of bytes to the beginning of the next line, so you divide by 4 to get the number of pixels. You can also take the pitch/4 out of the loops altogether (which I failed to realize when I posted earlier).
digital radiation
Athlon 1333 and a Geforce 3 Ti/500.
Direct draw, doing a multiple layer starfield with pixels in DirectDraw gives me arouynd 3200 fps.
You, my good man, are so ignorant...
The more I think, the more confussed I get.
Direct draw, doing a multiple layer starfield with pixels in DirectDraw gives me arouynd 3200 fps.
quote:
I don''t really like putting ''performance'' and ''directdraw'' in the same sentence if there isn''t also a ''lacks'' thrown in there.
You, my good man, are so ignorant...
The more I think, the more confussed I get.
That does seem a little low. The last DirectDraw program I ran, I had a quad bouncing around the scene at 5400 FPS. Even a GeForce should be able to push more than 175 FPS. In window mode the FPS wont be as high, make sure to run it in fullscreen. In fullscreen, DirectDraw has full access to the video card.
Try this for setting a pixel, it's a little faster.
Lock/Unlock
Set Pixel:
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
[edited by - UltimaX on July 22, 2003 10:51:36 AM]
Try this for setting a pixel, it's a little faster.
Lock/Unlock
//--
//--In header file
//--
long m_VideoPitch;
LPVOID m_VideoStart;
int m_SurfaceLocked;
//--
//--In source file
//--
int LockSurface(void)
{
if(m_Surface == NULL){return 0;}
if(m_Surface->Lock(NULL, &m_SurfaceDescription, DDLOCK_WAIT, NULL) != DD_OK){return 0;}
m_VideoPitch = m_SurfaceDescription.lPitch;
m_VideoStart = m_SurfaceDescription.lpSurface;
m_SurfaceLocked = 1;
return 1;
}
//--
void UnlockSurface(void)
{
if(m_Surface == NULL || !m_SurfaceLocked){return;}
m_Surface->Unlock(NULL);
m_VideoPitch = 0;
m_VideoStart = 0;
m_SurfaceLocked = 0;
}
Set Pixel:
void SetPixelXL(int X, int Y, uchar Red, uchar Green, uchar Blue)
{
if((m_Surface == NULL) | (!m_SurfaceLocked)){return;}
long Pitch = this->m_VideoPitch;
LPVOID Start = this->m_VideoStart;
int BPP = m_SurfaceDescription.ddpfPixelFormat.dwRGBBitCount;
if((BPP == 16) | (BPP == 24))
{
_asm
{
PUSH ESI
PUSHF
MOV EAX, Y
MUL Pitch
MOV EBX, EAX
MOV EAX, X
MOV CX, 3
MUL CX
ADD EAX, EBX
MOV ESI, Start
ADD ESI, EAX
MOV AL, Blue
MOV DH, Green
MOV DL, Red
MOV [ESI], AL
INC ESI
MOV [ESI], DH
INC ESI
MOV [ESI], DL
POPF
POP ESI
}
}
else
{
if(BPP == 32)
{
_asm
{
PUSH ESI
PUSHF
MOV EAX, Y
MUL Pitch
MOV EBX, EAX
MOV EAX, X
MOV CX, 4
MUL CX
ADD EAX, EBX
MOV ESI, Start
ADD ESI, EAX
MOV AL, Blue
MOV DH, Green
MOV DL, Red
MOV [ESI], AL
INC ESI
MOV [ESI], DH
INC ESI
MOV [ESI], DL
POPF
POP ESI
}
}
}
}
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
[edited by - UltimaX on July 22, 2003 10:51:36 AM]
Remember what DirectDraw is optimized for: memory copies. Thus you''re only going to get amazing performance when you are blitting things... especially from VRAM to VRAM. Plotting pixels directly into VRAM isn''t going to give you stellar performance no matter what computer you are on.
ok its an old topic but .... I was in hollyday ... so sorry
UltimaX:
I lock the surface, and I use (I think) all the optimisations that we can find in the documentation of Microsoft.
I lock the surface and I write all the pixels with a color with surface flipping.
and I optain 175fps . You optain 5200 !! Its interresting but are you blitting surface or really locking surface and writting pixels ?
If it is the (good) case, we must compare the source code ... maybe in the night
friendly Chuck
UltimaX:
I lock the surface, and I use (I think) all the optimisations that we can find in the documentation of Microsoft.
I lock the surface and I write all the pixels with a color with surface flipping.
and I optain 175fps . You optain 5200 !! Its interresting but are you blitting surface or really locking surface and writting pixels ?
If it is the (good) case, we must compare the source code ... maybe in the night
friendly Chuck
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement