1 Star 0 Fork 1

波波/Gut

forked from 2144/Gut 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ShaderStorageBuffer.h 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
2144 提交于 2023-10-02 12:14 . s
#pragma once
#include "Core.h"
#ifdef _WIN32
struct ShaderStorageBuffer
{
unsigned int SSBO;
struct Desc
{
const void *data = 0;
unsigned int dataLen;
unsigned int usage = GL_DYNAMIC_COPY;
unsigned int binding;
};
bool Create(const Desc &desc);
template <typename T>
bool Create(unsigned int binding)
{
Desc desc;
desc.dataLen = sizeof(T);
desc.binding = binding;
return Create(desc);
}
template <typename T>
void Write(const T &buf)
{
glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO);
GLvoid *p = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY);
memcpy(p, &buf, sizeof(buf));
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
};
template <typename T>
void Write(void *data, int len)
{
glBindBuffer(GL_SHADER_STORAGE_BUFFER, SSBO);
GLvoid *p = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY);
memcpy(p, data, len);
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
}
template <typename T>
void Read(T &t)
{
Read(&t, sizeof(T));
}
void Read(void *data, int dataLen);
void Delete();
};
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bobo110/gut.git
git@gitee.com:bobo110/gut.git
bobo110
gut
Gut
master

搜索帮助