Module: wine
Branch: master
Commit: ddf52dda15e83eae639ef2ce0ec4071b321ce34f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ddf52dda15e83eae639ef2ce0…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Sun Mar 30 14:52:18 2008 +0200
wined3d: Deactivate GL_FRAGMENT_SHADER_ATI before deactivating a context.
Mesa has a bug that causes a crash due to a NULL pointer dereference
with the R200 driver when making a context current that has
GL_FRAGMENT_SHADER_ATI enabled. This patch works around this bug by
making sure that GL_FRAGMENT_SHADER_ATI is disabled before deactivating
a context, and reactivates it afterwards. The context manager keeps
GL_ATI_FRAGMENT_SHADER generally enabled, except if the context is in 2D
blit mode.
---
dlls/wined3d/context.c | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 0934180..d20f5f2 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -351,6 +351,11 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
/* Set up the context defaults */
oldCtx = pwglGetCurrentContext();
oldDrawable = pwglGetCurrentDC();
+ if(oldCtx && oldDrawable && GL_SUPPORT(ATI_FRAGMENT_SHADER)) {
+ /* See comment in ActivateContext context switching */
+ glDisable(GL_FRAGMENT_SHADER_ATI);
+ checkGLcall("glEnable(GL_FRAGMENT_SHADER_ATI)");
+ }
if(pwglMakeCurrent(hdc, ctx) == FALSE) {
ERR("Cannot activate context to set up defaults\n");
goto out;
@@ -414,9 +419,6 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + s - 1);
checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ...\n");
}
- } else if(GL_SUPPORT(ATI_FRAGMENT_SHADER)) {
- glEnable(GL_FRAGMENT_SHADER_ATI);
- checkGLcall("glEnable(GL_FRAGMENT_SHADER_ATI)");
}
if(GL_SUPPORT(ARB_POINT_SPRITE)) {
@@ -428,9 +430,16 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
}
LEAVE_GL();
+ /* Never keep GL_FRAGMENT_SHADER_ATI enabled on a context that we switch away from,
+ * but enable it for the first context we create, and reenable it on the old context
+ */
if(oldDrawable && oldCtx) {
pwglMakeCurrent(oldDrawable, oldCtx);
}
+ if(GL_SUPPORT(ATI_FRAGMENT_SHADER)) {
+ glEnable(GL_FRAGMENT_SHADER_ATI);
+ checkGLcall("glEnable(GL_FRAGMENT_SHADER_ATI)");
+ }
out:
return ret;
@@ -928,9 +937,23 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
}
else {
TRACE("Switching gl ctx to %p, hdc=%p ctx=%p\n", context, context->hdc, context->glCtx);
+
+ if(GL_SUPPORT(ATI_FRAGMENT_SHADER)) {
+ /* Mesa crashes when enabling a context with GL_FRAGMENT_SHADER_ATI enabled.
+ * Thus we disable it before deactivating any context, and re-enable it afterwards.
+ *
+ * This bug is filed as bug #15269 on bugs.freedesktop.org
+ */
+ glDisable(GL_FRAGMENT_SHADER_ATI);
+ checkGLcall("glEnable(GL_FRAGMENT_SHADER_ATI)");
+ }
+
ret = pwglMakeCurrent(context->hdc, context->glCtx);
if(ret == FALSE) {
ERR("Failed to activate the new context\n");
+ } else if(GL_SUPPORT(ATI_FRAGMENT_SHADER) && !context->last_was_blit) {
+ glEnable(GL_FRAGMENT_SHADER_ATI);
+ checkGLcall("glEnable(GL_FRAGMENT_SHADER_ATI)");
}
}
if(This->activeContext->vshader_const_dirty) {
Module: wine
Branch: master
Commit: 20e63160df1be7f43af17c251247c8412d741b1a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=20e63160df1be7f43af17c251…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Thu Apr 3 11:41:02 2008 +0200
wined3d: Initialize some ARB shader output parameters.
---
dlls/wined3d/arb_program_shader.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 7a841cd..a8d2c70 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -1987,12 +1987,27 @@ static void shader_arb_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFF
/* We need a constant to fixup the final position */
shader_addline(buffer, "PARAM posFixup = program.env[%d];\n", ARB_SHADER_PRIVCONST_POS);
- if((GLINFO_LOCATION).set_texcoord_w) {
- int i;
- for(i = 0; i < min(8, MAX_REG_TEXCRD); i++) {
- if(This->baseShader.reg_maps.texcoord_mask[i] != 0 &&
- This->baseShader.reg_maps.texcoord_mask[i] != WINED3DSP_WRITEMASK_ALL) {
- shader_addline(buffer, "MOV result.texcoord[%u].w, -helper_const.y;\n", i);
+ /* Initialize output parameters. GL_ARB_vertex_program does not require special initialization values
+ * for output parameters. D3D in theory does not do that either, but some applications depend on a
+ * proper initialization of the secondary color, and programs using the fixed function pipeline without
+ * a replacement shader depend on the texcoord.w beeing set properly.
+ *
+ * GL_NV_vertex_program defines that all output values are initialized to {0.0, 0.0, 0.0, 1.0}. This
+ * assetion is in effect even when using GL_ARB_vertex_program without any NV specific additions. So
+ * skip this if NV_vertex_program is supported. Otherwise, initialize the secondary color. For the tex-
+ * coords, we have a flag in the opengl caps. Many cards do not require the texcoord beeing set, and
+ * this can eat a number of instructions, so skip it unless this cap is set as well
+ */
+ if(!GL_SUPPORT(NV_VERTEX_PROGRAM)) {
+ shader_addline(buffer, "MOV result.color.secondary, -helper_const.wwwy;\n");
+
+ if((GLINFO_LOCATION).set_texcoord_w) {
+ int i;
+ for(i = 0; i < min(8, MAX_REG_TEXCRD); i++) {
+ if(This->baseShader.reg_maps.texcoord_mask[i] != 0 &&
+ This->baseShader.reg_maps.texcoord_mask[i] != WINED3DSP_WRITEMASK_ALL) {
+ shader_addline(buffer, "MOV result.texcoord[%u].w, -helper_const.y;\n", i);
+ }
}
}
}