Skip to content

Commit

Permalink
[hdSt,hdx] ImageShaderRenderPass needs to set a viewport to ensure th…
Browse files Browse the repository at this point in the history
…e rendering state is valid.

This addresses the regression caused by removing the glViewport setting from UsdAppUtilsFrameRecorder in CL 2251239.

(Internal change: 2253453)
  • Loading branch information
cvj authored and pixar-oss committed Oct 27, 2022
1 parent 1f15312 commit d27b1be
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 13 deletions.
3 changes: 3 additions & 0 deletions pxr/imaging/hdSt/imageShaderRenderPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
53 changes: 43 additions & 10 deletions pxr/imaging/hdx/oitResolveTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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)) {
Expand Down
13 changes: 10 additions & 3 deletions pxr/imaging/hdx/oitResolveTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ PXR_NAMESPACE_OPEN_SCOPE

class HdSceneDelegate;

using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
using HdStRenderPassStateSharedPtr = std::shared_ptr<class HdStRenderPassState>;

using HdSt_ImageShaderRenderPassSharedPtr =
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d27b1be

Please sign in to comment.