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 / SobelFilter / RenderTarget.h < prev    next >
Encoding:
C/C++ Source or Header  |  2016-03-02  |  1.4 KB  |  55 lines

  1. //***************************************************************************************
  2. // RenderTarget.h by Frank Luna (C) 2015 All Rights Reserved.
  3. //***************************************************************************************
  4.  
  5. #pragma once
  6.  
  7. #include "../../Common/d3dUtil.h"
  8.  
  9. class RenderTarget
  10. {
  11. public:
  12.     ///<summary>
  13.     /// The width and height should match the dimensions of the input texture to blur.
  14.     /// Recreate when the screen is resized. 
  15.     ///</summary>
  16.     RenderTarget(ID3D12Device* device,
  17.         UINT width, UINT height,
  18.         DXGI_FORMAT format);
  19.         
  20.     RenderTarget(const RenderTarget& rhs)=delete;
  21.     RenderTarget& operator=(const RenderTarget& rhs)=delete;
  22.     ~RenderTarget()=default;
  23.  
  24.     ID3D12Resource* Resource();
  25.     CD3DX12_GPU_DESCRIPTOR_HANDLE Srv();
  26.     CD3DX12_CPU_DESCRIPTOR_HANDLE Rtv();
  27.  
  28.     void BuildDescriptors(
  29.         CD3DX12_CPU_DESCRIPTOR_HANDLE hCpuSrv,
  30.         CD3DX12_GPU_DESCRIPTOR_HANDLE hGpuSrv,
  31.         CD3DX12_CPU_DESCRIPTOR_HANDLE hCpuRtv);
  32.  
  33.     void OnResize(UINT newWidth, UINT newHeight);
  34.  
  35. private:
  36.     void BuildDescriptors();
  37.     void BuildResource();
  38.  
  39. private:
  40.  
  41.     ID3D12Device* md3dDevice = nullptr;
  42.  
  43.     UINT mWidth = 0;
  44.     UINT mHeight = 0;
  45.     DXGI_FORMAT mFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
  46.  
  47.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuSrv;
  48.     CD3DX12_GPU_DESCRIPTOR_HANDLE mhGpuSrv;
  49.     CD3DX12_CPU_DESCRIPTOR_HANDLE mhCpuRtv;
  50.  
  51.     // Two for ping-ponging the textures.
  52.     Microsoft::WRL::ComPtr<ID3D12Resource> mOffscreenTex = nullptr;
  53. };
  54.  
  55.