// Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. // // This file is part of the AMD Render Pipeline Shaders SDK which is // released under the AMD INTERNAL EVALUATION LICENSE. // // See file LICENSE.RTF for full license details. node Geometry(rtv offscreenRenderTarget : SV_Target0, uint useMSAA); graphics node GeometryMSAA(rtv offscreenRTMSAA : SV_Target0, uint useMSAA, [writeonly(resolve)] texture offscreenRT : SV_ResolveTarget0); graphics node Quads(rtv backBuffer : SV_Target0, srv offscreenRenderTarget); export void render_to_texture([readonly(present)] texture backbuffer, bool useMultisampling) { ResourceDesc backbufferDesc = backbuffer.desc(); uint32_t width = (uint32_t)backbufferDesc.Width; uint32_t height = (uint32_t)backbufferDesc.Height; RPS_FORMAT backbufferFormat = backbufferDesc.Format; // create the resources we need for the offscreen rendering, as well as a view into it. texture offscreenRT = create_tex2d(backbufferFormat, width, height); // clear and then render geometry to offscreen target if (useMultisampling) { texture offscreenRTMSAA = create_tex2d(backbufferFormat, width, height, 1, 1, 1, 4); clear(offscreenRTMSAA, float4(0.0, 0.4, 0.2, 1.0)); GeometryMSAA(offscreenRTMSAA, useMultisampling, offscreenRT); } else { clear(offscreenRT, float4(0.0, 0.2, 0.4, 1.0)); Geometry(offscreenRT, false); } // render to the back buffer. Quads(backbuffer, offscreenRT); }