Blowbox 2017
A 3D Game Engine by Riko Ophorst using DirectX 12
pixel_buffer.h
1 #pragma once
2 
3 #include "util/string.h"
4 #include "gpu_resource.h"
5 
6 namespace blowbox
7 {
16  class PixelBuffer : public GpuResource
17  {
18  public:
20  PixelBuffer();
21 
23  const UINT& GetWidth() const { return width_; }
24 
26  const UINT& GetHeight() const { return height_; }
27 
29  const DXGI_FORMAT& GetFormat() const { return format_; }
30 
31  protected:
42  D3D12_RESOURCE_DESC DescribeTex2D(UINT width, UINT height, UINT depth_or_array_size, UINT num_mips, DXGI_FORMAT format, UINT flags);
43 
50  void AssociateWithResource(const WString& name, ID3D12Resource* resource, const D3D12_RESOURCE_STATES& current_resource_state);
51 
58  void CreateTextureResource(const WString& name, const D3D12_RESOURCE_DESC& resource_desc, const D3D12_CLEAR_VALUE& clear_value);
59 
60  protected:
62  static DXGI_FORMAT GetBaseFormat(DXGI_FORMAT format);
63 
65  static DXGI_FORMAT GetUAVFormat(DXGI_FORMAT format);
66 
68  static DXGI_FORMAT GetDSVFormat(DXGI_FORMAT format);
69 
71  static DXGI_FORMAT GetDepthFormat(DXGI_FORMAT format);
72 
74  static DXGI_FORMAT GetStencilFormat(DXGI_FORMAT format);
75 
76  protected:
77  UINT width_;
78  UINT height_;
79  UINT array_size_;
80  DXGI_FORMAT format_;
81  };
82 }
D3D12_RESOURCE_DESC DescribeTex2D(UINT width, UINT height, UINT depth_or_array_size, UINT num_mips, DXGI_FORMAT format, UINT flags)
Generates a D3D12_RESOURCE_DESC for Texture2D resources.
Definition: pixel_buffer.cc:18
const UINT & GetWidth() const
Definition: pixel_buffer.h:23
UINT width_
The width of the pixel buffer in texels.
Definition: pixel_buffer.h:77
void AssociateWithResource(const WString &name, ID3D12Resource *resource, const D3D12_RESOURCE_STATES &current_resource_state)
Associates this PixelBuffer with a pre-existing resource (useful for stuff like SwapChain buffers) ...
Definition: pixel_buffer.cc:42
Wraps ID3D12Resource objects.
Definition: gpu_resource.h:19
UINT height_
The height of the pixel buffer in texels.
Definition: pixel_buffer.h:78
static DXGI_FORMAT GetUAVFormat(DXGI_FORMAT format)
Definition: pixel_buffer.cc:132
static DXGI_FORMAT GetBaseFormat(DXGI_FORMAT format)
Definition: pixel_buffer.cc:84
Wrapper for pixel-type resources.
Definition: pixel_buffer.h:16
PixelBuffer()
Constructs a PixelBuffer resource.
Definition: pixel_buffer.cc:9
eastl::wstring WString
Typedef for wrapping the EASTL wstring.
Definition: string.h:20
const DXGI_FORMAT & GetFormat() const
Definition: pixel_buffer.h:29
DXGI_FORMAT format_
The format of the resource itself.
Definition: pixel_buffer.h:80
void CreateTextureResource(const WString &name, const D3D12_RESOURCE_DESC &resource_desc, const D3D12_CLEAR_VALUE &clear_value)
Creates a new texture resource for this PixelBuffer.
Definition: pixel_buffer.cc:64
The main Blowbox namespace.
Definition: image.cc:8
const UINT & GetHeight() const
Definition: pixel_buffer.h:26
static DXGI_FORMAT GetDSVFormat(DXGI_FORMAT format)
Definition: pixel_buffer.cc:177
static DXGI_FORMAT GetStencilFormat(DXGI_FORMAT format)
Definition: pixel_buffer.cc:249
static DXGI_FORMAT GetDepthFormat(DXGI_FORMAT format)
Definition: pixel_buffer.cc:213
UINT array_size_
The array size of the pixel buffer.
Definition: pixel_buffer.h:79