home *** CD-ROM | disk | FTP | other *** search
/ Introduction to 3D Game …ogramming with DirectX 12 / Introduction-to-3D-Game-Programming-with-DirectX-12.ISO / Code.Textures / Chapter 13 The Compute Shader / Blur / FrameResource.h < prev    next >
Encoding:
C/C++ Source or Header  |  2016-03-02  |  3.0 KB  |  80 lines

  1. #pragma once
  2.  
  3. #include "../../Common/d3dUtil.h"
  4. #include "../../Common/MathHelper.h"
  5. #include "../../Common/UploadBuffer.h"
  6.  
  7. struct ObjectConstants
  8. {
  9.     DirectX::XMFLOAT4X4 World = MathHelper::Identity4x4();
  10.     DirectX::XMFLOAT4X4 TexTransform = MathHelper::Identity4x4();
  11. };
  12.  
  13. struct PassConstants
  14. {
  15.     DirectX::XMFLOAT4X4 View = MathHelper::Identity4x4();
  16.     DirectX::XMFLOAT4X4 InvView = MathHelper::Identity4x4();
  17.     DirectX::XMFLOAT4X4 Proj = MathHelper::Identity4x4();
  18.     DirectX::XMFLOAT4X4 InvProj = MathHelper::Identity4x4();
  19.     DirectX::XMFLOAT4X4 ViewProj = MathHelper::Identity4x4();
  20.     DirectX::XMFLOAT4X4 InvViewProj = MathHelper::Identity4x4();
  21.     DirectX::XMFLOAT3 EyePosW = { 0.0f, 0.0f, 0.0f };
  22.     float cbPerObjectPad1 = 0.0f;
  23.     DirectX::XMFLOAT2 RenderTargetSize = { 0.0f, 0.0f };
  24.     DirectX::XMFLOAT2 InvRenderTargetSize = { 0.0f, 0.0f };
  25.     float NearZ = 0.0f;
  26.     float FarZ = 0.0f;
  27.     float TotalTime = 0.0f;
  28.     float DeltaTime = 0.0f;
  29.  
  30.     DirectX::XMFLOAT4 AmbientLight = { 0.0f, 0.0f, 0.0f, 1.0f };
  31.  
  32.     DirectX::XMFLOAT4 FogColor = { 0.7f, 0.7f, 0.7f, 1.0f };
  33.     float gFogStart = 5.0f;
  34.     float gFogRange = 150.0f;
  35.     DirectX::XMFLOAT2 cbPerObjectPad2;
  36.  
  37.     // Indices [0, NUM_DIR_LIGHTS) are directional lights;
  38.     // indices [NUM_DIR_LIGHTS, NUM_DIR_LIGHTS+NUM_POINT_LIGHTS) are point lights;
  39.     // indices [NUM_DIR_LIGHTS+NUM_POINT_LIGHTS, NUM_DIR_LIGHTS+NUM_POINT_LIGHT+NUM_SPOT_LIGHTS)
  40.     // are spot lights for a maximum of MaxLights per object.
  41.     Light Lights[MaxLights];
  42. };
  43.  
  44. struct Vertex
  45. {
  46.     DirectX::XMFLOAT3 Pos;
  47.     DirectX::XMFLOAT3 Normal;
  48.     DirectX::XMFLOAT2 TexC;
  49. };
  50.  
  51. // Stores the resources needed for the CPU to build the command lists
  52. // for a frame.  
  53. struct FrameResource
  54. {
  55. public:
  56.     
  57.     FrameResource(ID3D12Device* device, UINT passCount, UINT objectCount, UINT materialCount, UINT waveVertCount);
  58.     FrameResource(const FrameResource& rhs) = delete;
  59.     FrameResource& operator=(const FrameResource& rhs) = delete;
  60.     ~FrameResource();
  61.  
  62.     // We cannot reset the allocator until the GPU is done processing the commands.
  63.     // So each frame needs their own allocator.
  64.     Microsoft::WRL::ComPtr<ID3D12CommandAllocator> CmdListAlloc;
  65.  
  66.     // We cannot update a cbuffer until the GPU is done processing the commands
  67.     // that reference it.  So each frame needs their own cbuffers.
  68.    // std::unique_ptr<UploadBuffer<FrameConstants>> FrameCB = nullptr;
  69.     std::unique_ptr<UploadBuffer<PassConstants>> PassCB = nullptr;
  70.     std::unique_ptr<UploadBuffer<MaterialConstants>> MaterialCB = nullptr;
  71.     std::unique_ptr<UploadBuffer<ObjectConstants>> ObjectCB = nullptr;
  72.  
  73.     // We cannot update a dynamic vertex buffer until the GPU is done processing
  74.     // the commands that reference it.  So each frame needs their own.
  75.     std::unique_ptr<UploadBuffer<Vertex>> WavesVB = nullptr;
  76.  
  77.     // Fence value to mark commands up to this fence point.  This lets us
  78.     // check if these frame resources are still in use by the GPU.
  79.     UINT64 Fence = 0;
  80. };