st/mesa: don't serialize all streamout state if there are no SO outputs
authorMarek Olšák <marek.olsak@amd.com>
Mon, 25 Nov 2019 22:01:42 +0000 (17:01 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 26 Nov 2019 20:14:10 +0000 (15:14 -0500)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/state_tracker/st_shader_cache.c

index b777e8dcbbafb3e2e8d008f0f922d4d3df33b4a4..6543a532630b3ce1e61fdb140e4c1fd3b33d67d0 100644 (file)
@@ -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