コード例 #1
0
/**
 * Serializes gl_shader structure, writes shader header
 * information and exec_list of instructions
 */
extern "C" char *
mesa_shader_serialize(struct gl_context *ctx, struct gl_shader *shader, size_t *size, bool shader_only)
{
   assert(ctx);

   if (!supported_by_shader_cache(shader, true /* is_write */))
      return NULL;

   *size = 0;

   memory_writer blob;

   // write the size early for quick completeness checking
   assert(blob.position() == 0);
   uint32_t shader_sentinel = 0;
   blob.write_uint32_t(shader_sentinel);

   if (shader_only) {
      /* If only serializing shader, we must populate our cache identifiers */
      blob.write(&cache_validation_data, sizeof(cache_validation_data));

      blob.write_string(mesa_get_shader_cache_magic());
      blob.write_string((const char *)ctx->Driver.GetString(ctx, GL_VENDOR));
      blob.write_string((const char *)ctx->Driver.GetString(ctx, GL_RENDERER));
   }

   int32_t start_pos = blob.position();
   uint32_t shader_data_len = 0;
   uint32_t shader_type = shader->Type;

   blob.write_uint32_t(shader_data_len);
   blob.write_uint32_t(shader_type);

   blob.write(shader, sizeof(struct gl_shader));

   /* dump all shader instructions */
   serialize_list(shader->ir, blob);

   shader_data_len = blob.position() -
      start_pos - sizeof(shader_data_len);
   blob.overwrite(&shader_data_len, sizeof(shader_data_len), start_pos);

   // write shader length to sentinel for now
   shader_sentinel = shader_data_len;
   blob.overwrite(&shader_sentinel, sizeof(shader_sentinel), 0);

   *size = blob.position();

   return blob.release_memory(size);
}
コード例 #2
0
ファイル: dhcp.cpp プロジェクト: simple555a/libtins
void DHCP::domain_name_servers(const vector<ipaddress_type>& dns) {
    serialization_type buffer = serialize_list(dns);
    add_option(option(DOMAIN_NAME_SERVERS, buffer.begin(), buffer.end()));
}
コード例 #3
0
ファイル: dhcp.cpp プロジェクト: simple555a/libtins
void DHCP::routers(const vector<ipaddress_type>& routers) {
    serialization_type buffer = serialize_list(routers);
    add_option(option(ROUTERS, buffer.begin(), buffer.end()));
}
コード例 #4
0
ファイル: listish.hpp プロジェクト: Mr-Kumar-Abhishek/qboard
 inline bool operator()( NodeType & dest, const SerType & src ) const
 {
         return serialize_list( dest, src );
 }