void VolumetricLighting::InitRenderTarget(SetupContext& context) { if (!m_outputTexturesInited) { m_outputTexturesInited = true; using gxapi::eFormat; auto formatSDFCullData = eFormat::R32_UINT; auto formatDst = eFormat::R16G16B16A16_FLOAT; gxapi::UavTexture2DArray uavDesc; uavDesc.activeArraySize = 1; uavDesc.firstArrayElement = 0; uavDesc.mipLevel = 0; uavDesc.planeIndex = 0; gxapi::SrvTexture2DArray srvDesc; srvDesc.activeArraySize = 1; srvDesc.firstArrayElement = 0; srvDesc.numMipLevels = -1; srvDesc.mipLevelClamping = 0; srvDesc.mostDetailedMip = 0; srvDesc.planeIndex = 0; uint32_t dispatchW, dispatchH; SetWorkgroupSize((unsigned)m_depthTexSrv.GetResource().GetWidth(), (unsigned)m_depthTexSrv.GetResource().GetHeight(), 16, 16, dispatchW, dispatchH); //TODO 1D tex Texture2DDesc desc; desc.width = dispatchW * dispatchH; desc.height = 1024; desc.format = formatSDFCullData; TextureUsage uavusage{ true, true, false, true }; Texture2D sdfCullDataTex = context.CreateTexture2D(desc, uavusage); sdfCullDataTex.SetName("SDF culling sdf cull data tex"); m_sdfCullDataUAV = context.CreateUav(sdfCullDataTex, formatSDFCullData, uavDesc); m_sdfCullDataSRV = context.CreateSrv(sdfCullDataTex, formatSDFCullData, srvDesc); for (int c = 0; c < 2; ++c) { desc.width = m_depthTexSrv.GetResource().GetWidth(); desc.height = m_depthTexSrv.GetResource().GetHeight(); desc.format = formatDst; Texture2D dstTex = context.CreateTexture2D(desc, uavusage); sdfCullDataTex.SetName("SDF culling dst tex"); m_volDstTexUAV[c] = context.CreateUav(dstTex, formatDst, uavDesc); m_volDstTexUAV[c].GetResource().SetName((std::string("SDF culling vol dst UAV") + std::to_string(c)).c_str()); } desc.width = m_depthTexSrv.GetResource().GetWidth(); desc.height = m_depthTexSrv.GetResource().GetHeight(); desc.format = formatDst; Texture2D dstTex = context.CreateTexture2D(desc, uavusage); sdfCullDataTex.SetName("SDF culling dst tex"); m_dstTexUAV = context.CreateUav(dstTex, formatDst, uavDesc); } }
void DepthReduction::InitRenderTarget(SetupContext& context) { using gxapi::eFormat; auto formatDepthReductionResult = eFormat::R32G32_FLOAT; gxapi::UavTexture2DArray uavDesc; uavDesc.activeArraySize = 1; uavDesc.firstArrayElement = 0; uavDesc.mipLevel = 0; uavDesc.planeIndex = 0; gxapi::SrvTexture2DArray srvDesc; srvDesc.activeArraySize = 1; srvDesc.firstArrayElement = 0; srvDesc.numMipLevels = -1; srvDesc.mipLevelClamping = 0; srvDesc.mostDetailedMip = 0; srvDesc.planeIndex = 0; unsigned dispatchW, dispatchH; SetWorkgroupSize((unsigned)std::ceil(m_width * 0.5f), m_height, 16, 16, dispatchW, dispatchH); Texture2D tex = context.CreateTexture2D({ dispatchW, dispatchH, formatDepthReductionResult }, { true, true, false, true }); tex.SetName("Depth reduction intermediate texture"); m_uav = context.CreateUav(tex, formatDepthReductionResult, uavDesc); m_srv = context.CreateSrv(tex, formatDepthReductionResult, srvDesc); }
void NeighborMax::InitRenderTarget(SetupContext& context) { if (!m_outputTexturesInited) { m_outputTexturesInited = true; using gxapi::eFormat; auto formatNeighborMax = eFormat::R8G8_UNORM; gxapi::RtvTexture2DArray rtvDesc; rtvDesc.activeArraySize = 1; rtvDesc.firstArrayElement = 0; rtvDesc.firstMipLevel = 0; rtvDesc.planeIndex = 0; gxapi::SrvTexture2DArray srvDesc; srvDesc.activeArraySize = 1; srvDesc.firstArrayElement = 0; srvDesc.numMipLevels = -1; srvDesc.mipLevelClamping = 0; srvDesc.mostDetailedMip = 0; srvDesc.planeIndex = 0; Texture2DDesc desc{ m_inputTexSrv.GetResource().GetWidth(), m_inputTexSrv.GetResource().GetHeight(), formatNeighborMax }; Texture2D neighbormax_tex = context.CreateTexture2D(desc, { true, true, false, false }); neighbormax_tex.SetName("Motion blur neighbormax tex"); m_neighbormax_rtv = context.CreateRtv(neighbormax_tex, formatNeighborMax, rtvDesc); } }
void BloomBlur::InitRenderTarget(SetupContext& context) { if (!m_outputTexturesInited) { m_outputTexturesInited = true; using gxapi::eFormat; auto formatBlur = eFormat::R16G16B16A16_FLOAT; gxapi::RtvTexture2DArray rtvDesc; rtvDesc.activeArraySize = 1; rtvDesc.firstArrayElement = 0; rtvDesc.firstMipLevel = 0; rtvDesc.planeIndex = 0; gxapi::SrvTexture2DArray srvDesc; srvDesc.activeArraySize = 1; srvDesc.firstArrayElement = 0; srvDesc.numMipLevels = -1; srvDesc.mipLevelClamping = 0; srvDesc.mostDetailedMip = 0; srvDesc.planeIndex = 0; Texture2DDesc desc{ m_inputTexSrv.GetResource().GetWidth(), m_inputTexSrv.GetResource().GetHeight(), formatBlur }; Texture2D blur_tex = context.CreateTexture2D(desc, { true, true, false, false }); blur_tex.SetName("Bloom blur tex"); m_blur_rtv = context.CreateRtv(blur_tex, formatBlur, rtvDesc); } }
void BrightLumPass::InitRenderTarget(SetupContext& context) { if (!m_outputTexturesInited) { m_outputTexturesInited = true; using gxapi::eFormat; auto formatBrightPass = eFormat::R16G16B16A16_FLOAT; auto formatLuminance = eFormat::R16_FLOAT; gxapi::RtvTexture2DArray rtvDesc; rtvDesc.activeArraySize = 1; rtvDesc.firstArrayElement = 0; rtvDesc.firstMipLevel = 0; rtvDesc.planeIndex = 0; gxapi::SrvTexture2DArray srvDesc; srvDesc.activeArraySize = 1; srvDesc.firstArrayElement = 0; srvDesc.numMipLevels = -1; srvDesc.mipLevelClamping = 0; srvDesc.mostDetailedMip = 0; srvDesc.planeIndex = 0; Texture2DDesc desc{ m_inputTexSrv.GetResource().GetWidth(), m_inputTexSrv.GetResource().GetHeight(), formatBrightPass }; Texture2D bright_pass_tex = context.CreateTexture2D(desc, { true, true, false, false }); bright_pass_tex.SetName("Bright pass tex"); m_bright_pass_rtv = context.CreateRtv(bright_pass_tex, formatBrightPass, rtvDesc); desc.format = formatLuminance; Texture2D luminance_tex = context.CreateTexture2D(desc, { true, true, false, false }); luminance_tex.SetName("Luminance tex"); m_luminance_rtv = context.CreateRtv(luminance_tex, formatLuminance, rtvDesc); } }