Commit e7a71e15 authored by Roderick Colenbrander's avatar Roderick Colenbrander Committed by Alexandre Julliard

wined3d: Turn blit_shader color_fixup_supported into blit_supported.

parent 15b959fb
...@@ -6840,31 +6840,46 @@ static void arbfp_blit_unset(IWineD3DDevice *iface) { ...@@ -6840,31 +6840,46 @@ static void arbfp_blit_unset(IWineD3DDevice *iface) {
LEAVE_GL(); LEAVE_GL();
} }
static BOOL arbfp_blit_color_fixup_supported(const struct wined3d_gl_info *gl_info, struct color_fixup_desc fixup) static BOOL arbfp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool,
const struct wined3d_format_desc *src_format_desc,
const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
const struct wined3d_format_desc *dst_format_desc)
{ {
enum complex_fixup complex_fixup; enum complex_fixup src_fixup = get_complex_fixup(src_format_desc->color_fixup);
if (TRACE_ON(d3d_shader) && TRACE_ON(d3d)) if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
{ {
TRACE("Checking support for fixup:\n"); TRACE("Checking support for fixup:\n");
dump_color_fixup_desc(fixup); dump_color_fixup_desc(src_format_desc->color_fixup);
}
if (blit_op != BLIT_OP_BLIT)
{
TRACE("Unsupported blit_op=%d\n", blit_op);
return FALSE;
} }
if (is_identity_fixup(fixup)) if (!is_identity_fixup(dst_format_desc->color_fixup))
{
TRACE("Destination fixups are not supported\n");
return FALSE;
}
if (is_identity_fixup(src_format_desc->color_fixup))
{ {
TRACE("[OK]\n"); TRACE("[OK]\n");
return TRUE; return TRUE;
} }
/* We only support YUV conversions. */ /* We only support YUV conversions. */
if (!is_complex_fixup(fixup)) if (!is_complex_fixup(src_format_desc->color_fixup))
{ {
TRACE("[FAILED]\n"); TRACE("[FAILED]\n");
return FALSE; return FALSE;
} }
complex_fixup = get_complex_fixup(fixup); switch(src_fixup)
switch(complex_fixup)
{ {
case COMPLEX_FIXUP_YUY2: case COMPLEX_FIXUP_YUY2:
case COMPLEX_FIXUP_UYVY: case COMPLEX_FIXUP_UYVY:
...@@ -6874,7 +6889,7 @@ static BOOL arbfp_blit_color_fixup_supported(const struct wined3d_gl_info *gl_in ...@@ -6874,7 +6889,7 @@ static BOOL arbfp_blit_color_fixup_supported(const struct wined3d_gl_info *gl_in
return TRUE; return TRUE;
default: default:
FIXME("Unsupported YUV fixup %#x\n", complex_fixup); FIXME("Unsupported YUV fixup %#x\n", src_fixup);
TRACE("[FAILED]\n"); TRACE("[FAILED]\n");
return FALSE; return FALSE;
} }
...@@ -6891,7 +6906,7 @@ const struct blit_shader arbfp_blit = { ...@@ -6891,7 +6906,7 @@ const struct blit_shader arbfp_blit = {
arbfp_blit_free, arbfp_blit_free,
arbfp_blit_set, arbfp_blit_set,
arbfp_blit_unset, arbfp_blit_unset,
arbfp_blit_color_fixup_supported, arbfp_blit_supported,
arbfp_blit_color_fill arbfp_blit_color_fill
}; };
......
...@@ -3643,7 +3643,9 @@ static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter, ...@@ -3643,7 +3643,9 @@ static BOOL CheckSurfaceCapability(struct wined3d_adapter *adapter,
if (CheckDepthStencilCapability(adapter, adapter_format_desc, check_format_desc)) return TRUE; if (CheckDepthStencilCapability(adapter, adapter_format_desc, check_format_desc)) return TRUE;
/* If opengl can't process the format natively, the blitter may be able to convert it */ /* If opengl can't process the format natively, the blitter may be able to convert it */
if (adapter->blitter->color_fixup_supported(&adapter->gl_info, check_format_desc->color_fixup)) if (adapter->blitter->blit_supported(&adapter->gl_info, BLIT_OP_BLIT,
NULL, WINED3DPOOL_DEFAULT, 0, check_format_desc,
NULL, WINED3DPOOL_DEFAULT, 0, adapter_format_desc))
{ {
TRACE_(d3d_caps)("[OK]\n"); TRACE_(d3d_caps)("[OK]\n");
return TRUE; return TRUE;
......
...@@ -2120,6 +2120,8 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ ...@@ -2120,6 +2120,8 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
const struct wined3d_format_desc *glDesc = This->resource.format_desc; const struct wined3d_format_desc *glDesc = This->resource.format_desc;
IWineD3DDeviceImpl *device = This->resource.device; IWineD3DDeviceImpl *device = This->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
BOOL blit_supported = FALSE;
RECT rect = {0, 0, This->pow2Width, This->pow2Height};
/* Default values: From the surface */ /* Default values: From the surface */
*format = glDesc->glFormat; *format = glDesc->glFormat;
...@@ -2146,14 +2148,18 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ ...@@ -2146,14 +2148,18 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
Paletted Texture Paletted Texture
**************** */ **************** */
blit_supported = device->blitter->blit_supported(&device->adapter->gl_info, BLIT_OP_BLIT,
&rect, This->resource.usage, This->resource.pool,
This->resource.format_desc, &rect, This->resource.usage,
This->resource.pool, This->resource.format_desc);
/* Use conversion when the blit_shader backend supports it. It only supports this in case of /* Use conversion when the blit_shader backend supports it. It only supports this in case of
* texturing. Further also use conversion in case of color keying. * texturing. Further also use conversion in case of color keying.
* Paletted textures can be emulated using shaders but only do that for 2D purposes e.g. situations * Paletted textures can be emulated using shaders but only do that for 2D purposes e.g. situations
* in which the main render target uses p8. Some games like GTA Vice City use P8 for texturing which * in which the main render target uses p8. Some games like GTA Vice City use P8 for texturing which
* conflicts with this. * conflicts with this.
*/ */
if (!((device->blitter->color_fixup_supported(gl_info, This->resource.format_desc->color_fixup) if (!((blit_supported && device->render_targets && This == (IWineD3DSurfaceImpl*)device->render_targets[0]))
&& device->render_targets && This == (IWineD3DSurfaceImpl*)device->render_targets[0]))
|| colorkey_active || !use_texturing) || colorkey_active || !use_texturing)
{ {
*format = GL_RGBA; *format = GL_RGBA;
...@@ -4028,18 +4034,17 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -4028,18 +4034,17 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
dst_rect.top += This->currentDesc.Height - h; dst_rect.bottom += This->currentDesc.Height - h; dst_rect.top += This->currentDesc.Height - h; dst_rect.bottom += This->currentDesc.Height - h;
} }
if (!is_identity_fixup(This->resource.format_desc->color_fixup)) if (!myDevice->blitter->blit_supported(&myDevice->adapter->gl_info, BLIT_OP_BLIT,
&src_rect, Src->resource.usage, Src->resource.pool, Src->resource.format_desc,
&dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
{ {
FIXME("Destination format %s has a fixup, this is not supported.\n", FIXME("Unsupported blit operation falling back to software\n");
debug_d3dformat(This->resource.format_desc->format));
dump_color_fixup_desc(This->resource.format_desc->color_fixup);
}
if (!myDevice->blitter->color_fixup_supported(&myDevice->adapter->gl_info, Src->resource.format_desc->color_fixup)) /* Clear the palette as the surface didn't have a palette attached, it would confuse GetPalette and other calls */
{ if(paletteOverride)
FIXME("Source format %s has an unsupported fixup:\n", Src->palette = NULL;
debug_d3dformat(Src->resource.format_desc->format));
dump_color_fixup_desc(Src->resource.format_desc->color_fixup); return WINED3DERR_INVALIDCALL;
} }
myDevice->blitter->set_shader((IWineD3DDevice *) myDevice, Src); myDevice->blitter->set_shader((IWineD3DDevice *) myDevice, Src);
...@@ -5126,30 +5131,45 @@ static void ffp_blit_unset(IWineD3DDevice *iface) ...@@ -5126,30 +5131,45 @@ static void ffp_blit_unset(IWineD3DDevice *iface)
LEAVE_GL(); LEAVE_GL();
} }
static BOOL ffp_blit_color_fixup_supported(const struct wined3d_gl_info *gl_info, struct color_fixup_desc fixup) static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool,
const struct wined3d_format_desc *src_format_desc,
const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
const struct wined3d_format_desc *dst_format_desc)
{ {
enum complex_fixup complex_fixup; enum complex_fixup src_fixup = get_complex_fixup(src_format_desc->color_fixup);
if (TRACE_ON(d3d_surface) && TRACE_ON(d3d)) if (TRACE_ON(d3d_surface) && TRACE_ON(d3d))
{ {
TRACE("Checking support for fixup:\n"); TRACE("Checking support for fixup:\n");
dump_color_fixup_desc(fixup); dump_color_fixup_desc(src_format_desc->color_fixup);
} }
/* We only support identity conversions. */ if (blit_op != BLIT_OP_BLIT)
if (is_identity_fixup(fixup))
{ {
TRACE("[OK]\n"); TRACE("Unsupported blit_op=%d\n", blit_op);
return TRUE; return FALSE;
}
if (!is_identity_fixup(dst_format_desc->color_fixup))
{
TRACE("Destination fixups are not supported\n");
return FALSE;
} }
complex_fixup = get_complex_fixup(fixup); if (src_fixup == COMPLEX_FIXUP_P8 && gl_info->supported[EXT_PALETTED_TEXTURE])
if(complex_fixup == COMPLEX_FIXUP_P8 && gl_info->supported[EXT_PALETTED_TEXTURE])
{ {
TRACE("P8 fixup supported\n"); TRACE("P8 fixup supported\n");
return TRUE; return TRUE;
} }
/* We only support identity conversions. */
if (is_identity_fixup(src_format_desc->color_fixup))
{
TRACE("[OK]\n");
return TRUE;
}
TRACE("[FAILED]\n"); TRACE("[FAILED]\n");
return FALSE; return FALSE;
} }
...@@ -5165,7 +5185,7 @@ const struct blit_shader ffp_blit = { ...@@ -5165,7 +5185,7 @@ const struct blit_shader ffp_blit = {
ffp_blit_free, ffp_blit_free,
ffp_blit_set, ffp_blit_set,
ffp_blit_unset, ffp_blit_unset,
ffp_blit_color_fixup_supported, ffp_blit_supported,
ffp_blit_color_fill ffp_blit_color_fill
}; };
...@@ -5190,7 +5210,11 @@ static void cpu_blit_unset(IWineD3DDevice *iface) ...@@ -5190,7 +5210,11 @@ static void cpu_blit_unset(IWineD3DDevice *iface)
{ {
} }
static BOOL cpu_blit_color_fixup_supported(const struct wined3d_gl_info *gl_info, struct color_fixup_desc fixup) static BOOL cpu_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool,
const struct wined3d_format_desc *src_format_desc,
const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
const struct wined3d_format_desc *dst_format_desc)
{ {
return FALSE; return FALSE;
} }
...@@ -5209,6 +5233,6 @@ const struct blit_shader cpu_blit = { ...@@ -5209,6 +5233,6 @@ const struct blit_shader cpu_blit = {
cpu_blit_free, cpu_blit_free,
cpu_blit_set, cpu_blit_set,
cpu_blit_unset, cpu_blit_unset,
cpu_blit_color_fixup_supported, cpu_blit_supported,
cpu_blit_color_fill cpu_blit_color_fill
}; };
...@@ -1168,6 +1168,11 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_ ...@@ -1168,6 +1168,11 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_
const struct wined3d_gl_info *gl_info, const struct StateEntryTemplate *vertex, const struct wined3d_gl_info *gl_info, const struct StateEntryTemplate *vertex,
const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc) DECLSPEC_HIDDEN; const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc) DECLSPEC_HIDDEN;
enum blit_operation
{
BLIT_OP_BLIT
};
/* Shaders for color conversions in blits */ /* Shaders for color conversions in blits */
struct blit_shader struct blit_shader
{ {
...@@ -1175,7 +1180,9 @@ struct blit_shader ...@@ -1175,7 +1180,9 @@ struct blit_shader
void (*free_private)(IWineD3DDevice *iface); void (*free_private)(IWineD3DDevice *iface);
HRESULT (*set_shader)(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface); HRESULT (*set_shader)(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface);
void (*unset_shader)(IWineD3DDevice *iface); void (*unset_shader)(IWineD3DDevice *iface);
BOOL (*color_fixup_supported)(const struct wined3d_gl_info *gl_info, struct color_fixup_desc fixup); BOOL (*blit_supported)(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool, const struct wined3d_format_desc *src_format_desc,
const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool, const struct wined3d_format_desc *dst_format_desc);
HRESULT (*color_fill)(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color); HRESULT (*color_fill)(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color);
}; };
......
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