#include <ShaderSystem.h>
Public 成员函数 | |
| ShaderSystem ()=default | |
| ~ShaderSystem () | |
| ShaderSystem (const ShaderSystem &)=delete | |
| ShaderSystem & | operator= (const ShaderSystem &)=delete |
| void | setGpgpu (Gpgpu *gpu) |
| Gpgpu * | getGpgpu () const |
| void | setShaderSource (const std::string &glsl) |
| void | setShader (ComputeShader *shader, bool takeOwnership=false) |
| ComputeShader * | getShader () const |
| void | setLocalSize (int localSize) |
| int | getLocalSize () const |
| GpuBuffer * | ensureBuffer (int binding, int floatCount) |
| GpuBuffer * | getBuffer (int binding) const |
| void | upload (int binding, const float *data, int floatCount) |
| void | download (int binding, float *out, int floatCount) const |
| void | upload (int binding, const std::vector< float > &data) |
| std::vector< float > | download (int binding, int floatCount) const |
| void | setFloat (int index, float value) |
| float | getFloat (int index) const |
| void | dispatch (int entityCount, float dt=0.f) |
| void | clearBuffers () |
静态 Public 属性 | |
| static constexpr int | kMaxBindings = ComputeShader::kMaxBindings |
| static constexpr int | kDefaultLocalSize = 64 |
详细描述
ECS ↔ GPGPU bridge: run a compute shader as an ECS System over N entities.
Layout convention (matches Gpgpu::dispatch):
- set=0 binding i = SSBO of tightly-packed floats for that field group
- push constants: data[0]=dt, data[1]=entityCount (float), data[2..]=user
Typical flow:
- setGpgpu + setShaderSource (or setShader)
- pack / upload float SoA-or-AoS streams per binding
- dispatch(entityCount)
- download / unpack back into components
Script: eve.ShaderSystem (extends eve.System) wraps this class. C++ ECS: use packViewComponent / unpackViewComponent in EcsGpu.h.
在文件 ShaderSystem.h 第 30 行定义.
构造及析构函数说明
◆ ShaderSystem() [1/2]
|
default |
◆ ~ShaderSystem()
| eve::gpgpu::ShaderSystem::~ShaderSystem | ( | ) |
在文件 ShaderSystem.cpp 第 12 行定义.
引用了 clearBuffers().
◆ ShaderSystem() [2/2]
|
delete |
成员函数说明
◆ clearBuffers()
| void eve::gpgpu::ShaderSystem::clearBuffers | ( | ) |
◆ dispatch()
| void eve::gpgpu::ShaderSystem::dispatch | ( | int | entityCount, |
| float | dt = 0.f |
||
| ) |
Bind buffers, set push[0]=dt and push[1]=entityCount, dispatch workgroups. No-op when shader/gpu missing or entityCount <= 0.
在文件 ShaderSystem.cpp 第 100 行定义.
引用了 eve::gpgpu::ComputeShader::bindBuffer(), eve::gpgpu::Gpgpu::dispatch(), kDefaultLocalSize, kMaxBindings , 以及 eve::gpgpu::ComputeShader::setFloat().
被这些函数引用 eve::gpgpu::runViewComponentSystem().
◆ download() [1/2]
| void eve::gpgpu::ShaderSystem::download | ( | int | binding, |
| float * | out, | ||
| int | floatCount | ||
| ) | const |
在文件 ShaderSystem.cpp 第 72 行定义.
引用了 getBuffer() , 以及 eve::gpgpu::GpuBuffer::readFloat32s().
被这些函数引用 download() , 以及 eve::gpgpu::unpackViewComponent().
◆ download() [2/2]
| std::vector< float > eve::gpgpu::ShaderSystem::download | ( | int | binding, |
| int | floatCount | ||
| ) | const |
在文件 ShaderSystem.cpp 第 84 行定义.
引用了 download().
◆ ensureBuffer()
| GpuBuffer * eve::gpgpu::ShaderSystem::ensureBuffer | ( | int | binding, |
| int | floatCount | ||
| ) |
Ensure binding has a storage buffer with at least floatCount floats.
在文件 ShaderSystem.cpp 第 44 行定义.
引用了 eve::gpgpu::GpuBuffer::getSize(), kMaxBindings , 以及 eve::gpgpu::Gpgpu::newBuffer().
被这些函数引用 upload().
◆ getBuffer()
| GpuBuffer * eve::gpgpu::ShaderSystem::getBuffer | ( | int | binding | ) | const |
◆ getFloat()
| float eve::gpgpu::ShaderSystem::getFloat | ( | int | index | ) | const |
在文件 ShaderSystem.cpp 第 95 行定义.
◆ getGpgpu()
|
inline |
在文件 ShaderSystem.h 第 42 行定义.
◆ getLocalSize()
|
inline |
在文件 ShaderSystem.h 第 56 行定义.
◆ getShader()
|
inline |
在文件 ShaderSystem.h 第 53 行定义.
◆ operator=()
|
delete |
◆ setFloat()
| void eve::gpgpu::ShaderSystem::setFloat | ( | int | index, |
| float | value | ||
| ) |
在文件 ShaderSystem.cpp 第 90 行定义.
引用了 eve::gpgpu::ComputeShader::setFloat() , 以及 value.
◆ setGpgpu()
| void eve::gpgpu::ShaderSystem::setGpgpu | ( | Gpgpu * | gpu | ) |
在文件 ShaderSystem.cpp 第 21 行定义.
◆ setLocalSize()
| void eve::gpgpu::ShaderSystem::setLocalSize | ( | int | localSize | ) |
在文件 ShaderSystem.cpp 第 40 行定义.
引用了 kDefaultLocalSize.
◆ setShader()
| void eve::gpgpu::ShaderSystem::setShader | ( | ComputeShader * | shader, |
| bool | takeOwnership = false |
||
| ) |
Use an existing ComputeShader. Does not take ownership unless takeOwnership is true.
在文件 ShaderSystem.cpp 第 31 行定义.
引用了 shader.
◆ setShaderSource()
| void eve::gpgpu::ShaderSystem::setShaderSource | ( | const std::string & | glsl | ) |
Compile GLSL compute and take ownership of the resulting ComputeShader.
在文件 ShaderSystem.cpp 第 23 行定义.
◆ upload() [1/2]
| void eve::gpgpu::ShaderSystem::upload | ( | int | binding, |
| const float * | data, | ||
| int | floatCount | ||
| ) |
在文件 ShaderSystem.cpp 第 66 行定义.
引用了 data, ensureBuffer() , 以及 eve::gpgpu::GpuBuffer::writeFloat32s().
被这些函数引用 eve::gpgpu::packViewComponent() , 以及 upload().
◆ upload() [2/2]
| void eve::gpgpu::ShaderSystem::upload | ( | int | binding, |
| const std::vector< float > & | data | ||
| ) |
Convenience: upload from / download to a vector.
在文件 ShaderSystem.cpp 第 79 行定义.
类成员变量说明
◆ kDefaultLocalSize
|
staticconstexpr |
在文件 ShaderSystem.h 第 33 行定义.
被这些函数引用 dispatch() , 以及 setLocalSize().
◆ kMaxBindings
|
staticconstexpr |
在文件 ShaderSystem.h 第 32 行定义.
被这些函数引用 clearBuffers(), dispatch(), ensureBuffer() , 以及 getBuffer().
该类的文档由以下文件生成:
- src/modules/gpgpu/ShaderSystem.h
- src/modules/gpgpu/ShaderSystem.cpp