void GpuBuffer::Create( const std::wstring& Name, uint32_t NumElements, uint32_t ElementSize, const void* InitData /* = nullptr */ ) { m_ElementCount = NumElements; m_ElementSize = ElementSize; m_BufferSize = NumElements*ElementSize; D3D12_RESOURCE_DESC ResourceDesc = DescribeBuffer(); m_UsageState = D3D12_RESOURCE_STATE_COMMON; D3D12_HEAP_PROPERTIES HeapProps; HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; HeapProps.CreationNodeMask = 1; HeapProps.VisibleNodeMask = 1; HRESULT hr; V( Graphics::g_device->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, &ResourceDesc, m_UsageState, nullptr, IID_PPV_ARGS( &m_pResource ) ) ); m_GpuVirtualAddress = m_pResource->GetGPUVirtualAddress(); if (InitData) CommandContext::InitializeBuffer( *this, InitData, m_BufferSize ); #ifdef RELEASE ( Name ); #else m_pResource->SetName( Name.c_str() ); #endif CreateDerivedViews(); }
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 ); }
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 ); }
void GpuBuffer::CreatePlaced( const std::wstring& Name, ID3D12Heap* BackingHeap, uint32_t HeapOffset, uint32_t NumElements, uint32_t ElementSize, const void* InitData /* = nullptr */ ) { m_ElementCount = NumElements; m_ElementSize = ElementSize; m_BufferSize = NumElements * ElementSize; HRESULT hr; D3D12_RESOURCE_DESC ResourceDesc = DescribeBuffer(); m_UsageState = D3D12_RESOURCE_STATE_COMMON; V( Graphics::g_device->CreatePlacedResource( BackingHeap, HeapOffset, &ResourceDesc, m_UsageState, nullptr, IID_PPV_ARGS( &m_pResource ) ) ); m_GpuVirtualAddress = m_pResource->GetGPUVirtualAddress(); if (InitData) CommandContext::InitializeBuffer( *this, InitData, m_BufferSize ); #ifdef RELEASE ( Name ); #else m_pResource->SetName( Name.c_str() ); #endif CreateDerivedViews(); }
//-------------------------------------------------------------------------------------- // VolumeTexture //-------------------------------------------------------------------------------------- void VolumeTexture::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t Depth, 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 Desc = DescribeTex3D(Width, Height, Depth, NumMips, Format, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS); D3D12_HEAP_PROPERTIES HeapProps; HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; HeapProps.CreationNodeMask = 1; HeapProps.VisibleNodeMask = 1; HRESULT hr; V( Graphics::g_device->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, &Desc, D3D12_RESOURCE_STATE_COMMON, NULL, IID_PPV_ARGS( &m_pResource ) ) ); #ifdef RELEASE (Name); #else m_pResource->SetName(Name.c_str()); #endif CreateDerivedViews(); }