STATE_VDECL & friends

Stefan Dösinger stefan at codeweavers.com
Fri Jun 17 18:05:27 CDT 2011


Hi,

This is a brain core dump before going to bed for the other d3d developers. I 
did some testing concerning the vertexdeclaration, vertex shader, stream 
sources and pixel shader states. Currently the first 3 are hard linked, and 
the pixel shader is also tied to the vertex shader. I was interested which 
states are invalid how often, and where separating the states makes sense.

Basically about 40% of all draws only the pixel shader is invalid. In another 
30%-50% the pixel shader and stream source are invalid, and in about 10% to 
20% of all draws all 4 states are reapplied anyways. There are relatively few 
cases where the vertex declaration and vertex shader are changed alone.

So what does this mean? We'll have to spit away the pixel shader and stream 
sources states. The good news is that the stream sources are easy to separate 
- when the streamsources are invalid only reapply them, if the vdecl or 
vshader are dirty reapply shader+decl+streamsrc. The bad news is that applying 
the stream sources is the most expensive part.

The pixel shader is already somewhat separated. Changing the pixel shader will 
only reapply the vertex shader, but not stream sources or other vdecl-related 
states. Separating vertex and pixel shaders will be tricky and not fully 
possible on some drivers(needs GL_ARB_separate_shader_objects or ARB shaders) 
and all shaders(Shader Model 3.0 varying passing)

In addition to this we'll have to make parsing of the vertex declaration 
cheaper. I'll think of something... I'll also write some quick and dirty 
patches to see how much performance we really get out of these changes.

Stefan

PS: I attached my debug patch and the output for a few games.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dirtydebug
Type: text/x-patch
Size: 6531 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20110618/6543fc8d/attachment.bin>
-------------- next part --------------
nfsshift:
err:d3d_draw:drawPrimitive 0.000 none, 0.090 all
err:d3d_draw:drawPrimitive 0.000 vs only, 0.000 stream only, 0.000 decl only, 0.421 ps only
err:d3d_draw:drawPrimitive 0.000 vs_stream, 0.000 vs_decl, 0.000 stream_decl, 0.005 vs_ps, 0.000 decl_ps, 0.344 stream_ps
err:d3d_draw:drawPrimitive 0.000 vs_decl_stream, 0.000 vs_decl_ps, 0.033 vs_stream_ps, 0.106 decl_stream_ps

TmForever:
err:d3d_draw:drawPrimitive 0.000 none, 0.070 all
err:d3d_draw:drawPrimitive 0.000 vs only, 0.000 stream only, 0.000 decl only, 0.339 ps only
err:d3d_draw:drawPrimitive 0.000 vs_stream, 0.000 vs_decl, 0.000 stream_decl, 0.004 vs_ps, 0.000 decl_ps, 0.565 stream_ps
err:d3d_draw:drawPrimitive 0.000 vs_decl_stream, 0.000 vs_decl_ps, 0.018 vs_stream_ps, 0.003 decl_stream_ps

Mass Effect 2:
err:d3d_draw:drawPrimitive 0.000 none, 0.122 all
err:d3d_draw:drawPrimitive 0.000 vs only, 0.000 stream only, 0.000 decl only, 0.434 ps only
err:d3d_draw:drawPrimitive 0.000 vs_stream, 0.000 vs_decl, 0.000 stream_decl, 0.030 vs_ps, 0.000 decl_ps, 0.282 stream_ps
err:d3d_draw:drawPrimitive 0.000 vs_decl_stream, 0.000 vs_decl_ps, 0.062 vs_stream_ps, 0.070 decl_stream_ps

StarCraft 2:
err:d3d_draw:drawPrimitive 0.000 none, 0.173 all
err:d3d_draw:drawPrimitive 0.000 vs only, 0.000 stream only, 0.000 decl only, 0.324 ps only
err:d3d_draw:drawPrimitive 0.000 vs_stream, 0.000 vs_decl, 0.000 stream_decl, 0.065 vs_ps, 0.000 decl_ps, 0.311 stream_ps
err:d3d_draw:drawPrimitive 0.000 vs_decl_stream, 0.000 vs_decl_ps, 0.108 vs_stream_ps, 0.019 decl_stream_ps

Half Life 2:
err:d3d_draw:drawPrimitive 0.000 none, 0.197 all
err:d3d_draw:drawPrimitive 0.000 vs only, 0.000 stream only, 0.000 decl only, 0.489 ps only
err:d3d_draw:drawPrimitive 0.000 vs_stream, 0.000 vs_decl, 0.000 stream_decl, 0.113 vs_ps, 0.001 decl_ps, 0.135 stream_ps
err:d3d_draw:drawPrimitive 0.000 vs_decl_stream, 0.020 vs_decl_ps, 0.038 vs_stream_ps, 0.007 decl_stream_ps
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20110618/6543fc8d/attachment.pgp>


More information about the wine-devel mailing list