Skip to main content
gamedev.net
🔒 Locked

Optimization questions...

Started by IceGod 2 replies 500+ views
Original Post
IceGod
IceGod
Hi, I have a star field, and I''m using my own transformations to animate it. Using this data, I''m creating an array of vertices for each star. Each star has four vertices, along with color and texture coordinates, and the four vertices make up a quad that I render using triangle strips. Each time the stars are changed, I have to recreate my vertices and recopy them to the vertex buffer. I''m wondering if this is a good way to do this? Are there any optimizations I can employ? I don''t think theres any way I can get the data to be untransformed, but I just want to be sure I''m doing this in a good way. For example, what is the best setup for my vertex buffer? My vertices are sorted by texture (well, not exactly, I just render a fixed number of them with one texture and then another fixed number with a seperate texture). Another question I have is, why does the FPS increase so remarkedly when going from windowed to full screen mode? In quake 3, when I press alt-enter to switch to windowed mode, there is virtually no difference in frames per second if I run a timedemo. Also, in some of the DX sample apps (skinned mesh for example), there isn''t much difference when switching either. I get about 330 fps at 640x480 in windowed, and 800fps in fullcsreen. Same bit depths etc. Anyone have any idea what can be causing this? Thanks, IceGod
DmGoober
DmGoober
Dont recreate your vertices! Just change their matrices using SetTransform ().
Before each call to drawindexedprimitive (or drawprimitive) simply call SetTransform to the appropriate matrix.

I know you are doing your own transforms, but your method invovles locking down the VB and writing to it, which stops DX from doing a lot of optimizations.

Wait a minute. . .

Technically, by changing the matrices you are sending your graphics card 4*4 pieces of data. Of course, as it turns out, in your case, you only have 4 vertices, each one has 3 pieces of data . . . plus the texture coordinates. . . nm. Using settransform should be faster.

But if you''re getting 800 fps, who really cares about speed anyways? Oh and performance windowed/fullscreen depends a lot on your graphics card. . . one of my graphics cards does 3fps/30fps while my other card does 148fps/90fps (yes, it runs faster windowed for some stupid reason!) Go figure.

DmGoober
Alexander "DmGoober" Jhinalexjh@online.microsoft.com[Warning! This email account is not attended. All comments are the opinions of an individual employee and are not representative of Microsoft Corporation.]
IceGod
IceGod
quote:
Original post by DmGoober
Dont recreate your vertices! Just change their matrices using SetTransform ().
Before each call to drawindexedprimitive (or drawprimitive) simply call SetTransform to the appropriate matrix.



Well, right now all my vertices are pre-transformed and lit. What I am doing is calculating the position of all my stars, and then filling a vertex array with all that data (nothing happening with vertex buffer yet), computing the vertices and texture coords of my quads on the fly. Then I lock the vertex buffer, copy the data over, and render. I''m using DrawPrimitive, would DrawIndexPrimitive be any faster? None of my stars really share much in common (besides relative size), since they are all in different positions. It seems setting the transform between each call to drawprimitive would be a lot slower, since I have to set the transform AND draw the vertices anyways. I''m definitely not changing the vertex buffer while I''m drawing though, if thats what you thought. Another optimization I thought might help is using trianglelists instead of strips, this way I could render a bunch of primitives in one call, instead of having to call drawprimitive for each quad. Would this help?

quote:

But if you''re getting 800 fps, who really cares about speed anyways? Oh and performance windowed/fullscreen depends a lot on your graphics card. . . one of my graphics cards does 3fps/30fps while my other card does 148fps/90fps (yes, it runs faster windowed for some stupid reason!) Go figure.

DmGoober


Well, if its my graphics card, why doesn''t it do it in quake 3 or the skinned mesh app? My guess is that quake3 and the skinned mesh app use my graphics card more than my cpu, so thats whats limiting it. But in windowed mode, since I''m drawing so little, its my cpu that limits it, and windowed uses more CPU power (or something?). Although I can''t explain a 2x performance increase. Anyone else have any ideas?

IceGod
CpMan
CpMan
But what if those stars were going all in different directions, SetTransform wouldn''t work (i think), becuase it would make them go in the same direction. You''d have to render each star serpatly
VSEDebug Visual Studio.NET Add-In. Enhances debugging in ways never thought possible.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.