From 31d51fb1754d02514e28f2b8db6fbe8206834f6d Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 3 Feb 2010 11:02:21 +0100 Subject: [PATCH] wined3d: Preload textures before applying states. --- dlls/wined3d/context.c | 1 + dlls/wined3d/device.c | 44 ++++++++++++++++++++++++++++++++++ dlls/wined3d/state.c | 1 - dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index a3da14a19e..ffc105e02f 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2214,6 +2214,7 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI } IWineD3DDeviceImpl_FindTexUnitMap(device); + device_preload_textures(device); ENTER_GL(); for (i = 0; i < context->numDirtyEntries; ++i) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index bf5ad3c28b..0652172a84 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -370,6 +370,50 @@ void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info, } } +static void device_preload_texture(IWineD3DStateBlockImpl *stateblock, unsigned int idx) +{ + IWineD3DBaseTextureImpl *texture; + enum WINED3DSRGB srgb; + + if (!(texture = (IWineD3DBaseTextureImpl *)stateblock->textures[idx])) return; + srgb = stateblock->samplerState[idx][WINED3DSAMP_SRGBTEXTURE] ? SRGB_SRGB : SRGB_RGB; + texture->baseTexture.internal_preload((IWineD3DBaseTexture *)texture, srgb); +} + +void device_preload_textures(IWineD3DDeviceImpl *device) +{ + IWineD3DStateBlockImpl *stateblock = device->stateBlock; + unsigned int i; + + if (use_vs(stateblock)) + { + for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) + { + if (((IWineD3DBaseShaderImpl *)stateblock->vertexShader)->baseShader.reg_maps.sampler_type[i]) + device_preload_texture(stateblock, MAX_FRAGMENT_SAMPLERS + i); + } + } + + if (use_ps(stateblock)) + { + for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) + { + if (((IWineD3DBaseShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.sampler_type[i]) + device_preload_texture(stateblock, i); + } + } + else + { + WORD ffu_map = device->fixed_function_usage_map; + + for (i = 0; ffu_map; ffu_map >>= 1, ++i) + { + if (ffu_map & 1) + device_preload_texture(stateblock, i); + } + } +} + /********************************************************** * IUnknown parts follows **********************************************************/ diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 5384f3e57d..81f5386b69 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3527,7 +3527,6 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine if(stateblock->textures[sampler]) { BOOL srgb = stateblock->samplerState[sampler][WINED3DSAMP_SRGBTEXTURE]; IWineD3DBaseTextureImpl *tex_impl = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler]; - tex_impl->baseTexture.internal_preload(stateblock->textures[sampler], srgb ? SRGB_SRGB : SRGB_RGB); IWineD3DBaseTexture_BindTexture(stateblock->textures[sampler], srgb); basetexture_apply_state_changes(stateblock->textures[sampler], stateblock->textureState[sampler], stateblock->samplerState[sampler], gl_info); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index afc45114ce..17e27332f1 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1620,6 +1620,7 @@ struct IWineD3DDeviceImpl HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags, IUnknown *parent, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN; +void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN; LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN; void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN; -- 2.32.0.93.g670b81a890