Myth 9: You Can Determine The Performance Of A Graphics Call With The Following Methodology:
int start = getTime();
pD->DrawIndexedPrimitive(…);
int end = getTime();
int time = end-start;
The code above is understandable and
intuitive. Unfortunately, VGO is not. The missing piece is the work
that exists under the “hood” of the API and the hardware that it
drives.
The CPU is a low latency, low
throughput resource. In other words, if you ask it one question, you
get a quick response. The GPU is a high latency, high throughput
processor. In other words, if you ask it a question, you get a slow
response. If you ask it many questions, the response is just as slow
as if you asked it one.
How do we manage this difference in
processing? With a structure called the command buffer. The code
above is measuring the time it takes to set the command into the
command buffer and determine if your render state changed from the
last time you called DrawIndexPrimitive. This does NOT tell you how
long it takes to render the triangles. That works occurs at a
different time and is under the control of your drivers.
To measure that data, you would either
need to force the DrawIndexedPrimitive call to no longer act in
parallel (thus reducing the need for a buffer) or use drivers that
can provide that information for you.
Myth 10: OpenGL Is Faster Than
DirectX (Or Visa Versa)
Not so fast. Religion, politics, and
API supremacy is not something I am prepared to discuss in a public
forum. The decision is deeply personal, and rooted in the financial
gain that your favorite API provides for your future. All sarcasm
aside, let’s look at some facts.
You can make a slow game in OpenGL and
you can make a slow game in DirectX. An API is an interface to your
driver, and the driver is an interface to hardware. Any API that
gives access to the hardware, without hindering it, will provide
plenty of opportunity for performance.
I will go out on a limb and suggest
that, at this time of this article, OpenGL is lacking the toolset
supported by DirectX for analyzing GPU performance. There are
several efforts in development to alleviate this.
In Closing
The process of VGO is as mystifying and
complex as the hardware that drives our games. In the near future,
this process will be demystified by better tools and made more
complex by modern hardware, such as multi-core (think double digit
number of cores) and unified shader architectures. Before
implementing any optimization “tip” or “trick”, be certain to
understand the underlying hardware that provides the optimization. If
you don’t, you may be perpetuating another optimization myth.
|