wined3d: Introduce wined3d_sampler_bind() helper function.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-03-20 12:13:06 +01:00 committed by Alexandre Julliard
parent f82a437a90
commit 584ec259b2
4 changed files with 36 additions and 15 deletions

View file

@ -3394,14 +3394,12 @@ static void context_bind_shader_resources(struct wined3d_context *context,
const struct wined3d_state *state, enum wined3d_shader_type shader_type)
{
unsigned int bind_idx, shader_sampler_count, base, count, i;
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_device *device = context->device;
struct wined3d_shader_sampler_map_entry *entry;
struct wined3d_shader_resource_view *view;
const struct wined3d_shader *shader;
struct wined3d_sampler *sampler;
const DWORD *tex_unit_map;
GLuint sampler_name;
if (!(shader = state->shader[shader_type]))
return;
@ -3429,16 +3427,10 @@ static void context_bind_shader_resources(struct wined3d_context *context,
}
if (entry->sampler_idx == WINED3D_SAMPLER_DEFAULT)
sampler_name = device->default_sampler->name;
else if ((sampler = state->sampler[shader_type][entry->sampler_idx]))
sampler_name = sampler->name;
else
sampler_name = device->null_sampler->name;
context_active_texture(context, gl_info, bind_idx);
GL_EXTCALL(glBindSampler(bind_idx, sampler_name));
checkGLcall("glBindSampler");
wined3d_shader_resource_view_bind(view, context);
sampler = device->default_sampler;
else if (!(sampler = state->sampler[shader_type][entry->sampler_idx]))
sampler = device->null_sampler;
wined3d_shader_resource_view_bind(view, bind_idx, sampler, context);
}
}

View file

@ -150,3 +150,24 @@ HRESULT CDECL wined3d_sampler_create(struct wined3d_device *device, const struct
return WINED3D_OK;
}
/* This function relies on the correct texture being bound and loaded. */
void wined3d_sampler_bind(struct wined3d_sampler *sampler, unsigned int unit,
struct wined3d_texture *texture, const struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
{
GL_EXTCALL(glBindSampler(unit, sampler->name));
checkGLcall("bind sampler");
}
else if (texture)
{
wined3d_texture_apply_sampler_desc(texture, &sampler->desc, context);
}
else
{
ERR("Could not apply sampler state.\n");
}
}

View file

@ -638,13 +638,17 @@ HRESULT CDECL wined3d_shader_resource_view_create(const struct wined3d_view_desc
}
void wined3d_shader_resource_view_bind(struct wined3d_shader_resource_view *view,
struct wined3d_context *context)
unsigned int unit, struct wined3d_sampler *sampler, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_texture *texture;
context_active_texture(context, gl_info, unit);
if (view->gl_view.name)
{
context_bind_texture(context, view->gl_view.target, view->gl_view.name);
wined3d_sampler_bind(sampler, unit, NULL, context);
return;
}
@ -656,6 +660,7 @@ void wined3d_shader_resource_view_bind(struct wined3d_shader_resource_view *view
texture = wined3d_texture_from_resource(view->resource);
wined3d_texture_bind(texture, context, FALSE);
wined3d_sampler_bind(sampler, unit, texture, context);
}
ULONG CDECL wined3d_unordered_access_view_incref(struct wined3d_unordered_access_view *view)

View file

@ -3087,6 +3087,9 @@ struct wined3d_sampler
GLuint name;
};
void wined3d_sampler_bind(struct wined3d_sampler *sampler, unsigned int unit,
struct wined3d_texture *texture, const struct wined3d_context *context) DECLSPEC_HIDDEN;
struct wined3d_vertex_declaration_element
{
const struct wined3d_format *format;
@ -3415,8 +3418,8 @@ struct wined3d_shader_resource_view
struct wined3d_gl_view gl_view;
};
void wined3d_shader_resource_view_bind(struct wined3d_shader_resource_view *view,
struct wined3d_context *context) DECLSPEC_HIDDEN;
void wined3d_shader_resource_view_bind(struct wined3d_shader_resource_view *view, unsigned int unit,
struct wined3d_sampler *sampler, struct wined3d_context *context) DECLSPEC_HIDDEN;
struct wined3d_unordered_access_view
{