timing to prevent window blinking
timing to prevent window blinking
Well really i am wondering what is a good timing combo for cls'ing(the screen) and drawing windows
currently its 60hz (every 60ms)
but when i added in cls it started to flicker
so what should it be?
every way ive tried it it flickers
currently its 60hz (every 60ms)
but when i added in cls it started to flicker
so what should it be?
every way ive tried it it flickers
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: timing to prevent window blinking
60hz != 60ms.
You should wait for the vertical retrace before doing any screen updates. You should also copy dwords at all times, whenever possible.
--Jeff
You should wait for the vertical retrace before doing any screen updates. You should also copy dwords at all times, whenever possible.
--Jeff
Re: timing to prevent window blinking
hmmm yes vertical retrace
but i was afraid my drawing will take longer than vertical retrace
and the dword thing
yea thats a big optimization tip speed it up 4 times
but i was afraid my drawing will take longer than vertical retrace
and the dword thing
yea thats a big optimization tip speed it up 4 times
Re: timing to prevent window blinking
you could also use on-board buffering -- though that won't work on 'standard' VGA (in graphics mode -- but then in text mode it isn't a big deal anyway), but most cards supporting any more advanced modes should have enough memory to handle it -- though you will need vbe3, v86-vbe, or a proper driver (only practical for older, or intel controllers)
- matthias
- Member
- Posts: 158
- Joined: Fri Oct 22, 2004 11:00 pm
- Location: Vlaardingen, Holland
- Contact:
Re: timing to prevent window blinking
I might be wrong but it isn't it a speed up with the power of 4 and not times for?hckr83 wrote: and the dword thing
yea thats a big optimization tip speed it up 4 times
Last edited by matthias on Sun Mar 05, 2006 12:00 am, edited 1 time in total.
The source of my problems is in the source.
-
- Member
- Posts: 144
- Joined: Tue Oct 26, 2004 11:00 pm
- Location: Australia
Re: timing to prevent window blinking
No. It's a x4 increase in speed. There is no way of increasing the speed of a copy operation by an exponential amount because every copy operation is of order O(n).matthias wrote:I might be wrong but it isn't it a speed up with the power of 4 and not times for?hckr83 wrote: and the dword thing
yea thats a big optimization tip speed it up 4 times
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
--- Albert Einstein
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: timing to prevent window blinking
You should be able to. If you're always composing your graphics offscreen and merely blitting a buffer to the screen, you should be able to perform this within a refresh and eliminate flicker.hckr83 wrote:hmmm yes vertical retrace
but i was afraid my drawing will take longer than vertical retrace
It's a performance must -- not just for graphics, either. Also note that they need to be dword aligned dwords, as well, or else the pipeline will break up the writes into more then one aligned write.hckr83 wrote: and the dword thing
yea thats a big optimization tip speed it up 4 times
Re: timing to prevent window blinking
no, only if it crosses a 64bit boundry (thats a qword) will it require more than one read (at least on P5+ -- you are correct for 386/486)
- carbonBased
- Member
- Posts: 382
- Joined: Sat Nov 20, 2004 12:00 am
- Location: Wellesley, Ontario, Canada
- Contact:
Re: timing to prevent window blinking
You're saying that the following code can compile and run without any alignment issues?
long longValue = 10;
char *byteAligned = 0x00000001;
*((long*)byteAligned) = longValue;
That doesn't sound right to me...
long longValue = 10;
char *byteAligned = 0x00000001;
*((long*)byteAligned) = longValue;
That doesn't sound right to me...
-
- Member
- Posts: 144
- Joined: Tue Oct 26, 2004 11:00 pm
- Location: Australia
Re: timing to prevent window blinking
The code will run, it will just run twice as slowcarbonBased wrote:You're saying that the following code can compile and run without any alignment issues?
long longValue = 10;
char *byteAligned = 0x00000001;
*((long*)byteAligned) = longValue;
That doesn't sound right to me...
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
--- Albert Einstein
Re: timing to prevent window blinking
no it wont -- the CPU (beginning with the P5) fetches 64bits at a time (not 32) regardless of the size of data -- therefore, there will be no penalty if the fetch doesn't cross a 64bit boundary
-
- Member
- Posts: 144
- Joined: Tue Oct 26, 2004 11:00 pm
- Location: Australia
Re: timing to prevent window blinking
uh-huh...
But what if you are running on an AMD?
Or a Cyrix?
Or an older intel?
What if you want to port your code to SPARC? It wont run *at all* if values are not aligned.
What if you are reading double precision floating point rather than long integer? That's a 64-bit number and it will improve performance vastly if numbers are aligned.
The CPU will actually start moving whole cache lines instead of just dwords (are the cache lines 64 bytes or 32?)
But what if you are running on an AMD?
Or a Cyrix?
Or an older intel?
What if you want to port your code to SPARC? It wont run *at all* if values are not aligned.
What if you are reading double precision floating point rather than long integer? That's a 64-bit number and it will improve performance vastly if numbers are aligned.
Well if we are talking about the later processors, the speed increase is actually 64 times over. When you use a string copy operation such asand the dword thing
yea thats a big optimization tip speed it up 4 times
Code: Select all
rep movsd
Last edited by Da_Maestro on Thu Mar 09, 2006 12:00 am, edited 1 time in total.
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
--- Albert Einstein
Re: timing to prevent window blinking
uh -- i think you missed my point -- you said that dword transfers should be dword aligned -- i said, i should be qword aligned -- not that it shouldn't be aligned at all -- infact, some things are required to be aligned (even on x86)What if you are reading double precision floating point rather than long integer? That's a 64-bit number and it will improve performance vastly if numbers are aligned.
i believe AMD chips have also been 64bit -- at least since the Athlon (more likely later k6s, though i am less knowledged about early AMD designs)But what if you are running on an AMD?
yes, older chips (486 and earlier) should be dword aligned -- but most people (i am an exception, btw) ignore anything older than the P5 (some even northwood) because it makes OSdev much easier
Last edited by JAAman on Fri Mar 10, 2006 12:00 am, edited 1 time in total.
-
- Member
- Posts: 144
- Joined: Tue Oct 26, 2004 11:00 pm
- Location: Australia
Re: timing to prevent window blinking
no my point was that the code quoted before by carbonbased would infact run twice as slow (well at least the statement assigning the value to the misaligned variable)
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
--- Albert Einstein
Re: timing to prevent window blinking
no it would not -- because as long as the data does not cross a qword boundry (which that example code doesn't), it will be done in a single (actually 1/4 on P-IVs) bus cycle because the CPU will actually transfer a qword into the memory bus, but only latch a dword that is located from bytes 1-4, and ignore bytes 0, 5, 6, & 7
like this:
mov [0x01], eax
transfer:
all will be transfered in a single transaction, not 2
x is values ignored by the memory subsystem, and AL = AL, AH = AH, EAX= high word of EAX register
like this:
mov [0x01], eax
transfer:
Code: Select all
byte 0 1 2 3 4 5 6 7
data transfer x AL AH EAX x x x
x is values ignored by the memory subsystem, and AL = AL, AH = AH, EAX= high word of EAX register
Last edited by JAAman on Mon Mar 13, 2006 12:00 am, edited 1 time in total.