In the process of porting a D3D7 engine to D3D9, I have, as expected, encountered a few issues.
First and foremost amongst these, is performance. The D3D9 engine runs approximately 30-40% slower than the DX7 one.
One the major goals for the new engine was to keep the fundamentals as close to the original as possible. I was able to pretty much accomplish this, albeit one major hiccup.
To make a long story a little shorter, in the original implementation, the landscape engine builds a certain number of tiles (textures), depending on too many factors to get into here, by rendering to a single render target texture, created at app initialization in video memory, and then blitting it across vid mem to the appropriate landscape texture, also located in vid mem. The landscape texture table uses up to 64 MB of video RAM, and the textures are created in DXT1 format if supported.
Now, in DX9, I have not been able to find any method to copy from a render target texture, obviously located in vid mem, to another texture also located in vid mem. It seems that this is not possible. Therefore, I render directly into the landscape texture table. Every landscape tile is now a render target texture, and directly receives the rendering.
Unfortunately, I can no longer use DXT compression on these tiles, as they are render targets. For each tile, which are of differing sizes (1024x1024 max - 64x64 min), I grab the Level 0 surface, create a matching DepthStencil surface, set them as the current RenderTarget, and begin rendering. At EndScene, I Release these two surfaces, switch to another tile, and repeat.
Are there any obvious problems with this new implementation that could explain the performance hit? Is there any fast way to copy a render texture into another texture across vid mem in DX9? Are there any other snafu's to keep in mind when porting to DX9?
Thanks in advance.
First and foremost amongst these, is performance. The D3D9 engine runs approximately 30-40% slower than the DX7 one.
One the major goals for the new engine was to keep the fundamentals as close to the original as possible. I was able to pretty much accomplish this, albeit one major hiccup.
To make a long story a little shorter, in the original implementation, the landscape engine builds a certain number of tiles (textures), depending on too many factors to get into here, by rendering to a single render target texture, created at app initialization in video memory, and then blitting it across vid mem to the appropriate landscape texture, also located in vid mem. The landscape texture table uses up to 64 MB of video RAM, and the textures are created in DXT1 format if supported.
Now, in DX9, I have not been able to find any method to copy from a render target texture, obviously located in vid mem, to another texture also located in vid mem. It seems that this is not possible. Therefore, I render directly into the landscape texture table. Every landscape tile is now a render target texture, and directly receives the rendering.
Unfortunately, I can no longer use DXT compression on these tiles, as they are render targets. For each tile, which are of differing sizes (1024x1024 max - 64x64 min), I grab the Level 0 surface, create a matching DepthStencil surface, set them as the current RenderTarget, and begin rendering. At EndScene, I Release these two surfaces, switch to another tile, and repeat.
Are there any obvious problems with this new implementation that could explain the performance hit? Is there any fast way to copy a render texture into another texture across vid mem in DX9? Are there any other snafu's to keep in mind when porting to DX9?
Thanks in advance.