[PATCH 1/1] d3dx9: Complete test for D3DXCreateSphere. (try 5)

Octavian Voicu octavian.voicu at gmail.com
Mon Jul 26 21:56:05 CDT 2010

On Tue, Jul 27, 2010 at 5:04 AM, Misha Koshelev <misha680 at gmail.com> wrote:
> Linking same file in test and main dll: I am not aware of a precedent for
> this but if there is one of course I would be glad to be shown otherwise.

On second thought, not sure if it is worth it anyway, there is
probably not that much to share.

> Second comment: please pardon if I am misunderstanding but how is what you
> suggest not simply moving the lookup table calculation from the helper
> function which we will also use for, at the very least, the cylinder test,
> inside the actual compute_sphere function itself?

My observation is that you don't need to precompute *both* tables for
compute_sphere (you still need to compute the phi table) -- so no, I'm
not suggesting you move the lookup table calculation from the helper.

As for the theta table, you only access it by theta.sin[stack] and
theta.cos[stack] from the inner loop, so you could do something like

    /* middle */
    theta = theta_start;
    for (stack = 0; stack < stacks - 1; stack++)
        sin_theta = sin(theta);
        cos_theta = cos(theta);
        for (slice = 0; slice < slices; slice++)
            mesh->vertices[vertex].normal.x = sin_theta * phi.cos[slice];
            mesh->vertices[vertex].normal.y = sin_theta * phi.sin[slice];
            mesh->vertices[vertex].normal.z = cos_theta;
            mesh->vertices[vertex].position.x = radius * sin_theta *
            mesh->vertices[vertex].position.y = radius * sin_theta *
            mesh->vertices[vertex].position.z = radius * cos_theta;
            /* ... */
        /* ... */
        theta += theta_step;

Anyway, this is a minor issue. Although the above is a bit faster
(because you don't need to allocate an extra table and then access it
in memory), it's not very relevant for the tests.

I only mentioned it because I noticed you didn't update the
D3DXCreateSphere implementation to use tables yet, so maybe you use
this when you do. If some app would call D3DXCreateSphere very often,
then it might be worth it.

Keep up the good work!


More information about the wine-devel mailing list