wined3d: Store GL sampler limits as array.

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-15 12:00:07 +01:00 committed by Alexandre Julliard
parent 3f10995ecb
commit 09fa9fbcf1
6 changed files with 49 additions and 51 deletions

View File

@ -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)

View File

@ -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. */

View File

@ -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)

View File

@ -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;

View File

@ -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)
for (i = 0; i < WINED3D_SHADER_TYPE_GRAPHICS_COUNT; ++i)
{
*count = gl_limits->samplers[i];
if (i == shader_type)
return;
*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;
}

View File

@ -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;