There is a texture created by the following function call:

direct3d_device->CreateTexture( width, height, 1, D3DUSAGE_RENDERTARGET, get_pixel_format(), D3DPOOL_DEFAULT, &direct3d_texture ); 

As you know, textures created with the D3DPOOL_DEFAULT flag cannot be blocked for reading and writing.

It is necessary to read part of the texture (no need to write). Is there a way around this restriction? Create texture with flag D3DUSAGE_RENDERTARGET | D3DUSAGE_DYNAMIC D3DUSAGE_RENDERTARGET | D3DUSAGE_DYNAMIC failed.

  • You can copy from a D3DPOOL_DEFAULT texture to another texture created with the D3DPOOL_MANAGED flag, which you can then block and read - but this method is rather slow. - cpp_user

1 answer 1

Can. The slowest way is to use LoadSurfaceFromSurface to copy to D3DPOOL_MANAGED. The fastest (it works 100-200 times faster than the first method) - first, using GetRenderTargetData, copy to D3DPOOL_SYSTEMMEM, and then load and read or, if necessary, copy to d3dpool_managed.

  • I saw GetRenderTargetData but stopped the moment that it copies the entire texture into the system memory, while I needed a small region of a large texture. - cpp_user