d3d12: GenerateMips() error: invalid mip level range
Steps to re-produce:
Create a Texture with mipmaps.
Fill texture mip0 with a compute shader
GenerateMips()
Problem
Diligent Engine: ERROR: Debug assertion failed in Diligent::`anonymous-namespace'::StateTransitionHelper::AddD3D12ResourceBarriers(), file CommandContext.cpp, line 309:
Invalid mip level range
My early inspection
GenerateMips.cpp:
// Transition dst mip levels to UAV state
StateTransitionDesc DstMipsBarrier{pTexD3D12, OriginalState, RESOURCE_STATE_UNORDERED_ACCESS, STATE_TRANSITION_FLAG_NONE};
if (DstMipsBarrier.OldState != DstMipsBarrier.NewState)
{
DstMipsBarrier.FirstMipLevel = ViewDesc.MostDetailedMip + TopMip + 1;
DstMipsBarrier.MipLevelsCount = NumMips;
DstMipsBarrier.FirstArraySlice = ViewDesc.FirstArraySlice;
DstMipsBarrier.ArraySliceCount = ViewDesc.NumArraySlices;
Ctx.TransitionResource(*pTexD3D12, DstMipsBarrier);
}
ComputeCtx.Dispatch((DstWidth + 7) / 8, (DstHeight + 7) / 8, ViewDesc.NumArraySlices);
// Transition the lowest level back to original layout or leave it in RESOURCE_STATE_SHADER_RESOURCE
// if all subresources are processed
if (SrcMipBarrier.NewState != FinalState)
{
SrcMipBarrier.OldState = SrcMipBarrier.NewState;
SrcMipBarrier.NewState = FinalState;
Ctx.TransitionResource(*pTexD3D12, SrcMipBarrier);
}
if (DstMipsBarrier.NewState != FinalState)
{
DstMipsBarrier.OldState = DstMipsBarrier.NewState;
DstMipsBarrier.NewState = FinalState;
// Do not transition the bottom level if we have more mips to process
if (TopMip + NumMips < BottomMip)
--DstMipsBarrier.MipLevelsCount;
if (DstMipsBarrier.MipLevelsCount > 0)
Ctx.TransitionResource(*pTexD3D12, DstMipsBarrier);
}
Transition DstMipsBarrier to FinalState, the DstMipsBarrier.MipLevelsCount maybe default to -1.
If previous DstMipsBarrier.OldState == DstMipsBarrier.NewState.
d3d12: GenerateMips() error: invalid mip level range
Steps to re-produce:
Problem
My early inspection
GenerateMips.cpp:
Transition DstMipsBarrier to FinalState, the DstMipsBarrier.MipLevelsCount maybe default to
-1
. If previousDstMipsBarrier.OldState == DstMipsBarrier.NewState
.I can provide sample code later if you like.