Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wined3d/cs.c | 10 +- dlls/wined3d/device.c | 176 +++++++++++++++++---------------- dlls/wined3d/texture.c | 2 +- dlls/wined3d/wined3d_private.h | 2 +- 4 files changed, 100 insertions(+), 90 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 0385b8f4693..4ee3d97b7fc 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -677,7 +677,7 @@ static void wined3d_cs_exec_clear(struct wined3d_cs *cs, const void *data) void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) { - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; const struct wined3d_viewport *vp = &state->viewports[0]; struct wined3d_rendertarget_view *view; struct wined3d_cs_clear *op; @@ -886,7 +886,7 @@ static void acquire_compute_pipeline_resources(const struct wined3d_state *state void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z) { - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; struct wined3d_cs_dispatch *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); @@ -904,7 +904,7 @@ void wined3d_cs_emit_dispatch(struct wined3d_cs *cs, void wined3d_cs_emit_dispatch_indirect(struct wined3d_cs *cs, struct wined3d_buffer *buffer, unsigned int offset) { - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; struct wined3d_cs_dispatch *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); @@ -1045,7 +1045,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, enum wined3d_primitive_type pri unsigned int index_count, unsigned int start_instance, unsigned int instance_count, bool indexed) { const struct wined3d_d3d_info *d3d_info = &cs->device->adapter->d3d_info; - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; struct wined3d_cs_draw *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); @@ -1069,7 +1069,7 @@ void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, enum wined3d_primitive unsigned int patch_vertex_count, struct wined3d_buffer *buffer, unsigned int offset, bool indexed) { const struct wined3d_d3d_info *d3d_info = &cs->device->adapter->d3d_info; - const struct wined3d_state *state = &cs->device->state; + const struct wined3d_state *state = cs->device->state; struct wined3d_cs_draw *op;
op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e44ca3ddb63..865d7f83098 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -251,6 +251,8 @@ void wined3d_device_cleanup(struct wined3d_device *device) wine_rb_destroy(&device->depth_stencil_states, device_leftover_depth_stencil_state, NULL); wine_rb_destroy(&device->so_descs, device_free_so_desc, NULL);
+ heap_free(device->state); + device->state = NULL; wined3d_decref(device->wined3d); device->wined3d = NULL; } @@ -1083,7 +1085,7 @@ HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, str { static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 0.0f}; const struct wined3d_swapchain_desc *swapchain_desc; - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; DWORD clear_flags = 0; unsigned int i; HRESULT hr; @@ -1188,7 +1190,7 @@ static void device_free_depth_stencil_state(struct wine_rb_entry *entry, void *c
void wined3d_device_uninit_3d(struct wined3d_device *device) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_resource *resource, *cursor; struct wined3d_rendertarget_view *view; struct wined3d_texture *texture; @@ -1300,7 +1302,7 @@ UINT CDECL wined3d_device_get_available_texture_mem(const struct wined3d_device void CDECL wined3d_device_set_stream_output(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer, UINT offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_stream_output *stream; struct wined3d_buffer *prev_buffer;
@@ -1327,7 +1329,7 @@ void CDECL wined3d_device_set_stream_output(struct wined3d_device *device, UINT struct wined3d_buffer * CDECL wined3d_device_get_stream_output(struct wined3d_device *device, UINT idx, UINT *offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, idx %u, offset %p.\n", device, idx, offset);
@@ -1345,7 +1347,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_stream_output(struct wined3d_de HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_stream_state *stream; struct wined3d_buffer *prev_buffer;
@@ -1389,7 +1391,7 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *device, UINT stream_idx, struct wined3d_buffer **buffer, UINT *offset, UINT *stride) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; const struct wined3d_stream_state *stream;
TRACE("device %p, stream_idx %u, buffer %p, offset %p, stride %p.\n", @@ -1412,7 +1414,7 @@ HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *devi
static void wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_stream_state *stream; UINT old_flags, old_freq;
@@ -1431,7 +1433,7 @@ static void wined3d_device_set_stream_source_freq(struct wined3d_device *device, static void wined3d_device_set_transform(struct wined3d_device *device, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(d3dts), matrix); @@ -1459,7 +1461,7 @@ static void wined3d_device_set_transform(struct wined3d_device *device, static void wined3d_device_get_transform(const struct wined3d_device *device, enum wined3d_transform_state transform_state, struct wined3d_matrix *matrix) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, transform_state %s, matrix %p.\n", device, debug_d3dtstype(transform_state), matrix);
@@ -1476,7 +1478,7 @@ static void wined3d_device_get_transform(const struct wined3d_device *device, static void wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const struct wined3d_light *light) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_light_info *object = NULL; float rho;
@@ -1576,7 +1578,7 @@ static void wined3d_device_set_light(struct wined3d_device *device,
static void wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_light_info *light_info;
TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable); @@ -1601,7 +1603,7 @@ static void wined3d_device_set_light_enable(struct wined3d_device *device, UINT static HRESULT wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const struct wined3d_vec4 *plane) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane);
@@ -1648,7 +1650,7 @@ HRESULT CDECL wined3d_device_get_clip_status(const struct wined3d_device *device
static void wined3d_device_set_material(struct wined3d_device *device, const struct wined3d_material *material) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, material %p.\n", device, material);
@@ -1659,7 +1661,7 @@ static void wined3d_device_set_material(struct wined3d_device *device, const str void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; enum wined3d_format_id prev_format; struct wined3d_buffer *prev_buffer; unsigned int prev_offset; @@ -1687,7 +1689,7 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, struct wined3d_buffer * CDECL wined3d_device_get_index_buffer(const struct wined3d_device *device, enum wined3d_format_id *format, unsigned int *offset) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, format %p, offset %p.\n", device, format, offset);
@@ -1699,7 +1701,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_index_buffer(const struct wined
void CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, base_index %d.\n", device, base_index);
@@ -1709,7 +1711,7 @@ void CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, I void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned int viewport_count, const struct wined3d_viewport *viewports) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, viewport_count %u, viewports %p.\n", device, viewport_count, viewports); @@ -1732,7 +1734,7 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned void CDECL wined3d_device_get_viewports(const struct wined3d_device *device, unsigned int *viewport_count, struct wined3d_viewport *viewports) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; unsigned int count;
TRACE("device %p, viewport_count %p, viewports %p.\n", device, viewport_count, viewports); @@ -1746,7 +1748,7 @@ void CDECL wined3d_device_get_viewports(const struct wined3d_device *device, uns
static void resolve_depth_buffer(struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; struct wined3d_rendertarget_view *src_view; struct wined3d_resource *dst_resource; struct wined3d_texture *dst_texture; @@ -1766,7 +1768,7 @@ static void resolve_depth_buffer(struct wined3d_device *device) void CDECL wined3d_device_set_blend_state(struct wined3d_device *device, struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor, unsigned int sample_mask) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_blend_state *prev;
TRACE("device %p, blend_state %p, blend_factor %s, sample_mask %#x.\n", @@ -1790,7 +1792,7 @@ void CDECL wined3d_device_set_blend_state(struct wined3d_device *device, struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct wined3d_device *device, struct wined3d_color *blend_factor, unsigned int *sample_mask) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, blend_factor %p, sample_mask %p.\n", device, blend_factor, sample_mask);
@@ -1802,7 +1804,7 @@ struct wined3d_blend_state * CDECL wined3d_device_get_blend_state(const struct w void CDECL wined3d_device_set_depth_stencil_state(struct wined3d_device *device, struct wined3d_depth_stencil_state *depth_stencil_state, unsigned int stencil_ref) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_depth_stencil_state *prev;
TRACE("device %p, depth_stencil_state %p, stencil_ref %u.\n", device, depth_stencil_state, stencil_ref); @@ -1822,7 +1824,7 @@ void CDECL wined3d_device_set_depth_stencil_state(struct wined3d_device *device,
struct wined3d_depth_stencil_state * CDECL wined3d_device_get_depth_stencil_state(const struct wined3d_device *device, unsigned int *stencil_ref) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, stencil_ref %p.\n", device, stencil_ref);
@@ -1833,7 +1835,7 @@ struct wined3d_depth_stencil_state * CDECL wined3d_device_get_depth_stencil_stat void CDECL wined3d_device_set_rasterizer_state(struct wined3d_device *device, struct wined3d_rasterizer_state *rasterizer_state) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_rasterizer_state *prev;
TRACE("device %p, rasterizer_state %p.\n", device, rasterizer_state); @@ -1852,7 +1854,7 @@ void CDECL wined3d_device_set_rasterizer_state(struct wined3d_device *device,
struct wined3d_rasterizer_state * CDECL wined3d_device_get_rasterizer_state(struct wined3d_device *device) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -1862,7 +1864,7 @@ struct wined3d_rasterizer_state * CDECL wined3d_device_get_rasterizer_state(stru void CDECL wined3d_device_set_render_state(struct wined3d_device *device, enum wined3d_render_state render_state, DWORD value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, render_state %s (%#x), value %#x.\n", device, debug_d3drenderstate(render_state), render_state, value);
@@ -1889,7 +1891,7 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device, enum wined3d_render_state render_state) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, render_state %s (%#x).\n", device, debug_d3drenderstate(render_state), render_state);
@@ -1899,7 +1901,7 @@ DWORD CDECL wined3d_device_get_render_state(const struct wined3d_device *device, static void wined3d_device_set_sampler_state(struct wined3d_device *device, UINT sampler_idx, enum wined3d_sampler_state sampler_state, DWORD value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, sampler_idx %u, sampler_state %s, value %#x.\n", device, sampler_idx, debug_d3dsamplerstate(sampler_state), value); @@ -1917,7 +1919,7 @@ static void wined3d_device_set_sampler_state(struct wined3d_device *device, void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsigned int rect_count, const RECT *rects) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, rect_count %u, rects %p.\n", device, rect_count, rects); @@ -1945,7 +1947,7 @@ void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsig
void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device, unsigned int *rect_count, RECT *rects) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; unsigned int count;
TRACE("device %p, rect_count %p, rects %p.\n", device, rect_count, rects); @@ -1960,7 +1962,7 @@ void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device, void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, struct wined3d_vertex_declaration *declaration) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_vertex_declaration *prev = state->vertex_declaration;
TRACE("device %p, declaration %p.\n", device, declaration); @@ -1978,7 +1980,7 @@ void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -1987,7 +1989,7 @@ struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(
void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev = state->shader[WINED3D_SHADER_TYPE_VERTEX];
TRACE("device %p, shader %p.\n", device, shader); @@ -2005,7 +2007,7 @@ void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struc
struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2015,7 +2017,7 @@ struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wine void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_buffer *buffer) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_buffer *prev;
TRACE("device %p, type %#x, idx %u, buffer %p.\n", device, type, idx, buffer); @@ -2041,7 +2043,7 @@ void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, struct wined3d_buffer * CDECL wined3d_device_get_constant_buffer(const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, shader_type %#x, idx %u.\n", device, shader_type, idx);
@@ -2057,7 +2059,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_constant_buffer(const struct wi static void wined3d_device_set_shader_resource_view(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_shader_resource_view *view) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; const struct wined3d_rendertarget_view *dsv; struct wined3d_shader_resource_view *prev;
@@ -2105,7 +2107,7 @@ void CDECL wined3d_device_set_vs_resource_view(struct wined3d_device *device, static struct wined3d_shader_resource_view *wined3d_device_get_shader_resource_view( const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
if (idx >= MAX_SHADER_RESOURCE_VIEWS) { @@ -2127,7 +2129,7 @@ struct wined3d_shader_resource_view * CDECL wined3d_device_get_vs_resource_view( static void wined3d_device_set_sampler(struct wined3d_device *device, enum wined3d_shader_type type, UINT idx, struct wined3d_sampler *sampler) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_sampler *prev;
if (idx >= MAX_SAMPLER_OBJECTS) @@ -2158,7 +2160,7 @@ void CDECL wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx static struct wined3d_sampler *wined3d_device_get_sampler(const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
if (idx >= MAX_SAMPLER_OBJECTS) { @@ -2179,7 +2181,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_vs_sampler(const struct wined3 static void wined3d_device_set_vs_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2198,7 +2200,7 @@ static void wined3d_device_set_vs_consts_b(struct wined3d_device *device, static void wined3d_device_set_vs_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2217,7 +2219,7 @@ static void wined3d_device_set_vs_consts_i(struct wined3d_device *device, static void wined3d_device_set_vs_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2235,7 +2237,7 @@ static void wined3d_device_set_vs_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev = state->shader[WINED3D_SHADER_TYPE_PIXEL];
TRACE("device %p, shader %p.\n", device, shader); @@ -2253,7 +2255,7 @@ void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct
struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2293,7 +2295,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_ps_sampler(const struct wined3 static void wined3d_device_set_ps_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2312,7 +2314,7 @@ static void wined3d_device_set_ps_consts_b(struct wined3d_device *device, static void wined3d_device_set_ps_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2331,7 +2333,7 @@ static void wined3d_device_set_ps_consts_i(struct wined3d_device *device, static void wined3d_device_set_ps_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; unsigned int i;
TRACE("device %p, start_idx %u, count %u, constants %p.\n", @@ -2349,7 +2351,7 @@ static void wined3d_device_set_ps_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_hull_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); @@ -2367,7 +2369,7 @@ void CDECL wined3d_device_set_hull_shader(struct wined3d_device *device, struct
struct wined3d_shader * CDECL wined3d_device_get_hull_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2407,7 +2409,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_hs_sampler(const struct wined3
void CDECL wined3d_device_set_domain_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); @@ -2425,7 +2427,7 @@ void CDECL wined3d_device_set_domain_shader(struct wined3d_device *device, struc
struct wined3d_shader * CDECL wined3d_device_get_domain_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2465,7 +2467,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_ds_sampler(const struct wined3
void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
TRACE("device %p, shader %p.\n", device, shader); @@ -2482,7 +2484,7 @@ void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, str
struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2521,7 +2523,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_gs_sampler(const struct wined3
void CDECL wined3d_device_set_compute_shader(struct wined3d_device *device, struct wined3d_shader *shader) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); @@ -2539,7 +2541,7 @@ void CDECL wined3d_device_set_compute_shader(struct wined3d_device *device, stru
struct wined3d_shader * CDECL wined3d_device_get_compute_shader(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -2581,7 +2583,7 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev enum wined3d_pipeline pipeline, unsigned int idx, struct wined3d_unordered_access_view *uav, unsigned int initial_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_unordered_access_view *prev;
if (idx >= MAX_UNORDERED_ACCESS_VIEWS) @@ -2605,7 +2607,7 @@ static void wined3d_device_set_pipeline_unordered_access_view(struct wined3d_dev static struct wined3d_unordered_access_view *wined3d_device_get_pipeline_unordered_access_view( const struct wined3d_device *device, enum wined3d_pipeline pipeline, unsigned int idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
if (idx >= MAX_UNORDERED_ACCESS_VIEWS) { @@ -3214,7 +3216,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO enum wined3d_material_color_source diffuse_source, specular_source, ambient_source, emissive_source; const struct wined3d_color *material_specular_state_colour; struct wined3d_matrix mat, proj_mat, view_mat, world_mat; - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; const struct wined3d_format *output_colour_format; static const struct wined3d_color black; struct wined3d_map_desc map_desc; @@ -3532,7 +3534,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device, UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer, const struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_stream_info stream_info; struct wined3d_resource *resource; struct wined3d_box box = {0}; @@ -3609,7 +3611,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device, static void wined3d_device_set_texture_stage_state(struct wined3d_device *device, UINT stage, enum wined3d_texture_stage_state texture_state, DWORD value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
TRACE("device %p, stage %u, texture_state %s, value %#x.\n", @@ -3636,7 +3638,7 @@ static void wined3d_device_set_texture_stage_state(struct wined3d_device *device static void wined3d_device_set_texture(struct wined3d_device *device, UINT stage, struct wined3d_texture *texture) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_texture *prev;
TRACE("device %p, stage %u, texture %p.\n", device, stage, texture); @@ -4127,7 +4129,7 @@ HRESULT CDECL wined3d_device_end_scene(struct wined3d_device *device) HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, rect_count %u, rects %p, flags %#x, color %s, depth %.8e, stencil %u.\n", device, rect_count, rects, flags, debug_color(color), depth, stencil); @@ -4166,7 +4168,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou void CDECL wined3d_device_set_predication(struct wined3d_device *device, struct wined3d_query *predicate, BOOL value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_query *prev;
TRACE("device %p, predicate %p, value %#x.\n", device, predicate, value); @@ -4186,7 +4188,7 @@ void CDECL wined3d_device_set_predication(struct wined3d_device *device,
struct wined3d_query * CDECL wined3d_device_get_predication(struct wined3d_device *device, BOOL *value) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, value %p.\n", device, value);
@@ -4215,7 +4217,7 @@ void CDECL wined3d_device_dispatch_compute_indirect(struct wined3d_device *devic void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device, enum wined3d_primitive_type primitive_type, unsigned int patch_vertex_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, primitive_type %s, patch_vertex_count %u.\n", device, debug_d3dprimitivetype(primitive_type), patch_vertex_count); @@ -4227,7 +4229,7 @@ void CDECL wined3d_device_set_primitive_type(struct wined3d_device *device, void CDECL wined3d_device_get_primitive_type(const struct wined3d_device *device, enum wined3d_primitive_type *primitive_type, unsigned int *patch_vertex_count) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p, primitive_type %p, patch_vertex_count %p.\n", device, primitive_type, patch_vertex_count); @@ -4241,7 +4243,7 @@ void CDECL wined3d_device_get_primitive_type(const struct wined3d_device *device
HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT start_vertex, UINT vertex_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, start_vertex %u, vertex_count %u.\n", device, start_vertex, vertex_count);
@@ -4254,7 +4256,7 @@ HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT void CDECL wined3d_device_draw_primitive_instanced(struct wined3d_device *device, UINT start_vertex, UINT vertex_count, UINT start_instance, UINT instance_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, start_vertex %u, vertex_count %u, start_instance %u, instance_count %u.\n", device, start_vertex, vertex_count, start_instance, instance_count); @@ -4266,7 +4268,7 @@ void CDECL wined3d_device_draw_primitive_instanced(struct wined3d_device *device void CDECL wined3d_device_draw_primitive_instanced_indirect(struct wined3d_device *device, struct wined3d_buffer *buffer, unsigned int offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, buffer %p, offset %u.\n", device, buffer, offset);
@@ -4276,7 +4278,7 @@ void CDECL wined3d_device_draw_primitive_instanced_indirect(struct wined3d_devic
HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, start_idx %u, index_count %u.\n", device, start_idx, index_count);
@@ -4299,7 +4301,7 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *devic void CDECL wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device *device, UINT start_idx, UINT index_count, UINT start_instance, UINT instance_count) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, start_idx %u, index_count %u, start_instance %u, instance_count %u.\n", device, start_idx, index_count, start_instance, instance_count); @@ -4311,7 +4313,7 @@ void CDECL wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device void CDECL wined3d_device_draw_indexed_primitive_instanced_indirect(struct wined3d_device *device, struct wined3d_buffer *buffer, unsigned int offset) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
TRACE("device %p, buffer %p, offset %u.\n", device, buffer, offset);
@@ -4476,7 +4478,7 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; struct wined3d_texture *texture; DWORD i;
@@ -5057,7 +5059,7 @@ void CDECL wined3d_device_clear_unordered_access_view_uint(struct wined3d_device struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(const struct wined3d_device *device, unsigned int view_idx) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state; unsigned int max_rt_count;
TRACE("device %p, view_idx %u.\n", device, view_idx); @@ -5074,7 +5076,7 @@ struct wined3d_rendertarget_view * CDECL wined3d_device_get_rendertarget_view(co
struct wined3d_rendertarget_view * CDECL wined3d_device_get_depth_stencil_view(const struct wined3d_device *device) { - const struct wined3d_state *state = &device->state; + const struct wined3d_state *state = device->state;
TRACE("device %p.\n", device);
@@ -5084,7 +5086,7 @@ struct wined3d_rendertarget_view * CDECL wined3d_device_get_depth_stencil_view(c static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device, const struct wined3d_rendertarget_view *view, BOOL dsv) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
if (view && wined3d_is_rtv_srv_bound(view)) { @@ -5106,7 +5108,7 @@ static void wined3d_unbind_srv_for_rtv(struct wined3d_device *device, HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device, unsigned int view_idx, struct wined3d_rendertarget_view *view, BOOL set_viewport) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_rendertarget_view *prev; unsigned int max_rt_count;
@@ -5131,7 +5133,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device * primary stateblock. */ if (!view_idx && set_viewport) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
state->viewports[0].x = 0; state->viewports[0].y = 0; @@ -5174,7 +5176,7 @@ HRESULT CDECL wined3d_device_set_rendertarget_view(struct wined3d_device *device HRESULT CDECL wined3d_device_set_depth_stencil_view(struct wined3d_device *device, struct wined3d_rendertarget_view *view) { - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_rendertarget_view *prev;
TRACE("device %p, view %p.\n", device, view); @@ -5449,7 +5451,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device, const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info; struct wined3d_swapchain_state *swapchain_state; struct wined3d_swapchain_desc *current_desc; - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_resource *resource, *cursor; struct wined3d_rendertarget_view *view; struct wined3d_swapchain *swapchain; @@ -5804,7 +5806,7 @@ static void device_resource_remove(struct wined3d_device *device, struct wined3d void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) { enum wined3d_resource_type type = resource->type; - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state; struct wined3d_rendertarget_view *rtv; unsigned int i;
@@ -5962,7 +5964,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined struct wined3d_adapter *adapter = wined3d->adapters[adapter_idx]; const struct wined3d_fragment_pipe_ops *fragment_pipeline; const struct wined3d_vertex_pipe_ops *vertex_pipeline; - struct wined3d_state *state = &device->state; + struct wined3d_state *state; unsigned int i; HRESULT hr;
@@ -6013,8 +6015,15 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return hr; }
+ if (!(state = heap_alloc(sizeof(*state)))) + { + hr = E_OUTOFMEMORY; + goto err; + } + memset(state, 0, sizeof(*state)); state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+ device->state = state; device->max_frame_latency = 3;
if (!(device->cs = wined3d_cs_create(device))) @@ -6028,6 +6037,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined return WINED3D_OK;
err: + if (state) heap_free(state); for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i) { heap_free(device->multistate_funcs[i]); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 40b25c6f229..42316b4d85f 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1602,7 +1602,7 @@ DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod) if (texture->lod != lod) { struct wined3d_device *device = resource->device; - struct wined3d_state *state = &device->state; + struct wined3d_state *state = device->state;
wined3d_resource_wait_idle(resource); texture->lod = lod; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 2a75ab5d43d..56d3ef8fea2 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3776,7 +3776,7 @@ struct wined3d_device
enum wined3d_feature_level feature_level;
- struct wined3d_state state; + struct wined3d_state *state;
/* Internal use fields */ struct wined3d_device_creation_parameters create_parms;