| 936 | } |
| 937 | |
| 938 | void Renderer::EncodePostprocessComputePass(MTL::ComputeCommandEncoder* encoder, uint32_t viewIdx) |
| 939 | { |
| 940 | encoder->pushDebugGroup(NS::String::string("Postprocess Pass", NS::StringEncoding::UTF8StringEncoding)); |
| 941 | encoder->setComputePipelineState(m_PostprocessComputePipeline->GetPipelineState()); |
| 942 | /* |
| 943 | constant type_Constants& Constants [[buffer(0)]], |
| 944 | texture2d<float, access::read> _InTexture [[texture(0)]], |
| 945 | texture2d<float, access::write> _OutTexture [[texture(1)]], |
| 946 | */ |
| 947 | uint32_t offsetBytes = 0u; |
| 948 | simd::float2 texSize = m_Drawable->GetLogicalSize(); |
| 949 | int pixelCount = std::floor(texSize.x * texSize.y + 0.5f); |
| 950 | MTL::Texture* texture = m_Drawable->GetTexture(viewIdx); |
| 951 | |
| 952 | Buffer* constantsBuffer = m_Graphics->AllocatePerFrameConstantsBuffer(sizeof(PostprocessConstants), offsetBytes); |
| 953 | PostprocessConstants* postprocessConstants = (PostprocessConstants*)constantsBuffer->GetDataToModify(offsetBytes); |
| 954 | postprocessConstants->_Params = AsFloat4((int)texSize.x, (int)texSize.y, pixelCount); |
| 955 | encoder->setBuffer(constantsBuffer->GetHandle(), offsetBytes, 0); |
| 956 | encoder->setTexture(texture, 0); |
| 957 | encoder->setTexture(texture, 1); |
| 958 | |
| 959 | uint32_t groupCount = (pixelCount + GROUP_SIZE - 1) / GROUP_SIZE; |
| 960 | encoder->dispatchThreadgroups(MTL::Size(groupCount, 1, texture->arrayLength()), MTL::Size(GROUP_SIZE, 1, 1)); |
| 961 | encoder->insertDebugSignpost(NS::String::string("Postprocess", NS::StringEncoding::UTF8StringEncoding)); |
| 962 | encoder->popDebugGroup(); |
| 963 | } |
| 964 | |
| 965 | void Renderer::EncodePostprocessRenderPass(MTL::RenderCommandEncoder* encoder, uint32_t viewIdx) |
| 966 | { |
nothing calls this directly
no test coverage detected