8000 Disable SetShadingRate when not supported. by bostelk · Pull Request #30 · electronicarts/gigi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Disable SetShadingRate when not supported. #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 53 additions & 7 deletions GigiViewerDX12/Interpreter/RenderGraphNode_Action_DrawCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,17 +1054,41 @@ bool GigiInterpreterPreviewWindowDX12::OnNodeAction(const RenderGraphNode_Action
// transition
queuedTransitions.push_back({ TRANSITION_DEBUG_INFO_NAMED(textureInfo.m_resource, D3D12_RESOURCE_STATE_SHADING_RATE_SOURCE, GetNodeName(resourceNode).c_str()) });

ID3D12GraphicsCommandList5* VRSCommandList = nullptr;
if (FAILED(m_commandList->QueryInterface(IID_PPV_ARGS(&VRSCommandList))))
bool sparseSampling = false;
D3D12_FEATURE_DATA_D3D12_OPTIONS6 options;
if (S_OK == m_device->CheckFeatureSupport(
D3D12_FEATURE_D3D12_OPTIONS6,
&options,
sizeof(options)))
{
m_logFn(LogLevel::Error, "Draw call node \"%s\" couldn't get a ID3D12GraphicsCommandList5*", node.name.c_str());
return false;
switch (options.VariableShadingRateTier) {
case D3D12_VARIABLE_SHADING_RATE_TIER_1:
case D3D12_VARIABLE_SHADING_RATE_TIER_2:
{
sparseSampling = true;
break;
}
default: {
m_logFn(LogLevel::Error, "Draw call node \"%s\" could not enable sparse shading because it is not supported", node.name.c_str());
break;
}
}
}

// Set the shading rate image
VRSCommandList->RSSetShadingRateImage(textureInfo.m_resource);
if (sparseSampling)
{
ID3D12GraphicsCommandList5* VRSCommandList = nullptr;
if (FAILED(m_commandList->QueryInterface(IID_PPV_ARGS(&VRSCommandList))))
{
m_logFn(LogLevel::Error, "Draw call node \"%s\" couldn't get a ID3D12GraphicsCommandList5*", node.name.c_str());
return false;
}

// Set the shading rate image
VRSCommandList->RSSetShadingRateImage(textureInfo.m_resource);

VRSCommandList->Release();
VRSCommandList->Release();
}
}
}
}
Expand Down Expand Up @@ -1584,7 +1608,28 @@ bool GigiInterpreterPreviewWindowDX12::OnNodeAction(const RenderGraphNode_Action
m_commandList->OMSetRenderTargets((UINT)colorTargetHandles.size(), colorTargetHandles.data(), false, depthTargetHandlePtr);
m_commandList->OMSetStencilRef(node.stencilRef);

bool sparseSampling = false;
D3D12_FEATURE_DATA_D3D12_OPTIONS6 options;
if (S_OK == m_device->CheckFeatureSupport(
D3D12_FEATURE_D3D12_OPTIONS6,
&options,
sizeof(options)))
{
switch (options.VariableShadingRateTier) {
case D3D12_VARIABLE_SHADING_RATE_TIER_1:
case D3D12_VARIABLE_SHADING_RATE_TIER_2: {
sparseSampling = true;
8000 break;
}
default: {
m_logFn(LogLevel::Error, "Draw call node \"%s\" could not enable sparse shading because it is not supported", node.name.c_str());
break;
}
}
}

// variable rate shading - set sparse sampling
if (sparseSampling)
{
ID3D12GraphicsCommandList5* VRSCommandList = nullptr;
if (FAILED(m_commandList->QueryInterface(IID_PPV_ARGS(&VRSCommandList))))
Expand Down Expand Up @@ -1729,6 +1774,7 @@ bool GigiInterpreterPreviewWindowDX12::OnNodeAction(const RenderGraphNode_Action
}

// variable rate shading - set it back to dense sampling
if (sparseSampling)
{
ID3D12GraphicsCommandList5* VRSCommandList = nullptr;
if (FAILED(m_commandList->QueryInterface(IID_PPV_ARGS(&VRSCommandList))))
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Tristan Calderbank

William Donnelly

Kyle Bostelmann

[Gigi would not be possible without several open sourced libraries](readme/OSS.md)

# Contributing
Expand Down
0