BOOL CGatewayInfoteamSerialToI::ProcessCommand(CCommandRoot* pCommand,CLayerManagerBase* pManager,HANDLE h_Handle,HANDLE hTransactionHandle) { CCommand_PS* pCommand_PS; CInterfaceManagerBase* pInterfaceManager; if(CGateway::ProcessCommand(pCommand, pManager, h_Handle, hTransactionHandle)) { if(CheckLayers(pCommand,pManager)) { pCommand_PS = (CCommand_PS*)pCommand; pInterfaceManager = (CInterfaceManagerBase*)pManager; switch(pCommand->GetCommandId()) { case INFOTEAM_SERIAL_PROCESS_PROTOCOL : return Process_ProcessProtocol(pCommand_PS,pInterfaceManager,h_Handle,hTransactionHandle); case INFOTEAM_SERIAL_PROCESS_PROTOCOL_MAXON : return Process_ProcessProtocolMaxon(pCommand_PS,pInterfaceManager,h_Handle,hTransactionHandle); case INFOTEAM_SERIAL_ABORT_PROTOCOL_MAXON : return Process_AbortProtocolMaxon(pCommand_PS,pInterfaceManager,h_Handle,hTransactionHandle); case INFOTEAM_SERIAL_SEND_CHUNK : return Process_SendChunk(pCommand_PS,pInterfaceManager,h_Handle,hTransactionHandle); case INFOTEAM_SERIAL_RECEIVE_DATA : return Process_ReceiveData(pCommand_PS,pInterfaceManager,h_Handle,hTransactionHandle); } } } return FALSE; }
BOOL CGatewayCANopenToEpos::ProcessCommand(CCommandRoot* pCommand, CLayerManagerBase* pManager, HANDLE h_Handle, HANDLE hTransactionHandle) { CCommand_PS* pCommand_PS; CDeviceCommandSetManagerBase* pDeviceCommandSetManager; if(CGateway::ProcessCommand(pCommand, pManager, h_Handle, hTransactionHandle)) { if(CheckLayers(pCommand, pManager)) { pCommand_PS = (CCommand_PS*)pCommand; pDeviceCommandSetManager = (CDeviceCommandSetManagerBase*)pManager; switch(pCommand->GetCommandId()) { case CANOPEN_INITIATE_SDO_DOWNLOAD: return Process_InitiateSDODownload(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_DOWNLOAD_SDO_SEGMENT: return Process_DownloadSDOSegment(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_INITIATE_SDO_UPLOAD: return Process_InitiateSDOUpload(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_UPLOAD_SDO_SEGMENT: return Process_UploadSDOSegment(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_NETWORK_INDICATION: return Process_NetworkIndication(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_ABORT_SDO_TRANSFER: return Process_AbortSDOTransfer(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_SEND_NMT_SERVICE: return Process_SendNMTService(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_SEND_CAN_FRAME: return Process_SendCANFrame(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_READ_CAN_FRAME: return Process_ReadCANFrame(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_REQUEST_CAN_FRAME: return Process_RequestCANFrame(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_SEND_LSS_FRAME: return Process_SendLSSFrame(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); case CANOPEN_READ_LSS_FRAME: return Process_ReadLSSFrame(pCommand_PS, pDeviceCommandSetManager, h_Handle, hTransactionHandle); } } } return FALSE; }
//******************************************************************** BOOL CGatewayRS232ToWin32::ProcessCommand(CCommandRoot* pCommand, CLayerManagerBase* pManager, HANDLE h_Handle, HANDLE hTransactionHandle) { CCommand_I* pCommand_I; if(CGateway::ProcessCommand(pCommand, pManager, h_Handle, hTransactionHandle)) { if(CheckLayers(pCommand, pManager)) { pCommand_I = (CCommand_I*)pCommand; switch(pCommand->GetCommandId()) { case RS232_WRITE_DATA: return Process_WriteData(pCommand_I); case RS232_READ_DATA: return Process_ReadData(pCommand_I); } } } return FALSE; }
BOOL CGatewayEpos2ToMaxonSerialV1::ProcessCommand(CCommandRoot* pCommand, CLayerManagerBase* pManager, HANDLE h_Handle, HANDLE hTransactionHandle) { CCommand_DCS* pCommand_DCS; CProtocolStackManagerBase* pProtocolStackManager; if(CGateway::ProcessCommand(pCommand, pManager, h_Handle, hTransactionHandle)) { if(CheckLayers(pCommand, pManager)) { pCommand_DCS = (CCommand_DCS*)pCommand; pProtocolStackManager = (CProtocolStackManagerBase*)pManager; switch(pCommand->GetCommandId()) { //Object Dictionary Access Commands case EPOS2_READ_OBJECT: return Process_ReadObject(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); case EPOS2_WRITE_OBJECT: return Process_WriteObject(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); case EPOS2_INITIATE_SEGMENT_READ: return Process_InitiateSegmentedRead(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); case EPOS2_INITIATE_SEGMENT_WRITE: return Process_InitiateSegmentedWrite(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); case EPOS2_SEGMENT_READ: return Process_SegmentRead(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); case EPOS2_SEGMENT_WRITE: return Process_SegmentWrite(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); case EPOS2_ABORT_SEGMENT_TRANSFER: return Process_AbortSegmentedTransfer(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); //Network Management Commands case EPOS2_SEND_NMT_SERVICE: return Process_SendNMTService(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); //General Gateway case EPOS2_SEND_CAN_FRAME: return Process_SendCANFrame(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); case EPOS2_READ_CAN_FRAME: return Process_ReadCANFrame(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); case EPOS2_REQUEST_CAN_FRAME: return Process_RequestCANFrame(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); //Layer Setting Services case EPOS2_SEND_LSS_FRAME: return Process_SendLSSFrame(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); case EPOS2_READ_LSS_FRAME: return Process_ReadLSSFrame(pCommand_DCS, pProtocolStackManager, h_Handle, hTransactionHandle); } } } return FALSE; }
VkResult VulkanContext::CreateInstance(const CreateInfo &info) { if (!vkCreateInstance) { init_error_ = "Vulkan not loaded - can't create instance"; return VK_ERROR_INITIALIZATION_FAILED; } flags_ = info.flags; // List extensions to try to enable. instance_extensions_enabled_.push_back(VK_KHR_SURFACE_EXTENSION_NAME); #ifdef _WIN32 instance_extensions_enabled_.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); #elif defined(__ANDROID__) instance_extensions_enabled_.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); #else #if defined(VK_USE_PLATFORM_XLIB_KHR) if (IsInstanceExtensionAvailable(VK_KHR_XLIB_SURFACE_EXTENSION_NAME)) { instance_extensions_enabled_.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); } #endif //#if defined(VK_USE_PLATFORM_XCB_KHR) // instance_extensions_enabled_.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); //#endif //#if defined(VK_USE_PLATFORM_MIR_KHR) // instance_extensions_enabled_.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); //#endif #if defined(VK_USE_PLATFORM_WAYLAND_KHR) if (IsInstanceExtensionAvailable(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME)) { instance_extensions_enabled_.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); } #endif #endif if (flags_ & VULKAN_FLAG_VALIDATE) { if (IsInstanceExtensionAvailable(VK_EXT_DEBUG_REPORT_EXTENSION_NAME)) { for (size_t i = 0; i < ARRAY_SIZE(validationLayers); i++) { instance_layer_names_.push_back(validationLayers[i]); device_layer_names_.push_back(validationLayers[i]); } instance_extensions_enabled_.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); } else { ELOG("Validation layer extension not available - not enabling Vulkan validation."); flags_ &= ~VULKAN_FLAG_VALIDATE; } } // Validate that all the instance extensions we ask for are actually available. for (auto ext : instance_extensions_enabled_) { if (!IsInstanceExtensionAvailable(ext)) WLOG("WARNING: Does not seem that instance extension '%s' is available. Trying to proceed anyway.", ext); } VkApplicationInfo app_info{ VK_STRUCTURE_TYPE_APPLICATION_INFO }; app_info.pApplicationName = info.app_name; app_info.applicationVersion = info.app_ver; app_info.pEngineName = info.app_name; // Let's increment this when we make major engine/context changes. app_info.engineVersion = 2; app_info.apiVersion = VK_API_VERSION_1_0; VkInstanceCreateInfo inst_info{ VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO }; inst_info.flags = 0; inst_info.pApplicationInfo = &app_info; inst_info.enabledLayerCount = (uint32_t)instance_layer_names_.size(); inst_info.ppEnabledLayerNames = instance_layer_names_.size() ? instance_layer_names_.data() : nullptr; inst_info.enabledExtensionCount = (uint32_t)instance_extensions_enabled_.size(); inst_info.ppEnabledExtensionNames = instance_extensions_enabled_.size() ? instance_extensions_enabled_.data() : nullptr; #if SIMULATE_VULKAN_FAILURE == 2 VkResult res = VK_ERROR_INCOMPATIBLE_DRIVER; #else VkResult res = vkCreateInstance(&inst_info, nullptr, &instance_); #endif if (res != VK_SUCCESS) { if (res == VK_ERROR_LAYER_NOT_PRESENT) { WLOG("Validation on but layers not available - dropping layers"); // Drop the validation layers and try again. instance_layer_names_.clear(); device_layer_names_.clear(); inst_info.enabledLayerCount = 0; inst_info.ppEnabledLayerNames = nullptr; res = vkCreateInstance(&inst_info, nullptr, &instance_); if (res != VK_SUCCESS) ELOG("Failed to create instance even without validation: %d", res); } else { ELOG("Failed to create instance : %d", res); } } if (res != VK_SUCCESS) { init_error_ = "Failed to create Vulkan instance"; return res; } VulkanLoadInstanceFunctions(instance_); if (!CheckLayers(instance_layer_properties_, instance_layer_names_)) { WLOG("CheckLayers for instance failed"); // init_error_ = "Failed to validate instance layers"; // return; } uint32_t gpu_count = 1; #if SIMULATE_VULKAN_FAILURE == 3 gpu_count = 0; #else res = vkEnumeratePhysicalDevices(instance_, &gpu_count, nullptr); #endif if (gpu_count <= 0) { ELOG("Vulkan driver found but no supported GPU is available"); init_error_ = "No Vulkan physical devices found"; vkDestroyInstance(instance_, nullptr); instance_ = nullptr; return VK_ERROR_INITIALIZATION_FAILED; } assert(gpu_count > 0); physical_devices_.resize(gpu_count); res = vkEnumeratePhysicalDevices(instance_, &gpu_count, physical_devices_.data()); if (res != VK_SUCCESS) { init_error_ = "Failed to enumerate physical devices"; vkDestroyInstance(instance_, nullptr); instance_ = nullptr; return res; } return VK_SUCCESS; }
void VulkanContext::ChooseDevice(int physical_device) { physical_device_ = physical_device; ILOG("Chose physical device %d: %p", physical_device, physical_devices_[physical_device]); GetDeviceLayerProperties(); if (!CheckLayers(device_layer_properties_, device_layer_names_)) { WLOG("CheckLayers for device %d failed", physical_device); } vkGetPhysicalDeviceQueueFamilyProperties(physical_devices_[physical_device_], &queue_count, nullptr); assert(queue_count >= 1); queue_props.resize(queue_count); vkGetPhysicalDeviceQueueFamilyProperties(physical_devices_[physical_device_], &queue_count, queue_props.data()); assert(queue_count >= 1); // Detect preferred formats, in this order. static const VkFormat depthStencilFormats[] = { VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D16_UNORM_S8_UINT, }; deviceInfo_.preferredDepthStencilFormat = VK_FORMAT_UNDEFINED; for (size_t i = 0; i < ARRAY_SIZE(depthStencilFormats); i++) { VkFormatProperties props; vkGetPhysicalDeviceFormatProperties(physical_devices_[physical_device_], depthStencilFormats[i], &props); if (props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { deviceInfo_.preferredDepthStencilFormat = depthStencilFormats[i]; break; } } if (deviceInfo_.preferredDepthStencilFormat == VK_FORMAT_UNDEFINED) { // WTF? This is bad. ELOG("Could not find a usable depth stencil format."); } // This is as good a place as any to do this vkGetPhysicalDeviceMemoryProperties(physical_devices_[physical_device_], &memory_properties); vkGetPhysicalDeviceProperties(physical_devices_[physical_device_], &gpu_props); // Optional features vkGetPhysicalDeviceFeatures(physical_devices_[physical_device_], &featuresAvailable_); memset(&featuresEnabled_, 0, sizeof(featuresEnabled_)); // Enable a few safe ones if they are available. if (featuresAvailable_.dualSrcBlend) { featuresEnabled_.dualSrcBlend = true; } if (featuresAvailable_.largePoints) { featuresEnabled_.largePoints = true; } if (featuresAvailable_.wideLines) { featuresEnabled_.wideLines = true; } if (featuresAvailable_.geometryShader) { featuresEnabled_.geometryShader = true; } if (featuresAvailable_.logicOp) { featuresEnabled_.logicOp = true; } if (featuresAvailable_.depthClamp) { featuresEnabled_.depthClamp = true; } if (featuresAvailable_.depthBounds) { featuresEnabled_.depthBounds = true; } if (featuresAvailable_.samplerAnisotropy) { featuresEnabled_.samplerAnisotropy = true; } // For easy wireframe mode, someday. if (featuresEnabled_.fillModeNonSolid) { featuresEnabled_.fillModeNonSolid = true; } GetDeviceLayerExtensionList(nullptr, device_extension_properties_); device_extensions_enabled_.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); }
void DoMoveSizeWindow(struct Window *targetwindow, LONG NewLeftEdge, LONG NewTopEdge, LONG NewWidth, LONG NewHeight, BOOL send_newsize, struct IntuitionBase *IntuitionBase) { struct IIHData *iihdata = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data; //struct IntWindow *w = (struct IntWindow *)targetwindow; struct Layer *targetlayer = WLAYER(targetwindow)/*, *L*/; struct Requester *req; struct InputEvent *ie; LONG OldLeftEdge = targetwindow->LeftEdge; LONG OldTopEdge = targetwindow->TopEdge; LONG OldWidth = targetwindow->Width; LONG OldHeight = targetwindow->Height; LONG pos_dx, pos_dy, size_dx, size_dy; /* correct new window coords if necessary */ FixWindowCoords(targetwindow, &NewLeftEdge, &NewTopEdge, &NewWidth, &NewHeight,IntuitionBase); D(bug("DoMoveSizeWindow to %d,%d %d x %d\n", NewLeftEdge, NewTopEdge, NewWidth, NewHeight)); pos_dx = NewLeftEdge - OldLeftEdge; pos_dy = NewTopEdge - OldTopEdge; size_dx = NewWidth - OldWidth; size_dy = NewHeight - OldHeight; LOCK_REFRESH(targetwindow->WScreen); /* jDc: intuition 68k doesn't care about that */ // if (pos_dx || pos_dy || size_dx || size_dy) // { if (size_dx || size_dy) { WindowSizeWillChange(targetwindow, size_dx, size_dy, IntuitionBase); } targetwindow->LeftEdge += pos_dx; targetwindow->TopEdge += pos_dy; #ifndef __MORPHOS__ targetwindow->RelLeftEdge += pos_dx; targetwindow->RelTopEdge += pos_dy; #endif targetwindow->Width = NewWidth; targetwindow->Height = NewHeight; targetwindow->GZZWidth = targetwindow->Width - targetwindow->BorderLeft - targetwindow->BorderRight; targetwindow->GZZHeight = targetwindow->Height - targetwindow->BorderTop - targetwindow->BorderBottom; /* check for GZZ window */ if (BLAYER(targetwindow)) { /* move outer window first */ MoveSizeLayer(BLAYER(targetwindow), pos_dx, pos_dy, size_dx, size_dy); } MoveSizeLayer(targetlayer, pos_dx, pos_dy, size_dx, size_dy); for (req = targetwindow->FirstRequest; req; req = req->OlderRequest) { struct Layer *layer = req->ReqLayer; if (layer) { int dx, dy, dw, dh; int left, top, right, bottom; left = NewLeftEdge + req->LeftEdge; top = NewTopEdge + req->TopEdge; right = left + req->Width - 1; bottom = top + req->Height - 1; if (left > NewLeftEdge + NewWidth - 1) left = NewLeftEdge + NewWidth - 1; if (top > NewTopEdge + NewHeight - 1) top = NewTopEdge + NewHeight - 1; if (right > NewLeftEdge + NewWidth - 1) right = NewLeftEdge + NewWidth - 1; if (bottom > NewTopEdge + NewHeight - 1) bottom = NewTopEdge + NewHeight - 1; dx = left - layer->bounds.MinX; dy = top - layer->bounds.MinY; dw = right - left - layer->bounds.MaxX + layer->bounds.MinX; dh = bottom - top - layer->bounds.MaxY + layer->bounds.MinY; MoveSizeLayer(layer, dx, dy, dw, dh); } } #if 0 if (w->ZipLeftEdge != ~0) w->ZipLeftEdge = OldLeftEdge; if (w->ZipTopEdge != ~0) w->ZipTopEdge = OldTopEdge; if (w->ZipWidth != ~0) w->ZipWidth = OldWidth; if (w->ZipHeight != ~0) w->ZipHeight = OldHeight; #endif if (pos_dx || pos_dy) { UpdateMouseCoords(targetwindow); #ifndef __MORPHOS__ if (HAS_CHILDREN(targetwindow)) move_family(targetwindow, pos_dx, pos_dy); #endif } // } /* if (pos_dx || pos_dy || size_dx || size_dy) */ if (size_dx || size_dy) { WindowSizeHasChanged(targetwindow, size_dx, size_dy, FALSE, IntuitionBase); } ih_fire_intuimessage(targetwindow, IDCMP_CHANGEWINDOW, CWCODE_MOVESIZE, targetwindow, IntuitionBase); if (send_newsize) { /* Send IDCMP_NEWSIZE and IDCMP_CHANGEWINDOW to resized window, even if there was no resizing/position change at all. BGUI for example relies on this! */ ih_fire_intuimessage(targetwindow, IDCMP_NEWSIZE, 0, targetwindow, IntuitionBase); if ((ie = AllocInputEvent(iihdata))) { ie->ie_Class = IECLASS_EVENT; ie->ie_Code = IECODE_NEWSIZE; ie->ie_EventAddress = targetwindow; CurrentTime(&ie->ie_TimeStamp.tv_secs, &ie->ie_TimeStamp.tv_micro); } } // jDc: CheckLayers calls LOCK_REFRESH, so there's no reason to UNLOCK here! // UNLOCK_REFRESH(targetwindow->WScreen); CheckLayers(targetwindow->WScreen, IntuitionBase); UNLOCK_REFRESH(targetwindow->WScreen); #if 0 if (size_dx || size_dy) { if (!(((struct IntWindow *)targetwindow)->CustomShape)) { struct wdpWindowShape shapemsg; struct Region *shape; shapemsg.MethodID = WDM_WINDOWSHAPE; shapemsg.wdp_Width = targetwindow->Width; shapemsg.wdp_Height = targetwindow->Height; shapemsg.wdp_Window = targetwindow; shapemsg.wdp_TrueColor = (((struct IntScreen *)targetwindow->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR); shapemsg.wdp_UserBuffer = ((struct IntWindow *)targetwindow)->DecorUserBuffer; shape = DoMethodA(((struct IntScreen *)(targetwindow->WScreen))->WinDecorObj, (Msg)&shapemsg); if (((struct IntWindow *)targetwindow)->OutlineShape) DisposeRegion(((struct IntWindow *)targetwindow)->OutlineShape); ((struct IntWindow *)targetwindow)->OutlineShape = shape; ChangeWindowShape(targetwindow, shape, NULL); ((struct IntWindow *)targetwindow)->CustomShape = FALSE; } } #endif }