wined3d: Introduce context_get_tex_unit_mapping() 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-14 13:15:58 +01:00 committed by Alexandre Julliard
parent 1865352e3f
commit 12edaf9ad0
3 changed files with 45 additions and 29 deletions

View File

@ -2081,6 +2081,43 @@ void context_destroy(struct wined3d_device *device, struct wined3d_context *cont
if (destroy) HeapFree(GetProcessHeap(), 0, context);
}
const DWORD *context_get_tex_unit_mapping(const struct wined3d_context *context,
const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
if (!shader_version)
{
*base = 0;
*count = MAX_TEXTURES;
return context->tex_unit_map;
}
if (shader_version->major >= 4)
{
wined3d_gl_limits_get_texture_unit_range(&gl_info->limits, shader_version->type, base, count);
return NULL;
}
switch (shader_version->type)
{
case WINED3D_SHADER_TYPE_PIXEL:
*base = 0;
*count = MAX_FRAGMENT_SAMPLERS;
break;
case WINED3D_SHADER_TYPE_VERTEX:
*base = MAX_FRAGMENT_SAMPLERS;
*count = MAX_VERTEX_SAMPLERS;
break;
default:
ERR("Unhandled shader type %#x.\n", shader_version->type);
*base = 0;
*count = 0;
}
return context->tex_unit_map;
}
/* Context activation is done by the caller. */
static void set_blit_dimension(const struct wined3d_gl_info *gl_info, UINT width, UINT height)
{

View File

@ -624,36 +624,15 @@ static void shader_glsl_load_samplers_range(const struct wined3d_gl_info *gl_inf
static void shader_glsl_load_samplers(const struct wined3d_context *context,
struct shader_glsl_priv *priv, GLuint program_id, const struct wined3d_shader_reg_maps *reg_maps)
{
const struct wined3d_shader_version *version = &reg_maps->shader_version;
const char *prefix = shader_glsl_get_prefix(version->type);
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_shader_version *shader_version;
const DWORD *tex_unit_map;
unsigned int base, count;
const char *prefix;
if (reg_maps->shader_version.major >= 4)
{
tex_unit_map = NULL;
wined3d_gl_limits_get_texture_unit_range(&gl_info->limits, version->type, &base, &count);
}
else
{
tex_unit_map = context->tex_unit_map;
switch (reg_maps->shader_version.type)
{
case WINED3D_SHADER_TYPE_PIXEL:
base = 0;
count = MAX_FRAGMENT_SAMPLERS;
break;
case WINED3D_SHADER_TYPE_VERTEX:
base = MAX_FRAGMENT_SAMPLERS;
count = MAX_VERTEX_SAMPLERS;
break;
default:
ERR("Unhandled shader type %#x.\n", reg_maps->shader_version.type);
return;
}
}
shader_version = reg_maps ? &reg_maps->shader_version : NULL;
prefix = shader_glsl_get_prefix(shader_version ? shader_version->type : WINED3D_SHADER_TYPE_PIXEL);
tex_unit_map = context_get_tex_unit_mapping(context, shader_version, &base, &count);
shader_glsl_load_samplers_range(gl_info, priv, program_id, prefix, base, count, tex_unit_map);
}
@ -9096,9 +9075,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
{
entry->constant_update_mask |= WINED3D_SHADER_CONST_FFP_PS;
shader_glsl_load_samplers_range(gl_info, priv, program_id,
shader_glsl_get_prefix(WINED3D_SHADER_TYPE_PIXEL),
0, MAX_TEXTURES, context->tex_unit_map);
shader_glsl_load_samplers(context, priv, program_id, NULL);
}
for (i = 0; i < MAX_TEXTURES; ++i)

View File

@ -1926,6 +1926,8 @@ void context_free_event_query(struct wined3d_event_query *query) DECLSPEC_HIDDEN
void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
struct wined3d_context *context_get_current(void) DECLSPEC_HIDDEN;
GLenum context_get_offscreen_gl_buffer(const struct wined3d_context *context) DECLSPEC_HIDDEN;
const DWORD *context_get_tex_unit_mapping(const struct wined3d_context *context,
const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
void context_gl_resource_released(struct wined3d_device *device,
GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;