Module: wine Branch: refs/heads/master Commit: ea905eab09e325b425f3e392ddddf0e8861c3bd8 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=ea905eab09e325b425f3e392...
Author: H. Verbeet hverbeet@gmail.com Date: Thu Aug 3 21:53:16 2006 +0200
wined3d: Disable vertex arrays after we're done drawing from them.
After drawing from a vertex array we should disable them, to prevent the next draw calls from potentially reading past their ends. This also moves the disabling of vertex attrib arrays (for shaders) into its own function.
---
dlls/wined3d/drawprim.c | 55 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index ab6162c..e337789 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -794,6 +794,27 @@ static void draw_vertex(IWineD3DDevice * } #endif /* TODO: Software shaders */
+/* This should match any arrays loaded in loadNumberedArrays. */ +/* TODO: Only load / unload arrays if we have to. */ +static void unloadNumberedArrays(IWineD3DDevice *iface) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + + /* disable any attribs (this is the same for both GLSL and ARB modes) */ + GLint maxAttribs; + int i; + + /* Leave all the attribs disabled */ + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &maxAttribs); + /* MESA does not support it right not */ + if (glGetError() != GL_NO_ERROR) + maxAttribs = 16; + for (i = 0; i < maxAttribs; ++i) { + GL_EXTCALL(glDisableVertexAttribArrayARB(i)); + checkGLcall("glDisableVertexAttribArrayARB(reg);"); + } +} + +/* TODO: Only load / unload arrays if we have to. */ static void loadNumberedArrays( IWineD3DDevice *iface, IWineD3DVertexShader *shader, @@ -825,6 +846,25 @@ static void loadNumberedArrays( } }
+/* This should match any arrays loaded in loadVertexData. */ +/* TODO: Only load / unload arrays if we have to. */ +static void unloadVertexData(IWineD3DDevice *iface) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + int texture_idx; + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { + glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); + } + for (texture_idx = 0; texture_idx < GL_LIMITS(textures); ++texture_idx) { + glClientActiveTextureARB(GL_TEXTURE0_ARB + texture_idx); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +} + +/* TODO: Only load / unload arrays if we have to. */ static void loadVertexData(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd) { unsigned int textureNo = 0; unsigned int texture_idx = 0; @@ -1814,21 +1854,12 @@ #undef BUFFER_OR_DATA
/* Cleanup vertex program */ if (useVertexShaderFunction) { - /* disable any attribs (this is the same for both GLSL and ARB modes) */ - GLint maxAttribs; - int i; - /* Leave all the attribs disabled */ - glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &maxAttribs); - /* MESA does not support it right not */ - if (glGetError() != GL_NO_ERROR) - maxAttribs = 16; - for (i = 0; i < maxAttribs; ++i) { - GL_EXTCALL(glDisableVertexAttribArrayARB(i)); - checkGLcall("glDisableVertexAttribArrayARB(reg);"); - } + unloadNumberedArrays(iface);
if (wined3d_settings.vs_selected_mode == SHADER_ARB) glDisable(GL_VERTEX_PROGRAM_ARB); + } else { + unloadVertexData(iface); }
/* Cleanup fragment program */