IntersectionApi* IntersectionApi::Create(std::uint32_t devidx) { IntersectionApi* result = nullptr; #ifdef USE_EMBREE if (devidx == GetCalc()->GetDeviceCount()) result = new IntersectionApiImpl(new EmbreeIntersectionDevice()); else #endif //USE_EMBREE result = new IntersectionApiImpl(new CalcIntersectionDevice(GetCalc(), GetCalc()->CreateDevice(devidx))); return result; }
void IntersectionApi::GetDeviceInfo(std::uint32_t devidx, DeviceInfo& devinfo) { auto* calc = GetCalc(); if (IsDeviceIndexEmbree(devidx)) { #ifdef USE_EMBREE devinfo.name = "embree"; devinfo.vendor = "intel"; devinfo.type = DeviceInfo::kCpu; devinfo.platform = DeviceInfo::kEmbree; #else assert(false); #endif //USE_EMBREE return; } assert(calc); Calc::DeviceSpec spec; calc->GetDeviceSpec(devidx, spec); // TODO: careful with memory management of strings devinfo.name = spec.name; devinfo.vendor = spec.vendor; devinfo.type = spec.type == Calc::DeviceType::kGpu ? DeviceInfo::kGpu : DeviceInfo::kCpu; }
void CCalcFrameDlg::OnBnClickedBtChu() { if( m_bPressNumber ) m_strButtonOld = m_strOutPut; if( !m_bIsBaseCalc ) GetCalc(); GetCalc(); m_strResultOld = m_strOutPut; m_enCalcType = en_Div; InsertRecord(en_Record_Div); m_bPressNumber = false; m_bPressEnable = true; }
std::uint32_t IntersectionApi::GetDeviceCount() { std::uint32_t result = GetCalc()->GetDeviceCount(); #ifdef USE_EMBREE ++result; // last one - embree device #endif //USE_EMBREE return result; }
std::uint32_t IntersectionApi::GetDeviceCount() { auto* calc = GetCalc(); std::uint32_t result = 0; if (calc != nullptr) { result += GetCalc()->GetDeviceCount(); } // embree is always the last device #ifdef USE_EMBREE if (s_calc_platform & DeviceInfo::Platform::kEmbree) { ++result; } #endif //USE_EMBREE return result; }
void CCalcFrameDlg::OnBnClickedBtDengyu() { GetCalc(); m_bPressNumber = false; InsertRecord(en_Record_Equal); m_strButtonOld = m_strOutPut; }
static bool IsDeviceIndexEmbree(uint32_t devidx) { #ifdef USE_EMBREE auto* calc = GetCalc(); if (calc != nullptr) { if (devidx == GetCalc()->GetDeviceCount()) { return true; } } else if(devidx == 0) { return true; } #endif //USE_EMBREE return false; }
void IntersectionApi::GetDeviceInfo(std::uint32_t devidx, DeviceInfo& devinfo) { #ifdef USE_EMBREE if (devidx == GetCalc()->GetDeviceCount()) { devinfo.name = "embree"; devinfo.vendor = "intel"; devinfo.type = DeviceInfo::kCpu; } else #endif //USE_EMBREE { Calc::DeviceSpec spec; GetCalc()->GetDeviceSpec(devidx, spec); // TODO: careful with memory management of strings devinfo.name = spec.name; devinfo.vendor = spec.vendor; devinfo.type = spec.type == Calc::DeviceType::kGpu ? DeviceInfo::kGpu : DeviceInfo::kCpu; } }
IntersectionApiCL* IntersectionApiCL::CreateFromOpenClContext(cl_context context, cl_device_id device, cl_command_queue queue) { auto calc = dynamic_cast<Calc::CalcCl*>(GetCalc()); if (calc) { return new IntersectionApiImpl(new CalcIntersectionDeviceCl(calc, calc->CreateDevice(context, device, queue))); } return nullptr; }
void CCalcFrameDlg::OnBnClickedBtKailifangn() { if( m_bPressNumber ) m_strButtonOld = m_strOutPut; GetCalc(); m_strResultOld = m_strOutPut; m_enCalcType = en_Yroot; InsertRecord(en_Record_Pow); m_bPressNumber = false; }
IntersectionApi* IntersectionApi::Create(std::uint32_t devidx) { if (IsDeviceIndexEmbree(devidx)) { #ifdef USE_EMBREE return new IntersectionApiImpl(new EmbreeIntersectionDevice()); #endif //USE_EMBREE } else { auto* calc = GetCalc(); if (calc != nullptr) { return new IntersectionApiImpl(new CalcIntersectionDevice(calc, calc->CreateDevice(devidx))); } } return nullptr; }
void CCalcFrameDlg::OnBnClickedBtJia() { //保存之前按键数字的记录,用来计算,注意一点只是用户输出的数字才能在这里赋值, //计算出来的结果不能显示在记录里面 if( m_bPressNumber ) m_strButtonOld = m_strOutPut; //因为加法具有等于的作用,所以每次执行这个操作的时候,先计算一下值 //m_bIsBaseCalc的作用,防止用户来回切换+-*/运算,同时可以去修改记录里面的运算符号 if( !m_bIsBaseCalc ) GetCalc(); //先将之前的输出结果保存起来 m_strResultOld = m_strOutPut; m_enCalcType = en_Add; InsertRecord(en_Record_Add); m_bPressNumber = false; m_bPressEnable = true; m_bIsBaseCalc = true; }