Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create UAV for 3D texture #381

Open
Bundas102 opened this issue Sep 12, 2023 · 1 comment
Open

Cannot create UAV for 3D texture #381

Bundas102 opened this issue Sep 12, 2023 · 1 comment

Comments

@Bundas102
Copy link

Creating a UAV for any MIP level other than the base level fails.

auto tex = Texture::create3D(mpDevice, 32, 32, 32, ResourceFormat::R8Uint, 2, nullptr, ResourceBindFlags::AllColorViews);
auto uav = tex->getUAV(1);

The above code results in the following error.
D3D12 ERROR: ID3D12Device::CreateUnorderedAccessView: The Dimensions of the View are invalid. MipSlice (value = 1) must be between 0 and MipLevels-1 of the Texture Resource, 1, inclusively. FirstWSlice (value = 0) must be between 0 and the Depth size of the Mip Level, 15, inclusively. With the current FirstWSlice, WSize (value = 32) must be between 1 and 16, or -1 to default to all slices from MipSlice, inclusively, in order that the View fit on the Texture. [ STATE_CREATION ERROR #345: CREATEUNORDEREDACCESSVIEW_INVALIDDIMENSIONS]

The problem is WSize being 32 insted of 16 (since level 1 is half the size of the full texture). Similar things happen for larger MIP levels; WSize seems to be always set to the base size.

@valasekg
Copy link

valasekg commented Jan 5, 2025

@skallweitNV , could you please let us know if you consider this a Falcor issue or a Slang Gfx one? I am fine with either but if the latter, I'd like to take this to the Slang repository. This issue blocks explicitly UAV-ing up a non-base mip level of a 3D texture. We usually patch up Falcor\Source\Falcor\Core\API\Texture.cpp 's Texture::getUAV something to the effect of

ref<UnorderedAccessView> Texture::getUAV(uint32_t mipLevel, uint32_t firstArraySlice, uint32_t arraySize)
{
    auto createFunc =
        [mipLevel](Texture* pTexture, uint32_t mostDetailedMip, uint32_t mipCount, uint32_t firstArraySlice, uint32_t arraySize)
    {
        auto& size = pTexture->getGfxTextureResource()->getDesc()->size;
        gfx::ITextureResource::Extents origSize = size;
        size.depth = size.depth >> mipLevel;
        size.depth = size.depth < 1 ? 1 : size.depth;
        auto view = UnorderedAccessView::create(pTexture->getDevice().get(), pTexture, mostDetailedMip, firstArraySlice, arraySize);
        size = origSize;
        return view;
    };
    return findViewCommon<UnorderedAccessView>(this, mipLevel, 1, firstArraySlice, arraySize, mUavs, createFunc);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants