| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#ifndef __D3D12_PROPERTY_LAYOUT_FORMAT_TABLE_H__ |
| 8 |
#define __D3D12_PROPERTY_LAYOUT_FORMAT_TABLE_H__ |
| 9 |
#include "d3d12.h" |
| 10 |
#define MAP_ALIGN_REQUIREMENT 16 // Map is required to return 16-byte aligned addresses |
| 11 |
|
| 12 |
struct D3D12_PROPERTY_LAYOUT_FORMAT_TABLE |
| 13 |
{ |
| 14 |
public: |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
typedef struct FORMAT_DETAIL |
| 19 |
{ |
| 20 |
DXGI_FORMAT DXGIFormat; |
| 21 |
DXGI_FORMAT ParentFormat; |
| 22 |
const DXGI_FORMAT* pDefaultFormatCastSet; |
| 23 |
UINT8 BitsPerComponent[4]; |
| 24 |
UINT8 BitsPerUnit; |
| 25 |
BYTE SRGBFormat : 1; |
| 26 |
UINT WidthAlignment : 4; |
| 27 |
UINT HeightAlignment : 4; |
| 28 |
UINT DepthAlignment : 1; |
| 29 |
D3D_FORMAT_LAYOUT Layout : 1; |
| 30 |
D3D_FORMAT_TYPE_LEVEL TypeLevel : 2; |
| 31 |
D3D_FORMAT_COMPONENT_NAME ComponentName0 : 3; |
| 32 |
D3D_FORMAT_COMPONENT_NAME ComponentName1 : 3; |
| 33 |
D3D_FORMAT_COMPONENT_NAME ComponentName2 : 3; |
| 34 |
D3D_FORMAT_COMPONENT_NAME ComponentName3 : 3; |
| 35 |
D3D_FORMAT_COMPONENT_INTERPRETATION ComponentInterpretation0 : 3; |
| 36 |
D3D_FORMAT_COMPONENT_INTERPRETATION ComponentInterpretation1 : 3; |
| 37 |
D3D_FORMAT_COMPONENT_INTERPRETATION ComponentInterpretation2 : 3; |
| 38 |
D3D_FORMAT_COMPONENT_INTERPRETATION ComponentInterpretation3 : 3; |
| 39 |
bool bDX9VertexOrIndexFormat : 1; |
| 40 |
bool bDX9TextureFormat : 1; |
| 41 |
bool bFloatNormFormat : 1; |
| 42 |
bool bPlanar : 1; |
| 43 |
bool bYUV : 1; |
| 44 |
bool bDependantFormatCastSet : 1; |
| 45 |
bool bInternal : 1; |
| 46 |
} FORMAT_DETAIL; |
| 47 |
|
| 48 |
private: |
| 49 |
static const FORMAT_DETAIL s_FormatDetail[]; |
| 50 |
static const UINT s_NumFormats; |
| 51 |
static const LPCSTR s_FormatNames[]; |
| 52 |
public: |
| 53 |
static UINT GetNumFormats(); |
| 54 |
static const FORMAT_DETAIL* GetFormatTable(); |
| 55 |
static D3D_FEATURE_LEVEL GetHighestDefinedFeatureLevel(); |
| 56 |
|
| 57 |
static DXGI_FORMAT GetFormat (SIZE_T Index); |
| 58 |
static bool FormatExists (DXGI_FORMAT Format); |
| 59 |
static bool FormatExistsInHeader (DXGI_FORMAT Format, bool bExternalHeader = true); |
| 60 |
static UINT GetByteAlignment (DXGI_FORMAT Format); |
| 61 |
static bool IsBlockCompressFormat (DXGI_FORMAT Format); |
| 62 |
static LPCSTR GetName (DXGI_FORMAT Format, bool bHideInternalFormats = true); |
| 63 |
static bool IsSRGBFormat (DXGI_FORMAT Format); |
| 64 |
static UINT GetBitsPerStencil (DXGI_FORMAT Format); |
| 65 |
static UINT GetBitsPerDepth (DXGI_FORMAT Format); |
| 66 |
static void GetFormatReturnTypes (DXGI_FORMAT Format, D3D_FORMAT_COMPONENT_INTERPRETATION* pInterpretations); |
| 67 |
static UINT GetNumComponentsInFormat(DXGI_FORMAT Format); |
| 68 |
static UINT GetMinNumComponentsInFormats(DXGI_FORMAT FormatA, DXGI_FORMAT FormatB); |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
static UINT Sequential2AbsoluteComponentIndex (DXGI_FORMAT Format, UINT SequentialComponentIndex); |
| 73 |
static bool CanBeCastEvenFullyTyped (DXGI_FORMAT Format, D3D_FEATURE_LEVEL fl); |
| 74 |
static UINT8 GetAddressingBitsPerAlignedSize (DXGI_FORMAT Format); |
| 75 |
static DXGI_FORMAT GetParentFormat (DXGI_FORMAT Format); |
| 76 |
static const DXGI_FORMAT* GetFormatCastSet (DXGI_FORMAT Format); |
| 77 |
static D3D_FORMAT_LAYOUT GetLayout (DXGI_FORMAT Format); |
| 78 |
static D3D_FORMAT_TYPE_LEVEL GetTypeLevel (DXGI_FORMAT Format); |
| 79 |
static UINT GetBitsPerUnit (DXGI_FORMAT Format); |
| 80 |
static UINT GetBitsPerUnitThrow (DXGI_FORMAT Format); |
| 81 |
static UINT GetBitsPerElement (DXGI_FORMAT Format); |
| 82 |
static UINT GetWidthAlignment (DXGI_FORMAT Format); |
| 83 |
static UINT GetHeightAlignment (DXGI_FORMAT Format); |
| 84 |
static UINT GetDepthAlignment (DXGI_FORMAT Format); |
| 85 |
static BOOL Planar (DXGI_FORMAT Format); |
| 86 |
static BOOL NonOpaquePlanar (DXGI_FORMAT Format); |
| 87 |
static BOOL YUV (DXGI_FORMAT Format); |
| 88 |
static BOOL Opaque (DXGI_FORMAT Format); |
| 89 |
static bool FamilySupportsStencil (DXGI_FORMAT Format); |
| 90 |
static UINT NonOpaquePlaneCount (DXGI_FORMAT Format); |
| 91 |
static BOOL DX9VertexOrIndexFormat (DXGI_FORMAT Format); |
| 92 |
static BOOL DX9TextureFormat (DXGI_FORMAT Format); |
| 93 |
static BOOL FloatNormTextureFormat (DXGI_FORMAT Format); |
| 94 |
static bool DepthOnlyFormat (DXGI_FORMAT format); |
| 95 |
static UINT8 GetPlaneCount (DXGI_FORMAT Format); |
| 96 |
static bool MotionEstimatorAllowedInputFormat (DXGI_FORMAT Format); |
| 97 |
static bool SupportsSamplerFeedback (DXGI_FORMAT Format); |
| 98 |
static bool DecodeHistogramAllowedForOutputFormatSupport(DXGI_FORMAT Format); |
| 99 |
static UINT8 GetPlaneSliceFromViewFormat (DXGI_FORMAT ResourceFormat, DXGI_FORMAT ViewFormat); |
| 100 |
static bool FloatAndNotFloatFormats (DXGI_FORMAT FormatA, DXGI_FORMAT FormatB); |
| 101 |
static bool SNORMAndUNORMFormats (DXGI_FORMAT FormatA, DXGI_FORMAT FormatB); |
| 102 |
static bool ValidCastToR32UAV (DXGI_FORMAT from, DXGI_FORMAT to); |
| 103 |
static bool IsSupportedTextureDisplayableFormat (DXGI_FORMAT, bool bMediaFormatOnly); |
| 104 |
static D3D_FORMAT_COMPONENT_INTERPRETATION GetFormatComponentInterpretation (DXGI_FORMAT Format, UINT AbsoluteComponentIndex); |
| 105 |
static UINT GetBitsPerComponent (DXGI_FORMAT Format, UINT AbsoluteComponentIndex); |
| 106 |
static D3D_FORMAT_COMPONENT_NAME GetComponentName (DXGI_FORMAT Format, UINT AbsoluteComponentIndex); |
| 107 |
static HRESULT CalculateExtraPlanarRows (DXGI_FORMAT format, UINT plane0Height, _Out_ UINT& totalHeight); |
| 108 |
static HRESULT CalculateMinimumRowMajorRowPitch (DXGI_FORMAT Format, UINT Width, _Out_ UINT& RowPitch); |
| 109 |
static HRESULT CalculateMinimumRowMajorSlicePitch (DXGI_FORMAT Format, UINT ContextBasedRowPitch, UINT Height, _Out_ UINT& SlicePitch); |
| 110 |
static void GetYCbCrChromaSubsampling (DXGI_FORMAT Format, _Out_ UINT& HorizontalSubsampling, _Out_ UINT& VerticalSubsampling); |
| 111 |
|
| 112 |
static HRESULT CalculateResourceSize (UINT width, UINT height, UINT depth, DXGI_FORMAT format, UINT mipLevels, UINT subresources, _Out_ SIZE_T& totalByteSize, _Out_writes_opt_(subresources) D3D12_MEMCPY_DEST* pDst = nullptr); |
| 113 |
static void GetTileShape (D3D12_TILE_SHAPE* pTileShape, DXGI_FORMAT Format, D3D12_RESOURCE_DIMENSION Dimension, UINT SampleCount); |
| 114 |
static void Get4KTileShape (D3D12_TILE_SHAPE* pTileShape, DXGI_FORMAT Format, D3D12_RESOURCE_DIMENSION Dimension, UINT SampleCount); |
| 115 |
static void GetMipDimensions (UINT8 mipSlice, _Inout_ UINT64* pWidth, _Inout_opt_ UINT64* pHeight = nullptr, _Inout_opt_ UINT64* pDepth = nullptr); |
| 116 |
static void GetPlaneSubsampledSizeAndFormatForCopyableLayout(UINT PlaneSlice, DXGI_FORMAT Format, UINT Width, UINT Height, _Out_ DXGI_FORMAT& PlaneFormat, _Out_ UINT& MinPlanePitchWidth, _Out_ UINT& PlaneWidth, _Out_ UINT& PlaneHeight); |
| 117 |
|
| 118 |
static UINT GetDetailTableIndex (DXGI_FORMAT Format); |
| 119 |
static UINT GetDetailTableIndexNoThrow (DXGI_FORMAT Format); |
| 120 |
static UINT GetDetailTableIndexThrow (DXGI_FORMAT Format); |
| 121 |
static bool SupportsDepth (DXGI_FORMAT Format); |
| 122 |
static bool SupportsStencil (DXGI_FORMAT Format); |
| 123 |
private: |
| 124 |
static const FORMAT_DETAIL* GetFormatDetail (DXGI_FORMAT Format); |
| 125 |
|
| 126 |
}; |
| 127 |
|
| 128 |
#endif |