Henri Verbeet : wined3d: Preload textures before applying states.
Alexandre Julliard
julliard at winehq.org
Wed Feb 3 09:33:05 CST 2010
Module: wine
Branch: master
Commit: 31d51fb1754d02514e28f2b8db6fbe8206834f6d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=31d51fb1754d02514e28f2b8db6fbe8206834f6d
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Wed Feb 3 11:02:21 2010 +0100
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 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index a3da14a..ffc105e 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 bf5ad3c..0652172 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 5384f3e..81f5386 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 afc4511..17e2733 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;
More information about the wine-cvs
mailing list