diff --git a/pxr/imaging/hdSt/imageShaderRenderPass.cpp b/pxr/imaging/hdSt/imageShaderRenderPass.cpp index d96ce29edb..12c450a51c 100644 --- a/pxr/imaging/hdSt/imageShaderRenderPass.cpp +++ b/pxr/imaging/hdSt/imageShaderRenderPass.cpp @@ -172,6 +172,9 @@ HdSt_ImageShaderRenderPass::_Execute( return; } + const GfVec4i viewport = stRenderPassState->ComputeViewport(desc); + gfxCmds->SetViewport(viewport); + // Camera state needs to be updated once per pass (not per batch). stRenderPassState->ApplyStateFromCamera(); diff --git a/pxr/imaging/hdx/oitResolveTask.cpp b/pxr/imaging/hdx/oitResolveTask.cpp index f779b94d98..5719176023 100644 --- a/pxr/imaging/hdx/oitResolveTask.cpp +++ b/pxr/imaging/hdx/oitResolveTask.cpp @@ -182,31 +182,63 @@ HdxOitResolveTask::Sync( // So, the Sync step for the image shader render pass is skipped as well. } -const HdRenderPassAovBindingVector& -HdxOitResolveTask::_GetAovBindings( - HdTaskContext * const ctx) const +HdRenderPassStateSharedPtr +HdxOitResolveTask::_GetContextRenderPassState( + HdTaskContext* const ctx) const { - static HdRenderPassAovBindingVector empty; - if (!_HasTaskContextData(ctx, HdxTokens->renderPassState)) { - return empty; + return nullptr; } HdRenderPassStateSharedPtr renderPassState; _GetTaskContextData(ctx, HdxTokens->renderPassState, &renderPassState); - if (!renderPassState) { + return renderPassState; +} + +void +HdxOitResolveTask::_UpdateCameraFraming( + HdTaskContext* const ctx) +{ + const HdRenderPassStateSharedPtr ctxRenderPassState = + _GetContextRenderPassState(ctx); + if (!ctxRenderPassState) { + TF_CODING_ERROR("Unable to set camera framing data due to missing " + "render pass state on task context"); + return; + } + + const CameraUtilFraming& framing = ctxRenderPassState->GetFraming(); + if (framing.IsValid()) { + _renderPassState->SetCameraAndFraming( + ctxRenderPassState->GetCamera(), framing, + ctxRenderPassState->GetOverrideWindowPolicy()); + } else { + _renderPassState->SetCameraAndViewport( + ctxRenderPassState->GetCamera(), ctxRenderPassState->GetViewport()); + } +} + +const HdRenderPassAovBindingVector& +HdxOitResolveTask::_GetAovBindings( + HdTaskContext* const ctx) const +{ + static HdRenderPassAovBindingVector empty; + + const HdRenderPassStateSharedPtr ctxRenderPassState = + _GetContextRenderPassState(ctx); + if (!ctxRenderPassState) { return empty; } - return renderPassState->GetAovBindings(); + return ctxRenderPassState->GetAovBindings(); } GfVec2i HdxOitResolveTask::_ComputeScreenSize( - HdTaskContext *ctx, + HdTaskContext* ctx, HdRenderIndex* renderIndex) const { - const HdRenderPassAovBindingVector&aovBindings = _GetAovBindings(ctx); + const HdRenderPassAovBindingVector& aovBindings = _GetAovBindings(ctx); if (aovBindings.empty()) { return _GetScreenSize(); } @@ -388,6 +420,7 @@ HdxOitResolveTask::Execute(HdTaskContext* ctx) if (!TF_VERIFY(_renderPassShader)) return; _renderPassState->SetAovBindings(_GetAovBindings(ctx)); + _UpdateCameraFraming(ctx); HdxOitBufferAccessor oitBufferAccessor(ctx); if (!oitBufferAccessor.AddOitBufferBindings(_renderPassShader)) { diff --git a/pxr/imaging/hdx/oitResolveTask.h b/pxr/imaging/hdx/oitResolveTask.h index b22aeed695..9349a65f59 100644 --- a/pxr/imaging/hdx/oitResolveTask.h +++ b/pxr/imaging/hdx/oitResolveTask.h @@ -36,6 +36,7 @@ PXR_NAMESPACE_OPEN_SCOPE class HdSceneDelegate; +using HdRenderPassStateSharedPtr = std::shared_ptr; using HdStRenderPassStateSharedPtr = std::shared_ptr; using HdSt_ImageShaderRenderPassSharedPtr = @@ -106,11 +107,17 @@ class HdxOitResolveTask : public HdTask GfVec2i const& screenSize); GfVec2i _ComputeScreenSize( - HdTaskContext *ctx, + HdTaskContext* ctx, HdRenderIndex* renderIndex) const; - const HdRenderPassAovBindingVector &_GetAovBindings( - HdTaskContext *ctx) const; + const HdRenderPassAovBindingVector& _GetAovBindings( + HdTaskContext* ctx) const; + + void _UpdateCameraFraming( + HdTaskContext* ctx); + + HdRenderPassStateSharedPtr _GetContextRenderPassState( + HdTaskContext* ctx) const; HdSt_ImageShaderRenderPassSharedPtr _renderPass; HdStRenderPassStateSharedPtr _renderPassState;