mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-11-22 13:47:11 +00:00
Sharpening GPU time shows the shader that ran instead of always RCAS
This commit is contained in:
1 parent
988f8dab23
commit
f4a29dfe44
8 files changed
+58
-15
No files matched your search
@@ -30,6 +30,29 @@ void RCAS_Common::FillMotionConstants(InternalConstants& OutConstants, const Rca
|
||||
OutConstants.MotionTextureScale = (float) OutConstants.MotionWidth / (float) OutConstants.OutputWidth;
|
||||
}
|
||||
|
||||
void RCAS_Common::SetTimedShader(SharpenShader InShader)
|
||||
{
|
||||
// Same names as the Method combo of the menu
|
||||
const char* name = "RCAS";
|
||||
|
||||
switch (InShader)
|
||||
{
|
||||
case SharpenShader::DepthAware:
|
||||
name = "Depth Aware (RCAS)";
|
||||
break;
|
||||
case SharpenShader::LocalContrastDepthAware:
|
||||
name = "Depth Aware (DAS)";
|
||||
break;
|
||||
case SharpenShader::BabaNeural:
|
||||
name = "Neural (BaBa)";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_timedShaderName = name;
|
||||
}
|
||||
|
||||
void RCAS_Common::FillMotionConstants(InternalConstantsDA& OutConstants, const RcasConstants& InConstants)
|
||||
{
|
||||
OutConstants.Sharpness = InConstants.Sharpness * 2.0f;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "shaders/DA_RCAS_Shader.h"
|
||||
#include "shaders/RCAS_Shader.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
struct RcasConstants
|
||||
{
|
||||
float Sharpness;
|
||||
@@ -25,7 +27,14 @@ struct RcasConstants
|
||||
|
||||
class RCAS_Common
|
||||
{
|
||||
public:
|
||||
// The sharpening shader that ran last, its GPU time is shown under this name
|
||||
const char* TimedShaderName() const { return _timedShaderName; }
|
||||
|
||||
protected:
|
||||
// Called by Dispatch with the shader it runs, after the fallbacks
|
||||
void SetTimedShader(SharpenShader InShader);
|
||||
|
||||
struct alignas(256) InternalConstants
|
||||
{
|
||||
float Sharpness;
|
||||
@@ -121,4 +130,8 @@ class RCAS_Common
|
||||
void FillMotionConstants(InternalConstants& OutConstants, const RcasConstants& InConstants);
|
||||
void FillMotionConstants(InternalConstantsDA& OutConstants, const RcasConstants& InConstants);
|
||||
void FillMotionConstants(InternalConstantsBaba& OutConstants, const RcasConstants& InConstants);
|
||||
|
||||
private:
|
||||
// Written by Dispatch, read by the present hooks
|
||||
std::atomic<const char*> _timedShaderName { "RCAS" };
|
||||
};
|
||||
@@ -337,6 +337,8 @@ bool RCAS_Dx11::Dispatch(ID3D11Device* InDevice, ID3D11DeviceContext* InContext,
|
||||
if (sharpnessShader == SharpenShader::BabaNeural && !EnsureBabaShader(InDevice))
|
||||
sharpnessShader = SharpenShader::RCAS;
|
||||
|
||||
SetTimedShader(sharpnessShader);
|
||||
|
||||
if (sharpnessShader == SharpenShader::LocalContrastDepthAware)
|
||||
{
|
||||
return DispatchDASDepthAdaptive(InDevice, InContext, InResource, InMotionVectors, InDepth, InConstants,
|
||||
|
||||
@@ -215,6 +215,8 @@ bool RCAS_Dx12::Dispatch(ID3D12GraphicsCommandList* InCmdList, ID3D12Resource* I
|
||||
if (sharpnessShader == SharpenShader::BabaNeural && !EnsureBabaPipeline())
|
||||
sharpnessShader = SharpenShader::RCAS;
|
||||
|
||||
SetTimedShader(sharpnessShader);
|
||||
|
||||
if (sharpnessShader == SharpenShader::LocalContrastDepthAware)
|
||||
{
|
||||
return DispatchDepthAdaptive(_pipelineStateDASDA, InCmdList, InResource, InMotionVectors, InDepth, InConstants,
|
||||
|
||||
@@ -226,18 +226,6 @@ bool RCAS_Vk::DispatchRCAS(VkCommandBuffer InCmdList, RcasConstants InConstants,
|
||||
bool RCAS_Vk::DispatchBaba(VkCommandBuffer InCmdList, RcasConstants InConstants, const VkImageInfo& InResourceInfo,
|
||||
const VkImageInfo& InMotionVectorsInfo, const VkImageInfo& OutResourceInfo)
|
||||
{
|
||||
// No spir-v for it, plain RCAS instead
|
||||
if (_pipelineBaba == VK_NULL_HANDLE)
|
||||
{
|
||||
if (!_babaFallbackLogged)
|
||||
{
|
||||
LOG_WARN("BaBa Neural sharpening isn't available for Vulkan in this build, using RCAS");
|
||||
_babaFallbackLogged = true;
|
||||
}
|
||||
|
||||
return DispatchRCAS(InCmdList, InConstants, InResourceInfo, InMotionVectorsInfo, OutResourceInfo);
|
||||
}
|
||||
|
||||
InternalConstantsBaba constants {};
|
||||
constants.OutputWidth = OutResourceInfo.Width;
|
||||
constants.OutputHeight = OutResourceInfo.Height;
|
||||
@@ -313,6 +301,21 @@ bool RCAS_Vk::Dispatch(VkDevice InDevice, VkCommandBuffer InCmdList, RcasConstan
|
||||
if (InDepthInfo == nullptr &&
|
||||
(sharpnessShader == SharpenShader::LocalContrastDepthAware || sharpnessShader == SharpenShader::DepthAware))
|
||||
sharpnessShader = SharpenShader::RCAS;
|
||||
|
||||
// No spir-v for BaBa Neural, plain RCAS instead
|
||||
if (sharpnessShader == SharpenShader::BabaNeural && _pipelineBaba == VK_NULL_HANDLE)
|
||||
{
|
||||
if (!_babaFallbackLogged)
|
||||
{
|
||||
LOG_WARN("BaBa Neural sharpening isn't available for Vulkan in this build, using RCAS");
|
||||
_babaFallbackLogged = true;
|
||||
}
|
||||
|
||||
sharpnessShader = SharpenShader::RCAS;
|
||||
}
|
||||
|
||||
SetTimedShader(sharpnessShader);
|
||||
|
||||
if (sharpnessShader == SharpenShader::LocalContrastDepthAware)
|
||||
{
|
||||
return DispatchDepthAdaptive(InCmdList, InConstants, InResourceInfo, InMotionVectorsInfo, OutResourceInfo,
|
||||
|
||||
@@ -515,7 +515,7 @@ void IFeature_Dx11::ReadDetailedGpuTimes(void* deviceContextVoid, std::vector<De
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { ShortName(), lastUpscalerTime.value(), true });
|
||||
|
||||
if (lastRcasTime)
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { RCAS->Name(), lastRcasTime.value(), true });
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { RCAS->TimedShaderName(), lastRcasTime.value(), true });
|
||||
|
||||
if (lastOutputScalingTime)
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { OutputScaler->Name(), lastOutputScalingTime.value(), true });
|
||||
|
||||
@@ -755,7 +755,7 @@ void IFeature_Dx12::ReadDetailedGpuTimes(void* commandQueueVoid, std::vector<Det
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { ShortName(), lastUpscalerTime.value(), true });
|
||||
|
||||
if (lastRcasTime)
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { RCAS->Name(), lastRcasTime.value(), true });
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { RCAS->TimedShaderName(), lastRcasTime.value(), true });
|
||||
|
||||
if (lastOutputScalingTime)
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { OutputScaler->Name(), lastOutputScalingTime.value(), true });
|
||||
|
||||
@@ -477,7 +477,7 @@ void IFeature_Vk::ReadDetailedGpuTimes(void* unused, std::vector<DetailedGpuTime
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { ShortName(), lastUpscalerTime.value(), true });
|
||||
|
||||
if (lastRcasTime)
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { RCAS->Name(), lastRcasTime.value(), true });
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { RCAS->TimedShaderName(), lastRcasTime.value(), true });
|
||||
|
||||
if (lastOutputScalingTime)
|
||||
detailedGpuTimes.emplace_back(DetailedGpuTime { OutputScaler->Name(), lastOutputScalingTime.value(), true });
|
||||
|
||||
Reference in new issue
Block a user