Commit ac7a67fa authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Use wined3d_device_context functions internally where possible.

parent 44e41324
...@@ -933,16 +933,17 @@ void CDECL wined3d_device_release_focus_window(struct wined3d_device *device) ...@@ -933,16 +933,17 @@ void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
static void device_init_swapchain_state(struct wined3d_device *device, struct wined3d_swapchain *swapchain) static void device_init_swapchain_state(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
{ {
BOOL ds_enable = swapchain->state.desc.enable_auto_depth_stencil; BOOL ds_enable = swapchain->state.desc.enable_auto_depth_stencil;
struct wined3d_device_context *context = &device->cs->c;
unsigned int i; unsigned int i;
for (i = 0; i < device->adapter->d3d_info.limits.max_rt_count; ++i) for (i = 0; i < device->adapter->d3d_info.limits.max_rt_count; ++i)
{ {
wined3d_device_set_rendertarget_view(device, i, NULL, FALSE); wined3d_device_context_set_rendertarget_view(context, i, NULL, FALSE);
} }
if (device->back_buffer_view) if (device->back_buffer_view)
wined3d_device_set_rendertarget_view(device, 0, device->back_buffer_view, TRUE); wined3d_device_context_set_rendertarget_view(context, 0, device->back_buffer_view, TRUE);
wined3d_device_set_depth_stencil_view(device, ds_enable ? device->auto_depth_stencil_view : NULL); wined3d_device_context_set_depth_stencil_view(context, ds_enable ? device->auto_depth_stencil_view : NULL);
} }
void wined3d_device_delete_opengl_contexts_cs(void *object) void wined3d_device_delete_opengl_contexts_cs(void *object)
...@@ -3979,9 +3980,9 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, ...@@ -3979,9 +3980,9 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
TRACE("device %p, stateblock %p.\n", device, stateblock); TRACE("device %p, stateblock %p.\n", device, stateblock);
if (changed->vertexShader) if (changed->vertexShader)
wined3d_device_set_vertex_shader(device, state->vs); wined3d_device_context_set_shader(context, WINED3D_SHADER_TYPE_VERTEX, state->vs);
if (changed->pixelShader) if (changed->pixelShader)
wined3d_device_set_pixel_shader(device, state->ps); wined3d_device_context_set_shader(context, WINED3D_SHADER_TYPE_PIXEL, state->ps);
for (start = 0; ; start = range.offset + range.size) for (start = 0; ; start = range.offset + range.size)
{ {
...@@ -4136,12 +4137,12 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, ...@@ -4136,12 +4137,12 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
if ((entry = wine_rb_get(&device->rasterizer_states, &desc))) if ((entry = wine_rb_get(&device->rasterizer_states, &desc)))
{ {
rasterizer_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_rasterizer_state, entry); rasterizer_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_rasterizer_state, entry);
wined3d_device_set_rasterizer_state(device, rasterizer_state); wined3d_device_context_set_rasterizer_state(context, rasterizer_state);
} }
else if (SUCCEEDED(wined3d_rasterizer_state_create(device, &desc, NULL, else if (SUCCEEDED(wined3d_rasterizer_state_create(device, &desc, NULL,
&wined3d_null_parent_ops, &rasterizer_state))) &wined3d_null_parent_ops, &rasterizer_state)))
{ {
wined3d_device_set_rasterizer_state(device, rasterizer_state); wined3d_device_context_set_rasterizer_state(context, rasterizer_state);
if (wine_rb_put(&device->rasterizer_states, &desc, &rasterizer_state->entry) == -1) if (wine_rb_put(&device->rasterizer_states, &desc, &rasterizer_state->entry) == -1)
{ {
ERR("Failed to insert rasterizer state.\n"); ERR("Failed to insert rasterizer state.\n");
...@@ -4209,12 +4210,14 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, ...@@ -4209,12 +4210,14 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
if ((entry = wine_rb_get(&device->blend_states, &desc))) if ((entry = wine_rb_get(&device->blend_states, &desc)))
{ {
blend_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_blend_state, entry); blend_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_blend_state, entry);
wined3d_device_set_blend_state(device, blend_state, &colour, state->rs[WINED3D_RS_MULTISAMPLEMASK]); wined3d_device_context_set_blend_state(context, blend_state, &colour,
state->rs[WINED3D_RS_MULTISAMPLEMASK]);
} }
else if (SUCCEEDED(wined3d_blend_state_create(device, &desc, NULL, else if (SUCCEEDED(wined3d_blend_state_create(device, &desc, NULL,
&wined3d_null_parent_ops, &blend_state))) &wined3d_null_parent_ops, &blend_state)))
{ {
wined3d_device_set_blend_state(device, blend_state, &colour, state->rs[WINED3D_RS_MULTISAMPLEMASK]); wined3d_device_context_set_blend_state(context, blend_state, &colour,
state->rs[WINED3D_RS_MULTISAMPLEMASK]);
if (wine_rb_put(&device->blend_states, &desc, &blend_state->entry) == -1) if (wine_rb_put(&device->blend_states, &desc, &blend_state->entry) == -1)
{ {
ERR("Failed to insert blend state.\n"); ERR("Failed to insert blend state.\n");
...@@ -4276,12 +4279,12 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, ...@@ -4276,12 +4279,12 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
if ((entry = wine_rb_get(&device->depth_stencil_states, &desc))) if ((entry = wine_rb_get(&device->depth_stencil_states, &desc)))
{ {
depth_stencil_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_depth_stencil_state, entry); depth_stencil_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_depth_stencil_state, entry);
wined3d_device_set_depth_stencil_state(device, depth_stencil_state, stencil_ref); wined3d_device_context_set_depth_stencil_state(context, depth_stencil_state, stencil_ref);
} }
else if (SUCCEEDED(wined3d_depth_stencil_state_create(device, &desc, NULL, else if (SUCCEEDED(wined3d_depth_stencil_state_create(device, &desc, NULL,
&wined3d_null_parent_ops, &depth_stencil_state))) &wined3d_null_parent_ops, &depth_stencil_state)))
{ {
wined3d_device_set_depth_stencil_state(device, depth_stencil_state, stencil_ref); wined3d_device_context_set_depth_stencil_state(context, depth_stencil_state, stencil_ref);
if (wine_rb_put(&device->depth_stencil_states, &desc, &depth_stencil_state->entry) == -1) if (wine_rb_put(&device->depth_stencil_states, &desc, &depth_stencil_state->entry) == -1)
{ {
ERR("Failed to insert depth/stencil state.\n"); ERR("Failed to insert depth/stencil state.\n");
...@@ -4325,22 +4328,22 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, ...@@ -4325,22 +4328,22 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
} }
if (changed->indices) if (changed->indices)
wined3d_device_set_index_buffer(device, state->index_buffer, state->index_format, 0); wined3d_device_context_set_index_buffer(context, state->index_buffer, state->index_format, 0);
wined3d_device_set_base_vertex_index(device, state->base_vertex_index); wined3d_device_set_base_vertex_index(device, state->base_vertex_index);
if (changed->vertexDecl) if (changed->vertexDecl)
wined3d_device_set_vertex_declaration(device, state->vertex_declaration); wined3d_device_context_set_vertex_declaration(context, state->vertex_declaration);
if (changed->material) if (changed->material)
wined3d_device_set_material(device, &state->material); wined3d_device_set_material(device, &state->material);
if (changed->viewport) if (changed->viewport)
wined3d_device_set_viewports(device, 1, &state->viewport); wined3d_device_context_set_viewports(context, 1, &state->viewport);
if (changed->scissorRect) if (changed->scissorRect)
wined3d_device_set_scissor_rects(device, 1, &state->scissor_rect); wined3d_device_context_set_scissor_rects(context, 1, &state->scissor_rect);
map = changed->streamSource; map = changed->streamSource;
while (map) while (map)
{ {
i = wined3d_bit_scan(&map); i = wined3d_bit_scan(&map);
wined3d_device_set_stream_source(device, i, state->streams[i].buffer, wined3d_device_context_set_stream_source(context, i, state->streams[i].buffer,
state->streams[i].offset, state->streams[i].stride); state->streams[i].offset, state->streams[i].stride);
} }
map = changed->streamFreq; map = changed->streamFreq;
...@@ -5696,9 +5699,10 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, ...@@ -5696,9 +5699,10 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
wined3d_device_reset_cb callback, BOOL reset_state) wined3d_device_reset_cb callback, BOOL reset_state)
{ {
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info; const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
struct wined3d_device_context *context = &device->cs->c;
struct wined3d_swapchain_state *swapchain_state; struct wined3d_swapchain_state *swapchain_state;
struct wined3d_state *state = context->state;
struct wined3d_swapchain_desc *current_desc; struct wined3d_swapchain_desc *current_desc;
struct wined3d_state *state = device->cs->c.state;
struct wined3d_resource *resource, *cursor; struct wined3d_resource *resource, *cursor;
struct wined3d_rendertarget_view *view; struct wined3d_rendertarget_view *view;
struct wined3d_swapchain *swapchain; struct wined3d_swapchain *swapchain;
...@@ -5737,9 +5741,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, ...@@ -5737,9 +5741,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
for (i = 0; i < d3d_info->limits.max_rt_count; ++i) for (i = 0; i < d3d_info->limits.max_rt_count; ++i)
{ {
wined3d_device_set_rendertarget_view(device, i, NULL, FALSE); wined3d_device_context_set_rendertarget_view(context, i, NULL, FALSE);
} }
wined3d_device_set_depth_stencil_view(device, NULL); wined3d_device_context_set_depth_stencil_view(context, NULL);
if (reset_state) if (reset_state)
{ {
...@@ -5961,9 +5965,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, ...@@ -5961,9 +5965,9 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
else else
{ {
if ((view = device->back_buffer_view)) if ((view = device->back_buffer_view))
wined3d_device_set_rendertarget_view(device, 0, view, FALSE); wined3d_device_context_set_rendertarget_view(context, 0, view, FALSE);
if ((view = device->auto_depth_stencil_view)) if ((view = device->auto_depth_stencil_view))
wined3d_device_set_depth_stencil_view(device, view); wined3d_device_context_set_depth_stencil_view(context, view);
} }
if (reset_state) if (reset_state)
......
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