Commit bad48492 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Introduce wined3d_texture_use_pbo().

parent ef816275
...@@ -518,19 +518,6 @@ static void surface_evict_sysmem(struct wined3d_surface *surface) ...@@ -518,19 +518,6 @@ static void surface_evict_sysmem(struct wined3d_surface *surface)
surface_invalidate_location(surface, WINED3D_LOCATION_SYSMEM); surface_invalidate_location(surface, WINED3D_LOCATION_SYSMEM);
} }
static BOOL surface_use_pbo(const struct wined3d_surface *surface)
{
const struct wined3d_gl_info *gl_info = &surface->resource.device->adapter->gl_info;
struct wined3d_texture *texture = surface->container;
return texture->resource.pool == WINED3D_POOL_DEFAULT
&& surface->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU
&& gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
&& !texture->resource.format->convert
&& !(texture->flags & WINED3D_TEXTURE_PIN_SYSMEM)
&& !(texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED);
}
static HRESULT surface_private_setup(struct wined3d_surface *surface) static HRESULT surface_private_setup(struct wined3d_surface *surface)
{ {
/* TODO: Check against the maximum texture sizes supported by the video card. */ /* TODO: Check against the maximum texture sizes supported by the video card. */
...@@ -597,7 +584,7 @@ static HRESULT surface_private_setup(struct wined3d_surface *surface) ...@@ -597,7 +584,7 @@ static HRESULT surface_private_setup(struct wined3d_surface *surface)
if (texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL) if (texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL)
surface->locations = WINED3D_LOCATION_DISCARDED; surface->locations = WINED3D_LOCATION_DISCARDED;
if (surface_use_pbo(surface)) if (wined3d_texture_use_pbo(texture, gl_info))
surface->resource.map_binding = WINED3D_LOCATION_BUFFER; surface->resource.map_binding = WINED3D_LOCATION_BUFFER;
return WINED3D_OK; return WINED3D_OK;
...@@ -1743,7 +1730,8 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struc ...@@ -1743,7 +1730,8 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struc
* If the surface didn't use PBOs previously but could now, don't * If the surface didn't use PBOs previously but could now, don't
* change it - whatever made us not use PBOs might come back, e.g. * change it - whatever made us not use PBOs might come back, e.g.
* color keys. */ * color keys. */
if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER && !surface_use_pbo(surface)) if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER
&& !wined3d_texture_use_pbo(surface->container, gl_info))
surface->resource.map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM; surface->resource.map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM;
if (create_dib) if (create_dib)
......
...@@ -28,6 +28,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture); ...@@ -28,6 +28,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
WINE_DECLARE_DEBUG_CHANNEL(winediag); WINE_DECLARE_DEBUG_CHANNEL(winediag);
BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
{
return texture->resource.pool == WINED3D_POOL_DEFAULT
&& texture->resource.access_flags & WINED3D_RESOURCE_ACCESS_CPU
&& gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
&& !texture->resource.format->convert
&& !(texture->flags & (WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_COND_NP2_EMULATED));
}
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops, static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops,
UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags, UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags,
struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops,
...@@ -61,6 +70,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc ...@@ -61,6 +70,8 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
return hr; return hr;
} }
wined3d_resource_update_draw_binding(&texture->resource); wined3d_resource_update_draw_binding(&texture->resource);
if ((flags & WINED3D_TEXTURE_CREATE_MAPPABLE) || desc->format == WINED3DFMT_D16_LOCKABLE)
texture->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU;
texture->texture_ops = texture_ops; texture->texture_ops = texture_ops;
......
...@@ -489,9 +489,7 @@ HRESULT wined3d_volume_init(struct wined3d_volume *volume, struct wined3d_textur ...@@ -489,9 +489,7 @@ HRESULT wined3d_volume_init(struct wined3d_volume *volume, struct wined3d_textur
volume->texture_level = level; volume->texture_level = level;
volume->locations = WINED3D_LOCATION_DISCARDED; volume->locations = WINED3D_LOCATION_DISCARDED;
if (desc->pool == WINED3D_POOL_DEFAULT && desc->usage & WINED3DUSAGE_DYNAMIC if (wined3d_texture_use_pbo(container, gl_info))
&& gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
&& !format->convert)
{ {
wined3d_resource_free_sysmem(&volume->resource); wined3d_resource_free_sysmem(&volume->resource);
volume->resource.map_binding = WINED3D_LOCATION_BUFFER; volume->resource.map_binding = WINED3D_LOCATION_BUFFER;
......
...@@ -2458,6 +2458,8 @@ void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture, ...@@ -2458,6 +2458,8 @@ void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture,
void wined3d_texture_set_dirty(struct wined3d_texture *texture) DECLSPEC_HIDDEN; void wined3d_texture_set_dirty(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
void wined3d_texture_set_swapchain(struct wined3d_texture *texture, void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
#define WINED3D_LOCATION_DISCARDED 0x00000001 #define WINED3D_LOCATION_DISCARDED 0x00000001
#define WINED3D_LOCATION_SYSMEM 0x00000002 #define WINED3D_LOCATION_SYSMEM 0x00000002
......
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