Huge SetStreamSource performance hit
  Home FAQ Contact Sign in
microsoft.public.win32.programmer.directx.graphics.shaders only
 
Advanced search
POPULAR GROUPS

more...

 Up
Huge SetStreamSource performance hit         

Group: microsoft.public.win32.programmer.directx.graphics.shaders · Group Profile
Author: VladR
Date: Dec 29, 2006 15:03

I`m working under DirectX 8.1 (actually, using DX 8.1 headers on a computer
that has DirectX 9.0c installed) and have noticed that setting the Stream 1
equals to half the performance (~250 vs ~500 fps).

This is Vertex Declaration:
DWORD dwDeclTerrain3 [] =
{
D3DVSD_STREAM(0),
D3DVSD_REG(0, D3DVSDT_FLOAT1 ), // Y-Position of vertex
D3DVSD_REG(3, D3DVSDT_D3DCOLOR ),// Normal + Alpha
D3DVSD_REG(5, D3DVSDT_D3DCOLOR ),// Diffuse color
D3DVSD_STREAM(1),
D3DVSD_REG(4, D3DVSDT_FLOAT3 ), // Precalculated Position per each chunk
D3DVSD_REG(6, D3DVSDT_SHORT2 ),// Tex coords
D3DVSD_END()
};

I`m pretty sure that the performance drop comes from setting the Stream 1
(remarked it in code to check), since almost everything else has been
remarked, so it`s not executed at all. I also tried reducing the Vertex
Shader length from about 40 instructions into just ~10 (just transforming the
position), but this didn`t improve performance at all. Only after I remarked
the line "s1 = fm_pd3dDevice->SetStreamSource( 1,
VBChunkPositionStream.VB_Handle, sizeof SCompressedTerrainStream);", did the
performance jump from 250 to about 500 (obviously, terrain wasn`t rendered
correctly, but that`s not important since I was just trying to find out
what`s slowing it down).

Texturing/Fog was disabled, so it was just a matter of pure Vertex Shader.
Also, i tested it at resolution 640x480 to reduce any fillrate issues (AA/AF
were off also, Driver set to performance). When DIP calls were remarked, FPS
jumped from 250/500 to ~2500 (nothing else haws been drawn/processed).

Since I`m working with streams for quite a long time, it`s pretty weird to
me because I haven`t yet encountered such a performance drop while using
them. I suspect, that this is because of my latest Vertex compression (to
reduce the amount of VRAM consumed by terrain chunks) - therefore the size of
Vertex has dropped down to a probably not very good cache-friendly size - it
is now 12 Bytes (and I plan in future to drop it down to just 2 Bytes for
YPOS, since it`s a regular heightmap) for Stream 0 (each terrain chunk has a
separate VB) and 12 Bytes for Stream 1 (just 1 single VB used with ALL 256
terrain chunks (each chunk being 128x128 vertices) ).
Previous Vertex sizes were bigger, but I had much higher FPS than now (I
have only about 250 fps with 230.000 triangles rendered in 13 DIP calls
which is just ~60Mtris/s - a very low value in itself, since if I render just
the terrain vegetation in same amount of DIP calls (each terrain chunk has
associated vegetation chunk) and similar amount of triangles (~250.000), I
get fps of about 400 with texturing/fog off - but there are no streams for
vegetation - here it is about 100Mtris/s which is not ideal either (but then
the vegetation isn`t continuous as terrain is, so it`s understandable), but
at least usable).

My configuration:
GF6600 AGP,128 MB RAM, AMD XP2500, 512 MB RAM, WinXP-SP2, DirectX 9.0c, MSVC
6.0, Forceware 91.47

Why does setting the second stream result in so massive performance hit ?
Could it be Vertex Cache-related ?
no comments
diggit! del.icio.us! reddit!