Commit c3e2909f authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Store the maximum number of "compat" varyings in struct wined3d_d3d_limits.

parent ca6cbb73
......@@ -3769,6 +3769,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
d3d_info->limits.vs_uniform_count = shader_caps.vs_uniform_count;
d3d_info->limits.ps_uniform_count = shader_caps.ps_uniform_count;
d3d_info->limits.varying_count = shader_caps.varying_count;
d3d_info->limits.max_compat_varying_count = shader_caps.max_compat_varying_count;
d3d_info->shader_double_precision = !!(shader_caps.wined3d_caps & WINED3D_SHADER_CAP_DOUBLE_PRECISION);
d3d_info->shader_output_interpolation = !!(shader_caps.wined3d_caps & WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION);
......
......@@ -4957,6 +4957,7 @@ static void shader_arb_get_caps(const struct wined3d_adapter *adapter, struct sh
}
caps->varying_count = 0;
caps->max_compat_varying_count = 0;
caps->wined3d_caps = WINED3D_SHADER_CAP_SRGB_WRITE;
if (use_nv_clip(gl_info))
caps->wined3d_caps |= WINED3D_SHADER_CAP_VS_CLIPPING;
......
......@@ -420,6 +420,15 @@ static void shader_glsl_add_version_declaration(struct wined3d_string_buffer *bu
shader_addline(buffer, "#version %u\n", shader_glsl_get_version(gl_info));
}
unsigned int shader_glsl_max_compat_varyings(const struct wined3d_gl_info *gl_info)
{
/* On core profile we have to also count diffuse and specular colours and
* the fog coordinate. */
if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
return WINED3D_MAX_TEXTURES * 4;
return (WINED3D_MAX_TEXTURES + 2) * 4 + 1;
}
static void shader_glsl_append_imm_vec(struct wined3d_string_buffer *buffer,
const float *values, unsigned int size, const struct wined3d_gl_info *gl_info)
{
......@@ -7146,7 +7155,7 @@ static GLuint shader_glsl_generate_vs3_rasterizer_input_setup(struct shader_glsl
if (texcoords_written_mask[i] != WINED3DSP_WRITEMASK_ALL)
{
if (gl_info->limits.glsl_varyings < wined3d_max_compat_varyings(gl_info)
if (gl_info->limits.glsl_varyings < shader_glsl_max_compat_varyings(gl_info)
&& !texcoords_written_mask[i])
continue;
......@@ -9057,7 +9066,7 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
if (settings->texcoords & (1u << i))
shader_addline(buffer, "ffp_varying_texcoord[%u] = ffp_texture_matrix[%u] * ffp_attrib_texcoord%u;\n",
i, i, i);
else if (gl_info->limits.glsl_varyings >= wined3d_max_compat_varyings(gl_info))
else if (gl_info->limits.glsl_varyings >= shader_glsl_max_compat_varyings(gl_info))
shader_addline(buffer, "ffp_varying_texcoord[%u] = vec4(0.0);\n", i);
else
output_legacy_texcoord = FALSE;
......@@ -11093,6 +11102,7 @@ static void shader_glsl_get_caps(const struct wined3d_adapter *adapter, struct s
caps->vs_uniform_count = min(WINED3D_MAX_VS_CONSTS_F, gl_info->limits.glsl_vs_float_constants);
caps->ps_uniform_count = min(WINED3D_MAX_PS_CONSTS_F, gl_info->limits.glsl_ps_float_constants);
caps->varying_count = gl_info->limits.glsl_varyings;
caps->max_compat_varying_count = shader_glsl_max_compat_varyings(gl_info);
/* FIXME: The following line is card dependent. -8.0 to 8.0 is the
* Direct3D minimum requirement.
......@@ -11542,7 +11552,7 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context,
* Likewise, we have to invalidate the shader when using per-vertex
* colours and diffuse/specular attribute presence changes, or when
* normal presence changes. */
if (gl_info->limits.glsl_varyings < wined3d_max_compat_varyings(gl_info)
if (gl_info->limits.glsl_varyings < shader_glsl_max_compat_varyings(gl_info)
|| (state->render_states[WINED3D_RS_COLORVERTEX]
&& (diffuse != context->last_was_diffuse || specular != context->last_was_specular))
|| normal != context->last_was_normal)
......@@ -12054,7 +12064,7 @@ static void glsl_fragment_pipe_vdecl(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id)
{
/* Because of settings->texcoords_initialized and args->texcoords_initialized. */
if (context->gl_info->limits.glsl_varyings < wined3d_max_compat_varyings(context->gl_info))
if (context->gl_info->limits.glsl_varyings < shader_glsl_max_compat_varyings(context->gl_info))
context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL;
if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_FOGENABLE)))
......@@ -12065,7 +12075,7 @@ static void glsl_fragment_pipe_vs(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id)
{
/* Because of settings->texcoords_initialized and args->texcoords_initialized. */
if (context->gl_info->limits.glsl_varyings < wined3d_max_compat_varyings(context->gl_info))
if (context->gl_info->limits.glsl_varyings < shader_glsl_max_compat_varyings(context->gl_info))
context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL;
}
......
......@@ -4114,7 +4114,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
}
}
if (context->d3d_info->limits.varying_count < wined3d_max_compat_varyings(context->gl_info))
if (d3d_info->limits.varying_count < d3d_info->limits.max_compat_varying_count)
{
const struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
......
......@@ -5911,13 +5911,6 @@ void multiply_matrix(struct wined3d_matrix *dst, const struct wined3d_matrix *sr
*dst = tmp;
}
unsigned int wined3d_max_compat_varyings(const struct wined3d_gl_info *gl_info)
{
/* On core profile we have to also count diffuse and specular colors and the
* fog coordinate. */
return gl_info->supported[WINED3D_GL_LEGACY_CONTEXT] ? WINED3D_MAX_TEXTURES * 4 : (WINED3D_MAX_TEXTURES + 2) * 4 + 1;
}
void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state,
struct ffp_frag_settings *settings, BOOL ignore_textype)
{
......@@ -5957,7 +5950,6 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d
unsigned int i;
DWORD ttff;
DWORD cop, aop, carg0, carg1, carg2, aarg0, aarg1, aarg2;
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
settings->padding = 0;
......@@ -6196,8 +6188,7 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d
* Reading uninitialized varyings on core profile contexts results in an
* error while with builtin varyings on legacy contexts you get undefined
* behavior. */
if (d3d_info->limits.varying_count
&& d3d_info->limits.varying_count < wined3d_max_compat_varyings(gl_info))
if (d3d_info->limits.varying_count && d3d_info->limits.varying_count < d3d_info->limits.max_compat_varying_count)
{
settings->texcoords_initialized = 0;
for (i = 0; i < WINED3D_MAX_TEXTURES; ++i)
......@@ -6378,7 +6369,6 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
{
enum wined3d_material_color_source diffuse_source, emissive_source, ambient_source, specular_source;
const struct wined3d_stream_info *si = &context->stream_info;
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
unsigned int coord_idx, i;
......@@ -6403,7 +6393,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
settings->texcoords |= 1u << i;
settings->texgen[i] = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
}
if (d3d_info->limits.varying_count >= wined3d_max_compat_varyings(gl_info))
if (d3d_info->limits.varying_count >= d3d_info->limits.max_compat_varying_count)
settings->texcoords = (1u << WINED3D_MAX_TEXTURES) - 1;
if (d3d_info->emulated_flatshading)
......@@ -6452,7 +6442,7 @@ void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
settings->texcoords |= 1u << i;
settings->texgen[i] = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
}
if (d3d_info->limits.varying_count >= wined3d_max_compat_varyings(gl_info))
if (d3d_info->limits.varying_count >= d3d_info->limits.max_compat_varying_count)
settings->texcoords = (1u << WINED3D_MAX_TEXTURES) - 1;
for (i = 0; i < WINED3D_MAX_ACTIVE_LIGHTS; ++i)
......
......@@ -175,6 +175,7 @@ struct wined3d_d3d_limits
unsigned int max_rt_count;
unsigned int max_clip_distances;
unsigned int max_compat_varying_count;
unsigned int texture_size;
float pointsize_max;
};
......@@ -1317,10 +1318,11 @@ struct shader_caps
unsigned int ps_version;
unsigned int cs_version;
DWORD vs_uniform_count;
DWORD ps_uniform_count;
unsigned int vs_uniform_count;
unsigned int ps_uniform_count;
float ps_1x_max_value;
DWORD varying_count;
unsigned int varying_count;
unsigned int max_compat_varying_count;
DWORD wined3d_caps;
};
......@@ -2930,7 +2932,6 @@ int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb
extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
unsigned int wined3d_max_compat_varyings(const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state,
struct ffp_frag_settings *settings, BOOL ignore_textype) DECLSPEC_HIDDEN;
const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment