当大量元素时,Vulkan Buffer WorkGroupID不返回实际值 [英] Vulkan Buffer WorkGroupID not returning actual value when large number of elements

查看:150
本文介绍了当大量元素时,Vulkan Buffer WorkGroupID不返回实际值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 pow(2,24) local_size_x = 64 创建一个缓冲区作为布局输入限定符返回 WorkGroupID = 262143 ,由于 pow(2,24)/ 64-1 都很好,它为零

Creating a buffer with pow(2, 24) and a local_size_x = 64 for the layout input qualifier will return WorkGroupID = 262143 which is all fine due to pow(2,24) / 64 - 1, it is zero indexed.

但是,如果我们将问题的全局维度/无元素/大小增加到 pow(2,25)假设 WorkGroupID 将无缘无故地返回值,它们与数学值不匹配。

However if we increase the global dimension / no elements / size of the problem to pow(2, 25) lets say WorkGroupID will return values without a reason, they do not match the math.

这里有一些设备认为我认为重要的限制:

Here are some limits that the device got that I think matter:

maxStorageBufferRange:          uint32_t = 4294967295
        maxComputeSharedMemorySize:     uint32_t = 32768
        maxComputeWorkGroupCount:       uint32_t[3] = 00000202898A8EC4
            maxComputeWorkGroupCount[0]:    uint32_t = 65535
            maxComputeWorkGroupCount[1]:    uint32_t = 65535
            maxComputeWorkGroupCount[2]:    uint32_t = 65535
        maxComputeWorkGroupInvocations: uint32_t = 1024
        maxComputeWorkGroupSize:        uint32_t[3] = 00000202898A8ED4
            maxComputeWorkGroupSize[0]:     uint32_t = 1024
            maxComputeWorkGroupSize[1]:     uint32_t = 1024
            maxComputeWorkGroupSize[2]:     uint32_t = 1024

我不会过多分配设备支持的元素。
因此,经过2天+ 16小时,我仍然不知道发生了什么...

I do not go overboard with allocating more elements that the device supports. So after 2 days + 16 hrs I still did not figure out whats going on...

WorkGroupSize WorkGroupID LocalInvocationID GlobalInvocationID 表示相同的内容问题,当我达到否。的元素。难怪 GlobalInvocationID 会由于计算方式而出现相同的问题...

WorkGroupSize, WorkGroupID, LocalInvocationID and GlobalInvocationID presents the same problem when I reach a n no. of elements. It is no wonder that GlobalInvocationID presents the same problem due to how it is calculated...

#version 450
// Size of the Local Work-group is defined trough input layout qualifier
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;


layout(set = 0, binding = 0) buffer deviceBuffer
{
   uint x[];
};


void main() {
    uint i = gl_GlobalInvocationID.x;
    //uint i = gl_WorkGroupSize.x * gl_WorkGroupID.x * gl_LocalInvocationID.x;


    //x[i] += x[i];

// Total No. of Work Items (threads) in Global Dimension
//x[i] = gl_NumWorkGroups.x;

// Size of Work Dimension specified in Input Layout Qualifier
//x[i] = gl_WorkGroupSize.x;

// Is given by Global Dimension / Work Group Size
x[i] = gl_WorkGroupID.x;

//x[i] = gl_LocalInvocationID.x;

}


推荐答案


maxComputeWorkGroupCount[0]: uint32_t = 65535
maxComputeWorkGroupCount[1]: uint32_t = 65535
maxComputeWorkGroupCount[2]: uint32_t = 65535

vkCmdDispatch 的大小为x = pow(2,25 ),y = 1,z = 1

vkCmdDispatch have the size in x = pow(2, 25), y = 1, z = 1

根据您提供的信息 groupCountX = 2 25 = 33554432,但限制为 maxComputeWorkGroupCount [0] = 65535 = 2 16 -1

Based on the info you provided groupCountX = 225 = 33554432, but the limit is maxComputeWorkGroupCount[0] = 65535 = 216-1.

Vulkan规范 vkCmdDispatch的有效用法说:

The Vulkan specification Valid Usage for vkCmdDispatch says:



  • groupCountX 必须小于或等于 VkPhysicalDeviceLimits :: maxComputeWorkGroupCount [0]

  • groupCountX must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0]

违反有效用法是未定义的行为。 不确定的行为是指从看起来一切正常的一切到您的PC陷入黑洞并破坏该太阳系的任何事物。出于所有意图和目的,违反有效用法是应用程序代码的逻辑错误。

Violating Valid Usage is undefined behavior. "Undefined behavior" means anything from "everything seemingly working fine" to "your PC colapses into a black hole and destroys this solar system". For all intents and purposes violating Valid Usage is a logical error of the application code.

这篇关于当大量元素时,Vulkan Buffer WorkGroupID不返回实际值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆