AddDialog::AddDialog(QWidget *parent, bf_chain_t chain) : QDialog(parent), ui(new Ui::AddDialog) { ui->setupUi(this); ui->leSourceHostIP->setEnabled(false); ui->leSourcePort->setValidator(new QIntValidator(0,65535)); setChain(chain); // QRegExp rx("\\b(([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d?\\d|2[0-4]\\d|25[0-5])\\b"); QString Octet = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"; ui->leSourceHostIP->setValidator(new QRegExpValidator( QRegExp("^" + Octet + "\\." + Octet + "\\." + Octet + "\\." + Octet + "$"), this)); connect(ui->rbAnyone,SIGNAL(toggled(bool)),SLOT(rbAnyone_toggled(bool))); connect(ui->rbHostname,SIGNAL(toggled(bool)),SLOT(rbHostname_toggled(bool))); QString title = QString("Add new %1 rule").arg(chain==CHAIN_INPUT?"inbound":"outbound"); setWindowTitle(title); QStringList sl; sl << "UDP" << "TCP"; ui->cbProto->addItems(sl); }
OVR_PUBLIC_FUNCTION(ovrResult) ovrHmd_CreateSwapTextureSetD3D11(ovrHmd hmd, ID3D11Device* device, const D3D11_TEXTURE2D_DESC* desc, ovrSwapTextureSet** outTextureSet) { BOOST_LOG_TRIVIAL(trace) << "ovrHmd_CreateSwapTextureSetD3D11 format " << desc->Format << " samples " << desc->SampleDesc.Count << " bindflags " << desc->BindFlags << " miscflags " << desc->MiscFlags; D3D11_TEXTURE2D_DESC descClone; memcpy(&descClone, desc, sizeof(D3D11_TEXTURE2D_DESC)); ovrTextureSwapChainDesc1_3 d; d.Type = ovrTexture_2D; d.ArraySize = desc->ArraySize; d.Format = getOVRFormat(desc->Format); if (d.Format == 0) { BOOST_LOG_TRIVIAL(error) << "ovrHmd_CreateSwapTextureSetD3D11 unknown format"; return -1; } d.Width = desc->Width; d.Height = desc->Height; d.MipLevels = desc->MipLevels; d.SampleCount = desc->SampleDesc.Count; d.MiscFlags = 0; switch (d.Format) { case OVR_FORMAT_R8G8B8A8_UNORM_SRGB: case OVR_FORMAT_B8G8R8A8_UNORM_SRGB: case OVR_FORMAT_B8G8R8X8_UNORM_SRGB: d.MiscFlags |= ovrTextureMisc_DX_Typeless; break; } if (getWrapperSettings()->srgbCorrectionEnabled) { switch (d.Format) { case OVR_FORMAT_R8G8B8A8_UNORM_SRGB: descClone.Format = DXGI_FORMAT_R8G8B8A8_UNORM; break; case OVR_FORMAT_B8G8R8A8_UNORM_SRGB: descClone.Format = DXGI_FORMAT_B8G8R8A8_UNORM; break; case OVR_FORMAT_B8G8R8X8_UNORM_SRGB: descClone.Format = DXGI_FORMAT_B8G8R8X8_UNORM; break; } } bool makeShaderView = false; d.BindFlags = 0; /*if (desc->BindFlags & D3D11_BIND_RENDER_TARGET) { d.BindFlags |= ovrTextureBind_DX_RenderTarget; } if (desc->BindFlags & D3D11_BIND_UNORDERED_ACCESS) { d.BindFlags |= ovrTextureBind_DX_UnorderedAccess; }*/ if (desc->BindFlags & D3D11_BIND_DEPTH_STENCIL) { d.MiscFlags |= ovrTextureMisc_DX_Typeless; d.BindFlags |= ovrTextureBind_DX_DepthStencil; } if (desc->BindFlags & D3D11_BIND_SHADER_RESOURCE) { makeShaderView = true; } d.StaticImage = ovrFalse; ovrTextureSwapChainWrapper* chainwrapper = (ovrTextureSwapChainWrapper*)malloc(sizeof(ovrTextureSwapChainWrapper)); device->GetImmediateContext(&chainwrapper->pContext); ovrResult result = ovr_CreateTextureSwapChainDX1_3((ovrSession1_3)hmd->Handle, (IUnknown*)device, &d, &chainwrapper->swapChain); if (!OVR_SUCCESS(result)) { BOOST_LOG_TRIVIAL(error) << "ovrHmd_CreateSwapTextureSetD3D11 could not create TextureSwapChain"; return result; } ovrSwapTextureSet* ts = (ovrSwapTextureSet*)malloc(sizeof(ovrSwapTextureSet)); setChain((ovrSession1_3)hmd->Handle, ts, chainwrapper); ovr_GetTextureSwapChainLength1_3((ovrSession1_3)hmd->Handle, chainwrapper->swapChain, &chainwrapper->textureCount); chainwrapper->textures = (ID3D11Texture2D**)calloc(chainwrapper->textureCount, sizeof(ID3D11Texture2D*)); ts->TextureCount = 2; ts->CurrentIndex = 0; ts->Textures = (ovrTexture*)calloc(ts->TextureCount, sizeof(ovrD3D11Texture)); for (int i = 0; i < chainwrapper->textureCount; ++i) { result = ovr_GetTextureSwapChainBufferDX1_3((ovrSession1_3)hmd->Handle, chainwrapper->swapChain, i, IID_ID3D11Texture2D, (void**)&chainwrapper->textures[i]); if (!OVR_SUCCESS(result)) { BOOST_LOG_TRIVIAL(error) << "ovrHmd_CreateSwapTextureSetD3D11 could not allocate TextureSwapChainBuffer"; return result; } } for (int i = 0;i < 2;i++) { ovrD3D11Texture* ovrtext = (ovrD3D11Texture*)&ts->Textures[i]; HRESULT hr = device->CreateTexture2D(&descClone, nullptr, &ovrtext->D3D11.pTexture); if (hr < 0) { BOOST_LOG_TRIVIAL(error) << "ovrHmd_CreateSwapTextureSetD3D11 could create texture"; return ovrError_ServiceError; } if (makeShaderView) { HRESULT rs; D3D11_SHADER_RESOURCE_VIEW_DESC depthSrv; ZeroMemory(&depthSrv, sizeof(D3D11_SHADER_RESOURCE_VIEW_DESC)); depthSrv.Format = getShaderResourceFormat(descClone.Format); depthSrv.ViewDimension = desc->SampleDesc.Count > 1 ? D3D11_SRV_DIMENSION_TEXTURE2DMS : D3D11_SRV_DIMENSION_TEXTURE2D; depthSrv.Texture2D.MostDetailedMip = 0; depthSrv.Texture2D.MipLevels = desc->MipLevels; rs = device->CreateShaderResourceView((ID3D11Resource*)ovrtext->D3D11.pTexture, &depthSrv, &(ovrtext->D3D11.pSRView)); if (rs < 0) { BOOST_LOG_TRIVIAL(error) << "ovrHmd_CreateSwapTextureSetD3D11 could not create ShaderResourceView"; return ovrError_ServiceError; } } ovrtext->D3D11.Header.API = ovrRenderAPI_D3D11; ovrtext->D3D11.Header.TextureSize.w = d.Width; ovrtext->D3D11.Header.TextureSize.h = d.Height; } *outTextureSet = ts; return result; }