Skip to content

Commit

Permalink
Add feature for per render target blending
Browse files Browse the repository at this point in the history
Task-number: QTBUG-130334
Change-Id: I30ae0023ce8b5c26360e4255d64c209ebe404ede
Reviewed-by: Laszlo Agocs <[email protected]>
  • Loading branch information
anttimaa committed Nov 15, 2024
1 parent 36dca3c commit c06c8eb
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/gui/rhi/qrhi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,11 @@ Q_STATIC_LOGGING_CATEGORY(QRHI_LOG_RUB, "qt.rhi.rub")
specification of the shading rate is supported via regular textures. In
practice this may be supported with Direct 3D 12 and Vulkan. This enum value
has been introduced in Qt 6.9.
\value PerRenderTargetBlending Indicates that per rendertarget blending is
supported i.e. different render targets in MRT framebuffer can have different
blending modes. Currently always returns false for OpenGL.
This enum value has been introduced in Qt 6.9.
*/

/*!
Expand Down
3 changes: 2 additions & 1 deletion src/gui/rhi/qrhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,8 @@ class Q_GUI_EXPORT QRhi
ResolveDepthStencil,
VariableRateShading,
VariableRateShadingMap,
VariableRateShadingMapWithTexture
VariableRateShadingMapWithTexture,
PerRenderTargetBlending,
};

enum BeginFrameFlag {
Expand Down
2 changes: 2 additions & 0 deletions src/gui/rhi/qrhid3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
case QRhi::VariableRateShadingMap:
case QRhi::VariableRateShadingMapWithTexture:
return false;
case QRhi::PerRenderTargetBlending:
return true;
default:
Q_UNREACHABLE();
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/rhi/qrhid3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ bool QRhiD3D12::isFeatureSupported(QRhi::Feature feature) const
case QRhi::VariableRateShadingMap:
case QRhi::VariableRateShadingMapWithTexture:
return caps.vrsMap;
case QRhi::PerRenderTargetBlending:
return true;
}
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/gui/rhi/qrhigles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@ bool QRhiGles2::create(QRhi::Flags flags)
}

caps.unpackRowLength = !caps.gles || caps.ctxMajor >= 3;
caps.perRenderTargetBlending = false;

nativeHandlesStruct.context = ctx;

Expand Down Expand Up @@ -1507,6 +1508,8 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
case QRhi::VariableRateShadingMap:
case QRhi::VariableRateShadingMapWithTexture:
return false;
case QRhi::PerRenderTargetBlending:
return caps.perRenderTargetBlending;
default:
Q_UNREACHABLE_RETURN(false);
}
Expand Down
4 changes: 3 additions & 1 deletion src/gui/rhi/qrhigles2_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,8 @@ class QRhiGles2 : public QRhiImplementation
objectLabel(false),
glesMultisampleRenderToTexture(false),
glesMultiviewMultisampleRenderToTexture(false),
unpackRowLength(false)
unpackRowLength(false),
perRenderTargetBlending(false)
{ }
int ctxMajor;
int ctxMinor;
Expand Down Expand Up @@ -1085,6 +1086,7 @@ class QRhiGles2 : public QRhiImplementation
uint glesMultisampleRenderToTexture : 1;
uint glesMultiviewMultisampleRenderToTexture : 1;
uint unpackRowLength : 1;
uint perRenderTargetBlending : 1;
} caps;
QGles2SwapChain *currentSwapChain = nullptr;
QSet<GLint> supportedCompressedFormats;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/rhi/qrhimetal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,8 @@ inline Int aligned(Int v, Int byteAlign)
return caps.shadingRateMap;
case QRhi::VariableRateShadingMapWithTexture:
return false;
case QRhi::PerRenderTargetBlending:
return true;
default:
Q_UNREACHABLE();
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/rhi/qrhivulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5202,6 +5202,8 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
case QRhi::VariableRateShadingMap:
case QRhi::VariableRateShadingMapWithTexture:
return caps.renderPass2KHR && caps.imageBasedShadingRate;
case QRhi::PerRenderTargetBlending:
return true;
default:
Q_UNREACHABLE_RETURN(false);
}
Expand Down

0 comments on commit c06c8eb

Please sign in to comment.