Skip to content
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ else ( )
endif ( )

set( NugetPackagesRoot "${CMAKE_BINARY_DIR}/rps_nuget_packages" )
set( DXAgilitySDK_VERSION_STRING "1.608.3" )
set( DXAgilitySDK_VERSION 608 ) # to set D3D12SDKVersion
set( DXAgilitySDK_VERSION_STRING "1.613.0" )
set( DXAgilitySDK_VERSION 613 ) # to set D3D12SDKVersion
set( DXAgilitySDK_INSTALL_DIR "${NugetPackagesRoot}/DXAgilitySDK.${DXAgilitySDK_VERSION_STRING}" )
set( RpsDXAgilitySDK_DIR "${DXAgilitySDK_INSTALL_DIR}" CACHE STRING "DX12 Agility SDK directory" )

Expand Down
19 changes: 12 additions & 7 deletions src/runtime/common/phases/rps_access_dag_build.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,18 @@ namespace rps

AccessTransitionInfo transitionInfo;

const NodeId lastAccessor = accessState.accessorNodes.empty()
? RPS_INDEX_NONE_U32
: accessState.accessorNodes.Get(m_nodeRefLists).back();

const bool bAccessedByCurrentNode = (lastAccessor == currNodeId);

if ((accessState.lastTransition == RenderGraph::INVALID_TRANSITION) ||
NeedTransition(beforeAccess, newAccess, transitionInfo))
NeedTransition(beforeAccess, newAccess, transitionInfo, bAccessedByCurrentNode))
{
// New Transition
NodeId lastAccessor = accessState.accessorNodes.empty()
? RPS_INDEX_NONE_U32
: accessState.accessorNodes.Get(m_nodeRefLists).back();

if (lastAccessor != currNodeId)
if (!bAccessedByCurrentNode)
{
AddNewTransition(graph, currNodeId, accessState, newAccess, resourceId, range);
}
Expand Down Expand Up @@ -470,7 +473,8 @@ namespace rps

inline bool NeedTransition(const RpsAccessAttr& before,
const RpsAccessAttr& after,
AccessTransitionInfo& accessTransInfo) const
AccessTransitionInfo& accessTransInfo,
bool bAccessedByCurrentNode) const
{
// Coarse filter before calling runtime dependent CalculateAccessTransition:
// TODO: Get this from runtime device
Expand All @@ -486,7 +490,8 @@ namespace rps
return accessTransInfo.bTransition;
}

if (IsReadOnly(before) && IsReadOnly(after))
if ((IsReadOnly(before) && IsReadOnly(after)) ||
(bAccessedByCurrentNode && rpsAllBitsSet(before.accessFlags, after.accessFlags)))
{
accessTransInfo.bMergedAccessStates = before != after;
accessTransInfo.mergedAccess = before | after;
Expand Down
9 changes: 9 additions & 0 deletions src/runtime/common/phases/rps_pre_process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ namespace rps
pResInstance->InvalidateRuntimeResource(pRuntimeBackend);
}
pResInstance->isPendingInit = false;
pResInstance->isAccessed = false;

pResInstance->SetInitialAccess(AccessAttr{});

Expand Down Expand Up @@ -356,6 +357,7 @@ namespace rps

ResourceInstance tempResInstCopy = parentResInstance;
tempResInstCopy.isTemporalSlice = true;
tempResInstCopy.isAccessed = false;

if (!bIsParentParamResource)
{
Expand Down Expand Up @@ -404,6 +406,11 @@ namespace rps

temporalSlice.SetInitialAccess(AccessAttr{});
temporalSlice.finalAccesses = {};

for (uint32_t iTemporalSlice = 0; iTemporalSlice < numTemporalLayers; iTemporalSlice++)
{
resInstances[parentResInstance.temporalLayerOffset + iTemporalSlice].isAccessed = false;
}
}

return RPS_OK;
Expand Down Expand Up @@ -839,6 +846,8 @@ namespace rps

accessInfo.resourceId = resInstanceId;

resInstance.isAccessed = true;

bool bPendingRecreate = false;

if (resInstance.desc.IsImage())
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/common/phases/rps_schedule_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace rps
printer(" ]");
}

for (uint32_t iCmd = batchInfo.waitFencesBegin, cmdEnd = batchInfo.waitFencesBegin + batchInfo.numCmds;
for (uint32_t iCmd = batchInfo.cmdBegin, cmdEnd = batchInfo.cmdBegin + batchInfo.numCmds;
iCmd < cmdEnd;
iCmd++)
{
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/common/rps_render_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ namespace rps

if (pCreateInfo)
{
(*ppRenderGraph)->OnInit(renderGraphCreateInfo);
RPS_V_RETURN((*ppRenderGraph)->OnInit(renderGraphCreateInfo));
}


if (pRuntimeDevice)
{
if ((*ppRenderGraph)->m_createInfo.numPhases == 0)
Expand Down
1 change: 1 addition & 0 deletions src/runtime/common/rps_render_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace rps
bool isAliased : 1;
bool isPendingCreate : 1;
bool isPendingInit : 1;
bool isAccessed : 1;
bool isMutableFormat : 1;
bool bBufferFormattedWrite : 1;
bool bBufferFormattedRead : 1;
Expand Down
5 changes: 2 additions & 3 deletions src/runtime/common/rps_render_graph_signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,8 @@ namespace rps

uint32_t FindNodeDeclIndexByName(const StrRef name) const
{
auto iter = std::find_if(m_nodeDecls.begin(), m_nodeDecls.end(), [&](const auto& nodeDecl) {
return ((0 == strncmp(nodeDecl.name.str, name.str, name.len)) && (nodeDecl.name.str[name.len] == '\0'));
});
auto iter = std::find_if(
m_nodeDecls.begin(), m_nodeDecls.end(), [&](const auto& nodeDecl) { return (nodeDecl.name == name); });
return (iter != m_nodeDecls.end()) ? uint32_t(iter - m_nodeDecls.begin()) : RPS_INDEX_NONE_U32;
}

Expand Down
4 changes: 3 additions & 1 deletion src/runtime/common/rps_rpsl_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,12 @@ namespace rps
pResDesc->buffer.sizeInBytesHi = height;
}

const uint32_t stableResId =
const TResult<uint32_t> stableResId =
m_pGraphBuilder->GetCurrentProgram()
->m_persistentIndexGenerator.Generate<ProgramInstance::PERSISTENT_INDEX_KIND_RESOURCE_ID>(id);

RPS_V_RETURN(stableResId.Result());

RPS_V_RETURN(m_pGraphBuilder->DeclareResource(stableResId, pResDesc, {}, pOutResourceId));

return RPS_OK;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/common/rps_runtime_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace rps

const bool bIsCreated = resInstance.hRuntimeResource && !resInstance.isPendingCreate;

if (!resInstance.isExternal && bIsCreated)
if (!resInstance.isExternal && bIsCreated && resInstance.isAccessed)
{
resInstance.prevFinalAccess = (bResetAliasedResourceToNoAccess && resInstance.isAliased)
? AccessAttr{}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/d3d12/rps_d3d12_barrier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace rps

RPS_ASSERT(!(resInstance.isAliased && resInstance.IsPersistent()));

if (resInstance.hRuntimeResource && !resInstance.isAliased)
if (resInstance.hRuntimeResource && resInstance.isAccessed && !resInstance.isAliased)
{
for (auto& finalAccess :
resInstance.finalAccesses.Get(context.renderGraph.GetResourceFinalAccesses()))
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/d3d12/rps_d3d12_enhanced_barrier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace rps
{
auto& resInstance = resourceInstances[iRes];

if (!resInstance.isAliased && resInstance.hRuntimeResource &&
if (resInstance.isAccessed && !resInstance.isAliased && resInstance.hRuntimeResource &&
(resInstance.initialAccess.accessFlags != RPS_ACCESS_UNKNOWN))
{
for (auto& finalAccess :
Expand Down
24 changes: 0 additions & 24 deletions src/runtime/d3d12/rps_d3d12_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,6 @@ namespace rps
static inline RpsResourceFlags D3D12ResourceFlagsToRps(D3D12_RESOURCE_FLAGS flags)
{
RpsResourceFlags result = RPS_RESOURCE_FLAG_NONE;

if (flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)
result |= RPS_ACCESS_UNORDERED_ACCESS_BIT;

if (flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET)
result |= RPS_ACCESS_RENDER_TARGET_BIT;

if (flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL)
{
result |= RPS_ACCESS_DEPTH_STENCIL;

if (!(flags & D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE))
{
result |= RPS_ACCESS_SHADER_RESOURCE_BIT;
}
}

#if RPS_D3D12_ENHANCED_BARRIER_SUPPORT
if (flags & D3D12_RESOURCE_FLAG_RAYTRACING_ACCELERATION_STRUCTURE)
{
result |= (RPS_ACCESS_RAYTRACING_AS_BUILD_BIT | RPS_ACCESS_RAYTRACING_AS_READ_BIT);
}
#endif //RPS_D3D12_ENHANCED_BARRIER_SUPPORT

return result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/vk/rps_vk_runtime_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ namespace rps

const bool bResHasMemoryBound = resInstance.hRuntimeResource && !resInstance.isPendingCreate;

if (!resInstance.isAliased && bResHasMemoryBound &&
if (resInstance.isAccessed && !resInstance.isAliased && bResHasMemoryBound &&
(resInstance.initialAccess.accessFlags != RPS_ACCESS_UNKNOWN))
{
for (auto& finalAccess :
Expand Down
38 changes: 27 additions & 11 deletions tests/gui/test_mrt_viewport_clear_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ protected :
REQUIRE(accessInfo.range.arrayLayers == 1);
REQUIRE(accessInfo.range.baseMipLevel == 0);
REQUIRE(accessInfo.range.mipLevels == 1);
REQUIRE(accessInfo.viewFormat == RPS_FORMAT_B8G8R8A8_UNORM);
REQUIRE(accessInfo.viewFormat == rpsFormatFromVK(m_swapChainFormat.format));
REQUIRE(resourceAccessInfo.access.accessFlags == accessInfo.access.accessFlags);
REQUIRE(resourceAccessInfo.access.accessStages == accessInfo.access.accessStages);
REQUIRE(resourceAccessInfo.range.baseArrayLayer == accessInfo.range.baseArrayLayer);
Expand Down Expand Up @@ -452,14 +452,22 @@ protected :
vkCmdBindPipeline(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, m_psoWriteDepthStencil);

uint32_t drawId = 0;
vkCmdPushConstants(
cmdBuf, m_pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, PushConstOffsetDrawId, sizeof(drawId), &drawId);
vkCmdPushConstants(cmdBuf,
m_pipelineLayout,
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
PushConstOffsetDrawId,
sizeof(drawId),
&drawId);
vkCmdSetStencilReference(cmdBuf, VK_STENCIL_FACE_FRONT_AND_BACK, 0x1);
vkCmdDraw(cmdBuf, 3, 1, 0, 0);

drawId = 1;
vkCmdPushConstants(
cmdBuf, m_pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, PushConstOffsetDrawId, sizeof(drawId), &drawId);
vkCmdPushConstants(cmdBuf,
m_pipelineLayout,
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
PushConstOffsetDrawId,
sizeof(drawId),
&drawId);
vkCmdSetStencilReference(cmdBuf, VK_STENCIL_FACE_FRONT_AND_BACK, 0x2);
vkCmdDraw(cmdBuf, 3, 1, 0, 0);
}
Expand Down Expand Up @@ -521,8 +529,12 @@ protected :

vkCmdBindPipeline(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, m_psoReadDepthWriteStencil);
float depth = 0.25f;
vkCmdPushConstants(
cmdBuf, m_pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, PushConstOffsetFlagDepth, sizeof(depth), &depth);
vkCmdPushConstants(cmdBuf,
m_pipelineLayout,
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
PushConstOffsetFlagDepth,
sizeof(depth),
&depth);
vkCmdSetStencilReference(cmdBuf, VK_STENCIL_FACE_FRONT_AND_BACK, 0x2);
vkCmdDraw(cmdBuf, 3, 1, 0, 0);
}
Expand Down Expand Up @@ -591,8 +603,12 @@ protected :

vkCmdBindPipeline(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, m_psoReadDepthStencil);
const float depth = 0.5f;
vkCmdPushConstants(
cmdBuf, m_pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, PushConstOffsetFlagDepth, sizeof(depth), &depth);
vkCmdPushConstants(cmdBuf,
m_pipelineLayout,
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
PushConstOffsetFlagDepth,
sizeof(depth),
&depth);
vkCmdSetStencilReference(cmdBuf, VK_STENCIL_FACE_FRONT_AND_BACK, 0x3);
vkCmdDraw(cmdBuf, 3, 1, 0, 0);
}
Expand Down Expand Up @@ -644,8 +660,8 @@ protected :

ThrowIfFailedVK(vkCreateDescriptorSetLayout(m_device, &setLayoutCI, nullptr, &m_descriptorSetLayout));

VkPushConstantRange pushConstRanges[] = {{VK_SHADER_STAGE_FRAGMENT_BIT, 0, 4},
{VK_SHADER_STAGE_VERTEX_BIT, 4, 8}};
VkPushConstantRange pushConstRanges[] = {{VK_SHADER_STAGE_FRAGMENT_BIT, 0, 8},
{VK_SHADER_STAGE_VERTEX_BIT, 0, 8}};

VkPipelineLayoutCreateInfo plCI = {VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO};
plCI.setLayoutCount = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/gui/test_multithreading_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class TestVkMultithreading : public RpsTestVulkanRenderer, public TestRpsMultith
EndCmdList(cl);
}

SubmitCmdLists(m_activePrimaryCmdBufs.data(), uint32_t(m_activePrimaryCmdBufs.size()), VK_TRUE);
SubmitCmdLists(m_activePrimaryCmdBufs.data(), uint32_t(m_activePrimaryCmdBufs.size()), true);

for (auto& secondaryCmdBuf : m_activeSecondaryCmdBufs)
{
Expand Down
34 changes: 1 addition & 33 deletions tests/gui/test_temporal_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,39 +97,7 @@ class TestVkTemporal : public RpsTestVulkanRenderer

virtual void OnRender(uint32_t frameIndex) override
{
RpsRenderGraphBatchLayout batchLayout = {};
RpsResult result = rpsRenderGraphGetBatchLayout(m_rpsRenderGraph, &batchLayout);
REQUIRE(result == RPS_OK);

ReserveSemaphores(batchLayout.numFenceSignals);

for (uint32_t iBatch = 0; iBatch < batchLayout.numCmdBatches; iBatch++)
{
auto& batch = batchLayout.pCmdBatches[iBatch];

ActiveCommandList cmdList = BeginCmdList(RPS_AFX_QUEUE_INDEX_GFX);

RpsRenderGraphRecordCommandInfo recordInfo = {};

recordInfo.pUserContext = this;
recordInfo.cmdBeginIndex = batch.cmdBegin;
recordInfo.numCmds = batch.numCmds;
recordInfo.hCmdBuffer = rpsVKCommandBufferToHandle(cmdList.cmdBuf);

result = rpsRenderGraphRecordCommands(m_rpsRenderGraph, &recordInfo);
REQUIRE(result == RPS_OK);

EndCmdList(cmdList);

SubmitCmdLists(&cmdList,
1,
((iBatch + 1) == batchLayout.numCmdBatches),
batch.numWaitFences,
batchLayout.pWaitFenceIndices + batch.waitFencesBegin,
batch.signalFenceIndex);

RecycleCmdList(cmdList);
}
ExecuteRenderGraph(frameIndex, m_rpsRenderGraph);
}

private:
Expand Down
36 changes: 2 additions & 34 deletions tests/gui/test_triangle_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,39 +137,7 @@ class TestVkTriangle : public RpsTestVulkanRenderer

if (useRps)
{
RpsRenderGraphBatchLayout batchLayout = {};
RpsResult result = rpsRenderGraphGetBatchLayout(m_rpsRenderGraph, &batchLayout);
REQUIRE(result == RPS_OK);

ReserveSemaphores(batchLayout.numFenceSignals);

for (uint32_t iBatch = 0; iBatch < batchLayout.numCmdBatches; iBatch++)
{
auto& batch = batchLayout.pCmdBatches[iBatch];

ActiveCommandList cmdList = BeginCmdList(RPS_AFX_QUEUE_INDEX_GFX);

RpsRenderGraphRecordCommandInfo recordInfo = {};

recordInfo.pUserContext = this;
recordInfo.cmdBeginIndex = batch.cmdBegin;
recordInfo.numCmds = batch.numCmds;
recordInfo.hCmdBuffer = rpsVKCommandBufferToHandle(cmdList.cmdBuf);

result = rpsRenderGraphRecordCommands(m_rpsRenderGraph, &recordInfo);
REQUIRE(result == RPS_OK);

EndCmdList(cmdList);

SubmitCmdLists(&cmdList,
1,
((iBatch + 1) == batchLayout.numCmdBatches),
batch.numWaitFences,
batchLayout.pWaitFenceIndices + batch.waitFencesBegin,
batch.signalFenceIndex);

RecycleCmdList(cmdList);
}
ExecuteRenderGraph(frameIndex, m_rpsRenderGraph);
}
else
{
Expand All @@ -179,7 +147,7 @@ class TestVkTriangle : public RpsTestVulkanRenderer

EndCmdList(cmdList);

SubmitCmdLists(&cmdList, 1, VK_TRUE);
SubmitCmdLists(&cmdList, 1, true);

RecycleCmdList(cmdList);
}
Expand Down
Loading