每天学习一点点9.13 helloworld系列sample的图示大总结

1.整体初始化流程图示

2.当你需要绘制vertex的时候

1.Vertex格式创建

2.创建ComPtr<ID3D12RootSignature> m_rootSignature

3.创建vertex shader, 创建pixel shader

4.创建一个pipeline stae并和填入signature, shaders, 以及inputlayout

5.创建vertex buffer, 然后把顶点数据移到vertex buffer中

6.创建vertex buffer view

7.在command list里面分别set signature,set view port,set scissor rect, set render target etc开始渲染

 

3.当你需要绘制texture的时候

srv需要resource heap来支持, 应该说所有resource都需要desc_heap来支持

1.Load pipeline的时候, 创建srvHeap

2.创建root signature还要创建并引入sampler

3.rootsignature desc init的时候要用1.1版本

4.创建inpuit lay out的时候也要有点变化, input变成position和texturecoord UV了

5.创建texture resource

6.创建中间upload heap, 这玩意就是数据中转站

7.读取真正的texture数据

8.record 从upload heap 到 m_texture数据的command

9.录入barrier将m_texture的未来状态改为Pixel shader resource

10. 创建shader resource view

11.这里我们开始设置m_commandList->SetDescriptorHeaps即开始有了额外的资源的可以使用了

12.SetGraphicsRootDescriptorTable告诉我们的资源描述符在哪找 

13.开始渲染



4.当你需要使用constant buffer的时候

新建constant buffer结构体

eg:struct SceneConstantBuffer

    {

        XMFLOAT4 offset;

        float padding[60]; // 256字节对齐

    };

1.m_constantBuffer buffer 接口

2.m_constantBufferData 实际我们读写的数据

3.m_pCbvDataBegin 存储没关闭的buffer的raw pointer指针

4.m_cbvHeap 存储view的

5.load pipeline的时候 创建cbvheap

6.load assets的时候创建root_signature

7.创建constant buffer

8.创建buffer view在cbvheap上

9.把buffer内部的pointer给m_pCbvDataBegin并且不关闭map,

10.command list依旧要设置cbv_heap位资源和desctable

11.渲染的时候就可以改变m_constantBufferData然后把data移动到buffer里面就ok了

 

5.当你需要使用frame buffering的时候

这个没啥好说的,基本都是固定操作. 其实就是变成一个frame一个allocator和fence value 多加了一个wait for gpu 而已


6.当你需要使用bundle的时候

    1. 在loadpipeline的时候多创建一个bundle_allocator

    2. loadassets的时候, 创建一个bundle command list直接往里面录入命令存着

    3. 每次生成命令的时候用主 m_commandList->ExecuteBundle(m_bundle.Get());就可以在原地把命令展开了, 这样不仅可以隐藏很多细节,而且可以重复利用.

posted @ 2021-09-14 00:25  Tonarinototoro  阅读(55)  评论(0编辑  收藏  举报