Skip to content

Update from task 2d627b0c-a9fa-4455-8d79-07dc3164b345#29

Open
tronpis wants to merge 1 commit into
vulkan-rendergraph-dependencies-ad7c9from
rendergraph-dependency-issues-4b345
Open

Update from task 2d627b0c-a9fa-4455-8d79-07dc3164b345#29
tronpis wants to merge 1 commit into
vulkan-rendergraph-dependencies-ad7c9from
rendergraph-dependency-issues-4b345

Conversation

@tronpis
Copy link
Copy Markdown
Owner

@tronpis tronpis commented Apr 2, 2026

This PR was created by qwen-chat coder for task 2d627b0c-a9fa-4455-8d79-07dc3164b345.

- Validate dependency direction in RenderGraph::compile to enforce from < to for correct execution order
- Use stored dependencyFlags in PassLevelDependency when calling vkCmdPipelineBarrier
- Update RenderGraphBuilder documentation to clarify dependency ordering requirements
- Add error handling for invalid dependency indices and directions during compilation
@qodo-code-review
Copy link
Copy Markdown

ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

Review Summary by Qodo

Fix Vulkan render graph dependency validation and flag usage

🐞 Bug fix ✨ Enhancement

Grey Divider

Walkthroughs

Description
• Validate dependency direction in RenderGraph::compile to enforce from < to ordering
• Use stored dependencyFlags in PassLevelDependency when calling vkCmdPipelineBarrier
• Add error handling for invalid dependency indices and directions during compilation
• Update RenderGraphBuilder documentation to clarify dependency ordering requirements
Diagram
flowchart LR
  A["Dependency Validation"] -->|"Check from < to"| B["Error Handling"]
  B -->|"Invalid direction"| C["Runtime Exception"]
  D["PassLevelDependency"] -->|"Collect flags"| E["combinedDependencyFlags"]
  E -->|"Pass to barrier"| F["vkCmdPipelineBarrier"]
  G["Documentation"] -->|"Clarify ordering"| H["RenderGraphBuilder"]
Loading

Grey Divider

File Changes

1. FarmEngine/src/rendering/graph/RenderGraph.cpp 🐞 Bug fix +13/-1

Validate dependency direction and use dependency flags

• Added validation to enforce dependency direction where from < to for correct execution order
• Introduced combinedDependencyFlags variable to collect dependency flags from all pass-level
 dependencies
• Updated vkCmdPipelineBarrier call to use combinedDependencyFlags instead of hardcoded 0
• Added error handling with descriptive message for invalid dependency directions

FarmEngine/src/rendering/graph/RenderGraph.cpp


2. FarmEngine/src/rendering/graph/RenderGraph.h 📝 Documentation +4/-0

Document dependency ordering requirements

• Added documentation comments to addDependency method clarifying from < to ordering requirement
• Added documentation comments to addResourceDependency method with same ordering clarification
• Notes explain that passes execute sequentially and invalid dependencies will throw errors

FarmEngine/src/rendering/graph/RenderGraph.h


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 2, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. BY_REGION weakens barriers 🐞 Bug ≡ Correctness
Description
RenderGraph::recordBarriers now passes a combined VkDependencyFlags to vkCmdPipelineBarrier; since
compile() hardcodes VK_DEPENDENCY_BY_REGION_BIT for all pass-level dependencies, any pass with such
a dependency will emit region-limited barriers (and that flag also applies to any image barriers in
the same call). This can under-synchronize non-framebuffer/texture-style dependencies (e.g.,
ShadowMap written in one pass then sampled in another) and there’s no builder API to disable or
choose dependency flags.
Code

FarmEngine/src/rendering/graph/RenderGraph.cpp[R433-437]

            cmd,
            srcStage,
            dstStage,
-            0,
+            combinedDependencyFlags,
            static_cast<uint32_t>(memoryBarriers.size()),
Evidence
The PR changes recordBarriers to OR dependency flags from pass-level dependencies and pass them into
vkCmdPipelineBarrier. Independently, pass-level dependencies are always created with
VK_DEPENDENCY_BY_REGION_BIT, so this PR effectively turns BY_REGION on for any vkCmdPipelineBarrier
emitted for passes that have addDependency()-style dependencies; because memory and image barriers
are emitted in the same vkCmdPipelineBarrier call, the flag applies to both kinds of barriers.
ExampleUsage demonstrates addDependency being used for a ShadowPass->MainGeometry dependency (depth
write -> shader read), which is not inherently framebuffer-region-local, making BY_REGION a risky
default.

FarmEngine/src/rendering/graph/RenderGraph.cpp[372-443]
FarmEngine/src/rendering/graph/RenderGraph.cpp[274-285]
FarmEngine/src/rendering/graph/ExampleUsage.h[75-116]
Best Practice: Vulkan Spec (VkDependencyFlags / VK_DEPENDENCY_BY_REGION_BIT)

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`recordBarriers()` now forwards `VkDependencyFlags` into `vkCmdPipelineBarrier()`. Because pass-level dependencies are currently created with `VK_DEPENDENCY_BY_REGION_BIT` unconditionally, this PR effectively changes barrier semantics to be region-limited whenever any pass-level dependency exists, and the flag also applies to image barriers emitted in the same `vkCmdPipelineBarrier()` call.

## Issue Context
- `compile()` currently sets `PassLevelDependency::dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT` for every pass-level dependency.
- `recordBarriers()` now ORs all `dependencyFlags` and passes them to `vkCmdPipelineBarrier()`.
- There is no public builder API to select/disable dependency flags.

## Fix Focus Areas
- FarmEngine/src/rendering/graph/RenderGraph.cpp[274-285]
- FarmEngine/src/rendering/graph/RenderGraph.cpp[372-443]

## Recommended fix
1. Default `PassLevelDependency::dependencyFlags` to `0` (safe default), unless the caller explicitly requests BY_REGION.
2. Extend `RenderGraphBuilder::addDependency()` (and possibly `addResourceDependency()` if needed) to accept an optional `VkDependencyFlags` parameter.
3. If you need different `dependencyFlags` for memory vs image barriers, emit separate `vkCmdPipelineBarrier()` calls so flags don’t unintentionally apply to all barriers in the combined call.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds important validation and fixes for render graph dependency handling. The changes properly validate dependency direction and correctly propagate dependency flags to pipeline barriers. No blocking issues identified - the implementation is correct and improves robustness.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request reorganizes the .gitignore file for better clarity and introduces a validation check in the RenderGraph to ensure that producer passes are defined before consumer passes. It also implements the aggregation of dependency flags for pipeline barriers. Feedback was provided regarding the use of combinedDependencyFlags in vkCmdPipelineBarrier, noting that VK_DEPENDENCY_BY_REGION_BIT requires all involved pipeline stages to be graphics-related to avoid Vulkan validation errors or undefined behavior when compute or transfer stages are present.

srcStage,
dstStage,
0,
combinedDependencyFlags,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using combinedDependencyFlags (which currently aggregates VK_DEPENDENCY_BY_REGION_BIT for pass-level dependencies) in vkCmdPipelineBarrier without validating the pipeline stages is risky. According to the Vulkan specification, VK_DEPENDENCY_BY_REGION_BIT can only be used if all pipeline stages in srcStageMask and dstStageMask are graphics stages. If any barrier in this call (including resource barriers) involves compute (VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT) or transfer stages, this will result in a validation error or undefined behavior. Consider only applying this flag if the aggregated stages are compatible with graphics-only operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants