Skip to content

Commit

Permalink
Updated for latest d3dx12.h
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Nov 18, 2016
1 parent a600872 commit 1c5c524
Showing 1 changed file with 68 additions and 2 deletions.
70 changes: 68 additions & 2 deletions Src/d3dx12.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,71 @@ struct CD3DX12_RECT : public D3D12_RECT
operator const D3D12_RECT&() const { return *this; }
};

//------------------------------------------------------------------------------------------------
struct CD3DX12_VIEWPORT : public D3D12_VIEWPORT
{
CD3DX12_VIEWPORT()
{}
explicit CD3DX12_VIEWPORT( const D3D12_VIEWPORT& o ) :
D3D12_VIEWPORT( o )
{}
explicit CD3DX12_VIEWPORT(
FLOAT topLeftX,
FLOAT topLeftY,
FLOAT width,
FLOAT height,
FLOAT minDepth = D3D12_MIN_DEPTH,
FLOAT maxDepth = D3D12_MAX_DEPTH )
{
TopLeftX = topLeftX;
TopLeftY = topLeftY;
Width = width;
Height = height;
MinDepth = minDepth;
MaxDepth = maxDepth;
}
explicit CD3DX12_VIEWPORT(
_In_ ID3D12Resource* pResource,
UINT mipSlice = 0,
FLOAT topLeftX = 0.0f,
FLOAT topLeftY = 0.0f,
FLOAT minDepth = D3D12_MIN_DEPTH,
FLOAT maxDepth = D3D12_MAX_DEPTH )
{
D3D12_RESOURCE_DESC Desc = pResource->GetDesc();
const UINT64 SubresourceWidth = Desc.Width >> mipSlice;
const UINT64 SubresourceHeight = Desc.Height >> mipSlice;
switch (Desc.Dimension)
{
case D3D12_RESOURCE_DIMENSION_BUFFER:
TopLeftX = topLeftX;
TopLeftY = 0.0f;
Width = Desc.Width - topLeftX;
Height = 1.0f;
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE1D:
TopLeftX = topLeftX;
TopLeftY = 0.0f;
Width = (SubresourceWidth ? SubresourceWidth : 1.0f) - topLeftX;
Height = 1.0f;
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE2D:
case D3D12_RESOURCE_DIMENSION_TEXTURE3D:
TopLeftX = topLeftX;
TopLeftY = topLeftY;
Width = (SubresourceWidth ? SubresourceWidth : 1.0f) - topLeftX;
Height = (SubresourceHeight ? SubresourceHeight: 1.0f) - topLeftY;
break;
default: break;
}

MinDepth = minDepth;
MaxDepth = maxDepth;
}
~CD3DX12_VIEWPORT() {}
operator const D3D12_VIEWPORT&() const { return *this; }
};

//------------------------------------------------------------------------------------------------
struct CD3DX12_BOX : public D3D12_BOX
{
Expand Down Expand Up @@ -453,13 +518,13 @@ struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE
D3D12_SHADER_BYTECODE(o)
{}
CD3DX12_SHADER_BYTECODE(
ID3DBlob* pShaderBlob )
_In_ ID3DBlob* pShaderBlob )
{
pShaderBytecode = pShaderBlob->GetBufferPointer();
BytecodeLength = pShaderBlob->GetBufferSize();
}
CD3DX12_SHADER_BYTECODE(
void* _pShaderBytecode,
const void* _pShaderBytecode,
SIZE_T bytecodeLength )
{
pShaderBytecode = _pShaderBytecode;
Expand Down Expand Up @@ -1938,6 +2003,7 @@ inline HRESULT D3DX12SerializeVersionedRootSignature(
return E_INVALIDARG;
}


#endif // defined( __cplusplus )

#endif //__D3DX12_H__
Expand Down

0 comments on commit 1c5c524

Please sign in to comment.