首页 \ 问答 \ 指向Compute Shader的输入结构的指针(Pointer into input struct of Compute Shader)

指向Compute Shader的输入结构的指针(Pointer into input struct of Compute Shader)

我的计算着色器再次出现问题...我想将包含指针的结构传递给计算着色器。 这是我的结构示例:

struct couleurStruct {
    float r;
    float g;
    float b;
    float a;
    float *x;
};

这是我的SSBO初始化:

couleurStruct *coul;
coul = (couleurStruct *)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 1 * sizeof(couleurStruct), bufMask);
//coul->x = (float *)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 1 * sizeof(float), bufMask);

coul->r = 0.0;
coul->g = 1.0;
coul->b = 0.0;
coul->a = 1.0;
coul->x[0] = 0.5;

glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);

glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, structBuffer);

我尝试了很多不同的初始化但没有成功......

那么,有没有办法分配所需的所有内存(因为我知道我的指针所指向的每个数组中需要的内存)并将其传递给计算着色器? 或者是否真的不可能将指针传递给计算着色器?

感谢您的帮助!


Once more I have a problem with my compute shader... I would like to pass a structure containing a pointer into a compute shader. This is my structure example:

struct couleurStruct {
    float r;
    float g;
    float b;
    float a;
    float *x;
};

Here is my SSBO initialization :

couleurStruct *coul;
coul = (couleurStruct *)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 1 * sizeof(couleurStruct), bufMask);
//coul->x = (float *)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 1 * sizeof(float), bufMask);

coul->r = 0.0;
coul->g = 1.0;
coul->b = 0.0;
coul->a = 1.0;
coul->x[0] = 0.5;

glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);

glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, structBuffer);

I tried a lot of different initializations but without success...

So, is there a way to allocate all the memory needed (because I know the memory I will need inside each of the arrays pointed by my pointers) and pass it to the compute shader? Or is it really impossible to pass a pointer to a compute shader?

Thank you for your help!


原文:https://stackoverflow.com/questions/42396805
更新时间:2023-04-15 13:04

最满意答案

您需要重新编译库。

  1. 删除构建它的目录。
  2. 创建一个目录来构建库。
  3. 切换到该目录并发出:

    ../configure --enable-unicode --enable-debug

  4. 问题

  5. 编译你的项目。

顺便说一下,你有没有理由尝试过时的wx版本? 你应该得到最新的3.1版本。


You need to recompile the library.

  1. Remove the directory where you build it.
  2. Create a directory to build the library.
  3. Change to that directory and issue:

    ../configure --enable-unicode --enable-debug

  4. Issue make

  5. Compile you project.

BTW, is there a reason you are trying an outdated version of wx? You should get the latest 3.1 release.

相关问答

更多
  • 您需要重新编译库。 删除构建它的目录。 创建一个目录来构建库。 切换到该目录并发出: ../configure --enable-unicode --enable-debug 问题 编译你的项目。 顺便说一下,你有没有理由尝试过时的wx版本? 你应该得到最新的3.1版本。 You need to recompile the library. Remove the directory where you build it. Create a directory to build the library. Ch ...
  • 您需要向Button添加自定义CSS: GdkDisplay *display; GdkScreen *screen; display = gdk_display_get_default (); screen = gdk_display_get_default_screen (display); GtkCssProvider *provider; provider = gtk_css_provider_new (); gtk_style_context_add_provider_for_screen ...
  • 您可以尝试更改标签的颜色而不是按钮的颜色。 按钮实际上只是可点击的垃圾箱。 带文本的按钮只是一个有用的构造函数,可以自动添加标签。 #histoToolGreen label { color: green; } #histoToolBlue label { color: blue; } You might try changing the color of the label rather than that of the button. Buttons are really just clic ...
  • 您可能需要检查您的标头是否都没有以这种方式或那种方式声明DEBUG宏。 我遇到过这个问题一次。 除此之外,最好还是执行静态链接。 You may need to check if none of your headers declares DEBUG macro this or that way. I ran into this problem once. Apart from that, it may be better to perform static linking instead.
  • Gtk.Widget类具有Gtk.Widget类型的Accessible属性。 您可以获得但不设置此属性。 您也无法在子类中覆盖它。 但是,似乎Atk.Object具有多个可写属性,写入它们会更改AT返回的信息。 例如: var widget = new Gtk.Label("Hello World"); widget.Accessible.Role = Atk.Role.PushButton; 这会创建一个普通的标签小部件,但会导致AT认为它实际上是一个按钮小部件。 我还没有确定如何更改窗口小部件的明显 ...
  • 如果你想改变你的应用程序的总体字体,我会把这个工作留给gtkrc(然后成为一个谷歌问题,“gtkrc字体”查询将我们带到这个Ubuntu论坛链接 ,其中有以下代码片段gtkrc文件): style "font" { font_name = "Corbel 8" } widget_class "*" style "font" gtk-font-name = "Corbel 8" (用您/用户需要的字体替换字体) 然后,用户将获得一致的体验,并且能够轻松更改设置,而无需篡改代码,也无需处理维护个人配置相关代码 ...
  • 你只需要用新的库版本重新编译它。 从收到的错误消息来看,您没有这样做,或者编译失败。 另外,请确保您阅读有关升级到3.0的文档,因为它几乎是您将会遇到错误的保证。 You just need to re-compile it with the new library version. Judging from the error message you received you didn't do it or the compilation was unsuccessful. Also, make sure ...
  • 我已经找到了问题(它只花了我一个月的最佳时间:)) - 你需要在你的机器上安装g++ 。 您可以使用sudo yum install gcc-c++安装它。 I have figured out the issue (and it only took me the best part of a month :))--you need to have g++ installed on your machine. You can install it with sudo yum install gcc-c++. ...
  • 于是我在网上搜索,发现了“patchelf”命令。 由于我的二进制文件(使用cx_Freeze生成)与我的可执行文件位于同一目录中,因此我创建了该脚本: for i in *so* do patchelf --set-rpath '.' $i done 因为,我的独立应用程序可以在“空的”openSuse系统上启动...... 注意: 该解决方案适用于cx_Freeze 4.3.x,但不适用于5.x版本 我成功地在各种其他Linux平台(Debian,Mint,Ubuntu,Mageia,Fed ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)