Skip to content

Validation error when creating (some) images with an allocator with tight alignment enabled (fix proposal) #83

@rtryan98

Description

@rtryan98

When creating resources, the allocator will add the D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT flag, independently of the resource dimension.

Because images aren't supported with tight alignment, and the allocator properly changes the provided alignment of 0 to the correct value, the following validation error appears:

ID3D12Device::GetResourceAllocationInfo2: D3D12_RESOURCE_DESC::Alignment is invalid. The value is 4096. When D3D12_RESOURCE_DESC::Flag bit for D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT is set, Alignment must be 0. [ STATE_CREATION ERROR #721: CREATERESOURCE_INVALIDALIGNMENT]

Adding a check for inOutResourceDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER here fixes the issue.

if (IsTightAlignmentEnabled() &&
// Don't allow USE_TIGHT_ALIGNMENT together with ALLOW_CROSS_ADAPTER as there is a D3D Debug Layer error:
// D3D12 ERROR: ID3D12Device::GetResourceAllocationInfo: D3D12_RESOURCE_DESC::Flag D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT will be ignored since D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER is set. [ STATE_CREATION ERROR #599: CREATERESOURCE_INVALIDMISCFLAGS]
(inOutResourceDesc.Flags & D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER) == 0)
{
inOutResourceDesc.Flags |= D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions