[PATCH 5/5] wined3d: Set color keys through the command stream.
Stefan Dösinger
stefan at codeweavers.com
Sun Apr 5 17:28:55 CDT 2015
As long as we're running asynchronously we could just store a pointer in
the structure. Since we need to change it anyway I decided to keep it
free of pointers right away.
The swich when the color key is unset isn't necessary at this point. I
have kept it because the next patches will add dirtification for color
key states for src blt keys.
---
dlls/wined3d/cs.c | 82 ++++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/texture.c | 49 ++-----------------------
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 87 insertions(+), 46 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 4a04b00..adc2295 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -49,6 +49,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_SET_SAMPLER_STATE,
WINED3D_CS_OP_SET_TRANSFORM,
WINED3D_CS_OP_SET_CLIP_PLANE,
+ WINED3D_CS_OP_SET_COLOR_KEY,
WINED3D_CS_OP_SET_MATERIAL,
WINED3D_CS_OP_RESET_STATE,
};
@@ -170,6 +171,14 @@ struct wined3d_cs_set_texture
struct wined3d_texture *texture;
};
+struct wined3d_cs_set_color_key
+{
+ enum wined3d_cs_op opcode;
+ struct wined3d_texture *texture;
+ DWORD flags;
+ struct wined3d_color_key color_key;
+};
+
struct wined3d_cs_set_shader_resource_view
{
enum wined3d_cs_op opcode;
@@ -870,6 +879,78 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const
cs->ops->submit(cs);
}
+#define WINED3D_CKEY_REMOVE 0x80000000
+
+static void wined3d_cs_exec_set_color_key(struct wined3d_cs *cs, const void *data)
+{
+ const struct wined3d_cs_set_color_key *op = data;
+ struct wined3d_texture *texture = op->texture;
+
+ if (op->flags & WINED3D_CKEY_REMOVE)
+ {
+ switch (op->flags & ~(WINED3D_CKEY_COLORSPACE | WINED3D_CKEY_REMOVE))
+ {
+ case WINED3D_CKEY_DST_BLT:
+ texture->color_key_flags &= ~WINED3D_CKEY_DST_BLT;
+ break;
+
+ case WINED3D_CKEY_DST_OVERLAY:
+ texture->color_key_flags &= ~WINED3D_CKEY_DST_OVERLAY;
+ break;
+
+ case WINED3D_CKEY_SRC_BLT:
+ texture->color_key_flags &= ~WINED3D_CKEY_SRC_BLT;
+ break;
+
+ case WINED3D_CKEY_SRC_OVERLAY:
+ texture->color_key_flags &= ~WINED3D_CKEY_SRC_OVERLAY;
+ break;
+ }
+ }
+ else
+ {
+ switch (op->flags & ~WINED3D_CKEY_COLORSPACE)
+ {
+ case WINED3D_CKEY_DST_BLT:
+ texture->dst_blt_color_key = op->color_key;
+ texture->color_key_flags |= WINED3D_CKEY_DST_BLT;
+ break;
+
+ case WINED3D_CKEY_DST_OVERLAY:
+ texture->dst_overlay_color_key = op->color_key;
+ texture->color_key_flags |= WINED3D_CKEY_DST_OVERLAY;
+ break;
+
+ case WINED3D_CKEY_SRC_BLT:
+ texture->src_blt_color_key = op->color_key;
+ texture->color_key_flags |= WINED3D_CKEY_SRC_BLT;
+ break;
+
+ case WINED3D_CKEY_SRC_OVERLAY:
+ texture->src_overlay_color_key = op->color_key;
+ texture->color_key_flags |= WINED3D_CKEY_SRC_OVERLAY;
+ break;
+ }
+ }
+}
+
+void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
+ DWORD flags, const struct wined3d_color_key *color_key)
+{
+ struct wined3d_cs_set_color_key *op;
+
+ op = cs->ops->require_space(cs, sizeof(*op));
+ op->opcode = WINED3D_CS_OP_SET_COLOR_KEY;
+ op->texture = texture;
+ op->flags = flags;
+ if (color_key)
+ op->color_key = *color_key;
+ else
+ op->flags |= WINED3D_CKEY_REMOVE;
+
+ cs->ops->submit(cs);
+}
+
static void wined3d_cs_exec_set_material(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_set_material *op = data;
@@ -936,6 +1017,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_SET_SAMPLER_STATE */ wined3d_cs_exec_set_sampler_state,
/* WINED3D_CS_OP_SET_TRANSFORM */ wined3d_cs_exec_set_transform,
/* WINED3D_CS_OP_SET_CLIP_PLANE */ wined3d_cs_exec_set_clip_plane,
+ /* WINED3D_CS_OP_SET_COLOR_KEY */ wined3d_cs_exec_set_color_key,
/* WINED3D_CS_OP_SET_MATERIAL */ wined3d_cs_exec_set_material,
/* WINED3D_CS_OP_RESET_STATE */ wined3d_cs_exec_reset_state,
};
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 6b2e266..1ab100c 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -571,6 +571,8 @@ enum wined3d_texture_filter_type CDECL wined3d_texture_get_autogen_filter_type(c
HRESULT CDECL wined3d_texture_set_color_key(struct wined3d_texture *texture,
DWORD flags, const struct wined3d_color_key *color_key)
{
+ struct wined3d_device *device = texture->resource.device;
+
TRACE("texture %p, flags %#x, color_key %p.\n", texture, flags, color_key);
if (flags & WINED3D_CKEY_COLORSPACE)
@@ -579,52 +581,7 @@ HRESULT CDECL wined3d_texture_set_color_key(struct wined3d_texture *texture,
return WINED3DERR_INVALIDCALL;
}
- if (color_key)
- {
- switch (flags & ~WINED3D_CKEY_COLORSPACE)
- {
- case WINED3D_CKEY_DST_BLT:
- texture->dst_blt_color_key = *color_key;
- texture->color_key_flags |= WINED3D_CKEY_DST_BLT;
- break;
-
- case WINED3D_CKEY_DST_OVERLAY:
- texture->dst_overlay_color_key = *color_key;
- texture->color_key_flags |= WINED3D_CKEY_DST_OVERLAY;
- break;
-
- case WINED3D_CKEY_SRC_BLT:
- texture->src_blt_color_key = *color_key;
- texture->color_key_flags |= WINED3D_CKEY_SRC_BLT;
- break;
-
- case WINED3D_CKEY_SRC_OVERLAY:
- texture->src_overlay_color_key = *color_key;
- texture->color_key_flags |= WINED3D_CKEY_SRC_OVERLAY;
- break;
- }
- }
- else
- {
- switch (flags & ~WINED3D_CKEY_COLORSPACE)
- {
- case WINED3D_CKEY_DST_BLT:
- texture->color_key_flags &= ~WINED3D_CKEY_DST_BLT;
- break;
-
- case WINED3D_CKEY_DST_OVERLAY:
- texture->color_key_flags &= ~WINED3D_CKEY_DST_OVERLAY;
- break;
-
- case WINED3D_CKEY_SRC_BLT:
- texture->color_key_flags &= ~WINED3D_CKEY_SRC_BLT;
- break;
-
- case WINED3D_CKEY_SRC_OVERLAY:
- texture->color_key_flags &= ~WINED3D_CKEY_SRC_OVERLAY;
- break;
- }
- }
+ wined3d_cs_emit_set_color_key(device->cs, texture, flags, color_key);
return WINED3D_OK;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 5d736dd..4faebaf 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2552,6 +2552,8 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw
void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
+void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
+ DWORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type,
UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs,
--
2.3.4
More information about the wine-patches
mailing list