Commit c5bf96c9 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Get rid of IWineD3DBaseTextureClass.

parent 316f1c2e
......@@ -503,10 +503,15 @@ static void shader_arb_load_np2fixup_constants(void *shader_priv,
continue;
}
if (idx % 2) {
tex_dim[2] = tex->baseTexture.pow2Matrix[0]; tex_dim[3] = tex->baseTexture.pow2Matrix[5];
} else {
tex_dim[0] = tex->baseTexture.pow2Matrix[0]; tex_dim[1] = tex->baseTexture.pow2Matrix[5];
if (idx % 2)
{
tex_dim[2] = tex->pow2_matrix[0];
tex_dim[3] = tex->pow2_matrix[5];
}
else
{
tex_dim[0] = tex->pow2_matrix[0];
tex_dim[1] = tex->pow2_matrix[5];
}
}
......@@ -1344,7 +1349,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
case WINED3DSTT_2D:
texture = device->stateBlock->state.textures[sampler_idx];
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
{
tex_type = "RECT";
} else {
......
......@@ -151,10 +151,10 @@ static void context_apply_attachment_filter_states(const struct wined3d_context
update_magfilter = TRUE;
}
if (texture->baseTexture.bindCount)
if (texture->bind_count)
{
WARN("Render targets should not be bound to a sampler\n");
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(texture->baseTexture.sampler));
IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(texture->sampler));
}
if (update_minfilter || update_magfilter)
......
......@@ -460,7 +460,7 @@ static void device_preload_texture(const struct wined3d_state *state, unsigned i
if (!(texture = state->textures[idx])) return;
srgb = state->sampler_states[idx][WINED3DSAMP_SRGBTEXTURE] ? SRGB_SRGB : SRGB_RGB;
texture->baseTexture.texture_ops->texture_preload(texture, srgb);
texture->texture_ops->texture_preload(texture, srgb);
}
void device_preload_textures(IWineD3DDeviceImpl *device)
......@@ -4501,11 +4501,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
if (texture)
{
LONG bind_count = InterlockedIncrement(&texture->baseTexture.bindCount);
LONG bind_count = InterlockedIncrement(&texture->bind_count);
wined3d_texture_incref(texture);
if (!prev || texture->baseTexture.target != prev->baseTexture.target)
if (!prev || texture->target != prev->target)
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADER);
if (!prev && stage < gl_info->limits.texture_stages)
......@@ -4518,12 +4518,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
}
if (bind_count == 1)
texture->baseTexture.sampler = stage;
texture->sampler = stage;
}
if (prev)
{
LONG bind_count = InterlockedDecrement(&prev->baseTexture.bindCount);
LONG bind_count = InterlockedDecrement(&prev->bind_count);
wined3d_texture_decref(prev);
......@@ -4533,7 +4533,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, WINED3DTSS_ALPHAOP));
}
if (bind_count && prev->baseTexture.sampler == stage)
if (bind_count && prev->sampler == stage)
{
unsigned int i;
......@@ -4545,7 +4545,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface,
if (This->updateStateBlock->state.textures[i] == prev)
{
TRACE("Texture is also bound to stage %u.\n", i);
prev->baseTexture.sampler = i;
prev->sampler = i;
break;
}
}
......@@ -5120,7 +5120,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture(IWineD3DDevice *iface,
}
/* Make sure that the destination texture is loaded. */
dst_texture->baseTexture.texture_ops->texture_preload(dst_texture, SRGB_RGB);
dst_texture->texture_ops->texture_preload(dst_texture, SRGB_RGB);
/* Update every surface level of the texture. */
switch (type)
......
......@@ -711,10 +711,15 @@ static void shader_glsl_load_np2fixup_constants(void *shader_priv,
continue;
}
if (idx % 2) {
tex_dim[2] = tex->baseTexture.pow2Matrix[0]; tex_dim[3] = tex->baseTexture.pow2Matrix[5];
} else {
tex_dim[0] = tex->baseTexture.pow2Matrix[0]; tex_dim[1] = tex->baseTexture.pow2Matrix[5];
if (idx % 2)
{
tex_dim[2] = tex->pow2_matrix[0];
tex_dim[3] = tex->pow2_matrix[5];
}
else
{
tex_dim[0] = tex->pow2_matrix[0];
tex_dim[1] = tex->pow2_matrix[5];
}
}
......@@ -1065,14 +1070,14 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
texture = state->textures[i];
if (pshader && ps_args->shadow & (1 << i))
{
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
shader_addline(buffer, "uniform sampler2DRectShadow %csampler%u;\n", prefix, i);
else
shader_addline(buffer, "uniform sampler2DShadow %csampler%u;\n", prefix, i);
}
else
{
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
shader_addline(buffer, "uniform sampler2DRect %csampler%u;\n", prefix, i);
else
shader_addline(buffer, "uniform sampler2D %csampler%u;\n", prefix, i);
......@@ -3079,7 +3084,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
}
}
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
......@@ -3133,7 +3138,7 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
sampler_idx = ins->src[1].reg.idx;
texture = device->stateBlock->state.textures[sampler_idx];
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
......@@ -3159,7 +3164,7 @@ static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins)
sampler_idx = ins->src[1].reg.idx;
texture = device->stateBlock->state.textures[sampler_idx];
if (texture && texture->baseTexture.target == GL_TEXTURE_RECTANGLE_ARB)
if (texture && texture->target == GL_TEXTURE_RECTANGLE_ARB)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
......
......@@ -45,7 +45,7 @@ static void nvts_activate_dimensions(const struct wined3d_state *state, DWORD st
if (state->textures[stage])
{
switch (state->textures[stage]->baseTexture.target)
switch (state->textures[stage]->target)
{
case GL_TEXTURE_2D:
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_2D);
......
......@@ -2101,10 +2101,8 @@ void find_ps_compile_args(const struct wined3d_state *state,
args->shadow |= 1 << i;
/* Flag samplers that need NP2 texcoord fixup. */
if (!texture->baseTexture.pow2Matrix_identity)
{
if (!texture->pow2_matrix_identity)
args->np2_fixup |= (1 << i);
}
}
if (shader->baseShader.reg_maps.shader_version.major >= 3)
{
......@@ -2332,7 +2330,7 @@ void pixelshader_update_samplers(struct wined3d_shader_reg_maps *reg_maps, struc
continue;
}
switch (textures[i]->baseTexture.target)
switch (textures[i]->target)
{
case GL_TEXTURE_RECTANGLE_ARB:
case GL_TEXTURE_2D:
......@@ -2351,8 +2349,7 @@ void pixelshader_update_samplers(struct wined3d_shader_reg_maps *reg_maps, struc
break;
default:
FIXME("Unrecognized texture type %#x, using 2D.\n",
textures[i]->baseTexture.target);
FIXME("Unrecognized texture type %#x, using 2D.\n", textures[i]->target);
sampler_type[i] = WINED3DSTT_2D;
}
}
......
......@@ -499,11 +499,11 @@ static void state_alpha(DWORD state, struct wined3d_stateblock *stateblock, stru
if (stateblock->state.textures[0])
{
struct wined3d_texture *texture = stateblock->state.textures[0];
GLenum texture_dimensions = texture->baseTexture.target;
GLenum texture_dimensions = texture->target;
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
{
IWineD3DSurfaceImpl *surf = surface_from_resource(texture->baseTexture.sub_resources[0]);
IWineD3DSurfaceImpl *surf = surface_from_resource(texture->sub_resources[0]);
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT)
{
......@@ -3192,11 +3192,11 @@ void tex_alphaop(DWORD state, struct wined3d_stateblock *stateblock, struct wine
if (stateblock->state.render_states[WINED3DRS_COLORKEYENABLE] && !stage && stateblock->state.textures[0])
{
struct wined3d_texture *texture = stateblock->state.textures[0];
GLenum texture_dimensions = texture->baseTexture.target;
GLenum texture_dimensions = texture->target;
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
{
IWineD3DSurfaceImpl *surf = surface_from_resource(texture->baseTexture.sub_resources[0]);
IWineD3DSurfaceImpl *surf = surface_from_resource(texture->sub_resources[0]);
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT && !surf->resource.format->alpha_mask)
{
......@@ -3307,7 +3307,7 @@ static void transform_texture(DWORD state_id, struct wined3d_stateblock *statebl
if (!use_ps(state))
{
TRACE("Non power two matrix multiply fixup\n");
glMultMatrixf(state->textures[texUnit]->baseTexture.pow2Matrix);
glMultMatrixf(state->textures[texUnit]->pow2_matrix);
}
}
}
......@@ -3598,8 +3598,9 @@ static void sampler_texmatrix(DWORD state, struct wined3d_stateblock *stateblock
* The mapped stage is already active because the sampler() function below, which is part of the
* misc pipeline
*/
if(sampler < MAX_TEXTURES) {
const BOOL texIsPow2 = !texture->baseTexture.pow2Matrix_identity;
if (sampler < MAX_TEXTURES)
{
const BOOL texIsPow2 = !texture->pow2_matrix_identity;
if (texIsPow2 || (context->lastWasPow2Texture & (1 << sampler)))
{
......@@ -3646,7 +3647,7 @@ static void sampler(DWORD state_id, struct wined3d_stateblock *stateblock, struc
struct wined3d_texture *texture = state->textures[sampler];
BOOL srgb = state->sampler_states[sampler][WINED3DSAMP_SRGBTEXTURE];
texture->baseTexture.texture_ops->texture_bind(texture, gl_info, srgb);
texture->texture_ops->texture_bind(texture, gl_info, srgb);
wined3d_texture_apply_state_changes(texture, state->sampler_states[sampler], gl_info);
if (gl_info->supported[EXT_TEXTURE_LOD_BIAS])
......@@ -3670,7 +3671,7 @@ static void sampler(DWORD state_id, struct wined3d_stateblock *stateblock, struc
}
/* Trigger shader constant reloading (for NP2 texcoord fixup) */
if (!texture->baseTexture.pow2Matrix_identity)
if (!texture->pow2_matrix_identity)
{
device->shader_backend->shader_load_np2fixup_constants(device->shader_priv, gl_info, state);
}
......
......@@ -327,9 +327,9 @@ void draw_textured_quad(IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
if (src_surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
struct wined3d_texture *texture = src_surface->container.u.texture;
texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
texture->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
texture->texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
texture->texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
texture->texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
}
}
......@@ -700,7 +700,7 @@ void surface_bind(IWineD3DSurfaceImpl *surface, const struct wined3d_gl_info *gl
struct wined3d_texture *texture = surface->container.u.texture;
TRACE("Passing to container (%p).\n", texture);
texture->baseTexture.texture_ops->texture_bind(texture, gl_info, srgb);
texture->texture_ops->texture_bind(texture, gl_info, srgb);
}
else
{
......@@ -1365,7 +1365,7 @@ void surface_internal_preload(IWineD3DSurfaceImpl *surface, enum WINED3DSRGB srg
struct wined3d_texture *texture = surface->container.u.texture;
TRACE("Passing to container (%p).\n", texture);
texture->baseTexture.texture_ops->texture_preload(texture, srgb);
texture->texture_ops->texture_preload(texture, srgb);
}
else
{
......@@ -1752,14 +1752,14 @@ void surface_prepare_texture(IWineD3DSurfaceImpl *surface, const struct wined3d_
if (surface->container.type == WINED3D_CONTAINER_TEXTURE)
{
struct wined3d_texture *texture = surface->container.u.texture;
UINT sub_count = texture->baseTexture.level_count * texture->baseTexture.layer_count;
UINT sub_count = texture->level_count * texture->layer_count;
UINT i;
TRACE("surface %p is a subresource of texture %p.\n", surface, texture);
for (i = 0; i < sub_count; ++i)
{
IWineD3DSurfaceImpl *s = surface_from_resource(texture->baseTexture.sub_resources[i]);
IWineD3DSurfaceImpl *s = surface_from_resource(texture->sub_resources[i]);
surface_prepare_texture_internal(s, gl_info, srgb);
}
......
......@@ -2803,7 +2803,7 @@ void gen_ffp_frag_op(struct wined3d_stateblock *stateblock, struct ffp_frag_sett
}
else
{
switch (texture->baseTexture.target)
switch (texture->target)
{
case GL_TEXTURE_1D:
settings->op[i].tex_type = tex_1d;
......@@ -2863,11 +2863,11 @@ void gen_ffp_frag_op(struct wined3d_stateblock *stateblock, struct ffp_frag_sett
GLenum texture_dimensions;
texture = stateblock->state.textures[0];
texture_dimensions = texture->baseTexture.target;
texture_dimensions = texture->target;
if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
{
IWineD3DSurfaceImpl *surf = surface_from_resource(texture->baseTexture.sub_resources[0]);
IWineD3DSurfaceImpl *surf = surface_from_resource(texture->sub_resources[0]);
if (surf->CKeyFlags & WINEDDSD_CKSRCBLT && !surf->resource.format->alpha_mask)
{
......@@ -3032,7 +3032,7 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st
{
if (texture)
{
switch (texture->baseTexture.target)
switch (texture->target)
{
case GL_TEXTURE_2D:
glDisable(GL_TEXTURE_3D);
......
......@@ -59,7 +59,7 @@ static void volume_bind_and_dirtify(struct IWineD3DVolumeImpl *volume, const str
IWineD3DDeviceImpl_MarkStateDirty(volume->resource.device, STATE_SAMPLER(active_sampler));
}
container->baseTexture.texture_ops->texture_bind(container, gl_info, FALSE);
container->texture_ops->texture_bind(container, gl_info, FALSE);
}
void volume_add_dirty_box(struct IWineD3DVolumeImpl *volume, const WINED3DBOX *dirty_box)
......
......@@ -1888,30 +1888,25 @@ struct wined3d_texture_ops
void (*texture_sub_resource_cleanup)(struct wined3d_resource *sub_resource);
};
typedef struct IWineD3DBaseTextureClass
struct wined3d_texture
{
struct wined3d_resource resource;
const struct wined3d_texture_ops *texture_ops;
struct gl_texture texture_rgb, texture_srgb;
struct gl_texture texture_rgb, texture_srgb;
struct wined3d_resource **sub_resources;
UINT layer_count;
UINT level_count;
float pow2Matrix[16];
UINT LOD;
WINED3DTEXTUREFILTERTYPE filterType;
LONG bindCount;
DWORD sampler;
BOOL is_srgb;
BOOL pow2Matrix_identity;
BOOL cond_np2;
const struct min_lookup *minMipLookup;
const GLenum *magLookup;
float pow2_matrix[16];
UINT lod;
WINED3DTEXTUREFILTERTYPE filter_type;
LONG bind_count;
DWORD sampler;
BOOL is_srgb;
BOOL pow2_matrix_identity;
BOOL cond_np2;
const struct min_lookup *min_mip_lookup;
const GLenum *mag_lookup;
GLenum target;
} IWineD3DBaseTextureClass;
struct wined3d_texture
{
struct wined3d_resource resource;
IWineD3DBaseTextureClass baseTexture;
};
static inline struct wined3d_texture *wined3d_texture_from_resource(struct wined3d_resource *resource)
......@@ -1923,8 +1918,7 @@ static inline struct gl_texture *wined3d_texture_get_gl_texture(struct wined3d_t
const struct wined3d_gl_info *gl_info, BOOL srgb)
{
return srgb && !gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
? &texture->baseTexture.texture_srgb
: &texture->baseTexture.texture_rgb;
? &texture->texture_srgb : &texture->texture_rgb;
}
void wined3d_texture_apply_state_changes(struct wined3d_texture *texture,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment