I’ve been using non-type template parameters Buffer<DXGI_FORMAT_R32G32B32_UINT, RING_BUFFER_LENGTH> m_myBuffer;
because I want to look at the type and know the values of it’s member constants (without having to look for where it’s constructor was called). However, I think this is slowing down compilation (there is a type/constructor instantiated each time I use the template).
template<DXGI_FORMAT FORMAT, UINT64 LENGTH>
struct GpuBuffer : GpuResource
{
static constexpr UINT64 length = LENGTH;;
static constexpr UINT64 DATA_TYPE_BYTES = DataTypeBytes(FORMAT);
GpuBuffer(GraphicsResources& resources, const wchar_t* name, D3D12_HEAP_TYPE heapType = D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE)
: GpuResource(resources, D3D12_RESOURCE_STATE_COMMON
, CD3DX12_RESOURCE_DESC::Buffer(LENGTH* DATA_TYPE_BYTES, flags)
, name, heapType)
{}
};
I thought about using a naming convention, so that when I jump to definition, I will be able to see the parameters that I (hopefully) parsed to the constructor.
struct Parent {
Config m_myBufferConfig{DXGI_FORMAT_R32G32B32_UINT, RING_BUFFER_LENGTH};
GpuResource m_myBuffer;
Parent() : m_myBuffer{m_myBufferConfig.format, m_myBufferConfig.length} {}
}
I assume this is a known problem. How do people solve this?
3