shichao Posted March 5, 2019 Share Posted March 5, 2019 i want to use share texture with a mutex lock, so i use the device created in unigine, and create a texture with MiscFlags is D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX. so it return E_INVALIDARG. but i use D3D11_RESOURCE_MISC_SHARED is ok. and i found in the \engine\framework\direct3d11\D3D11RenderContext.cpp . the device is created after this functions called CreateDXGIFactory -> DXGIFactory->EnumAdapters -> D3D11CreateDevice . use this device to create a D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX texture is also return E_INVALIDARG. how should i do to create this texture in unigine? IDXGIFactory * DXGIFactory; IDXGIAdapter * Adapter; if ((CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&DXGIFactory)))) return 0; if ((DXGIFactory->EnumAdapters(0, &Adapter))) return 0; if ((D3D11CreateDevice(Adapter, Adapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, &g_pd3dDevice, NULL, &g_pImmediateContext))) return 0; ID3D11Texture2D* pd3d11Texture2DShared = nullptr; HRESULT hhh; ID3D11Device* pd3d11Device = g_pd3dDevice; D3D11_TEXTURE2D_DESC sharedTextureDesc; ZeroMemory(&sharedTextureDesc, sizeof(sharedTextureDesc)); sharedTextureDesc.Width = 1920; sharedTextureDesc.Height = 1080; sharedTextureDesc.MipLevels = 1; sharedTextureDesc.ArraySize = 1; sharedTextureDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; sharedTextureDesc.SampleDesc.Count = 1; sharedTextureDesc.Usage = D3D11_USAGE_DEFAULT; sharedTextureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; sharedTextureDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX; hhh = pd3d11Device->CreateTexture2D(&sharedTextureDesc, NULL, &pd3d11Texture2DShared); Link to comment
silent Posted March 5, 2019 Share Posted March 5, 2019 shichao It seems that's D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX is fully supported under Windows 8+ and DirectX 11.1. We do support only DirectX 11.0 features due to compatibility issues (and especially between DX / GL methods). Right now you can try to use Texture::fromD3D11Texture2D() method to convert such texture to the engine internal format (for example, if you need to use this texture in shader). Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts