From: Elizabeth Figura zfigura@codeweavers.com
All of the backends old enough to not support shader-based color keying (i.e. the fixed function backends) have been removed. --- dlls/wined3d/texture.c | 58 +--------- dlls/wined3d/utils.c | 189 --------------------------------- dlls/wined3d/wined3d_private.h | 9 -- 3 files changed, 1 insertion(+), 255 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index e0271151735..deb4304c282 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -956,13 +956,6 @@ static void wined3d_texture_update_map_binding(struct wined3d_texture *texture) texture->update_map_binding = 0; }
-static void wined3d_texture_set_map_binding(struct wined3d_texture *texture, DWORD map_binding) -{ - texture->update_map_binding = map_binding; - if (!texture->resource.map_count) - wined3d_texture_update_map_binding(texture); -} - /* A GL context is provided by the caller */ static void gltexture_delete(struct wined3d_device *device, const struct wined3d_gl_info *gl_info, struct gl_texture *tex) @@ -2032,9 +2025,7 @@ void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl, DWORD alloc_flag = srgb ? WINED3D_TEXTURE_SRGB_ALLOCATED : WINED3D_TEXTURE_RGB_ALLOCATED; const struct wined3d_gl_info *gl_info = context_gl->gl_info; struct wined3d_resource *resource = &texture_gl->t.resource; - const struct wined3d_device *device = resource->device; const struct wined3d_format *format = resource->format; - const struct wined3d_color_key_conversion *conversion; const struct wined3d_format_gl *format_gl; GLenum internal;
@@ -2054,12 +2045,6 @@ void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl, { texture_gl->t.flags |= WINED3D_TEXTURE_CONVERTED; } - else if ((conversion = wined3d_format_get_color_key_conversion(&texture_gl->t, TRUE))) - { - texture_gl->t.flags |= WINED3D_TEXTURE_CONVERTED; - format = wined3d_get_format(device->adapter, conversion->dst_format, resource->bind_flags); - TRACE("Using format %s for color key conversion.\n", debug_d3dformat(format->id)); - } format_gl = wined3d_format_gl(format);
wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb); @@ -2937,14 +2922,12 @@ static BOOL wined3d_texture_load_renderbuffer(struct wined3d_texture *texture, static BOOL wined3d_texture_gl_load_texture(struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, struct wined3d_context_gl *context_gl, BOOL srgb) { - unsigned int width, height, level, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch; struct wined3d_device *device = texture_gl->t.resource.device; const struct wined3d_gl_info *gl_info = context_gl->gl_info; - const struct wined3d_color_key_conversion *conversion; + unsigned int level, src_row_pitch, src_slice_pitch; struct wined3d_texture_sub_resource *sub_resource; const struct wined3d_format *format; struct wined3d_bo_address data; - BYTE *src_mem, *dst_mem = NULL; struct wined3d_box src_box; DWORD dst_location; BOOL depth; @@ -3027,49 +3010,10 @@ static BOOL wined3d_texture_gl_load_texture(struct wined3d_texture_gl *texture_g wined3d_texture_get_pitch(&texture_gl->t, level, &src_row_pitch, &src_slice_pitch);
format = texture_gl->t.resource.format; - if ((conversion = wined3d_format_get_color_key_conversion(&texture_gl->t, TRUE))) - format = wined3d_get_format(device->adapter, conversion->dst_format, texture_gl->t.resource.bind_flags); - - /* Don't use PBOs for converted surfaces. During PBO conversion we look at - * WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is - * getting called. */ - if (conversion && sub_resource->bo) - { - TRACE("Removing the pbo attached to texture %p, %u.\n", texture_gl, sub_resource_idx); - - wined3d_texture_load_location(&texture_gl->t, sub_resource_idx, &context_gl->c, WINED3D_LOCATION_SYSMEM); - wined3d_texture_set_map_binding(&texture_gl->t, WINED3D_LOCATION_SYSMEM); - }
wined3d_texture_get_memory(&texture_gl->t, sub_resource_idx, &context_gl->c, &data); - if (conversion) - { - width = src_box.right - src_box.left; - height = src_box.bottom - src_box.top; - wined3d_format_calculate_pitch(format, device->surface_alignment, - width, height, &dst_row_pitch, &dst_slice_pitch); - - src_mem = wined3d_context_gl_map_bo_address(context_gl, &data, src_slice_pitch, WINED3D_MAP_READ); - if (!(dst_mem = malloc(dst_slice_pitch))) - { - ERR("Out of memory (%u).\n", dst_slice_pitch); - return FALSE; - } - conversion->convert(src_mem, src_row_pitch, dst_mem, dst_row_pitch, - width, height, &texture_gl->t.async.gl_color_key); - src_row_pitch = dst_row_pitch; - src_slice_pitch = dst_slice_pitch; - wined3d_context_gl_unmap_bo_address(context_gl, &data, 0, NULL); - - data.buffer_object = 0; - data.addr = dst_mem; - } - wined3d_texture_gl_upload_data(&context_gl->c, wined3d_const_bo_address(&data), format, &src_box, src_row_pitch, src_slice_pitch, &texture_gl->t, sub_resource_idx, dst_location, 0, 0, 0); - - free(dst_mem); - return TRUE; }
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 7ba67781e50..8c25973a403 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -1198,160 +1198,6 @@ static void x8_d24_unorm_download(const BYTE *src, BYTE *dst, } }
-static BOOL color_in_range(const struct wined3d_color_key *color_key, DWORD color) -{ - /* FIXME: Is this really how color keys are supposed to work? I think it - * makes more sense to compare the individual channels. */ - return color >= color_key->color_space_low_value - && color <= color_key->color_space_high_value; -} - -static void convert_b5g6r5_unorm_b5g5r5a1_unorm_color_key(const BYTE *src, unsigned int src_pitch, - BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, - const struct wined3d_color_key *color_key) -{ - const WORD *src_row; - unsigned int x, y; - WORD *dst_row; - - for (y = 0; y < height; ++y) - { - src_row = (WORD *)&src[src_pitch * y]; - dst_row = (WORD *)&dst[dst_pitch * y]; - for (x = 0; x < width; ++x) - { - WORD src_color = src_row[x]; - if (!color_in_range(color_key, src_color)) - dst_row[x] = 0x8000u | ((src_color & 0xffc0u) >> 1) | (src_color & 0x1fu); - else - dst_row[x] = ((src_color & 0xffc0u) >> 1) | (src_color & 0x1fu); - } - } -} - -static void convert_b5g5r5x1_unorm_b5g5r5a1_unorm_color_key(const BYTE *src, unsigned int src_pitch, - BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, - const struct wined3d_color_key *color_key) -{ - const WORD *src_row; - unsigned int x, y; - WORD *dst_row; - - for (y = 0; y < height; ++y) - { - src_row = (WORD *)&src[src_pitch * y]; - dst_row = (WORD *)&dst[dst_pitch * y]; - for (x = 0; x < width; ++x) - { - WORD src_color = src_row[x]; - if (color_in_range(color_key, src_color)) - dst_row[x] = src_color & ~0x8000; - else - dst_row[x] = src_color | 0x8000; - } - } -} - -static void convert_b8g8r8_unorm_b8g8r8a8_unorm_color_key(const BYTE *src, unsigned int src_pitch, - BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, - const struct wined3d_color_key *color_key) -{ - const BYTE *src_row; - unsigned int x, y; - DWORD *dst_row; - - for (y = 0; y < height; ++y) - { - src_row = &src[src_pitch * y]; - dst_row = (DWORD *)&dst[dst_pitch * y]; - for (x = 0; x < width; ++x) - { - DWORD src_color = (src_row[x * 3 + 2] << 16) | (src_row[x * 3 + 1] << 8) | src_row[x * 3]; - if (!color_in_range(color_key, src_color)) - dst_row[x] = src_color | 0xff000000; - } - } -} - -static void convert_b8g8r8x8_unorm_b8g8r8a8_unorm_color_key(const BYTE *src, unsigned int src_pitch, - BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, - const struct wined3d_color_key *color_key) -{ - const DWORD *src_row; - unsigned int x, y; - DWORD *dst_row; - - for (y = 0; y < height; ++y) - { - src_row = (DWORD *)&src[src_pitch * y]; - dst_row = (DWORD *)&dst[dst_pitch * y]; - for (x = 0; x < width; ++x) - { - DWORD src_color = src_row[x]; - if (color_in_range(color_key, src_color)) - dst_row[x] = src_color & ~0xff000000; - else - dst_row[x] = src_color | 0xff000000; - } - } -} - -static void convert_b8g8r8a8_unorm_b8g8r8a8_unorm_color_key(const BYTE *src, unsigned int src_pitch, - BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, - const struct wined3d_color_key *color_key) -{ - const DWORD *src_row; - unsigned int x, y; - DWORD *dst_row; - - for (y = 0; y < height; ++y) - { - src_row = (DWORD *)&src[src_pitch * y]; - dst_row = (DWORD *)&dst[dst_pitch * y]; - for (x = 0; x < width; ++x) - { - DWORD src_color = src_row[x]; - if (color_in_range(color_key, src_color)) - src_color &= ~0xff000000; - dst_row[x] = src_color; - } - } -} - -const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion( - const struct wined3d_texture *texture, BOOL need_alpha_ck) -{ - const struct wined3d_format *format = texture->resource.format; - unsigned int i; - - static const struct - { - enum wined3d_format_id src_format; - struct wined3d_color_key_conversion conversion; - } - color_key_info[] = - { - {WINED3DFMT_B5G6R5_UNORM, {WINED3DFMT_B5G5R5A1_UNORM, convert_b5g6r5_unorm_b5g5r5a1_unorm_color_key }}, - {WINED3DFMT_B5G5R5X1_UNORM, {WINED3DFMT_B5G5R5A1_UNORM, convert_b5g5r5x1_unorm_b5g5r5a1_unorm_color_key }}, - {WINED3DFMT_B8G8R8_UNORM, {WINED3DFMT_B8G8R8A8_UNORM, convert_b8g8r8_unorm_b8g8r8a8_unorm_color_key }}, - {WINED3DFMT_B8G8R8X8_UNORM, {WINED3DFMT_B8G8R8A8_UNORM, convert_b8g8r8x8_unorm_b8g8r8a8_unorm_color_key }}, - {WINED3DFMT_B8G8R8A8_UNORM, {WINED3DFMT_B8G8R8A8_UNORM, convert_b8g8r8a8_unorm_b8g8r8a8_unorm_color_key }}, - }; - - if (need_alpha_ck && (texture->async.flags & WINED3D_TEXTURE_ASYNC_COLOR_KEY)) - { - for (i = 0; i < ARRAY_SIZE(color_key_info); ++i) - { - if (color_key_info[i].src_format == format->id) - return &color_key_info[i].conversion; - } - - FIXME("Color-keying not supported with format %s.\n", debug_d3dformat(format->id)); - } - - return NULL; -} - /* We intentionally don't support WINED3DFMT_D32_UNORM. No hardware driver * supports it on d3d9, and applications get confused when we do. * @@ -6306,41 +6152,6 @@ void wined3d_ffp_get_fs_settings(const struct wined3d_state *state, aarg0 = (args[aop] & ARG0) ? state->texture_states[i][WINED3D_TSS_ALPHA_ARG0] : ARG_UNUSED; }
- if (!i && state->render_states[WINED3D_RS_COLORKEYENABLE] - && texture && !(texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP) - && (texture->async.color_key_flags & WINED3D_CKEY_SRC_BLT) && !texture->resource.format->alpha_size) - { - if (aop == WINED3D_TOP_DISABLE) - { - aarg1 = WINED3DTA_TEXTURE; - aop = WINED3D_TOP_SELECT_ARG1; - } - else if (aop == WINED3D_TOP_SELECT_ARG1 && aarg1 != WINED3DTA_TEXTURE) - { - if (state->blend_state && state->blend_state->desc.rt[0].enable) - { - aarg2 = WINED3DTA_TEXTURE; - aop = WINED3D_TOP_MODULATE; - } - else - { - aarg1 = WINED3DTA_TEXTURE; - } - } - else if (aop == WINED3D_TOP_SELECT_ARG2 && aarg2 != WINED3DTA_TEXTURE) - { - if (state->blend_state && state->blend_state->desc.rt[0].enable) - { - aarg1 = WINED3DTA_TEXTURE; - aop = WINED3D_TOP_MODULATE; - } - else - { - aarg2 = WINED3DTA_TEXTURE; - } - } - } - if (is_invalid_op(state, i, aop, aarg1, aarg2, aarg0)) { aarg0 = ARG_UNUSED; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 817fb99193b..7b2ef0d4b7f 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4554,13 +4554,6 @@ struct wined3d_rational UINT denominator; };
-struct wined3d_color_key_conversion -{ - enum wined3d_format_id dst_format; - void (*convert)(const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch, - unsigned int width, unsigned int height, const struct wined3d_color_key *colour_key); -}; - enum wined3d_channel_type { WINED3D_CHANNEL_TYPE_NONE, @@ -4638,8 +4631,6 @@ void wined3d_format_get_float_color_key(const struct wined3d_format *format, const struct wined3d_color_key *key, struct wined3d_color *float_colors); BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id, enum wined3d_format_id view_format_id); -const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion( - const struct wined3d_texture *texture, BOOL need_alpha_ck); uint32_t wined3d_format_pack(const struct wined3d_format *format, const struct wined3d_uvec4 *value); BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1, enum wined3d_format_id format2);