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

wined3d: Get rid of wined3d_select_blitter().

Instead, chain the blitters themselves. This also fixes the issue that currently only a single blitter can store extra data in the "blit_priv" field of struct wined3d_device. Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 4b8c0d87
......@@ -979,7 +979,7 @@ static void wined3d_device_delete_opengl_contexts_cs(void *object)
}
context = context_acquire(device, NULL, 0);
device->blitter->free_private(device);
device->blitter->ops->blitter_destroy(device->blitter, context);
device->shader_backend->shader_free_private(device);
destroy_dummy_textures(device, context);
destroy_default_samplers(device, context);
......@@ -1014,12 +1014,15 @@ static void wined3d_device_create_primary_opengl_context_cs(void *object)
return;
}
if (FAILED(hr = device->blitter->alloc_private(device)))
if (!(device->blitter = wined3d_cpu_blitter_create()))
{
ERR("Failed to allocate blitter private data, hr %#x.\n", hr);
ERR("Failed to create CPU blitter.\n");
device->shader_backend->shader_free_private(device);
return;
}
wined3d_ffp_blitter_create(&device->blitter, &device->adapter->gl_info);
wined3d_arbfp_blitter_create(&device->blitter, device);
wined3d_fbo_blitter_create(&device->blitter, &device->adapter->gl_info);
swapchain = device->swapchains[0];
target = swapchain->back_buffers ? swapchain->back_buffers[0] : swapchain->front_buffer;
......@@ -4144,9 +4147,7 @@ HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *devi
struct wined3d_rendertarget_view *view, const RECT *rect, DWORD flags,
const struct wined3d_color *color, float depth, DWORD stencil)
{
const struct wined3d_blitter_ops *blitter;
struct wined3d_resource *resource;
enum wined3d_blit_op blit_op;
RECT r;
TRACE("device %p, view %p, rect %s, flags %#x, color %s, depth %.8e, stencil %u.\n",
......@@ -4184,19 +4185,7 @@ HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *devi
return hr;
}
if (flags & WINED3DCLEAR_TARGET)
blit_op = WINED3D_BLIT_OP_COLOR_FILL;
else
blit_op = WINED3D_BLIT_OP_DEPTH_FILL;
if (!(blitter = wined3d_select_blitter(&device->adapter->gl_info, &device->adapter->d3d_info,
blit_op, NULL, 0, 0, NULL, rect, resource->usage, resource->pool, resource->format)))
{
FIXME("No blitter is capable of performing the requested fill operation.\n");
return WINED3DERR_INVALIDCALL;
}
blitter->blitter_clear(device, view, rect, flags, color, depth, stencil);
device->blitter->ops->blitter_clear(device->blitter, device, view, rect, flags, color, depth, stencil);
return WINED3D_OK;
}
......@@ -4981,8 +4970,6 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
return hr;
}
device->blitter = adapter->blitter;
state_init(&device->state, &device->fb, &adapter->gl_info,
&adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device->update_state = &device->state;
......
......@@ -2599,16 +2599,6 @@ static const struct wined3d_shader_backend_ops *select_shader_backend(const stru
return &none_shader_backend;
}
static const struct wined3d_blitter_ops *select_blit_implementation(const struct wined3d_gl_info *gl_info,
const struct wined3d_shader_backend_ops *shader_backend_ops)
{
if ((shader_backend_ops == &glsl_shader_backend
|| shader_backend_ops == &arb_program_shader_backend)
&& gl_info->supported[ARB_FRAGMENT_PROGRAM])
return &arbfp_blit;
return &ffp_blit;
}
static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
const struct wined3d_extension_map *map, UINT entry_count)
{
......@@ -4169,7 +4159,6 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
adapter->shader_backend = select_shader_backend(gl_info);
adapter->vertex_pipe = select_vertex_implementation(gl_info, adapter->shader_backend);
adapter->fragment_pipe = select_fragment_implementation(gl_info, adapter->shader_backend);
adapter->blitter = select_blit_implementation(gl_info, adapter->shader_backend);
adapter->shader_backend->shader_get_caps(gl_info, &shader_caps);
adapter->d3d_info.vs_clipping = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_VS_CLIPPING;
......@@ -6567,7 +6556,6 @@ static BOOL wined3d_adapter_init_nogl(struct wined3d_adapter *adapter, UINT ordi
adapter->vertex_pipe = &none_vertex_pipe;
adapter->fragment_pipe = &none_fragment_pipe;
adapter->shader_backend = &none_shader_backend;
adapter->blitter = &cpu_blit;
display_device.cb = sizeof(display_device);
EnumDisplayDevicesW(NULL, ordinal, &display_device, 0);
......
......@@ -306,22 +306,12 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
struct wined3d_texture *texture = swapchain->back_buffers[0];
struct wined3d_surface *back_buffer = texture->sub_resources[0].u.surface;
struct wined3d_device *device = swapchain->device;
const struct wined3d_blitter_ops *blitter;
enum wined3d_texture_filter_type filter;
DWORD location;
TRACE("swapchain %p, context %p, src_rect %s, dst_rect %s.\n",
swapchain, context, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect));
if (!(blitter = wined3d_select_blitter(&device->adapter->gl_info,
&device->adapter->d3d_info, WINED3D_BLIT_OP_COLOR_BLIT,
src_rect, texture->resource.usage, texture->resource.pool, texture->resource.format,
dst_rect, texture->resource.usage, texture->resource.pool, texture->resource.format)))
{
FIXME("No blitter supports the requested blit.\n");
return;
}
if ((src_rect->right - src_rect->left == dst_rect->right - dst_rect->left
&& src_rect->bottom - src_rect->top == dst_rect->bottom - dst_rect->top)
|| is_complex_fixup(texture->resource.format->color_fixup))
......@@ -334,8 +324,8 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
location = WINED3D_LOCATION_RB_RESOLVED;
wined3d_texture_validate_location(texture, 0, WINED3D_LOCATION_DRAWABLE);
blitter->blit_surface(device, WINED3D_BLIT_OP_COLOR_BLIT, context, back_buffer, location,
src_rect, back_buffer, WINED3D_LOCATION_DRAWABLE, dst_rect, NULL, filter);
device->blitter->ops->blitter_blit(device->blitter, WINED3D_BLIT_OP_COLOR_BLIT, context, back_buffer,
location, src_rect, back_buffer, WINED3D_LOCATION_DRAWABLE, dst_rect, NULL, filter);
wined3d_texture_invalidate_location(texture, 0, WINED3D_LOCATION_DRAWABLE);
}
......
......@@ -5794,37 +5794,6 @@ int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb
return memcmp(ka, kb, sizeof(*ka));
}
const struct wined3d_blitter_ops *wined3d_select_blitter(const struct wined3d_gl_info *gl_info,
const struct wined3d_d3d_info *d3d_info, enum wined3d_blit_op blit_op,
const RECT *src_rect, DWORD src_usage, enum wined3d_pool src_pool, const struct wined3d_format *src_format,
const RECT *dst_rect, DWORD dst_usage, enum wined3d_pool dst_pool, const struct wined3d_format *dst_format)
{
static const struct wined3d_blitter_ops * const blitters[] =
{
&fbo_blitter_ops,
&arbfp_blit,
&ffp_blit,
&cpu_blit,
};
unsigned int i;
TRACE("gl_info %p, d3d_info %p, blit_op %#x, src_rect %s, src_usage %s, src_pool %s, src_format %s, "
"dst_rect %s, dst_usage %s, dst_pool %s, dst_format %s.\n", gl_info, d3d_info, blit_op,
wine_dbgstr_rect(src_rect), debug_d3dusage(src_usage), debug_d3dpool(src_pool),
src_format ? debug_d3dformat(src_format->id) : "(null)", wine_dbgstr_rect(dst_rect),
debug_d3dusage(dst_usage), debug_d3dpool(dst_pool), debug_d3dformat(dst_format->id));
for (i = 0; i < sizeof(blitters) / sizeof(*blitters); ++i)
{
if (blitters[i]->blit_supported(gl_info, d3d_info, blit_op,
src_rect, src_usage, src_pool, src_format,
dst_rect, dst_usage, dst_pool, dst_format))
return blitters[i];
}
return NULL;
}
void wined3d_get_draw_rect(const struct wined3d_state *state, RECT *rect)
{
const struct wined3d_viewport *vp = &state->viewport;
......
......@@ -1867,33 +1867,33 @@ enum wined3d_blit_op
WINED3D_BLIT_OP_DEPTH_BLIT,
};
struct wined3d_blitter
{
const struct wined3d_blitter_ops *ops;
struct wined3d_blitter *next;
};
struct wined3d_blitter_ops
{
HRESULT (*alloc_private)(struct wined3d_device *device);
void (*free_private)(struct wined3d_device *device);
BOOL (*blit_supported)(const struct wined3d_gl_info *gl_info,
const struct wined3d_d3d_info *d3d_info, enum wined3d_blit_op blit_op,
const RECT *src_rect, DWORD src_usage, enum wined3d_pool src_pool, const struct wined3d_format *src_format,
const RECT *dst_rect, DWORD dst_usage, enum wined3d_pool dst_pool, const struct wined3d_format *dst_format);
void (*blitter_clear)(struct wined3d_device *device, struct wined3d_rendertarget_view *view,
const RECT *rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
void (*blit_surface)(struct wined3d_device *device, enum wined3d_blit_op op, struct wined3d_context *context,
void (*blitter_destroy)(struct wined3d_blitter *blitter, struct wined3d_context *context);
void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device,
struct wined3d_rendertarget_view *view, const RECT *rect, DWORD flags,
const struct wined3d_color *colour, float depth, DWORD stencil);
void (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect,
struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter);
};
extern const struct wined3d_blitter_ops fbo_blitter_ops DECLSPEC_HIDDEN;
extern const struct wined3d_blitter_ops arbfp_blit DECLSPEC_HIDDEN;
extern const struct wined3d_blitter_ops ffp_blit DECLSPEC_HIDDEN;
extern const struct wined3d_blitter_ops cpu_blit DECLSPEC_HIDDEN;
void wined3d_arbfp_blitter_create(struct wined3d_blitter **next,
const struct wined3d_device *device) DECLSPEC_HIDDEN;
struct wined3d_blitter *wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN;
void wined3d_fbo_blitter_create(struct wined3d_blitter **next,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
void wined3d_ffp_blitter_create(struct wined3d_blitter **next,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN;
const struct wined3d_blitter_ops *wined3d_select_blitter(const struct wined3d_gl_info *gl_info,
const struct wined3d_d3d_info *d3d_info, enum wined3d_blit_op blit_op,
const RECT *src_rect, DWORD src_usage, enum wined3d_pool src_pool, const struct wined3d_format *src_format,
const RECT *dst_rect, DWORD dst_usage, enum wined3d_pool dst_pool, const struct wined3d_format *dst_format)
DECLSPEC_HIDDEN;
struct wined3d_context *context_acquire(const struct wined3d_device *device,
struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
......@@ -2361,7 +2361,6 @@ struct wined3d_adapter
const struct wined3d_vertex_pipe_ops *vertex_pipe;
const struct fragment_pipeline *fragment_pipe;
const struct wined3d_shader_backend_ops *shader_backend;
const struct wined3d_blitter_ops *blitter;
};
struct wined3d_caps_gl_ctx
......@@ -2624,11 +2623,10 @@ struct wined3d_device
void *shader_priv;
void *fragment_priv;
void *vertex_priv;
void *blit_priv;
struct StateEntry StateTable[STATE_HIGHEST + 1];
/* Array of functions for states which are handled by more than one pipeline part */
APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
const struct wined3d_blitter_ops *blitter;
struct wined3d_blitter *blitter;
BYTE vertexBlendUsed : 1; /* To avoid needless setting of the blend matrices */
BYTE bCursorVisible : 1;
......
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