本文整理汇总了C++中DeviceInterface类的典型用法代码示例。如果您正苦于以下问题:C++ DeviceInterface类的具体用法?C++ DeviceInterface怎么用?C++ DeviceInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DeviceInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createImage
Image::Image (const DeviceInterface& vk,
const VkDevice device,
Allocator& allocator,
const VkImageCreateInfo& imageCreateInfo,
const MemoryRequirement memoryRequirement)
{
m_image = createImage(vk, device, &imageCreateInfo);
m_allocation = allocator.allocate(getImageMemoryRequirements(vk, device, *m_image), memoryRequirement);
VK_CHECK(vk.bindImageMemory(device, *m_image, m_allocation->getMemory(), m_allocation->getOffset()));
}
示例2: createBuffer
Buffer::Buffer (const DeviceInterface& vk,
const VkDevice device,
Allocator& allocator,
const VkBufferCreateInfo& bufferCreateInfo,
const MemoryRequirement memoryRequirement)
{
m_buffer = createBuffer(vk, device, &bufferCreateInfo);
m_allocation = allocator.allocate(getBufferMemoryRequirements(vk, device, *m_buffer), memoryRequirement);
VK_CHECK(vk.bindBufferMemory(device, *m_buffer, m_allocation->getMemory(), m_allocation->getOffset()));
}
示例3: getSwapchainImages
std::vector<VkImage> getSwapchainImages (const DeviceInterface& vkd,
VkDevice device,
VkSwapchainKHR swapchain)
{
deUint32 numImages = 0;
VK_CHECK(vkd.getSwapchainImagesKHR(device, swapchain, &numImages, DE_NULL));
if (numImages > 0)
{
std::vector<VkImage> images (numImages);
VK_CHECK(vkd.getSwapchainImagesKHR(device, swapchain, &numImages, &images[0]));
return images;
}
else
return std::vector<VkImage>();
}
示例4: beginCommandBuffer
void beginCommandBuffer (const DeviceInterface& vk, const VkCommandBuffer commandBuffer)
{
const VkCommandBufferBeginInfo commandBufBeginParams =
{
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType;
DE_NULL, // const void* pNext;
0u, // VkCommandBufferUsageFlags flags;
(const VkCommandBufferInheritanceInfo*)DE_NULL,
};
VK_CHECK(vk.beginCommandBuffer(commandBuffer, &commandBufBeginParams));
}
示例5: invalidateMappedMemoryRange
void invalidateMappedMemoryRange (const DeviceInterface& vkd, VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size)
{
const VkMappedMemoryRange range =
{
VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
DE_NULL,
memory,
offset,
size
};
VK_CHECK(vkd.invalidateMappedMemoryRanges(device, 1u, &range));
}
示例6: deviceNameColumnData
QVariant deviceNameColumnData(const Device::Node& node, DeviceInterface& dev, int role)
{
static const QFont italicFont{[] () { QFont f; f.setItalic(true); return f; }()};
using namespace iscore;
switch(role)
{
case Qt::DisplayRole:
case Qt::EditRole:
return node.get<DeviceSettings>().name;
case Qt::FontRole:
{
if(!dev.connected())
return italicFont;
}
default:
return {};
}
}
示例7: bindImagePlaneMemory
void bindImagePlaneMemory (const DeviceInterface& vkd,
VkDevice device,
VkImage image,
VkDeviceMemory memory,
VkDeviceSize memoryOffset,
VkImageAspectFlagBits planeAspect)
{
const VkBindImagePlaneMemoryInfo planeInfo =
{
VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO_KHR,
DE_NULL,
planeAspect
};
const VkBindImageMemoryInfo coreInfo =
{
VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR,
&planeInfo,
image,
memory,
memoryOffset,
};
VK_CHECK(vkd.bindImageMemory2(device, 1u, &coreInfo));
}
示例8: endCommandBuffer
void endCommandBuffer (const DeviceInterface& vk, const VkCommandBuffer commandBuffer)
{
VK_CHECK(vk.endCommandBuffer(commandBuffer));
}
示例9: sizeof
cl_int MemObject::init()
{
// Get the device list of the context
DeviceInterface **devices = 0;
cl_int rs;
rs = ((Context *)parent())->info(CL_CONTEXT_NUM_DEVICES,
sizeof(unsigned int),
&p_num_devices, 0);
if (rs != CL_SUCCESS)
return rs;
p_devices_to_allocate = p_num_devices;
devices = (DeviceInterface **)std::malloc(p_num_devices *
sizeof(DeviceInterface *));
if (!devices)
return CL_OUT_OF_HOST_MEMORY;
rs = ((Context *)parent())->info(CL_CONTEXT_DEVICES,
p_num_devices * sizeof(DeviceInterface *),
devices, 0);
if (rs != CL_SUCCESS)
{
std::free((void *)devices);
return rs;
}
// Allocate a table of DeviceBuffers
p_devicebuffers = (DeviceBuffer **)std::malloc(p_num_devices *
sizeof(DeviceBuffer *));
if (!p_devicebuffers)
{
std::free((void *)devices);
return CL_OUT_OF_HOST_MEMORY;
}
// If we have more than one device, the allocation on the devices is
// defered to first use, so host_ptr can become invalid. So, copy it in
// a RAM location and keep it. Also, set a flag telling CPU devices that
// they don't need to reallocate and re-copy host_ptr
if (p_num_devices > 1 && (p_flags & CL_MEM_COPY_HOST_PTR))
{
void *tmp_hostptr = std::malloc(size());
if (!tmp_hostptr)
{
std::free((void *)devices);
return CL_OUT_OF_HOST_MEMORY;
}
std::memcpy(tmp_hostptr, p_host_ptr, size());
p_host_ptr = tmp_hostptr;
// Now, the client application can safely std::free() its host_ptr
}
// Create a DeviceBuffer for each device
unsigned int failed_devices = 0;
for (unsigned int i=0; i<p_num_devices; ++i)
{
DeviceInterface *device = devices[i];
rs = CL_SUCCESS;
p_devicebuffers[i] = device->createDeviceBuffer(this, &rs);
if (rs != CL_SUCCESS)
{
p_devicebuffers[i] = 0;
failed_devices++;
}
}
if (failed_devices == p_num_devices)
{
// Each device found a reason to reject the buffer, so it's invalid
std::free((void *)devices);
return rs;
}
std::free((void *)devices);
devices = 0;
// If we have only one device, already allocate the buffer
if (p_num_devices == 1)
{
if (!p_devicebuffers[0]->allocate())
return CL_MEM_OBJECT_ALLOCATION_FAILURE;
}
return CL_SUCCESS;
}
示例10: printDeviceNotificationLine
/**
* @private
*/
void printDeviceNotificationLine(OutputStream* outputStream, unsigned char header, Device* device) {
DeviceInterface* deviceInterface = device->deviceInterface;
int argumentLength = deviceInterface->deviceGetInterface(header, DEVICE_MODE_NOTIFY, true);
printMethodOrNotificationMetaData(outputStream, deviceInterface, header, argumentLength, 0, true);
}
示例11: all
//.........这里部分代码省略.........
for(unsigned int i=0;i<envPath.length();i++)
{
if (envPath[i] == '\\'){
envPath.insert(i,1,'\\');
i++;
}
}
plgsPath = envPath;
plgsPath.append("\\\\plugins.csv");
plugins.open(plgsPath.c_str(),ios::out | ios::binary);
}
if(plugins.fail())
{
cout << "Error opening:"<< plgsPath << endl;
MessageBox(NULL,plgsPath.c_str(),"Ambient Library - Error", MB_OK);
errorMessage = DEVICE_ERROR_OPEN_DRIVER_LIST ;
}else
{
while(plugins.good()){
getline(plugins,line);
all.append(line);
}
}
plugins.close();
// parse the file
//MessageBox(NULL,all.c_str(), "MUH", MB_OK);
std::vector<std::string> devs = Utils::StringSplit(all,";");
// now we know which drivers to load, because the number after every dll specifies which ones we are going to load
// after loading the dll, query it and save which effects it can handle
for(unsigned int i=0;i<devs.size();i+=2){
if(atoi(devs[i+1].c_str()) == LOAD_DRIVER)
{
wchar_t *libText;
std::string pt = envPath;
pt.append("\\\\plugins\\\\");
pt.append(devs[i].c_str());
libText = new wchar_t[strlen(pt.c_str())+1];
memset(libText,0,strlen(pt.c_str())+1);
MultiByteToWideChar(CP_ACP,NULL,pt.c_str(),-1,libText,strlen(pt.c_str())+1);
drv = LoadLibrary(pt.c_str());
delete []libText;
if(drv != NULL){
// dll got loaded properly
// get our entrypoint
InitDeviceDriverPtr = (ctor_b_InitDeviceDriver) GetProcAddress(drv,"ctor_b_InitDeviceDriver");
if (NULL != InitDeviceDriverPtr)
{
// add the driver to our list
DeviceInterface *devI = InitDeviceDriverPtr(disableFateTime);
ptr<std::vector<int>> vec; // we are responsible for the vector ...
vec = new std::vector<int>();
devI->getSupportedSensoryEffects(vec);
devices.insert(pair<DeviceInterface *,ptr<std::vector<int>>>(devI,vec));
// now we have our driver loaded
cout << "Loaded device driver successfuly!"<< endl;
loadedPlugins.push_back(drv);
}else{
std::string error_msg;
error_msg.append("Error at loading driver: ");
error_msg.append(devs[i].c_str());
MessageBox(NULL, error_msg.c_str(), "Ambient Library - Error", MB_OK);
cout << "Error at loading driver: "<< devs[i].c_str() << endl;
errorMessage = DEVICE_ERROR_LOADING_DRIVERS;
FreeLibrary(drv);
}
}else{
cout << "No such device driver could be found: " << devs[i].c_str() << endl;
}
}else{
//MessageBox(NULL, devs[i].c_str(), "Not Loading..", MB_OK);
}
}
}
示例12: bindBufferDedicated
MovePtr<Allocation> bindBufferDedicated (const InstanceInterface& vki, const DeviceInterface& vkd, const VkPhysicalDevice physDevice, const VkDevice device, const VkBuffer buffer, const MemoryRequirement requirement)
{
MovePtr<Allocation> alloc(allocateDedicated(vki, vkd, physDevice, device, buffer, requirement));
VK_CHECK(vkd.bindBufferMemory(device, buffer, alloc->getMemory(), alloc->getOffset()));
return alloc;
}
示例13: bindBuffer
MovePtr<Allocation> bindBuffer (const DeviceInterface& vk, const VkDevice device, Allocator& allocator, const VkBuffer buffer, const MemoryRequirement requirement)
{
MovePtr<Allocation> alloc(allocator.allocate(getBufferMemoryRequirements(vk, device, buffer), requirement));
VK_CHECK(vk.bindBufferMemory(device, buffer, alloc->getMemory(), alloc->getOffset()));
return alloc;
}
示例14: bindImage
MovePtr<Allocation> bindImage (const DeviceInterface& vk, const VkDevice device, Allocator& allocator, const VkImage image, const MemoryRequirement requirement)
{
MovePtr<Allocation> alloc = allocator.allocate(getImageMemoryRequirements(vk, device, image), requirement);
VK_CHECK(vk.bindImageMemory(device, image, alloc->getMemory(), alloc->getOffset()));
return alloc;
}
示例15: void
/*
* Native kernel
*/
NativeKernelEvent::NativeKernelEvent(CommandQueue *parent,
void (*user_func)(void *),
void *args,
size_t cb_args,
cl_uint num_mem_objects,
const MemObject **mem_list,
const void **args_mem_loc,
cl_uint num_events_in_wait_list,
const Event **event_wait_list,
cl_int *errcode_ret)
: Event (parent, Queued, num_events_in_wait_list, event_wait_list, errcode_ret),
p_user_func((void *)user_func), p_args(0)
{
if (*errcode_ret != CL_SUCCESS) return;
// Parameters sanity
if (!user_func)
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
if (!args && (cb_args || num_mem_objects))
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
if (args && !cb_args)
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
if (num_mem_objects && (!mem_list || !args_mem_loc))
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
if (!num_mem_objects && (mem_list || args_mem_loc))
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
// Check that the device can execute a native kernel
DeviceInterface *device;
cl_device_exec_capabilities caps;
*errcode_ret = parent->info(CL_QUEUE_DEVICE, sizeof(DeviceInterface *),
&device, 0);
if (*errcode_ret != CL_SUCCESS)
return;
*errcode_ret = device->info(CL_DEVICE_EXECUTION_CAPABILITIES,
sizeof(cl_device_exec_capabilities), &caps, 0);
if (*errcode_ret != CL_SUCCESS)
return;
if ((caps & CL_EXEC_NATIVE_KERNEL) == 0)
{
*errcode_ret = CL_INVALID_OPERATION;
return;
}
// Copy the arguments in a new list
if (cb_args)
{
p_args = std::malloc(cb_args);
if (!p_args)
{
*errcode_ret = CL_OUT_OF_HOST_MEMORY;
return;
}
std::memcpy((void *)p_args, (void *)args, cb_args);
// Replace memory objects with global pointers
for (cl_uint i=0; i<num_mem_objects; ++i)
{
const MemObject *buffer = mem_list[i];
const char *loc = (const char *)args_mem_loc[i];
if (!buffer)
{
*errcode_ret = CL_INVALID_MEM_OBJECT;
return;
}
// We need to do relocation : loc is in args, we need it in p_args
size_t delta = (char *)p_args - (char *)args;
loc += delta;
//.........这里部分代码省略.........