D3D11渲染流程笔记
2024-07-30
18
0
渲染流程
- gs_effect_set_vec4(color, colorVal); //参数到effect buffer
- gs_technique_begin_pass
- gs_load_vertexshader
- ID3D11DeviceContext::VSSetShader - 设置顶点着色器
- ID3D11DeviceContext::IASetInputLayout - 设置顶点着色器的参数布局
- ID3D11DeviceContext::VSSetConstantBuffers - 设置顶点着色器常量空间
- gs_load_pixelshader
- ID3D11DeviceContext::PSSetShader 设置像素着色器
- ID3D11DeviceContext::PSSetConstantBuffers 设置像素着器常量空间
- ID3D11DeviceContext::PSSetSamplers 设置采样状态
- upload_parameters(tech->effect, false)
- upload_shader_params(vshader_params, changed_only);
- gs_shader_set_val()// effect buffer -> gs buffer
- upload_shader_params(pshader_params, changed_only);
- gs_shader_set_val
- upload_shader_params(vshader_params, changed_only);
- gs_load_vertexshader
- gs_draw_sprite(0, 0, context->width, context->height)
- gs_vertexbuffer_flush(graphics->sprite_buffer); //map unmap更新显卡内部顶点数据
- gs_load_vertexbuffer(graphics->sprite_buffer); //设置curVertexBuffer为graphics->sprite_buffer
- gs_load_indexbuffer(NULL); //顶点索引没有用
- gs_draw(GS_TRISTRIP, 0, 0)
- device->FlushOutputViews();//设置OMSetRenderTargets
- gs_effect_update_params(effect)
- upload_parameters(effect, true)
- device->LoadVertexBufferData(); //IASetVertexBuffers
- device->UpdateBlendState(); //OMSetBlendState
- device->UpdateRasterState(); //光栅化配置
- device->UpdateZStencilState(); //OMSetDepthStencilState
- device->UpdateViewProjMatrix();
- device->curVertexShader->UploadParams();//更新顶点着色器参数到着色器常量空间
- device->curPixelShader->UploadParams(); //更新像系着色器参数到着色器常量空间
- device->context->Draw(num_verts, start_vert); //最终绘制D3D11DeviceContext::Draw