[PATCH 2/5] d3d10core: Implement d3d10_device_SetPredication().
Henri Verbeet
hverbeet at codeweavers.com
Fri Sep 19 03:41:46 CDT 2014
---
dlls/d3d10core/async.c | 8 ++++++++
dlls/d3d10core/d3d10core_private.h | 1 +
dlls/d3d10core/device.c | 8 +++++++-
dlls/wined3d/cs.c | 29 +++++++++++++++++++++++++++++
dlls/wined3d/device.c | 21 +++++++++++++++++++++
dlls/wined3d/wined3d.spec | 1 +
dlls/wined3d/wined3d_private.h | 4 ++++
include/wine/wined3d.h | 2 ++
8 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d10core/async.c b/dlls/d3d10core/async.c
index f41369b..058b7bc 100644
--- a/dlls/d3d10core/async.c
+++ b/dlls/d3d10core/async.c
@@ -171,6 +171,14 @@ static const struct ID3D10QueryVtbl d3d10_query_vtbl =
d3d10_query_GetDesc,
};
+struct d3d10_query *unsafe_impl_from_ID3D10Query(ID3D10Query *iface)
+{
+ if (!iface)
+ return NULL;
+ assert(iface->lpVtbl == &d3d10_query_vtbl);
+ return CONTAINING_RECORD(iface, struct d3d10_query, ID3D10Query_iface);
+}
+
HRESULT d3d10_query_init(struct d3d10_query *query, struct d3d10_device *device,
const D3D10_QUERY_DESC *desc, BOOL predicate)
{
diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index 0891ae0..71c4dc0 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -304,6 +304,7 @@ struct d3d10_query
HRESULT d3d10_query_init(struct d3d10_query *query, struct d3d10_device *device,
const D3D10_QUERY_DESC *desc, BOOL predicate) DECLSPEC_HIDDEN;
+struct d3d10_query *unsafe_impl_from_ID3D10Query(ID3D10Query *iface) DECLSPEC_HIDDEN;
/* IDirect3D10Device1 */
struct d3d10_device
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index a5d806a..7dc6543 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -385,7 +385,13 @@ static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,
static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, ID3D10Predicate *predicate, BOOL value)
{
- FIXME("iface %p, predicate %p, value %d stub!\n", iface, predicate, value);
+ struct d3d10_device *device = impl_from_ID3D10Device(iface);
+ struct d3d10_query *query;
+
+ TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
+
+ query = unsafe_impl_from_ID3D10Query((ID3D10Query *)predicate);
+ wined3d_device_set_predication(device->wined3d_device, query ? query->wined3d_query : NULL, value);
}
static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface,
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 205f3d8..bdd86c8 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -29,6 +29,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_PRESENT,
WINED3D_CS_OP_CLEAR,
WINED3D_CS_OP_DRAW,
+ WINED3D_CS_OP_SET_PREDICATION,
WINED3D_CS_OP_SET_VIEWPORT,
WINED3D_CS_OP_SET_SCISSOR_RECT,
WINED3D_CS_OP_SET_RENDERTARGET_VIEW,
@@ -84,6 +85,13 @@ struct wined3d_cs_draw
BOOL indexed;
};
+struct wined3d_cs_set_predication
+{
+ enum wined3d_cs_op opcode;
+ struct wined3d_query *predicate;
+ BOOL value;
+};
+
struct wined3d_cs_set_viewport
{
enum wined3d_cs_op opcode;
@@ -317,6 +325,26 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, UINT start_idx, UINT index_coun
cs->ops->submit(cs);
}
+static void wined3d_cs_exec_set_predication(struct wined3d_cs *cs, const void *data)
+{
+ const struct wined3d_cs_set_predication *op = data;
+
+ cs->state.predicate = op->predicate;
+ cs->state.predicate_value = op->value;
+}
+
+void wined3d_cs_emit_set_predication(struct wined3d_cs *cs, struct wined3d_query *predicate, BOOL value)
+{
+ struct wined3d_cs_set_predication *op;
+
+ op = cs->ops->require_space(cs, sizeof(*op));
+ op->opcode = WINED3D_CS_OP_SET_PREDICATION;
+ op->predicate = predicate;
+ op->value = value;
+
+ cs->ops->submit(cs);
+}
+
static void wined3d_cs_exec_set_viewport(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_set_viewport *op = data;
@@ -880,6 +908,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
/* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present,
/* WINED3D_CS_OP_CLEAR */ wined3d_cs_exec_clear,
/* WINED3D_CS_OP_DRAW */ wined3d_cs_exec_draw,
+ /* WINED3D_CS_OP_SET_PREDICATION */ wined3d_cs_exec_set_predication,
/* WINED3D_CS_OP_SET_VIEWPORT */ wined3d_cs_exec_set_viewport,
/* WINED3D_CS_OP_SET_SCISSOR_RECT */ wined3d_cs_exec_set_scissor_rect,
/* WINED3D_CS_OP_SET_RENDERTARGET_VIEW */ wined3d_cs_exec_set_rendertarget_view,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 44fa206..cfe3b4c 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3333,6 +3333,27 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
return WINED3D_OK;
}
+void CDECL wined3d_device_set_predication(struct wined3d_device *device,
+ struct wined3d_query *predicate, BOOL value)
+{
+ struct wined3d_query *prev;
+
+ TRACE("device %p, predicate %p, value %#x.\n", device, predicate, value);
+
+ prev = device->update_state->predicate;
+ if (predicate)
+ {
+ FIXME("Predicated rendering not implemented.\n");
+ wined3d_query_incref(predicate);
+ }
+ device->update_state->predicate = predicate;
+ device->update_state->predicate_value = value;
+ if (!device->recording)
+ wined3d_cs_emit_set_predication(device->cs, predicate, value);
+ if (prev)
+ wined3d_query_decref(prev);
+}
+
void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device,
enum wined3d_primitive_type primitive_type)
{
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index e064d1a..e0f9ebc 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -126,6 +126,7 @@
@ cdecl wined3d_device_set_multithreaded(ptr)
@ cdecl wined3d_device_set_npatch_mode(ptr float)
@ cdecl wined3d_device_set_pixel_shader(ptr ptr)
+@ cdecl wined3d_device_set_predication(ptr ptr long)
@ cdecl wined3d_device_set_primitive_type(ptr long)
@ cdecl wined3d_device_set_ps_cb(ptr long ptr)
@ cdecl wined3d_device_set_ps_consts_b(ptr long ptr long)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ff98ec0..330fadd 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1862,6 +1862,8 @@ struct wined3d_state
INT base_vertex_index;
INT load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
GLenum gl_primitive_type;
+ struct wined3d_query *predicate;
+ BOOL predicate_value;
struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
@@ -2508,6 +2510,8 @@ void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs,
void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer,
enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_material *material) DECLSPEC_HIDDEN;
+void wined3d_cs_emit_set_predication(struct wined3d_cs *cs,
+ struct wined3d_query *predicate, BOOL value) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int view_idx,
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index fdbd65b..01f8e2a 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2237,6 +2237,8 @@ void __cdecl wined3d_device_set_material(struct wined3d_device *device, const st
void __cdecl wined3d_device_set_multithreaded(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_set_npatch_mode(struct wined3d_device *device, float segments);
void __cdecl wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader);
+void __cdecl wined3d_device_set_predication(struct wined3d_device *device,
+ struct wined3d_query *predicate, BOOL value);
void __cdecl wined3d_device_set_primitive_type(struct wined3d_device *device,
enum wined3d_primitive_type primitive_topology);
void __cdecl wined3d_device_set_ps_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer);
--
1.7.10.4
More information about the wine-patches
mailing list