当前位置:网站首页>unity computeshader的可读写buffer
unity computeshader的可读写buffer
2022-07-31 10:32:00 【VT LI】
可读写buffer:
computeshader中的读写的buffer,在opengl上是用ssbo实现的。
KernelState中的inBuffers,outBuffers这些buffer,会走到GfxDeviceGLES::SetComputeBuffer,如果索引0x7FFFFF表示GLE中实际上不存在缓冲区,但仍然需要计数器。则用BindShaderStorageBuffer来绑定ssbo,

ssbo的特点
1.如果用ubo,他的大小只能在16kb以内,但是ssbo可以达到128mb。
2.ssbo是可写的
3.ssbo具有可变存储,最多可达为该特定缓冲区绑定的任何缓冲区范围
4.在所有条件相同的情况下,SSBO访问可能会比UBO访问慢。
绑定方式
GLuint ssbo;
glGenBuffers(1, &ssbo);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(data), data, GLenum usage); //sizeof(data) only works for statically sized C/C++ arrays.
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, ssbo);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); // unbindshader中使用
layout(std430, binding = 2) buffer anotherLayoutName
{
int some_int;
float fixed_array[42];
float variable_array[];
};对应的dx12的概念是
Structured Buffer | SSBO |
UAV Buffer,RWBuffer | SSBO |
边栏推荐
猜你喜欢
随机推荐
力扣shell刷题
内网渗透学习(四)域横向移动——SMB和WMI服务利用
SQL存储过程详解
Make your own dataset in FCN and train it
尚医通【预约挂号系统】总结
cocoaPods管理之后工程结构变化
Windows安装mysql详细步骤(通俗易懂,简单上手)
【Go事】一眼看穿 Go 的集合和切片
MySQL中JOIN的用法
csdn文件导出为pdf
梅科尔工作室--鸿蒙十四天开发培训笔记(八)
matlab 读取csv文件绘图
Deletion of the sequence table
Day113. Shangyitong: user authentication, Alibaba Cloud OSS, patient management
NowCoderTOP17-22 Binary search/sort - continuous update ing
Hospital management system database, course design, SQLserver, pure code design
【LeetCode】383.赎金信
Add a shuffling effect to every pie
[Part 1 of Cloud Native Monitoring Series] A detailed explanation of Prometheus monitoring system
Redis的简单使用









