コード例 #1
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML that contains the extents of a rectangle
///
/// \param rRect reference to a RECT structure to encode in XML
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XMLRect(WinRect& rRect)
{
    gtASCIIString out;
    out += XML("left", rRect.left);
    out += XML("top", rRect.top);
    out += XML("right", rRect.right);
    out += XML("bottom", rRect.bottom);

    return XML("rect", out.asCharArray());
}
コード例 #2
0
ファイル: ext_xml.cpp プロジェクト: MarkTseng/hiphop-php
static Variant php_xml_parser_create_impl(CStrRef encoding_param,
                                          CStrRef ns_param, int ns_support) {
  XmlParser *parser;
  int auto_detect = 0;
  XML_Char *encoding;

  if (!encoding_param.isNull()) {
    /* The supported encoding types are hardcoded here because
     * we are limited to the encodings supported by expat/xmltok.
     */
    if (encoding_param.size() == 0) {
      encoding = XML(default_encoding);
      auto_detect = 1;
    } else if (strcasecmp(encoding_param.data(), "ISO-8859-1") == 0) {
      encoding = (XML_Char*)"ISO-8859-1";
    } else if (strcasecmp(encoding_param.data(), "UTF-8") == 0) {
      encoding = (XML_Char*)"UTF-8";
    } else if (strcasecmp(encoding_param.data(), "US-ASCII") == 0) {
      encoding = (XML_Char*)"US-ASCII";
    } else {
      raise_warning("unsupported source encoding \"%s\"",
                    encoding_param.c_str());
      return false;
    }
  } else {
    encoding = XML(default_encoding);
  }

  String separator;
  if (ns_support && ns_param.empty()){
    separator = ":";
  } else {
    separator = ns_param;
  }

  parser = NEWOBJ(XmlParser)();
  parser->parser = XML_ParserCreate_MM
    ((auto_detect ? NULL : encoding), &php_xml_mem_hdlrs,
     !separator.empty() ? (const XML_Char*)separator.data() : NULL);

  parser->target_encoding = encoding;
  parser->case_folding = 1;
  setNull(parser->object);
  parser->isparsing = 0;

  XML_SetUserData(parser->parser, parser);

  return Object(parser);
}
コード例 #3
0
ファイル: ext_xml.cpp プロジェクト: simonwelsh/hhvm
static Variant php_xml_parser_create_impl(const String& encoding_param,
                                          const String& ns_param,
                                          int ns_support) {
  int auto_detect = 0;
  XML_Char *encoding;

  if (!encoding_param.isNull()) {
    /* The supported encoding types are hardcoded here because
     * we are limited to the encodings supported by expat/xmltok.
     */
    if (encoding_param.size() == 0) {
      encoding = XML(default_encoding);
      auto_detect = 1;
    } else if (strcasecmp(encoding_param.data(), "ISO-8859-1") == 0) {
      encoding = (XML_Char*)"ISO-8859-1";
    } else if (strcasecmp(encoding_param.data(), "UTF-8") == 0) {
      encoding = (XML_Char*)"UTF-8";
    } else if (strcasecmp(encoding_param.data(), "US-ASCII") == 0) {
      encoding = (XML_Char*)"US-ASCII";
    } else {
      raise_warning("unsupported source encoding \"%s\"",
                    encoding_param.c_str());
      return false;
    }
  } else {
    encoding = XML(default_encoding);
  }

  String separator;
  if (ns_support && ns_param.empty()) {
    separator = ":";
  } else {
    separator = ns_param;
  }

  auto parser = req::make<XmlParser>();
  parser->parser = XML_ParserCreate_MM
    ((auto_detect ? NULL : encoding), &php_xml_mem_hdlrs,
     !separator.empty() ? (const XML_Char*)separator.data() : NULL);

  parser->target_encoding = encoding;
  parser->case_folding = 1;
  parser->object.asTypedValue()->m_type = KindOfNull;
  parser->isparsing = 0;

  XML_SetUserData(parser->parser, getParserToken(parser));

  return Variant(std::move(parser));
}
コード例 #4
0
ファイル: XML.cpp プロジェクト: BigEvilCorporation/ion-engine
		XML* XML::AddChild(const std::string& name)
		{
			std::string nameLower = string::ToLower(name);
			u32 hash = ion::Hash(nameLower.c_str());
			m_children.push_back(std::make_pair(hash, XML()));
			return &m_children.back().second;
		}
コード例 #5
0
ファイル: mltcontroller.cpp プロジェクト: sagesong/shotcut
void Controller::restart()
{
    if (!m_consumer) return;
    if (m_producer && m_producer->is_valid() && m_producer->get_speed() != 0) {
        // Update the real_time property if not paused.
        m_consumer->set("real_time", realTime());
    }
    const char* position = m_consumer->frames_to_time(m_consumer->position());
    double speed = m_producer->get_speed();
    QString xml = XML();
    stop();
    if (!setProducer(new Mlt::Producer(profile(), "xml-string", xml.toUtf8().constData()))) {
#ifdef Q_OS_WIN
        play(speed);
        if (m_producer && m_producer->is_valid())
            m_producer->seek(position);
        // Windows needs an extra kick here when not paused!
        if (speed != 0.0)
            play(speed);
#else
        if (m_producer && m_producer->is_valid())
            m_producer->seek(position);
        play(speed);
#endif
    }
}
コード例 #6
0
ファイル: wshelpers.hpp プロジェクト: lrenn/HPCC-Platform
inline StringBuffer& operator<<(StringBuffer& buf, const JScript& j)
{
    StringBuffer script;
    appendStringAsCPP(script,strlen(j.s),j.s,false);
    buf<<XML(script.str());
    return buf;
}
コード例 #7
0
ファイル: level.cpp プロジェクト: christianboutin/Shmoulette
PyObject* Level::addXmlBranch(PyObject *self, PyObject* args){
	char* objName;
	PyArg_ParseTuple(args, "s", &objName);
	string s = objName;
	s = "<level>"+s+"</level>";
	getSingleton()->getCurrentSegment()->pushObjects(&XML(s));
	Py_RETURN_NONE;

	//return PyFloat_FromDouble(getSingleton()->mCurrentSegment->getTimeDelta());
}
コード例 #8
0
//--------------------------------------------------------------------------
/// Responds to active requests
//--------------------------------------------------------------------------
void FrameDebugger::EndFrame()
{
    if (m_drawCallList.IsActive())
    {
        // In GL m_LastDrawCall is a pointer to an auto variable. The Auto variable has gone out of scope when m_LastDrawCall is used and causes a crash in GL.
        // Commenting this out until a fix is available.
        // m_drawCallList.Send( m_LastDrawCall->GetHashCategories() + m_drawCallList);
        m_drawCallList.Send(m_drawCallList.asCharArray());
    }

    if (m_Stats.IsActive())
    {
        gtASCIIString out;
        out = XML("TotalDrawCallCount", m_ulDrawCallCounter);
        out += XML("BreakPoint", m_dwBreakPoint);

        m_Stats.Send(out.asCharArray());
    }
}
コード例 #9
0
 // load by enumeration
 bool loadByEnum( Service_Enumeration enm, serviceMap sMap )
 {
    serviceMap :: iterator itx = sMap.begin();
    while( itx != sMap.end() )
    {
      // DBG       cout << "<br> PROG ENUM:" << itx->second.prog_enum << "<br>" << endl;
      if( atol(itx->second.prog_enum.c_str()) == enm )
      {
        // DBG         cout << "<br> PARAMS PASSED:" << itx->second.xml_params << "<br>" << endl;
        XML( itx->second.xml_params );
        break;
      }
      ++itx;
    }
 }
コード例 #10
0
/// Generates an XML command tree for each of the injected processes.
/// \return the XML command tree
std::string ProcessTracker::GetCommandTree()
{
    std::string strXML;

    for (ProcessInfoList::iterator iter = this->m_injectedProcessList.begin();
         iter != this->m_injectedProcessList.end();
         ++iter)
    {
        gtASCIIString strWrapperXML;

        // we should only include the processes that are active
        bool include = false;

        // check the active wrappers to see if one of them is for this process
        for (WrapperMap::iterator wrapperIter = g_activeWrappersMap.begin();
             wrapperIter != g_activeWrappersMap.end();
             ++wrapperIter)
        {
            // parse out the process ID
            unsigned long pid = 0;
            sscanf_s(wrapperIter->first.c_str(), "%lu/", &pid);

            // if this process ID matches, then we want to include this information in the commandTreeXML
            if (pid == iter->th32ProcessID)
            {
                include = true;
                gtASCIIString tmpString = "id='";
                tmpString += wrapperIter->second.strPluginShortDesc;
                tmpString += "'";
                strWrapperXML += XMLAttrib("Plugin", tmpString.asCharArray());
            }
        }

        // only include if there was an active wrapper was found in this process
        if (include)
        {
            gtASCIIString strAttrib;
            strAttrib.appendFormattedString("id='%lu' name='%s'", iter->th32ProcessID, iter->szExeFile);

            gtASCIIString tmpString = XMLAttrib("Kill_Process", "url='Kill' name='Kill Process'");
            tmpString += XML("PID", iter->th32ProcessID);
            tmpString += strWrapperXML;
            strXML += XMLAttrib("Process", strAttrib.asCharArray(), tmpString.asCharArray()).asCharArray();
        }
    }

    return strXML;
}
コード例 #11
0
ファイル: nuiSVGView.cpp プロジェクト: jbl2024/nui3
bool nuiSVGView::Load (nglIStream& rSource)
{
  bool result = false;
  if (mpShape)
    delete mpShape;

  nuiXML XML("SVG File");
  mpShape = new nuiSVGShape();
  InvalidateLayout();
  nglTime t;
  if (!XML.Load(rSource))
    return false;
  nglTime xmlt;
  result = mpShape->Load(&XML);
  nglTime loadt;

  NGL_OUT(_T("Xml load time: %f\nSvg load time: %f\n"), (double)xmlt - (double)t, (double)loadt - (double)xmlt);

  return result;
}
コード例 #12
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML with a node and a hex value
///
/// \param strNode node name
/// \param ptr string containing the URL
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XMLHexPtr(const char* strNode, const void* ptr)
{
#ifdef _WIN32
    const char* text = "0x%p";
#else
    const char* text = "%p";

    // special case for NULL pointer; don't print (nil). Client expects
    // 32 or 64 bit hex value returned
    if (ptr == NULL)
    {
#ifdef X64
        text = "0x000000000000000%d";
#else
        text = "0x0000000%d";
#endif
    }

#endif
    return XML(strNode, FormatText(text, ptr).asCharArray());
}
コード例 #13
0
void Controller::restart()
{
    if (!m_consumer) return;
    if (m_producer && m_producer->is_valid() && m_producer->get_speed() != 0) {
        // Update the real_time property if not paused.
        m_consumer->set("real_time", realTime());
    }
    if (m_producer && m_producer->is_valid() && Settings.playerGPU()) {
        const char* position = m_consumer->frames_to_time(m_consumer->position());
        double speed = m_producer->get_speed();
        QString xml = XML();
        close();
        if (!setProducer(new Mlt::Producer(profile(), "xml-string", xml.toUtf8().constData()))) {
            m_producer->seek(position);
            m_producer->set_speed(speed);
            m_consumer->start();
        }
    } else {
        m_consumer->stop();
        m_consumer->start();
    }
}
//--------------------------------------------------------------------------
/// Write a chunk of XML that will ultimately be written to disk as a metadata file.
/// \param outMetadataXML A generated chunk of XML based on the contents of this instance.
//--------------------------------------------------------------------------
void TraceMetadata::WriteToXML(gtASCIIString& outMetadataXML)
{
    gtASCIIString metadataXML;

    metadataXML += XML("Location",          FormatText("%s", mMetadataFilepath.c_str()).asCharArray());
    metadataXML += XML("FrameNumber",       FormatText("%u", mFrameIndex).asCharArray());
    metadataXML += XML("Architecture",      FormatText("%u", mArchitecture).asCharArray());

    gtASCIIString contentsXML;

    contentsXML += XML("LinkedTrace",       FormatText("%s", mPathToTraceFile.c_str()).asCharArray());
    contentsXML += XML("FrameBufferImage",  FormatText("%s", mPathToFrameBufferImage.c_str()).asCharArray());

    // Pull this section of the contents out of the internal FrameInfo structure.
    mFrameInfo.WriteToXML(contentsXML);

    // Surround the generated contents string with a parent element
    metadataXML += XML("Contents", contentsXML.asCharArray());

    // Now surround the entire chunk with an "XML" block so there's a single root node.
    outMetadataXML = XML("XML", metadataXML.asCharArray());
}
コード例 #15
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
gtASCIIString GetDrawCallXML(unsigned long ulIndex, const char* strDrawCallXML)
{
    gtASCIIString str = XML("index", FormatText("%lu", ulIndex).asCharArray());
    str += strDrawCallXML;
    return XML("drawcall", str.asCharArray());
}
コード例 #16
0
//--------------------------------------------------------------
/// Generates XML that describes the injected processes and which
/// plugins were injected.
/// \return string containing the XML
//--------------------------------------------------------------
gtASCIIString ProcessTracker::GetProcessesXML()
{
    std::unordered_map< DWORD, gtASCIIString > procXMLMap;

    this->UpdateListOfInjectedProcesses();

    ProcessInfoList injectedProcesses = this->GetListOfInjectedProcesses();

    WrapperMap wrappers = GetWrapperMap();

    // the strPlatform is named this way to match options in the client.
#ifdef X64
    gtASCIIString strPlatform = "Win64";
#else
    gtASCIIString strPlatform = "Win32";
#endif

#ifndef CODEXL_GRAPHICS

    if (injectedProcesses.empty() == true)
    {
        LogConsole(logERROR, "There are no processes running which have been injected with the GPU PerfStudio server plugin\n");
        LogConsole(logERROR, "Please ensure that the server has the same bitness as the target application\n");
        LogConsole(logERROR, "For example, use the 64-bit GPU PerfStudio server with a 64-bit application\n");
    }

#endif

    for (ProcessInfoList::iterator procIter = injectedProcesses.begin();
         procIter != injectedProcesses.end();
         ++procIter)
    {

        DWORD pid = procIter->th32ProcessID;

        // only add the process info if it wasn't already found.
        if (procXMLMap.find(pid) == procXMLMap.end())
        {
            // insert new process and the process info
            gtASCIIString tmpString = XML("Name", XMLEscape(procIter->szExeFile).asCharArray());
            tmpString += XML("PID", pid);
            tmpString += XML("Path", XMLEscape(procIter->szPath).asCharArray());
            tmpString += XML("Platform",  strPlatform.asCharArray());
            procXMLMap[ pid ] = tmpString;

            // if this process is the one that was launched, then we know what the args and working directory were.
            // we could probably get the actual args and working dir from MicroDLL if it is a different app though, which
            // would be the case if this app uses a launcher app.
            if (m_injectedAppName.compare(procIter->szPath) == 0)
            {
                tmpString = XML("Args", XMLEscape(m_injectedAppArgs.c_str()).asCharArray());
                tmpString += XML("WDir", XMLEscape(m_injectedAppDir.c_str()).asCharArray());
                procXMLMap[ pid ] += tmpString.asCharArray();
            }
        }

        // add an API node for each of the wrappers that are injected into the app
        for (WrapperMap::const_iterator wrapperIter = wrappers.begin(); wrapperIter != wrappers.end(); ++wrapperIter)
        {
            // List of plugin extensions to check for. On Windows, test for 32 and 64 bit plugins.
            // On linux, just check for the plugin corresponding to the server bitness
            static const char* pluginExtensions[] =
            {
#ifdef WIN32
                GDT_DEBUG_SUFFIX GDT_BUILD_SUFFIX "." DLL_EXTENSION,
                "-x64" GDT_DEBUG_SUFFIX GDT_BUILD_SUFFIX "." DLL_EXTENSION
#else
                GDT_PROJECT_SUFFIX "." DLL_EXTENSION
#endif
            };

            int numPlugins = sizeof(pluginExtensions) / sizeof(pluginExtensions[0]);

            for (int loop = 0; loop < numPlugins; loop++)
            {
                // check to see if this wrapper is in the application
                gtASCIIString strPluginName = wrapperIter->second.strPluginName;

                if (SG_GET_BOOL(OptionDllReplacement) == false)
                {
                    strPluginName += pluginExtensions[loop];
                }

                if (IsLibraryLoadedInProcess(pid, strPluginName.asCharArray(), NULL))
                {
                    bool attached = false;

                    if (g_activeWrappersMap.find(FormatText("%lu/%s", pid, wrapperIter->first.c_str()).asCharArray()) != g_activeWrappersMap.end())
                    {
                        // the pid/plugin string was listed in the active wrappers map, so the plugin must be active.
                        attached = true;
                    }

                    procXMLMap[pid] += XMLAttrib("API", FormatText("attached='%s'", attached ? "TRUE" : "FALSE").asCharArray(), wrapperIter->second.strPluginShortDesc.asCharArray());
                }
            }
        }
    }

    // concatenate the process XML and additional info
    gtASCIIString xml;

    for (std::unordered_map< DWORD, gtASCIIString >::iterator iterP = procXMLMap.begin();
         iterP != procXMLMap.end();
         iterP++)
    {
        xml += XML("Process", (iterP->second).asCharArray());
    }

    gtASCIIString out = XMLHeader();
    out += XML("ProcessList", xml.asCharArray());

    return out;
}
コード例 #17
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML with a node and an int value
///
/// \param strNode node name
/// \param nValue int value enclosed by the node
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XML(const char* strNode, int nValue)
{
    return XML(strNode, FormatText("%d", nValue).asCharArray());
}
コード例 #18
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML with a node and a float value
///
/// \param strNode node name
/// \param fValue float value enclosed by the node
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XML(const char* strNode, float fValue)
{
    return XML(strNode, FormatText("%f", fValue).asCharArray());
}
コード例 #19
0
ファイル: vtk.cpp プロジェクト: armando-2011/DynamO
  void 
  OPVTK::ticker()
  {
    ++imageCounter;

    if (fields)
      {
	BOOST_FOREACH(const Particle & Part, Sim->particleList)
	  {
	    Vector  position = Part.getPosition(),
	      velocity = Part.getVelocity();
	  
	    Sim->dynamics.BCs().applyBC(position, velocity);
	  
	    size_t id(getCellID(position));
	  
	    //Samples
	    ++SampleCounter[id];
	  
	    double mass = Sim->dynamics.getSpecies(Part).getMass(Part.getID());

	    //Velocity Vectors
	    Momentum[id] += velocity * mass;
	  
	    //Energy Field
	    mVsquared[id] += velocity.nrm2() * mass;
	  }
      }

    if (snapshots)
      {
	char *fileName;
	if ( asprintf(&fileName, "%05ld", imageCounter) < 0)
	  M_throw() << "asprintf error in tinkerXYZ";
      
	std::ofstream of((std::string("paraview") + fileName + std::string(".vtu")).c_str());
      
	free(fileName);

	magnet::xml::XmlStream XML(of);
      
	XML //<< std::scientific
	  //This has a minus one due to the digit in front of the decimal
	  //An extra one is added if we're rounding
	  << std::setprecision(std::numeric_limits<double>::digits10 - 1)
	  << magnet::xml::prolog() << magnet::xml::tag("VTKFile")
	  << magnet::xml::attr("type") << "UnstructuredGrid"
	  << magnet::xml::attr("version") << "0.1"
	  << magnet::xml::attr("byte_order") << "LittleEndian"
	  << magnet::xml::tag("UnstructuredGrid")
	  << magnet::xml::tag("Piece") 
	  << magnet::xml::attr("NumberOfPoints") << Sim->N
	  << magnet::xml::attr("NumberOfCells") << 0
	  << magnet::xml::tag("Points")
	  << magnet::xml::tag("DataArray")
	  << magnet::xml::attr("type") << "Float32"
	  << magnet::xml::attr("format") << "ascii"
	  << magnet::xml::attr("NumberOfComponents") << "3"
	  << magnet::xml::chardata();
      
	BOOST_FOREACH(const Particle& part, Sim->particleList)
	  XML << part.getPosition()[0] / Sim->dynamics.units().unitLength() << " "
	      << part.getPosition()[1] / Sim->dynamics.units().unitLength() << " "
	      << part.getPosition()[2] / Sim->dynamics.units().unitLength() << "\n";
      
	XML << magnet::xml::endtag("DataArray")
	    << magnet::xml::endtag("Points")
	    << magnet::xml::tag("Cells") 

	    << magnet::xml::tag("DataArray")
	    << magnet::xml::attr("type") << "Int32" 
	    << magnet::xml::attr("Name") << "connectivity" 
	    << magnet::xml::attr("format") << "ascii" 
	    << magnet::xml::endtag("DataArray") 

	    << magnet::xml::tag("DataArray") 
	    << magnet::xml::attr("type") << "Int32" 
	    << magnet::xml::attr("Name") << "offsets" 
	    << magnet::xml::attr("format") << "ascii" 
	    << magnet::xml::endtag("DataArray") 

	    << magnet::xml::tag("DataArray") 
	    << magnet::xml::attr("type") << "UInt8" 
	    << magnet::xml::attr("Name") << "types" 
	    << magnet::xml::attr("format") << "ascii" 
	    << magnet::xml::endtag("DataArray") 

	    << magnet::xml::endtag("Cells")
	    << magnet::xml::tag("CellData") << magnet::xml::endtag("CellData")
	    << magnet::xml::tag("PointData"); 

	//Velocity data    
	XML << magnet::xml::tag("DataArray")
	    << magnet::xml::attr("type") << "Float32"
	    << magnet::xml::attr("Name") << "Velocities"
	    << magnet::xml::attr("NumberOfComponents") << "3"
	    << magnet::xml::attr("format") << "ascii"
	    << magnet::xml::chardata();
    
	BOOST_FOREACH(const Particle& part, Sim->particleList)
	  XML << part.getVelocity()[0] / Sim->dynamics.units().unitVelocity() << " "
	      << part.getVelocity()[1] / Sim->dynamics.units().unitVelocity() << " "
	      << part.getVelocity()[2] / Sim->dynamics.units().unitVelocity() << "\n";
    
	XML << magnet::xml::endtag("DataArray");

	XML << magnet::xml::endtag("PointData")
	    << magnet::xml::endtag("Piece")
	    << magnet::xml::endtag("UnstructuredGrid")
	    << magnet::xml::endtag("VTKFile")
	  ;
      }
  }
コード例 #20
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML with a node and a bool value
///
/// \param strNode node name
/// \param bValue bool value enclosed by the node
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XMLBool(const char* strNode, bool bValue)
{
    return XML(strNode, bValue ? "TRUE" : "FALSE");
}
コード例 #21
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML with a node and a double value
///
/// \param strNode node name
/// \param dValue double value enclosed by the node
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XML(const char* strNode, double dValue)
{
    return XML(strNode, FormatText("%Lf", dValue).asCharArray());
}
コード例 #22
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML with a node and an unsigned int value
///
/// \param strNode node name
/// \param uValue unsigned int value enclosed by the node
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XML(const char* strNode, unsigned int uValue)
{
    return XML(strNode, FormatText("%u", uValue).asCharArray());
}
コード例 #23
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
gtASCIIString TextureArrayElementXML(const char* strStage,
                                     const char* strArrayName,
                                     unsigned int uSlot,
                                     XML_TEXTURE_TYPE eType,
                                     unsigned int uWidth,
                                     unsigned int uHeight,
                                     unsigned int uDepth,
                                     unsigned int uMipLevels,
                                     const char* strUsage,
                                     const char* strFormat,
                                     unsigned int uSamples,
                                     unsigned int uOffset,
                                     const char* shaderInputTypeString,
                                     ResourceImageType eRIT,
                                     UINT GpuIndex)
{
    gtASCIIString strType = "Unknown";

    switch (eType)
    {
        case XTT_1D:
            strType = "1D";
            break;

        case XTT_1DARRAY:
            strType = "1DArray";
            break;

        case XTT_2D:
            strType = "2D";
            break;

        case XTT_2DARRAY:
            strType = "2DArray";
            break;

        case XTT_2DMS:
            strType = "2DMS";
            break;

        case XTT_2DMSARRAY:
            strType = "2DMSArray";
            break;

        case XTT_3D:
            strType = "3D";
            break;

        case XTT_CUBEMAP:
            strType = "CubeMap";
            break;

        case XTT_CUBEMAPARRAY:
            strType = "CubeMapArray";
            break;

        case XTT_BUFFER:
            strType = "Buffer";
            break;

        case XTT_BUFFEREX:
            strType = "BufferEx";
            break;

        case XTT_UNKNOWN:
            strType = "Unknown";
            break;
    }

    if (strlen(shaderInputTypeString) > 1)
    {
        // Include the shader input type in the XML
        gtASCIIString xmlString = XML("Type", strType.asCharArray());
        xmlString += XML("InputType", shaderInputTypeString);
        xmlString += XML("Width", uWidth);
        xmlString += XML("Height", uHeight);
        xmlString += XML("Depth", uDepth);
        xmlString += XML("MipLevels", uMipLevels);
        xmlString += XML("Usage", strUsage);
        xmlString += XML("Format", strFormat);
        xmlString += XML("Samples", uSamples);
        xmlString += XML("Offset", uOffset);
        xmlString += XML("ResourceImageType", eRIT);
        xmlString += XML("GPUIndex", GpuIndex);
        return XMLAttrib("Slot", FormatText("Stage='%s' Path='%s' Index='%u'", strStage, strArrayName, uSlot).asCharArray(), xmlString.asCharArray());
    }
    else
    {
        // Dont' include the shader input type in the XML
        gtASCIIString xmlString = XML("Type", strType.asCharArray());
        xmlString += XML("Width", uWidth);
        xmlString += XML("Height", uHeight);
        xmlString += XML("Depth", uDepth);
        xmlString += XML("MipLevels", uMipLevels);
        xmlString += XML("Usage", strUsage);
        xmlString += XML("Format", strFormat);
        xmlString += XML("Samples", uSamples);
        xmlString += XML("Offset", uOffset);
        xmlString += XML("ResourceImageType", eRIT);
        xmlString += XML("GPUIndex", GpuIndex);
        return XMLAttrib("Slot", FormatText("Stage='%s' Path='%s' Index='%u'", strStage, strArrayName, uSlot).asCharArray(), xmlString.asCharArray());
    }
}
コード例 #24
0
//--------------------------------------------------------------------------
/// Should be called by an API-specific FrameDebugger at each drawcall
/// \param rDrawCall the API-specific DrawCall that is being executed
//--------------------------------------------------------------------------
void FrameDebugger::OnDrawCall(IDrawCall& rDrawCall)
{
    m_ulDrawCallCounter++;

    if (m_drawCallList.IsActive())
    {
        m_LastDrawCall = &rDrawCall;
        gtASCIIString xmlString = rDrawCall.GetXML();
        xmlString += XML("hash", rDrawCall.GetHash().asCharArray());
        m_drawCallList += GetDrawCallXML(m_ulDrawCallCounter, xmlString.asCharArray()) ;
    }

    // Could collect drawcall XML here if desired
    if (IsDrawCallEnabled(m_ulDrawCallCounter))
    {
        // Make sure to not render after the frame debugger's break point
        if (IsTargetDrawCall(m_ulDrawCallCounter) == false)
        {
            // execute the drawcall for the app
            rDrawCall.Execute();
        }
        else
        {
            // have the pipeline process non-hud commands before drawing anything on HUD
            OnDrawCallAtBreakPointPreHUD(rDrawCall);

            // allow the API-specific FrameDebugger to decide whether or not to do the drawcall at the breakpoint
            DoDrawCallAtBreakPoint(rDrawCall);

            // Send the current draw call back to the client.
            if (m_CurrentDrawCall.IsActive())
            {
                m_CurrentDrawCall.Send(rDrawCall.GetXML().asCharArray());
            }

            bool bRes = BeginHUD();
            PsAssert(bRes != false);

            if (bRes == false)
            {
                Log(logERROR, "BeginHUD() failed");
                return;
            }

            // show the wireframe overlay
            if (m_bWireframeOverlay)
            {
                DoWireframeOverlay(rDrawCall, m_fWireframeOverlayColor[0], m_fWireframeOverlayColor[1], m_fWireframeOverlayColor[2], m_fWireframeOverlayColor[3]);
            }

            if (m_bAutoRenderTarget)
            {
                DoAutoRenderTarget();
            }

            OnDrawCallAtBreakPoint(rDrawCall);

            EndHUD();

            // skip the rest of the draws if HUD is being configured
            if (false == m_bConfigHUD)
            {
                // When the frame debugger is enabled we process the messages from inside the FD and no longer re-render the Frame Capture. This speeds up processing of messages
                // in apps that are running very slowly
                for (int ProcessedCommands = 0;;)
                {
                    if (m_drawCallList.IsActive() == true || m_Stats.IsActive() == true)
                    {
                        break;
                    }

                    // have the pipeline process non-hud commands before drawing anything on HUD
                    OnDrawCallAtBreakPointPreHUD(rDrawCall);
                    OnDrawCallAtBreakPoint(rDrawCall);

                    gtASCIIString SuCmd = PeekPendingRequests();

                    // Check for non FD command, if this changes then we have to re-render the HUD etc. So we break out
                    if (SuCmd.length() != 0)
                    {
                        char* pCmd = (char*)SuCmd.asCharArray();
                        ProcessedCommands++;

                        if (strstr(pCmd, "FD/Pipeline") == NULL)
                        {
                            LogConsole(logMESSAGE, "Processed in FD %3u\n", ProcessedCommands);
                            break;
                        }

                        GetSinglePendingRequest();
                    }
                }
            }
        }
    }
}
コード例 #25
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML to describe a drawcall
///
/// \param strDrawCallName string name of the drawcall (the function name)
/// \param strParams string describing the parameters of the draw call
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString GetDrawCallXML(const char* strDrawCallName, const char* strParams)
{
    gtASCIIString xml = XML("call", strDrawCallName);
    xml += XML("parameters", strParams);
    return xml;
}
コード例 #26
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML with a node and a long value
///
/// \param strNode node name
/// \param lValue long value enclosed by the node
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XML(const char* strNode, long lValue)
{
    return XML(strNode, FormatText("%u", lValue).asCharArray());
}
コード例 #27
0
ファイル: vtk.cpp プロジェクト: herbsolo/DynamO
void 
OPVTK::eventUpdate(const IntEvent& IEvent, const PairEventData& PDat)
{
  if (CollisionStats)
    {
      ++collCounter[getCellID(PDat.particle1_.getParticle().getPosition())];
      ++collCounter[getCellID(PDat.particle2_.getParticle().getPosition())];

      if (!(++eventCounter % 50000))
	{
	  char *fileName;
	  if ( asprintf(&fileName, "%05ld", ++collstatsfilecounter) < 0)
	    M_throw() << "asprintf error in VTK";
	  
	  std::ofstream of((std::string("CollStats") + fileName + std::string(".vtu")).c_str());
	  
	  free(fileName);

	  magnet::xml::XmlStream XML(of);
	  
	  
	  XML << magnet::xml::tag("VTKFile")
	      << magnet::xml::attr("type") << "ImageData"
	      << magnet::xml::attr("version") << "0.1"
	      << magnet::xml::attr("byte_order") << "LittleEndian"
	      << magnet::xml::attr("compressor") << "vtkZLibDataCompressor"
	      << magnet::xml::tag("ImageData")
	      << magnet::xml::attr("WholeExtent");
	  
	  for (size_t iDim(0); iDim < NDIM; ++iDim)
	    XML << " " << "0 " << nBins[iDim] - 1;
	  
	  XML << magnet::xml::attr("Origin");
	  
	  for (size_t iDim(0); iDim < NDIM; ++iDim)
	    XML << (Sim->primaryCellSize[iDim] * (-0.5))
	      / Sim->dynamics.units().unitLength()
		<< " ";
	  
	  XML << magnet::xml::attr("Spacing");
	  
	  for (size_t iDim(0); iDim < NDIM; ++iDim)
	    XML << binWidth[iDim] / Sim->dynamics.units().unitLength() << " ";
	  
	  XML << magnet::xml::tag("Piece")
	      << magnet::xml::attr("Extent");
	  
	  for (size_t iDim(0); iDim < NDIM; ++iDim)
	    XML << " " << "0 " << nBins[iDim] - 1;
	  
	  XML << magnet::xml::tag("PointData");
	  
	  
	  //////////////////////////HERE BEGINS THE OUTPUT OF THE FIELDS
	  ////////////SAMPLE COUNTS
	  XML << magnet::xml::tag("DataArray")
	      << magnet::xml::attr("type") << "Int32"
	      << magnet::xml::attr("Name") << "Collisions Per Snapshot"
	      << magnet::xml::attr("format") << "ascii"
	      << magnet::xml::chardata();
	  
	  BOOST_FOREACH(const unsigned long& val, collCounter)
	    XML << val;
	  
	  XML << "\n" << magnet::xml::endtag("DataArray");
	  
	  BOOST_FOREACH(unsigned long& val, collCounter)
	    val = 0;
	  
	  std::vector<size_t> density(nBins[0] * nBins[1] * nBins[2], 0);

	  BOOST_FOREACH(const Particle& part, Sim->particleList)
	    ++density[getCellID(part.getPosition())];
	  
	  XML << magnet::xml::tag("DataArray")
	      << magnet::xml::attr("type") << "Float32"
	      << magnet::xml::attr("Name") << "Density"
	      << magnet::xml::attr("format") << "ascii"
	      << magnet::xml::chardata();
	  
	  BOOST_FOREACH(const size_t& val, density)
	    XML << (val / binVol);
	  
	  XML << "\n" << magnet::xml::endtag("DataArray");

	  ////////////Postamble
	  XML << magnet::xml::endtag("PointData")
	      << magnet::xml::tag("CellData")
	      << magnet::xml::endtag("CellData")
	      << magnet::xml::endtag("Piece")
	      << magnet::xml::endtag("ImageData")
	      << magnet::xml::endtag("VTKFile");
	}
    }
コード例 #28
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML with a node and a BOOL value
///
/// \param strNode node name
/// \param bValue BOOL value enclosed by the node
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XMLBOOL(const char* strNode, int bValue)
{
    return XML(strNode, bValue ? "TRUE" : "FALSE");
}
コード例 #29
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML that contains two nodes: "name" and "value" and each have an
/// associated value. Particularly useful for counter data
///
/// \param strName string containing the name of the value
/// \param strValue string containing the value to encode
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XMLNameValue(const char* strName, const char* strValue)
{
    gtASCIIString xml = XML("name", strName);
    xml += XML("value",  strValue);
    return xml;
}
コード例 #30
0
ファイル: xml.cpp プロジェクト: PlusChie/CodeXL
//-----------------------------------------------------------------------------
/// generates XML with a node and a UINT64 value
///
/// \param strNode node name
/// \param lValue long value enclosed by the node
/// \return generated XML string
//-----------------------------------------------------------------------------
gtASCIIString XML(const char* strNode, UINT64 lValue)
{
    return XML(strNode, FormatText("%ld", lValue).asCharArray());
}