UE4渲染资源创建与销毁
使用的是4.26.1版本引擎
G:\svn\UnrealEngine\Engine\Binaries\Win64\UE4Editor-Win64-Debug.exe G:\svn\MyTest1\MyTest1.uproject PhysxTestMap -game -d3d11 -nothreading -forceRHIBypass -Windowed ResX=800 ResY=600
Texture2D
D3D11下Texture2D的用法
ID3D11ShaderResourceView* g_pTexture1 = NULL; ID3D11ShaderResourceView* g_pTexture2 = NULL; ID3D11SamplerState* g_pSampLinear = NULL; // PCF sampler state for shadow mapping ID3D11SamplerState* g_pPCFSamplerState = NULL; // Create Shader Resouce View (Texture2D) WCHAR str[MAX_PATH]; V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"..\\Media\\Bokeh1.dds" ) ); V_RETURN( D3DX11CreateShaderResourceViewFromFile( g_pDevice, str, NULL, NULL, &g_pTexture1, NULL ) ); // ID3D11Device* g_pDevice; V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"..\\Media\\Bokeh2.dds" ) ); V_RETURN( D3DX11CreateShaderResourceViewFromFile( g_pDevice, str, NULL, NULL, &g_pTexture2, NULL ) ); // ID3D11Device* g_pDevice; // Set Shader Resources ID3D11ShaderResourceView* arrViews[2] = { g_pTexture1, g_pTexture2}; pd3dImmediateContext->PSSetShaderResources(0, 2, arrViews);// ID3D11DeviceContext* pd3dImmediateContext // -------------------------------------------------------------- // Create sampler D3D11_SAMPLER_DESC samDesc; ZeroMemory( &samDesc, sizeof(samDesc) ); samDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; samDesc.AddressU = samDesc.AddressV = samDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; samDesc.MaxAnisotropy = 1; samDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; samDesc.MaxLOD = D3D11_FLOAT32_MAX; V_RETURN( pd3dDevice->CreateSamplerState( &samDesc, &g_pSampLinear ) ); // Create the PCF sampler state D3D11_SAMPLER_DESC samDesc2; ZeroMemory( &samDesc2, sizeof(samDesc2) ); samDesc2.Filter = D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR; samDesc2.AddressU = samDesc2.AddressV = samDesc2.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; samDesc2.MaxAnisotropy = 1; samDesc2.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL; samDesc2.MaxLOD = D3D11_FLOAT32_MAX; V_RETURN( g_pDevice->CreateSamplerState( &samDesc2, &g_pPCFSamplerState ) ); // Set render resources pd3dImmediateContext->PSSetSamplers( 0, 1, &g_pSampLinear ); // ID3D11DeviceContext* pd3dImmediateContext // Set the shadowmapping PCF sampler pd3dImmediateContext->PSSetSamplers( 2, 1, &g_pPCFSamplerState ); // ID3D11DeviceContext* pd3dImmediateContext
创建
TD3D11Texture2D<FD3D11BaseTexture2D>::TD3D11Texture2D<FD3D11BaseTexture2D>(FD3D11DynamicRHI *,ID3D11Texture2D *,ID3D11ShaderResourceView *,bool,int,const TArray<TRefCountPtr<ID3D11RenderTargetView>,TSizedDefaultAllocator<32> > &,TRefCountPtr<ID3D11DepthStencilView> *,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int,EPixelFormat,bool,ETextureCreateFlags,bool,const FClearValueBinding &) D3D11Resources.h:378 FD3D11DynamicRHI::CreateD3D11Texture2D<FD3D11BaseTexture2D>(unsigned int,unsigned int,unsigned int,bool,bool,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,FRHIResourceCreateInfo &) D3D11Texture.cpp:1019 // 会创建ShaderResourceView FD3D11DynamicRHI::RHICreateTexture2D(unsigned int,unsigned int,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,ERHIAccess,FRHIResourceCreateInfo &) D3D11Texture.cpp:1223 FD3D11DynamicRHI::RHICreateTexture2D_RenderThread(FRHICommandListImmediate &,unsigned int,unsigned int,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,ERHIAccess,FRHIResourceCreateInfo &) D3D11Texture.cpp:1237 FTexture2DResource::CreateTexture() Texture2DResource.cpp:87 FStreamableTextureResource::InitRHI() StreamableTextureResource.cpp:172 FRenderResource::InitResource() RenderResource.cpp:102 EnqueueUniqueRenderCommand<`BeginInitResource'::`2'::InitCommandName,<lambda_b5723c02a85a82cd772e604c4f4548bf> >(<lambda_b5723c02a85a82cd772e604c4f4548bf> &&) RenderingThread.h:244 BeginInitResource(FRenderResource *) RenderResource.cpp:155 UTexture::UpdateResource() Texture.cpp:165 UTexture2D::UpdateResource() Texture2D.cpp:440 UTexture::PostLoad() Texture.cpp:434 UTexture2D::PostLoad() Texture2D.cpp:377 UObject::ConditionalPostLoad() Obj.cpp:1082 EndLoad(FUObjectSerializeContext *) UObjectGlobals.cpp:1647 <lambda_331d34f2fc994df37d1cf9ee9119237a>::operator()() UObjectGlobals.cpp:1255 LoadPackageInternal(UPackage *,const wchar_t *,unsigned int,FLinkerLoad *,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1360 LoadPackage(UPackage *,const wchar_t *,unsigned int,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1458 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12865 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7ff657a2a __scrt_common_main_seh() 0x00007ff7ff657a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
BeginDestroy销毁
FTexture::ReleaseRHI() RenderResource.h:423 FStreamableTextureResource::ReleaseRHI() StreamableTextureResource.cpp:193 FRenderResource::ReleaseResource() RenderResource.cpp:119 EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4> >(<lambda_aec70190632b98f970ea922a5c9418a4> &&) RenderingThread.h:244 BeginReleaseResource(FRenderResource *) RenderResource.cpp:246 UTexture::BeginFinalReleaseResource() Texture.cpp:445 UTexture::BeginDestroy() Texture.cpp:463 UTexture2D::BeginDestroy() Texture2D.cpp:459 UObject::ConditionalBeginDestroy() Obj.cpp:963 UnhashUnreachableObjects(bool,float) GarbageCollection.cpp:2105 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2043 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
FinishDestroy销毁
FTexture2DResource::~FTexture2DResource() Texture2DResource.cpp:52 FTexture2DResource::`scalar deleting destructor'(unsigned int) 0x00007fffd8a2d798 UTexture::FinishDestroy() Texture.cpp:490 UObject::ConditionalFinishDestroy() Obj.cpp:1020 IncrementalDestroyGarbage(bool,float) GarbageCollection.cpp:1570 IncrementalPurgeGarbage(bool,float) GarbageCollection.cpp:1495 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2054 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff6ebf47a2a __scrt_common_main_seh() 0x00007ff6ebf47a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
FTexture2DRHIRef TextureTargetRHI的销毁,都是直接调用SafeRelease()将自己置空
TextureTargetRHI.SafeRelease();
RenderTarget
D3D11下RenderTarget的用法
HRESULT TextureRender::InitResource(ID3D11Device* device, int texWidth, int texHeight, bool generateMips) { // 防止重复初始化造成内存泄漏 m_pOutputTextureSRV.Reset(); // ComPtr<ID3D11ShaderResourceView> m_pOutputTextureSRV RenderToTexture的Texture的SRV m_pOutputTextureRTV.Reset(); // ComPtr<ID3D11RenderTargetView> m_pOutputTextureRTV RenderToTexture的RenderTargetView m_pOutputTextureDSV.Reset(); // ComPtr<ID3D11DepthStencilView> m_pOutputTextureDSV RenderToTexture的DepthStencilView m_pCacheRTV.Reset(); // ComPtr<ID3D11RenderTargetView> m_pCacheRTV 保存RenderToTexture之前的RenderTargetView m_pCacheDSV.Reset(); // ComPtr<ID3D11DepthStencilView> m_pCacheDSV 保存RenderToTexture之前的DepthStencilView m_GenerateMips = generateMips; // bool m_GenerateMips HRESULT hr; // ****************** // 1. 创建纹理 // ComPtr<ID3D11Texture2D> texture; D3D11_TEXTURE2D_DESC texDesc; texDesc.Width = texWidth; texDesc.Height = texHeight; texDesc.MipLevels = (m_GenerateMips ? 0 : 1); // 0为完整mipmap链 texDesc.ArraySize = 1; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; texDesc.Usage = D3D11_USAGE_DEFAULT; texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; texDesc.CPUAccessFlags = 0; texDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; // 现在texture用于新建纹理 hr = device->CreateTexture2D(&texDesc, NULL, texture.GetAddressOf()); if (FAILED(hr)) return hr; // ****************** // 2. 创建纹理对应的渲染目标视图 // D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; rtvDesc.Format = texDesc.Format; rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; rtvDesc.Texture2D.MipSlice = 0; hr = device->CreateRenderTargetView(texture.Get(), &rtvDesc, m_pOutputTextureRTV.GetAddressOf()); if (FAILED(hr)) return hr; // ****************** // 3. 创建纹理对应的着色器资源视图 // D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; srvDesc.Format = texDesc.Format; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.Texture2D.MostDetailedMip = 0; srvDesc.Texture2D.MipLevels = -1; // 使用所有的mip等级 hr = device->CreateShaderResourceView(texture.Get(), &srvDesc, m_pOutputTextureSRV.GetAddressOf()); if (FAILED(hr)) return hr; // ****************** // 4. 创建与纹理等宽高的深度/模板缓冲区和对应的视图 // texDesc.Width = texWidth; texDesc.Height = texHeight; texDesc.MipLevels = 0; texDesc.ArraySize = 1; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; texDesc.Usage = D3D11_USAGE_DEFAULT; texDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; texDesc.CPUAccessFlags = 0; texDesc.MiscFlags = 0; ComPtr<ID3D11Texture2D> depthTex; hr = device->CreateTexture2D(&texDesc, NULL, depthTex.GetAddressOf()); if (FAILED(hr)) return hr; D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; dsvDesc.Format = texDesc.Format; dsvDesc.Flags = 0; dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; dsvDesc.Texture2D.MipSlice = 0; hr = device->CreateDepthStencilView(depthTex.Get(), &dsvDesc, m_pOutputTextureDSV.GetAddressOf()); if (FAILED(hr)) return hr; // ****************** // 5. 初始化视口 // // D3D11_VIEWPORT m_OutputViewPort m_OutputViewPort.TopLeftX = 0.0f; m_OutputViewPort.TopLeftY = 0.0f; m_OutputViewPort.Width = static_cast<float>(texWidth); m_OutputViewPort.Height = static_cast<float>(texHeight); m_OutputViewPort.MinDepth = 0.0f; m_OutputViewPort.MaxDepth = 1.0f; return S_OK; } void TextureRender::Begin(ID3D11DeviceContext* deviceContext, const float backgroundColor[4]) { // 缓存RenderToTexture之前的渲染目标和深度模板视图 deviceContext->OMGetRenderTargets(1, m_pCacheRTV.GetAddressOf(), m_pCacheDSV.GetAddressOf()); // 缓存视口 unsigned int num_Viewports = 1; deviceContext->RSGetViewports(&num_Viewports, &m_CacheViewPort); // D3D11_VIEWPORT m_CacheViewPort // 清空缓冲区 deviceContext->ClearRenderTargetView(m_pOutputTextureRTV.Get(), backgroundColor); deviceContext->ClearDepthStencilView(m_pOutputTextureDSV.Get(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); // 设置渲染目标和深度模板视图 deviceContext->OMSetRenderTargets(1, m_pOutputTextureRTV.GetAddressOf(), m_pOutputTextureDSV.Get()); // 设置视口 deviceContext->RSSetViewports(1, &m_OutputViewPort); } void TextureRender::End(ID3D11DeviceContext* deviceContext) { // 恢复默认设定的染目标和深度模板视图 deviceContext->RSSetViewports(1, &m_CacheViewPort); deviceContext->OMSetRenderTargets(1, m_pCacheRTV.GetAddressOf(), m_pCacheDSV.Get()); // 若之前有指定需要mipmap链,则生成 if (m_GenerateMips) { deviceContext->GenerateMips(m_pOutputTextureSRV.Get()); } // 清空临时缓存的渲染目标视图和深度模板视图 m_pCacheDSV.Reset(); m_pCacheRTV.Reset(); } ID3D11ShaderResourceView* TextureRender::GetOutputTexture() { return m_pOutputTextureSRV.Get(); // 返回RenderToTexture的SRV } /****************************************************************************************************************/ m_pMinimapRender = std::make_unique<TextureRender>(); // std::unique_ptr<TextureRender> m_pMinimapRender HR(m_pMinimapRender->InitResource(m_pd3dDevice.Get(), 400, 400, true)); m_pMinimapRender->Begin(m_pd3dImmediateContext.Get(), Colors::Black); DrawScene(); // 绘制场景到RenderTarget上 m_pMinimapRender->End(m_pd3dImmediateContext.Get()); ID3D11ShaderResourceView * TextureResult = m_pMinimapRender->GetOutputTexture(); // 获取RenderToTexture的纹理
RenderTargetPool创建RT
RHICreateTargetableShaderResource2D(unsigned int,unsigned int,unsigned char,unsigned int,ETextureCreateFlags,ETextureCreateFlags,bool,bool,FRHIResourceCreateInfo &,TRefCountPtr<FRHITexture2D> &,TRefCountPtr<FRHITexture2D> &,unsigned int) RHIUtilities.h:664 FRenderTargetPool::FindFreeElementInternal(FRHICommandList &,const FPooledRenderTargetDesc &,const wchar_t *,bool,bool) RenderTargetPool.cpp:416 FRenderTargetPool::FindFreeElement(FRHICommandList &,const FPooledRenderTargetDesc &,TRefCountPtr<IPooledRenderTarget> &,const wchar_t *,ERenderTargetTransience,bool) RenderTargetPool.cpp:695 FSystemTextures::InitializeCommonTextures(FRHICommandListImmediate &) SystemTextures.cpp:46 FSystemTextures::InitializeTextures(FRHICommandListImmediate &,Type) SystemTextures.h:34 FRendererModule::InitializeSystemTextures(FRHICommandListImmediate &) Renderer.cpp:101 FSlateRHIRenderer::DrawWindow_RenderThread(FRHICommandListImmediate &,FViewportInfo &,FSlateWindowElementList &,const FSlateDrawWindowCommandParams &) SlateRHIRenderer.cpp:705 <lambda_5572aad9e16943e81269070aa3e3a76b>::operator()(FRHICommandListImmediate &) SlateRHIRenderer.cpp:1321 EnqueueUniqueRenderCommand<`FSlateRHIRenderer::DrawWindows_Private'::`42'::SlateDrawWindowsCommandName,<lambda_5572aad9e16943e81269070aa3e3a76b> >(<lambda_5572aad9e16943e81269070aa3e3a76b> &&) RenderingThread.h:244 FSlateRHIRenderer::DrawWindows_Private(FSlateDrawBuffer &) SlateRHIRenderer.cpp:1318 FSlateRHIRenderer::DrawWindows(FSlateDrawBuffer &) SlateRHIRenderer.cpp:1190 FSlateApplication::PrivateDrawWindows(TSharedPtr<SWindow,0>) SlateApplication.cpp:1295 FSlateApplication::DrawWindows() SlateApplication.cpp:1017 FSlateApplication::TickAndDrawWidgets(float) SlateApplication.cpp:1566 FSlateApplication::Tick(ESlateTickType) SlateApplication.cpp:1423 UGameEngine::CreateGameWindow() GameEngine.cpp:642 UGameEngine::Init(IEngineLoop *) GameEngine.cpp:1137 FEngineLoop::Init() LaunchEngineLoop.cpp:3952 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff64b1f7a1a __scrt_common_main_seh() 0x00007ff64b1f79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
特效创建RT
FD3D11DynamicRHI::CreateD3D11Texture2D<FD3D11BaseTexture2D>(unsigned int,unsigned int,unsigned int,bool,bool,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,FRHIResourceCreateInfo &) D3D11Texture.cpp:561 FD3D11DynamicRHI::RHICreateTexture2D(unsigned int,unsigned int,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,ERHIAccess,FRHIResourceCreateInfo &) D3D11Texture.cpp:1223 FD3D11DynamicRHI::RHICreateTexture2D_RenderThread(FRHICommandListImmediate &,unsigned int,unsigned int,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,ERHIAccess,FRHIResourceCreateInfo &) D3D11Texture.cpp:1237 RHICreateTargetableShaderResource2D(unsigned int,unsigned int,unsigned char,unsigned int,ETextureCreateFlags,ETextureCreateFlags,bool,bool,FRHIResourceCreateInfo &,TRefCountPtr<FRHITexture2D> &,TRefCountPtr<FRHITexture2D> &,unsigned int) RHIUtilities.h:677 FParticleStateTextures::InitRHI() ParticleGpuSimulation.cpp:251 FRenderResource::InitResource() RenderResource.cpp:102 <lambda_a5c1fb86cab753c7ea09dd43d275a40a>::operator()(FRHICommandList &) ParticleGpuSimulation.cpp:393 EnqueueUniqueRenderCommand<`FParticleSimulationResources::Init'::`2'::FInitParticleSimulationResourcesCommandName,<lambda_a5c1fb86cab753c7ea09dd43d275a40a> >(FParticleSimulationResources::<lambda_a5c1fb86cab753c7ea09dd43d275a40a> &&) RenderingThread.h:244 FFXSystem::InitGPUResources() ParticleGpuSimulation.cpp:4404 FFXSystem::InitGPUSimulation() ParticleGpuSimulation.cpp:4378 FFXSystem::FFXSystem(Type,EShaderPlatform,FGPUSortManager *) FXSystem.cpp:201 FFXSystemInterface::Create(Type,EShaderPlatform) FXSystem.cpp:37 UWorld::CreateFXSystem() World.cpp:7315 FScene::FScene(UWorld *,bool,bool,bool,Type) RendererScene.cpp:1125 FRendererModule::AllocateScene(UWorld *,bool,bool,Type) RendererScene.cpp:4460 UWorld::InitWorld(InitializationValues) World.cpp:1455 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12985 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff64b1f7a1a __scrt_common_main_seh() 0x00007ff64b1f79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
从RenderTargetPool创建SceneColor的RT
FD3D11DynamicRHI::CreateD3D11Texture2D<FD3D11BaseTexture2D>(unsigned int,unsigned int,unsigned int,bool,bool,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,FRHIResourceCreateInfo &) D3D11Texture.cpp:563 FD3D11DynamicRHI::RHICreateTexture2D(unsigned int,unsigned int,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,ERHIAccess,FRHIResourceCreateInfo &) D3D11Texture.cpp:1223 FD3D11DynamicRHI::RHICreateTexture2D_RenderThread(FRHICommandListImmediate &,unsigned int,unsigned int,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,ERHIAccess,FRHIResourceCreateInfo &) D3D11Texture.cpp:1237 RHICreateTargetableShaderResource2D(unsigned int,unsigned int,unsigned char,unsigned int,ETextureCreateFlags,ETextureCreateFlags,bool,bool,FRHIResourceCreateInfo &,TRefCountPtr<FRHITexture2D> &,TRefCountPtr<FRHITexture2D> &,unsigned int) RHIUtilities.h:677 FRenderTargetPool::FindFreeElementInternal(FRHICommandList &,const FPooledRenderTargetDesc &,const wchar_t *,bool,bool) RenderTargetPool.cpp:416 FRenderTargetPool::FindFreeElement(FRHICommandList &,const FPooledRenderTargetDesc &,TRefCountPtr<IPooledRenderTarget> &,const wchar_t *,ERenderTargetTransience,bool) RenderTargetPool.cpp:695 FSceneRenderTargets::AllocSceneColor(FRHICommandList &) SceneRenderTargets.cpp:983 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:1919 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UGameEngine::Tick(float,bool) GameEngine.cpp:1908 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff64b1f7a1a __scrt_common_main_seh() 0x00007ff64b1f79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
从RenderTargetPool创建GBuffer的RT
FD3D11DynamicRHI::CreateD3D11Texture2D<FD3D11BaseTexture2D>(unsigned int,unsigned int,unsigned int,bool,bool,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,FRHIResourceCreateInfo &) D3D11Texture.cpp:563 FD3D11DynamicRHI::RHICreateTexture2D(unsigned int,unsigned int,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,ERHIAccess,FRHIResourceCreateInfo &) D3D11Texture.cpp:1223 FD3D11DynamicRHI::RHICreateTexture2D_RenderThread(FRHICommandListImmediate &,unsigned int,unsigned int,unsigned char,unsigned int,unsigned int,ETextureCreateFlags,ERHIAccess,FRHIResourceCreateInfo &) D3D11Texture.cpp:1237 RHICreateTargetableShaderResource2D(unsigned int,unsigned int,unsigned char,unsigned int,ETextureCreateFlags,ETextureCreateFlags,bool,bool,FRHIResourceCreateInfo &,TRefCountPtr<FRHITexture2D> &,TRefCountPtr<FRHITexture2D> &,unsigned int) RHIUtilities.h:677 FRenderTargetPool::FindFreeElementInternal(FRHICommandList &,const FPooledRenderTargetDesc &,const wchar_t *,bool,bool) RenderTargetPool.cpp:416 FRenderTargetPool::FindFreeElement(FRHICommandList &,const FPooledRenderTargetDesc &,TRefCountPtr<IPooledRenderTarget> &,const wchar_t *,ERenderTargetTransience,bool) RenderTargetPool.cpp:695 FSceneRenderTargets::AllocGBufferTargets(FRHICommandList &,ETextureCreateFlags) SceneRenderTargets.cpp:1103 FSceneRenderTargets::AllocGBufferTargets(FRHICommandList &) SceneRenderTargets.cpp:1079 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:1753 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff64b1f7a1a __scrt_common_main_seh() 0x00007ff64b1f79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
VertexBuffer
D3D11下多个VertexBuffer用法
// ****************** // 5________ 6 // /| /| // /_|_____/ | // 1|4|_ _ 2|_|7 // | / | / // |/______|/ // 0 3 // ****************** // 新建顶点Position缓冲区 XMFLOAT3 vertices_positon[] = { XMFLOAT3(-1.0f, -1.0f, -1.0f), XMFLOAT3(-1.0f, 1.0f, -1.0f), XMFLOAT3(1.0f, 1.0f, -1.0f), XMFLOAT3(1.0f, -1.0f, -1.0f), XMFLOAT3(-1.0f, -1.0f, 1.0f), XMFLOAT3(-1.0f, 1.0f, 1.0f), XMFLOAT3(1.0f, 1.0f, 1.0f), XMFLOAT3(1.0f, -1.0f, 1.0f) }; // 设置顶点缓冲区描述 D3D11_BUFFER_DESC vbd1; ZeroMemory(&vbd1, sizeof(vbd1)); vbd1.Usage = D3D11_USAGE_IMMUTABLE; vbd1.ByteWidth = sizeof(vertices_positon); vbd1.BindFlags = D3D11_BIND_VERTEX_BUFFER; vbd1.CPUAccessFlags = 0; D3D11_SUBRESOURCE_DATA InitData; ZeroMemory(&InitData, sizeof(InitData)); InitData.pSysMem = vertices_positon; HR(m_pd3dDevice->CreateBuffer(&vbd1, &InitData, m_pVertexPositionBuffer.GetAddressOf())); // 新建顶点Color缓冲区 XMFLOAT4 vertices_color[] = { XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f), XMFLOAT4(1.0f, 0.0f, 0.0f, 1.0f), XMFLOAT4(1.0f, 1.0f, 0.0f, 1.0f), XMFLOAT4(0.0f, 1.0f, 0.0f, 1.0f), XMFLOAT4(0.0f, 0.0f, 1.0f, 1.0f), XMFLOAT4(1.0f, 0.0f, 1.0f, 1.0f), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f), XMFLOAT4(0.0f, 1.0f, 1.0f, 1.0f) }; // 设置顶点缓冲区描述 D3D11_BUFFER_DESC vbd2; ZeroMemory(&vbd2, sizeof(vbd2)); vbd2.Usage = D3D11_USAGE_IMMUTABLE; vbd2.ByteWidth = sizeof(vertices_color); vbd2.BindFlags = D3D11_BIND_VERTEX_BUFFER; vbd2.CPUAccessFlags = 0; D3D11_SUBRESOURCE_DATA InitData; ZeroMemory(&InitData, sizeof(InitData)); InitData.pSysMem = vertices_color; HR(m_pd3dDevice->CreateBuffer(&vbd2, &InitData, m_pVertexColorBuffer.GetAddressOf())); // 设置顶点Position缓冲区和Color缓冲区 struct MeshDataInput { std::vector<ID3D11Buffer*> pVertexBuffers; std::vector<uint32_t> strides; std::vector<uint32_t> offsets; }; MeshDataInput input; input.pVertexBuffers = { m_pVertexPositionBuffer.Get(), // ComPtr<ID3D11Buffer> m_pVertexPositionBuffer; // POSITION顶点位置Buffer m_pVertexColorBuffer.Get(), // ComPtr<ID3D11Buffer> m_pVertexColorBuffer; // COLOR颜色Buffer }; input.strides = { 12, 16 }; input.offsets = { 0, 0}; deviceContext->IASetVertexBuffers(0, (uint32_t)input.pVertexBuffers.size(), input.pVertexBuffers.data(), input.strides.data(), input.offsets.data());
StaticMesh类关系图
StaticMesh创建VertexBuffer
FD3D11DynamicRHI::RHICreateVertexBuffer(unsigned int,unsigned int,ERHIAccess,FRHIResourceCreateInfo &) D3D11VertexBuffer.cpp:119 FD3D11DynamicRHI::CreateVertexBuffer_RenderThread(FRHICommandListImmediate &,unsigned int,unsigned int,ERHIAccess,FRHIResourceCreateInfo &) D3D11VertexBuffer.cpp:129 FStaticMeshVertexBuffer::CreateTangentsRHIBuffer_Internal<1>() StaticMeshVertexBuffer.cpp:280 FStaticMeshVertexBuffer::CreateTangentsRHIBuffer_RenderThread() StaticMeshVertexBuffer.cpp:292 FStaticMeshVertexBuffer::InitRHI() StaticMeshVertexBuffer.cpp:363 FRenderResource::InitResource() RenderResource.cpp:102 FStaticMeshVertexBuffer::InitResource() StaticMeshVertexBuffer.cpp:393 EnqueueUniqueRenderCommand<`BeginInitResource'::`2'::InitCommandName,<lambda_b5723c02a85a82cd772e604c4f4548bf> >(<lambda_b5723c02a85a82cd772e604c4f4548bf> &&) RenderingThread.h:244 BeginInitResource(FRenderResource *) RenderResource.cpp:155 FStaticMeshLODResources::InitResources(UStaticMesh *) StaticMesh.cpp:1221 FStaticMeshRenderData::InitResources(Type,UStaticMesh *) StaticMesh.cpp:1611 UStaticMesh::InitResources() StaticMesh.cpp:2766 UStaticMesh::PostLoad() StaticMesh.cpp:5056 UObject::ConditionalPostLoad() Obj.cpp:1082 UBodySetup::PostLoad() BodySetup.cpp:1145 UObject::ConditionalPostLoad() Obj.cpp:1082 EndLoad(FUObjectSerializeContext *) UObjectGlobals.cpp:1647 <lambda_331d34f2fc994df37d1cf9ee9119237a>::operator()() UObjectGlobals.cpp:1255 LoadPackageInternal(UPackage *,const wchar_t *,unsigned int,FLinkerLoad *,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1360 LoadPackage(UPackage *,const wchar_t *,unsigned int,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1458 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12865 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff71c367a2a __scrt_common_main_seh() 0x00007ff71c367a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
StaticMesh BeginDestroy销毁
FStaticMeshVertexBuffer::ReleaseRHI() StaticMeshVertexBuffer.cpp:385 FRenderResource::ReleaseResource() RenderResource.cpp:119 FStaticMeshVertexBuffer::ReleaseResource() StaticMeshVertexBuffer.cpp:400 EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4> >(<lambda_aec70190632b98f970ea922a5c9418a4> &&) RenderingThread.h:244 BeginReleaseResource(FRenderResource *) RenderResource.cpp:246 FStaticMeshLODResources::ReleaseResources() StaticMesh.cpp:1317 FStaticMeshRenderData::ReleaseResources() StaticMesh.cpp:1657 UStaticMesh::ReleaseResources() StaticMesh.cpp:3076 UStaticMesh::BeginDestroy() StaticMesh.cpp:3494 UObject::ConditionalBeginDestroy() Obj.cpp:963 UnhashUnreachableObjects(bool,float) GarbageCollection.cpp:2105 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2043 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
SkeletalMesh类关系图
SkeletalMesh创建VertexBuffer
FD3D11DynamicRHI::RHICreateVertexBuffer(unsigned int,unsigned int,ERHIAccess,FRHIResourceCreateInfo &) D3D11VertexBuffer.cpp:27 FD3D11DynamicRHI::CreateVertexBuffer_RenderThread(FRHICommandListImmediate &,unsigned int,unsigned int,ERHIAccess,FRHIResourceCreateInfo &) D3D11VertexBuffer.cpp:129 FPositionVertexBuffer::CreateRHIBuffer_Internal<1>() PositionVertexBuffer.cpp:202 FPositionVertexBuffer::CreateRHIBuffer_RenderThread() PositionVertexBuffer.cpp:214 FPositionVertexBuffer::InitRHI() PositionVertexBuffer.cpp:247 FRenderResource::InitResource() RenderResource.cpp:102 EnqueueUniqueRenderCommand<`BeginInitResource'::`2'::InitCommandName,<lambda_b5723c02a85a82cd772e604c4f4548bf> >(<lambda_b5723c02a85a82cd772e604c4f4548bf> &&) RenderingThread.h:244 BeginInitResource(FRenderResource *) RenderResource.cpp:155 FSkeletalMeshLODRenderData::InitResources(bool,int,TArray<UMorphTarget *,TSizedDefaultAllocator<32> > &,USkeletalMesh *) SkeletalMeshLODRenderData.cpp:124 FSkeletalMeshRenderData::InitResources(bool,TArray<UMorphTarget *,TSizedDefaultAllocator<32> > &,USkeletalMesh *) SkeletalMeshRenderData.cpp:497 USkeletalMesh::InitResources() SkeletalMesh.cpp:861 USkeletalMesh::PostLoad() SkeletalMesh.cpp:2588 UObject::ConditionalPostLoad() Obj.cpp:1082 EndLoad(FUObjectSerializeContext *) UObjectGlobals.cpp:1647 <lambda_331d34f2fc994df37d1cf9ee9119237a>::operator()() UObjectGlobals.cpp:1255 LoadPackageInternal(UPackage *,const wchar_t *,unsigned int,FLinkerLoad *,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1360 LoadPackage(UPackage *,const wchar_t *,unsigned int,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1458 ResolveName(UObject *&,FString &,bool,bool,unsigned int,const FLinkerInstancingContext *) UObjectGlobals.cpp:787 StaticLoadObjectInternal(UClass *,UObject *,const wchar_t *,const wchar_t *,unsigned int,UPackageMap *,bool,const FLinkerInstancingContext *) UObjectGlobals.cpp:848 StaticLoadObject(UClass *,UObject *,const wchar_t *,const wchar_t *,unsigned int,UPackageMap *,bool,const FLinkerInstancingContext *) UObjectGlobals.cpp:924 StaticLoadClass(UClass *,UObject *,const wchar_t *,const wchar_t *,unsigned int,UPackageMap *) UObjectGlobals.cpp:957 ConstructorHelpersInternal::FindOrLoadClass(FString &,UClass *) ConstructorHelpers.h:87 ConstructorHelpers::FClassFinder<APawn>::FClassFinder<APawn>(const wchar_t *) ConstructorHelpers.h:188 AMyTest1GameMode::AMyTest1GameMode() MyTest1GameMode.cpp:10 InternalConstructor<AMyTest1GameMode>(const FObjectInitializer &) Class.h:3307 UClass::CreateDefaultObject() Class.cpp:3707 UObjectLoadAllCompiledInDefaultProperties() UObjectBase.cpp:907 ProcessNewlyLoadedUObjects(FName,bool) UObjectBase.cpp:996 TBaseStaticDelegateInstance<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::ExecuteIfSafe(FName,bool) DelegateInstancesImpl.h:729 TMulticastDelegate<void __cdecl(FName,bool),FDefaultDelegateUserPolicy>::Broadcast(FName,bool) DelegateSignatureImpl.inl:955 FModuleManager::LoadModuleWithFailureReason(FName,EModuleLoadResult &) ModuleManager.cpp:516 FModuleDescriptor::LoadModulesForPhase(Type,const TArray<FModuleDescriptor,TSizedDefaultAllocator<32> > &,TMap<FName,enum EModuleLoadResult,FDefaultSetAllocator,TDefaultMapHashableKeyFuncs<FName,enum EModuleLoadResult,0> > &) ModuleDescriptor.cpp:560 FProjectManager::LoadModulesForProject(Type) ProjectManager.cpp:60 FEngineLoop::LoadStartupModules() LaunchEngineLoop.cpp:3815 FEngineLoop::PreInitPostStartupScreen(const wchar_t *) LaunchEngineLoop.cpp:3198 FEngineLoop::PreInit(const wchar_t *) LaunchEngineLoop.cpp:3591 EnginePreInit(const wchar_t *) Launch.cpp:42 GuardedMain(const wchar_t *) Launch.cpp:127 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff64b1f7a1a __scrt_common_main_seh() 0x00007ff64b1f79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
SkeletalMesh BeginDestroy销毁
UE4Editor-RenderCore-Win64-Debug.dll!FVertexBuffer::ReleaseRHI() Line 509 C++ UE4Editor-Engine-Win64-Debug.dll!FPositionVertexBuffer::ReleaseRHI() Line 272 C++ UE4Editor-RenderCore-Win64-Debug.dll!FRenderResource::ReleaseResource() Line 120 C++ UE4Editor-RenderCore-Win64-Debug.dll!EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4>>(BeginReleaseResource::__l2::<lambda_aec70190632b98f970ea922a5c9418a4> && Lambda={...}) Line 245 C++ UE4Editor-RenderCore-Win64-Debug.dll!BeginReleaseResource(FRenderResource * Resource=0x00000272156eb2c8) Line 251 C++ UE4Editor-Engine-Win64-Debug.dll!FSkeletalMeshLODRenderData::ReleaseResources() Line 256 C++ UE4Editor-Engine-Win64-Debug.dll!FSkeletalMeshRenderData::ReleaseResources() Line 519 C++ UE4Editor-Engine-Win64-Debug.dll!USkeletalMesh::ReleaseResources() Line 885 C++ UE4Editor-Engine-Win64-Debug.dll!USkeletalMesh::BeginDestroy() Line 1402 C++ UE4Editor-CoreUObject-Win64-Debug.dll!UObject::ConditionalBeginDestroy() Line 996 C++ UE4Editor-CoreUObject-Win64-Debug.dll!UnhashUnreachableObjects(bool bUseTimeLimit=false, float TimeLimit=0.00200000009) Line 2108 C++ UE4Editor-CoreUObject-Win64-Debug.dll!IncrementalPurgeGarbage(bool bUseTimeLimit=false, float TimeLimit=0.00200000009) Line 1485 C++ UE4Editor-CoreUObject-Win64-Debug.dll!StaticExit() Line 4528 C++ UE4Editor-CoreUObject-Win64-Debug.dll!TBaseStaticDelegateInstance<void __cdecl(void),FDefaultDelegateUserPolicy>::ExecuteIfSafe() Line 731 C++ UE4Editor-Win64-Debug.exe!TMulticastDelegate<void __cdecl(void),FDefaultDelegateUserPolicy>::Broadcast() Line 955 C++ UE4Editor-Win64-Debug.exe!FEngineLoop::AppPreExit() Line 5719 C++ UE4Editor-Win64-Debug.exe!FEngineLoop::Exit() Line 4184 C++ UE4Editor-Win64-Debug.exe!EngineExit() Line 74 C++ UE4Editor-Win64-Debug.exe!GuardedMain(const wchar_t * CmdLine=0x0000027195372f80) Line 182 C++ UE4Editor-Win64-Debug.exe!WinMain(HINSTANCE__ * hInInstance=0x00007ff699450000, HINSTANCE__ * hPrevInstance=0x0000000000000000, char * __formal=0x0000027191074e46, int nCmdShow=10) Line 257 C++ [Inline Frame] UE4Editor-Win64-Debug.exe!invoke_main() Line 102 C++ UE4Editor-Win64-Debug.exe!__scrt_common_main_seh() Line 288 C++ kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown
FSkeletalMeshObjectGPUSkin创建VertexBuffer
UE4Editor-Engine-Win64-Debug.dll!FPositionVertexBuffer::InitRHI() Line 250 C++ UE4Editor-RenderCore-Win64-Debug.dll!FRenderResource::InitResource() Line 102 C++ UE4Editor-RenderCore-Win64-Debug.dll!EnqueueUniqueRenderCommand<`BeginInitResource'::`2'::InitCommandName,<lambda_b5723c02a85a82cd772e604c4f4548bf>>(BeginInitResource::__l2::<lambda_b5723c02a85a82cd772e604c4f4548bf> && Lambda={...}) Line 245 C++ UE4Editor-RenderCore-Win64-Debug.dll!BeginInitResource(FRenderResource * Resource=0x000001ccb2892ef0) Line 160 C++ UE4Editor-Engine-Win64-Debug.dll!FSkeletalMeshObjectGPUSkin::FSkeletalMeshObjectLOD::InitResources(unsigned int VertexOffsetUsage=0, const FSkeletalMeshObject::FSkelMeshObjectLODInfo & MeshLODInfo={...}, FSkelMeshComponentLODInfo * CompLODInfo=0x000001ccb28e9440, ERHIFeatureLevel::Type InFeatureLevel=SM5) Line 1775 C++ UE4Editor-Engine-Win64-Debug.dll!FSkeletalMeshObjectGPUSkin::InitResources(USkinnedMeshComponent * InMeshComponent=0x000001cd16c8eb00) Line 194 C++ UE4Editor-Engine-Win64-Debug.dll!FSkeletalMeshObjectGPUSkin::FSkeletalMeshObjectGPUSkin(USkinnedMeshComponent * InMeshComponent=0x000001cd16c8eb00, FSkeletalMeshRenderData * InSkelMeshRenderData=0x000001cd1594a440, ERHIFeatureLevel::Type InFeatureLevel=SM5) Line 158 C++ UE4Editor-Engine-Win64-Debug.dll!USkinnedMeshComponent::CreateRenderState_Concurrent(FRegisterComponentContext * Context=0x000000867d377d18) Line 560 C++ UE4Editor-Engine-Win64-Debug.dll!UActorComponent::ExecuteRegisterEvents(FRegisterComponentContext * Context=0x000000867d377d18) Line 1533 C++ UE4Editor-Engine-Win64-Debug.dll!UActorComponent::RegisterComponentWithWorld(UWorld * InWorld=0x000001cc918d8100, FRegisterComponentContext * Context=0x000000867d377d18) Line 1223 C++ UE4Editor-Engine-Win64-Debug.dll!AActor::IncrementalRegisterComponents(int NumComponentsToRegister=2147483647, FRegisterComponentContext * Context=0x000000867d377d18) Line 4582 C++ UE4Editor-Engine-Win64-Debug.dll!ULevel::IncrementalUpdateComponents(int NumComponentsToUpdate=0, bool bRerunConstructionScripts=true, FRegisterComponentContext * Context=0x000000867d377d18) Line 1094 C++ UE4Editor-Engine-Win64-Debug.dll!ULevel::UpdateLevelComponents(bool bRerunConstructionScripts=true, FRegisterComponentContext * Context=0x000000867d377d18) Line 971 C++ UE4Editor-Engine-Win64-Debug.dll!UWorld::UpdateWorldComponents(bool bRerunConstructionScripts=true, bool bCurrentLevelOnly=true, FRegisterComponentContext * Context=0x000000867d377d18) Line 1963 C++ UE4Editor-Engine-Win64-Debug.dll!UWorld::InitializeActorsForPlay(const FURL & InURL={...}, bool bResetTime=true, FRegisterComponentContext * Context=0x000000867d377d18) Line 4202 C++ UE4Editor-Engine-Win64-Debug.dll!UEngine::LoadMap(FWorldContext & WorldContext={...}, FURL URL={...}, UPendingNetGame * Pending=0x0000000000000000, FString & Error={...}) Line 13058 C++ UE4Editor-Engine-Win64-Debug.dll!UEngine::Browse(FWorldContext & WorldContext={...}, FURL URL={...}, FString & Error={...}) Line 12303 C++ UE4Editor-Engine-Win64-Debug.dll!UGameInstance::StartGameInstance() Line 580 C++ UE4Editor-Engine-Win64-Debug.dll!UGameEngine::Start() Line 1167 C++ UE4Editor-Win64-Debug.exe!FEngineLoop::Init() Line 3989 C++ UE4Editor-Win64-Debug.exe!EngineInit() Line 52 C++ UE4Editor-Win64-Debug.exe!GuardedMain(const wchar_t * CmdLine=0x000001cc90742f80) Line 153 C++ UE4Editor-Win64-Debug.exe!WinMain(HINSTANCE__ * hInInstance=0x00007ff699450000, HINSTANCE__ * hPrevInstance=0x0000000000000000, char * __formal=0x000001cc8c3a4e46, int nCmdShow=10) Line 257 C++ [Inline Frame] UE4Editor-Win64-Debug.exe!invoke_main() Line 102 C++ UE4Editor-Win64-Debug.exe!__scrt_common_main_seh() Line 288 C++ kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown
FSkeletalMeshObjectGPUSkin销毁VertexBuffer
FVertexBuffer::ReleaseRHI() RenderResource.h:510 FPositionVertexBuffer::ReleaseRHI() PositionVertexBuffer.cpp:271 FRenderResource::ReleaseResource() RenderResource.cpp:119 EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4> >(<lambda_aec70190632b98f970ea922a5c9418a4> &&) RenderingThread.h:244 BeginReleaseResource(FRenderResource *) RenderResource.cpp:246 FSkeletalMeshObjectGPUSkin::FSkeletalMeshObjectLOD::ReleaseResources() SkeletalRenderGPUSkin.cpp:1795 FSkeletalMeshObjectGPUSkin::ReleaseResources() SkeletalRenderGPUSkin.cpp:209 USkinnedMeshComponent::DestroyRenderState_Concurrent() SkinnedMeshComponent.cpp:627 UActorComponent::ExecuteUnregisterEvents() ActorComponent.cpp:1548 UActorComponent::UnregisterComponent() ActorComponent.cpp:1300 AActor::UnregisterAllComponents(bool) Actor.cpp:4498 UWorld::DestroyActor(AActor *,bool,bool) LevelActor.cpp:807 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12709 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
IndexBuffer
D3D11下IndexBuffer用法
// ****************** // 索引数组 // // 设置立方体顶点 // 5________ 6 // /| /| // /_|_____/ | // 1|4|_ _ 2|_|7 // | / | / // |/______|/ // 0 3 DWORD indices[] = { // 立方体顶点索引 // 正面 0, 1, 2, 2, 3, 0, // 左面 4, 5, 1, 1, 0, 4, // 顶面 1, 5, 6, 6, 2, 1, // 背面 7, 6, 5, 5, 4, 7, // 右面 3, 2, 6, 6, 7, 3, // 底面 4, 0, 3, 3, 7, 4 }; // 设置索引缓冲区描述 D3D11_BUFFER_DESC ibd; ZeroMemory(&ibd, sizeof(ibd)); ibd.Usage = D3D11_USAGE_IMMUTABLE; ibd.ByteWidth = sizeof(indices); ibd.BindFlags = D3D11_BIND_INDEX_BUFFER; ibd.CPUAccessFlags = 0; // 新建索引缓冲区 D3D11_SUBRESOURCE_DATA InitData; ZeroMemory(&InitData, sizeof(InitData)); InitData.pSysMem = indices; HR(m_pd3dDevice->CreateBuffer(&ibd, &InitData, pIndexBuffer.GetAddressOf())); // ComPtr<ID3D11Buffer> pIndexBuffer; // 设置IndexBuffer发起DrawCall m_pd3dDevice->IASetIndexBuffer(pIndexBuffer, DXGI_FORMAT_R16_UINT, 0); m_pd3dDevice->DrawIndexed(sizeof(indices)/sizeof(DWORD), 0, 0);
StaticMesh创建
FD3D11DynamicRHI::RHICreateIndexBuffer(unsigned int,unsigned int,unsigned int,ERHIAccess,FRHIResourceCreateInfo &) D3D11IndexBuffer.cpp:24 FD3D11DynamicRHI::CreateIndexBuffer_RenderThread(FRHICommandListImmediate &,unsigned int,unsigned int,unsigned int,ERHIAccess,FRHIResourceCreateInfo &) D3D11IndexBuffer.cpp:94 FRawStaticIndexBuffer::CreateRHIBuffer_Internal<1>() RawIndexBuffer.cpp:336 FRawStaticIndexBuffer::CreateRHIBuffer_RenderThread() RawIndexBuffer.cpp:348 FRawStaticIndexBuffer::InitRHI() RawIndexBuffer.cpp:374 FRenderResource::InitResource() RenderResource.cpp:102 EnqueueUniqueRenderCommand<`BeginInitResource'::`2'::InitCommandName,<lambda_b5723c02a85a82cd772e604c4f4548bf> >(<lambda_b5723c02a85a82cd772e604c4f4548bf> &&) RenderingThread.h:244 BeginInitResource(FRenderResource *) RenderResource.cpp:155 FStaticMeshLODResources::InitResources(UStaticMesh *) StaticMesh.cpp:1230 FStaticMeshRenderData::InitResources(Type,UStaticMesh *) StaticMesh.cpp:1611 UStaticMesh::InitResources() StaticMesh.cpp:2766 UStaticMesh::PostLoad() StaticMesh.cpp:5056 UObject::ConditionalPostLoad() Obj.cpp:1082 UBodySetup::PostLoad() BodySetup.cpp:1145 UObject::ConditionalPostLoad() Obj.cpp:1082 EndLoad(FUObjectSerializeContext *) UObjectGlobals.cpp:1647 <lambda_331d34f2fc994df37d1cf9ee9119237a>::operator()() UObjectGlobals.cpp:1255 LoadPackageInternal(UPackage *,const wchar_t *,unsigned int,FLinkerLoad *,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1360 LoadPackage(UPackage *,const wchar_t *,unsigned int,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1458 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12865 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff71c367a2a __scrt_common_main_seh() 0x00007ff71c367a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
BeginDestroy销毁
FIndexBuffer::ReleaseRHI() RenderResource.h:617 FRenderResource::ReleaseResource() RenderResource.cpp:119 EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4> >(<lambda_aec70190632b98f970ea922a5c9418a4> &&) RenderingThread.h:244 BeginReleaseResource(FRenderResource *) RenderResource.cpp:246 FStaticMeshLODResources::ReleaseResources() StaticMesh.cpp:1315 FStaticMeshRenderData::ReleaseResources() StaticMesh.cpp:1657 UStaticMesh::ReleaseResources() StaticMesh.cpp:3076 UStaticMesh::BeginDestroy() StaticMesh.cpp:3494 UObject::ConditionalBeginDestroy() Obj.cpp:963 UnhashUnreachableObjects(bool,float) GarbageCollection.cpp:2105 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2043 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
UniformBuffer
D3D11下UniformBuffer用法
struct CBChangesEveryDrawing { DirectX::XMMATRIX world; DirectX::XMMATRIX worldInvTranspose; }; struct CBChangesEveryFrame { DirectX::XMMATRIX view; DirectX::XMFLOAT4 eyePos; }; struct CBChangesRarely { DirectionalLight dirLight[10]; PointLight pointLight[10]; SpotLight spotLight[10]; Material material; int numDirLight; int numPointLight; int numSpotLight; float pad; // 打包保证16字节对齐 }; bool InitResource() { // ... ... // 设置常量缓冲区描述 D3D11_BUFFER_DESC cbd; ZeroMemory(&cbd, sizeof(cbd)); cbd.Usage = D3D11_USAGE_DYNAMIC; cbd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; cbd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // 新建用于VS和PS的常量缓冲区 cbd.ByteWidth = sizeof(CBChangesEveryDrawing); HR(m_pd3dDevice->CreateBuffer(&cbd, nullptr, m_pConstantBuffers[0].GetAddressOf())); // ComPtr<ID3D11Buffer> m_pConstantBuffers[0] cbd.ByteWidth = sizeof(CBChangesEveryFrame); HR(m_pd3dDevice->CreateBuffer(&cbd, nullptr, m_pConstantBuffers[1].GetAddressOf())); // ComPtr<ID3D11Buffer> m_pConstantBuffers[1] cbd.ByteWidth = sizeof(CBChangesRarely); HR(m_pd3dDevice->CreateBuffer(&cbd, nullptr, m_pConstantBuffers[2].GetAddressOf())); // ComPtr<ID3D11Buffer> m_pConstantBuffers[2] // 更新不容易被修改的常量缓冲区资源 D3D11_MAPPED_SUBRESOURCE mappedData; HR(m_pd3dImmediateContext->Map(m_pConstantBuffers[2].Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedData)); memcpy_s(mappedData.pData, sizeof(CBChangesRarely), &m_CBRarely, sizeof(CBChangesRarely)); m_pd3dImmediateContext->Unmap(m_pConstantBuffers[2].Get(), 0); // 预先绑定各自所需的缓冲区,其中每帧更新的缓冲区需要绑定到两个缓冲区上 m_pd3dImmediateContext->VSSetConstantBuffers(0, 1, m_pConstantBuffers[0].GetAddressOf()); m_pd3dImmediateContext->VSSetConstantBuffers(1, 1, m_pConstantBuffers[1].GetAddressOf()); m_pd3dImmediateContext->PSSetConstantBuffers(1, 1, m_pConstantBuffers[1].GetAddressOf()); m_pd3dImmediateContext->PSSetConstantBuffers(2, 1, m_pConstantBuffers[2].GetAddressOf()); return true; } void UpdateScene(float dt) { // ... ... D3D11_MAPPED_SUBRESOURCE mappedData; HR(m_pd3dImmediateContext->Map(m_pConstantBuffers[1].Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedData)); memcpy_s(mappedData.pData, sizeof(CBChangesEveryFrame), &m_CBFrame, sizeof(CBChangesEveryFrame)); m_pd3dImmediateContext->Unmap(m_pConstantBuffers[1].Get(), 0); }
创建
FD3D11DynamicRHI::RHICreateUniformBuffer(const void *,const FRHIUniformBufferLayout &,EUniformBufferUsage,EUniformBufferValidation) D3D11UniformBuffer.cpp:176 TUniformBufferRef<FLocalVertexFactoryUniformShaderParameters>::CreateUniformBufferImmediate(const FLocalVertexFactoryUniformShaderParameters &,EUniformBufferUsage,EUniformBufferValidation) ShaderParameterMacros.h:115 CreateLocalVFUniformBuffer(const FLocalVertexFactory *,unsigned int,FColorVertexBuffer *,int,int) LocalVertexFactory.cpp:98 FLocalVertexFactory::InitRHI() LocalVertexFactory.cpp:393 FRenderResource::InitResource() RenderResource.cpp:102 <lambda_365cb4744e50d1171ec01a60fe05292d>::operator()(FRHICommandListImmediate &) StaticMesh.cpp:876 EnqueueUniqueRenderCommand<`FStaticMeshVertexFactories::InitVertexFactory'::`2'::InitStaticMeshVertexFactoryName,<lambda_365cb4744e50d1171ec01a60fe05292d> >(<lambda_365cb4744e50d1171ec01a60fe05292d> &&) RenderingThread.h:244 FStaticMeshVertexFactories::InitVertexFactory(const FStaticMeshLODResources &,FLocalVertexFactory &,unsigned int,const UStaticMesh *,bool) StaticMesh.cpp:852 FStaticMeshVertexFactories::InitResources(const FStaticMeshLODResources &,unsigned int,const UStaticMesh *) StaticMesh.cpp:882 FStaticMeshRenderData::InitResources(Type,UStaticMesh *) StaticMesh.cpp:1612 UStaticMesh::InitResources() StaticMesh.cpp:2766 UStaticMesh::PostLoad() StaticMesh.cpp:5056 UObject::ConditionalPostLoad() Obj.cpp:1082 UBodySetup::PostLoad() BodySetup.cpp:1145 UObject::ConditionalPostLoad() Obj.cpp:1082 EndLoad(FUObjectSerializeContext *) UObjectGlobals.cpp:1647 <lambda_331d34f2fc994df37d1cf9ee9119237a>::operator()() UObjectGlobals.cpp:1255 LoadPackageInternal(UPackage *,const wchar_t *,unsigned int,FLinkerLoad *,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1360 LoadPackage(UPackage *,const wchar_t *,unsigned int,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1458 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12865 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff71c367a2a __scrt_common_main_seh() 0x00007ff71c367a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建
FD3D11DynamicRHI::RHICreateUniformBuffer(const void *,const FRHIUniformBufferLayout &,EUniformBufferUsage,EUniformBufferValidation) D3D11UniformBuffer.cpp:197 TUniformBufferRef<FLocalVertexFactoryUniformShaderParameters>::CreateUniformBufferImmediate(const FLocalVertexFactoryUniformShaderParameters &,EUniformBufferUsage,EUniformBufferValidation) ShaderParameterMacros.h:115 CreateLocalVFUniformBuffer(const FLocalVertexFactory *,unsigned int,FColorVertexBuffer *,int,int) LocalVertexFactory.cpp:98 FGPUSkinPassthroughVertexFactory::SetData(const FLocalVertexFactory::FDataType &) SkeletalRenderGPUSkin.cpp:1346 TGPUSkinVertexFactory<0>::CopyDataTypeForPassthroughFactory(FGPUSkinPassthroughVertexFactory *) GPUSkinVertexFactory.cpp:426 <lambda_6ace177de4d39f0f176b25996cd7d151>::operator()(FRHICommandList &) SkeletalRenderGPUSkin.cpp:1386 EnqueueUniqueRenderCommand<`CreatePassthroughVertexFactory<TGPUSkinVertexFactory<0> >'::`2'::InitPassthroughGPUSkinVertexFactoryName,<lambda_6ace177de4d39f0f176b25996cd7d151> >(CreatePassthroughVertexFactory::__l2::<lambda_6ace177de4d39f0f176b25996cd7d151> &&) RenderingThread.h:244 CreatePassthroughVertexFactory<TGPUSkinVertexFactory<0> >(Type,TArray<TUniquePtr<FGPUSkinPassthroughVertexFactory,TDefaultDelete<FGPUSkinPassthroughVertexFactory> >,TSizedDefaultAllocator<32> > &,TGPUSkinVertexFactory<0> *) SkeletalRenderGPUSkin.cpp:1383 FSkeletalMeshObjectGPUSkin::FVertexFactoryData::InitVertexFactories(const FSkeletalMeshObjectGPUSkin::FVertexFactoryBuffers &,const TArray<FSkelMeshRenderSection,TSizedDefaultAllocator<32> > &,Type) SkeletalRenderGPUSkin.cpp:1547 FSkeletalMeshObjectGPUSkin::FSkeletalMeshObjectLOD::InitResources(unsigned int,const FSkeletalMeshObject::FSkelMeshObjectLODInfo &,FSkelMeshComponentLODInfo *,Type) SkeletalRenderGPUSkin.cpp:1783 FSkeletalMeshObjectGPUSkin::InitResources(USkinnedMeshComponent *) SkeletalRenderGPUSkin.cpp:191 FSkeletalMeshObjectGPUSkin::FSkeletalMeshObjectGPUSkin(USkinnedMeshComponent *,FSkeletalMeshRenderData *,Type) SkeletalRenderGPUSkin.cpp:158 USkinnedMeshComponent::CreateRenderState_Concurrent(FRegisterComponentContext *) SkinnedMeshComponent.cpp:560 UActorComponent::ExecuteRegisterEvents(FRegisterComponentContext *) ActorComponent.cpp:1532 UActorComponent::RegisterComponentWithWorld(UWorld *,FRegisterComponentContext *) ActorComponent.cpp:1220 AActor::IncrementalRegisterComponents(int,FRegisterComponentContext *) Actor.cpp:4578 ULevel::IncrementalUpdateComponents(int,bool,FRegisterComponentContext *) Level.cpp:1094 ULevel::UpdateLevelComponents(bool,FRegisterComponentContext *) Level.cpp:970 UWorld::UpdateWorldComponents(bool,bool,FRegisterComponentContext *) World.cpp:1962 UWorld::InitializeActorsForPlay(const FURL &,bool,FRegisterComponentContext *) World.cpp:4199 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13057 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff64b1f7a1a __scrt_common_main_seh() 0x00007ff64b1f79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建
FD3D11DynamicRHI::RHICreateUniformBuffer(const void *,const FRHIUniformBufferLayout &,EUniformBufferUsage,EUniformBufferValidation) D3D11UniformBuffer.cpp:176 TUniformBufferRef<FPrimitiveUniformShaderParameters>::CreateUniformBufferImmediate(const FPrimitiveUniformShaderParameters &,EUniformBufferUsage,EUniformBufferValidation) ShaderParameterMacros.h:115 FPrimitiveSceneProxy::UpdateUniformBuffer() PrimitiveSceneProxy.cpp:389 FPrimitiveSceneProxy::SetTransform(const FMatrix &,const FBoxSphereBounds &,const FBoxSphereBounds &,FVector) PrimitiveSceneProxy.cpp:418 <lambda_1c1e2958891bd343154e60d67e022f6f>::operator()(FRHICommandListImmediate &) RendererScene.cpp:1299 EnqueueUniqueRenderCommand<`FScene::AddPrimitive'::`2'::AddPrimitiveCommandName,<lambda_1c1e2958891bd343154e60d67e022f6f> >(<lambda_1c1e2958891bd343154e60d67e022f6f> &&) RenderingThread.h:244 FScene::AddPrimitive(UPrimitiveComponent *) RendererScene.cpp:1294 UPrimitiveComponent::CreateRenderState_Concurrent(FRegisterComponentContext *) PrimitiveComponent.cpp:565 UActorComponent::ExecuteRegisterEvents(FRegisterComponentContext *) ActorComponent.cpp:1532 UActorComponent::RegisterComponentWithWorld(UWorld *,FRegisterComponentContext *) ActorComponent.cpp:1220 UWorld::UpdateWorldComponents(bool,bool,FRegisterComponentContext *) World.cpp:1930 UWorld::InitializeNewWorld(InitializationValues) World.cpp:1749 UWorld::CreateWorld(Type,bool,FName,UPackage *,bool,Type) World.cpp:1831 UGameInstance::InitializeStandalone(FName,UPackage *) GameInstance.cpp:153 UGameEngine::Init(IEngineLoop *) GameEngine.cpp:1099 FEngineLoop::Init() LaunchEngineLoop.cpp:3952 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff64b1f7a1a __scrt_common_main_seh() 0x00007ff64b1f79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
更新
UpdateUniformBufferContents(ID3D11Device *,ID3D11DeviceContext *,FD3D11UniformBuffer *,const void *,unsigned int) D3D11UniformBuffer.cpp:276 FD3D11DynamicRHI::RHIUpdateUniformBuffer(FRHIUniformBuffer *,const void *) D3D11UniformBuffer.cpp:300 FPrimitiveSceneProxy::UpdateUniformBuffer() PrimitiveSceneProxy.cpp:385 FPrimitiveSceneProxy::SetTransform(const FMatrix &,const FBoxSphereBounds &,const FBoxSphereBounds &,FVector) PrimitiveSceneProxy.cpp:418 FScene::UpdateAllPrimitiveSceneInfos(FRHICommandListImmediate &,bool) RendererScene.cpp:4150 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:1300 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff64b1f7a1a __scrt_common_main_seh() 0x00007ff64b1f79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
销毁
TUniformBuffer<FLandscapeUniformShaderParameters>::ReleaseDynamicRHI() UniformBuffer.h:80 FRenderResource::ReleaseResource() RenderResource.cpp:120 FLandscapeComponentSceneProxy::~FLandscapeComponentSceneProxy() LandscapeRender.cpp:1686 FLandscapeComponentSceneProxy::`scalar deleting destructor'(unsigned int) 0x00007fffddf35e20 FScene::UpdateAllPrimitiveSceneInfos(FRHICommandListImmediate &,bool) RendererScene.cpp:4248 <lambda_8a41acb050614d83e592284e74be1a26>::operator()(FRHICommandListImmediate &) RendererScene.cpp:3319 EnqueueUniqueRenderCommand<`FScene::Release'::`2'::FReleaseCommandName,<lambda_8a41acb050614d83e592284e74be1a26> >(<lambda_8a41acb050614d83e592284e74be1a26> &&) RenderingThread.h:244 FScene::Release() RendererScene.cpp:3315 UWorld::FinishDestroy() World.cpp:939 UObject::ConditionalFinishDestroy() Obj.cpp:1020 IncrementalDestroyGarbage(bool,float) GarbageCollection.cpp:1570 IncrementalPurgeGarbage(bool,float) GarbageCollection.cpp:1495 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2054 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
TUniformBufferRef<TBufferStruct> UniformBufferRHI的销毁,都是直接调用SafeRelease()将自己置空
UniformBufferRHI.SafeRelease();
VertexShader
D3D11下VertexShader用法
const D3D11_INPUT_ELEMENT_DESC inputLayout[3] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; ComPtr<ID3DBlob> vsBlob; HR(CreateShaderFromFile(L"HLSL\\Triangle_VS.cso", L"HLSL\\Triangle_VS.hlsl", "VS", "vs_5_0", vsBlob.ReleaseAndGetAddressOf())); HR(deviceContext->CreateVertexShader(vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), nullptr, vertexShader.GetAddressOf())); // 创建顶点着色器 ComPtr<ID3D11VertexShader> vertexShader HR(deviceContext->CreateInputLayout(inputLayout, ARRAYSIZE(inputLayout),vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), vertexLayout.GetAddressOf())); // 创建并绑定顶点布局 //ComPtr<ID3D11InputLayout> vertexLayout // 设置图元类型,设定输入布局 deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); deviceContext->IASetInputLayout(vertexLayout.Get()); // 将顶点着色器绑定到渲染管线 deviceContext->VSSetShader(vertexShader.Get(), nullptr, 0);
创建
FD3D11DynamicRHI::RHICreateVertexShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:191 FD3D11DynamicRHI::CreateVertexShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:218 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:418 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 FMinimalBoundShaderStateInput::AsBoundShaderState() MeshPassProcessor.h:144 FGraphicsMinimalPipelineStateInitializer::AsGraphicsPipelineStateInitializer() MeshPassProcessor.h:254 FMeshDrawCommand::SubmitDraw(const FMeshDrawCommand &__restrict,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,unsigned int,FRHICommandList &,FMeshDrawCommandStateCache &__restrict) MeshPassProcessor.cpp:1139 SubmitMeshDrawCommandsRange(const TArray<FVisibleMeshDrawCommand,TMemStackAllocator<0> > &,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,bool,int,int,unsigned int,FRHICommandList &) MeshPassProcessor.cpp:1256 FParallelMeshDrawCommandPass::DispatchDraw(FParallelCommandListSet *,FRHICommandList &) MeshDrawCommands.cpp:1345 <lambda_e8a3056aa5d093dacc699207dd432975>::operator()(FRHICommandList &) BasePassRendering.cpp:1200 TRDGLambdaPass<FOpaqueBasePassParameters,<lambda_e8a3056aa5d093dacc699207dd432975> >::ExecuteImpl(FRHIComputeCommandList &) RenderGraphPass.h:424 FRDGPass::Execute(FRHIComputeCommandList &) RenderGraphPass.cpp:302 FRDGBuilder::ExecutePass(FRDGPass *) RenderGraphBuilder.cpp:1591 FRDGBuilder::Execute() RenderGraphBuilder.cpp:1257 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:2612 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7d7397a3a __scrt_common_main_seh() 0x00007ff7d7397a19 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建2
FD3D11DynamicRHI::RHICreateVertexShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:191 FD3D11DynamicRHI::CreateVertexShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:218 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:418 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 TShaderRefBase<FOcclusionQueryVS,FShaderMapPointerTable>::GetRHIShaderBase(EShaderFrequency) Shader.h:886 BeginOcclusionTests(FRHICommandListImmediate &,TArrayView<FViewInfo,int>,Type,const TArray<FViewOcclusionQueries,TInlineAllocator<1,TMemStackAllocator<0> > > &,unsigned int) SceneOcclusion.cpp:1204 <lambda_c2fed0f97485c798522737d96c81424a>::operator()(FRHICommandListImmediate &) SceneOcclusion.cpp:1381 TRDGLambdaPass<FRenderTargetParameters,<lambda_c2fed0f97485c798522737d96c81424a> >::ExecuteImpl(FRHIComputeCommandList &) RenderGraphPass.h:424 FRDGPass::Execute(FRHIComputeCommandList &) RenderGraphPass.cpp:302 FRDGBuilder::ExecutePass(FRDGPass *) RenderGraphBuilder.cpp:1591 FRDGBuilder::Execute() RenderGraphBuilder.cpp:1257 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:2612 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7d7397a3a __scrt_common_main_seh() 0x00007ff7d7397a19 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建3
FD3D11DynamicRHI::RHICreateVertexShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:191 FD3D11DynamicRHI::CreateVertexShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:218 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:418 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 TShaderRefBase<FSimpleElementVS,FShaderMapPointerTable>::GetRHIShaderBase(EShaderFrequency) Shader.h:886 FBatchedElements::PrepareShaders(FRHICommandList &,FGraphicsPipelineStateInitializer &,Type,ESimpleElementBlendMode,const FMatrix &,bool,FBatchedElementParameters *,const FTexture *,bool,float,const FDepthFieldGlowInfo *,const FSceneView *) BatchedElements.cpp:543 FBatchedElements::Draw(FRHICommandList &,const FMeshPassProcessorRenderState &,Type,bool,const FSceneView &,bool,float,Type) BatchedElements.cpp:1161 FCanvasBatchedElementRenderItem::Render_RenderThread(FRHICommandListImmediate &,FMeshPassProcessorRenderState &,const FCanvas *) Canvas.cpp:399 FCanvas::Flush_RenderThread(FRHICommandListImmediate &,bool,bool) Canvas.cpp:721 FDebugCanvasDrawer::DrawRenderThread(FRHICommandListImmediate &,const void *) DebugCanvas.cpp:310 FSlateRHIRenderingPolicy::DrawElements(FRHICommandListImmediate &,FSlateBackBuffer &,TRefCountPtr<FRHITexture2D> &,TRefCountPtr<FRHITexture2D> &,TRefCountPtr<FRHITexture2D> &,int,const TArray<FSlateRenderBatch,TSizedDefaultAllocator<32> > &,const FSlateRenderingParams &) SlateRHIRenderingPolicy.cpp:1216 FSlateRHIRenderer::DrawWindow_RenderThread(FRHICommandListImmediate &,FViewportInfo &,FSlateWindowElementList &,const FSlateDrawWindowCommandParams &) SlateRHIRenderer.cpp:895 <lambda_5572aad9e16943e81269070aa3e3a76b>::operator()(FRHICommandListImmediate &) SlateRHIRenderer.cpp:1321 EnqueueUniqueRenderCommand<`FSlateRHIRenderer::DrawWindows_Private'::`42'::SlateDrawWindowsCommandName,<lambda_5572aad9e16943e81269070aa3e3a76b> >(<lambda_5572aad9e16943e81269070aa3e3a76b> &&) RenderingThread.h:244 FSlateRHIRenderer::DrawWindows_Private(FSlateDrawBuffer &) SlateRHIRenderer.cpp:1318 FSlateRHIRenderer::DrawWindows(FSlateDrawBuffer &) SlateRHIRenderer.cpp:1190 FSlateApplication::PrivateDrawWindows(TSharedPtr<SWindow,0>) SlateApplication.cpp:1295 FSlateApplication::DrawWindows() SlateApplication.cpp:1017 FSlateApplication::TickAndDrawWidgets(float) SlateApplication.cpp:1566 FSlateApplication::Tick(ESlateTickType) SlateApplication.cpp:1423 FEngineLoop::Tick() LaunchEngineLoop.cpp:4944 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7d7397a3a __scrt_common_main_seh() 0x00007ff7d7397a19 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
销毁
FShaderMapResource::ReleaseShaders() ShaderResource.cpp:329 FShaderMapResource::ReleaseRHI() ShaderResource.cpp:348 FRenderResource::ReleaseResource() RenderResource.cpp:119 EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4> >(<lambda_aec70190632b98f970ea922a5c9418a4> &&) RenderingThread.h:244 BeginReleaseResource(FRenderResource *) RenderResource.cpp:246 FShaderMapResource::Release() ShaderResource.cpp:314 FShaderMapBase::~FShaderMapBase() ShaderMap.cpp:46 FMaterialShaderMap::~FMaterialShaderMap() MaterialShader.cpp:2365 FMaterialShaderMap::`scalar deleting destructor'(unsigned int) 0x00007fffd7a85ab4 FPendingCleanupObjects::~FPendingCleanupObjects() RenderingThread.cpp:1353 FlushRenderingCommands(bool) RenderingThread.cpp:1290 UMaterialInstance::ClearAllCachedCookedPlatformData() MaterialInstance.cpp:3259 UMaterialInstance::FinishDestroy() MaterialInstance.cpp:3621 UObject::ConditionalFinishDestroy() Obj.cpp:1020 IncrementalDestroyGarbage(bool,float) GarbageCollection.cpp:1570 IncrementalPurgeGarbage(bool,float) GarbageCollection.cpp:1495 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2054 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff6ebf47a2a __scrt_common_main_seh() 0x00007ff6ebf47a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
销毁
FRHIResource::Release() RHIResources.h:52 FShaderMapResource::ReleaseShaders() ShaderResource.cpp:329 FShaderMapResource::ReleaseRHI() ShaderResource.cpp:348 FRenderResource::ReleaseResource() RenderResource.cpp:119 EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4> >(<lambda_aec70190632b98f970ea922a5c9418a4> &&) RenderingThread.h:244 BeginReleaseResource(FRenderResource *) RenderResource.cpp:246 FShaderMapResource::Release() ShaderResource.cpp:314 FMinimalBoundShaderStateInput::~FMinimalBoundShaderStateInput() 0x00007fffcc906a11 Experimental::RobinHoodHashTable_Private::TRobinHoodHashTable<FGraphicsMinimalPipelineStateInitializer,FGraphicsMinimalPipelineStateId::FRefCountedGraphicsMinimalPipelineState,TDefaultMapHashableKeyFuncs<FGraphicsMinimalPipelineStateInitializer,FGraphicsMinimalPipelineStateId::FRefCountedGraphicsMinimalPipelineState,0>,TSizedDefaultAllocator<32> >::FData::Deallocate(unsigned int) RobinHoodHashTable.h:338 Experimental::RobinHoodHashTable_Private::TRobinHoodHashTable<FGraphicsMinimalPipelineStateInitializer,FGraphicsMinimalPipelineStateId::FRefCountedGraphicsMinimalPipelineState,TDefaultMapHashableKeyFuncs<FGraphicsMinimalPipelineStateInitializer,FGraphicsMinimalPipelineStateId::FRefCountedGraphicsMinimalPipelineState,0>,TSizedDefaultAllocator<32> >::RemoveByElementId(FHashElementId) RobinHoodHashTable.h:920 FGraphicsMinimalPipelineStateId::RemovePersistentId(FGraphicsMinimalPipelineStateId) MeshPassProcessor.cpp:398 FPrimitiveSceneInfo::RemoveCachedMeshDrawCommands() PrimitiveSceneInfo.cpp:466 FPrimitiveSceneInfo::RemoveStaticMeshes() PrimitiveSceneInfo.cpp:840 FPrimitiveSceneInfo::RemoveFromScene(bool) PrimitiveSceneInfo.cpp:896 FScene::UpdateAllPrimitiveSceneInfos(FRHICommandListImmediate &,bool) RendererScene.cpp:3890 <lambda_8a41acb050614d83e592284e74be1a26>::operator()(FRHICommandListImmediate &) RendererScene.cpp:3319 EnqueueUniqueRenderCommand<`FScene::Release'::`2'::FReleaseCommandName,<lambda_8a41acb050614d83e592284e74be1a26> >(<lambda_8a41acb050614d83e592284e74be1a26> &&) RenderingThread.h:244 FScene::Release() RendererScene.cpp:3315 UWorld::FinishDestroy() World.cpp:939 UObject::ConditionalFinishDestroy() Obj.cpp:1020 IncrementalDestroyGarbage(bool,float) GarbageCollection.cpp:1570 IncrementalPurgeGarbage(bool,float) GarbageCollection.cpp:1495 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2054 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
PixelShader
D3D11下PixelShader用法
// 创建像素着色器 ComPtr<ID3DBlob> psBlob; HR(CreateShaderFromFile(L"HLSL\\Triangle_PS.cso", L"HLSL\\Triangle_PS.hlsl", "PS", "ps_5_0", psBlob.ReleaseAndGetAddressOf())); HR(deviceContext->CreatePixelShader(psBlob->GetBufferPointer(), psBlob->GetBufferSize(), nullptr, pixelShader.GetAddressOf())); // ComPtr<ID3D11PixelShader> pixelShader // 将着色器绑定到渲染管线 deviceContext->PSSetShader(pixelShader.Get(), nullptr, 0);
创建
FD3D11DynamicRHI::RHICreatePixelShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:315 FD3D11DynamicRHI::CreatePixelShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:338 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:419 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 FMinimalBoundShaderStateInput::AsBoundShaderState() MeshPassProcessor.h:144 FGraphicsMinimalPipelineStateInitializer::AsGraphicsPipelineStateInitializer() MeshPassProcessor.h:254 FMeshDrawCommand::SubmitDraw(const FMeshDrawCommand &__restrict,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,unsigned int,FRHICommandList &,FMeshDrawCommandStateCache &__restrict) MeshPassProcessor.cpp:1139 SubmitMeshDrawCommandsRange(const TArray<FVisibleMeshDrawCommand,TMemStackAllocator<0> > &,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,bool,int,int,unsigned int,FRHICommandList &) MeshPassProcessor.cpp:1256 FParallelMeshDrawCommandPass::DispatchDraw(FParallelCommandListSet *,FRHICommandList &) MeshDrawCommands.cpp:1345 FDeferredShadingSceneRenderer::RenderPrePassView(FRHICommandList &,const FViewInfo &) DepthRendering.cpp:254 FDeferredShadingSceneRenderer::RenderPrePass(FRHICommandListImmediate &,TFunctionRef<void __cdecl(void)>) DepthRendering.cpp:676 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:1702 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff71c367a2a __scrt_common_main_seh() 0x00007ff71c367a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建2
FD3D11DynamicRHI::RHICreatePixelShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:315 FD3D11DynamicRHI::CreatePixelShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:338 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:419 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 FMinimalBoundShaderStateInput::AsBoundShaderState() MeshPassProcessor.h:144 FGraphicsMinimalPipelineStateInitializer::AsGraphicsPipelineStateInitializer() MeshPassProcessor.h:254 FMeshDrawCommand::SubmitDraw(const FMeshDrawCommand &__restrict,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,unsigned int,FRHICommandList &,FMeshDrawCommandStateCache &__restrict) MeshPassProcessor.cpp:1139 SubmitMeshDrawCommandsRange(const TArray<FVisibleMeshDrawCommand,TMemStackAllocator<0> > &,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,bool,int,int,unsigned int,FRHICommandList &) MeshPassProcessor.cpp:1256 FParallelMeshDrawCommandPass::DispatchDraw(FParallelCommandListSet *,FRHICommandList &) MeshDrawCommands.cpp:1345 <lambda_e8a3056aa5d093dacc699207dd432975>::operator()(FRHICommandList &) BasePassRendering.cpp:1200 TRDGLambdaPass<FOpaqueBasePassParameters,<lambda_e8a3056aa5d093dacc699207dd432975> >::ExecuteImpl(FRHIComputeCommandList &) RenderGraphPass.h:424 FRDGPass::Execute(FRHIComputeCommandList &) RenderGraphPass.cpp:302 FRDGBuilder::ExecutePass(FRDGPass *) RenderGraphBuilder.cpp:1591 FRDGBuilder::Execute() RenderGraphBuilder.cpp:1257 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:2612 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7d7397a3a __scrt_common_main_seh() 0x00007ff7d7397a19 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建3
FD3D11DynamicRHI::RHICreatePixelShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:315 FD3D11DynamicRHI::CreatePixelShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:338 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:419 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 TShaderRefBase<FDeferredLightPS,FShaderMapPointerTable>::GetRHIShaderBase(EShaderFrequency) Shader.h:886 FDeferredShadingSceneRenderer::RenderLight(FRHICommandList &,const FLightSceneInfo *,FRHITexture *,FRHITexture *,const FHairStrandsVisibilityViews *,bool,bool) LightRendering.cpp:2290 <lambda_dc8ad83445c50dce47468eac67fa9769>::operator()(FRHICommandList &) LightRendering.cpp:2416 TRDGLambdaPass<FRenderLightParameters,<lambda_dc8ad83445c50dce47468eac67fa9769> >::ExecuteImpl(FRHIComputeCommandList &) RenderGraphPass.h:424 FRDGPass::Execute(FRHIComputeCommandList &) RenderGraphPass.cpp:302 FRDGBuilder::ExecutePass(FRDGPass *) RenderGraphBuilder.cpp:1591 FRDGBuilder::Execute() RenderGraphBuilder.cpp:1257 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:2612 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7d7397a3a __scrt_common_main_seh() 0x00007ff7d7397a19 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建4
FD3D11DynamicRHI::RHICreatePixelShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:315 FD3D11DynamicRHI::CreatePixelShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:338 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:419 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 TShaderRefBase<FShader,FShaderMapPointerTable>::GetRHIShaderBase(EShaderFrequency) Shader.h:886 SetScreenPassPipelineState(FRHICommandList &,const FScreenPassPipelineState &) ScreenPass.cpp:80 DrawScreenPass<<lambda_3b149f0b65650a717c16ce456f545061> >(FRHICommandListImmediate &,const FViewInfo &,const FScreenPassTextureViewport &,const FScreenPassTextureViewport &,const FScreenPassPipelineState &,EScreenPassDrawFlags,<lambda_3b149f0b65650a717c16ce456f545061>) ScreenPass.h:325 <lambda_c0eccb52b803befd0db977a96ba73b4d>::operator()(FRHICommandListImmediate &) ScreenPass.h:491 TRDGLambdaPass<`anonymous namespace'::FFilterPS::FParameters,<lambda_c0eccb52b803befd0db977a96ba73b4d> >::ExecuteImpl(FRHIComputeCommandList &) RenderGraphPass.h:424 FRDGPass::Execute(FRHIComputeCommandList &) RenderGraphPass.cpp:302 FRDGBuilder::ExecutePass(FRDGPass *) RenderGraphBuilder.cpp:1591 FRDGBuilder::Execute() RenderGraphBuilder.cpp:1257 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:2612 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7d7397a3a __scrt_common_main_seh() 0x00007ff7d7397a19 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建5
FD3D11DynamicRHI::RHICreatePixelShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:315 FD3D11DynamicRHI::CreatePixelShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:338 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:419 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 TShaderRefBase<FSimpleElementGammaAlphaOnlyPS,FShaderMapPointerTable>::GetRHIShaderBase(EShaderFrequency) Shader.h:886 FBatchedElements::PrepareShaders(FRHICommandList &,FGraphicsPipelineStateInitializer &,Type,ESimpleElementBlendMode,const FMatrix &,bool,FBatchedElementParameters *,const FTexture *,bool,float,const FDepthFieldGlowInfo *,const FSceneView *) BatchedElements.cpp:651 FBatchedElements::Draw(FRHICommandList &,const FMeshPassProcessorRenderState &,Type,bool,const FSceneView &,bool,float,Type) BatchedElements.cpp:1161 FCanvasBatchedElementRenderItem::Render_RenderThread(FRHICommandListImmediate &,FMeshPassProcessorRenderState &,const FCanvas *) Canvas.cpp:399 FCanvas::Flush_RenderThread(FRHICommandListImmediate &,bool,bool) Canvas.cpp:721 FDebugCanvasDrawer::DrawRenderThread(FRHICommandListImmediate &,const void *) DebugCanvas.cpp:310 FSlateRHIRenderingPolicy::DrawElements(FRHICommandListImmediate &,FSlateBackBuffer &,TRefCountPtr<FRHITexture2D> &,TRefCountPtr<FRHITexture2D> &,TRefCountPtr<FRHITexture2D> &,int,const TArray<FSlateRenderBatch,TSizedDefaultAllocator<32> > &,const FSlateRenderingParams &) SlateRHIRenderingPolicy.cpp:1216 FSlateRHIRenderer::DrawWindow_RenderThread(FRHICommandListImmediate &,FViewportInfo &,FSlateWindowElementList &,const FSlateDrawWindowCommandParams &) SlateRHIRenderer.cpp:895 <lambda_5572aad9e16943e81269070aa3e3a76b>::operator()(FRHICommandListImmediate &) SlateRHIRenderer.cpp:1321 EnqueueUniqueRenderCommand<`FSlateRHIRenderer::DrawWindows_Private'::`42'::SlateDrawWindowsCommandName,<lambda_5572aad9e16943e81269070aa3e3a76b> >(<lambda_5572aad9e16943e81269070aa3e3a76b> &&) RenderingThread.h:244 FSlateRHIRenderer::DrawWindows_Private(FSlateDrawBuffer &) SlateRHIRenderer.cpp:1318 FSlateRHIRenderer::DrawWindows(FSlateDrawBuffer &) SlateRHIRenderer.cpp:1190 FSlateApplication::PrivateDrawWindows(TSharedPtr<SWindow,0>) SlateApplication.cpp:1295 FSlateApplication::DrawWindows() SlateApplication.cpp:1017 FSlateApplication::TickAndDrawWidgets(float) SlateApplication.cpp:1566 FSlateApplication::Tick(ESlateTickType) SlateApplication.cpp:1423 FEngineLoop::Tick() LaunchEngineLoop.cpp:4944 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7d7397a3a __scrt_common_main_seh() 0x00007ff7d7397a19 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
销毁
FShaderMapResource::ReleaseShaders() ShaderResource.cpp:329 FShaderMapResource::ReleaseRHI() ShaderResource.cpp:348 FRenderResource::ReleaseResource() RenderResource.cpp:119 EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4> >(<lambda_aec70190632b98f970ea922a5c9418a4> &&) RenderingThread.h:244 BeginReleaseResource(FRenderResource *) RenderResource.cpp:246 FShaderMapResource::Release() ShaderResource.cpp:314 FShaderMapBase::~FShaderMapBase() ShaderMap.cpp:46 FMaterialShaderMap::~FMaterialShaderMap() MaterialShader.cpp:2365 FMaterialShaderMap::`scalar deleting destructor'(unsigned int) 0x00007fffd7a85ab4 FPendingCleanupObjects::~FPendingCleanupObjects() RenderingThread.cpp:1353 FlushRenderingCommands(bool) RenderingThread.cpp:1290 UMaterialInstance::ClearAllCachedCookedPlatformData() MaterialInstance.cpp:3259 UMaterialInstance::FinishDestroy() MaterialInstance.cpp:3621 UObject::ConditionalFinishDestroy() Obj.cpp:1020 IncrementalDestroyGarbage(bool,float) GarbageCollection.cpp:1570 IncrementalPurgeGarbage(bool,float) GarbageCollection.cpp:1495 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2054 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff6ebf47a2a __scrt_common_main_seh() 0x00007ff6ebf47a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
销毁2
FRHIResource::Release() RHIResources.h:52 FShaderMapResource::ReleaseShaders() ShaderResource.cpp:329 FShaderMapResource::ReleaseRHI() ShaderResource.cpp:348 FRenderResource::ReleaseResource() RenderResource.cpp:119 EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4> >(<lambda_aec70190632b98f970ea922a5c9418a4> &&) RenderingThread.h:244 BeginReleaseResource(FRenderResource *) RenderResource.cpp:246 FShaderMapResource::Release() ShaderResource.cpp:314 FMinimalBoundShaderStateInput::~FMinimalBoundShaderStateInput() 0x00007fffcc906a11 Experimental::RobinHoodHashTable_Private::TRobinHoodHashTable<FGraphicsMinimalPipelineStateInitializer,FGraphicsMinimalPipelineStateId::FRefCountedGraphicsMinimalPipelineState,TDefaultMapHashableKeyFuncs<FGraphicsMinimalPipelineStateInitializer,FGraphicsMinimalPipelineStateId::FRefCountedGraphicsMinimalPipelineState,0>,TSizedDefaultAllocator<32> >::FData::Deallocate(unsigned int) RobinHoodHashTable.h:338 Experimental::RobinHoodHashTable_Private::TRobinHoodHashTable<FGraphicsMinimalPipelineStateInitializer,FGraphicsMinimalPipelineStateId::FRefCountedGraphicsMinimalPipelineState,TDefaultMapHashableKeyFuncs<FGraphicsMinimalPipelineStateInitializer,FGraphicsMinimalPipelineStateId::FRefCountedGraphicsMinimalPipelineState,0>,TSizedDefaultAllocator<32> >::RemoveByElementId(FHashElementId) RobinHoodHashTable.h:920 FGraphicsMinimalPipelineStateId::RemovePersistentId(FGraphicsMinimalPipelineStateId) MeshPassProcessor.cpp:398 FPrimitiveSceneInfo::RemoveCachedMeshDrawCommands() PrimitiveSceneInfo.cpp:466 FPrimitiveSceneInfo::RemoveStaticMeshes() PrimitiveSceneInfo.cpp:840 FPrimitiveSceneInfo::RemoveFromScene(bool) PrimitiveSceneInfo.cpp:896 FScene::UpdateAllPrimitiveSceneInfos(FRHICommandListImmediate &,bool) RendererScene.cpp:3890 <lambda_8a41acb050614d83e592284e74be1a26>::operator()(FRHICommandListImmediate &) RendererScene.cpp:3319 EnqueueUniqueRenderCommand<`FScene::Release'::`2'::FReleaseCommandName,<lambda_8a41acb050614d83e592284e74be1a26> >(<lambda_8a41acb050614d83e592284e74be1a26> &&) RenderingThread.h:244 FScene::Release() RendererScene.cpp:3315 UWorld::FinishDestroy() World.cpp:939 UObject::ConditionalFinishDestroy() Obj.cpp:1020 IncrementalDestroyGarbage(bool,float) GarbageCollection.cpp:1570 IncrementalPurgeGarbage(bool,float) GarbageCollection.cpp:1495 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2054 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
ComputeShader
D3D11下ComputeShader用法
ComPtr<ID3DBlob> blob; HR(CreateShaderFromFile(L"HLSL\\TextureMul_R32G32B32A32_CS.cso", L"HLSL\\TextureMul_R32G32B32A32_CS.hlsl", "CS", "cs_5_0", blob.GetAddressOf())); HR(m_pd3dDevice->CreateComputeShader(blob->GetBufferPointer(), blob->GetBufferSize(), nullptr, computeShader.GetAddressOf()));// ComPtr<ID3D11ComputeShader> computeShader; m_pd3dImmediateContext->CSSetShader(computeShader.Get(), nullptr, 0);
创建1
FRHIComputeShader::FRHIComputeShader() RHIResources.h:529 FD3D11ComputeShader::FD3D11ComputeShader() 0x00007fffbd26c7a1 FD3D11DynamicRHI::RHICreateComputeShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:345 FD3D11DynamicRHI::CreateComputeShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:368 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:423 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 TShaderRefBase<FMoveWholeIndirectionTextureCS,FShaderMapPointerTable>::GetRHIShaderBase(EShaderFrequency) Shader.h:886 FComputeShaderUtils::Dispatch<FMoveWholeIndirectionTextureCS>(FRHIComputeCommandList &,const TShaderRefBase<FMoveWholeIndirectionTextureCS,FShaderMapPointerTable> &,const FMoveWholeIndirectionTextureCS::FParameters &,FIntVector) RenderGraphUtils.h:248 FPrecomputedVolumetricLightmapData::AddToSceneData(FPrecomputedVolumetricLightmapData *) PrecomputedVolumetricLightmap.cpp:465 FVolumetricLightmapSceneData::AddLevelVolume(const FPrecomputedVolumetricLightmap *,EShadingPath,bool) RendererScene.cpp:2314 <lambda_ed53812d8d83ad18beea96b6a7185d0b>::operator()(FRHICommandListImmediate &) RendererScene.cpp:2407 EnqueueUniqueRenderCommand<`FScene::AddPrecomputedVolumetricLightmap'::`2'::AddVolumeCommandName,<lambda_ed53812d8d83ad18beea96b6a7185d0b> >(<lambda_ed53812d8d83ad18beea96b6a7185d0b> &&) RenderingThread.h:244 FScene::AddPrecomputedVolumetricLightmap(const FPrecomputedVolumetricLightmap *,bool) RendererScene.cpp:2394 FPrecomputedVolumetricLightmap::AddToScene(FSceneInterface *,UMapBuildDataRegistry *,FGuid,bool) PrecomputedVolumetricLightmap.cpp:713 ULevel::InitializeRenderingResources() Level.cpp:1957 UWorld::InitWorld(InitializationValues) World.cpp:1649 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12985 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7ff657a2a __scrt_common_main_seh() 0x00007ff7ff657a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建2
FD3D11DynamicRHI::RHICreateComputeShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:345 FD3D11DynamicRHI::CreateComputeShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:368 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:423 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 TShaderRefBase<FHairLUTCS,FShaderMapPointerTable>::GetRHIShaderBase(EShaderFrequency) Shader.h:886 FComputeShaderUtils::Dispatch<FHairLUTCS>(FRHIComputeCommandList &,const TShaderRefBase<FHairLUTCS,FShaderMapPointerTable> &,const FHairLUTCS::FParameters &,FIntVector) RenderGraphUtils.h:248 TRDGLambdaPass<FHairLUTCS::FParameters,<lambda_8db8aeda54fe0981d1ef671ffeaa02b4> >::ExecuteImpl(FRHIComputeCommandList &) RenderGraphPass.h:424 FRDGPass::Execute(FRHIComputeCommandList &) RenderGraphPass.cpp:302 FRDGBuilder::ExecutePass(FRDGPass *) RenderGraphBuilder.cpp:1591 FRDGBuilder::Execute() RenderGraphBuilder.cpp:1257 UpdateHairLUT(const FViewInfo &) HairStrandsLUT.cpp:387 FViewInfo::SetupUniformBufferParameters(FSceneRenderTargets &,const FViewMatrices &,const FViewMatrices &,FBox *,int,FViewUniformShaderParameters &) SceneRendering.cpp:1754 FViewInfo::InitRHIResources() SceneRendering.cpp:1788 FDeferredShadingSceneRenderer::InitViews(FRHICommandListImmediate &,Type,FILCUpdatePrimTaskData &) SceneVisibility.cpp:4370 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:1412 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7d7397a3a __scrt_common_main_seh() 0x00007ff7d7397a19 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
创建3
FD3D11DynamicRHI::RHICreateComputeShader(TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:345 FD3D11DynamicRHI::CreateComputeShader_RenderThread(FRHICommandListImmediate &,TArrayView<unsigned char const ,int>,const FSHAHash &) D3D11Shaders.cpp:368 FShaderMapResource_InlineCode::CreateRHIShader(int) ShaderResource.cpp:423 FShaderMapResource::CreateShader(int) ShaderResource.cpp:369 FShaderMapResource::GetShader(int) Shader.h:242 TShaderRefBase<FHZBBuildCS,FShaderMapPointerTable>::GetRHIShaderBase(EShaderFrequency) Shader.h:886 FComputeShaderUtils::Dispatch<FHZBBuildCS>(FRHIComputeCommandList &,const TShaderRefBase<FHZBBuildCS,FShaderMapPointerTable> &,const FHZBBuildCS::FParameters &,FIntVector) RenderGraphUtils.h:248 TRDGLambdaPass<FHZBBuildCS::FParameters,<lambda_281e9284882fe49acc40e8071c1eb605> >::ExecuteImpl(FRHIComputeCommandList &) RenderGraphPass.h:424 FRDGPass::Execute(FRHIComputeCommandList &) RenderGraphPass.cpp:302 FRDGBuilder::ExecutePass(FRDGPass *) RenderGraphBuilder.cpp:1591 FRDGBuilder::Execute() RenderGraphBuilder.cpp:1257 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:2612 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UGameEngine::Tick(float,bool) GameEngine.cpp:1908 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7d7397a3a __scrt_common_main_seh() 0x00007ff7d7397a19 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
BoundShaderState
FBoundShaderStateInput、FMinimalBoundShaderStateInput
/*** UnrealEngine\Engine\Source\Runtime\RHI\Public\RHIResources.h ***/ struct FBoundShaderStateInput { inline FBoundShaderStateInput() {} inline FBoundShaderStateInput ( FRHIVertexDeclaration* InVertexDeclarationRHI , FRHIVertexShader* InVertexShaderRHI #if PLATFORM_SUPPORTS_TESSELLATION_SHADERS , FRHIHullShader* InHullShaderRHI , FRHIDomainShader* InDomainShaderRHI #endif , FRHIPixelShader* InPixelShaderRHI #if PLATFORM_SUPPORTS_GEOMETRY_SHADERS , FRHIGeometryShader* InGeometryShaderRHI #endif ) : VertexDeclarationRHI(InVertexDeclarationRHI) , VertexShaderRHI(InVertexShaderRHI) #if PLATFORM_SUPPORTS_TESSELLATION_SHADERS , HullShaderRHI(InHullShaderRHI) , DomainShaderRHI(InDomainShaderRHI) #endif , PixelShaderRHI(InPixelShaderRHI) #if PLATFORM_SUPPORTS_GEOMETRY_SHADERS , GeometryShaderRHI(InGeometryShaderRHI) #endif { } void AddRefResources() { check(VertexDeclarationRHI); VertexDeclarationRHI->AddRef(); check(VertexShaderRHI); VertexShaderRHI->AddRef(); if (HullShaderRHI) { HullShaderRHI->AddRef(); } if (DomainShaderRHI) { DomainShaderRHI->AddRef(); } if (PixelShaderRHI) { PixelShaderRHI->AddRef(); } if (GeometryShaderRHI) { GeometryShaderRHI->AddRef(); } } void ReleaseResources() { check(VertexDeclarationRHI); VertexDeclarationRHI->Release(); check(VertexShaderRHI); VertexShaderRHI->Release(); if (HullShaderRHI) { HullShaderRHI->Release(); } if (DomainShaderRHI) { DomainShaderRHI->Release(); } if (PixelShaderRHI) { PixelShaderRHI->Release(); } if (GeometryShaderRHI) { GeometryShaderRHI->Release(); } } FRHIVertexDeclaration* VertexDeclarationRHI = nullptr; FRHIVertexShader* VertexShaderRHI = nullptr; FRHIHullShader* HullShaderRHI = nullptr; FRHIDomainShader* DomainShaderRHI = nullptr; FRHIPixelShader* PixelShaderRHI = nullptr; FRHIGeometryShader* GeometryShaderRHI = nullptr; }; /*** UnrealEngine\Engine\Source\Runtime\Renderer\Public\MeshPassProcessor.h ***/ struct FMinimalBoundShaderStateInput { inline FMinimalBoundShaderStateInput() {} FBoundShaderStateInput AsBoundShaderState() const { return FBoundShaderStateInput(VertexDeclarationRHI , VertexShaderResource ? static_cast<FRHIVertexShader*>(VertexShaderResource->GetShader(VertexShaderIndex)) : nullptr #if PLATFORM_SUPPORTS_TESSELLATION_SHADERS , HullShaderResource ? static_cast<FRHIHullShader*>(HullShaderResource->GetShader(HullShaderIndex)) : nullptr , DomainShaderResource ? static_cast<FRHIDomainShader*>(DomainShaderResource->GetShader(DomainShaderIndex)) : nullptr #endif , PixelShaderResource ? static_cast<FRHIPixelShader*>(PixelShaderResource->GetShader(PixelShaderIndex)) : nullptr #if PLATFORM_SUPPORTS_GEOMETRY_SHADERS , GeometryShaderResource ? static_cast<FRHIGeometryShader*>(GeometryShaderResource->GetShader(GeometryShaderIndex)) : nullptr #endif ); } void LazilyInitShaders() const { AsBoundShaderState(); // querying shaders will initialize on demand } bool NeedsShaderInitialisation() const { if (VertexShaderResource && !VertexShaderResource->HasShader(VertexShaderIndex)) { return true; } if (HullShaderResource && !HullShaderResource->HasShader(HullShaderIndex)) { return true; } if (DomainShaderResource && !DomainShaderResource->HasShader(DomainShaderIndex)) { return true; } if (PixelShaderResource && !PixelShaderResource->HasShader(PixelShaderIndex)) { return true; } if (GeometryShaderResource && !GeometryShaderResource->HasShader(GeometryShaderIndex)) { return true; } return false; } FRHIVertexDeclaration* VertexDeclarationRHI = nullptr; TRefCountPtr<FShaderMapResource> VertexShaderResource; TRefCountPtr<FShaderMapResource> HullShaderResource; TRefCountPtr<FShaderMapResource> DomainShaderResource; TRefCountPtr<FShaderMapResource> PixelShaderResource; TRefCountPtr<FShaderMapResource> GeometryShaderResource; int32 VertexShaderIndex = INDEX_NONE; int32 HullShaderIndex = INDEX_NONE; int32 DomainShaderIndex = INDEX_NONE; int32 PixelShaderIndex = INDEX_NONE; int32 GeometryShaderIndex = INDEX_NONE; };
创建
// 在FD3D11BoundShaderState构造函数中利用FRHIVertexDeclaration和FRHIVertexShader信息,并调用ID3D11Device::CreateInputLayout方法创建一个输入布局 // 同时也保存ID3D11VertexShader、ID3D11PixelShader、ID3D11HullShader、ID3D11DomainShader和ID3D11GeometryShader到FD3D11BoundShaderState对象中 FD3D11DynamicRHI::RHICreateBoundShaderState(FRHIVertexDeclaration *,FRHIVertexShader *,FRHIHullShader *,FRHIDomainShader *,FRHIPixelShader *,FRHIGeometryShader *) D3D11Shaders.cpp:492 IRHICommandContextPSOFallback::RHISetGraphicsPipelineState(FRHIGraphicsPipelineState *,bool) RHIContext.h:729 FD3D11DynamicRHI::RHISetGraphicsPipelineState(FRHIGraphicsPipelineState *,bool) D3D11Commands.cpp:193 FRHICommandList::SetGraphicsPipelineState(FGraphicsPipelineState *,const FBoundShaderStateInput &,bool) RHICommandList.h:3207 SetGraphicsPipelineState(FRHICommandList &,const FGraphicsPipelineStateInitializer &,EApplyRendertargetOption,bool) PipelineStateCache.cpp:347 FMeshDrawCommand::SubmitDraw(const FMeshDrawCommand &__restrict,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,unsigned int,FRHICommandList &,FMeshDrawCommandStateCache &__restrict) MeshPassProcessor.cpp:1141 SubmitMeshDrawCommandsRange(const TArray<FVisibleMeshDrawCommand,TMemStackAllocator<0> > &,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,bool,int,int,unsigned int,FRHICommandList &) MeshPassProcessor.cpp:1256 FParallelMeshDrawCommandPass::DispatchDraw(FParallelCommandListSet *,FRHICommandList &) MeshDrawCommands.cpp:1345 FDeferredShadingSceneRenderer::RenderPrePassView(FRHICommandList &,const FViewInfo &) DepthRendering.cpp:254 FDeferredShadingSceneRenderer::RenderPrePass(FRHICommandListImmediate &,TFunctionRef<void __cdecl(void)>) DepthRendering.cpp:676 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:1702 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff71c367a2a __scrt_common_main_seh() 0x00007ff71c367a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
PipelineState(PSO)
D3D11、OpenGL等LowAPI是没有PSO对象的,会调用FDynamicRHI::RHICreateGraphicsPipelineState仅创建一个FRHIGraphicsPipelineStateFallBack对象
PipelineState具体分为GraphicsPipeline、ComputePipeline和RayTracingPipelineState
> UE4Editor-RHI-Win64-Debug.dll!PipelineStateCache::GetAndOrCreateGraphicsPipelineState(FRHICommandList & RHICmdList={...}, const FGraphicsPipelineStateInitializer & OriginalInitializer={...}, EApplyRendertargetOption ApplyFlags=CheckApply) Line 1412 C++ UE4Editor-RHI-Win64-Debug.dll!SetGraphicsPipelineState(FRHICommandList & RHICmdList={...}, const FGraphicsPipelineStateInitializer & Initializer={...}, EApplyRendertargetOption ApplyFlags=CheckApply, bool bApplyAdditionalState=true) Line 339 C++ UE4Editor-Renderer-Win64-Debug.dll!FMeshDrawCommand::SubmitDraw(const FMeshDrawCommand & MeshDrawCommand={...}, const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32>> & GraphicsMinimalPipelineStateSet={...}, FRHIVertexBuffer * ScenePrimitiveIdsBuffer=0x000001534c103380, int PrimitiveIdOffset=0, unsigned int InstanceFactor=1, FRHICommandList & RHICmdList={...}, FMeshDrawCommandStateCache & StateCache={...}) Line 1142 C++ UE4Editor-Renderer-Win64-Debug.dll!SubmitMeshDrawCommandsRange(const TArray<FVisibleMeshDrawCommand,TMemStackAllocator<0>> & VisibleMeshDrawCommands={...}, const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32>> & GraphicsMinimalPipelineStateSet={...}, FRHIVertexBuffer * PrimitiveIdsBuffer=0x000001534c103380, int BasePrimitiveIdsOffset=0, bool bDynamicInstancing=true, int StartIndex=0, int NumMeshDrawCommands=28, unsigned int InstanceFactor=1, FRHICommandList & RHICmdList={...}) Line 1256 C++ UE4Editor-Renderer-Win64-Debug.dll!FParallelMeshDrawCommandPass::DispatchDraw(FParallelCommandListSet * ParallelCommandListSet=0x0000000000000000, FRHICommandList & RHICmdList={...}) Line 1345 C++ UE4Editor-Renderer-Win64-Debug.dll!FDeferredShadingSceneRenderer::RenderPrePassView(FRHICommandList & RHICmdList={...}, const FViewInfo & View={...}) Line 255 C++ UE4Editor-Renderer-Win64-Debug.dll!FDeferredShadingSceneRenderer::RenderPrePass(FRHICommandListImmediate & RHICmdList={...}, TFunctionRef<void __cdecl(void)> AfterTasksAreStarted={...}) Line 681 C++ UE4Editor-Renderer-Win64-Debug.dll!FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate & RHICmdList={...}) Line 1702 C++ UE4Editor-Renderer-Win64-Debug.dll!RenderViewFamily_RenderThread(FRHICommandListImmediate & RHICmdList={...}, FSceneRenderer * SceneRenderer=0x000001534c109600) Line 3619 C++ UE4Editor-Renderer-Win64-Debug.dll!FRendererModule::BeginRenderingViewFamily::__l35::<lambda>(FRHICommandListImmediate & RHICmdList={...}) Line 3888 C++ UE4Editor-Renderer-Win64-Debug.dll!EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,void <lambda>(FRHICommandListImmediate &)>(FRendererModule::BeginRenderingViewFamily::__l35::void <lambda>(FRHICommandListImmediate &) && Lambda=void <lambda>(FRHICommandListImmediate & RHICmdList){...}) Line 245 C++ UE4Editor-Renderer-Win64-Debug.dll!FRendererModule::BeginRenderingViewFamily(FCanvas * Canvas=0x00000036db376690, FSceneViewFamily * ViewFamily=0x00000036db372940) Line 3893 C++ UE4Editor-Engine-Win64-Debug.dll!UGameViewportClient::Draw(FViewport * InViewport=0x000001538f410b88, FCanvas * SceneCanvas=0x00000036db376690) Line 1631 C++ UE4Editor-Engine-Win64-Debug.dll!FViewport::Draw(bool bShouldPresent=false) Line 1559 C++ UE4Editor-Engine-Win64-Debug.dll!UGameEngine::RedrawViewports(bool bShouldPresent=false) Line 702 C++ UE4Editor-Engine-Win64-Debug.dll!UEngine::LoadMap(FWorldContext & WorldContext={...}, FURL URL={...}, UPendingNetGame * Pending=0x0000000000000000, FString & Error={...}) Line 13107 C++ UE4Editor-Engine-Win64-Debug.dll!UEngine::Browse(FWorldContext & WorldContext={...}, FURL URL={...}, FString & Error={...}) Line 12303 C++ UE4Editor-Engine-Win64-Debug.dll!UGameInstance::StartGameInstance() Line 580 C++ UE4Editor-Engine-Win64-Debug.dll!UGameEngine::Start() Line 1167 C++ UE4Editor-Win64-Debug.exe!FEngineLoop::Init() Line 3989 C++ UE4Editor-Win64-Debug.exe!EngineInit() Line 52 C++ UE4Editor-Win64-Debug.exe!GuardedMain(const wchar_t * CmdLine=0x0000015333b12f80) Line 153 C++ UE4Editor-Win64-Debug.exe!WinMain(HINSTANCE__ * hInInstance=0x00007ff78be80000, HINSTANCE__ * hPrevInstance=0x0000000000000000, char * __formal=0x000001532f7b4f36, int nCmdShow=10) Line 257 C++ [Inline Frame] UE4Editor-Win64-Debug.exe!invoke_main() Line 102 C++ UE4Editor-Win64-Debug.exe!__scrt_common_main_seh() Line 288 C++ kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown
FGraphicsPipelineStateInitializer、FGraphicsMinimalPipelineStateInitializer
/*** UnrealEngine\Engine\Source\Runtime\RHI\Public\RHIResources.h ***/ class FGraphicsPipelineStateInitializer { public: // Can't use TEnumByte<EPixelFormat> as it changes the struct to be non trivially constructible, breaking memset using TRenderTargetFormats = TStaticArray<uint8/*EPixelFormat*/, MaxSimultaneousRenderTargets>; // MaxSimultaneousRenderTargets为8 using TRenderTargetFlags = TStaticArray<uint32/*ETextureCreateFlags*/, MaxSimultaneousRenderTargets>; // MaxSimultaneousRenderTargets为8 FGraphicsPipelineStateInitializer() : BlendState(nullptr) , RasterizerState(nullptr) , DepthStencilState(nullptr) , RenderTargetsEnabled(0) , RenderTargetFormats(PF_Unknown) , RenderTargetFlags(0) , DepthStencilTargetFormat(PF_Unknown) , DepthStencilTargetFlag(0) , DepthTargetLoadAction(ERenderTargetLoadAction::ENoAction) , DepthTargetStoreAction(ERenderTargetStoreAction::ENoAction) , StencilTargetLoadAction(ERenderTargetLoadAction::ENoAction) , StencilTargetStoreAction(ERenderTargetStoreAction::ENoAction) , NumSamples(0) , SubpassHint(ESubpassHint::None) , SubpassIndex(0) , bDepthBounds(false) , MultiViewCount(0) , bHasFragmentDensityAttachment(false) , ShadingRate(EVRSShadingRate::VRSSR_1x1) , Flags(0) { #if PLATFORM_WINDOWS static_assert(sizeof(TRenderTargetFormats::ElementType) == sizeof(uint8/*EPixelFormat*/), "Change TRenderTargetFormats's uint8 to EPixelFormat's size!"); static_assert(sizeof(TRenderTargetFlags::ElementType) == sizeof(uint32/*ETextureCreateFlags*/), "Change TRenderTargetFlags's uint32 to ETextureCreateFlags's size!"); #endif static_assert(PF_MAX < MAX_uint8, "TRenderTargetFormats assumes EPixelFormat can fit in a uint8!"); } FGraphicsPipelineStateInitializer( FBoundShaderStateInput InBoundShaderState, FRHIBlendState* InBlendState, FRHIRasterizerState* InRasterizerState, FRHIDepthStencilState* InDepthStencilState, FImmutableSamplerState InImmutableSamplerState, EPrimitiveType InPrimitiveType, uint32 InRenderTargetsEnabled, const TRenderTargetFormats& InRenderTargetFormats, const TRenderTargetFlags& InRenderTargetFlags, EPixelFormat InDepthStencilTargetFormat, ETextureCreateFlags InDepthStencilTargetFlag, ERenderTargetLoadAction InDepthTargetLoadAction, ERenderTargetStoreAction InDepthTargetStoreAction, ERenderTargetLoadAction InStencilTargetLoadAction, ERenderTargetStoreAction InStencilTargetStoreAction, FExclusiveDepthStencil InDepthStencilAccess, uint32 InNumSamples, ESubpassHint InSubpassHint, uint8 InSubpassIndex, uint16 InFlags, bool bInDepthBounds, uint8 InMultiViewCount, bool bInHasFragmentDensityAttachment, EVRSShadingRate InShadingRate) : BoundShaderState(InBoundShaderState) , BlendState(InBlendState) , RasterizerState(InRasterizerState) , DepthStencilState(InDepthStencilState) , ImmutableSamplerState(InImmutableSamplerState) , PrimitiveType(InPrimitiveType) , RenderTargetsEnabled(InRenderTargetsEnabled) , RenderTargetFormats(InRenderTargetFormats) , RenderTargetFlags(InRenderTargetFlags) , DepthStencilTargetFormat(InDepthStencilTargetFormat) , DepthStencilTargetFlag(InDepthStencilTargetFlag) , DepthTargetLoadAction(InDepthTargetLoadAction) , DepthTargetStoreAction(InDepthTargetStoreAction) , StencilTargetLoadAction(InStencilTargetLoadAction) , StencilTargetStoreAction(InStencilTargetStoreAction) , DepthStencilAccess(InDepthStencilAccess) , NumSamples(InNumSamples) , SubpassHint(InSubpassHint) , SubpassIndex(InSubpassIndex) , bDepthBounds(bInDepthBounds) , MultiViewCount(InMultiViewCount) , bHasFragmentDensityAttachment(bInHasFragmentDensityAttachment) , ShadingRate(InShadingRate) , Flags(InFlags) { } bool operator==(const FGraphicsPipelineStateInitializer& rhs) const { if (BoundShaderState.VertexDeclarationRHI != rhs.BoundShaderState.VertexDeclarationRHI || BoundShaderState.VertexShaderRHI != rhs.BoundShaderState.VertexShaderRHI || BoundShaderState.PixelShaderRHI != rhs.BoundShaderState.PixelShaderRHI || #if PLATFORM_SUPPORTS_GEOMETRY_SHADERS BoundShaderState.GeometryShaderRHI != rhs.BoundShaderState.GeometryShaderRHI || #endif #if PLATFORM_SUPPORTS_TESSELLATION_SHADERS BoundShaderState.DomainShaderRHI != rhs.BoundShaderState.DomainShaderRHI || BoundShaderState.HullShaderRHI != rhs.BoundShaderState.HullShaderRHI || #endif BlendState != rhs.BlendState || RasterizerState != rhs.RasterizerState || DepthStencilState != rhs.DepthStencilState || ImmutableSamplerState != rhs.ImmutableSamplerState || PrimitiveType != rhs.PrimitiveType || bDepthBounds != rhs.bDepthBounds || MultiViewCount != rhs.MultiViewCount || ShadingRate != rhs.ShadingRate || bHasFragmentDensityAttachment != rhs.bHasFragmentDensityAttachment || RenderTargetsEnabled != rhs.RenderTargetsEnabled || RenderTargetFormats != rhs.RenderTargetFormats || RenderTargetFlags != rhs.RenderTargetFlags || DepthStencilTargetFormat != rhs.DepthStencilTargetFormat || DepthStencilTargetFlag != rhs.DepthStencilTargetFlag || DepthTargetLoadAction != rhs.DepthTargetLoadAction || DepthTargetStoreAction != rhs.DepthTargetStoreAction || StencilTargetLoadAction != rhs.StencilTargetLoadAction || StencilTargetStoreAction != rhs.StencilTargetStoreAction || DepthStencilAccess != rhs.DepthStencilAccess || NumSamples != rhs.NumSamples || SubpassHint != rhs.SubpassHint || SubpassIndex != rhs.SubpassIndex) { return false; } return true; } uint32 ComputeNumValidRenderTargets() const { // Get the count of valid render targets (ignore those at the end of the array with PF_Unknown) if (RenderTargetsEnabled > 0) { int32 LastValidTarget = -1; for (int32 i = (int32)RenderTargetsEnabled - 1; i >= 0; i--) { if (RenderTargetFormats[i] != PF_Unknown) { LastValidTarget = i; break; } } return uint32(LastValidTarget + 1); } return RenderTargetsEnabled; } FBoundShaderStateInput BoundShaderState; FRHIBlendState* BlendState; FRHIRasterizerState* RasterizerState; FRHIDepthStencilState* DepthStencilState; FImmutableSamplerState ImmutableSamplerState; EPrimitiveType PrimitiveType; uint32 RenderTargetsEnabled; TRenderTargetFormats RenderTargetFormats; TRenderTargetFlags RenderTargetFlags; EPixelFormat DepthStencilTargetFormat; uint32 DepthStencilTargetFlag; ERenderTargetLoadAction DepthTargetLoadAction; ERenderTargetStoreAction DepthTargetStoreAction; ERenderTargetLoadAction StencilTargetLoadAction; ERenderTargetStoreAction StencilTargetStoreAction; FExclusiveDepthStencil DepthStencilAccess; uint16 NumSamples; ESubpassHint SubpassHint; uint8 SubpassIndex; bool bDepthBounds; uint8 MultiViewCount; bool bHasFragmentDensityAttachment; EVRSShadingRate ShadingRate; // Note: these flags do NOT affect compilation of this PSO. // The resulting object is invariant with respect to whatever is set here, they are // behavior hints. // They do not participate in equality comparisons or hashing. union { struct { uint16 Reserved : 15; uint16 bFromPSOFileCache : 1; }; uint16 Flags; }; }; /*** UnrealEngine\Engine\Source\Runtime\Renderer\Public\MeshPassProcessor.h ***/ /** * Pipeline state without render target state * Useful for mesh passes where the render target state is not changing between draws. * Note: the size of this class affects rendering mesh pass traversal performance. */ class FGraphicsMinimalPipelineStateInitializer { public: // Can't use TEnumByte<EPixelFormat> as it changes the struct to be non trivially constructible, breaking memset using TRenderTargetFormats = TStaticArray<uint8/*EPixelFormat*/, MaxSimultaneousRenderTargets>; // MaxSimultaneousRenderTargets为8 using TRenderTargetFlags = TStaticArray<uint32/*ETextureCreateFlags*/, MaxSimultaneousRenderTargets>; // MaxSimultaneousRenderTargets为8 FGraphicsMinimalPipelineStateInitializer() : BlendState(nullptr) , RasterizerState(nullptr) , DepthStencilState(nullptr) , PrimitiveType(PT_Num) { static_assert(sizeof(EPixelFormat) != sizeof(uint8), "Change TRenderTargetFormats's uint8 to EPixelFormat"); static_assert(PF_MAX < MAX_uint8, "TRenderTargetFormats assumes EPixelFormat can fit in a uint8!"); } FGraphicsMinimalPipelineStateInitializer( FMinimalBoundShaderStateInput InBoundShaderState, FRHIBlendState* InBlendState, FRHIRasterizerState* InRasterizerState, FRHIDepthStencilState* InDepthStencilState, FImmutableSamplerState InImmutableSamplerState, EPrimitiveType InPrimitiveType ) : BoundShaderState(InBoundShaderState) , BlendState(InBlendState) , RasterizerState(InRasterizerState) , DepthStencilState(InDepthStencilState) , ImmutableSamplerState(InImmutableSamplerState) , PrimitiveType(InPrimitiveType) { } FGraphicsMinimalPipelineStateInitializer(const FGraphicsMinimalPipelineStateInitializer& InMinimalState) : BoundShaderState(InMinimalState.BoundShaderState) , BlendState(InMinimalState.BlendState) , RasterizerState(InMinimalState.RasterizerState) , DepthStencilState(InMinimalState.DepthStencilState) , ImmutableSamplerState(InMinimalState.ImmutableSamplerState) , bDepthBounds(InMinimalState.bDepthBounds) , DrawShadingRate(InMinimalState.DrawShadingRate) , PrimitiveType(InMinimalState.PrimitiveType) { } FGraphicsPipelineStateInitializer AsGraphicsPipelineStateInitializer() const { return FGraphicsPipelineStateInitializer ( BoundShaderState.AsBoundShaderState() , BlendState , RasterizerState , DepthStencilState , ImmutableSamplerState , PrimitiveType , 0 , FGraphicsPipelineStateInitializer::TRenderTargetFormats(PF_Unknown) , FGraphicsPipelineStateInitializer::TRenderTargetFlags(0) , PF_Unknown , TexCreate_None , ERenderTargetLoadAction::ENoAction , ERenderTargetStoreAction::ENoAction , ERenderTargetLoadAction::ENoAction , ERenderTargetStoreAction::ENoAction , FExclusiveDepthStencil::DepthNop , 0 , ESubpassHint::None , 0 , 0 , bDepthBounds , MultiViewCount , bHasFragmentDensityAttachment , DrawShadingRate ); } inline bool operator==(const FGraphicsMinimalPipelineStateInitializer& rhs) const { if (BoundShaderState.VertexDeclarationRHI != rhs.BoundShaderState.VertexDeclarationRHI || BoundShaderState.VertexShaderResource != rhs.BoundShaderState.VertexShaderResource || BoundShaderState.PixelShaderResource != rhs.BoundShaderState.PixelShaderResource || BoundShaderState.VertexShaderIndex != rhs.BoundShaderState.VertexShaderIndex || BoundShaderState.PixelShaderIndex != rhs.BoundShaderState.PixelShaderIndex || #if PLATFORM_SUPPORTS_GEOMETRY_SHADERS BoundShaderState.GeometryShaderResource != rhs.BoundShaderState.GeometryShaderResource || BoundShaderState.GeometryShaderIndex != rhs.BoundShaderState.GeometryShaderIndex || #endif #if PLATFORM_SUPPORTS_TESSELLATION_SHADERS BoundShaderState.DomainShaderResource != rhs.BoundShaderState.DomainShaderResource || BoundShaderState.HullShaderResource != rhs.BoundShaderState.HullShaderResource || BoundShaderState.DomainShaderIndex != rhs.BoundShaderState.DomainShaderIndex || BoundShaderState.HullShaderIndex != rhs.BoundShaderState.HullShaderIndex || #endif BlendState != rhs.BlendState || RasterizerState != rhs.RasterizerState || DepthStencilState != rhs.DepthStencilState || ImmutableSamplerState != rhs.ImmutableSamplerState || bDepthBounds != rhs.bDepthBounds || MultiViewCount != rhs.MultiViewCount || bHasFragmentDensityAttachment != rhs.bHasFragmentDensityAttachment || DrawShadingRate != rhs.DrawShadingRate || PrimitiveType != rhs.PrimitiveType) { return false; } return true; } inline bool operator!=(const FGraphicsMinimalPipelineStateInitializer& rhs) const { return !(*this == rhs); } inline friend uint32 GetTypeHash(const FGraphicsMinimalPipelineStateInitializer& Initializer) { //add and initialize any leftover padding within the struct to avoid unstable key struct FHashKey { uint32 VertexDeclaration; uint32 VertexShader; uint32 PixelShader; uint32 RasterizerState; } HashKey; HashKey.VertexDeclaration = PointerHash(Initializer.BoundShaderState.VertexDeclarationRHI); HashKey.VertexShader = GetTypeHash(Initializer.BoundShaderState.VertexShaderIndex); HashKey.PixelShader = GetTypeHash(Initializer.BoundShaderState.PixelShaderIndex); HashKey.RasterizerState = PointerHash(Initializer.RasterizerState); return uint32(CityHash64((const char*)&HashKey, sizeof(FHashKey))); } #define COMPARE_FIELD_BEGIN(Field) \ if (Field != rhs.Field) \ { return Field COMPARE_OP rhs.Field; } #define COMPARE_FIELD(Field) \ else if (Field != rhs.Field) \ { return Field COMPARE_OP rhs.Field; } #define COMPARE_FIELD_END \ else { return false; } bool operator<(const FGraphicsMinimalPipelineStateInitializer& rhs) const { #define COMPARE_OP < COMPARE_FIELD_BEGIN(BoundShaderState.VertexDeclarationRHI) COMPARE_FIELD(BoundShaderState.VertexShaderIndex) COMPARE_FIELD(BoundShaderState.PixelShaderIndex) COMPARE_FIELD(BoundShaderState.VertexShaderResource) COMPARE_FIELD(BoundShaderState.PixelShaderResource) #if PLATFORM_SUPPORTS_GEOMETRY_SHADERS COMPARE_FIELD(BoundShaderState.GeometryShaderIndex) COMPARE_FIELD(BoundShaderState.GeometryShaderResource) #endif #if PLATFORM_SUPPORTS_TESSELLATION_SHADERS COMPARE_FIELD(BoundShaderState.DomainShaderIndex) COMPARE_FIELD(BoundShaderState.HullShaderIndex) COMPARE_FIELD(BoundShaderState.DomainShaderResource) COMPARE_FIELD(BoundShaderState.HullShaderResource) #endif COMPARE_FIELD(BlendState) COMPARE_FIELD(RasterizerState) COMPARE_FIELD(DepthStencilState) COMPARE_FIELD(bDepthBounds) COMPARE_FIELD(MultiViewCount) COMPARE_FIELD(bHasFragmentDensityAttachment) COMPARE_FIELD(DrawShadingRate) COMPARE_FIELD(PrimitiveType) COMPARE_FIELD_END; #undef COMPARE_OP } bool operator>(const FGraphicsMinimalPipelineStateInitializer& rhs) const { #define COMPARE_OP > COMPARE_FIELD_BEGIN(BoundShaderState.VertexDeclarationRHI) COMPARE_FIELD(BoundShaderState.VertexShaderIndex) COMPARE_FIELD(BoundShaderState.PixelShaderIndex) COMPARE_FIELD(BoundShaderState.VertexShaderResource) COMPARE_FIELD(BoundShaderState.PixelShaderResource) #if PLATFORM_SUPPORTS_GEOMETRY_SHADERS COMPARE_FIELD(BoundShaderState.GeometryShaderIndex) COMPARE_FIELD(BoundShaderState.GeometryShaderResource) #endif #if PLATFORM_SUPPORTS_TESSELLATION_SHADERS COMPARE_FIELD(BoundShaderState.DomainShaderIndex) COMPARE_FIELD(BoundShaderState.HullShaderIndex) COMPARE_FIELD(BoundShaderState.DomainShaderResource) COMPARE_FIELD(BoundShaderState.HullShaderResource) #endif COMPARE_FIELD(BlendState) COMPARE_FIELD(RasterizerState) COMPARE_FIELD(DepthStencilState) COMPARE_FIELD(bDepthBounds) COMPARE_FIELD(MultiViewCount) COMPARE_FIELD(bHasFragmentDensityAttachment) COMPARE_FIELD(DrawShadingRate) COMPARE_FIELD(PrimitiveType) COMPARE_FIELD_END; #undef COMPARE_OP } #undef COMPARE_FIELD_BEGIN #undef COMPARE_FIELD #undef COMPARE_FIELD_END // TODO: [PSO API] - As we migrate reuse existing API objects, but eventually we can move to the direct initializers. // When we do that work, move this to RHI.h as its more appropriate there, but here for now since dependent typdefs are here. FMinimalBoundShaderStateInput BoundShaderState; FRHIBlendState* BlendState; FRHIRasterizerState* RasterizerState; FRHIDepthStencilState* DepthStencilState; FImmutableSamplerState ImmutableSamplerState; // Note: FGraphicsMinimalPipelineStateInitializer is 8-byte aligned and can't have any implicit padding, // as it is sometimes hashed and compared as raw bytes. Explicit padding is therefore required between // all data members and at the end of the structure. bool bDepthBounds = false; uint8 MultiViewCount = 0; bool bHasFragmentDensityAttachment = false; EVRSShadingRate DrawShadingRate = EVRSShadingRate::VRSSR_1x1; EPrimitiveType PrimitiveType; };
VertexDeclaration
从VertexFactory --》VertexDeclaration
class FD3D11VertexDeclaration : public FRHIVertexDeclaration { public: /** Elements of the vertex declaration. */ FD3D11VertexElements VertexElements; // typedef TArray<D3D11_INPUT_ELEMENT_DESC,TFixedAllocator<MaxVertexElementCount> > FD3D11VertexElements; // MaxVertexElementCount为16 uint16 StreamStrides[MaxVertexElementCount]; // /** Initialization constructor. */ explicit FD3D11VertexDeclaration(const FD3D11VertexElements& InElements, const uint16* InStrides) : VertexElements(InElements) { FMemory::Memcpy(StreamStrides, InStrides, sizeof(StreamStrides)); } };
注1:FD3D11VertexElements VertexElements用于创建输入布局
注2:uint16 StreamStrides[MaxVertexElementCount]是各顶点缓冲区的Stride偏移,会透传给FBoundShaderStateInput BoundShaderState的StreamStrides成员变量
D3D11多顶点缓冲区输入
在输入装配阶段中提供了16个输入槽(Slot),这意味着我们最多可以同时绑定16个顶点缓冲区作为输入。
现在假定着色器需要使用的顶点结构为:
索引 | 顶点位置 | 顶点法向量 | 顶点UV |
---|---|---|---|
0 | P1 | N1 | T0 |
1 | P2 | N2 | T1 |
2 | P3 | N3 | T2 |
示意图:
D3D11示例代码:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct MeshDataInput { std::vector<ID3D11Buffer*> pVertexBuffers; ID3D11Buffer* pIndexBuffer; std::vector<uint32_t> strides; std::vector<uint32_t> offsets; uint32_t indexCount; }; MeshDataInput input; input.pVertexBuffers = { meshData.pVertices.Get(), // ComPtr<ID3D11Buffer> pVertices; // POSITION顶点位置Buffer meshData.pNormals.Get(), // ComPtr<ID3D11Buffer> pNormals; // NORMAL法线Buffer meshData.pTexcoords.Get() // ComPtr<ID3D11Buffer> pTexcoords; // TEXCOORD纹理坐标Buffer }; input.strides = { 12, 12, 8 }; input.offsets = { 0, 0, 0 }; input.pIndexBuffer = meshData.pIndices.Get(); // Indices顶点数组 input.indexCount = meshData.IndexCount; // Indices顶点索引数目 // 设置顶点缓冲区 deviceContext->IASetVertexBuffers(0, (uint32_t)input.pVertexBuffers.size(), input.pVertexBuffers.data(), input.strides.data(), input.offsets.data()); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const D3D11_INPUT_ELEMENT_DESC inputLayout[3] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; ComPtr<ID3DBlob> vsBlob; HR(CreateShaderFromFile(L"HLSL\\Triangle_VS.cso", L"HLSL\\Triangle_VS.hlsl", "VS", "vs_5_0", vsBlob.ReleaseAndGetAddressOf())); HR(deviceContext->CreateVertexShader(vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), nullptr, vertexShader.GetAddressOf())); // 创建顶点着色器 HR(deviceContext->CreateInputLayout(inputLayout, ARRAYSIZE(inputLayout),vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), vertexLayout.GetAddressOf())); // 创建并绑定顶点布局 //ComPtr<ID3D11InputLayout> vertexLayout // 创建像素着色器 ComPtr<ID3DBlob> psBlob; HR(CreateShaderFromFile(L"HLSL\\Triangle_PS.cso", L"HLSL\\Triangle_PS.hlsl", "PS", "ps_5_0", psBlob.ReleaseAndGetAddressOf())); HR(deviceContext->CreatePixelShader(psBlob->GetBufferPointer(), psBlob->GetBufferSize(), nullptr, pixelShader.GetAddressOf())); // 设置图元类型,设定输入布局 deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); deviceContext->IASetInputLayout(vertexLayout.Get()); // 将着色器绑定到渲染管线 deviceContext->VSSetShader(vertexShader.Get(), nullptr, 0); deviceContext->PSSetShader(pixelShader.Get(), nullptr, 0); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 设置IndexBuffer发起DrawCall deviceContext->IASetIndexBuffer(input.pIndexBuffer, input.indexCount > 65535 ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT, 0); deviceContext->DrawIndexed(input.indexCount, 0, 0);
VertexDeclaration的D3D11_INPUT_ELEMENT_DESC VertexElements[16]和VertexShader一起创建出输入布局(InputLayout)
typedef struct D3D11_INPUT_ELEMENT_DESC { LPCSTR SemanticName; // 语义名 UINT SemanticIndex; // 语义名对应的索引值 DXGI_FORMAT Format; // DXGI数据格式 UINT InputSlot; // 输入槽(0-15) UINT AlignedByteOffset; // 对齐的字节偏移量 D3D11_INPUT_CLASSIFICATION InputSlotClass; // 输入槽类别(此时为顶点) UINT InstanceDataStepRate; // 忽略(0) } D3D11_INPUT_ELEMENT_DESC; const D3D11_INPUT_ELEMENT_DESC inputLayout[3] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 2, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; HRESULT ID3D11Device::CreateInputLayout( const D3D11_INPUT_ELEMENT_DESC *pInputElementDescs, // [In]输入布局描述 UINT NumElements, // [In]上述数组元素个数 const void *pShaderBytecodeWithInputSignature, // [In]顶点着色器字节码 SIZE_T BytecodeLength, // [In]顶点着色器字节码长度 ID3D11InputLayout **ppInputLayout);
具体实现见GetOrCreateVertexDeclaration函数:
/** UnrealEngine\Engine\Source\Runtime\RHI\Private\PipelineStateCache.cpp **/ FRHIVertexDeclaration* PipelineStateCache::GetOrCreateVertexDeclaration(const FVertexDeclarationElementList& Elements) { // Actual locking/contention time should be close to unmeasurable FScopeLock ScopeLock(&GVertexDeclarationLock); uint32 Key = FCrc::MemCrc_DEPRECATED(Elements.GetData(), Elements.Num() * sizeof(FVertexElement)); FRHIVertexDeclaration** Found = GVertexDeclarationCache.Find(Key); if (Found) { return *Found; } FVertexDeclarationRHIRef NewDeclaration = RHICreateVertexDeclaration(Elements); // Add an extra reference so we don't have TRefCountPtr in the maps NewDeclaration->AddRef(); GVertexDeclarationCache.Add(Key, NewDeclaration); return NewDeclaration; }
创建
FD3D11DynamicRHI::RHICreateVertexDeclaration(const TArray<FVertexElement,TFixedAllocator<16> > &) D3D11VertexDeclaration.cpp:119 PipelineStateCache::GetOrCreateVertexDeclaration(const TArray<FVertexElement,TFixedAllocator<16> > &) PipelineStateCache.cpp:1568 FVertexFactory::InitDeclaration(const TArray<FVertexElement,TFixedAllocator<16> > &,EVertexInputStreamType) VertexFactory.cpp:309 <lambda_1315dd09074554c3a40ed326552fe4f0>::operator()(EVertexInputStreamType,bool) LocalVertexFactory.cpp:299 FLocalVertexFactory::InitRHI() LocalVertexFactory.cpp:302 FRenderResource::InitResource() RenderResource.cpp:102 <lambda_365cb4744e50d1171ec01a60fe05292d>::operator()(FRHICommandListImmediate &) StaticMesh.cpp:876 EnqueueUniqueRenderCommand<`FStaticMeshVertexFactories::InitVertexFactory'::`2'::InitStaticMeshVertexFactoryName,<lambda_365cb4744e50d1171ec01a60fe05292d> >(<lambda_365cb4744e50d1171ec01a60fe05292d> &&) RenderingThread.h:244 FStaticMeshVertexFactories::InitVertexFactory(const FStaticMeshLODResources &,FLocalVertexFactory &,unsigned int,const UStaticMesh *,bool) StaticMesh.cpp:852 FStaticMeshVertexFactories::InitResources(const FStaticMeshLODResources &,unsigned int,const UStaticMesh *) StaticMesh.cpp:882 FStaticMeshRenderData::InitResources(Type,UStaticMesh *) StaticMesh.cpp:1612 UStaticMesh::InitResources() StaticMesh.cpp:2766 UStaticMesh::PostLoad() StaticMesh.cpp:5056 UObject::ConditionalPostLoad() Obj.cpp:1082 UBodySetup::PostLoad() BodySetup.cpp:1145 UObject::ConditionalPostLoad() Obj.cpp:1082 EndLoad(FUObjectSerializeContext *) UObjectGlobals.cpp:1647 <lambda_331d34f2fc994df37d1cf9ee9119237a>::operator()() UObjectGlobals.cpp:1255 LoadPackageInternal(UPackage *,const wchar_t *,unsigned int,FLinkerLoad *,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1360 LoadPackage(UPackage *,const wchar_t *,unsigned int,FArchive *,const FLinkerInstancingContext *) UObjectGlobals.cpp:1458 ResolveName(UObject *&,FString &,bool,bool,unsigned int,const FLinkerInstancingContext *) UObjectGlobals.cpp:787 StaticLoadObjectInternal(UClass *,UObject *,const wchar_t *,const wchar_t *,unsigned int,UPackageMap *,bool,const FLinkerInstancingContext *) UObjectGlobals.cpp:848 StaticLoadObject(UClass *,UObject *,const wchar_t *,const wchar_t *,unsigned int,UPackageMap *,bool,const FLinkerInstancingContext *) UObjectGlobals.cpp:924 ConstructorHelpersInternal::FindOrLoadObject<UStaticMesh>(FString &,unsigned int) ConstructorHelpers.h:36 ConstructorHelpers::FObjectFinder<UStaticMesh>::FObjectFinder<UStaticMesh>(const wchar_t *,unsigned int) ConstructorHelpers.h:109 UCameraComponent::UCameraComponent(const FObjectInitializer &) CameraComponent.cpp:36 UCameraComponent::__DefaultConstructor(const FObjectInitializer &) CameraComponent.h:23 InternalConstructor<UCameraComponent>(const FObjectInitializer &) Class.h:3307 UClass::CreateDefaultObject() Class.cpp:3707 FObjectInitializer::CreateDefaultSubobject(UObject *,FName,UClass *,UClass *,bool,bool) UObjectGlobals.cpp:3775 UObject::CreateDefaultSubobject(FName,UClass *,UClass *,bool,bool) Obj.cpp:114 ACameraActor::ACameraActor(const FObjectInitializer &) CameraActor.cpp:23 ACameraActor::__DefaultConstructor(const FObjectInitializer &) CameraActor.h:20 InternalConstructor<ACameraActor>(const FObjectInitializer &) Class.h:3307 UClass::CreateDefaultObject() Class.cpp:3707 UObjectLoadAllCompiledInDefaultProperties() UObjectBase.cpp:898 ProcessNewlyLoadedUObjects(FName,bool) UObjectBase.cpp:996 FEngineLoop::PreInitPostStartupScreen(const wchar_t *) LaunchEngineLoop.cpp:3015 FEngineLoop::PreInit(const wchar_t *) LaunchEngineLoop.cpp:3591 EnginePreInit(const wchar_t *) Launch.cpp:42 GuardedMain(const wchar_t *) Launch.cpp:127 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff797387a2a __scrt_common_main_seh() 0x00007ff797387a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
VertexDeclaration2
FD3D11DynamicRHI::RHICreateVertexDeclaration(const TArray<FVertexElement,TFixedAllocator<16> > &) D3D11VertexDeclaration.cpp:119 PipelineStateCache::GetOrCreateVertexDeclaration(const TArray<FVertexElement,TFixedAllocator<16> > &) PipelineStateCache.cpp:1568 FVertexFactory::InitDeclaration(const TArray<FVertexElement,TFixedAllocator<16> > &,EVertexInputStreamType) VertexFactory.cpp:318 TGPUSkinVertexFactory<0>::InitRHI() GPUSkinVertexFactory.cpp:542 FRenderResource::InitResource() RenderResource.cpp:102 <lambda_59a7953239106d4c85f6b8eff539d7cf>::operator()(FRHICommandList &) SkeletalRenderGPUSkin.cpp:1332 EnqueueUniqueRenderCommand<`CreateVertexFactory<FGPUBaseSkinVertexFactory,TGPUSkinVertexFactory<0> >'::`2'::InitGPUSkinVertexFactoryName,<lambda_59a7953239106d4c85f6b8eff539d7cf> >(CreateVertexFactory::__l2::<lambda_59a7953239106d4c85f6b8eff539d7cf> &&) RenderingThread.h:244 CreateVertexFactory<FGPUBaseSkinVertexFactory,TGPUSkinVertexFactory<0> >(TArray<TUniquePtr<FGPUBaseSkinVertexFactory,TDefaultDelete<FGPUBaseSkinVertexFactory> >,TSizedDefaultAllocator<32> > &,const FSkeletalMeshObjectGPUSkin::FVertexFactoryBuffers &,Type) SkeletalRenderGPUSkin.cpp:1326 FSkeletalMeshObjectGPUSkin::FVertexFactoryData::InitVertexFactories(const FSkeletalMeshObjectGPUSkin::FVertexFactoryBuffers &,const TArray<FSkelMeshRenderSection,TSizedDefaultAllocator<32> > &,Type) SkeletalRenderGPUSkin.cpp:1545 FSkeletalMeshObjectGPUSkin::FSkeletalMeshObjectLOD::InitResources(unsigned int,const FSkeletalMeshObject::FSkelMeshObjectLODInfo &,FSkelMeshComponentLODInfo *,Type) SkeletalRenderGPUSkin.cpp:1783 FSkeletalMeshObjectGPUSkin::InitResources(USkinnedMeshComponent *) SkeletalRenderGPUSkin.cpp:191 FSkeletalMeshObjectGPUSkin::FSkeletalMeshObjectGPUSkin(USkinnedMeshComponent *,FSkeletalMeshRenderData *,Type) SkeletalRenderGPUSkin.cpp:158 USkinnedMeshComponent::CreateRenderState_Concurrent(FRegisterComponentContext *) SkinnedMeshComponent.cpp:560 UActorComponent::ExecuteRegisterEvents(FRegisterComponentContext *) ActorComponent.cpp:1532 UActorComponent::RegisterComponentWithWorld(UWorld *,FRegisterComponentContext *) ActorComponent.cpp:1220 AActor::IncrementalRegisterComponents(int,FRegisterComponentContext *) Actor.cpp:4578 ULevel::IncrementalUpdateComponents(int,bool,FRegisterComponentContext *) Level.cpp:1094 ULevel::UpdateLevelComponents(bool,FRegisterComponentContext *) Level.cpp:970 UWorld::UpdateWorldComponents(bool,bool,FRegisterComponentContext *) World.cpp:1962 UWorld::InitializeActorsForPlay(const FURL &,bool,FRegisterComponentContext *) World.cpp:4199 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13057 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff797387a2a __scrt_common_main_seh() 0x00007ff797387a09 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
其他(销毁)
Material销毁
FRenderResource::ReleaseResource() RenderResource.cpp:123 FMaterialRenderProxy::ReleaseResource() MaterialShared.cpp:2713 <lambda_e6cc8b865f9ca1b211810ce543fae1b8>::operator()(FRHICommandListImmediate &) Material.cpp:4609 EnqueueUniqueRenderCommand<`UMaterial::BeginDestroy'::`9'::BeginDestroyCommandName,<lambda_e6cc8b865f9ca1b211810ce543fae1b8> >(<lambda_e6cc8b865f9ca1b211810ce543fae1b8> &&) RenderingThread.h:244 UMaterial::BeginDestroy() Material.cpp:4605 UObject::ConditionalBeginDestroy() Obj.cpp:963 UnhashUnreachableObjects(bool,float) GarbageCollection.cpp:2105 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2043 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
MaterialInstance销毁
FRenderResource::ReleaseResource() RenderResource.cpp:119 FMaterialRenderProxy::ReleaseResource() MaterialShared.cpp:2713 <lambda_2fba706c712bcc395dad67e370838ab1>::operator()(FRHICommandListImmediate &) MaterialInstance.cpp:3591 EnqueueUniqueRenderCommand<`UMaterialInstance::BeginDestroy'::`9'::BeginDestroyCommandName,<lambda_2fba706c712bcc395dad67e370838ab1> >(<lambda_2fba706c712bcc395dad67e370838ab1> &&) RenderingThread.h:244 UMaterialInstance::BeginDestroy() MaterialInstance.cpp:3587 UObject::ConditionalBeginDestroy() Obj.cpp:963 UnhashUnreachableObjects(bool,float) GarbageCollection.cpp:2105 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2043 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
MapBuildDataRegistry销毁
FPrecomputedVolumetricLightmapData::ReleaseRHI() PrecomputedVolumetricLightmap.cpp:303 FRenderResource::ReleaseResource() RenderResource.cpp:119 EnqueueUniqueRenderCommand<`BeginReleaseResource'::`2'::ReleaseCommandName,<lambda_aec70190632b98f970ea922a5c9418a4> >(<lambda_aec70190632b98f970ea922a5c9418a4> &&) RenderingThread.h:244 BeginReleaseResource(FRenderResource *) RenderResource.cpp:246 UMapBuildDataRegistry::ReleaseResources(const TSet<FGuid,DefaultKeyFuncs<FGuid,0>,FDefaultSetAllocator> *) MapBuildData.cpp:912 UMapBuildDataRegistry::BeginDestroy() MapBuildData.cpp:492 UObject::ConditionalBeginDestroy() Obj.cpp:963 UnhashUnreachableObjects(bool,float) GarbageCollection.cpp:2105 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2043 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
LightComponent销毁
BeginReleaseResource(FRenderResource *) RenderResource.cpp:251 ULightComponent::BeginDestroy() LightComponent.cpp:785 UObject::ConditionalBeginDestroy() Obj.cpp:963 UnhashUnreachableObjects(bool,float) GarbageCollection.cpp:2105 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2043 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
FLightSceneInfo销毁
FLightSceneInfo::ReleaseRHI() LightSceneInfo.cpp:271 FRenderResource::ReleaseResource() RenderResource.cpp:119 FLightSceneInfo::~FLightSceneInfo() LightSceneInfo.cpp:73 FLightSceneInfo::`scalar deleting destructor'(unsigned int) 0x00007fffcd071e7c FScene::RemoveLightSceneInfo_RenderThread(FLightSceneInfo *) RendererScene.cpp:2832 <lambda_4694209b136cda5099744ac7c3788731>::operator()(FRHICommandListImmediate &) RendererScene.cpp:2855 EnqueueUniqueRenderCommand<`FScene::RemoveLight'::`5'::FRemoveLightCommandName,<lambda_4694209b136cda5099744ac7c3788731> >(<lambda_4694209b136cda5099744ac7c3788731> &&) RenderingThread.h:244 FScene::RemoveLight(ULightComponent *) RendererScene.cpp:2851 ULightComponent::DestroyRenderState_Concurrent() LightComponent.cpp:851 UActorComponent::ExecuteUnregisterEvents() ActorComponent.cpp:1548 UActorComponent::UnregisterComponent() ActorComponent.cpp:1300 AActor::UnregisterAllComponents(bool) Actor.cpp:4498 ULevel::ClearLevelComponents() Level.cpp:894 UWorld::ClearWorldComponents() World.cpp:1898 UWorld::CleanupWorldInternal(bool,bool,UWorld *) World.cpp:4428 UWorld::CleanupWorld(bool,bool,UWorld *) World.cpp:4366 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12727 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
AtmosphereFogComponent销毁
FRenderResource::ReleaseResource() RenderResource.cpp:119 <lambda_19d2675f03c79a689d48b066db712619>::operator()(FRHICommandListImmediate &) AtmosphericFogComponent.cpp:254 EnqueueUniqueRenderCommand<`UAtmosphericFogComponent::ReleaseResource'::`5'::ReleaseAtmosphericFogTransmittanceTextureCommandName,<lambda_19d2675f03c79a689d48b066db712619> >(<lambda_19d2675f03c79a689d48b066db712619> &&) RenderingThread.h:244 UAtmosphericFogComponent::ReleaseResource() AtmosphericFogComponent.cpp:247 UAtmosphericFogComponent::BeginDestroy() AtmosphericFogComponent.cpp:237 UObject::ConditionalBeginDestroy() Obj.cpp:963 UnhashUnreachableObjects(bool,float) GarbageCollection.cpp:2105 CollectGarbageInternal(EObjectFlags,bool) GarbageCollection.cpp:2043 CollectGarbage(EObjectFlags,bool) GarbageCollection.cpp:2150 UEngine::TrimMemory() UnrealEngine.cpp:13138 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:12771 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UEngine::TickWorldTravel(FWorldContext &,float) UnrealEngine.cpp:12501 UGameEngine::Tick(float,bool) GameEngine.cpp:1783 FEngineLoop::Tick() LaunchEngineLoop.cpp:4830 EngineTick() Launch.cpp:62 GuardedMain(const wchar_t *) Launch.cpp:171 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff7b1fe7a1a __scrt_common_main_seh() 0x00007ff7b1fe79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
DrawCall
D3D11发起DrawCall
// 设置图元类型 deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); // 设置索引缓冲区(IndexBuffer) deviceContext->IASetIndexBuffer(pIndexBuffer.Get(), DXGI_FORMAT_R32_UINT, 0); // ComPtr<ID3D11Buffer> pIndexBuffer; // 发起DrawCall deviceContext->DrawIndexed(indexCount, 0, 0); // uint32_t indexCount // index索引的个数
发起DrawCall1
FD3D11DynamicRHI::RHIDrawIndexedPrimitive(FRHIIndexBuffer *,int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int) D3D11Commands.cpp:1764 FRHICommandList::DrawIndexedPrimitive(FRHIIndexBuffer *,int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int) RHICommandList.h:3085 FOcclusionQueryBatcher::Flush(FRHICommandList &) SceneOcclusion.cpp:370 BeginOcclusionTests(FRHICommandListImmediate &,TArrayView<FViewInfo,int>,Type,const TArray<FViewOcclusionQueries,TInlineAllocator<1,TMemStackAllocator<0> > > &,unsigned int) SceneOcclusion.cpp:1300 <lambda_c2fed0f97485c798522737d96c81424a>::operator()(FRHICommandListImmediate &) SceneOcclusion.cpp:1381 TRDGLambdaPass<FRenderTargetParameters,<lambda_c2fed0f97485c798522737d96c81424a> >::ExecuteImpl(FRHIComputeCommandList &) RenderGraphPass.h:424 FRDGPass::Execute(FRHIComputeCommandList &) RenderGraphPass.cpp:302 FRDGBuilder::ExecutePass(FRDGPass *) RenderGraphBuilder.cpp:1591 FRDGBuilder::Execute() RenderGraphBuilder.cpp:1257 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:2612 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff616ff7a1a __scrt_common_main_seh() 0x00007ff616ff79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
发起DrawCall2
FD3D11DynamicRHI::RHIDrawIndexedPrimitive(FRHIIndexBuffer *,int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int) D3D11Commands.cpp:1764 FRHICommandList::DrawIndexedPrimitive(FRHIIndexBuffer *,int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int) RHICommandList.h:3085 FMeshDrawCommand::SubmitDraw(const FMeshDrawCommand &__restrict,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,unsigned int,FRHICommandList &,FMeshDrawCommandStateCache &__restrict) MeshPassProcessor.cpp:1173 SubmitMeshDrawCommandsRange(const TArray<FVisibleMeshDrawCommand,TMemStackAllocator<0> > &,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,bool,int,int,unsigned int,FRHICommandList &) MeshPassProcessor.cpp:1256 FParallelMeshDrawCommandPass::DispatchDraw(FParallelCommandListSet *,FRHICommandList &) MeshDrawCommands.cpp:1345 FProjectedShadowInfo::RenderDepthInner(FRHICommandListImmediate &,FSceneRenderer *,TFunctionRef<void __cdecl(FRHICommandList &,bool)>,bool) ShadowDepthRendering.cpp:1215 FProjectedShadowInfo::RenderDepth(FRHICommandListImmediate &,FSceneRenderer *,TFunctionRef<void __cdecl(FRHICommandList &,bool)>,bool) ShadowDepthRendering.cpp:1310 FSceneRenderer::RenderShadowDepthMapAtlases(FRHICommandListImmediate &) ShadowDepthRendering.cpp:1561 FSceneRenderer::RenderShadowDepthMaps(FRHICommandListImmediate &) ShadowDepthRendering.cpp:1596 TRDGLambdaPass<FEmptyShaderParameters,<lambda_eb152669f71926859a99dd6c6dc64438> >::ExecuteImpl(FRHIComputeCommandList &) RenderGraphPass.h:424 FRDGPass::Execute(FRHIComputeCommandList &) RenderGraphPass.cpp:302 FRDGBuilder::ExecutePass(FRDGPass *) RenderGraphBuilder.cpp:1591 FRDGBuilder::Execute() RenderGraphBuilder.cpp:1257 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:2612 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff616ff7a1a __scrt_common_main_seh() 0x00007ff616ff79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1
发起DrawCall3
FD3D11DynamicRHI::RHIDrawIndexedPrimitive(FRHIIndexBuffer *,int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int) D3D11Commands.cpp:1731 FRHICommandList::DrawIndexedPrimitive(FRHIIndexBuffer *,int,unsigned int,unsigned int,unsigned int,unsigned int,unsigned int) RHICommandList.h:3085 FMeshDrawCommand::SubmitDraw(const FMeshDrawCommand &__restrict,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,unsigned int,FRHICommandList &,FMeshDrawCommandStateCache &__restrict) MeshPassProcessor.cpp:1173 SubmitMeshDrawCommandsRange(const TArray<FVisibleMeshDrawCommand,TMemStackAllocator<0> > &,const Experimental::TRobinHoodHashSet<FGraphicsMinimalPipelineStateInitializer,DefaultKeyFuncs<FGraphicsMinimalPipelineStateInitializer,0>,TSizedDefaultAllocator<32> > &,FRHIVertexBuffer *,int,bool,int,int,unsigned int,FRHICommandList &) MeshPassProcessor.cpp:1256 FParallelMeshDrawCommandPass::DispatchDraw(FParallelCommandListSet *,FRHICommandList &) MeshDrawCommands.cpp:1345 FDeferredShadingSceneRenderer::RenderPrePassView(FRHICommandList &,const FViewInfo &) DepthRendering.cpp:254 FDeferredShadingSceneRenderer::RenderPrePass(FRHICommandListImmediate &,TFunctionRef<void __cdecl(void)>) DepthRendering.cpp:676 FDeferredShadingSceneRenderer::Render(FRHICommandListImmediate &) DeferredShadingRenderer.cpp:1702 RenderViewFamily_RenderThread(FRHICommandListImmediate &,FSceneRenderer *) SceneRendering.cpp:3616 <lambda_73be3b292d373df226bf787512bb165a>::operator()(FRHICommandListImmediate &) SceneRendering.cpp:3887 EnqueueUniqueRenderCommand<`FRendererModule::BeginRenderingViewFamily'::`35'::FDrawSceneCommandName,<lambda_73be3b292d373df226bf787512bb165a> >(<lambda_73be3b292d373df226bf787512bb165a> &&) RenderingThread.h:244 FRendererModule::BeginRenderingViewFamily(FCanvas *,FSceneViewFamily *) SceneRendering.cpp:3881 UGameViewportClient::Draw(FViewport *,FCanvas *) GameViewportClient.cpp:1630 FViewport::Draw(bool) UnrealClient.cpp:1557 UGameEngine::RedrawViewports(bool) GameEngine.cpp:702 UEngine::LoadMap(FWorldContext &,FURL,UPendingNetGame *,FString &) UnrealEngine.cpp:13104 UEngine::Browse(FWorldContext &,FURL,FString &) UnrealEngine.cpp:12303 UGameInstance::StartGameInstance() GameInstance.cpp:580 UGameEngine::Start() GameEngine.cpp:1166 FEngineLoop::Init() LaunchEngineLoop.cpp:3989 EngineInit() Launch.cpp:52 GuardedMain(const wchar_t *) Launch.cpp:153 WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int) LaunchWindows.cpp:257 [Inlined] invoke_main() 0x00007ff616ff7a1a __scrt_common_main_seh() 0x00007ff616ff79f9 <unknown> 0x00007ff893da7614 <unknown> 0x00007ff8956e26a1