From 09fa9fbcf12336f226077ee353218b22f2a8cb72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 15 Mar 2017 12:00:07 +0100 Subject: [PATCH] wined3d: Store GL sampler limits as array. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/arb_program_shader.c | 2 +- dlls/wined3d/directx.c | 61 +++++++++++++++++-------------- dlls/wined3d/glsl_shader.c | 2 +- dlls/wined3d/state.c | 2 +- dlls/wined3d/utils.c | 28 ++++++-------- dlls/wined3d/wined3d_private.h | 5 +-- 6 files changed, 49 insertions(+), 51 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 4b8e7fb0374..66adf0f07be 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -5795,7 +5795,7 @@ static void arbfp_get_caps(const struct wined3d_gl_info *gl_info, struct fragmen /* TODO: Implement WINED3DTEXOPCAPS_PREMODULATE */ caps->MaxTextureBlendStages = MAX_TEXTURES; - caps->MaxSimultaneousTextures = min(gl_info->limits.fragment_samplers, MAX_TEXTURES); + caps->MaxSimultaneousTextures = min(gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL], MAX_TEXTURES); } static DWORD arbfp_get_emul_mask(const struct wined3d_gl_info *gl_info) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 1a56b81432b..23b10ba8634 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -3404,12 +3404,12 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) gl_info->limits.textures = 0; gl_info->limits.texture_coords = 0; for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i) + { gl_info->limits.uniform_blocks[i] = 0; - gl_info->limits.fragment_samplers = 1; - gl_info->limits.vertex_samplers = 0; - gl_info->limits.geometry_samplers = 0; - gl_info->limits.compute_samplers = 0; - gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers; + gl_info->limits.samplers[i] = 0; + } + gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = 1; + gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL]; gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers; gl_info->limits.vertex_attribs = 16; gl_info->limits.texture_buffer_offset_alignment = 1; @@ -3489,18 +3489,20 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER]) { gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &gl_max); - gl_info->limits.fragment_samplers = gl_max; + gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_max; } else { - gl_info->limits.fragment_samplers = gl_info->limits.textures; + gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = gl_info->limits.textures; } - TRACE("Max fragment samplers: %d.\n", gl_info->limits.fragment_samplers); + TRACE("Max fragment samplers: %d.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL]); if (gl_info->supported[ARB_VERTEX_SHADER]) { + unsigned int vertex_sampler_count; + gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &gl_max); - gl_info->limits.vertex_samplers = gl_max; + vertex_sampler_count = gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = gl_max; gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &gl_max); gl_info->limits.combined_samplers = gl_max; gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &gl_max); @@ -3520,23 +3522,24 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) * * So this is just a check to check that our assumption holds true. If not, write a warning * and reduce the number of vertex samplers or probably disable vertex texture fetch. */ - if (gl_info->limits.vertex_samplers && gl_info->limits.combined_samplers < 12 - && MAX_TEXTURES + gl_info->limits.vertex_samplers > gl_info->limits.combined_samplers) + if (vertex_sampler_count && gl_info->limits.combined_samplers < 12 + && MAX_TEXTURES + vertex_sampler_count > gl_info->limits.combined_samplers) { FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n", - gl_info->limits.vertex_samplers, gl_info->limits.combined_samplers); + vertex_sampler_count, gl_info->limits.combined_samplers); FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n"); if (gl_info->limits.combined_samplers > MAX_TEXTURES) - gl_info->limits.vertex_samplers = gl_info->limits.combined_samplers - MAX_TEXTURES; + vertex_sampler_count = gl_info->limits.combined_samplers - MAX_TEXTURES; else - gl_info->limits.vertex_samplers = 0; + vertex_sampler_count = 0; + gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX] = vertex_sampler_count; } } else { - gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers; + gl_info->limits.combined_samplers = gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL]; } - TRACE("Max vertex samplers: %u.\n", gl_info->limits.vertex_samplers); + TRACE("Max vertex samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX]); TRACE("Max combined samplers: %u.\n", gl_info->limits.combined_samplers); TRACE("Max vertex attributes: %u.\n", gl_info->limits.vertex_attribs); } @@ -3621,8 +3624,8 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) TRACE("Max geometry uniform blocks: %u (%d).\n", gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_GEOMETRY], gl_max); gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, &gl_max); - gl_info->limits.geometry_samplers = gl_max; - TRACE("Max geometry samplers: %u.\n", gl_info->limits.geometry_samplers); + gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY] = gl_max; + TRACE("Max geometry samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_GEOMETRY]); } if (gl_info->supported[ARB_FRAGMENT_SHADER]) { @@ -3648,8 +3651,8 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) TRACE("Max compute uniform blocks: %u (%d).\n", gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_COMPUTE], gl_max); gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, &gl_max); - gl_info->limits.compute_samplers = gl_max; - TRACE("Max compute samplers: %u.\n", gl_info->limits.compute_samplers); + gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE] = gl_max; + TRACE("Max compute samplers: %u.\n", gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE]); } if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) { @@ -3694,9 +3697,11 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) gl_info->limits.samples = gl_max; } - gl_info->limits.fragment_samplers = min(gl_info->limits.fragment_samplers, MAX_GL_FRAGMENT_SAMPLERS); - sampler_count = gl_info->limits.vertex_samplers + gl_info->limits.fragment_samplers - + gl_info->limits.geometry_samplers; + gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL] = + min(gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL], MAX_GL_FRAGMENT_SAMPLERS); + sampler_count = 0; + for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i) + sampler_count += gl_info->limits.samplers[i]; if (gl_info->supported[WINED3D_GL_VERSION_3_2] && gl_info->limits.combined_samplers < sampler_count) { /* The minimum value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS in OpenGL @@ -3704,16 +3709,16 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) * the minimum value is increased to 80. */ WARN("Graphics pipeline sampler count %u is greater than combined sampler count %u.\n", sampler_count, gl_info->limits.combined_samplers); - gl_info->limits.fragment_samplers = min(gl_info->limits.fragment_samplers, 16); - gl_info->limits.vertex_samplers = min(gl_info->limits.vertex_samplers, 16); - gl_info->limits.geometry_samplers = min(gl_info->limits.geometry_samplers, 16); + for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i) + gl_info->limits.samplers[i] = min(gl_info->limits.samplers[i], 16); } /* A majority of OpenGL implementations allow us to statically partition * the set of texture bindings into six separate sets. */ gl_info->limits.graphics_samplers = gl_info->limits.combined_samplers; - if (gl_info->limits.combined_samplers >= sampler_count + gl_info->limits.compute_samplers) - gl_info->limits.graphics_samplers -= gl_info->limits.compute_samplers; + sampler_count += gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE]; + if (gl_info->limits.combined_samplers >= sampler_count) + gl_info->limits.graphics_samplers -= gl_info->limits.samplers[WINED3D_SHADER_TYPE_COMPUTE]; } /* Context activation is done by the caller. */ diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index e363791c0cf..b24f512c46c 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -10476,7 +10476,7 @@ static void glsl_fragment_pipe_get_caps(const struct wined3d_gl_info *gl_info, s | WINED3DTEXOPCAPS_BUMPENVMAP | WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE; caps->MaxTextureBlendStages = MAX_TEXTURES; - caps->MaxSimultaneousTextures = min(gl_info->limits.fragment_samplers, MAX_TEXTURES); + caps->MaxSimultaneousTextures = min(gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL], MAX_TEXTURES); } static DWORD glsl_fragment_pipe_get_emul_mask(const struct wined3d_gl_info *gl_info) diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 51257f09519..8084cfb19d8 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3323,7 +3323,7 @@ static void tex_coordindex(struct wined3d_context *context, const struct wined3d return; } - if (mapped_stage >= min(gl_info->limits.fragment_samplers, MAX_FRAGMENT_SAMPLERS)) + if (mapped_stage >= min(gl_info->limits.samplers[WINED3D_SHADER_TYPE_PIXEL], MAX_FRAGMENT_SAMPLERS)) { WARN("stage %u not mapped to a valid texture unit (%u)\n", stage, mapped_stage); return; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index f22c314572a..3f9c0129538 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -2759,7 +2759,7 @@ static void query_internal_format(struct wined3d_adapter *adapter, } else { - if (!gl_info->limits.vertex_samplers) + if (!gl_info->limits.samplers[WINED3D_SHADER_TYPE_VERTEX]) format_clear_flag(format, WINED3DFMT_FLAG_VTF); if (!(gl_info->quirks & WINED3D_QUIRK_LIMITED_TEX_FILTERING)) @@ -5994,32 +5994,28 @@ void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *g void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits *gl_limits, enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) { + unsigned int i; + if (shader_type == WINED3D_SHADER_TYPE_COMPUTE) { if (gl_limits->combined_samplers == gl_limits->graphics_samplers) *base = 0; else *base = gl_limits->graphics_samplers - 1; - *count = gl_limits->compute_samplers; + *count = gl_limits->samplers[WINED3D_SHADER_TYPE_COMPUTE]; return; } *base = 0; - *count = gl_limits->fragment_samplers; - if (shader_type == WINED3D_SHADER_TYPE_PIXEL) - return; + for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i) + { + *count = gl_limits->samplers[i]; + if (i == shader_type) + return; + *base += *count; + } - *base += *count; - *count = gl_limits->vertex_samplers; - if (shader_type == WINED3D_SHADER_TYPE_VERTEX) - return; - - *base += *count; - *count = gl_limits->geometry_samplers; - if (shader_type == WINED3D_SHADER_TYPE_GEOMETRY) - return; - - *base += *count; + ERR("Unrecognized shader type %#x.\n", shader_type); *count = 0; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index cdcb1d16647..1a01106e94a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2275,10 +2275,7 @@ struct wined3d_gl_limits UINT textures; UINT texture_coords; unsigned int uniform_blocks[WINED3D_SHADER_TYPE_COUNT]; - unsigned int fragment_samplers; - unsigned int vertex_samplers; - unsigned int geometry_samplers; - unsigned int compute_samplers; + unsigned int samplers[WINED3D_SHADER_TYPE_COUNT]; unsigned int graphics_samplers; unsigned int combined_samplers; UINT general_combiners;