DirectX Compute Shaders是否在共享内存中支持2D阵列? [英] Do DirectX Compute Shaders support 2D arrays in shared memory?

查看:135
本文介绍了DirectX Compute Shaders是否在共享内存中支持2D阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在DirectX Compute Shader中使用groupshared内存以减少全局内存带宽并希望提高性能.我的输入数据是Texture2D,我可以使用2D索引访问它,如下所示:

I want to use groupshared memory in a DirectX Compute Shader to reduce global memory bandwidth and hopefully improve performance. My input data is a Texture2D and I can access it using 2D indexing like so:

Input[threadID.xy]

我想要一个共享内存的2D数组来缓存部分输入数据,所以我尝试了显而易见的方法:

I would like to have a 2D array of shared memory for caching portions of the input data, so I tried the obvious:

groupshared float SharedInput[32, 32];

它不会编译.错误消息显示syntax error: unexpected token ','.

It won't compile. The error message says syntax error: unexpected token ','.

有什么办法可以拥有2D共享内存数组吗?如果没有,那么使用存储在1D共享内存数组中的2D数据的好技术是什么?

Is there any way to have a 2D array of shared memory? If not, what's a good technique for working with 2D data stored in a 1D array of shared memory?

推荐答案

groupshared数组无法使用多维索引建立索引.您可以获得的最接近的是一个数组数组,其中每个维度都被独立索引.

groupshared arrays cannot be indexed with multi-dimensional indexing. The closest you can get is an array of arrays where each dimension is indexed independently.

groupshared float SharedInput[32][32];

它不像多维索引那么好,但是至少您不必手动计算线性索引.

It's not as nice as multi-dimensional indexing, but at least you don't have to compute a linear index manually.

这篇关于DirectX Compute Shaders是否在共享内存中支持2D阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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