夜莺
夜莺
**Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd...
**Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd...
https://github.com/killop/anything_about_game

https://github.com/luau-lang/luau
1、前言 ---- 前文([GPU架构与其逻辑管线](https://zhuanlan.zhihu.com/p/626636620))分析了Shader的运行机制,并指出了与其性能相关的硬件单元 - [流多处理器](https://zhida.zhihu.com/search?content_id=227462634&content_type=Article&match_order=1&q=%E6%B5%81%E5%A4%9A%E5%A4%84%E7%90%86%E5%99%A8&zhida_source=entity)(SM)。本篇文章将更具体地阐明Shader在SM中的执行流程,然后分析在这个流程中有哪些关键的性能因素,最后通过Debugger软件来分析Shader的性能瓶颈。接下来本文按这3部分顺序进行分析。 参考NVIDIA资料:[Issue Efficiency](https://link.zhihu.com/?target=https%3A//docs.nvidia.com/gameworks/content/developertools/desktop/analysis/report/cudaexperiments/kernellevel/issueefficiency.htm) 。 2、Shader执行流程 ------------ 在启动一个Shader时,GPU会按启动配置把一个个Block分配给SM,SM又会将Block分成一个个Warp,然后由[Warp调度器](https://zhida.zhihu.com/search?content_id=227462634&content_type=Article&match_order=1&q=Warp%E8%B0%83%E5%BA%A6%E5%99%A8&zhida_source=entity)派发执行Shader的指令。这里以一次[ComputeShader](https://zhida.zhihu.com/search?content_id=227462634&content_type=Article&match_order=1&q=ComputeShader&zhida_source=entity)(以下简称CS)的调用,说明一下Shader的执行流程: 1. CPU阶段,CPU侧调用Dispatch(GirdX,GirdY,GirdZ),让GPU启动 **GirdX \* GirdY \* GirdZ** 个Block(任务块); 2. 定义每个Block的三维大小(在CS入口函数处使用\[numthreads(GroupX,GroupY,GroupZ)\]); 3. 将CS的一个个Block负载均衡地分配给SM; 4. SM把Block中的任务以32个为一组,封装成Warp,要注意的是,不同Block的任务不能混在一个Warp里; 5. SM中的Warp调度器对Warp进行调度(丢到内核执行); 6. 被调度到的Warp,会以[SIMT](https://zhida.zhihu.com/search?content_id=227462634&content_type=Article&match_order=1&q=SIMT&zhida_source=entity) &...