[PATCH 5/8] wined3d: Introduce context_get_tex_unit_mapping() helper function.
Józef Kucia
jkucia at codeweavers.com
Tue Mar 14 07:15:58 CDT 2017
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/context.c | 37 +++++++++++++++++++++++++++++++++++++
dlls/wined3d/glsl_shader.c | 35 ++++++-----------------------------
dlls/wined3d/wined3d_private.h | 2 ++
3 files changed, 45 insertions(+), 29 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 42b1245..e1ecbbb 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -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)
{
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 572d2ef..34427ea 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -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 = ®_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 ? ®_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)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index ff2d3fa..5eb927f 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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;
--
2.10.2
More information about the wine-patches
mailing list