예제 #1
0
   void console::vprintf(eConsoleMessageType type, const char* p, va_list args)
   {
      init();

      scoped_mutex lock(*m_pMutex);

      m_num_messages[type]++;

      char buf[cConsoleBufSize];
      vsprintf_s(buf, cConsoleBufSize, p, args);

      bool handled = false;

      if (m_output_funcs.size())
      {
         for (uint i = 0; i < m_output_funcs.size(); i++)
            if (m_output_funcs[i].m_func(type, buf, m_output_funcs[i].m_pData))
               handled = true;
      }

      const char* pPrefix = NULL;
      if ((m_prefixes) && (m_at_beginning_of_line))
      {
         switch (type)
         {
            case cDebugConsoleMessage:    pPrefix = "Debug: ";   break;
            case cWarningConsoleMessage:  pPrefix = "Warning: "; break;
            case cErrorConsoleMessage:    pPrefix = "Error: ";   break;
            default: break;
         }
      }

      if ((!m_output_disabled) && (!handled))
      {
         if (pPrefix)
            ::printf("%s", pPrefix);
         ::printf(m_crlf ? "%s\n" : "%s", buf);
      }

      uint n = strlen(buf);
      m_at_beginning_of_line = (m_crlf) || ((n) && (buf[n - 1] == '\n'));

      if ((type != cProgressConsoleMessage) && (m_pLog_stream))
      {
         // Yes this is bad.
         dynamic_string tmp_buf(buf);

         tmp_buf.translate_lf_to_crlf();

         m_pLog_stream->printf(m_crlf ? "%s\r\n" : "%s", tmp_buf.get_ptr());
         m_pLog_stream->flush();
      }
   }
예제 #2
0
파일: fft.cpp 프로젝트: zogi/ocean_demo
gpu::compute::event ifft2d_hermitian_inplace::enqueue_transform(
    gpu::compute::command_queue queue,
    gpu::compute::memory_object buffer,
    gpu::compute::event_vector *wait_events)
{
    // cl::Event is just a wrapper around cl_event. In memory they should match
    // exactly.
    const cl_event *cl_wait_events =
        wait_events ? reinterpret_cast<cl_event *>(wait_events->data()) : nullptr;
    cl_uint num_wait_events = wait_events ? static_cast<cl_uint>(wait_events->size()) : 0;

    cl_event res_event;
    CLFFT_CHECK(clfftEnqueueTransform(
        fft_plan, CLFFT_BACKWARD, 1, &queue(), num_wait_events, cl_wait_events, &res_event,
        &buffer(), nullptr, tmp_buf()));
    return cl::Event(res_event);
}
예제 #3
0
    void console::vprintf(eConsoleMessageType type, const char *p, va_list args)
    {
        init();

        if (m_pMutex)
            m_pMutex->lock();

        m_num_messages[type]++;

        static char buf[cConsoleBufSize];

        char *pDst = buf;
        uint32_t buf_left = sizeof(buf);

        if ((m_prefixes) && (m_at_beginning_of_line))
        {
            if (m_tool_prefix[0])
            {
                size_t l = strlen(m_tool_prefix);
                memcpy(pDst, m_tool_prefix, l);
                pDst += l;
                buf_left -= l;
            }

            const char *pPrefix = NULL;
            switch (type)
            {
                case cDebugConsoleMessage:
                    pPrefix = "Debug: ";
                    break;
                case cWarningConsoleMessage:
                    pPrefix = "Warning: ";
                    break;
                case cErrorConsoleMessage:
                    pPrefix = "Error: ";
                    break;
                default:
                    break;
            }

            if (pPrefix)
            {
                size_t l = strlen(pPrefix);
                memcpy(pDst, pPrefix, l);
                pDst += l;
                buf_left -= l;
            }
        }

        vogl::vogl_vsprintf_s(pDst, buf_left, p, args);

        bool handled = false;

        if (m_num_output_funcs)
        {
            console_func *funcs = get_output_funcs();

            for (uint32_t i = 0; i < m_num_output_funcs; i++)
                if (funcs[i].m_func(type, buf, funcs[i].m_pData))
                    handled = true;
        }

        if ((!m_output_disabled) && (!handled))
        {
            FILE *pFile = (type == cErrorConsoleMessage) ? stderr : stdout;

            fputs(buf, pFile);
        }

        uint32_t n = static_cast<uint32_t>(strlen(buf));
        m_at_beginning_of_line = (n) && (buf[n - 1] == '\n');

        if ((type != cProgressConsoleMessage) && (m_pLog_stream))
        {
            // Yes this is bad.
            dynamic_string tmp_buf(buf);

            tmp_buf.translate_lf_to_crlf();

            m_pLog_stream->printf("%s", tmp_buf.get_ptr());
            m_pLog_stream->flush();
        }

        if (m_pMutex)
            m_pMutex->unlock();
    }