wined3d: Introduce wined3d_device_context_set_shader().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-03-04 21:29:50 -06:00 committed by Alexandre Julliard
parent f1842d5ba4
commit eda716682b
4 changed files with 25 additions and 68 deletions

View File

@ -2081,25 +2081,33 @@ struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(
return device->cs->c.state->vertex_declaration; return device->cs->c.state->vertex_declaration;
} }
void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader) void CDECL wined3d_device_context_set_shader(struct wined3d_device_context *context,
enum wined3d_shader_type type, struct wined3d_shader *shader)
{ {
struct wined3d_state *state = device->cs->c.state; struct wined3d_state *state = context->state;
struct wined3d_shader *prev; struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); TRACE("context %p, type %#x, shader %p.\n", context, type, shader);
prev = state->shader[WINED3D_SHADER_TYPE_VERTEX]; prev = state->shader[type];
if (shader == prev) if (shader == prev)
return; return;
if (shader) if (shader)
wined3d_shader_incref(shader); wined3d_shader_incref(shader);
state->shader[WINED3D_SHADER_TYPE_VERTEX] = shader; state->shader[type] = shader;
wined3d_device_context_emit_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_VERTEX, shader); wined3d_device_context_emit_set_shader(context, type, shader);
if (prev) if (prev)
wined3d_shader_decref(prev); wined3d_shader_decref(prev);
} }
void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{
TRACE("device %p, shader %p.\n", device, shader);
return wined3d_device_context_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_VERTEX, shader);
}
struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wined3d_device *device) struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wined3d_device *device)
{ {
TRACE("device %p.\n", device); TRACE("device %p.\n", device);
@ -2321,21 +2329,9 @@ static void wined3d_device_set_vs_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader) void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{ {
struct wined3d_state *state = device->cs->c.state;
struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); TRACE("device %p, shader %p.\n", device, shader);
prev = state->shader[WINED3D_SHADER_TYPE_PIXEL]; return wined3d_device_context_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_PIXEL, shader);
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
state->shader[WINED3D_SHADER_TYPE_PIXEL] = shader;
wined3d_device_context_emit_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_PIXEL, shader);
if (prev)
wined3d_shader_decref(prev);
} }
struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined3d_device *device) struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined3d_device *device)
@ -2431,20 +2427,9 @@ static void wined3d_device_set_ps_consts_f(struct wined3d_device *device,
void CDECL wined3d_device_set_hull_shader(struct wined3d_device *device, struct wined3d_shader *shader) void CDECL wined3d_device_set_hull_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{ {
struct wined3d_state *state = device->cs->c.state;
struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); TRACE("device %p, shader %p.\n", device, shader);
prev = state->shader[WINED3D_SHADER_TYPE_HULL]; return wined3d_device_context_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_HULL, shader);
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
state->shader[WINED3D_SHADER_TYPE_HULL] = shader;
wined3d_device_context_emit_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_HULL, shader);
if (prev)
wined3d_shader_decref(prev);
} }
struct wined3d_shader * CDECL wined3d_device_get_hull_shader(const struct wined3d_device *device) struct wined3d_shader * CDECL wined3d_device_get_hull_shader(const struct wined3d_device *device)
@ -2487,20 +2472,9 @@ struct wined3d_sampler * CDECL wined3d_device_get_hs_sampler(const struct wined3
void CDECL wined3d_device_set_domain_shader(struct wined3d_device *device, struct wined3d_shader *shader) void CDECL wined3d_device_set_domain_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{ {
struct wined3d_state *state = device->cs->c.state;
struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); TRACE("device %p, shader %p.\n", device, shader);
prev = state->shader[WINED3D_SHADER_TYPE_DOMAIN]; return wined3d_device_context_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_DOMAIN, shader);
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
state->shader[WINED3D_SHADER_TYPE_DOMAIN] = shader;
wined3d_device_context_emit_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_DOMAIN, shader);
if (prev)
wined3d_shader_decref(prev);
} }
struct wined3d_shader * CDECL wined3d_device_get_domain_shader(const struct wined3d_device *device) struct wined3d_shader * CDECL wined3d_device_get_domain_shader(const struct wined3d_device *device)
@ -2543,20 +2517,9 @@ struct wined3d_sampler * CDECL wined3d_device_get_ds_sampler(const struct wined3
void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, struct wined3d_shader *shader) void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{ {
struct wined3d_state *state = device->cs->c.state;
struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); TRACE("device %p, shader %p.\n", device, shader);
prev = state->shader[WINED3D_SHADER_TYPE_GEOMETRY]; return wined3d_device_context_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_GEOMETRY, shader);
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
state->shader[WINED3D_SHADER_TYPE_GEOMETRY] = shader;
wined3d_device_context_emit_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_GEOMETRY, shader);
if (prev)
wined3d_shader_decref(prev);
} }
struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wined3d_device *device) struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wined3d_device *device)
@ -2598,20 +2561,9 @@ struct wined3d_sampler * CDECL wined3d_device_get_gs_sampler(const struct wined3
void CDECL wined3d_device_set_compute_shader(struct wined3d_device *device, struct wined3d_shader *shader) void CDECL wined3d_device_set_compute_shader(struct wined3d_device *device, struct wined3d_shader *shader)
{ {
struct wined3d_state *state = device->cs->c.state;
struct wined3d_shader *prev;
TRACE("device %p, shader %p.\n", device, shader); TRACE("device %p, shader %p.\n", device, shader);
prev = state->shader[WINED3D_SHADER_TYPE_COMPUTE]; return wined3d_device_context_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_COMPUTE, shader);
if (shader == prev)
return;
if (shader)
wined3d_shader_incref(shader);
state->shader[WINED3D_SHADER_TYPE_COMPUTE] = shader;
wined3d_device_context_emit_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_COMPUTE, shader);
if (prev)
wined3d_shader_decref(prev);
} }
struct wined3d_shader * CDECL wined3d_device_get_compute_shader(const struct wined3d_device *device) struct wined3d_shader * CDECL wined3d_device_get_compute_shader(const struct wined3d_device *device)

View File

@ -166,6 +166,8 @@
@ cdecl wined3d_device_update_texture(ptr ptr ptr) @ cdecl wined3d_device_update_texture(ptr ptr ptr)
@ cdecl wined3d_device_validate_device(ptr ptr) @ cdecl wined3d_device_validate_device(ptr ptr)
@ cdecl wined3d_device_context_set_shader(ptr long ptr)
@ cdecl wined3d_output_find_closest_matching_mode(ptr ptr) @ cdecl wined3d_output_find_closest_matching_mode(ptr ptr)
@ cdecl wined3d_output_get_adapter(ptr) @ cdecl wined3d_output_get_adapter(ptr)
@ cdecl wined3d_output_get_desc(ptr ptr) @ cdecl wined3d_output_get_desc(ptr ptr)

View File

@ -89,7 +89,6 @@ struct wined3d_adapter;
struct wined3d_buffer_vk; struct wined3d_buffer_vk;
struct wined3d_context; struct wined3d_context;
struct wined3d_context_vk; struct wined3d_context_vk;
struct wined3d_device_context;
struct wined3d_gl_info; struct wined3d_gl_info;
struct wined3d_state; struct wined3d_state;
struct wined3d_swapchain_gl; struct wined3d_swapchain_gl;

View File

@ -2214,6 +2214,7 @@ struct wined3d_blend_state;
struct wined3d_buffer; struct wined3d_buffer;
struct wined3d_depth_stencil_state; struct wined3d_depth_stencil_state;
struct wined3d_device; struct wined3d_device;
struct wined3d_device_context;
struct wined3d_output; struct wined3d_output;
struct wined3d_palette; struct wined3d_palette;
struct wined3d_query; struct wined3d_query;
@ -2547,6 +2548,9 @@ HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device,
struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture); struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture);
HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes); HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes);
void __cdecl wined3d_device_context_set_shader(struct wined3d_device_context *context,
enum wined3d_shader_type type, struct wined3d_shader *shader);
HRESULT __cdecl wined3d_output_find_closest_matching_mode(const struct wined3d_output *output, HRESULT __cdecl wined3d_output_find_closest_matching_mode(const struct wined3d_output *output,
struct wined3d_display_mode *mode); struct wined3d_display_mode *mode);
struct wined3d_adapter * __cdecl wined3d_output_get_adapter(const struct wined3d_output *output); struct wined3d_adapter * __cdecl wined3d_output_get_adapter(const struct wined3d_output *output);