| 413 | } |
| 414 | |
| 415 | bool GPUDevice::LoadContent() |
| 416 | { |
| 417 | // Load internal rendering shader for GPU device low-level impl |
| 418 | _res->QuadShader = Content::LoadAsyncInternal<Shader>(TEXT("Shaders/Quad")); |
| 419 | if (_res->QuadShader == nullptr || _res->QuadShader->WaitForLoaded()) |
| 420 | return true; |
| 421 | QuadShader = _res->QuadShader->GetShader(); |
| 422 | GPUPipelineState::Description::DefaultFullscreenTriangle.VS = QuadShader->GetVS("VS"); |
| 423 | _res->PS_CopyLinear = CreatePipelineState(); |
| 424 | GPUPipelineState::Description desc = GPUPipelineState::Description::DefaultFullscreenTriangle; |
| 425 | desc.PS = QuadShader->GetPS("PS_CopyLinear"); |
| 426 | if (_res->PS_CopyLinear->Init(desc)) |
| 427 | return true; |
| 428 | _res->PS_Clear = CreatePipelineState(); |
| 429 | desc.PS = QuadShader->GetPS("PS_Clear"); |
| 430 | if (_res->PS_Clear->Init(desc)) |
| 431 | return true; |
| 432 | |
| 433 | // Create fullscreen triangle vertex buffer |
| 434 | { |
| 435 | // Create vertex buffer |
| 436 | // @formatter:off |
| 437 | static float vb[] = |
| 438 | { |
| 439 | // XY UV |
| 440 | -1.0f, -1.0f, 0.0f, 1.0f, |
| 441 | -1.0f, 3.0f, 0.0f, -1.0f, |
| 442 | 3.0f, -1.0f, 2.0f, 1.0f, |
| 443 | }; |
| 444 | // @formatter:on |
| 445 | _res->FullscreenTriangleVB = CreateBuffer(TEXT("QuadVB")); |
| 446 | auto layout = GPUVertexLayout::Get({ |
| 447 | { VertexElement::Types::Position, 0, 0, 0, PixelFormat::R32G32_Float }, |
| 448 | { VertexElement::Types::TexCoord, 0, 8, 0, PixelFormat::R32G32_Float }, |
| 449 | }); |
| 450 | if (_res->FullscreenTriangleVB->Init(GPUBufferDescription::Vertex(layout, 16, 3, vb))) |
| 451 | return true; |
| 452 | } |
| 453 | |
| 454 | // Load default material |
| 455 | _res->DefaultMaterial = Content::LoadAsyncInternal<Material>(TEXT("Engine/DefaultMaterial")); |
| 456 | if (_res->DefaultMaterial == nullptr) |
| 457 | return true; |
| 458 | _res->DefaultDeformableMaterial = Guid(0x639e12c0, 0x42d34bae, 0x89dd8b81, 0x7e1efc2d); |
| 459 | |
| 460 | // Load default normal map |
| 461 | _res->DefaultNormalMap = Content::LoadAsyncInternal<Texture>(TEXT("Engine/Textures/NormalTexture")); |
| 462 | if (_res->DefaultNormalMap == nullptr) |
| 463 | return true; |
| 464 | |
| 465 | // Load default solid white |
| 466 | _res->DefaultWhiteTexture = Content::LoadAsyncInternal<Texture>(TEXT("Engine/Textures/WhiteTexture")); |
| 467 | if (_res->DefaultWhiteTexture == nullptr) |
| 468 | return true; |
| 469 | |
| 470 | // Load default solid black |
| 471 | _res->DefaultBlackTexture = Content::LoadAsyncInternal<Texture>(TEXT("Engine/Textures/BlackTexture")); |
| 472 | if (_res->DefaultBlackTexture == nullptr) |