/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/RendererCore/Pipeline/Implementation/Passes/MsaaUpscalePass.cpp
116 строк
4 KB
Sanakan8472
Render Graph (#1948)
03 июн 2026, 10:19
Не верифицирован
03 июн 2026, 10:19
60bb12c
Код
Авторство
О чём код?
#include <RendererCore/RendererCorePCH.h> #include <Foundation/IO/TypeVersionContext.h> #include <RendererCore/Pipeline/Passes/MsaaUpscalePass.h> #include <RendererCore/Pipeline/View.h> #include <RendererCore/RenderContext/RenderContext.h> #include <RendererFoundation/Resources/RenderTargetView.h> #include <RendererFoundation/Resources/Texture.h> // clang-format off EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezMsaaUpscalePass, 2, ezRTTIDefaultAllocator<ezMsaaUpscalePass>) { EZ_BEGIN_PROPERTIES { EZ_MEMBER_PROPERTY("Input", m_PinInput), EZ_MEMBER_PROPERTY("Output", m_PinOutput), EZ_ENUM_MEMBER_PROPERTY("MSAA_Mode", ezGALMSAASampleCount, m_MsaaMode) } EZ_END_PROPERTIES; EZ_BEGIN_ATTRIBUTES { new ezCategoryAttribute("Utilities") } EZ_END_ATTRIBUTES; } EZ_END_DYNAMIC_REFLECTED_TYPE; // clang-format on ezMsaaUpscalePass::ezMsaaUpscalePass() : ezRenderPipelinePass("MsaaUpscalePass") { { // Load shader. m_hShader = ezResourceManager::LoadResource<ezShaderResource>("Shaders/Pipeline/MsaaUpscale.ezShader"); EZ_ASSERT_DEV(m_hShader.IsValid(), "Could not load msaa upscale shader!"); } } ezMsaaUpscalePass::~ezMsaaUpscalePass() = default; ezStatus ezMsaaUpscalePass::AddRenderPasses(const ezViewData& viewData, const ezCamera& camera, ezRenderGraph& ref_graph, const ezArrayPtr<const ezRenderPipelinePinConnection> inputs, ezArrayPtr<ezRenderPipelinePinConnection> outputs) { ezRenderGraphTextureHandle hInput = inputs[m_PinInput.m_uiInputIndex].m_TextureHandle; if (hInput.IsInvalidated()) return ezStatus(ezFmt("Input: Not connected")); const ezGALTextureCreationDescription inputDesc = ref_graph.GetTextureDesc(hInput); if (inputDesc.m_SampleCount != ezGALMSAASampleCount::None) return ezStatus(ezFmt("Input must not be a msaa target")); ezGALTextureCreationDescription outputDesc = inputDesc; outputDesc.m_SampleCount = m_MsaaMode; ezRenderGraphTextureHandle hOutput = ref_graph.CreateTexture(outputDesc); outputs[m_PinOutput.m_uiOutputIndex].m_TextureHandle = hOutput; auto pass = ref_graph.AddGraphicsPass("MsaaUpscale"); pass.AddColorTarget(hOutput); pass.ReadTexture(hInput, {}, ezGALResourceState::ShaderResource, ezGALShaderStageFlags::PixelShader); pass.SetStereoscopic(camera.IsStereoscopic()); pass.SetExecuteCallback([=](const ezRenderGraphContext& ctx) { const ezRenderViewContext& renderViewContext = *ctx.GetUserData<ezRenderViewContext>(); renderViewContext.UpdateViewport(); renderViewContext.m_pRenderContext->BindShader(m_hShader); renderViewContext.m_pRenderContext->BindNullMeshBuffer(ezGALPrimitiveTopology::Triangles, 1); ezBindGroupBuilder& bindGroup = renderViewContext.m_pRenderContext->GetBindGroup(); bindGroup.BindTexture("ColorTexture", ctx.ResolveTexture(hInput)); renderViewContext.m_pRenderContext->DrawMeshBuffer().IgnoreResult(); }); return EZ_SUCCESS; } ezResult ezMsaaUpscalePass::Serialize(ezStreamWriter& inout_stream) const { EZ_SUCCEED_OR_RETURN(SUPER::Serialize(inout_stream)); inout_stream << m_MsaaMode; return EZ_SUCCESS; } ezResult ezMsaaUpscalePass::Deserialize(ezStreamReader& inout_stream) { EZ_SUCCEED_OR_RETURN(SUPER::Deserialize(inout_stream)); const ezUInt32 uiVersion = ezTypeVersionReadContext::GetContext()->GetTypeVersion(GetStaticRTTI()); EZ_IGNORE_UNUSED(uiVersion); inout_stream >> m_MsaaMode; return EZ_SUCCESS; } ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// #include <Foundation/Serialization/AbstractObjectGraph.h> #include <Foundation/Serialization/GraphPatch.h> class ezMsaaUpscalePassPatch_1_2 : public ezGraphPatch { public: ezMsaaUpscalePassPatch_1_2() : ezGraphPatch("ezMsaaUpscalePass", 2) { } virtual void Patch(ezGraphPatchContext& ref_context, ezAbstractObjectGraph* pGraph, ezAbstractObjectNode* pNode) const override { pNode->RenameProperty("MSAA Mode", "MSAA_Mode"); } }; ezMsaaUpscalePassPatch_1_2 g_ezMsaaUpscalePassPatch_1_2; EZ_STATICLINK_FILE(RendererCore, RendererCore_Pipeline_Implementation_Passes_MsaaUpscalePass);