245 const Matrix4& viewProjectionPrevious,
const Matrix4& viewProjectionInverse,
246 const std::array<float, 4>& jitters,
const std::array<float, 4>& cameraParams,
247 const bool highQuality,
const bool historyValid,
249 const std::vector<std::shared_ptr<MetalBindGroupFormat>>& bindGroupFormats,
250 MTL::SamplerState* defaultSampler, MTL::DepthStencilState* defaultDepthStencilState)
252 if (!encoder || !sourceTexture || !historyTexture || !depthTexture) {
257 if (!_shader || !_composePass->vertexBuffer() || !_composePass->vertexFormat() || !_blendState || !_depthState) {
258 spdlog::warn(
"[executeTAAPass] missing TAA resources");
268 auto pipelineState = pipeline->
get(primitive, _composePass->vertexFormat(),
nullptr, -1, _shader, renderTarget,
270 if (!pipelineState) {
271 spdlog::warn(
"[executeTAAPass] failed to get pipeline state");
276 if (!vb || !vb->raw()) {
277 spdlog::warn(
"[executeTAAPass] missing vertex buffer");
281 encoder->setRenderPipelineState(pipelineState);
282 encoder->setCullMode(MTL::CullModeNone);
283 encoder->setDepthStencilState(_depthStencilState ? _depthStencilState : defaultDepthStencilState);
284 encoder->setVertexBuffer(vb->raw(), 0, 0);
290 encoder->setFragmentTexture(sourceHw ? sourceHw->raw() :
nullptr, 0);
291 encoder->setFragmentTexture(historyHw ? historyHw->raw() :
nullptr, 1);
292 encoder->setFragmentTexture(depthHw ? depthHw->raw() :
nullptr, 2);
293 if (defaultSampler) {
294 encoder->setFragmentSamplerState(defaultSampler, 0);
297 struct alignas(16) TaaUniforms
299 simd::float4x4 viewProjectionPrevious;
300 simd::float4x4 viewProjectionInverse;
301 simd::float4 jitters;
302 simd::float2 textureSize;
303 simd::float4 cameraParams;
304 uint32_t highQuality;
305 uint32_t historyValid;
310 uniforms.jitters = simd::float4{jitters[0], jitters[1], jitters[2], jitters[3]};
311 uniforms.textureSize = simd::float2{
312 static_cast<float>(std::max(sourceTexture->
width(), 1u)),
313 static_cast<float>(std::max(sourceTexture->
height(), 1u))
315 uniforms.cameraParams = simd::float4{cameraParams[0], cameraParams[1], cameraParams[2], cameraParams[3]};
316 uniforms.highQuality = highQuality ? 1u : 0u;
317 uniforms.historyValid = historyValid ? 1u : 0u;
318 encoder->setFragmentBytes(&uniforms,
sizeof(TaaUniforms), 5);
320 encoder->drawPrimitives(MTL::PrimitiveTypeTriangle,
static_cast<NS::UInteger
>(0),
321 static_cast<NS::UInteger
>(3));
322 _device->recordDrawCall();
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.
gpu::HardwareTexture * impl() const