[PATCH v2 3/5] wined3d: Move the fill mode to wined3d_rasterizer_state.
Zebediah Figura
z.figura12 at gmail.com
Fri Mar 6 10:40:14 CST 2020
On 3/6/20 10:33 AM, Henri Verbeet wrote:
> On Fri, 6 Mar 2020 at 05:04, Zebediah Figura <z.figura12 at gmail.com> wrote:
>> + if (set_rasterizer_state)
>> + {
>> + struct wined3d_rasterizer_state *rasterizer_state;
>> + struct wined3d_rasterizer_state_desc desc;
>> + struct wine_rb_entry *entry;
>> +
>> + desc.fill_mode = state->rs[WINED3D_RS_FILLMODE];
>> + desc.front_ccw = FALSE;
>> + desc.depth_bias_clamp = 0.0f;
>> + desc.depth_clip = TRUE;
>> +
>> + if ((entry = wine_rb_get(&device->rasterizer_states, &desc)))
>> + {
>> + rasterizer_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_rasterizer_state, entry);
>> + wined3d_device_set_rasterizer_state(device, rasterizer_state);
>> + }
> ...
>> +static int wined3d_rasterizer_state_compare(const void *key, const struct wine_rb_entry *entry)
>> +{
>> + const struct wined3d_rasterizer_state *state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_rasterizer_state, entry);
>> +
>> + return memcmp(&state->desc, key, sizeof(state->desc));
>> +}
>
> This works, but note that it's a little fragile; you're depending on
> there not being any holes or padding in the
> wined3d_rasterizer_state_desc structure.
>
Sure; I saw similar places using memcmp(), and figured since there
shouldn't be holes (at least on x86...) it'd be safe. Is it worth changing?
[And if so, is it worth changing e.g. glsl_blitter_args_compare()?]
More information about the wine-devel
mailing list