[PATCH 4/4] wined3d: Move state handling to wined3d_cs_emit_set_shader().

Henri Verbeet hverbeet at gmail.com
Tue Mar 2 08:32:52 CST 2021


On Tue, 2 Mar 2021 at 05:42, Zebediah Figura <z.figura12 at gmail.com> wrote:
>  void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type type, struct wined3d_shader *shader)
>  {
> +    struct wined3d_state *state = cs->state;
>      struct wined3d_cs_set_shader *op;
> +    struct wined3d_shader *prev;
> +
> +    prev = state->shader[type];
> +    if (shader == prev)
> +        return;
> +
> +    if (shader)
> +        wined3d_shader_incref(shader);
> +    state->shader[type] = shader;
> +    if (prev)
> +        wined3d_shader_decref(prev);
>
>      op = wined3d_cs_require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
>      op->opcode = WINED3D_CS_OP_SET_SHADER;

This kind of consolidation is fine, and we'll probably want to push it
a little further still, like we do for e.g.
wined3d_device_set_constant_buffer(), but I don't think it belongs in
wined3d_cs_emit_set_shader(). I don't know what your plans for the
public wined3d API for deferred contexts are, but I image we'd have
something similar to the following:

    HRESULT CDECL wined3d_device_context_set_shader(struct
wined3d_device_context *context,
            enum wined3d_shader_type type, struct wined3d_shader *shader);

and that would seem like the right place for this code.



More information about the wine-devel mailing list