Graphics v0.0.0
A simple abstraction layer for the modern graphics APIs.
载入中...
搜索中...
未找到
Shader类 参考

着色器阶段. 更多...

#include <Shader.h>

类 Shader 继承关系图:
GLShader VKShader

struct  Descriptor
 

Public 类型

enum class  Stage {
  Vertex , Fragment , Pixel = Fragment , Geometry ,
  Compute
}
 着色器阶段. 更多...
 

Public 成员函数

const std::string & get_name () const noexcept
 获取名称.
 
const std::string & get_entry_point () const noexcept
 获取入口点名称.
 
Stage get_stage () const noexcept
 获取阶段.
 

静态 Public 成员函数

static std::shared_ptr< Shadercreate (const Descriptor &desc)
 创建着色器阶段. 更多...
 

Protected 成员函数

 Shader (const Descriptor &desc)
 
std::vector< uint32_t > get_code (std::filesystem::path path)
 获取 SPIR-V 代码, 若未编译则先进行编译.
 
void compile (const std::filesystem::path &sourcePath, const std::filesystem::path &targetPath, Stage stage)
 将 GLSL 编译为 SPIR-V. 更多...
 
void parse (const std::vector< uint32_t > &buf)
 将 GLSL 编译为 SPIR-V. 更多...
 

Protected 属性

std::string name_
 
std::string entry_point_
 
Stage stage_
 

详细描述

着色器阶段.

成员枚举类型说明

◆ Stage

enum class Shader::Stage
strong

着色器阶段.

枚举值
Vertex 

顶点着色器.

Fragment 

片段着色器.

Pixel 

像素着色器.

Geometry 

几何着色器.

Compute 

计算着色器.

成员函数说明

◆ compile()

void Shader::compile ( const std::filesystem::path &  sourcePath,
const std::filesystem::path &  targetPath,
Stage  stage 
)
protected

将 GLSL 编译为 SPIR-V.

参数
sourcePathGLSL 文件路径.
targetPathSPIR-V 文件路径.
stage着色器阶段.
警告
入口点必须为 main.

TODO:

  • 支持定义宏.
  • 设置优化选项.

◆ create()

std::shared_ptr< Shader > Shader::create ( const Descriptor desc)
static

创建着色器阶段.

参数
desc描述符.

◆ parse()

void Shader::parse ( const std::vector< uint32_t > &  buf)
protected

将 GLSL 编译为 SPIR-V.

参数
bufSPIR-V 代码.

该类的文档由以下文件生成: