wined3d: Preload textures before applying states.

This commit is contained in:
Henri Verbeet 2010-02-03 11:02:21 +01:00 committed by Alexandre Julliard
parent 7ff576bbab
commit 31d51fb175
4 changed files with 46 additions and 1 deletions

View File

@ -2214,6 +2214,7 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI
} }
IWineD3DDeviceImpl_FindTexUnitMap(device); IWineD3DDeviceImpl_FindTexUnitMap(device);
device_preload_textures(device);
ENTER_GL(); ENTER_GL();
for (i = 0; i < context->numDirtyEntries; ++i) for (i = 0; i < context->numDirtyEntries; ++i)

View File

@ -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 * IUnknown parts follows
**********************************************************/ **********************************************************/

View File

@ -3527,7 +3527,6 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine
if(stateblock->textures[sampler]) { if(stateblock->textures[sampler]) {
BOOL srgb = stateblock->samplerState[sampler][WINED3DSAMP_SRGBTEXTURE]; BOOL srgb = stateblock->samplerState[sampler][WINED3DSAMP_SRGBTEXTURE];
IWineD3DBaseTextureImpl *tex_impl = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler]; 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); IWineD3DBaseTexture_BindTexture(stateblock->textures[sampler], srgb);
basetexture_apply_state_changes(stateblock->textures[sampler], basetexture_apply_state_changes(stateblock->textures[sampler],
stateblock->textureState[sampler], stateblock->samplerState[sampler], gl_info); stateblock->textureState[sampler], stateblock->samplerState[sampler], gl_info);

View File

@ -1620,6 +1620,7 @@ struct IWineD3DDeviceImpl
HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags, UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags,
IUnknown *parent, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN; IUnknown *parent, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN;
void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN; UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN; void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;