IDirect3DSurface9 :: LockRect的性能 [英] Performance of IDirect3DSurface9::LockRect

查看:436
本文介绍了IDirect3DSurface9 :: LockRect的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何方法可以提高IDirect3DSurface9 :: LockRect的性能?
我使用这种方法将数据直接放入渲染目标表面.
我将数据写入表面的最后一行.锁定列表行和曲面的所有区域都得到相同的结果.
我曾经使用过探查器.
英特尔VTune Amplifier XE 2011显示LockRect功能正在运行的大多数处理器时间.
它必须每秒运行24次(播放电影任务),并且处理器的空闲时间必须尽可能高,因为使用100%的处理器时间时,视频帧的尺寸非常大,以达到视频帧的最大可能分辨率.

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();

推荐答案

我使用了动态纹理. LockRect不会等待动态纹理.
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;
}


这篇关于IDirect3DSurface9 :: LockRect的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆