OBS-D3D11渲染梳理
+ -

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_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;
}

0 篇笔记 写笔记

作者信息
我爱内核
Windows驱动开发,网站开发
好好学习,天天向上。
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!