I'm currently using "D3DXLoadSurfaceFromMemory()" to update the texture.
Since the texture is created in managed pool, I think that internally, a
memcpy is used to update a copy of the texture in sysmem, before
transferring to the video card. I would like to directly move the memory
bits to the video, as UpdateTexture presumably does - but there's no
UpdateTextureFromMemory, just from another texture
Actually, I've found out that the difference between
D3DXLoadSurfaceFromMemory() and CopyMemory() line by line originates from
the memory allocation in the driver (cached, or non cached). Fixing the
driver resulted in almost identical measurements.
What I would like to do now is fast deinterlacing, since my frame grabber
grabs fields, not frames.
Copying line-by-line, even and odd, is too slow. I'm thinking of using a
> Well, I suppose you could write a custom Render filter/allocator which
> textures and passes the D3DLOCKED_RECT pBits value to upstream filters,
> forcing them to write directly into the texture memory. When you get them
> back, unlock them to flush the changes to the video card. I don't know if
> you can pass a stride parameter as well. You'd need to look into it.
> > I am trying to something very similar.
> > Trying to update a 3d texture from video..
> > Using BT848 and similar. DX81.
> > What would you recommend for this?
> > Is it (even) possible to use a 3d surface as a DS surface so bypassing
> > several steps?
> > > You were right!
> > > .
> > > I'm getting now a pointer to the surface bits with LockRect() and use
> > > CopyMemory in a loop on each row to place the data into the texture.
> > > D3DXLoadSurfaceFromMemory().: 20ms
> > > CopyMemory: 4ms
> > > May any further optimization be obtained, by eliminating the loop (so
> > > the driver could optimize the transfers to the video card)?
> > > I'm looking for a version of CopyRects, using memory -> surface,
> > of
> > > surface -> surface.
> > > Thank you,
> > > -- Luc
> > > > you;d probably get better performance by creating your surfaces
> > > > time and hand-copying the bits ( you need to lock the surface, get
> > > > pointer, and copy, and then unlock ).
> > > > --
> > > > Phil Taylor
> > > > PM : DirectX SDK, Managed DirectX, Windows XP Inbox 3D screensavers,
> > a
> > > > few more bits and bobs.
> > > > http://msdn.microsoft.com/directx
> > > > This posting is provided "AS IS" with no warranties, and confers no
> > > rights.
> > > > > Hello,
> > > > > I'm porting an application which interfaces to a video
> > > > > grabbing device. The existing driver doesn't implement the
> > > > > DirectShow interface - it simply places the video data in
> > > > > memory, providing a pointer to the latest grabbed frame.
> > > > > What would be the fastest way to display the image buffer?
> > > > > Currently, I'm using a texture of 1024x1024, and I copy
> > > > > the image, 720x576(PAL) using D3DXLoadSurfaceFromMemory().
> > > > > The performance is poor: 20 ms for this operation, on a
> > > > > Pentium3 700 Mhz, with a GeForce4 card.
> > > > > Thank you,
> > > > > -- Luc