Exemple #1
0
/* Do not call while under the GL lock. */
static void texture3d_preload(struct wined3d_texture *texture, enum WINED3DSRGB srgb)
{
    struct wined3d_device *device = texture->resource.device;
    struct wined3d_context *context = NULL;
    BOOL srgb_was_toggled = FALSE;
    unsigned int i;

    TRACE("texture %p, srgb %#x.\n", texture, srgb);

    if (!device->isInDraw)
        context = context_acquire(device, NULL);
    else if (texture->bind_count > 0)
    {
        BOOL texture_srgb = texture->flags & WINED3D_TEXTURE_IS_SRGB;
        BOOL sampler_srgb = texture_srgb_mode(texture, srgb);
        srgb_was_toggled = !texture_srgb != !sampler_srgb;

        if (srgb_was_toggled)
        {
            if (sampler_srgb)
                texture->flags |= WINED3D_TEXTURE_IS_SRGB;
            else
                texture->flags &= ~WINED3D_TEXTURE_IS_SRGB;
        }
    }

    /* If the texture is marked dirty or the sRGB sampler setting has changed
     * since the last load then reload the volumes. */
    if (texture->texture_rgb.dirty)
    {
        for (i = 0; i < texture->level_count; ++i)
        {
            volume_load(volume_from_resource(texture->sub_resources[i]), i,
                    texture->flags & WINED3D_TEXTURE_IS_SRGB);
        }
    }
    else if (srgb_was_toggled)
    {
        for (i = 0; i < texture->level_count; ++i)
        {
            struct wined3d_volume *volume = volume_from_resource(texture->sub_resources[i]);
            volume_add_dirty_box(volume, NULL);
            volume_load(volume, i, texture->flags & WINED3D_TEXTURE_IS_SRGB);
        }
    }
    else
    {
        TRACE("Texture %p not dirty, nothing to do.\n", texture);
    }

    if (context)
        context_release(context);

    /* No longer dirty */
    texture->texture_rgb.dirty = FALSE;
}
Exemple #2
0
static ULONG volume_resource_decref(struct wined3d_resource *resource)
{
    struct wined3d_volume *volume = volume_from_resource(resource);
    TRACE("Forwarding to container %p.\n", volume->container);

    return wined3d_texture_decref(volume->container);
}
Exemple #3
0
/* Do not call while under the GL lock. */
static void volumetexture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSRGB srgb)
{
    IWineD3DDeviceImpl *device = texture->resource.device;
    struct wined3d_context *context = NULL;
    BOOL srgb_mode = texture->baseTexture.is_srgb;
    BOOL srgb_was_toggled = FALSE;
    unsigned int i;

    TRACE("texture %p, srgb %#x.\n", texture, srgb);

    if (!device->isInDraw) context = context_acquire(device, NULL);
    else if (texture->baseTexture.bindCount > 0)
    {
        srgb_mode = device->stateBlock->state.sampler_states[texture->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE];
        srgb_was_toggled = texture->baseTexture.is_srgb != srgb_mode;
        texture->baseTexture.is_srgb = srgb_mode;
    }

    /* If the texture is marked dirty or the srgb sampler setting has changed
     * since the last load then reload the volumes. */
    if (texture->baseTexture.texture_rgb.dirty)
    {
        for (i = 0; i < texture->baseTexture.level_count; ++i)
        {
            volume_load(volume_from_resource(texture->baseTexture.sub_resources[i]), i, srgb_mode);
        }
    }
    else if (srgb_was_toggled)
    {
        for (i = 0; i < texture->baseTexture.level_count; ++i)
        {
            IWineD3DVolumeImpl *volume = volume_from_resource(texture->baseTexture.sub_resources[i]);
            volume_add_dirty_box(volume, NULL);
            volume_load(volume, i, srgb_mode);
        }
    }
    else
    {
        TRACE("Texture %p not dirty, nothing to do.\n", texture);
    }

    if (context) context_release(context);

    /* No longer dirty */
    texture->baseTexture.texture_rgb.dirty = FALSE;
}
Exemple #4
0
static void texture3d_sub_resource_cleanup(struct wined3d_resource *sub_resource)
{
    struct wined3d_volume *volume = volume_from_resource(sub_resource);

    /* Cleanup the container. */
    volume_set_container(volume, NULL);
    wined3d_volume_decref(volume);
}
Exemple #5
0
static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyRegion(IWineD3DBaseTexture *iface,
        UINT layer, const WINED3DBOX *dirty_region)
{
    IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
    struct wined3d_resource *sub_resource;

    TRACE("iface %p, layer %u, dirty_region %p.\n", iface, layer, dirty_region);

    if (!(sub_resource = basetexture_get_sub_resource(texture, layer * texture->baseTexture.level_count)))
    {
        WARN("Failed to get sub-resource.\n");
        return WINED3DERR_INVALIDCALL;
    }

    basetexture_set_dirty(texture, TRUE);
    volume_add_dirty_box(volume_from_resource(sub_resource), dirty_region);

    return WINED3D_OK;
}
Exemple #6
0
static void volumetexture_cleanup(IWineD3DBaseTextureImpl *This)
{
    unsigned int i;

    TRACE("(%p) : Cleaning up.\n", This);

    for (i = 0; i < This->baseTexture.level_count; ++i)
    {
        struct wined3d_resource *sub_resource = This->baseTexture.sub_resources[i];

        if (sub_resource)
        {
            IWineD3DVolumeImpl *volume = volume_from_resource(sub_resource);

            /* Cleanup the container. */
            volume_set_container(volume, NULL);
            IWineD3DVolume_Release((IWineD3DVolume *)volume);
        }
    }
    basetexture_cleanup((IWineD3DBaseTextureImpl *)This);
}
Exemple #7
0
static void volume_unload(struct wined3d_resource *resource)
{
    struct wined3d_volume *volume = volume_from_resource(resource);
    struct wined3d_device *device = volume->resource.device;
    struct wined3d_context *context;

    if (volume->resource.pool == WINED3D_POOL_DEFAULT)
        ERR("Unloading DEFAULT pool volume.\n");

    TRACE("texture %p.\n", resource);

    if (volume_prepare_system_memory(volume))
    {
        context = context_acquire(device, NULL);
        wined3d_volume_load_location(volume, context, WINED3D_LOCATION_SYSMEM);
        context_release(context);
        wined3d_volume_invalidate_location(volume, ~WINED3D_LOCATION_SYSMEM);
    }
    else
    {
        ERR("Out of memory when unloading volume %p.\n", volume);
        wined3d_volume_validate_location(volume, WINED3D_LOCATION_DISCARDED);
        wined3d_volume_invalidate_location(volume, ~WINED3D_LOCATION_DISCARDED);
    }

    if (volume->pbo)
    {
        /* Should not happen because only dynamic default pool volumes
         * have a buffer, and those are not evicted by device_evit_managed_resources
         * and must be freed before a non-ex device reset. */
        ERR("Unloading a volume with a buffer\n");
        wined3d_volume_free_pbo(volume);
    }

    /* The texture name is managed by the container. */
    volume->flags &= ~(WINED3D_VFLAG_ALLOCATED | WINED3D_VFLAG_SRGB_ALLOCATED
            | WINED3D_VFLAG_CLIENT_STORAGE);

    resource_unload(resource);
}
Exemple #8
0
static void wined3d_resource_sync(struct wined3d_resource *resource)
{
    struct wined3d_resource *real_res = resource;
    struct wined3d_surface *surface;
    struct wined3d_volume *volume;

    switch (resource->type)
    {
        case WINED3D_RTYPE_SURFACE:
            surface = surface_from_resource(resource);
            if (surface->container)
                real_res = &surface->container->resource;
            break;

        case WINED3D_RTYPE_VOLUME:
            volume = volume_from_resource(resource);
            real_res = &volume->container->resource;
            break;

        default:
            break;
    }
    wined3d_resource_wait_fence(real_res);
}
Exemple #9
0
struct wined3d_volume * CDECL wined3d_volume_from_resource(struct wined3d_resource *resource)
{
    return volume_from_resource(resource);
}
Exemple #10
0
static void texture3d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource,
        const struct wined3d_box *dirty_region)
{
    volume_add_dirty_box(volume_from_resource(sub_resource), dirty_region);
}
Exemple #11
0
static ULONG volume_resource_decref(struct wined3d_resource *resource)
{
    return wined3d_volume_decref(volume_from_resource(resource));
}
Exemple #12
0
static void texture3d_sub_resource_cleanup(struct wined3d_resource *sub_resource)
{
    struct wined3d_volume *volume = volume_from_resource(sub_resource);

    wined3d_volume_destroy(volume);
}
Exemple #13
0
static void texture3d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource,
        const struct wined3d_box *dirty_region)
{
    wined3d_texture_set_dirty(volume_from_resource(sub_resource)->container);
}
Exemple #14
0
static void texture3d_sub_resource_load(struct wined3d_resource *sub_resource,
        struct wined3d_context *context, BOOL srgb)
{
    wined3d_volume_load(volume_from_resource(sub_resource), context, srgb);
}