summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/shader_cache.cpp
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-10-11 09:44:33 -0700
committerJason Ekstrand <[email protected]>2017-10-12 21:47:06 -0700
commit49bb9f785af8349f3245bc223cb7e0e40b9fa243 (patch)
treec4d2ef614b9de4a62d480d0493a1cd857e15ff4e /src/compiler/glsl/shader_cache.cpp
parent0e3bd56c6ea783dbc93fce71cec98ab859782a81 (diff)
compiler/blob: Switch to init/finish instead of create/destroy
There's no reason why that tiny bit of memory needs to be on the heap. We always put blob_reader on the stack, so why not do the same with the writable blob. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/compiler/glsl/shader_cache.cpp')
-rw-r--r--src/compiler/glsl/shader_cache.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index c9109aa222b..f3c7a57699d 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1356,52 +1356,53 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
if (memcmp(prog->data->sha1, zero, sizeof(prog->data->sha1)) == 0)
return;
- struct blob *metadata = blob_create();
+ struct blob metadata;
+ blob_init(&metadata);
- write_uniforms(metadata, prog);
+ write_uniforms(&metadata, prog);
- write_hash_tables(metadata, prog);
+ write_hash_tables(&metadata, prog);
- blob_write_uint32(metadata, prog->data->Version);
- blob_write_uint32(metadata, prog->data->linked_stages);
+ blob_write_uint32(&metadata, prog->data->Version);
+ blob_write_uint32(&metadata, prog->data->linked_stages);
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_linked_shader *sh = prog->_LinkedShaders[i];
if (sh) {
- write_shader_metadata(metadata, sh);
+ write_shader_metadata(&metadata, sh);
if (sh->Program->info.name)
- blob_write_string(metadata, sh->Program->info.name);
+ blob_write_string(&metadata, sh->Program->info.name);
else
- blob_write_string(metadata, "");
+ blob_write_string(&metadata, "");
if (sh->Program->info.label)
- blob_write_string(metadata, sh->Program->info.label);
+ blob_write_string(&metadata, sh->Program->info.label);
else
- blob_write_string(metadata, "");
+ blob_write_string(&metadata, "");
size_t s_info_size, s_info_ptrs;
get_shader_info_and_pointer_sizes(&s_info_size, &s_info_ptrs,
&sh->Program->info);
/* Store shader info */
- blob_write_bytes(metadata,
+ blob_write_bytes(&metadata,
((char *) &sh->Program->info) + s_info_ptrs,
s_info_size - s_info_ptrs);
}
}
- write_xfb(metadata, prog);
+ write_xfb(&metadata, prog);
- write_uniform_remap_tables(metadata, prog);
+ write_uniform_remap_tables(&metadata, prog);
- write_atomic_buffers(metadata, prog);
+ write_atomic_buffers(&metadata, prog);
- write_buffer_blocks(metadata, prog);
+ write_buffer_blocks(&metadata, prog);
- write_subroutines(metadata, prog);
+ write_subroutines(&metadata, prog);
- write_program_resource_list(metadata, prog);
+ write_program_resource_list(&metadata, prog);
struct cache_item_metadata cache_item_metadata;
cache_item_metadata.type = CACHE_ITEM_TYPE_GLSL;
@@ -1423,7 +1424,7 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
}
}
- disk_cache_put(cache, prog->data->sha1, metadata->data, metadata->size,
+ disk_cache_put(cache, prog->data->sha1, metadata.data, metadata.size,
&cache_item_metadata);
if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
@@ -1433,7 +1434,7 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
fail:
free(cache_item_metadata.keys);
- blob_destroy(metadata);
+ blob_finish(&metadata);
}
bool