[Bug 20183] Black & White 2: texture corruption on higher resolutions

wine-bugs at winehq.org wine-bugs at winehq.org
Mon Sep 28 03:27:56 CDT 2009


http://bugs.winehq.org/show_bug.cgi?id=20183





--- Comment #5 from Itzamna <xamaniqinqu at gmail.com>  2009-09-28 03:27:55 ---
This bug is caused by invalid pixel point size scaling, which makes sense, as
there are two characteristics:

1) the bug gets more severe at higher resolutions
2) the bug itself looks like pieces of terrain are unfolded and enlarged while
it shouldn't be

The responsible code is part of function 'state_pscale' in
./dlls/wined3d/state.c:

static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock,
struct wined3d_context *context)
{
    /* TODO: Group this with the viewport */
    /*
     * POINTSCALEENABLE controls how point size value is treated. If set to
     * true, the point size is scaled with respect to height of viewport.
     * When set to false point size is in pixels.
     */

    /* Default values */
    GLfloat att[3] = {1.0f, 0.0f, 0.0f};
    union {
        DWORD d;
        float f;
    } pointSize, A, B, C;

    pointSize.d = stateblock->renderState[WINED3DRS_POINTSIZE];
    A.d = stateblock->renderState[WINED3DRS_POINTSCALE_A];
    B.d = stateblock->renderState[WINED3DRS_POINTSCALE_B];
    C.d = stateblock->renderState[WINED3DRS_POINTSCALE_C];

    if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) {
        GLfloat scaleFactor;
        float h = stateblock->viewport.Height;

        if(pointSize.f < GL_LIMITS(pointsizemin)) {
            /*
             * Minimum valid point size for OpenGL is driver specific. For
Direct3D it is
             * 0.0f. This means that OpenGL will clamp really small point sizes
to the
             * driver minimum. To correct for this we need to multiply by the
scale factor when sizes
             * are less than 1.0f. scale_factor =  1.0f / point_size.
             */
            scaleFactor = pointSize.f / GL_LIMITS(pointsizemin);
            /* Clamp the point size, don't rely on the driver to do it. MacOS
says min point size
             * is 1.0, but then accepts points below that and draws too small
points
             */
            pointSize.f = GL_LIMITS(pointsizemin);
        } else if(pointSize.f > GL_LIMITS(pointsize)) {
            /* gl already scales the input to glPointSize,
             * d3d scales the result after the point size scale.
             * If the point size is bigger than the max size, use the
             * scaling to scale it bigger, and set the gl point size to max
             */
            scaleFactor = pointSize.f / GL_LIMITS(pointsize);
            TRACE("scale: %f\n", scaleFactor);
            pointSize.f = GL_LIMITS(pointsize);
        } else {
            scaleFactor = 0.0f;
        }
        scaleFactor = pow(h * scaleFactor, 2);

        att[0] = A.f / scaleFactor;
        att[1] = B.f / scaleFactor;
        att[2] = C.f / scaleFactor;
    }

    if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
        GL_EXTCALL(glPointParameterfvARB)(GL_POINT_DISTANCE_ATTENUATION_ARB,
att);
        checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
    }
    else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
        GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
        checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
    } else if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) {
        WARN("POINT_PARAMETERS not supported in this version of opengl\n");
    }

    glPointSize(pointSize.f);
    checkGLcall("glPointSize(...);");
}

I'm trying to fix it, but I do not know what the minimal / maximal pixel point
sizes allowed in OpenGL are. Can a developer please help me?

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list