Jump to content

  • Log In with Google      Sign In   
  • Create Account

Direct vram access in DX


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 01 November 1999 - 08:25 AM

I know how to lock the surface memory and access the video memory directly. Now I need to know is if you can get a pointer to the attached backbuffer. This way I don't have to lock/unlock again (I can use blit right?).

Now the next question:
I have a 640x480 screen (let's keep it simple: 256 colors). Can I make the backbuffer bigger, let's see 680,520? Then it would look like this:
_____________
| _______ |
| | | |
| |_____| |
|___________|

The big rectangle is the backbuffer and the little one is the screen. Can you use blit to copy only the part that's in the screen to the primary surface?


Sponsor:

#2 Niels   Members   -  Reputation: 122

Like
Likes
Like

Posted 30 October 1999 - 08:10 AM

Hm!

Not quite sure what you're asking, so if this reply sounds weird, I probably misunderstood something, anywayz:

Reg. Lock/Unlock. The general rule is that you can't use blit on a locked surface. If your source surface is never changed, you can lock it, get a memory pointer and then unlock it, but continue to use the memory pointer (I don't know if this is legal, but I seem to get away with it ). Locking one surface should not prevent blitting to/from other surfaces.

Reg. different size front and backbuffers: I assume the reason you're talking front and back buffer is that you intend to use flip() in which case different size buffers doesn't make much sense. There's nothing stopping you from creating an offscreen surface with a different size than your primary surface (In either V-Mem or sysmem)...


#3 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 30 October 1999 - 09:12 AM

The rectangles weren't displayed right. The reason I want to do this is that I don't want to lock the primary surface memory all the time when the program runs (players can't use CTRL+ALT+DEL this way).

The reason that I want to have a bigger back surface is this: I will use a tile based system. This way I have to place all 32x32 (or 40x40) pixel sprites each frame (one layer). But why the bigger surface you may ask.
Well I want to do some scrolling. When you place the sprites on the screen there are 'half' sprites shown on the edges of the screen (when the screen scrolls). I don't want to put pixels out of the screen boundaries. Then I want to flip the backbuffer to the primary surface (/w hardware acceleration).


#4 INVERSED   Members   -  Reputation: 172

Like
Likes
Like

Posted 30 October 1999 - 12:32 PM

doesn't the ALLOWREBOOT coop level flag allow for ctrl+alt+del, or is that just in certain situations?

------------------
--Orion McClelland


#5 Splat   Members   -  Reputation: 122

Like
Likes
Like

Posted 30 October 1999 - 02:08 PM

I believe in this circumstance that Lock()ing the surface will grab the Win16 lock and thus really mess up normal machine operation while the surface is locked. I KNOW you can't debug when the Win16 lock has been taken.

As for your problem with using a bigger back buffer, I do not believe a back buffer can have different dimensions than the front. However, let me say that for smooth scrolling (which is what you seem to want to do), you should have a larger offscreen surface where you blit your tiles and stuff, then from that you should blit to the back buffer, then flip. Either that or blit partial tiles to the borders of the back buffer, then normal blit the rest. Either way should get you the effect you want.

- Splat


#6 Splat   Members   -  Reputation: 122

Like
Likes
Like

Posted 30 October 1999 - 03:26 PM

Oh yeah.

Niels: Keeping that pointer to video memory after Unlock()ing it is a "Bad Thing." Just think, the video card could decide to optimize its memory and rearrange the blocks of memory. Or you could be accessing memory that was being Blit()ed to and get unexpected results. Etc. I realize that dealing with debugging with DirectDraw is difficult when using your own blitting routines, so maybe you should only use Unlock()ed pointers in debug mode and turn them off when you want to compile a release version of your game.

- Splat


#7 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 30 October 1999 - 07:41 PM

I can use system memory as an offscreen surface (which will be bigger) and pass it to the primary surface.
But I thought that if I could make the attached backbuffer larger I could get a speed increase (using hardware acceleration). But I guess I have to do it with system memory.

#8 Starwynd   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 October 1999 - 03:34 AM

I think the answer is simple. Instead of making a bigger back surface, simply clip your tiles when you draw them. A good clipping routine will likely be faster than sending all that unnecessary data to the video card anyway.

Regards

Starwynd


#9 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 October 1999 - 06:20 AM

That's the catch!
It CAN be faster to send the extra data using assembler (using 32 bits memcopying). I don't have to use color keying 'cause it's the base layer.
These compares take a lot more clockticks than moves.

#10 Rock2000   Members   -  Reputation: 122

Like
Likes
Like

Posted 01 November 1999 - 05:41 AM

I think the speed difference between clipping the edges and copying the entire tile is pretty minor, and could swing either way (faster or slower) depending on how much is clipped. But since it sounds like your image will be aligned, and is small and 8bit, you're probably right.

However, you're still missing out on a much bigger speed increase. If you threw away your big surface approach, and DID clip the edges, then you'd be able to keep all the surfaces in vid mem, use hardware blitting to copy tiles to the back page (which will be much faster than drawing to your system surface), and then just flip video pages instead of copying your sys surface to the video card, which is generally VERY costly.

Rock


#11 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 01 November 1999 - 08:25 AM

I was thinking...
Vertical clipping can be faster (because I can still use 32 bits memcopy) but horizontal clipping can be a pain in the neck (checking if clipped number is divide-able by 4 etc...) however in 32 bits color this wouldn't apply.

I still have much to learn about DX.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS