///////////////////////////////////////////////////// ///////////////////////////////////////////////////// // // ResolveMultiSampling // ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// #include "stdafx.h" #include "CKRasterizer.h" CKERROR CreateResolveMultisamplingProto(CKBehaviorPrototype **); int ResolveMultisampling(const CKBehaviorContext& behcontext); // input parameters enum { InParam_ResolveColorBuffer = 0, InParam_ResolveDepthStencilBuffer, }; CKObjectDeclaration *FillBehaviorResolveMultisampling() { CKObjectDeclaration *od = CreateCKObjectDeclaration("Resolve Multisampling"); od->SetDescription("Force a multisampled framebuffer resolve until next SwapBuffer. Necessary for a StretchRect operation"); od->SetCategory("Shaders/General"); od->SetType(CKDLL_BEHAVIORPROTOTYPE); od->SetGuid(CKGUID(0x664457d3, 0x19327722)); od->SetAuthorGuid(CKGUID()); od->SetAuthorName("Virtools"); od->SetVersion(0x00010000); od->SetCreationFunction(CreateResolveMultisamplingProto); return od; } CKERROR CreateResolveMultisamplingProto(CKBehaviorPrototype **pproto) { CKBehaviorPrototype *proto = CreateCKBehaviorPrototype("Resolve Multisampling"); if(!proto) return CKERR_OUTOFMEMORY; proto->DeclareInput("In"); proto->DeclareInParameter("Resolve Color Buffer", CKPGUID_BOOL, "TRUE" ); proto->DeclareInParameter("Resolve Depth Stencil Buffer", CKPGUID_BOOL, "FALSE" ); proto->DeclareOutput("Out"); proto->DeclareOutput("Error"); proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL); proto->SetFunction(ResolveMultisampling); proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE); *pproto = proto; return CK_OK; } int ResolveMultisampling(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; beh->ActivateInput(0,FALSE); // CKRasterizerContext* rsctx = behcontext.CurrentRenderContext->GetRasterizerContext(); if (!rsctx) { beh->ActivateOutput(0); return CKBR_OK; } // if (rsctx->m_Antialias != 0 && rsctx->m_OffscreenMultiSampleCount == 0) { beh->m_Context->OutputToConsole("Resolve Multisampling error: This BB requires an offscreen multisampled framebuffer, and a non multisampled main backbuffer.\n" "Please set the 'CK2_3D/OffscreenMultisampledBuffer' variable to 'TRUE' to activate such configuration."); beh->ActivateOutput(1); } else { CKBOOL resolveColorBuffer = TRUE; CKBOOL resolveDepthStencilBuffer = FALSE; beh->GetInputParameterValue(InParam_ResolveColorBuffer, &resolveColorBuffer); beh->GetInputParameterValue(InParam_ResolveDepthStencilBuffer, &resolveDepthStencilBuffer); rsctx->ResolveMultisampling(resolveColorBuffer, resolveDepthStencilBuffer); beh->ActivateOutput(0); } return CKBR_OK; }