示例#1
0
// 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;
}