From 6cf011fcc8131c32ccccba2cf8dcb6cc12699e5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 25 Nov 2019 17:01:42 -0500 Subject: [PATCH] st/mesa: don't serialize all streamout state if there are no SO outputs Reviewed-by: Timothy Arceri --- src/mesa/state_tracker/st_shader_cache.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c index b777e8dcbba..6543a532630 100644 --- a/src/mesa/state_tracker/st_shader_cache.c +++ b/src/mesa/state_tracker/st_shader_cache.c @@ -44,8 +44,13 @@ static void write_stream_out_to_cache(struct blob *blob, struct pipe_shader_state *state) { - blob_write_bytes(blob, &state->stream_output, - sizeof(state->stream_output)); + blob_write_uint32(blob, state->stream_output.num_outputs); + if (state->stream_output.num_outputs) { + blob_write_bytes(blob, &state->stream_output.stride, + sizeof(state->stream_output.stride)); + blob_write_bytes(blob, &state->stream_output.output, + sizeof(state->stream_output.output)); + } } static void @@ -139,8 +144,14 @@ static void read_stream_out_from_cache(struct blob_reader *blob_reader, struct pipe_shader_state *state) { - blob_copy_bytes(blob_reader, (uint8_t *) &state->stream_output, - sizeof(state->stream_output)); + memset(&state->stream_output, 0, sizeof(state->stream_output)); + state->stream_output.num_outputs = blob_read_uint32(blob_reader); + if (state->stream_output.num_outputs) { + blob_copy_bytes(blob_reader, &state->stream_output.stride, + sizeof(state->stream_output.stride)); + blob_copy_bytes(blob_reader, &state->stream_output.output, + sizeof(state->stream_output.output)); + } } static void -- 2.30.2