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

wrong calculation for vulkan buffer 4-byte alignment in vkCmdUpdateBuffer #38

Closed
BlurryLight opened this issue Oct 26, 2023 · 1 comment

Comments

@BlurryLight
Copy link
Contributor

size += size % 4;

thisGulpSize += thisGulpSize % 4;

take 5 byte as example , 5 + (5 % 4) = 6, which is not multiple of 4.

An easily reproducible code is as follows:

        nvrhi::BufferDesc desc{};
        desc.byteSize = 5;
        desc.keepInitialState = true;
        desc.initialState = nvrhi::ResourceStates::Common; // some boilerplate...
        auto buf = GetDevice()->createBuffer(desc);
        std::array<uint8_t, 5> data{0, 1, 2, 3, 4};
        m_CommandList->writeBuffer(buf, data.data(),sizeof(data)); // write 5 bytes

vulkan validation layer catchs the error:

WARNING: [Vulkan: location=0xe9aa8ae3 code=0, layerPrefix='Validation'] Validation Error: [ VUID-vkCmdUpdateBuffer-dataSize-00038 ] Object 0: handle = 0x275ca6f9400, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xe9aa8ae3 | vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x6), is not a multiple of 4. The Vulkan spec states: dataSize must be a multiple of 4 (https://vulkan.lunarg.com/doc/view/1.3.243.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdUpdateBuffer-dataSize-00038)
@apanteleev
Copy link
Contributor

Fixed. Thank you for reporting this issue.

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