gpt4 book ai didi

glsl - 计算着色器中 [[vk::binding(0, 0)]] RWStructuredBuffer 的 GLSL 等价物是什么

转载 作者:行者123 更新时间:2023-12-02 15:49:39 24 4
gpt4 key购买 nike

我有这个 HLSL,我想用 GLSL 编写等价物。如果有用的话,我正在尝试运行此示例 https://github.com/mcleary/VulkanHpp-Compute-Sample

[[vk::binding(0, 0)]] RWStructuredBuffer<int> InBuffer;
[[vk::binding(1, 0)]] RWStructuredBuffer<int> OutBuffer;

[numthreads(1, 1, 1)]
void Main(uint3 DTid : SV_DispatchThreadID)
{
OutBuffer[DTid.x] = InBuffer[DTid.x] * InBuffer[DTid.x];
}

最佳答案

等效的 GLSL 应如下所示:

layout(std430, binding = 0) buffer InBuffer {
int inBuffer[ ];
};

layout(std430, binding = 1) buffer OutBuffer {
int outBuffer[ ];
};

layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main()
{
outBuffer[gl_GlobalInvocationID.x] = inBuffer[gl_GlobalInvocationID.x] * inBuffer[gl_GlobalInvocationID.x];
}

关于glsl - 计算着色器中 [[vk::binding(0, 0)]] RWStructuredBuffer<int> 的 GLSL 等价物是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72942798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com