本文整理汇总了C++中device类的典型用法代码示例。如果您正苦于以下问题:C++ device类的具体用法?C++ device怎么用?C++ device使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了device类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: num_query
timestamp_query::timestamp_query(device const& dvc, dx12u::cmd_queue const& q, int gpu_ordinal, std::size_t max_num_query) : num_query(max_num_query)
{
if (!dvc.Get())
{
throw error{ "null device" };
}
std::uint32_t gpu_mask = gpu_ordinal < 0 ? 1 : (1u << static_cast<std::uint32_t>(gpu_ordinal));
// alloc query buffer
size_t buf_aligned_sz = (num_query * sizeof(std::uint64_t) + 4095) & ~4095; // page aligned
auto heap_read_back = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_READBACK, gpu_mask, gpu_mask);
auto buffer_desc = CD3DX12_RESOURCE_DESC::Buffer(buf_aligned_sz);
auto r = dvc->CreateCommittedResource(&heap_read_back, D3D12_HEAP_FLAG_NONE,
&buffer_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&buffer));
dx12u::throw_if_error(r, "timestamp resource creation failure");
// query heap
D3D12_QUERY_HEAP_DESC heap_desc{};
heap_desc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
heap_desc.Count = static_cast<std::uint32_t>(num_query);
heap_desc.NodeMask = gpu_mask;
r = dvc->CreateQueryHeap(&heap_desc, IID_PPV_ARGS(&qh));
dx12u::throw_if_error(r, "timestamp query heap creation failure");
// clock frequency
dvc->SetStablePowerState(true);
q.get_com_ptr()->GetTimestampFrequency(&clock_freq);
}
开发者ID:GPUOpen-Effects,项目名称:ShadowFX,代码行数:29,代码来源:queries.cpp
示例2: device_
ibuffer::ibuffer(const device &device, const vk::BufferUsageFlags flags, const void *data, const size_t size)
: device_(device), size_(size)
{
handle_ = device.create_buffer(
vk::BufferCreateInfo()
.size(static_cast<vk::DeviceSize>(size))
.usage(flags));
gpumem_ = gpu_memory(
device,
device.get_buffer_memory_requirements(handle_),
vk::MemoryPropertyFlagBits::eHostVisible,
data);
device.bind_buffer_memory(handle_, gpumem_.handle(), 0);
}
开发者ID:PixelSpew,项目名称:nIceVulkan,代码行数:16,代码来源:buffer.cpp
示例3: default_device
device default_device()
{
static device dev;
if (!dev.id())
{
platform pl = default_platform();
std::vector<device> devices = pl.devices(device::accelerator);
if (devices.size()) dev = devices[0];
else // no accelerators found, try all
{
std::vector<device> devices = pl.devices(device::all);
if (devices.size()) dev = devices[0];
else OVXX_DO_THROW(std::runtime_error("No OpenCL devices found."));
}
}
return dev;
}
开发者ID:fsheikh,项目名称:openvsip,代码行数:17,代码来源:device.cpp
示例4: device_
descriptor_set_layout::descriptor_set_layout(const device &device, const vector<vk::DescriptorSetLayoutBinding> &bindings) :
device_(device)
{
handle_ = device.create_descriptor_set_layout(
vk::DescriptorSetLayoutCreateInfo()
.bindingCount(static_cast<uint32_t>(bindings.size()))
.pBindings(bindings.data()));
}
开发者ID:PixelSpew,项目名称:nIceVulkan,代码行数:8,代码来源:descriptor_set_layout.cpp
示例5: context
context(device const &d, cl_context_properties *props = 0)
{
OVXX_PRECONDITION(d.id() != 0);
cl_device_id id = d.id();
cl_int status;
impl_ = clCreateContext(props, 1, &id, context::callback, this, &status);
if (status < 0)
OVXX_DO_THROW(exception("clCreateContext", status));
}
开发者ID:fsheikh,项目名称:openvsip,代码行数:9,代码来源:context.hpp
示例6: get_global_cache
static boost::shared_ptr<parameter_cache> get_global_cache(const device &device)
{
// device name -> parameter cache
typedef std::map<std::string, boost::shared_ptr<parameter_cache> > cache_map;
BOOST_COMPUTE_DETAIL_GLOBAL_STATIC(cache_map, caches, ((std::less<std::string>())));
cache_map::iterator iter = caches.find(device.name());
if(iter == caches.end()){
boost::shared_ptr<parameter_cache> cache =
boost::make_shared<parameter_cache>(device);
caches.insert(iter, std::make_pair(device.name(), cache));
return cache;
}
else {
return iter->second;
}
}
开发者ID:junmuz,项目名称:compute,代码行数:20,代码来源:parameter_cache.hpp
示例7: genericKeyboard
genericKeyboard(cpu* host, device* keyboardProvider=NULL) {
this->host = host;
this->keyboardProvider = keyboardProvider;
host->addHardware(this);
reset();
if (keyboardProvider == NULL)
std::cout << "Warning: Keyboard has no display to attach to. Keyboard will still connect to dcpu16, but will be disabled." << std::endl;
else
keyboardProvider->registerKeyHandler(this);
}
开发者ID:srjek,项目名称:dcpu16,代码行数:11,代码来源:genericKeyboard.cpp
示例8: parameter_cache
parameter_cache(const device &device)
: m_dirty(false),
m_device_name(device.name())
{
#ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE
// get offline cache file name (e.g. /home/user/.boost_compute/tune/device.json)
m_file_name = make_file_name();
// load parameters from offline cache file (if it exists)
if(boost::filesystem::exists(m_file_name)){
read_from_disk();
}
#endif // BOOST_COMPUTE_USE_OFFLINE_CACHE
}
开发者ID:junmuz,项目名称:compute,代码行数:14,代码来源:parameter_cache.hpp
示例9: get_work_group_info
T get_work_group_info(const device &device, cl_kernel_work_group_info info)
{
T value;
cl_int ret = clGetKernelWorkGroupInfo(m_kernel,
device.id(),
info,
sizeof(T),
&value,
0);
if(ret != CL_SUCCESS){
BOOST_THROW_EXCEPTION(runtime_exception(ret));
}
return value;
}
开发者ID:sajis997,项目名称:compute,代码行数:15,代码来源:kernel.hpp
示例10: device_
descriptor_pool::descriptor_pool(const device &device) :
device_(device)
{
vector<vk::DescriptorPoolSize> poolSizes = {
vk::DescriptorPoolSize()
.type(vk::DescriptorType::eUniformBuffer)
.descriptorCount(1),
vk::DescriptorPoolSize()
.type(vk::DescriptorType::eCombinedImageSampler)
.descriptorCount(1)
};
handle_ = device.create_descriptor_pool(
vk::DescriptorPoolCreateInfo()
.poolSizeCount(static_cast<uint32_t>(poolSizes.size()))
.pPoolSizes(poolSizes.data())
.maxSets(1));
}
开发者ID:PixelSpew,项目名称:nIceVulkan,代码行数:18,代码来源:descriptor_pool.cpp
示例11: set_pu_control
void set_pu_control(device & device, int subdevice, rs_option option, int value)
{
auto handle = device.get_subdevice(subdevice).handle;
int ct_unit = 0, pu_unit = 0;
for(auto ct = uvc_get_input_terminals(handle); ct; ct = ct->next) ct_unit = ct->bTerminalID; // todo - Check supported caps
for(auto pu = uvc_get_processing_units(handle); pu; pu = pu->next) pu_unit = pu->bUnitID; // todo - Check supported caps
switch(option)
{
case RS_OPTION_COLOR_BACKLIGHT_COMPENSATION: return set_pu<uint16_t>(handle, subdevice, pu_unit, UVC_PU_BACKLIGHT_COMPENSATION_CONTROL, value);
case RS_OPTION_COLOR_BRIGHTNESS: return set_pu<int16_t>(handle, subdevice, pu_unit, UVC_PU_BRIGHTNESS_CONTROL, value);
case RS_OPTION_COLOR_CONTRAST: return set_pu<uint16_t>(handle, subdevice, pu_unit, UVC_PU_CONTRAST_CONTROL, value);
case RS_OPTION_COLOR_EXPOSURE: return set_pu<uint32_t>(handle, subdevice, ct_unit, UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL, value);
case RS_OPTION_COLOR_GAIN: return set_pu<uint16_t>(handle, subdevice, pu_unit, UVC_PU_GAIN_CONTROL, value);
case RS_OPTION_COLOR_GAMMA: return set_pu<uint16_t>(handle, subdevice, pu_unit, UVC_PU_GAMMA_CONTROL, value);
case RS_OPTION_COLOR_HUE: return; // set_pu<int16_t>(handle, subdevice, pu_unit, UVC_PU_HUE_CONTROL, value); // Causes LIBUSB_ERROR_PIPE, may be related to not being able to set UVC_PU_HUE_AUTO_CONTROL
case RS_OPTION_COLOR_SATURATION: return set_pu<uint16_t>(handle, subdevice, pu_unit, UVC_PU_SATURATION_CONTROL, value);
case RS_OPTION_COLOR_SHARPNESS: return set_pu<uint16_t>(handle, subdevice, pu_unit, UVC_PU_SHARPNESS_CONTROL, value);
case RS_OPTION_COLOR_WHITE_BALANCE: return set_pu<uint16_t>(handle, subdevice, pu_unit, UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL, value);
case RS_OPTION_COLOR_ENABLE_AUTO_EXPOSURE: return set_pu<uint8_t>(handle, subdevice, ct_unit, UVC_CT_AE_MODE_CONTROL, value ? 2 : 1); // Modes - (1: manual) (2: auto) (4: shutter priority) (8: aperture priority)
case RS_OPTION_COLOR_ENABLE_AUTO_WHITE_BALANCE: return set_pu<uint8_t>(handle, subdevice, pu_unit, UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, value);
default: throw std::logic_error("invalid option");
}
}
开发者ID:Aevena,项目名称:librealsense,代码行数:24,代码来源:uvc-libuvc.cpp
示例12: draw
/**
* Draw the enlarged schema. This methods can only
* be called after the block have been placed
*/
void decorateSchema::draw(device& dev)
{
assert(placed());
fSchema->draw(dev);
#if 0
// draw enlarge input wires
for (unsigned int i=0; i<inputs(); i++) {
point p = inputPoint(i);
point q = fSchema->inputPoint(i);
dev.trait(p.x, p.y, q.x, q.y);
}
// draw enlarge output wires
for (unsigned int i=0; i<outputs(); i++) {
point p = outputPoint(i);
point q = fSchema->outputPoint(i);
dev.trait(p.x, p.y, q.x, q.y);
}
#endif
// define the coordinates of the frame
double tw = (2+fText.size())*dLetter*0.75;
double x0 = x() + fMargin/2; // left
double y0 = y() + fMargin/2; // top
double x1 = x() + width() - fMargin/2; // right
double y1 = y() + height() - fMargin/2; // bottom
//double tl = x0 + 2*dWire; // left of text zone
double tl = x() + fMargin; // left of text zone
double tr = min(tl+tw, x1); // right of text zone
// draw the surronding frame
dev.dasharray(x0, y0, x0, y1); // left line
dev.dasharray(x0, y1, x1, y1); // bottom line
dev.dasharray(x1, y1, x1, y0); // right line
dev.dasharray(x0, y0, tl, y0); // top segment before text
dev.dasharray(tr, y0, x1, y0); // top segment after text
// draw the label
dev.label(tl, y0, fText.c_str()); //
}
开发者ID:EBone,项目名称:faust-1,代码行数:44,代码来源:decorateSchema.cpp
示例13: set_control
void set_control(device & device, const extension_unit & xu, uint8_t ctrl, void * data, int len)
{
int status = uvc_set_ctrl(device.get_subdevice(xu.subdevice).handle, xu.unit, ctrl, data, len);
if(status < 0) throw std::runtime_error(to_string() << "uvc_set_ctrl(...) returned " << libusb_error_name(status));
}
开发者ID:Aevena,项目名称:librealsense,代码行数:5,代码来源:uvc-libuvc.cpp
示例14: set_subdevice_mode
void set_subdevice_mode(device & device, int subdevice_index, int width, int height, uint32_t fourcc, int fps, std::function<void(const void * frame)> callback)
{
auto & sub = device.get_subdevice(subdevice_index);
check("get_stream_ctrl_format_size", uvc_get_stream_ctrl_format_size(sub.handle, &sub.ctrl, reinterpret_cast<const big_endian<uint32_t> &>(fourcc), width, height, fps));
sub.callback = callback;
}
开发者ID:Aevena,项目名称:librealsense,代码行数:6,代码来源:uvc-libuvc.cpp
示例15: max_word_sz
text_2d::text_2d(device const& dev, std::size_t max_str_size, std::size_t max_num_str, std::size_t max_buffered_frame, bool enable_filtering)
: max_word_sz(max_str_size), max_num_word(max_num_str)
{
assert(max_str_size > 0 && max_num_str > 0 && max_buffered_frame > 0);
if (dev.Get() == nullptr)
{
throw error{ "null device" };
}
words.resize(max_buffered_frame);
size_t const num_cb = max_num_str * max_buffered_frame;
size_t const num_tex = 1; // 1 text texture
srd_heap = dx12u::descriptor_heap{ dev.Get(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, num_cb + num_tex };
auto cb_sz = get_cb_size(max_str_size);
auto cb_total_sz = get_cb_size(max_str_size) * num_cb;
// alloc and upload texture
{
auto font_data = load_font_texture();
gu::mip_lvl_texture_view mip_view{};
mip_view.width = global::font_texture_width;
mip_view.height = global::font_texture_height;
mip_view.pitch = mip_view.width;
mip_view.slice_sz = font_data.size();
mip_view.data = font_data.data();
gu::texture_view tex_view{};
tex_view.bpp = 1;
tex_view.num_lvl = 1;
tex_view.mip = &mip_view;
dx12u::cmd_queue q{ dev };
dx12u::cmd_allocator allocator{ dev };
dx12u::gfx_cmd_list cl = allocator.alloc();
auto tex = dx12u::make_texture(dev, cl, tex_view, false, false, DXGI_FORMAT_R8_UNORM);
cl->Close();
q.push(cl);
q.sync();
font_texture = tex.texture_rsrc;
dev->CreateShaderResourceView(font_texture.Get(), &tex.srv_desc, srd_heap.get_cpu_handle(0));
}
// alloc cb_mem
{
auto upload_heap = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD);
auto buffer_desc = CD3DX12_RESOURCE_DESC::Buffer(cb_total_sz);
auto r = dev->CreateCommittedResource(&upload_heap, D3D12_HEAP_FLAG_NONE,
&buffer_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&cb_mem));
dx12u::throw_if_error(r);
for (size_t i = 0; i < num_cb; ++i)
{
// sh_mask_cb views
D3D12_CONSTANT_BUFFER_VIEW_DESC cbv_desc = {};
cbv_desc.SizeInBytes = static_cast<uint32_t>(cb_sz);
cbv_desc.BufferLocation = cb_mem->GetGPUVirtualAddress() + i * cb_sz;
dev->CreateConstantBufferView(&cbv_desc, srd_heap.get_cpu_handle(num_tex + i));
}
r = cb_mem->Map(0, nullptr, reinterpret_cast<void**>(&cb_ptr));
dx12u::throw_if_error(r);
assert(!!cb_ptr);
memset(cb_ptr, 0, cb_total_sz);
}
// pso
{
// root signature
auto filter = enable_filtering ? D3D12_FILTER_MIN_MAG_MIP_LINEAR : D3D12_FILTER_MIN_MAG_MIP_POINT;
dx12u::descriptor_sig_list descriptor_table0{};
dx12u::descriptor_sig_list descriptor_table1{};
descriptor_table0.append(dx12u::descriptor_sig{ dx12u::descriptor_type::srv, 0, 0, dx12u::shader_mask::ps });
descriptor_table1.append(dx12u::descriptor_sig{ dx12u::descriptor_type::cbv, 0, 0, dx12u::shader_mask::vs });
dx12u::descriptor_sig_list dsl{};
dsl.append(descriptor_table0); // TODO move to root once the number of sgpr is definite
dsl.append(descriptor_table1);
dx12u::static_sampler_list sl =
{
dx12u::make_default_static_sampler(0, filter),
};
rs = dx12u::make_root_signature(dev.Get(), dsl, sl);
// shader preprocessor definitions
auto const texture_char_w = static_cast<double>(global::font_texture_char_w) / static_cast<double>(global::font_texture_width);
using macro = std::pair<std::string, std::string>;
macro max_str_macro = macro{ "MAX_STR_SZ", std::to_string(max_str_size) };
macro char_w_macro = macro{ "CHAR_WIDTH", std::to_string(texture_char_w) };
D3D_SHADER_MACRO def[] =
{
max_str_macro.first.c_str(), max_str_macro.second.c_str(),
char_w_macro.first.c_str(), char_w_macro.second.c_str(),
nullptr, nullptr
};
//.........这里部分代码省略.........
开发者ID:GPUOpen-Effects,项目名称:ShadowFX,代码行数:101,代码来源:text.cpp
示例16: get_build_info
T get_build_info(cl_program_build_info info, const device &device) const
{
return detail::get_object_info<T>(clGetProgramBuildInfo, m_program, info, device.id());
}
开发者ID:2bbb,项目名称:compute,代码行数:4,代码来源:program.hpp
示例17: process
bool btlelibscanfilter::process(device &dev, adv_fields &fields, int rssi)
{
return dev.advertisement_fields().is_service_advertiset(uuid(BTLE_SERVICE));
}
开发者ID:venkatarajasekhar,项目名称:bluetooth-le,代码行数:4,代码来源:btlelibscanfilter.cpp
示例18: playback
playback(device d) : playback(d.get()) {}
开发者ID:UnaNancyOwen,项目名称:librealsense,代码行数:1,代码来源:rs_record_playback.hpp
示例19: recorder
recorder(device d) : recorder(d.get()) {}
开发者ID:UnaNancyOwen,项目名称:librealsense,代码行数:1,代码来源:rs_record_playback.hpp
示例20:
bool device::operator == (const device& other) const
{
return bda_ == other.addr();
}
开发者ID:venkatarajasekhar,项目名称:bluetooth-le,代码行数:4,代码来源:device.cpp
注:本文中的device类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论