wined3d: Disable transform feedback when there are no varyings to record.

In order to avoid GL errors when glBeginTransformFeedback() is called.
This is required only because we do not fully support stream output
component ranges.

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 2018-04-26 14:53:24 +02:00 committed by Alexandre Julliard
parent 0d90a7ba89
commit f6160d2ae8
1 changed files with 13 additions and 3 deletions

View File

@ -804,11 +804,12 @@ static void append_transform_feedback_skip_components(const char **varyings,
} }
} }
static void shader_glsl_generate_transform_feedback_varyings(const struct wined3d_stream_output_desc *so_desc, static BOOL shader_glsl_generate_transform_feedback_varyings(const struct wined3d_stream_output_desc *so_desc,
struct wined3d_string_buffer *buffer, const char **varyings, unsigned int *varying_count, struct wined3d_string_buffer *buffer, const char **varyings, unsigned int *varying_count,
char *strings, unsigned int *strings_length, GLenum buffer_mode) char *strings, unsigned int *strings_length, GLenum buffer_mode)
{ {
unsigned int i, buffer_idx, count, length, highest_output_slot, stride; unsigned int i, buffer_idx, count, length, highest_output_slot, stride;
BOOL have_varyings_to_record = FALSE;
count = length = 0; count = length = 0;
highest_output_slot = 0; highest_output_slot = 0;
@ -858,6 +859,8 @@ static void shader_glsl_generate_transform_feedback_varyings(const struct wined3
string_buffer_sprintf(buffer, "shader_in_out.reg%u", e->register_idx); string_buffer_sprintf(buffer, "shader_in_out.reg%u", e->register_idx);
append_transform_feedback_varying(varyings, &count, &strings, &length, buffer); append_transform_feedback_varying(varyings, &count, &strings, &length, buffer);
} }
have_varyings_to_record = TRUE;
} }
if (buffer_idx < so_desc->buffer_stride_count if (buffer_idx < so_desc->buffer_stride_count
@ -882,10 +885,12 @@ static void shader_glsl_generate_transform_feedback_varyings(const struct wined3
*varying_count = count; *varying_count = count;
if (strings_length) if (strings_length)
*strings_length = length; *strings_length = length;
return have_varyings_to_record;
} }
static void shader_glsl_init_transform_feedback(const struct wined3d_context *context, static void shader_glsl_init_transform_feedback(const struct wined3d_context *context,
struct shader_glsl_priv *priv, GLuint program_id, const struct wined3d_shader *shader) struct shader_glsl_priv *priv, GLuint program_id, struct wined3d_shader *shader)
{ {
const struct wined3d_stream_output_desc *so_desc = &shader->u.gs.so_desc; const struct wined3d_stream_output_desc *so_desc = &shader->u.gs.so_desc;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
@ -941,7 +946,12 @@ static void shader_glsl_init_transform_feedback(const struct wined3d_context *co
buffer = string_buffer_get(&priv->string_buffers); buffer = string_buffer_get(&priv->string_buffers);
shader_glsl_generate_transform_feedback_varyings(so_desc, buffer, NULL, &count, NULL, &length, mode); if (!shader_glsl_generate_transform_feedback_varyings(so_desc, buffer, NULL, &count, NULL, &length, mode))
{
FIXME("No varyings to record, disabling transform feedback.\n");
shader->u.gs.so_desc.element_count = 0;
return;
}
if (!(varyings = heap_calloc(count, sizeof(*varyings)))) if (!(varyings = heap_calloc(count, sizeof(*varyings))))
{ {