On 3/2/21 8:32 AM, Henri Verbeet wrote:
On Tue, 2 Mar 2021 at 05:42, Zebediah Figura <z.figura12(a)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.
Essentially, my plan *was* to export wined3d_cs_emit_set_shader() directly [perhaps with some terminology changed, but the same arguments]. I guess the only reason not to do that now is wined3d_device_set_state().