| 364 | } |
| 365 | |
| 366 | void TressFXSample::OnCreate(HWND hWnd) |
| 367 | { |
| 368 | GetDevice()->SetVSync(m_vSync); |
| 369 | GetDevice()->OnCreate(hWnd, NUMBER_OF_BACK_BUFFERS, VALIDATION_ENABLED, "TressFX"); |
| 370 | |
| 371 | m_activeScene.scene.reset(new EI_Scene); |
| 372 | |
| 373 | // Create a renderpass for GLTF (needed for PSO creation) |
| 374 | const EI_ResourceFormat FormatArray[] = { GetDevice()->GetColorBufferFormat(), GetDevice()->GetDepthBufferFormat() }; |
| 375 | { |
| 376 | const EI_AttachmentParams AttachmentParams[] = { { EI_RenderPassFlags::Load | EI_RenderPassFlags::Clear | EI_RenderPassFlags::Store }, |
| 377 | { EI_RenderPassFlags::Depth | EI_RenderPassFlags::Load | EI_RenderPassFlags::Clear | EI_RenderPassFlags::Store } }; |
| 378 | float ClearValues[] = { 0.f, 0.f, 0.f, 0.f, // Color |
| 379 | 1.f, 0.f }; // Depth |
| 380 | |
| 381 | m_pGLTFRenderTargetSet = GetDevice()->CreateRenderTargetSet(FormatArray, 2, AttachmentParams, ClearValues); |
| 382 | } |
| 383 | |
| 384 | // Create a renderpass for shadow rendering (needed for PSO creation) |
| 385 | { |
| 386 | const EI_Resource* ResourceArray[] = { GetDevice()->GetShadowBufferResource() }; |
| 387 | const EI_AttachmentParams AttachmentParams[] = { { EI_RenderPassFlags::Depth | EI_RenderPassFlags::Load | EI_RenderPassFlags::Clear | EI_RenderPassFlags::Store } }; |
| 388 | float ClearValues[] = { 1.f, 0.f }; // Depth Clear |
| 389 | m_pShadowRenderTargetSet = GetDevice()->CreateRenderTargetSet(ResourceArray, 1, AttachmentParams, ClearValues); |
| 390 | } |
| 391 | // Create a debug render pass |
| 392 | { |
| 393 | const EI_AttachmentParams AttachmentParams[] = { { EI_RenderPassFlags::Load | EI_RenderPassFlags::Store }, |
| 394 | { EI_RenderPassFlags::Depth | EI_RenderPassFlags::Load | EI_RenderPassFlags::Store } }; |
| 395 | |
| 396 | m_pDebugRenderTargetSet = GetDevice()->CreateRenderTargetSet(FormatArray, 2, AttachmentParams, nullptr); |
| 397 | } |
| 398 | |
| 399 | // init GUI (non gfx stuff) |
| 400 | ImGUI_Init((void *)hWnd); |
| 401 | LoadScene(0); |
| 402 | |
| 403 | m_activeScene.viewConstantBuffer.CreateBufferResource("viewConstants"); |
| 404 | EI_BindSetDescription set = { { m_activeScene.viewConstantBuffer.GetBufferResource() } }; |
| 405 | m_activeScene.viewBindSet = GetDevice()->CreateBindSet(GetViewLayout(), set); |
| 406 | |
| 407 | m_activeScene.shadowViewConstantBuffer.CreateBufferResource("shadowViewConstants"); |
| 408 | EI_BindSetDescription shadowSet = { { m_activeScene.shadowViewConstantBuffer.GetBufferResource() } }; |
| 409 | m_activeScene.shadowViewBindSet = GetDevice()->CreateBindSet(GetViewLayout(), shadowSet); |
| 410 | |
| 411 | m_activeScene.lightConstantBuffer.CreateBufferResource("LightConstants"); |
| 412 | |
| 413 | GetDevice()->EndAndSubmitCommandBuffer(); |
| 414 | GetDevice()->FlushGPU(); |
| 415 | } |
| 416 | |
| 417 | void TressFXSample::LoadScene(int sceneNumber) |
| 418 | { |
no test coverage detected