Stefan Dösinger : wined3d: Work around an ARBFP vs GLSL bug in Mac OS.

Alexandre Julliard julliard at winehq.org
Wed May 27 09:26:53 CDT 2009


Module: wine
Branch: master
Commit: 0629585c2401fd41cc8610a2f841a4db2fdeade6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0629585c2401fd41cc8610a2f841a4db2fdeade6

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Thu May  7 11:40:44 2009 +0200

wined3d: Work around an ARBFP vs GLSL bug in Mac OS.

---

 dlls/wined3d/context.c         |   21 +++++++++++++++++++++
 dlls/wined3d/wined3d_private.h |    1 +
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 8fb075d..ba1e100 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -946,6 +946,24 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
             checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ...\n");
         }
     }
+    if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) {
+        /* MacOS(radeon X1600 at least, but most likely others too) refuses to draw if GLSL and ARBFP are
+         * enabled, but the currently bound arbfp program is 0. Enabling ARBFP with prog 0 is invalid, but
+         * GLSL should bypass this. This causes problems in programs that never use the fixed function pipeline,
+         * because the ARBFP extension is enabled by the ARBFP pipeline at context creation, but no program
+         * is ever assigned.
+         *
+         * So make sure a program is assigned to each context. The first real ARBFP use will set a different
+         * program and the dummy program is destroyed when the context is destroyed.
+         */
+        const char *dummy_program =
+                "!!ARBfp1.0\n"
+                "MOV result.color, fragment.color.primary;\n"
+                "END\n";
+        GL_EXTCALL(glGenProgramsARB(1, &ret->dummy_arbfp_prog));
+        GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ret->dummy_arbfp_prog));
+        GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(dummy_program), dummy_program));
+    }
 
     for(s = 0; s < GL_LIMITS(point_sprite_units); s++) {
         GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + s));
@@ -1065,6 +1083,9 @@ void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context) {
         TRACE("Destroy dst FBO %d\n", context->dst_fbo);
         context_destroy_fbo(This, &context->dst_fbo);
     }
+    if(context->dummy_arbfp_prog) {
+        GL_EXTCALL(glDeleteProgramsARB(1, &context->dummy_arbfp_prog));
+    }
 
     LEAVE_GL();
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index f136dd8..1698504 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1234,6 +1234,7 @@ struct WineD3DContext {
     GLint                   gl_fog_source;
     GLfloat                 fog_coord_value;
     GLfloat                 color[4], fogstart, fogend, fogcolor[4];
+    GLuint                  dummy_arbfp_prog;
 };
 
 typedef enum ContextUsage {




More information about the wine-cvs mailing list