Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/stateblock.c | 37 +++++++++++++++++----------------- dlls/wined3d/wined3d_private.h | 4 +++- 2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 1c3704c10a5..24017490e67 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -575,7 +575,7 @@ void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state)
for (i = 0; i < LIGHTMAP_SIZE; ++i) { - LIST_FOR_EACH_ENTRY_SAFE(light, cursor, &state->light_state.light_map[i], struct wined3d_light_info, entry) + LIST_FOR_EACH_ENTRY_SAFE(light, cursor, &state->light_state->light_map[i], struct wined3d_light_info, entry) { list_remove(&light->entry); heap_free(light); @@ -1025,7 +1025,7 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, stateblock->stateblock_state.ps = state->ps; }
- wined3d_state_record_lights(&stateblock->stateblock_state.light_state, &state->light_state); + wined3d_state_record_lights(stateblock->stateblock_state.light_state, state->light_state);
TRACE("Capture done.\n"); } @@ -1073,17 +1073,17 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock, wined3d_device_set_vs_consts_b(device, idx, 1, &stateblock->stateblock_state.vs_consts_b[idx]); }
- for (i = 0; i < ARRAY_SIZE(stateblock->stateblock_state.light_state.light_map); ++i) + for (i = 0; i < ARRAY_SIZE(stateblock->stateblock_state.light_state->light_map); ++i) { const struct wined3d_light_info *light; struct wined3d_light_info *new_light;
- LIST_FOR_EACH_ENTRY(light, &stateblock->stateblock_state.light_state.light_map[i], struct wined3d_light_info, entry) + LIST_FOR_EACH_ENTRY(light, &stateblock->stateblock_state.light_state->light_map[i], struct wined3d_light_info, entry) { - if (SUCCEEDED(wined3d_light_state_set_light(&state->light_state, light->OriginalIndex, + if (SUCCEEDED(wined3d_light_state_set_light(state->light_state, light->OriginalIndex, &light->OriginalParms, &new_light))) { - wined3d_light_state_enable_light(&state->light_state, &device->adapter->d3d_info, new_light, light->glIndex != -1); + wined3d_light_state_enable_light(state->light_state, &device->adapter->d3d_info, new_light, light->glIndex != -1); } wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms); wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1); @@ -1678,24 +1678,23 @@ HRESULT CDECL wined3d_stateblock_set_light(struct wined3d_stateblock *stateblock return WINED3DERR_INVALIDCALL; }
- return wined3d_light_state_set_light(&stateblock->stateblock_state.light_state, light_idx, light, &object); + return wined3d_light_state_set_light(stateblock->stateblock_state.light_state, light_idx, light, &object); }
HRESULT CDECL wined3d_stateblock_set_light_enable(struct wined3d_stateblock *stateblock, UINT light_idx, BOOL enable) { + struct wined3d_light_state *light_state = stateblock->stateblock_state.light_state; struct wined3d_light_info *light_info; HRESULT hr;
TRACE("stateblock %p, light_idx %u, enable %#x.\n", stateblock, light_idx, enable);
- if (!(light_info = wined3d_light_state_get_light(&stateblock->stateblock_state.light_state, light_idx))) + if (!(light_info = wined3d_light_state_get_light(light_state, light_idx))) { - if (FAILED(hr = wined3d_light_state_set_light(&stateblock->stateblock_state.light_state, light_idx, - &WINED3D_default_light, &light_info))) + if (FAILED(hr = wined3d_light_state_set_light(light_state, light_idx, &WINED3D_default_light, &light_info))) return hr; } - wined3d_light_state_enable_light(&stateblock->stateblock_state.light_state, - &stateblock->device->adapter->d3d_info, light_info, enable); + wined3d_light_state_enable_light(light_state, &stateblock->device->adapter->d3d_info, light_info, enable); return S_OK; }
@@ -1981,9 +1980,9 @@ void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state, { unsigned int i;
- for (i = 0; i < ARRAY_SIZE(state->light_state.light_map); i++) + for (i = 0; i < ARRAY_SIZE(state->light_state->light_map); i++) { - list_init(&state->light_state.light_map[i]); + list_init(&state->light_state->light_map[i]); }
if (flags & WINED3D_STATE_INIT_DEFAULT) @@ -1998,6 +1997,7 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const stru
stateblock->ref = 1; stateblock->device = device; + stateblock->stateblock_state.light_state = &stateblock->light_state; wined3d_stateblock_state_init(&stateblock->stateblock_state, device, type == WINED3D_SBT_PRIMARY ? WINED3D_STATE_INIT_DEFAULT : 0);
@@ -2011,8 +2011,8 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const stru switch (type) { case WINED3D_SBT_ALL: - stateblock_init_lights(stateblock->stateblock_state.light_state.light_map, - device_state->stateblock_state.light_state.light_map); + stateblock_init_lights(stateblock->stateblock_state.light_state->light_map, + device_state->stateblock_state.light_state->light_map); stateblock_savedstates_set_all(&stateblock->changed, d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count); break; @@ -2023,8 +2023,8 @@ static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const stru break;
case WINED3D_SBT_VERTEX_STATE: - stateblock_init_lights(stateblock->stateblock_state.light_state.light_map, - device_state->stateblock_state.light_state.light_map); + stateblock_init_lights(stateblock->stateblock_state.light_state->light_map, + device_state->stateblock_state.light_state->light_map); stateblock_savedstates_set_vertex(&stateblock->changed, d3d_info->limits.vs_uniform_count); break; @@ -2078,5 +2078,6 @@ void CDECL wined3d_stateblock_reset(struct wined3d_stateblock *stateblock)
wined3d_stateblock_state_cleanup(&stateblock->stateblock_state); memset(&stateblock->stateblock_state, 0, sizeof(stateblock->stateblock_state)); + stateblock->stateblock_state.light_state = &stateblock->light_state; wined3d_stateblock_state_init(&stateblock->stateblock_state, stateblock->device, WINED3D_STATE_INIT_DEFAULT); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3ae7dab858e..5f779f041f0 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3247,7 +3247,7 @@ struct wined3d_stateblock_state struct wined3d_viewport viewport; RECT scissor_rect;
- struct wined3d_light_state light_state; + struct wined3d_light_state *light_state; };
struct wined3d_device @@ -3946,7 +3946,9 @@ struct wined3d_stateblock
/* Array indicating whether things have been set or changed */ struct wined3d_saved_states changed; + struct wined3d_stateblock_state stateblock_state; + struct wined3d_light_state light_state;
/* Contained state management */ DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/stateblock.c | 5 +++ dlls/wined3d/wined3d.spec | 1 + dlls/wined3d/wined3d_private.h | 55 --------------------------------- include/wine/wined3d.h | 56 ++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 55 deletions(-)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 24017490e67..1a0ba0a3d59 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1698,6 +1698,11 @@ HRESULT CDECL wined3d_stateblock_set_light_enable(struct wined3d_stateblock *sta return S_OK; }
+const struct wined3d_stateblock_state * CDECL wined3d_stateblock_get_state(const struct wined3d_stateblock *stateblock) +{ + return &stateblock->stateblock_state; +} + static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], const struct wined3d_d3d_info *d3d_info) { union diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index fed5ce1b128..bec84b5979c 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -259,6 +259,7 @@ @ cdecl wined3d_stateblock_capture(ptr ptr) @ cdecl wined3d_stateblock_create(ptr ptr long ptr) @ cdecl wined3d_stateblock_decref(ptr) +@ cdecl wined3d_stateblock_get_state(ptr) @ cdecl wined3d_stateblock_incref(ptr) @ cdecl wined3d_stateblock_init_contained_states(ptr) @ cdecl wined3d_stateblock_reset(ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 5f779f041f0..2a7dffb26a9 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -272,14 +272,8 @@ static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup }
/* Device caps */ -#define WINED3D_MAX_STREAMS 16 -#define WINED3D_MAX_TEXTURES 8 -#define WINED3D_MAX_FRAGMENT_SAMPLERS 16 -#define WINED3D_MAX_VERTEX_SAMPLERS 4 -#define WINED3D_MAX_COMBINED_SAMPLERS (WINED3D_MAX_FRAGMENT_SAMPLERS + WINED3D_MAX_VERTEX_SAMPLERS) #define WINED3D_MAX_ACTIVE_LIGHTS 8 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32 -#define WINED3D_MAX_CLIP_DISTANCES 8 #define MAX_CONSTANT_BUFFERS 15 #define MAX_SAMPLER_OBJECTS 16 #define MAX_SHADER_RESOURCE_VIEWS 128 @@ -699,10 +693,6 @@ enum wined3d_shader_conditional_op #define MAX_REG_INPUT 32 #define MAX_REG_OUTPUT 32 #define WINED3D_MAX_CBS 15 -#define WINED3D_MAX_CONSTS_B 16 -#define WINED3D_MAX_CONSTS_I 16 -#define WINED3D_MAX_VS_CONSTS_F 256 -#define WINED3D_MAX_PS_CONSTS_F 224
/* FIXME: This needs to go up to 2048 for * Shader model 3 according to msdn (and for software shaders) */ @@ -1504,8 +1494,6 @@ static inline void wined3d_colour_srgb_from_linear(struct wined3d_color *colour_ colour_srgb->a = colour->a; }
-#define WINED3D_HIGHEST_TRANSFORM_STATE WINED3D_TS_WORLD_MATRIX(255) /* Highest value in wined3d_transform_state. */ - void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info, const char *file, unsigned int line, const char *name) DECLSPEC_HIDDEN;
@@ -3121,15 +3109,6 @@ struct wined3d_stream_output UINT offset; };
-struct wined3d_stream_state -{ - struct wined3d_buffer *buffer; - UINT offset; - UINT stride; - UINT frequency; - UINT flags; -}; - #define LIGHTMAP_SIZE 43 #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
@@ -3216,40 +3195,6 @@ struct wined3d_dummy_textures * wined3d_device_create() ignores it. */ #define WINED3DCREATE_MULTITHREADED 0x00000004
-struct wined3d_stateblock_state -{ - struct wined3d_vertex_declaration *vertex_declaration; - struct wined3d_stream_state streams[WINED3D_MAX_STREAMS + 1]; - struct wined3d_buffer *index_buffer; - enum wined3d_format_id index_format; - int base_vertex_index; - - struct wined3d_shader *vs; - struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F]; - struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I]; - BOOL vs_consts_b[WINED3D_MAX_CONSTS_B]; - - struct wined3d_shader *ps; - struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F]; - struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I]; - BOOL ps_consts_b[WINED3D_MAX_CONSTS_B]; - - DWORD rs[WINEHIGHEST_RENDER_STATE + 1]; - struct wined3d_color blend_factor; - - struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS]; - DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; - DWORD texture_states[WINED3D_MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1]; - - struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1]; - struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES]; - struct wined3d_material material; - struct wined3d_viewport viewport; - RECT scissor_rect; - - struct wined3d_light_state *light_state; -}; - struct wined3d_device { LONG ref; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index eba14e9a022..8b64bf66c23 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -668,6 +668,7 @@ enum wined3d_transform_state };
#define WINED3D_TS_WORLD_MATRIX(index) (enum wined3d_transform_state)(index + 256) +#define WINED3D_HIGHEST_TRANSFORM_STATE WINED3D_TS_WORLD_MATRIX(255) /* Highest value in wined3d_transform_state. */
enum wined3d_basis_type { @@ -1588,6 +1589,17 @@ enum wined3d_shader_type #define WINED3D_REGISTER_WINDOW_NO_ALT_ENTER 0x00000002u #define WINED3D_REGISTER_WINDOW_NO_PRINT_SCREEN 0x00000004u
+#define WINED3D_MAX_STREAMS 16 +#define WINED3D_MAX_TEXTURES 8 +#define WINED3D_MAX_FRAGMENT_SAMPLERS 16 +#define WINED3D_MAX_VERTEX_SAMPLERS 4 +#define WINED3D_MAX_COMBINED_SAMPLERS (WINED3D_MAX_FRAGMENT_SAMPLERS + WINED3D_MAX_VERTEX_SAMPLERS) +#define WINED3D_MAX_CLIP_DISTANCES 8 +#define WINED3D_MAX_CONSTS_B 16 +#define WINED3D_MAX_CONSTS_I 16 +#define WINED3D_MAX_VS_CONSTS_F 256 +#define WINED3D_MAX_PS_CONSTS_F 224 + struct wined3d_display_mode { UINT width; @@ -2111,6 +2123,49 @@ struct wined3d_output_desc HMONITOR monitor; };
+struct wined3d_stream_state +{ + struct wined3d_buffer *buffer; + UINT offset; + UINT stride; + UINT frequency; + UINT flags; +}; + +struct wined3d_stateblock_state +{ + struct wined3d_vertex_declaration *vertex_declaration; + struct wined3d_stream_state streams[WINED3D_MAX_STREAMS + 1]; + struct wined3d_buffer *index_buffer; + enum wined3d_format_id index_format; + int base_vertex_index; + + struct wined3d_shader *vs; + struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F]; + struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I]; + BOOL vs_consts_b[WINED3D_MAX_CONSTS_B]; + + struct wined3d_shader *ps; + struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F]; + struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I]; + BOOL ps_consts_b[WINED3D_MAX_CONSTS_B]; + + DWORD rs[WINEHIGHEST_RENDER_STATE + 1]; + struct wined3d_color blend_factor; + + struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS]; + DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; + DWORD texture_states[WINED3D_MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1]; + + struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1]; + struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES]; + struct wined3d_material material; + struct wined3d_viewport viewport; + RECT scissor_rect; + + struct wined3d_light_state *light_state; +}; + struct wined3d_parent_ops { void (__stdcall *wined3d_object_destroyed)(void *parent); @@ -2666,6 +2721,7 @@ void __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device, const struct wined3d_stateblock *device_state, enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock); ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock); +const struct wined3d_stateblock_state * __cdecl wined3d_stateblock_get_state(const struct wined3d_stateblock *stateblock); ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock); void __cdecl wined3d_stateblock_init_contained_states(struct wined3d_stateblock *stateblock); void __cdecl wined3d_stateblock_reset(struct wined3d_stateblock *stateblock);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com