bool FGoogleVRHMDCustomPresent::AllocateRenderTargetTexture(uint32 Index, uint32 SizeX, uint32 SizeY, uint8 Format, uint32 NumMips, uint32 InFlags, uint32 TargetableTextureFlags, FTexture2DRHIRef& OutTargetableTexture, FTexture2DRHIRef& OutShaderResourceTexture, uint32 NumSamples) { check(SizeX != 0 && SizeY != 0); InFlags |= TargetableTextureFlags; FOpenGLDynamicRHI* GLRHI = static_cast<FOpenGLDynamicRHI*>(GDynamicRHI); TextureSet = FGoogleVRHMDTexture2DSet::CreateTexture2DSet( GLRHI, SizeX, SizeY, 1, EPixelFormat(Format), TexCreate_RenderTargetable | TexCreate_ShaderResource ); if(!TextureSet.IsValid()) { return false; } OutTargetableTexture = TextureSet->GetTexture2D(); OutShaderResourceTexture = TextureSet->GetTexture2D(); return true; }
bool FOculusRiftHMD::D3D11Bridge::AllocateRenderTargetTexture(uint32 SizeX, uint32 SizeY, uint8 Format, uint32 NumMips, uint32 Flags, uint32 TargetableTextureFlags, FTexture2DRHIRef& OutTargetableTexture, FTexture2DRHIRef& OutShaderResourceTexture, uint32 NumSamples) { check(SizeX != 0 && SizeY != 0); if (!ColorTextureSet || (ColorTextureSet->GetSizeX() != SizeX || ColorTextureSet->GetSizeY() != SizeY || ColorTextureSet->GetFormat() != Format)) { bNeedReAllocateTextureSet = true; } if (Hmd && bNeedReAllocateTextureSet) { auto D3D11RHI = static_cast<FD3D11DynamicRHI*>(GDynamicRHI); if (ColorTextureSet) { ColorTextureSet->ReleaseResources(Hmd); ColorTextureSet = nullptr; } ID3D11Device* D3DDevice = D3D11RHI->GetDevice(); const DXGI_FORMAT PlatformResourceFormat = (DXGI_FORMAT)GPixelFormats[Format].PlatformFormat; D3D11_TEXTURE2D_DESC dsDesc; dsDesc.Width = SizeX; dsDesc.Height = SizeY; dsDesc.MipLevels = 1; dsDesc.ArraySize = 1; dsDesc.Format = PlatformResourceFormat; //DXGI_FORMAT_B8G8R8A8_UNORM; dsDesc.SampleDesc.Count = 1; dsDesc.SampleDesc.Quality = 0; dsDesc.Usage = D3D11_USAGE_DEFAULT; dsDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; dsDesc.CPUAccessFlags = 0; dsDesc.MiscFlags = 0; ovrSwapTextureSet* textureSet; ovrHmd_CreateSwapTextureSetD3D11(Hmd, D3DDevice, &dsDesc, &textureSet); if (!textureSet) { UE_LOG(LogHMD, Error, TEXT("Can't create swap texture set (size %d x %d)"), SizeX, SizeY); return false; } bNeedReAllocateTextureSet = false; bNeedReAllocateMirrorTexture = true; UE_LOG(LogHMD, Log, TEXT("Allocated a new swap texture set (size %d x %d)"), SizeX, SizeY); ColorTextureSet = FD3D11Texture2DSet::D3D11CreateTexture2DSet( D3D11RHI, textureSet, dsDesc, EPixelFormat(Format), TexCreate_RenderTargetable | TexCreate_ShaderResource ); } OutTargetableTexture = ColorTextureSet->GetTexture2D(); OutShaderResourceTexture = ColorTextureSet->GetTexture2D(); return true; }
//--------------------------------------------------------------------------------------- void LomseDoorway::init_library(int pixel_format, int ppi, bool reverse_y_axis, ostream& reporter) { m_platform.pixel_format = EPixelFormat(pixel_format); m_platform.flip_y = reverse_y_axis; m_platform.screen_ppi = float(ppi); m_pLibraryScope = LOMSE_NEW LibraryScope(reporter, this); // m_pLibraryScope->get_threads_poll(); //force to create the threads }
UTexture2DDynamic* UTexture2DDynamic::Create(int32 InSizeX, int32 InSizeY, EPixelFormat InFormat, bool InIsResolveTarget) { EPixelFormat DesiredFormat = EPixelFormat(InFormat); if (InSizeX > 0 && InSizeY > 0 ) { auto NewTexture = NewObject<UTexture2DDynamic>(GetTransientPackage(), NAME_None, RF_Transient); if (NewTexture != NULL) { // Disable compression NewTexture->CompressionSettings = TC_Default; #if WITH_EDITORONLY_DATA NewTexture->CompressionNone = true; NewTexture->MipGenSettings = TMGS_NoMipmaps; NewTexture->CompressionNoAlpha = true; NewTexture->DeferCompression = false; #endif // #if WITH_EDITORONLY_DATA if ( InIsResolveTarget ) { // NewTexture->SRGB = false; NewTexture->bNoTiling = false; } else { // Untiled format NewTexture->bNoTiling = true; } NewTexture->Init(InSizeX, InSizeY, DesiredFormat, InIsResolveTarget); } return NewTexture; } else { UE_LOG(LogTexture, Warning, TEXT("Invalid parameters specified for UTexture2DDynamic::Create()")); return NULL; } }