Esempio n. 1
0
bool vogl_vao_state::deserialize(const json_node &node, const vogl_blob_manager &blob_manager)
{
    VOGL_FUNC_TRACER

    VOGL_NOTE_UNUSED(blob_manager);

    clear();

    m_snapshot_handle = node.value_as_uint32("handle");
    m_has_been_bound = node.value_as_bool("has_been_bound", true);
    m_element_array_binding = node.value_as_uint32("element_array_binding");

    const json_node *pVertex_attribs_array = node.find_child_array("vertex_attribs");
    if (!pVertex_attribs_array)
        return false;

    m_vertex_attribs.resize(pVertex_attribs_array->size());
    for (uint32_t i = 0; i < pVertex_attribs_array->size(); i++)
    {
        vogl_vertex_attrib_desc &desc = m_vertex_attribs[i];

        const json_node *pAttribs_obj = pVertex_attribs_array->get_value_as_object(i);
        if (!pAttribs_obj)
            return false;

        desc.m_pointer = static_cast<vogl_trace_ptr_value>(pAttribs_obj->value_as_uint64("pointer"));

        // Fallback for old traces
        if ((!i) && (pAttribs_obj->has_key("element_array_binding")))
            m_element_array_binding = pAttribs_obj->value_as_uint32("element_array_binding");

        desc.m_array_binding = pAttribs_obj->value_as_uint32("array_binding");
        desc.m_size = pAttribs_obj->value_as_int("size");
        desc.m_type = vogl_get_json_value_as_enum(*pAttribs_obj, "type");
        desc.m_stride = pAttribs_obj->value_as_int("stride");
        desc.m_integer = pAttribs_obj->value_as_bool("integer");
        desc.m_divisor = pAttribs_obj->value_as_uint32("divisor");
        desc.m_enabled = pAttribs_obj->value_as_bool("enabled");
        desc.m_normalized = pAttribs_obj->value_as_bool("normalized");
    }

    m_is_valid = true;

    return true;
}
Esempio n. 2
0
bool vogl_display_list::deserialize(const json_node &node, const vogl_blob_manager &blob_manager, const vogl_ctypes *pCtypes)
{
    VOGL_FUNC_TRACER

    clear();

    m_handle = node.value_as_uint32("handle");
    m_valid = node.value_as_bool("valid", true);
    m_generating = node.value_as_bool("generating");
    m_xfont = node.value_as_bool("xfont");

    if (m_xfont)
    {
        m_xfont_glyph = node.value_as_int("xfont_glyph");
        m_xfont_name = node.value_as_string("xfont_name");
    }

    const json_node *pPackets_array = node.find_child_array("packets");
    if (pPackets_array)
    {
        if (!pPackets_array->are_all_children_objects())
        {
            clear();
            return false;
        }

        vogl_trace_packet packet(pCtypes);

        m_packets.resize(pPackets_array->size());
        for (uint i = 0; i < pPackets_array->size(); i++)
        {
            if (!packet.json_deserialize(*pPackets_array->get_child(i), "<display_list>", &blob_manager))
            {
                clear();
                return false;
            }

            if (!packet.serialize(m_packets.get_packet_buf(i)))
            {
                clear();
                return false;
            }
        }
    }

    return true;
}