Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any way to increase performance of IDirect3DSurface9::LockRect?
I use this method to put data directly to render target surface.
I write the data to last line of surface. Locking list line and all area of surface gives same results.
I have used profilers.
Intel VTune Amplifier XE 2011 shows that most processor time the functions LockRect are runing.
This must run 24 times per second (playing movie task) and idle time of processor must be as high as possable because of very high video frame size to reach maximum possable resolution of video frame when 100 per cent of processor time is used.
// Stereo Blitdefines
#define NVSTEREO_IMAGE_SIGNATURE 0x4433564e //NV3D
				typedef struct _Nv_Stereo_Image_Header
				{
					unsigned int dwSignature;
					unsigned int dwWidth;
					unsigned int dwHeight;
					unsigned int dwBPP;
					unsigned int dwFlags;
				} NVSTEREOIMAGEHEADER, *LPNVSTEREOIMAGEHEADER;
				// ORedflags in the dwFlagsfielsof the _Nv_Stereo_Image_Headerstructure above
#define SIH_SWAP_EYES 0x00000001
#define SIH_SCALE_TO_FIT 0x00000002
			
				// Lock the stereo image
				D3DLOCKED_RECT lr;
/*//*/
				local_source_image_final->LockRect(&lr,NULL,0);
				// write stereo signature in the last raw of the stereo image
				LPNVSTEREOIMAGEHEADER pSIH=
					(LPNVSTEREOIMAGEHEADER)(((unsigned char *) lr.pBits) + (lr.Pitch* (local_source_rectangle_stretch.bottom - local_source_rectangle_stretch.top)));
/*//*/
/*/
				RECT local_stereo_information_rectangle = 
				{
					local_source_rectangle_stretch.left,
					local_source_rectangle_stretch.bottom-local_source_rectangle_stretch.top,
					local_source_rectangle_stretch.right,
					local_source_rectangle_stretch.bottom-local_source_rectangle_stretch.top+1
				};
				local_source_image_final->LockRect(&lr,&local_stereo_information_rectangle,0);
				// write stereo signature in the last raw of the stereo image
				LPNVSTEREOIMAGEHEADER pSIH=
					(LPNVSTEREOIMAGEHEADER)(((unsigned char *) lr.pBits));
/*/
				// Update the signature header values
				pSIH->dwSignature= NVSTEREO_IMAGE_SIGNATURE;
				pSIH->dwBPP= 32;
				pSIH->dwFlags= SIH_SWAP_EYES; // Src image has left on left and right on right
				pSIH->dwWidth= (local_source_rectangle_stretch.right - local_source_rectangle_stretch.left);
				pSIH->dwHeight= (local_source_rectangle_stretch.bottom - local_source_rectangle_stretch.top);
				// Unlock surface
				local_source_image_final->UnlockRect();
Posted
Updated 5-Dec-10 21:52pm
v3
Comments
[no name] 6-Dec-10 3:56am    
My profiler shows, that local_source_image_final->LockRect(&lr,NULL,0); runs 9 second in 1 minute test.

1 solution

I have used dynamic textures. LockRect does not wait with dynamic textures.
HRESULT local_handle_result = S_OK;
CComPtr<IDirect3DTexture9> local_source_texture;
local_handle_result = direct_3D_device->CreateTexture(
    cxImage,
    cyImage,
    1,
    D3DUSAGE_DYNAMIC,
    D3DFMT_A8R8G8B8,
    D3DPOOL_DEFAULT,
    &local_source_texture,
    NULL);
if(local_handle_result!=D3D_OK)
{
    return local_handle_result;
}
if(local_source_texture==NULL)
{
    return local_handle_result;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900