// TEXTURE FUNCTIONS
ComputeTexture* ComputeWrap::CreateTexture(DXGI_FORMAT dxFormat, UINT uWidth,
        UINT uHeight, UINT uRowPitch, VOID* pInitData, bool bCreateStaging, char* debugName)
{
    ComputeTexture* texture = new ComputeTexture();
    texture->_D3DContext = mD3DDeviceContext;

    texture->_Resource = CreateTextureResource(dxFormat, uWidth, uHeight, uRowPitch, pInitData);

    if(texture->_Resource != nullptr)
    {
        texture->_ResourceView = CreateTextureSRV(texture->_Resource);
        texture->_UnorderedAccessView = CreateTextureUAV(texture->_Resource);

        if(bCreateStaging)
            texture->_Staging = CreateStagingTexture(texture->_Resource);
    }

    if(debugName)
    {
        if(texture->_Resource)				SetDebugName(texture->_Resource, debugName);
        if(texture->_Staging)				SetDebugName(texture->_Staging, debugName);
        if(texture->_ResourceView)			SetDebugName(texture->_ResourceView, debugName);
        if(texture->_UnorderedAccessView)	SetDebugName(texture->_UnorderedAccessView, debugName);
    }

    return texture;
}
// TEXTURE FUNCTIONS
ComputeTexture* Compute::CreateTexture(DXGI_FORMAT dxFormat, UINT uWidth,
	UINT uHeight, UINT uRowPitch, VOID* initData, bool createStaging, char* debugName)
{
	ComputeTexture* texture = new ComputeTexture();
	texture->m_deviceContext = m_deviceContext;

	texture->m_resource = CreateTextureResource(dxFormat, uWidth, uHeight, uRowPitch, initData);

	if(texture->m_resource != nullptr)
	{
		texture->m_resourceView = CreateTextureSRV(texture->m_resource);
		texture->m_unorderedAccessView = CreateTextureUAV(texture->m_resource);
		
		if(createStaging)
			texture->m_staging = CreateStagingTexture(texture->m_resource);
	}

	if(debugName)
	{
		if(texture->m_resource)				SetDebugName(texture->m_resource, debugName);
		if(texture->m_staging)				SetDebugName(texture->m_staging, debugName);
		if(texture->m_resourceView)			SetDebugName(texture->m_resourceView, debugName);
		if(texture->m_unorderedAccessView)	SetDebugName(texture->m_unorderedAccessView, debugName);
	}

	return texture;
}
Beispiel #3
0
 void DepthBuffer::Create(const std::wstring & name, uint32_t width, uint32_t height, DXGI_FORMAT format, D3D12_GPU_VIRTUAL_ADDRESS vMemPtr)
 {
     D3D12_RESOURCE_DESC resDesc = describeTex2D(width, height, 1, 1, format, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL);
     D3D12_CLEAR_VALUE clearValue = {};
     clearValue.Format = format;
     clearValue.DepthStencil.Depth = m_clearDepth;
     clearValue.DepthStencil.Stencil = m_clearStencil;
     CreateTextureResource(graphics::g_pDevice, name, resDesc, clearValue, vMemPtr);
     CreateDerivedViews(graphics::g_pDevice, format);
 }
void DepthBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, DXGI_FORMAT Format,
	D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr /* = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN */ )
{
	D3D12_RESOURCE_DESC ResourceDesc = DescribeTex2D( Width, Height, 1, 1, Format, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL );
	D3D12_CLEAR_VALUE ClearValue = {};
	ClearValue.Format = Format;
	ClearValue.DepthStencil.Depth = m_ClearDepth;
	ClearValue.DepthStencil.Stencil = m_ClearStencil;
	CreateTextureResource( Graphics::g_device.Get(), Name, ResourceDesc, ClearValue, VidMemPtr );
	CreateDerivedViews( Graphics::g_device.Get(), Format );
}
Beispiel #5
0
void ColorBuffer::CreateArray( const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t ArrayCount,
	DXGI_FORMAT Format, D3D12_GPU_VIRTUAL_ADDRESS VidMem )
{
	D3D12_RESOURCE_DESC ResourceDesc = DescribeTex2D(Width, Height, ArrayCount, 1, Format,
		D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);

	D3D12_CLEAR_VALUE ClearValue = {};
	ClearValue.Format = Format;
	ClearValue.Color[0] = m_ClearColor.R();
	ClearValue.Color[1] = m_ClearColor.G();
	ClearValue.Color[2] = m_ClearColor.B();
	ClearValue.Color[3] = m_ClearColor.A();

	CreateTextureResource(Graphics::g_Device, Name, ResourceDesc, ClearValue, VidMem);
	CreateDerivedViews(Graphics::g_Device, Format, ArrayCount, 1);
}
void ColorBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t NumMips,
	DXGI_FORMAT Format, D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr /* = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN */ )
{
	NumMips = (NumMips == 0 ? ComputeNumMips( Width, Height ) : NumMips);
	D3D12_RESOURCE_DESC ResourceDesc = DescribeTex2D( Width, Height, 1, NumMips, Format,
		D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS );

	D3D12_CLEAR_VALUE ClearValue = {};
	ClearValue.Format = Format;
	ClearValue.Color[0] = DirectX::XMVectorGetX( m_ClearColor );
	ClearValue.Color[1] = DirectX::XMVectorGetY( m_ClearColor );
	ClearValue.Color[2] = DirectX::XMVectorGetZ( m_ClearColor );
	ClearValue.Color[3] = DirectX::XMVectorGetW( m_ClearColor );

	CreateTextureResource( Graphics::g_device.Get(), Name, ResourceDesc, ClearValue, VidMemPtr );
	CreateDerivedViews( Graphics::g_device.Get(), Format, 1, NumMips );
}