Commit 19d5e7ca authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3d8: Use wined3d_device_context methods.

parent a1ae5f1e
......@@ -114,6 +114,7 @@ struct d3d8_device
struct wined3d_device_parent device_parent;
LONG ref;
struct wined3d_device *wined3d_device;
struct wined3d_device_context *immediate_context;
unsigned int adapter_ordinal;
struct d3d8 *d3d_parent;
struct d3d8_handle_table handle_table;
......
......@@ -1534,17 +1534,17 @@ static HRESULT WINAPI d3d8_device_SetRenderTarget(IDirect3DDevice8 *iface,
original_dsv = wined3d_device_get_depth_stencil_view(device->wined3d_device);
rtv = ds_impl ? d3d8_surface_acquire_rendertarget_view(ds_impl) : NULL;
hr = wined3d_device_set_depth_stencil_view(device->wined3d_device, rtv);
hr = wined3d_device_context_set_depth_stencil_view(device->immediate_context, rtv);
d3d8_surface_release_rendertarget_view(ds_impl, rtv);
if (SUCCEEDED(hr))
{
rtv = render_target ? d3d8_surface_acquire_rendertarget_view(rt_impl) : NULL;
if (render_target)
{
if (SUCCEEDED(hr = wined3d_device_set_rendertarget_view(device->wined3d_device, 0, rtv, TRUE)))
if (SUCCEEDED(hr = wined3d_device_context_set_rendertarget_view(device->immediate_context, 0, rtv, TRUE)))
device_reset_viewport_state(device);
else
wined3d_device_set_depth_stencil_view(device->wined3d_device, original_dsv);
wined3d_device_context_set_depth_stencil_view(device->immediate_context, original_dsv);
}
d3d8_surface_release_rendertarget_view(rt_impl, rtv);
}
......@@ -2495,7 +2495,6 @@ static HRESULT WINAPI d3d8_device_DrawPrimitive(IDirect3DDevice8 *iface,
{
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
unsigned int vertex_count;
HRESULT hr;
TRACE("iface %p, primitive_type %#x, start_vertex %u, primitive_count %u.\n",
iface, primitive_type, start_vertex, primitive_count);
......@@ -2505,10 +2504,10 @@ static HRESULT WINAPI d3d8_device_DrawPrimitive(IDirect3DDevice8 *iface,
d3d8_device_upload_sysmem_vertex_buffers(device, start_vertex, vertex_count);
wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_d3d(primitive_type), 0);
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = wined3d_device_draw_primitive(device->wined3d_device, start_vertex, vertex_count);
wined3d_device_context_draw(device->immediate_context, start_vertex, vertex_count, 0, 0);
wined3d_mutex_unlock();
return hr;
return D3D_OK;
}
static HRESULT WINAPI d3d8_device_DrawIndexedPrimitive(IDirect3DDevice8 *iface,
......@@ -2535,7 +2534,7 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitive(IDirect3DDevice8 *iface,
d3d8_device_upload_sysmem_index_buffer(device, start_idx, index_count);
wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_d3d(primitive_type), 0);
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
wined3d_device_draw_indexed_primitive(device->wined3d_device, start_idx, index_count);
wined3d_device_context_draw_indexed(device->immediate_context, base_vertex_index, start_idx, index_count, 0, 0);
wined3d_mutex_unlock();
return D3D_OK;
......@@ -2629,7 +2628,7 @@ static HRESULT WINAPI d3d8_device_DrawPrimitiveUP(IDirect3DDevice8 *iface,
wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_d3d(primitive_type), 0);
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = wined3d_device_draw_primitive(device->wined3d_device, vb_pos / stride, vtx_count);
wined3d_device_context_draw(device->immediate_context, vb_pos / stride, vtx_count, 0, 0);
wined3d_stateblock_set_stream_source(device->state, 0, NULL, 0, 0);
done:
......@@ -2687,6 +2686,7 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
struct wined3d_map_desc wined3d_map_desc;
struct wined3d_box wined3d_box = {0};
struct wined3d_resource *ib, *vb;
unsigned int base_vertex_idx;
UINT vb_pos, ib_pos, align;
HRESULT hr;
......@@ -2753,11 +2753,13 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitiveUP(IDirect3DDevice8 *iface
wined3d_stateblock_set_index_buffer(device->state, device->index_buffer,
wined3dformat_from_d3dformat(index_format));
wined3d_stateblock_set_base_vertex_index(device->state, vb_pos / vertex_stride - min_vertex_idx);
base_vertex_idx = vb_pos / vertex_stride - min_vertex_idx;
wined3d_stateblock_set_base_vertex_index(device->state, base_vertex_idx);
wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_d3d(primitive_type), 0);
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
wined3d_device_draw_indexed_primitive(device->wined3d_device, ib_pos / idx_fmt_size, idx_count);
wined3d_device_context_draw_indexed(device->immediate_context,
base_vertex_idx, ib_pos / idx_fmt_size, idx_count, 0, 0);
wined3d_stateblock_set_stream_source(device->state, 0, NULL, 0, 0);
wined3d_stateblock_set_index_buffer(device->state, NULL, WINED3DFMT_UNKNOWN);
......@@ -3775,6 +3777,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
return hr;
}
device->immediate_context = wined3d_device_get_immediate_context(device->wined3d_device);
wined3d_get_device_caps(wined3d_adapter, wined3d_device_type_from_d3d(device_type), &caps);
device->max_user_clip_planes = caps.MaxUserClipPlanes;
device->vs_uniform_count = caps.MaxVertexShaderConst;
......
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