Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ddraw/device.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 51576c81e28..def3e7c2a43 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -3555,6 +3555,7 @@ static void setup_lighting(const struct d3d_device *device, DWORD fvf, DWORD fla if (!device->material || !(fvf & D3DFVF_NORMAL) || (flags & D3DDP_DONOTLIGHT)) enable = FALSE;
+ wined3d_stateblock_set_render_state(device->state, WINED3D_RS_LIGHTING, enable); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_LIGHTING, enable); }
@@ -7033,11 +7034,18 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, wined3d_device_set_render_state(ddraw->wined3d_device, WINED3D_RS_ZENABLE, d3d_device_update_depth_stencil(device)); if (version == 1) /* Color keying is initially enabled for version 1 devices. */ + { + wined3d_stateblock_set_render_state(ddraw->state, WINED3D_RS_COLORKEYENABLE, TRUE); wined3d_device_set_render_state(ddraw->wined3d_device, WINED3D_RS_COLORKEYENABLE, TRUE); + } else if (version == 2) + { + wined3d_stateblock_set_render_state(ddraw->state, WINED3D_RS_SPECULARENABLE, TRUE); wined3d_device_set_render_state(ddraw->wined3d_device, WINED3D_RS_SPECULARENABLE, TRUE); + } if (version < 7) { + wined3d_stateblock_set_render_state(ddraw->state, WINED3D_RS_NORMALIZENORMALS, TRUE); wined3d_device_set_render_state(ddraw->wined3d_device, WINED3D_RS_NORMALIZENORMALS, TRUE); IDirect3DDevice3_SetRenderState(&device->IDirect3DDevice3_iface, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/stateblock.c | 5 +++ dlls/wined3d/wined3d.spec | 1 + dlls/wined3d/wined3d_private.h | 66 --------------------------------- include/wine/wined3d.h | 67 ++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 66 deletions(-)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 1c3704c10a5..1196eb2a7f7 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1699,6 +1699,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 3ae7dab858e..4bc2ee19113 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -272,14 +272,7 @@ 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 +692,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 +1493,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,25 +3108,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) - -struct wined3d_light_state -{ - /* Light hashmap. Collisions are handled using linked lists. */ - struct list light_map[LIGHTMAP_SIZE]; - const struct wined3d_light_info *lights[WINED3D_MAX_ACTIVE_LIGHTS]; -}; - #define WINED3D_STATE_NO_REF 0x00000001 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
@@ -3216,40 +3184,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..c5ada12d66f 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,18 @@ 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_ACTIVE_LIGHTS 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 +2124,59 @@ struct wined3d_output_desc HMONITOR monitor; };
+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) + +struct wined3d_light_state +{ + /* Light hashmap. Collisions are handled using linked lists. */ + struct list light_map[LIGHTMAP_SIZE]; + const struct wined3d_light_info *lights[WINED3D_MAX_ACTIVE_LIGHTS]; +}; + +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 +2732,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);
On Thu, 28 Nov 2019 at 09:24, Zebediah Figura z.figura12@gmail.com wrote:
+#define LIGHTMAP_SIZE 43 +#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
Although wined3d is an internal Wine interface, it still seems unfortunate to expose this particular implementation detail in the public wined3d interface.
On 11/29/19 1:25 AM, Henri Verbeet wrote:
On Thu, 28 Nov 2019 at 09:24, Zebediah Figura z.figura12@gmail.com wrote:
+#define LIGHTMAP_SIZE 43 +#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
Although wined3d is an internal Wine interface, it still seems unfortunate to expose this particular implementation detail in the public wined3d interface.
Understandable, though I'm not immediately sure what do about it.
We could introduce individual wined3d_stateblock_get_*() helpers, though at the last point of conversation regarding stateblocks, I recall you seemed to prefer allowing direct access to struct wined3d_stateblock_state.
I guess another option is to hold a pointer to wined3d_light_state instead of exposing it directly.
On Fri, 29 Nov 2019 at 18:47, Zebediah Figura z.figura12@gmail.com wrote:
On 11/29/19 1:25 AM, Henri Verbeet wrote:
On Thu, 28 Nov 2019 at 09:24, Zebediah Figura z.figura12@gmail.com wrote:
+#define LIGHTMAP_SIZE 43 +#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
Although wined3d is an internal Wine interface, it still seems unfortunate to expose this particular implementation detail in the public wined3d interface.
Understandable, though I'm not immediately sure what do about it.
We could introduce individual wined3d_stateblock_get_*() helpers, though at the last point of conversation regarding stateblocks, I recall you seemed to prefer allowing direct access to struct wined3d_stateblock_state.
Generally yes.
I guess another option is to hold a pointer to wined3d_light_state instead of exposing it directly.
I don't necessarily have a clear solution either, but I'm thinking along those lines, yes.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 2d66c569938..51b7f4d6f59 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2329,6 +2329,7 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface, D3DRENDERSTATETYPE state, DWORD *value) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); + const struct wined3d_stateblock_state *device_state; struct wined3d_color factor;
TRACE("iface %p, state %#x, value %p.\n", iface, state, value); @@ -2344,7 +2345,8 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface, }
wined3d_mutex_lock(); - *value = wined3d_device_get_render_state(device->wined3d_device, state); + device_state = wined3d_stateblock_get_state(device->state); + *value = device_state->rs[state]; wined3d_mutex_unlock();
return D3D_OK;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
On Thu, Nov 28, 2019 at 6:54 AM Zebediah Figura z.figura12@gmail.com wrote:
Signed-off-by: Zebediah Figura z.figura12@gmail.com
dlls/d3d9/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 2d66c569938..51b7f4d6f59 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2329,6 +2329,7 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface, D3DRENDERSTATETYPE state, DWORD *value) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
const struct wined3d_stateblock_state *device_state; struct wined3d_color factor;
TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
@@ -2344,7 +2345,8 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface, }
wined3d_mutex_lock();
- *value = wined3d_device_get_render_state(device->wined3d_device, state);
device_state = wined3d_stateblock_get_state(device->state);
*value = device_state->rs[state]; wined3d_mutex_unlock();
return D3D_OK;
Just a couple of comments WRT potential future improvements. Obviously they apply to the other d3d* versions too.
The state for the stateblock isn't going to change from underneath so it could be stored in the d3d9 device once and for all instead of getting it from wined3d every time it's needed. It doesn't matter a lot I guess (and it's certainly not urgent anyway), especially for those Get*() methods, but it would be one less inter-module function call per API call.
On Tue, Dec 10, 2019 at 9:34 AM Matteo Bruni matteo.mystral@gmail.com wrote:
On Thu, Nov 28, 2019 at 6:54 AM Zebediah Figura z.figura12@gmail.com wrote:
Signed-off-by: Zebediah Figura z.figura12@gmail.com
dlls/d3d9/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 2d66c569938..51b7f4d6f59 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2329,6 +2329,7 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface, D3DRENDERSTATETYPE state, DWORD *value) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
const struct wined3d_stateblock_state *device_state; struct wined3d_color factor;
TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
@@ -2344,7 +2345,8 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface, }
wined3d_mutex_lock();
- *value = wined3d_device_get_render_state(device->wined3d_device, state);
device_state = wined3d_stateblock_get_state(device->state);
*value = device_state->rs[state]; wined3d_mutex_unlock();
return D3D_OK;
Just a couple of comments WRT potential future improvements. Obviously they apply to the other d3d* versions too.
The state for the stateblock isn't going to change from underneath so it could be stored in the d3d9 device once and for all instead of getting it from wined3d every time it's needed. It doesn't matter a lot I guess (and it's certainly not urgent anyway), especially for those Get*() methods, but it would be one less inter-module function call per API call.
I guess it was just one comment, after all...
On 12/10/19 2:34 AM, Matteo Bruni wrote:
On Thu, Nov 28, 2019 at 6:54 AM Zebediah Figura z.figura12@gmail.com wrote:
Signed-off-by: Zebediah Figura z.figura12@gmail.com
dlls/d3d9/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 2d66c569938..51b7f4d6f59 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2329,6 +2329,7 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface, D3DRENDERSTATETYPE state, DWORD *value) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
const struct wined3d_stateblock_state *device_state; struct wined3d_color factor;
TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
@@ -2344,7 +2345,8 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface, }
wined3d_mutex_lock();
- *value = wined3d_device_get_render_state(device->wined3d_device, state);
device_state = wined3d_stateblock_get_state(device->state);
*value = device_state->rs[state]; wined3d_mutex_unlock();
return D3D_OK;
Just a couple of comments WRT potential future improvements. Obviously they apply to the other d3d* versions too.
The state for the stateblock isn't going to change from underneath so it could be stored in the d3d9 device once and for all instead of getting it from wined3d every time it's needed. It doesn't matter a lot I guess (and it's certainly not urgent anyway), especially for those Get*() methods, but it would be one less inter-module function call per API call.
Good point, thanks. I hadn't thought of that.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d8/device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 89cdb4e14b0..62c75baae06 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1875,18 +1875,20 @@ static HRESULT WINAPI d3d8_device_GetRenderState(IDirect3DDevice8 *iface, D3DRENDERSTATETYPE state, DWORD *value) { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); + const struct wined3d_stateblock_state *device_state;
TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
wined3d_mutex_lock(); + device_state = wined3d_stateblock_get_state(device->state); switch (state) { case D3DRS_ZBIAS: - *value = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS); + *value = device_state->rs[WINED3D_RS_DEPTHBIAS]; break;
default: - *value = wined3d_device_get_render_state(device->wined3d_device, state); + *value = device_state->rs[state]; } wined3d_mutex_unlock();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ddraw/device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index def3e7c2a43..d4dd74f8ae3 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -2289,6 +2289,7 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface, D3DRENDERSTATETYPE state, DWORD *value) { struct d3d_device *device = impl_from_IDirect3DDevice7(iface); + const struct wined3d_stateblock_state *device_state; HRESULT hr = D3D_OK;
TRACE("iface %p, state %#x, value %p.\n", iface, state, value); @@ -2297,6 +2298,7 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface, return DDERR_INVALIDPARAMS;
wined3d_mutex_lock(); + device_state = wined3d_stateblock_get_state(device->state); switch (state) { case D3DRENDERSTATE_TEXTUREMAG: @@ -2392,7 +2394,7 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface, break;
case D3DRENDERSTATE_ZBIAS: - *value = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS); + *value = device_state->rs[WINED3D_RS_DEPTHBIAS]; break;
default: @@ -2403,7 +2405,7 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface, hr = E_NOTIMPL; break; } - *value = wined3d_device_get_render_state(device->wined3d_device, state); + *value = device_state->rs[state]; } wined3d_mutex_unlock();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 33 +++++++----------------- dlls/wined3d/stateblock.c | 47 ++++++++-------------------------- dlls/wined3d/wined3d.spec | 1 - dlls/wined3d/wined3d_private.h | 3 +-- include/wine/wined3d.h | 4 +-- 5 files changed, 21 insertions(+), 67 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 51b7f4d6f59..174cdc5bf49 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2304,22 +2304,18 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevi
TRACE("iface %p, state %#x, value %#x.\n", iface, state, value);
- if (state == D3DRS_BLENDFACTOR) - { - wined3d_color_from_d3dcolor(&factor, value); - wined3d_mutex_lock(); - wined3d_stateblock_set_blend_factor(device->update_state, &factor); - if (!device->recording) - wined3d_device_set_blend_state(device->wined3d_device, NULL, &factor); - wined3d_mutex_unlock(); - - return D3D_OK; - } - wined3d_mutex_lock(); wined3d_stateblock_set_render_state(device->update_state, state, value); if (!device->recording) - wined3d_device_set_render_state(device->wined3d_device, state, value); + { + if (state == D3DRS_BLENDFACTOR) + { + wined3d_color_from_d3dcolor(&factor, value); + wined3d_device_set_blend_state(device->wined3d_device, NULL, &factor); + } + else + wined3d_device_set_render_state(device->wined3d_device, state, value); + } wined3d_mutex_unlock();
return D3D_OK; @@ -2330,20 +2326,9 @@ static HRESULT WINAPI d3d9_device_GetRenderState(IDirect3DDevice9Ex *iface, { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); const struct wined3d_stateblock_state *device_state; - struct wined3d_color factor;
TRACE("iface %p, state %#x, value %p.\n", iface, state, value);
- if (state == D3DRS_BLENDFACTOR) - { - wined3d_mutex_lock(); - wined3d_device_get_blend_state(device->wined3d_device, &factor); - wined3d_mutex_unlock(); - *value = D3DCOLOR_COLORVALUE(factor.r, factor.g, factor.b, factor.a); - - return D3D_OK; - } - wined3d_mutex_lock(); device_state = wined3d_stateblock_get_state(device->state); *value = device_state->rs[state]; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 1196eb2a7f7..056fb7198b8 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -35,6 +35,7 @@ static const DWORD pixel_states_render[] = WINED3D_RS_ALPHAREF, WINED3D_RS_ALPHATESTENABLE, WINED3D_RS_ANTIALIASEDLINEENABLE, + WINED3D_RS_BLENDFACTOR, WINED3D_RS_BLENDOP, WINED3D_RS_BLENDOPALPHA, WINED3D_RS_BACK_STENCILFAIL, @@ -208,7 +209,6 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, states->pixelShader = 1; states->vertexShader = 1; states->scissorRect = 1; - states->blend_state = 1;
/* Fixed size arrays */ states->streamSource = 0xffff; @@ -236,7 +236,6 @@ static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states unsigned int i;
states->pixelShader = 1; - states->blend_state = 1;
for (i = 0; i < ARRAY_SIZE(pixel_states_render); ++i) { @@ -903,15 +902,6 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, stateblock->stateblock_state.scissor_rect = state->scissor_rect; }
- if (stateblock->changed.blend_state - && memcmp(&state->blend_factor, &stateblock->stateblock_state.blend_factor, - sizeof(stateblock->stateblock_state.blend_factor))) - { - TRACE("Updating blend factor.\n"); - - stateblock->stateblock_state.blend_factor = state->blend_factor; - } - map = stateblock->changed.streamSource; for (i = 0; map; map >>= 1, ++i) { @@ -1129,7 +1119,14 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock, enum wined3d_render_state rs = stateblock->contained_render_states[i];
state->rs[rs] = stateblock->stateblock_state.rs[rs]; - wined3d_device_set_render_state(device, rs, stateblock->stateblock_state.rs[rs]); + if (rs == WINED3D_RS_BLENDFACTOR) + { + struct wined3d_color color; + wined3d_color_from_d3dcolor(&color, stateblock->stateblock_state.rs[rs]); + wined3d_device_set_blend_state(device, NULL, &color); + } + else + wined3d_device_set_render_state(device, rs, stateblock->stateblock_state.rs[rs]); }
/* Texture states. */ @@ -1209,12 +1206,6 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock, wined3d_device_set_scissor_rects(device, 1, &stateblock->stateblock_state.scissor_rect); }
- if (stateblock->changed.blend_state) - { - state->blend_factor = stateblock->stateblock_state.blend_factor; - wined3d_device_set_blend_state(device, NULL, &stateblock->stateblock_state.blend_factor); - } - map = stateblock->changed.streamSource; for (i = 0; map; map >>= 1, ++i) { @@ -1437,15 +1428,6 @@ void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateb stateblock->changed.renderState[state >> 5] |= 1u << (state & 0x1f); }
-void CDECL wined3d_stateblock_set_blend_factor(struct wined3d_stateblock *stateblock, - const struct wined3d_color *blend_factor) -{ - TRACE("stateblock %p, blend_factor %p.\n", stateblock, blend_factor); - - stateblock->stateblock_state.blend_factor = *blend_factor; - stateblock->changed.blend_state = TRUE; -} - void CDECL wined3d_stateblock_set_sampler_state(struct wined3d_stateblock *stateblock, UINT sampler_idx, enum wined3d_sampler_state state, DWORD value) { @@ -1828,6 +1810,7 @@ static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], c rs[WINED3D_RS_COLORWRITEENABLE1] = 0x0000000f; rs[WINED3D_RS_COLORWRITEENABLE2] = 0x0000000f; rs[WINED3D_RS_COLORWRITEENABLE3] = 0x0000000f; + rs[WINED3D_RS_BLENDFACTOR] = 0xffffffff; rs[WINED3D_RS_SRGBWRITEENABLE] = 0; rs[WINED3D_RS_DEPTHBIAS] = 0; rs[WINED3D_RS_WRAP8] = 0; @@ -1921,11 +1904,6 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
init_default_sampler_states(state->sampler_states);
- state->blend_factor.r = 1.0f; - state->blend_factor.g = 1.0f; - state->blend_factor.b = 1.0f; - state->blend_factor.a = 1.0f; - for (i = 0; i < WINED3D_MAX_STREAMS; ++i) state->streams[i].frequency = 1; } @@ -1972,11 +1950,6 @@ static void stateblock_state_init_default(struct wined3d_stateblock_state *state
init_default_sampler_states(state->sampler_states);
- state->blend_factor.r = 1.0f; - state->blend_factor.g = 1.0f; - state->blend_factor.b = 1.0f; - state->blend_factor.a = 1.0f; - for (i = 0; i < WINED3D_MAX_STREAMS; ++i) state->streams[i].frequency = 1; } diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index bec84b5979c..716b902f313 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -264,7 +264,6 @@ @ cdecl wined3d_stateblock_init_contained_states(ptr) @ cdecl wined3d_stateblock_reset(ptr) @ cdecl wined3d_stateblock_set_base_vertex_index(ptr long) -@ cdecl wined3d_stateblock_set_blend_factor(ptr ptr) @ cdecl wined3d_stateblock_set_clip_plane(ptr long ptr) @ cdecl wined3d_stateblock_set_index_buffer(ptr ptr long) @ cdecl wined3d_stateblock_set_light(ptr long ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 4bc2ee19113..d79cfbc69dc 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3863,9 +3863,8 @@ struct wined3d_saved_states DWORD pixelShader : 1; DWORD vertexShader : 1; DWORD scissorRect : 1; - DWORD blend_state : 1; DWORD store_stream_offset : 1; - DWORD padding : 3; + DWORD padding : 4; };
struct StageState { diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index c5ada12d66f..387a65e84c2 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -384,6 +384,7 @@ enum wined3d_render_state WINED3D_RS_COLORWRITEENABLE1 = 190, WINED3D_RS_COLORWRITEENABLE2 = 191, WINED3D_RS_COLORWRITEENABLE3 = 192, + WINED3D_RS_BLENDFACTOR = 193, WINED3D_RS_SRGBWRITEENABLE = 194, WINED3D_RS_DEPTHBIAS = 195, WINED3D_RS_WRAP8 = 198, @@ -2162,7 +2163,6 @@ struct wined3d_stateblock_state 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]; @@ -2737,8 +2737,6 @@ 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); void __cdecl wined3d_stateblock_set_base_vertex_index(struct wined3d_stateblock *stateblock, INT base_index); -void __cdecl wined3d_stateblock_set_blend_factor(struct wined3d_stateblock *stateblock, - const struct wined3d_color *blend_factor); HRESULT __cdecl wined3d_stateblock_set_clip_plane(struct wined3d_stateblock *stateblock, UINT plane_idx, const struct wined3d_vec4 *plane); void __cdecl wined3d_stateblock_set_index_buffer(struct wined3d_stateblock *stateblock,
On Thu, 28 Nov 2019 at 09:24, Zebediah Figura z.figura12@gmail.com wrote:
@@ -1921,11 +1904,6 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
init_default_sampler_states(state->sampler_states);
- state->blend_factor.r = 1.0f;
- state->blend_factor.g = 1.0f;
- state->blend_factor.b = 1.0f;
- state->blend_factor.a = 1.0f;
This one should stay, right?
On 12/2/19 6:59 AM, Henri Verbeet wrote:
On Thu, 28 Nov 2019 at 09:24, Zebediah Figura z.figura12@gmail.com wrote:
@@ -1921,11 +1904,6 @@ static void state_init_default(struct wined3d_state *state, const struct wined3d
init_default_sampler_states(state->sampler_states);
- state->blend_factor.r = 1.0f;
- state->blend_factor.g = 1.0f;
- state->blend_factor.b = 1.0f;
- state->blend_factor.a = 1.0f;
This one should stay, right?
Yep, thanks for catching that. I swear I looked over this several times to make sure I was only touching the stateblock_state, and I still missed this :-/