HLSL着色器对象创建流程
2026-02-01
5
0
着色器对象创建分为顶点着色器和像素着色器。
不对对于OBS着色器代码,其是通过着色器文件混写的,故需要先从源文件中读取文件,然后进行词分析,分析出像素着色器和顶点着色器,然后构建成独立的着色器代码,再分别进行“编译”。
- gs_effect_create_from_file(filename, NULL);
- gs_effect_create
- ep_parse
- ep_compile
- ep_compile_technique
- ep_compile_pass
- ep_compile_pass_shader(顶点着色器)
- ep_compile_pass_shader(像素着色器)
- ep_compile_pass
- ep_compile_technique
- ep_compile
- ep_parse
- gs_effect_create
对于ep_compile_pass_shader,则通过gs_vertexshader_create来创建
gs_shader_t *gs_vertexshader_create(const char *shader, const char *file,
char **error_string)
{
graphics_t *graphics = thread_graphics;
if (!gs_valid_p("gs_vertexshader_create", shader))
return NULL;
return graphics->exports.device_vertexshader_create(
graphics->device, shader, file, error_string);
}
则进入D3D11.Dll中
gs_shader_t *device_vertexshader_create(gs_device_t *device,
const char *shader_string,
const char *file, char **error_string)
{
gs_vertex_shader *shader = new gs_vertex_shader(device, file, shader_string);
return shader;
}
OBS-D3D11渲染梳理





