From 5e97e2295190b7e8714fefdb2e0bdb76a2af5e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Mon, 27 Jun 2011 17:52:39 +0200 Subject: [PATCH] wined3d: Separate stream sources and vertex declaration. Changing the stream sources does not require a reapplication of the vertex declaration. Even setting a NULL vertex buffer doesn't make attributes disappear - it just causes a segfault on Windows. --- dlls/wined3d/context.c | 2 +- dlls/wined3d/state.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index bdf1f37827..3af69e895e 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2178,7 +2178,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de * updating a resource location. */ device_update_tex_unit_map(device); device_preload_textures(device); - if (isStateDirty(context, STATE_VDECL)) + if (isStateDirty(context, STATE_VDECL) || isStateDirty(context, STATE_STREAMSRC)) device_update_stream_info(device, context->gl_info); if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 77dd1dd6f6..b17a254e21 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -4468,6 +4468,7 @@ static void streamsrc(DWORD state, struct wined3d_stateblock *stateblock, struct BOOL load_numbered = use_vs(&stateblock->state) && !device->useDrawStridedSlow; BOOL load_named = !use_vs(&stateblock->state) && !device->useDrawStridedSlow; + if (isStateDirty(context, STATE_VDECL)) return; if (context->numberedArraysLoaded && !load_numbered) { unloadNumberedArrays(context); @@ -4494,6 +4495,12 @@ static void streamsrc(DWORD state, struct wined3d_stateblock *stateblock, struct } } +static void vdecl_miscpart(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context) +{ + if (isStateDirty(context, STATE_STREAMSRC)) return; + streamsrc(state, stateblock, context); +} + static void vertexdeclaration(DWORD state_id, struct wined3d_stateblock *stateblock, struct wined3d_context *context) { const struct wined3d_gl_info *gl_info = context->gl_info; @@ -4884,8 +4891,8 @@ const struct StateEntryTemplate misc_state_template[] = { { STATE_RENDER(WINED3DRS_DESTBLENDALPHA), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3DRS_DESTBLENDALPHA), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, { STATE_RENDER(WINED3DRS_BLENDOPALPHA), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), NULL }, WINED3D_GL_EXT_NONE }, - { STATE_STREAMSRC, { STATE_VDECL, NULL }, WINED3D_GL_EXT_NONE }, - { STATE_VDECL, { STATE_VDECL, streamsrc }, WINED3D_GL_EXT_NONE }, + { STATE_STREAMSRC, { STATE_STREAMSRC, streamsrc }, WINED3D_GL_EXT_NONE }, + { STATE_VDECL, { STATE_VDECL, vdecl_miscpart }, WINED3D_GL_EXT_NONE }, { STATE_FRONTFACE, { STATE_FRONTFACE, frontface }, WINED3D_GL_EXT_NONE }, { STATE_SCISSORRECT, { STATE_SCISSORRECT, scissorrect }, WINED3D_GL_EXT_NONE }, { STATE_POINTSPRITECOORDORIGIN, { STATE_POINTSPRITECOORDORIGIN, psorigin }, WINED3D_GL_VERSION_2_0 }, @@ -5063,7 +5070,7 @@ const struct StateEntryTemplate misc_state_template[] = { { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler }, WINED3D_GL_EXT_NONE }, { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler }, WINED3D_GL_EXT_NONE }, { STATE_BASEVERTEXINDEX, { STATE_BASEVERTEXINDEX, state_nop, }, ARB_DRAW_ELEMENTS_BASE_VERTEX }, - { STATE_BASEVERTEXINDEX, { STATE_VDECL, NULL, }, WINED3D_GL_EXT_NONE }, + { STATE_BASEVERTEXINDEX, { STATE_STREAMSRC, NULL, }, WINED3D_GL_EXT_NONE }, {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE }, };