mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 20:59:54 +00:00
wined3d: Track GL texture states in a separate structure.
This commit is contained in:
parent
1c93ab1ee0
commit
5b5e3bd0d2
@ -45,8 +45,8 @@ HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DR
|
||||
texture->baseTexture.levels = levels;
|
||||
texture->baseTexture.filterType = (usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3DTEXF_LINEAR : WINED3DTEXF_NONE;
|
||||
texture->baseTexture.LOD = 0;
|
||||
texture->baseTexture.dirty = TRUE;
|
||||
texture->baseTexture.srgbDirty = TRUE;
|
||||
texture->baseTexture.texture_rgb.dirty = TRUE;
|
||||
texture->baseTexture.texture_srgb.dirty = TRUE;
|
||||
texture->baseTexture.is_srgb = FALSE;
|
||||
texture->baseTexture.pow2Matrix_identity = TRUE;
|
||||
|
||||
@ -75,23 +75,23 @@ void basetexture_unload(IWineD3DBaseTexture *iface)
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
|
||||
|
||||
if(This->baseTexture.textureName) {
|
||||
if(This->baseTexture.texture_rgb.name) {
|
||||
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
|
||||
ENTER_GL();
|
||||
glDeleteTextures(1, &This->baseTexture.textureName);
|
||||
This->baseTexture.textureName = 0;
|
||||
glDeleteTextures(1, &This->baseTexture.texture_rgb.name);
|
||||
This->baseTexture.texture_rgb.name = 0;
|
||||
LEAVE_GL();
|
||||
}
|
||||
|
||||
if(This->baseTexture.srgbTextureName) {
|
||||
if(This->baseTexture.texture_srgb.name) {
|
||||
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
|
||||
ENTER_GL();
|
||||
glDeleteTextures(1, &This->baseTexture.srgbTextureName);
|
||||
This->baseTexture.srgbTextureName = 0;
|
||||
glDeleteTextures(1, &This->baseTexture.texture_srgb.name);
|
||||
This->baseTexture.texture_srgb.name = 0;
|
||||
LEAVE_GL();
|
||||
}
|
||||
This->baseTexture.dirty = TRUE;
|
||||
This->baseTexture.srgbDirty = TRUE;
|
||||
This->baseTexture.texture_rgb.dirty = TRUE;
|
||||
This->baseTexture.texture_srgb.dirty = TRUE;
|
||||
}
|
||||
|
||||
DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
|
||||
@ -113,8 +113,8 @@ DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
|
||||
if(This->baseTexture.LOD != LODNew) {
|
||||
This->baseTexture.LOD = LODNew;
|
||||
|
||||
This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
|
||||
This->baseTexture.srgbstates[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
|
||||
This->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
|
||||
This->baseTexture.texture_srgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
|
||||
if(This->baseTexture.bindCount) {
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(This->baseTexture.sampler));
|
||||
}
|
||||
@ -158,7 +158,7 @@ HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DT
|
||||
*/
|
||||
ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
|
||||
ENTER_GL();
|
||||
glBindTexture(textureDimensions, This->baseTexture.textureName);
|
||||
glBindTexture(textureDimensions, This->baseTexture.texture_rgb.name);
|
||||
checkGLcall("glBindTexture");
|
||||
switch(FilterType) {
|
||||
case WINED3DTEXF_NONE:
|
||||
@ -205,16 +205,16 @@ BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty)
|
||||
{
|
||||
BOOL old;
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
old = This->baseTexture.dirty || This->baseTexture.srgbDirty;
|
||||
This->baseTexture.dirty = dirty;
|
||||
This->baseTexture.srgbDirty = dirty;
|
||||
old = This->baseTexture.texture_rgb.dirty || This->baseTexture.texture_srgb.dirty;
|
||||
This->baseTexture.texture_rgb.dirty = dirty;
|
||||
This->baseTexture.texture_srgb.dirty = dirty;
|
||||
return old;
|
||||
}
|
||||
|
||||
BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface)
|
||||
{
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
return This->baseTexture.dirty || This->baseTexture.srgbDirty;
|
||||
return This->baseTexture.texture_rgb.dirty || This->baseTexture.texture_srgb.dirty;
|
||||
}
|
||||
|
||||
/* Context activation is done by the caller. */
|
||||
@ -224,49 +224,46 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
|
||||
HRESULT hr = WINED3D_OK;
|
||||
UINT textureDimensions;
|
||||
BOOL isNewTexture = FALSE;
|
||||
GLuint *texture;
|
||||
DWORD *states;
|
||||
struct gl_texture *gl_tex;
|
||||
TRACE("(%p) : About to bind texture\n", This);
|
||||
|
||||
This->baseTexture.is_srgb = srgb; /* SRGB mode cache for PreLoad calls outside drawprim */
|
||||
if(srgb) {
|
||||
texture = &This->baseTexture.srgbTextureName;
|
||||
states = This->baseTexture.srgbstates;
|
||||
gl_tex = &This->baseTexture.texture_srgb;
|
||||
} else {
|
||||
texture = &This->baseTexture.textureName;
|
||||
states = This->baseTexture.states;
|
||||
gl_tex = &This->baseTexture.texture_rgb;
|
||||
}
|
||||
|
||||
textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
|
||||
ENTER_GL();
|
||||
/* Generate a texture name if we don't already have one */
|
||||
if (*texture == 0) {
|
||||
if (gl_tex->name == 0) {
|
||||
*set_surface_desc = TRUE;
|
||||
glGenTextures(1, texture);
|
||||
glGenTextures(1, &gl_tex->name);
|
||||
checkGLcall("glGenTextures");
|
||||
TRACE("Generated texture %d\n", *texture);
|
||||
TRACE("Generated texture %d\n", gl_tex->name);
|
||||
if (This->resource.pool == WINED3DPOOL_DEFAULT) {
|
||||
/* Tell opengl to try and keep this texture in video ram (well mostly) */
|
||||
GLclampf tmp;
|
||||
tmp = 0.9f;
|
||||
glPrioritizeTextures(1, texture, &tmp);
|
||||
glPrioritizeTextures(1, &gl_tex->name, &tmp);
|
||||
|
||||
}
|
||||
/* Initialise the state of the texture object
|
||||
to the openGL defaults, not the directx defaults */
|
||||
states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_WRAP;
|
||||
states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_WRAP;
|
||||
states[WINED3DTEXSTA_ADDRESSW] = WINED3DTADDRESS_WRAP;
|
||||
states[WINED3DTEXSTA_BORDERCOLOR] = 0;
|
||||
states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_LINEAR;
|
||||
states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
|
||||
states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
|
||||
states[WINED3DTEXSTA_MAXMIPLEVEL] = 0;
|
||||
states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
|
||||
states[WINED3DTEXSTA_SRGBTEXTURE] = 0;
|
||||
states[WINED3DTEXSTA_ELEMENTINDEX] = 0;
|
||||
states[WINED3DTEXSTA_DMAPOFFSET] = 0;
|
||||
states[WINED3DTEXSTA_TSSADDRESSW] = WINED3DTADDRESS_WRAP;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_WRAP;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_WRAP;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSW] = WINED3DTADDRESS_WRAP;
|
||||
gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = 0;
|
||||
gl_tex->states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_LINEAR;
|
||||
gl_tex->states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
|
||||
gl_tex->states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
|
||||
gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = 0;
|
||||
gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
|
||||
gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE] = 0;
|
||||
gl_tex->states[WINED3DTEXSTA_ELEMENTINDEX] = 0;
|
||||
gl_tex->states[WINED3DTEXSTA_DMAPOFFSET] = 0;
|
||||
gl_tex->states[WINED3DTEXSTA_TSSADDRESSW] = WINED3DTADDRESS_WRAP;
|
||||
IWineD3DBaseTexture_SetDirty(iface, TRUE);
|
||||
isNewTexture = TRUE;
|
||||
|
||||
@ -274,7 +271,7 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
|
||||
/* This means double binding the texture at creation, but keeps the code simpler all
|
||||
* in all, and the run-time path free from additional checks
|
||||
*/
|
||||
glBindTexture(textureDimensions, *texture);
|
||||
glBindTexture(textureDimensions, gl_tex->name);
|
||||
checkGLcall("glBindTexture");
|
||||
glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
|
||||
checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE)");
|
||||
@ -284,8 +281,8 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
|
||||
}
|
||||
|
||||
/* Bind the texture */
|
||||
if (*texture != 0) {
|
||||
glBindTexture(textureDimensions, *texture);
|
||||
if (gl_tex->name != 0) {
|
||||
glBindTexture(textureDimensions, gl_tex->name);
|
||||
checkGLcall("glBindTexture");
|
||||
if (isNewTexture) {
|
||||
/* For a new texture we have to set the textures levels after binding the texture.
|
||||
@ -348,40 +345,41 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
|
||||
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1])
|
||||
{
|
||||
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
|
||||
DWORD state, *states;
|
||||
DWORD state;
|
||||
GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
|
||||
BOOL cond_np2 = IWineD3DBaseTexture_IsCondNP2(iface);
|
||||
DWORD aniso;
|
||||
struct gl_texture *gl_tex;
|
||||
|
||||
TRACE("iface %p, textureStates %p, samplerStates %p\n", iface, textureStates, samplerStates);
|
||||
|
||||
if(This->baseTexture.is_srgb) {
|
||||
states = This->baseTexture.srgbstates;
|
||||
gl_tex = &This->baseTexture.texture_srgb;
|
||||
} else {
|
||||
states = This->baseTexture.states;
|
||||
gl_tex = &This->baseTexture.texture_rgb;
|
||||
}
|
||||
|
||||
/* This function relies on the correct texture being bound and loaded. */
|
||||
|
||||
if(samplerStates[WINED3DSAMP_ADDRESSU] != states[WINED3DTEXSTA_ADDRESSU]) {
|
||||
if(samplerStates[WINED3DSAMP_ADDRESSU] != gl_tex->states[WINED3DTEXSTA_ADDRESSU]) {
|
||||
state = samplerStates[WINED3DSAMP_ADDRESSU];
|
||||
apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_S, cond_np2);
|
||||
states[WINED3DTEXSTA_ADDRESSU] = state;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSU] = state;
|
||||
}
|
||||
|
||||
if(samplerStates[WINED3DSAMP_ADDRESSV] != states[WINED3DTEXSTA_ADDRESSV]) {
|
||||
if(samplerStates[WINED3DSAMP_ADDRESSV] != gl_tex->states[WINED3DTEXSTA_ADDRESSV]) {
|
||||
state = samplerStates[WINED3DSAMP_ADDRESSV];
|
||||
apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_T, cond_np2);
|
||||
states[WINED3DTEXSTA_ADDRESSV] = state;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSV] = state;
|
||||
}
|
||||
|
||||
if(samplerStates[WINED3DSAMP_ADDRESSW] != states[WINED3DTEXSTA_ADDRESSW]) {
|
||||
if(samplerStates[WINED3DSAMP_ADDRESSW] != gl_tex->states[WINED3DTEXSTA_ADDRESSW]) {
|
||||
state = samplerStates[WINED3DSAMP_ADDRESSW];
|
||||
apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_R, cond_np2);
|
||||
states[WINED3DTEXSTA_ADDRESSW] = state;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSW] = state;
|
||||
}
|
||||
|
||||
if(samplerStates[WINED3DSAMP_BORDERCOLOR] != states[WINED3DTEXSTA_BORDERCOLOR]) {
|
||||
if(samplerStates[WINED3DSAMP_BORDERCOLOR] != gl_tex->states[WINED3DTEXSTA_BORDERCOLOR]) {
|
||||
float col[4];
|
||||
|
||||
state = samplerStates[WINED3DSAMP_BORDERCOLOR];
|
||||
@ -389,10 +387,10 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
|
||||
TRACE("Setting border color for %u to %x\n", textureDimensions, state);
|
||||
glTexParameterfv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
|
||||
checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
|
||||
states[WINED3DTEXSTA_BORDERCOLOR] = state;
|
||||
gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = state;
|
||||
}
|
||||
|
||||
if(samplerStates[WINED3DSAMP_MAGFILTER] != states[WINED3DTEXSTA_MAGFILTER]) {
|
||||
if(samplerStates[WINED3DSAMP_MAGFILTER] != gl_tex->states[WINED3DTEXSTA_MAGFILTER]) {
|
||||
GLint glValue;
|
||||
state = samplerStates[WINED3DSAMP_MAGFILTER];
|
||||
if (state > WINED3DTEXF_ANISOTROPIC) {
|
||||
@ -404,25 +402,25 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
|
||||
TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
|
||||
glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
|
||||
|
||||
states[WINED3DTEXSTA_MAGFILTER] = state;
|
||||
gl_tex->states[WINED3DTEXSTA_MAGFILTER] = state;
|
||||
}
|
||||
|
||||
if((samplerStates[WINED3DSAMP_MINFILTER] != states[WINED3DTEXSTA_MINFILTER] ||
|
||||
samplerStates[WINED3DSAMP_MIPFILTER] != states[WINED3DTEXSTA_MIPFILTER] ||
|
||||
samplerStates[WINED3DSAMP_MAXMIPLEVEL] != states[WINED3DTEXSTA_MAXMIPLEVEL])) {
|
||||
if((samplerStates[WINED3DSAMP_MINFILTER] != gl_tex->states[WINED3DTEXSTA_MINFILTER] ||
|
||||
samplerStates[WINED3DSAMP_MIPFILTER] != gl_tex->states[WINED3DTEXSTA_MIPFILTER] ||
|
||||
samplerStates[WINED3DSAMP_MAXMIPLEVEL] != gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL])) {
|
||||
GLint glValue;
|
||||
|
||||
states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
|
||||
states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
|
||||
states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
|
||||
gl_tex->states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
|
||||
gl_tex->states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
|
||||
gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
|
||||
|
||||
if (states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC
|
||||
|| states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_ANISOTROPIC)
|
||||
if (gl_tex->states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC
|
||||
|| gl_tex->states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_ANISOTROPIC)
|
||||
{
|
||||
|
||||
FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %d D3DSAMP_MIPFILTER value %d\n",
|
||||
states[WINED3DTEXSTA_MINFILTER],
|
||||
states[WINED3DTEXSTA_MIPFILTER]);
|
||||
gl_tex->states[WINED3DTEXSTA_MINFILTER],
|
||||
gl_tex->states[WINED3DTEXSTA_MIPFILTER]);
|
||||
}
|
||||
glValue = wined3d_gl_min_mip_filter(This->baseTexture.minMipLookup,
|
||||
min(max(samplerStates[WINED3DSAMP_MINFILTER], WINED3DTEXF_POINT), WINED3DTEXF_LINEAR),
|
||||
@ -435,15 +433,15 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
|
||||
checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
|
||||
|
||||
if(!cond_np2) {
|
||||
if(states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
|
||||
if(gl_tex->states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
|
||||
glValue = This->baseTexture.LOD;
|
||||
} else if(states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
|
||||
} else if(gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
|
||||
glValue = This->baseTexture.levels - 1;
|
||||
} else if(states[WINED3DTEXSTA_MAXMIPLEVEL] < This->baseTexture.LOD) {
|
||||
} else if(gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] < This->baseTexture.LOD) {
|
||||
/* baseTexture.LOD is already clamped in the setter */
|
||||
glValue = This->baseTexture.LOD;
|
||||
} else {
|
||||
glValue = states[WINED3DTEXSTA_MAXMIPLEVEL];
|
||||
glValue = gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL];
|
||||
}
|
||||
/* Note that D3DSAMP_MAXMIPLEVEL specifies the biggest mipmap(default 0), while
|
||||
* GL_TEXTURE_MAX_LEVEL specifies the smallest mimap used(default 1000).
|
||||
@ -453,9 +451,9 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
|
||||
}
|
||||
}
|
||||
|
||||
if ((states[WINED3DSAMP_MAGFILTER] != WINED3DTEXF_ANISOTROPIC
|
||||
&& states[WINED3DSAMP_MINFILTER] != WINED3DTEXF_ANISOTROPIC
|
||||
&& states[WINED3DSAMP_MIPFILTER] != WINED3DTEXF_ANISOTROPIC)
|
||||
if ((gl_tex->states[WINED3DSAMP_MAGFILTER] != WINED3DTEXF_ANISOTROPIC
|
||||
&& gl_tex->states[WINED3DSAMP_MINFILTER] != WINED3DTEXF_ANISOTROPIC
|
||||
&& gl_tex->states[WINED3DSAMP_MIPFILTER] != WINED3DTEXF_ANISOTROPIC)
|
||||
|| cond_np2)
|
||||
{
|
||||
aniso = 1;
|
||||
@ -465,7 +463,7 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
|
||||
aniso = samplerStates[WINED3DSAMP_MAXANISOTROPY];
|
||||
}
|
||||
|
||||
if (states[WINED3DTEXSTA_MAXANISOTROPY] != aniso)
|
||||
if (gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] != aniso)
|
||||
{
|
||||
if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC))
|
||||
{
|
||||
@ -476,6 +474,6 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
|
||||
{
|
||||
WARN("Anisotropic filtering not supported.\n");
|
||||
}
|
||||
states[WINED3DTEXSTA_MAXANISOTROPY] = aniso;
|
||||
gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = aniso;
|
||||
}
|
||||
}
|
||||
|
@ -125,17 +125,17 @@ static void context_apply_attachment_filter_states(IWineD3DSurface *surface, BOO
|
||||
/* Update base texture states array */
|
||||
if (SUCCEEDED(IWineD3DSurface_GetContainer(surface, &IID_IWineD3DBaseTexture, (void **)&texture_impl)))
|
||||
{
|
||||
if (texture_impl->baseTexture.states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_POINT
|
||||
|| texture_impl->baseTexture.states[WINED3DTEXSTA_MIPFILTER] != WINED3DTEXF_NONE)
|
||||
if (texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_POINT
|
||||
|| texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] != WINED3DTEXF_NONE)
|
||||
{
|
||||
texture_impl->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
|
||||
texture_impl->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
|
||||
texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
|
||||
texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
|
||||
update_minfilter = TRUE;
|
||||
}
|
||||
|
||||
if (texture_impl->baseTexture.states[WINED3DTEXSTA_MAGFILTER] != WINED3DTEXF_POINT)
|
||||
if (texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] != WINED3DTEXF_POINT)
|
||||
{
|
||||
texture_impl->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
|
||||
texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
|
||||
update_magfilter = TRUE;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ static void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3
|
||||
srgb_mode = This->baseTexture.is_srgb;
|
||||
break;
|
||||
}
|
||||
dirty = srgb_mode ? &This->baseTexture.srgbDirty : &This->baseTexture.dirty;
|
||||
dirty = srgb_mode ? &This->baseTexture.texture_srgb.dirty : &This->baseTexture.texture_rgb.dirty;
|
||||
|
||||
TRACE("(%p) : About to load texture: dirtified(%u).\n", This, *dirty);
|
||||
|
||||
@ -293,9 +293,9 @@ static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *i
|
||||
for (i = 0; i < This->baseTexture.levels; ++i) {
|
||||
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j) {
|
||||
if(This->baseTexture.is_srgb) {
|
||||
surface_set_texture_name(This->surfaces[j][i], This->baseTexture.srgbTextureName, TRUE);
|
||||
surface_set_texture_name(This->surfaces[j][i], This->baseTexture.texture_srgb.name, TRUE);
|
||||
} else {
|
||||
surface_set_texture_name(This->surfaces[j][i], This->baseTexture.textureName, FALSE);
|
||||
surface_set_texture_name(This->surfaces[j][i], This->baseTexture.texture_rgb.name, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -387,8 +387,8 @@ static HRESULT WINAPI IWineD3DCubeTextureImpl_UnlockRect(IWineD3DCubeTexture *if
|
||||
static HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface, WINED3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) {
|
||||
HRESULT hr = WINED3DERR_INVALIDCALL;
|
||||
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
|
||||
This->baseTexture.dirty = TRUE;
|
||||
This->baseTexture.srgbDirty = TRUE;
|
||||
This->baseTexture.texture_rgb.dirty = TRUE;
|
||||
This->baseTexture.texture_srgb.dirty = TRUE;
|
||||
TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
|
||||
if (FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
|
||||
surface_add_dirty_rect(This->surfaces[FaceType][0], pDirtyRect);
|
||||
|
@ -4696,9 +4696,9 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
|
||||
*/
|
||||
if(SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DBaseTexture, (void **) &texture)))
|
||||
{
|
||||
((IWineD3DBaseTextureImpl *) texture)->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
|
||||
((IWineD3DBaseTextureImpl *) texture)->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
|
||||
((IWineD3DBaseTextureImpl *) texture)->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
|
||||
((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
|
||||
((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
|
||||
((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
|
||||
IWineD3DBaseTexture_Release(texture);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ static void texture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRG
|
||||
srgb_mode = This->baseTexture.is_srgb;
|
||||
break;
|
||||
}
|
||||
dirty = srgb_mode ? &This->baseTexture.srgbDirty : &This->baseTexture.dirty;
|
||||
dirty = srgb_mode ? &This->baseTexture.texture_srgb.dirty : &This->baseTexture.texture_rgb.dirty;
|
||||
|
||||
if (!device->isInDraw)
|
||||
{
|
||||
@ -275,12 +275,16 @@ static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface, BO
|
||||
hr = basetexture_bind((IWineD3DBaseTexture *)iface, srgb, &set_gl_texture_desc);
|
||||
if (set_gl_texture_desc && SUCCEEDED(hr)) {
|
||||
UINT i;
|
||||
struct gl_texture *gl_tex;
|
||||
|
||||
if(This->baseTexture.is_srgb) {
|
||||
gl_tex = &This->baseTexture.texture_srgb;
|
||||
} else {
|
||||
gl_tex = &This->baseTexture.texture_rgb;
|
||||
}
|
||||
|
||||
for (i = 0; i < This->baseTexture.levels; ++i) {
|
||||
if(This->baseTexture.is_srgb) {
|
||||
surface_set_texture_name(This->surfaces[i], This->baseTexture.srgbTextureName, TRUE);
|
||||
} else {
|
||||
surface_set_texture_name(This->surfaces[i], This->baseTexture.textureName, FALSE);
|
||||
}
|
||||
surface_set_texture_name(This->surfaces[i], gl_tex->name, This->baseTexture.is_srgb);
|
||||
}
|
||||
/* Conditinal non power of two textures use a different clamping default. If we're using the GL_WINE_normalized_texrect
|
||||
* partial driver emulation, we're dealing with a GL_TEXTURE_2D texture which has the address mode set to repeat - something
|
||||
@ -298,11 +302,11 @@ static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface, BO
|
||||
glTexParameteri(IWineD3DTexture_GetTextureDimensions(iface), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
|
||||
LEAVE_GL();
|
||||
This->baseTexture.states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_CLAMP;
|
||||
This->baseTexture.states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_CLAMP;
|
||||
This->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
|
||||
This->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
|
||||
This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_CLAMP;
|
||||
gl_tex->states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_CLAMP;
|
||||
gl_tex->states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
|
||||
gl_tex->states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
|
||||
gl_tex->states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,8 +392,8 @@ static HRESULT WINAPI IWineD3DTextureImpl_UnlockRect(IWineD3DTexture *iface, UIN
|
||||
|
||||
static HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, CONST RECT* pDirtyRect) {
|
||||
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
|
||||
This->baseTexture.dirty = TRUE;
|
||||
This->baseTexture.srgbDirty = TRUE;
|
||||
This->baseTexture.texture_rgb.dirty = TRUE;
|
||||
This->baseTexture.texture_srgb.dirty = TRUE;
|
||||
TRACE("(%p) : dirtyfication of surface Level (0)\n", This);
|
||||
surface_add_dirty_rect(This->surfaces[0], pDirtyRect);
|
||||
|
||||
|
@ -266,7 +266,8 @@ static HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, WINED3DL
|
||||
|
||||
if (containerType == WINED3DRTYPE_VOLUMETEXTURE) {
|
||||
IWineD3DBaseTextureImpl* pTexture = (IWineD3DBaseTextureImpl*) cont;
|
||||
pTexture->baseTexture.dirty = TRUE;
|
||||
pTexture->baseTexture.texture_rgb.dirty = TRUE;
|
||||
pTexture->baseTexture.texture_srgb.dirty = TRUE;
|
||||
} else {
|
||||
FIXME("Set dirty on container type %d\n", containerType);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINE
|
||||
|
||||
/* If the texture is marked dirty or the srgb sampler setting has changed
|
||||
* since the last load then reload the volumes. */
|
||||
if (This->baseTexture.dirty)
|
||||
if (This->baseTexture.texture_rgb.dirty)
|
||||
{
|
||||
for (i = 0; i < This->baseTexture.levels; ++i)
|
||||
{
|
||||
@ -74,7 +74,7 @@ static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINE
|
||||
}
|
||||
|
||||
/* No longer dirty */
|
||||
This->baseTexture.dirty = FALSE;
|
||||
This->baseTexture.texture_rgb.dirty = FALSE;
|
||||
}
|
||||
|
||||
static void volumetexture_cleanup(IWineD3DVolumeTextureImpl *This)
|
||||
@ -312,7 +312,8 @@ static HRESULT WINAPI IWineD3DVolumeTextureImpl_UnlockBox(IWineD3DVolumeTexture
|
||||
|
||||
static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, CONST WINED3DBOX* pDirtyBox) {
|
||||
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
|
||||
This->baseTexture.dirty = TRUE;
|
||||
This->baseTexture.texture_rgb.dirty = TRUE;
|
||||
This->baseTexture.texture_srgb.dirty = TRUE;
|
||||
TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
|
||||
volume_add_dirty_box(This->volumes[0], pDirtyBox);
|
||||
|
||||
|
@ -1756,16 +1756,20 @@ enum WINED3DSRGB
|
||||
SRGB_BOTH = 3, /* Loads both textures */
|
||||
};
|
||||
|
||||
struct gl_texture
|
||||
{
|
||||
DWORD states[MAX_WINETEXTURESTATES];
|
||||
BOOL dirty;
|
||||
GLuint name;
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
|
||||
*/
|
||||
typedef struct IWineD3DBaseTextureClass
|
||||
{
|
||||
DWORD states[MAX_WINETEXTURESTATES];
|
||||
DWORD srgbstates[MAX_WINETEXTURESTATES];
|
||||
struct gl_texture texture_rgb, texture_srgb;
|
||||
UINT levels;
|
||||
BOOL dirty, srgbDirty;
|
||||
UINT textureName, srgbTextureName;
|
||||
float pow2Matrix[16];
|
||||
UINT LOD;
|
||||
WINED3DTEXTUREFILTERTYPE filterType;
|
||||
|
Loading…
Reference in New Issue
Block a user