コード例 #1
0
ファイル: view.c プロジェクト: vindo-app/wine
static void wined3d_shader_resource_view_create_texture_view(struct wined3d_shader_resource_view *view,
        const struct wined3d_shader_resource_view_desc *desc, struct wined3d_texture *texture,
        const struct wined3d_format *view_format)
{
    const struct wined3d_gl_info *gl_info;
    struct wined3d_context *context;
    struct gl_texture *gl_texture;

    context = context_acquire(texture->resource.device, NULL);
    gl_info = context->gl_info;

    if (!gl_info->supported[ARB_TEXTURE_VIEW])
    {
        context_release(context);
        FIXME("OpenGL implementation does not support texture views.\n");
        return;
    }

    wined3d_texture_prepare_texture(texture, context, FALSE);
    gl_texture = wined3d_texture_get_gl_texture(texture, FALSE);

    gl_info->gl_ops.gl.p_glGenTextures(1, &view->object);
    GL_EXTCALL(glTextureView(view->object, view->target, gl_texture->name, view_format->glInternal,
            desc->u.texture.level_idx, desc->u.texture.level_count,
            desc->u.texture.layer_idx, desc->u.texture.layer_count));
    checkGLcall("Create texture view");

    context_release(context);
}
コード例 #2
0
ファイル: resource.c プロジェクト: zalcyon/wine
void *wined3d_resource_map_internal(struct wined3d_resource *resource, DWORD flags)
{
    struct wined3d_device *device = resource->device;
    struct wined3d_context *context = NULL;
    void *mem;

    if (device->d3d_initialized)
        context = context_acquire(device, NULL);

    if (!wined3d_resource_prepare_map_memory(resource, context))
    {
        WARN("Out of memory.\n");
        context_release(context);
        return NULL;
    }

    if (flags & WINED3D_MAP_DISCARD)
    {
        switch (resource->map_binding)
        {
            case WINED3D_LOCATION_BUFFER:
                resource->map_buffer = wined3d_device_get_bo(device, resource->size,
                        GL_STREAM_DRAW_ARB, GL_PIXEL_UNPACK_BUFFER_ARB, context);
                break;

            case WINED3D_LOCATION_SYSMEM:
                wined3d_resource_allocate_sysmem(resource);
                break;

            default:
                if (resource->access_fence)
                    ERR("Location %s does not support DISCARD maps.\n",
                            wined3d_debug_location(resource->map_binding));
                if (resource->pool != WINED3D_POOL_DEFAULT)
                    FIXME("Discard used on %s pool resource.\n", debug_d3dpool(resource->pool));
        }
        wined3d_resource_validate_location(resource, resource->map_binding);
    }
    else
    {
        wined3d_resource_load_location(resource, context, resource->map_binding);
    }

    mem = wined3d_resource_get_map_ptr(resource, context, flags);

    if (context)
        context_release(context);

    return mem;
}
コード例 #3
0
ファイル: swapchain.c プロジェクト: mgriepentrog/wine
/* Do not call while under the GL lock. */
static struct wined3d_context *swapchain_create_context(struct wined3d_swapchain *swapchain)
{
    struct wined3d_context **newArray;
    struct wined3d_context *ctx;

    TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId());

    if (!(ctx = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format)))
    {
        ERR("Failed to create a new context for the swapchain\n");
        return NULL;
    }
    context_release(ctx);

    newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * (swapchain->num_contexts + 1));
    if(!newArray) {
        ERR("Out of memory when trying to allocate a new context array\n");
        context_destroy(swapchain->device, ctx);
        return NULL;
    }
    memcpy(newArray, swapchain->context, sizeof(*newArray) * swapchain->num_contexts);
    HeapFree(GetProcessHeap(), 0, swapchain->context);
    newArray[swapchain->num_contexts] = ctx;
    swapchain->context = newArray;
    swapchain->num_contexts++;

    TRACE("Returning context %p\n", ctx);
    return ctx;
}
コード例 #4
0
ファイル: view.c プロジェクト: andrei1489/wine
ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view)
{
    ULONG refcount = InterlockedDecrement(&view->refcount);

    TRACE("%p decreasing refcount to %u.\n", view, refcount);

    if (!refcount)
    {
        if (view->object)
        {
            const struct wined3d_gl_info *gl_info;
            struct wined3d_context *context;

            context = context_acquire(view->resource->device, NULL);
            gl_info = context->gl_info;
            gl_info->gl_ops.gl.p_glDeleteTextures(1, &view->object);
            checkGLcall("glDeleteTextures");
            context_release(context);
        }
        /* Call wined3d_object_destroyed() before releasing the resource,
         * since releasing the resource may end up destroying the parent. */
        view->parent_ops->wined3d_object_destroyed(view->parent);
        wined3d_resource_decref(view->resource);
        HeapFree(GetProcessHeap(), 0, view);
    }

    return refcount;
}
コード例 #5
0
ファイル: volume.c プロジェクト: Kelimion/wine
HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume)
{
    TRACE("volume %p.\n", volume);

    if (!(volume->flags & WINED3D_VFLAG_LOCKED))
    {
        WARN("Trying to unlock unlocked volume %p.\n", volume);
        return WINED3DERR_INVALIDCALL;
    }

    if (volume->flags & WINED3D_VFLAG_PBO)
    {
        struct wined3d_device *device = volume->resource.device;
        struct wined3d_context *context = context_acquire(device, NULL);
        const struct wined3d_gl_info *gl_info = context->gl_info;

        GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, volume->pbo));
        GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB));
        GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
        checkGLcall("Unmap PBO");

        context_release(context);
    }

    volume->flags &= ~WINED3D_VFLAG_LOCKED;

    return WINED3D_OK;
}
コード例 #6
0
ファイル: volume.c プロジェクト: karolherbst/wine
HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume)
{
    TRACE("volume %p.\n", volume);

    if (!volume->resource.map_count)
    {
        WARN("Trying to unlock an unlocked volume %p.\n", volume);
        return WINED3DERR_INVALIDCALL;
    }

    if (volume->resource.map_binding == WINED3D_LOCATION_BUFFER)
    {
        struct wined3d_device *device = volume->resource.device;
        struct wined3d_context *context = context_acquire(device, NULL);
        const struct wined3d_gl_info *gl_info = context->gl_info;

        GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, volume->pbo));
        GL_EXTCALL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));
        GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
        checkGLcall("Unmap PBO");

        context_release(context);
    }

    volume->resource.map_count--;

    return WINED3D_OK;
}
コード例 #7
0
struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *iface)
{
    IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *) iface;
#ifndef VBOX_WITH_WDDM
    struct wined3d_context **newArray;
#endif
    struct wined3d_context *ctx;

    TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());

    if (!(ctx = context_create(This, (IWineD3DSurfaceImpl *)This->frontBuffer, This->ds_format)))
    {
        ERR("Failed to create a new context for the swapchain\n");
        return NULL;
    }
    context_release(ctx);
#ifdef VBOX_WITH_WDDM
    /* no need to do anything since context gets added to the device context list within the context_create call */
#else
    newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * (This->num_contexts + 1));
    if(!newArray) {
        ERR("Out of memory when trying to allocate a new context array\n");
        context_destroy(This->device, ctx);
        return NULL;
    }
    memcpy(newArray, This->context, sizeof(*newArray) * This->num_contexts);
    HeapFree(GetProcessHeap(), 0, This->context);
    newArray[This->num_contexts] = ctx;
    This->context = newArray;
    This->num_contexts++;
#endif
    TRACE("Returning context %p\n", ctx);
    return ctx;
}
コード例 #8
0
ファイル: SCDOpen.c プロジェクト: 010001111/darling
static void
pushDisconnect(SCDynamicStoreRef store)
{
	void					*context_info;
	void					(*context_release)(const void *);
	SCDynamicStoreDisconnectCallBack	disconnectFunction;
	SCDynamicStorePrivateRef		storePrivate	= (SCDynamicStorePrivateRef)store;

	disconnectFunction = storePrivate->disconnectFunction;
	if (disconnectFunction == NULL) {
		// if no reconnect callout, push empty notification
		storePrivate->disconnectForceCallBack = TRUE;
		return;
	}

	if (storePrivate->rlsContext.retain != NULL) {
		context_info	= (void *)storePrivate->rlsContext.retain(storePrivate->rlsContext.info);
		context_release	= storePrivate->rlsContext.release;
	} else {
		context_info	= storePrivate->rlsContext.info;
		context_release	= NULL;
	}
	(*disconnectFunction)(store, context_info);
	if (context_release) {
		context_release(context_info);
	}

	return;
}
コード例 #9
0
ファイル: texture.c プロジェクト: alexwgo/wine
void CDECL wined3d_texture_preload(struct wined3d_texture *texture)
{
    struct wined3d_context *context;
    context = context_acquire(texture->resource.device, NULL);
    wined3d_texture_load(texture, context, texture->flags & WINED3D_TEXTURE_IS_SRGB);
    context_release(context);
}
コード例 #10
0
ファイル: basetexture.c プロジェクト: LastRitter/vbox-haiku
void basetexture_unload(IWineD3DBaseTexture *iface)
{
    IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
    IWineD3DDeviceImpl *device = This->resource.device;

#ifdef VBOX_WITH_WDDM
    if (VBOXSHRC_IS_SHARED_OPENED(This))
    {
        This->baseTexture.texture_rgb.name = 0;
        This->baseTexture.texture_srgb.name = 0;
    }
    else
#endif
    {
        struct wined3d_context *context = NULL;
        if (This->baseTexture.texture_rgb.name || This->baseTexture.texture_srgb.name)
        {
            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
        }

        if(This->baseTexture.texture_rgb.name) {
            gltexture_delete(&This->baseTexture.texture_rgb);
        }
        if(This->baseTexture.texture_srgb.name) {
            gltexture_delete(&This->baseTexture.texture_srgb);
        }

        if (context) context_release(context);
    }

    This->baseTexture.texture_rgb.dirty = TRUE;
    This->baseTexture.texture_srgb.dirty = TRUE;
}
コード例 #11
0
ファイル: basetexture.c プロジェクト: r6144/wine
void basetexture_unload(IWineD3DBaseTexture *iface)
{
    IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
    IWineD3DDeviceImpl *device = This->resource.device;
    struct wined3d_context *context = NULL;

    if (This->baseTexture.texture_rgb.name || This->baseTexture.texture_srgb.name)
    {
        context = context_acquire(device, NULL);
    }

    if(This->baseTexture.texture_rgb.name) {
        gltexture_delete(&This->baseTexture.texture_rgb);
    }
    if(This->baseTexture.texture_srgb.name) {
        gltexture_delete(&This->baseTexture.texture_srgb);
    }

    if (context) context_release(context);

    This->baseTexture.texture_rgb.dirty = TRUE;
    This->baseTexture.texture_srgb.dirty = TRUE;

    resource_unload((IWineD3DResourceImpl *)This);
}
コード例 #12
0
ファイル: texture.c プロジェクト: carlosbislip/wine
/* Do not call while under the GL lock. */
static void texture2d_preload(struct wined3d_texture *texture, enum WINED3DSRGB srgb)
{
    UINT sub_count = texture->level_count * texture->layer_count;
    struct wined3d_device *device = texture->resource.device;
    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    struct wined3d_context *context = NULL;
    struct gl_texture *gl_tex;
    BOOL srgb_mode;
    UINT i;

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

    srgb_mode = texture_srgb_mode(texture, srgb);
    gl_tex = wined3d_texture_get_gl_texture(texture, gl_info, srgb_mode);

    if (!device->isInDraw)
    {
        /* No danger of recursive calls, context_acquire() sets isInDraw to TRUE
         * when loading offscreen render targets into the texture. */
        context = context_acquire(device, NULL);
    }

    if (texture->resource.format->id == WINED3DFMT_P8_UINT
            || texture->resource.format->id == WINED3DFMT_P8_UINT_A8_UNORM)
    {
        for (i = 0; i < sub_count; ++i)
        {
            struct wined3d_surface *surface = surface_from_resource(texture->sub_resources[i]);

            if (palette9_changed(surface))
            {
                TRACE("Reloading surface %p because the d3d8/9 palette was changed.\n", surface);
                /* TODO: This is not necessarily needed with hw palettized texture support. */
                surface_load_location(surface, SFLAG_INSYSMEM, NULL);
                /* Make sure the texture is reloaded because of the palette
                 * change, this kills performance though :( */
                surface_modify_location(surface, SFLAG_INTEXTURE, FALSE);
            }
        }
    }

    if (gl_tex->dirty)
    {
        /* Reload the surfaces if the texture is marked dirty. */
        for (i = 0; i < sub_count; ++i)
        {
            surface_load(surface_from_resource(texture->sub_resources[i]), srgb_mode);
        }
    }
    else
    {
        TRACE("Texture %p not dirty, nothing to do.\n", texture);
    }

    /* No longer dirty. */
    gl_tex->dirty = FALSE;

    if (context) context_release(context);
}
コード例 #13
0
ファイル: query.c プロジェクト: kernelOfTruth/wine
static HRESULT wined3d_timestamp_query_ops_get_data(struct wined3d_query *query,
        void *data, DWORD size, DWORD flags)
{
    struct wined3d_timestamp_query *tq = query->extendedData;
    struct wined3d_device *device = query->device;
    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    struct wined3d_context *context;
    GLuint available;
    GLuint64 timestamp;
    HRESULT res;

    TRACE("query %p, data %p, size %#x, flags %#x.\n", query, data, size, flags);

    if (!tq->context)
        query->state = QUERY_CREATED;

    if (query->state == QUERY_CREATED)
    {
        /* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves. */
        TRACE("Query wasn't yet started, returning S_OK.\n");
        timestamp = 0;
        fill_query_data(data, size, &timestamp, sizeof(timestamp));
        return S_OK;
    }

    if (tq->context->tid != GetCurrentThreadId())
    {
        FIXME("%p Wrong thread, returning 1.\n", query);
        timestamp = 1;
        fill_query_data(data, size, &timestamp, sizeof(timestamp));
        return S_OK;
    }

    context = context_acquire(query->device, tq->context->current_rt);

    GL_EXTCALL(glGetQueryObjectuiv(tq->id, GL_QUERY_RESULT_AVAILABLE, &available));
    checkGLcall("glGetQueryObjectuiv(GL_QUERY_RESULT_AVAILABLE)");
    TRACE("available %#x.\n", available);

    if (available)
    {
        if (size)
        {
            GL_EXTCALL(glGetQueryObjectui64v(tq->id, GL_QUERY_RESULT, &timestamp));
            checkGLcall("glGetQueryObjectui64v(GL_QUERY_RESULT)");
            TRACE("Returning timestamp %s.\n", wine_dbgstr_longlong(timestamp));
            fill_query_data(data, size, &timestamp, sizeof(timestamp));
        }
        res = S_OK;
    }
    else
    {
        res = S_FALSE;
    }

    context_release(context);

    return res;
}
コード例 #14
0
static HRESULT WINAPI IWineD3DTextureImpl_SetShRcState(IWineD3DTexture *iface, VBOXWINEEX_SHRC_STATE enmState) {
    IWineD3DTextureImpl *This = (IWineD3DTextureImpl*)iface;
    struct wined3d_context *context = NULL;
    HRESULT hr = IWineD3DResourceImpl_SetShRcState((IWineD3DResource*)iface, enmState);
    unsigned int i;

    if (FAILED(hr))
    {
        ERR("IWineD3DResource_SetShRcState failed");
        return hr;
    }

    for (i = 0; i < This->baseTexture.levels; ++i)
    {
        if (This->surfaces[i])
        {
            HRESULT tmpHr = IWineD3DResource_SetShRcState((IWineD3DResource*)This->surfaces[i], enmState);
            Assert(tmpHr == S_OK);
        }
    }

    if (!This->resource.device->isInDraw)
    {
        context = context_acquire(This->resource.device, NULL, CTXUSAGE_RESOURCELOAD);
        if (!context)
        {
            ERR("zero context!");
            return E_FAIL;
        }

        if (!context->valid)
        {
            ERR("context invalid!");
            context_release(context);
            return E_FAIL;
        }
    }

    device_cleanup_durtify_texture_target(This->resource.device, This->target);

    if (context)
        context_release(context);

    return WINED3D_OK;
}
コード例 #15
0
ファイル: view.c プロジェクト: Moteesh/reactos
static void wined3d_shader_resource_view_cs_init(void *object)
{
    struct wined3d_shader_resource_view *view = object;
    struct wined3d_resource *resource = view->resource;
    const struct wined3d_format *view_format;
    const struct wined3d_gl_info *gl_info;
    const struct wined3d_view_desc *desc;
    GLenum view_target;

    view_format = view->format;
    gl_info = &resource->device->adapter->gl_info;
    desc = &view->desc;

    if (resource->type == WINED3D_RTYPE_BUFFER)
    {
        struct wined3d_buffer *buffer = buffer_from_resource(resource);
        struct wined3d_context *context;

        context = context_acquire(resource->device, NULL, 0);
        create_buffer_view(&view->gl_view, context, desc, buffer, view_format);
        context_release(context);
    }
    else
    {
        struct wined3d_texture *texture = texture_from_resource(resource);

        view_target = get_texture_view_target(gl_info, desc, texture);

        if (resource->format->id == view_format->id && texture->target == view_target
                && !desc->u.texture.level_idx && desc->u.texture.level_count == texture->level_count
                && !desc->u.texture.layer_idx && desc->u.texture.layer_count == texture->layer_count
                && !is_stencil_view_format(view_format))
        {
            TRACE("Creating identity shader resource view.\n");
        }
        else if (texture->swapchain && texture->swapchain->desc.backbuffer_count > 1)
        {
            FIXME("Swapchain shader resource views not supported.\n");
        }
        else if (resource->format->typeless_id == view_format->typeless_id
                && resource->format->gl_view_class == view_format->gl_view_class)
        {
            create_texture_view(&view->gl_view, view_target, desc, texture, view_format);
        }
        else if (wined3d_format_is_depth_view(resource->format->id, view_format->id))
        {
            create_texture_view(&view->gl_view, view_target, desc, texture, resource->format);
        }
        else
        {
            FIXME("Shader resource view not supported, resource format %s, view format %s.\n",
                    debug_d3dformat(resource->format->id), debug_d3dformat(view_format->id));
        }
    }

    wined3d_resource_release(resource);
}
コード例 #16
0
ファイル: texture.c プロジェクト: carlosbislip/wine
/* 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;
}
コード例 #17
0
ファイル: sampler.c プロジェクト: grandhuit/wine-patched
void wined3d_sampler_destroy(struct wined3d_sampler *sampler)
{
    struct wined3d_context *context = context_acquire(sampler->device, NULL);
    const struct wined3d_gl_info *gl_info = context->gl_info;

    GL_EXTCALL(glDeleteSamplers(1, &sampler->name));
    context_release(context);

    HeapFree(GetProcessHeap(), 0, sampler);
}
コード例 #18
0
ファイル: api.c プロジェクト: Esquim/Various-Work
void		*ft_calloc(size_t n, size_t size)
{
	void		*p;

	context_acquire();
	if (g_ctx.cfg.print_allocated)
		ft_mlog(&g_ctx, INFO, "calloc(%zd, %zd)", n, size);
	context_release();
	p = ft_malloc(n * size);
	context_acquire();
	if (p)
		memset(p, 0, n * size);
	else
		ft_mlog(&g_ctx, ERROR, "null pointer exception!");
	if (g_ctx.cfg.print_nb_blocks)
		ft_mlog(&g_ctx, INFO, "Blocks: %zd", g_ctx.stat.nb_blocks);
	context_release();
	return (p);
}
コード例 #19
0
ファイル: volume.c プロジェクト: Kelimion/wine
static void wined3d_volume_free_pbo(struct wined3d_volume *volume)
{
    struct wined3d_context *context = context_acquire(volume->resource.device, NULL);
    const struct wined3d_gl_info *gl_info = context->gl_info;

    TRACE("Deleting PBO %u belonging to volume %p.\n", volume->pbo, volume);
    GL_EXTCALL(glDeleteBuffersARB(1, &volume->pbo));
    checkGLcall("glDeleteBuffersARB");
    volume->pbo = 0;
    context_release(context);
}
コード例 #20
0
ファイル: resource.c プロジェクト: zalcyon/wine
void wined3d_resource_unmap_internal(struct wined3d_resource *resource)
{
    struct wined3d_device *device = resource->device;
    struct wined3d_context *context = NULL;

    if (device->d3d_initialized)
        context = context_acquire(device, NULL);
    wined3d_resource_release_map_ptr(resource, context);
    if (context)
        context_release(context);
}
コード例 #21
0
ファイル: api.c プロジェクト: Esquim/Various-Work
void		ft_free(void *p)
{
	context_acquire();
	if (!p)
		ft_mlog(&g_ctx, WARNING, "freeing null pointer.");
	if (g_ctx.cfg.print_unallocated)
		ft_mlog(&g_ctx, INFO, "free(%p)", p);
	g_ctx.fn.free(&g_ctx, p);
	if (g_ctx.cfg.print_nb_blocks)
		ft_mlog(&g_ctx, INFO, "Blocks: %zd", g_ctx.stat.nb_blocks);
	context_release();
}
コード例 #22
0
ファイル: texture.c プロジェクト: Dimillian/wine
static void texture2d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource,
        const struct wined3d_box *dirty_region)
{
    struct wined3d_surface *surface = surface_from_resource(sub_resource);
    struct wined3d_context *context;

    context = context_acquire(surface->resource.device, NULL);
    wined3d_resource_prepare_map_memory(&surface->resource, context);
    wined3d_resource_load_location(&surface->resource, context, surface->resource.map_binding);
    context_release(context);
    wined3d_resource_invalidate_location(&surface->resource, ~surface->resource.map_binding);
}
コード例 #23
0
ファイル: query.c プロジェクト: LastRitter/vbox-haiku
void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
{
    const struct wined3d_gl_info *gl_info;
    struct wined3d_context *context;

    if (query->context)
    {
        if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId())
        {
#ifdef VBOX_WINE_WITH_SINGLE_CONTEXT
            ERR("unexpected\n");
#endif
            context_free_event_query(query);
            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
            context_alloc_event_query(context, query);
        }
        else
        {
            context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
        }
    }
    else
    {
        context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
        context_alloc_event_query(context, query);
    }

    gl_info = context->gl_info;

    ENTER_GL();

    if (gl_info->supported[ARB_SYNC])
    {
        if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync));
        checkGLcall("glDeleteSync");
        query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
        checkGLcall("glFenceSync");
    }
    else if (gl_info->supported[APPLE_FENCE])
    {
        GL_EXTCALL(glSetFenceAPPLE(query->object.id));
        checkGLcall("glSetFenceAPPLE");
    }
    else if (gl_info->supported[NV_FENCE])
    {
        GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV));
        checkGLcall("glSetFenceNV");
    }

    LEAVE_GL();

    context_release(context);
}
コード例 #24
0
ファイル: resource.c プロジェクト: zalcyon/wine
void wined3d_resource_free_bo(struct wined3d_resource *resource)
{
    struct wined3d_context *context = context_acquire(resource->device, NULL);

    if (resource->buffer != resource->map_buffer)
        ERR("Releasing resource buffer with buffer != map_buffer.\n");

    wined3d_device_release_bo(resource->device, resource->buffer, context);
    resource->buffer = NULL;
    resource->map_buffer = NULL;

    context_release(context);
}
コード例 #25
0
static void
rlsPerform(void *info)
{
	CFArrayRef			changedKeys;
	void				*context_info;
	void				(*context_release)(const void *);
	SCDynamicStoreCallBack		rlsFunction;
	SCDynamicStoreRef		store		= (SCDynamicStoreRef)info;
	SCDynamicStorePrivateRef	storePrivate	= (SCDynamicStorePrivateRef)store;

#ifdef	DEBUG
	SCLog(_sc_verbose, LOG_DEBUG, CFSTR("  executing notification function"));
#endif	/* DEBUG */

	changedKeys = SCDynamicStoreCopyNotifiedKeys(store);
	if (storePrivate->disconnectForceCallBack) {
		storePrivate->disconnectForceCallBack = FALSE;
		if (changedKeys == NULL) {
			changedKeys = CFArrayCreate(NULL, NULL, 0, &kCFTypeArrayCallBacks);
		}
	} else {
		if (changedKeys == NULL) {
			/* if no changes or something happened to the server */
			return;
		} else if (CFArrayGetCount(changedKeys) == 0) {
			goto done;
		}
	}

	rlsFunction = storePrivate->rlsFunction;

	if (storePrivate->rlsContext.retain != NULL) {
		context_info	= (void *)storePrivate->rlsContext.retain(storePrivate->rlsContext.info);
		context_release	= storePrivate->rlsContext.release;
	} else {
		context_info	= storePrivate->rlsContext.info;
		context_release	= NULL;
	}
	if (rlsFunction != NULL) {
		(*rlsFunction)(store, changedKeys, context_info);
	}
	if (context_release != NULL) {
		context_release(context_info);
	}

    done :

	CFRelease(changedKeys);
	return;
}
コード例 #26
0
ファイル: volumetexture.c プロジェクト: ElvisTulip/vbox
static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
{
    /* Override the IWineD3DResource Preload method. */
    IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
    IWineD3DDeviceImpl *device = This->resource.device;
    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    struct wined3d_context *context = NULL;
    BOOL srgb_mode = This->baseTexture.is_srgb;
    BOOL srgb_was_toggled = FALSE;
    unsigned int i;

    TRACE("(%p) : About to load texture.\n", This);

    if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
    else if (gl_info->supported[EXT_TEXTURE_SRGB] && This->baseTexture.bindCount > 0)
    {
        srgb_mode = device->stateBlock->samplerState[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE];
        srgb_was_toggled = This->baseTexture.is_srgb != srgb_mode;
        This->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 (This->baseTexture.texture_rgb.dirty)
    {
        for (i = 0; i < This->baseTexture.levels; ++i)
        {
            IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
        }
    }
    else if (srgb_was_toggled)
    {
        for (i = 0; i < This->baseTexture.levels; ++i)
        {
            volume_add_dirty_box(This->volumes[i], NULL);
            IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
        }
    }
    else
    {
        TRACE("(%p) Texture not dirty, nothing to do.\n", iface);
    }

    if (context) context_release(context);

    /* No longer dirty */
    This->baseTexture.texture_rgb.dirty = FALSE;
}
コード例 #27
0
ファイル: view.c プロジェクト: Moteesh/reactos
void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
        unsigned int value)
{
    const struct wined3d_gl_info *gl_info;
    struct wined3d_context *context;

    if (!view->counter_bo)
        return;

    context = context_acquire(view->resource->device, NULL, 0);
    gl_info = context->gl_info;
    GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, view->counter_bo));
    GL_EXTCALL(glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(value), &value));
    checkGLcall("set atomic counter");
    context_release(context);
}
コード例 #28
0
ファイル: sampler.c プロジェクト: Moteesh/reactos
static void wined3d_sampler_destroy_object(void *object)
{
    struct wined3d_sampler *sampler = object;
    const struct wined3d_gl_info *gl_info;
    struct wined3d_context *context;

    if (sampler->name)
    {
        context = context_acquire(sampler->device, NULL, 0);
        gl_info = context->gl_info;
        GL_EXTCALL(glDeleteSamplers(1, &sampler->name));
        context_release(context);
    }

    heap_free(sampler);
}
コード例 #29
0
ファイル: view.c プロジェクト: Moteesh/reactos
static void wined3d_unordered_access_view_cs_init(void *object)
{
    struct wined3d_unordered_access_view *view = object;
    struct wined3d_resource *resource = view->resource;
    struct wined3d_view_desc *desc = &view->desc;
    const struct wined3d_gl_info *gl_info;

    gl_info = &resource->device->adapter->gl_info;

    if (resource->type == WINED3D_RTYPE_BUFFER)
    {
        struct wined3d_buffer *buffer = buffer_from_resource(resource);
        struct wined3d_context *context;

        context = context_acquire(resource->device, NULL, 0);
        gl_info = context->gl_info;
        create_buffer_view(&view->gl_view, context, desc, buffer, view->format);
        if (desc->flags & (WINED3D_VIEW_BUFFER_COUNTER | WINED3D_VIEW_BUFFER_APPEND))
        {
            static const GLuint initial_value = 0;
            GL_EXTCALL(glGenBuffers(1, &view->counter_bo));
            GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, view->counter_bo));
            GL_EXTCALL(glBufferData(GL_ATOMIC_COUNTER_BUFFER,
                    sizeof(initial_value), &initial_value, GL_STATIC_DRAW));
            checkGLcall("create atomic counter buffer");
        }
        context_release(context);
    }
    else
    {
        struct wined3d_texture *texture = texture_from_resource(resource);
        unsigned int depth_or_layer_count;

        if (resource->type == WINED3D_RTYPE_TEXTURE_3D)
            depth_or_layer_count = wined3d_texture_get_level_depth(texture, desc->u.texture.level_idx);
        else
            depth_or_layer_count = texture->layer_count;

        if (desc->u.texture.layer_idx || desc->u.texture.layer_count != depth_or_layer_count)
        {
            create_texture_view(&view->gl_view, get_texture_view_target(gl_info, desc, texture),
                    desc, texture, view->format);
        }
    }

    wined3d_resource_release(resource);
}
コード例 #30
0
ファイル: basetexture.c プロジェクト: dvdhoo/wine
HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTextureImpl *texture, WINED3DTEXTUREFILTERTYPE filter_type)
{
    TRACE("texture %p, filter_type %s.\n", texture, debug_d3dtexturefiltertype(filter_type));

    if (!(texture->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP))
    {
        WARN("Texture doesn't have AUTOGENMIPMAP usage.\n");
        return WINED3DERR_INVALIDCALL;
    }

    if (texture->baseTexture.filterType != filter_type)
    {
        GLenum target = texture->baseTexture.target;
        struct wined3d_context *context;

        context = context_acquire(texture->resource.device, NULL);

        ENTER_GL();
        glBindTexture(target, texture->baseTexture.texture_rgb.name);
        checkGLcall("glBindTexture");
        switch (filter_type)
        {
            case WINED3DTEXF_NONE:
            case WINED3DTEXF_POINT:
                glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
                checkGLcall("glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST)");
                break;

            case WINED3DTEXF_LINEAR:
                glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
                checkGLcall("glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
                break;

            default:
                WARN("Unexpected filter type %#x, setting to GL_NICEST.\n", filter_type);
                glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
                checkGLcall("glTexParameteri(target, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
                break;
        }
        LEAVE_GL();

        context_release(context);
    }
    texture->baseTexture.filterType = filter_type;

    return WINED3D_OK;
}