shader: align centroid and vertex-pixel interpolation #643

Closed
github-bot wants to merge 2 commits from gh-pr/643/head into gh-pr/643/base
Owner

@⁠carbonimax on GitHub · 2026-09-16 16:30 UTC · original
carbonimax:fix/single-sample-centroid → main · +491 −396 · 7 files · 2 commits · closed without merging

Summary

  • Reuse center barycentric loads for perspective-centroid pixel inputs when all resolved attachments are single-sample.
  • Include the pipeline AA count in the pixel-program cache key.
  • Build a shared VS/PS parameter-location plan so flat and smooth aliases do not collide with vertex exports.
  • Publish the plan from the vertex stage, consume it in the pixel stage, duplicate exported values to required aliases, and cover the plan inputs in both stage cache keys.
  • Keep tessellation and mesh paths on their existing behavior.

Validation

  • shader_cfg_tests builds for x86_64 on macOS.
  • ctest -R shader_cfg passes: 1/1.
  • Regression coverage checks cache-key separation, single-sample center loads, unchanged multisample centroid emission, non-empty VS alias stores, PS locations 0/1, and flat/smooth decorations.
  • Independent Astra review found no blocking issue.
  • Earlier integrated MoltenVK validation showed the centroid shader compiling and its graphics pipeline being created; the game then reached a separate PerVertex limitation.

No isolated GPU run, execution of the game, or visual validation is claimed for the new shared VS/PS location plan.

**@⁠carbonimax** on GitHub · 2026-09-16 16:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/643) `carbonimax:fix/single-sample-centroid` → `main` · +491 −396 · 7 files · 2 commits · closed without merging ## Summary - Reuse center barycentric loads for perspective-centroid pixel inputs when all resolved attachments are single-sample. - Include the pipeline AA count in the pixel-program cache key. - Build a shared VS/PS parameter-location plan so flat and smooth aliases do not collide with vertex exports. - Publish the plan from the vertex stage, consume it in the pixel stage, duplicate exported values to required aliases, and cover the plan inputs in both stage cache keys. - Keep tessellation and mesh paths on their existing behavior. ## Validation - `shader_cfg_tests` builds for x86_64 on macOS. - `ctest -R shader_cfg` passes: 1/1. - Regression coverage checks cache-key separation, single-sample center loads, unchanged multisample centroid emission, non-empty VS alias stores, PS locations 0/1, and flat/smooth decorations. - Independent Astra review found no blocking issue. - Earlier integrated MoltenVK validation showed the centroid shader compiling and its graphics pipeline being created; the game then reached a separate PerVertex limitation. No isolated GPU run, execution of the game, or visual validation is claimed for the new shared VS/PS location plan.
Apply the repository's pinned clang-format 22.1.3 hook to the source files modified by this pull request.

Assisted-by: OpenAI GPT-6.1 Sol
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:27:59 +00:00
github-bot closed this pull request 2026-11-26 09:27:59 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-16 16:30 UTC · original · edited 2026-10-13 22:44 UTC

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: be341be1-18cb-4a2a-8529-886c9cd387bd

📥 Commits

Reviewing files that changed from the base of the PR and between ec393cbbb77d0b1a12106ff3aaf06be34113fa10 and 2908af3a718588b887ef0967f501ff15f773dbab.

📒 Files selected for processing (3)
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • tests/shaderCfgTests.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

Walkthrough

Changes

The draw path derives single-sample state and passes it through PipelineCache. Coupled vertex and pixel pipelines now share validated parameter-plan metadata. Shader cache keys include the new metadata. SPIR-V emission supports parameter aliases and direct centroid loads for single-sample pixels. Tests cover cache specialization, parameter planning, alias outputs, decorations, and valid SPIR-V.

Changes

Layer / File(s) Summary
Draw and pipeline propagation RefreshShaders derives single_sample. GetGraphicsPrograms forwards it and compiles coupled vertex and pixel programs with shared parameter-plan metadata.
Pixel parameter planning New metadata stores parameter locations, aliases, validity, and single-sample state. Plan construction validates inputs and reserves vertex-export locations.
Alias output and shader specialization Vertex SPIR-V emission creates alias outputs. Pixel emission uses planned locations. Static keys include parameter metadata and ps_single_sample.
Validation Tests cover single-sample recompilation, parameter-plan validation, alias locations, copied outputs, decorations, cache keys, and SPIR-V validity.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 73 functions across 12 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: aligning centroid interpolation and vertex-pixel interpolation.
Description check ✅ Passed The description directly explains the single-sample centroid behavior, shared VS/PS parameter-location plan, cache-key updates, preserved paths, and validation results.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 6.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 73 functions across 12 files. (1 skipped: 1 too large.)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-16 16:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/643#issuecomment-5700937978) · edited 2026-10-13 22:44 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/643#gh-light-mode-only"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg" alt="Review Change Stack" width="202" height="32"></a><a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/643#gh-dark-mode-only"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg" alt="Review Change Stack" width="202" height="32"></a> <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: review paused by coderabbit.ai --> > [!NOTE] > ## Reviews paused > > It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the `reviews.auto_review.auto_pause_after_reviewed_commits` setting. > > Use the following commands to manage reviews: > - `@coderabbitai resume` to resume automatic reviews. > - `@coderabbitai review` to trigger a single review. > > Use the checkboxes below for quick actions: > - [ ] <!-- {"checkboxId":"7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> ▶️ Resume reviews > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review <!-- end of auto-generated comment: review paused by coderabbit.ai --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `be341be1-18cb-4a2a-8529-886c9cd387bd` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between ec393cbbb77d0b1a12106ff3aaf06be34113fa10 and 2908af3a718588b887ef0967f501ff15f773dbab. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (3)</strong></summary> <dl> <dd> * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `tests/shaderCfgTests.cpp` </dd> </dl> </details> <details> <summary><strong>🚧 Files skipped from review as they are similar to previous changes (1)</strong></summary> <dl> <dd> * src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp </dd> </dl> </details> **Included review availability:** Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> ## Walkthrough ### Changes The draw path derives single-sample state and passes it through `PipelineCache`. Coupled vertex and pixel pipelines now share validated parameter-plan metadata. Shader cache keys include the new metadata. SPIR-V emission supports parameter aliases and direct centroid loads for single-sample pixels. Tests cover cache specialization, parameter planning, alias outputs, decorations, and valid SPIR-V. ### Changes |Layer / File(s)|Summary| |:---|:---| |**Draw and pipeline propagation**|`RefreshShaders` derives `single_sample`. `GetGraphicsPrograms` forwards it and compiles coupled vertex and pixel programs with shared parameter-plan metadata.| |**Pixel parameter planning**|New metadata stores parameter locations, aliases, validity, and single-sample state. Plan construction validates inputs and reserves vertex-export locations.| |**Alias output and shader specialization**|Vertex SPIR-V emission creates alias outputs. Pixel emission uses planned locations. Static keys include parameter metadata and `ps_single_sample`.| |**Validation**|Tests cover single-sample recompilation, parameter-plan validation, alias locations, copied outputs, decorations, cache keys, and SPIR-V validity.| **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"2908af3a718588b887ef0967f501ff15f773dbab" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>🚥 Pre-merge checks | ✅ 4 | ❌ 1</strong></summary> <dl> <dd> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :--------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 6.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 73 functions across 12 files. (1 skipped: … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly summarizes the main changes: aligning centroid interpolation and vertex-pixel interpolation. | | Description check | ✅ Passed | The description directly explains the single-sample centroid behavior, shared VS/PS parameter-location plan, cache-key updates, preserved paths, and validation results. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 6.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 73 functions across 12 files. (1 skipped: 1 too large.) </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=643)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-19 22:14 UTC · original · edited 2026-10-01 17:00 UTC
On src/graphics/host_gpu/renderer/renderDraw.cpp line 914 (outdated):

@@ -899,18 +903,29 @@ static void RefreshShaders(CommandBuffer& buffer, const DrawCallInfo& draw,
 			        .export_mapping;
 		}
 	}
+	// Centroid equals center only when every active attachment has one sample.
+	bool single_sample = true;
+	for (uint32_t i = 0; i < state.color_count; ++i) {
+		single_sample &= state.color_info[i].desc.info.samples == 1u;
+	}
+	if (state.depth_info.image_id) {
+		single_sample &= state.depth_info.desc.info.samples == 1u;
+	} else if (state.color_count == 0) {
+		single_sample = render_sample_count(ctx.GetAaConfig().msaa_num_samples) == 1u;

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

sed -n '850,950p' src/graphics/host_gpu/renderer/renderDraw.cpp
rg -n -B8 -A12 'RefreshShaders\(' src/graphics/host_gpu/renderer/renderDraw.cpp
rg -n -B6 -A12 'color_count|depth_info.*image_id|num_samples|sample_count' src/graphics/host_gpu/renderer/renderDraw.cpp | head -260

Repository: KytyPS5/KytyPS5

Length of output: 13842


🏁 Script executed:

rg -n -B12 -A18 'PrepareDrawRenderState\(' src/graphics/host_gpu/renderer/renderDraw.cpp
rg -n -B8 -A18 'GetGraphicsPrograms\(' src/graphics/host_gpu
rg -n -B8 -A18 'single_sample|centroid|center' src/graphics/host_gpu

Repository: KytyPS5/KytyPS5

Length of output: 36520


🏁 Script executed:

rg -n -B10 -A16 'ps_single_sample|ResolveRenderColorTarget|ResolveRenderDepthTarget' src/graphics/host_gpu

Repository: KytyPS5/KytyPS5

Length of output: 17842


🏁 Script executed:

rg -n -B12 -A20 'ps_single_sample|LoadInput|centroid|interpolat' src | head -260

Repository: KytyPS5/KytyPS5

Length of output: 21344


Use the resolved attachment sample count for single_sample.

Both draw paths value-initialize DrawRenderState, so RefreshShaders sees no color or depth attachments. It therefore uses ctx.GetAaConfig().msaa_num_samples for attached draws and passes that value into pixel_info.ps_single_sample. This can select the wrong center/centroid interpolation path.

Make the attachment sample counts available before passing single_sample to GetGraphicsPrograms. Keep the AA value only as the fallback when no active attachment exists. Preserve the current shader-output-derived mrt_mask dependency when restructuring this order.

✅ Confirmed as addressed by @⁠carbonimax

**@⁠coderabbitai[bot]** on GitHub · 2026-09-19 22:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/643#discussion_r4054957008) · edited 2026-10-01 17:00 UTC On `src/graphics/host_gpu/renderer/renderDraw.cpp` line 914 (outdated): ```diff @@ -899,18 +903,29 @@ static void RefreshShaders(CommandBuffer& buffer, const DrawCallInfo& draw, .export_mapping; } } + // Centroid equals center only when every active attachment has one sample. + bool single_sample = true; + for (uint32_t i = 0; i < state.color_count; ++i) { + single_sample &= state.color_info[i].desc.info.samples == 1u; + } + if (state.depth_info.image_id) { + single_sample &= state.depth_info.desc.info.samples == 1u; + } else if (state.color_count == 0) { + single_sample = render_sample_count(ctx.GetAaConfig().msaa_num_samples) == 1u; ``` _🎯 Functional Correctness_ | _🟠 Major_ | _🏗️ Heavy lift_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '850,950p' src/graphics/host_gpu/renderer/renderDraw.cpp rg -n -B8 -A12 'RefreshShaders\(' src/graphics/host_gpu/renderer/renderDraw.cpp rg -n -B6 -A12 'color_count|depth_info.*image_id|num_samples|sample_count' src/graphics/host_gpu/renderer/renderDraw.cpp | head -260 ``` Repository: KytyPS5/KytyPS5 Length of output: 13842 --- 🏁 Script executed: ```bash rg -n -B12 -A18 'PrepareDrawRenderState\(' src/graphics/host_gpu/renderer/renderDraw.cpp rg -n -B8 -A18 'GetGraphicsPrograms\(' src/graphics/host_gpu rg -n -B8 -A18 'single_sample|centroid|center' src/graphics/host_gpu ``` Repository: KytyPS5/KytyPS5 Length of output: 36520 --- 🏁 Script executed: ```bash rg -n -B10 -A16 'ps_single_sample|ResolveRenderColorTarget|ResolveRenderDepthTarget' src/graphics/host_gpu ``` Repository: KytyPS5/KytyPS5 Length of output: 17842 --- 🏁 Script executed: ```bash rg -n -B12 -A20 'ps_single_sample|LoadInput|centroid|interpolat' src | head -260 ``` Repository: KytyPS5/KytyPS5 Length of output: 21344 --- </details> **Use the resolved attachment sample count for `single_sample`.** Both draw paths value-initialize `DrawRenderState`, so `RefreshShaders` sees no color or depth attachments. It therefore uses `ctx.GetAaConfig().msaa_num_samples` for attached draws and passes that value into `pixel_info.ps_single_sample`. This can select the wrong center/centroid interpolation path. Make the attachment sample counts available before passing `single_sample` to `GetGraphicsPrograms`. Keep the AA value only as the fallback when no active attachment exists. Preserve the current shader-output-derived `mrt_mask` dependency when restructuring this order. <!-- fingerprinting:phantom:medusa:tapir --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d36a257ed57c2c40191d47de --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠carbonimax <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-19 22:14 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: d4704a5e-6a7b-43af-8bd6-e63af20d27b1

📥 Commits

Reviewing files that changed from the base of the PR and between da091907718cee1156aec46b59b7cd5de71e4ba6 and 49b987403b150e5493262bbb61524570955d30d8.

📒 Files selected for processing (12)
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterAnalysis.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp
  • src/graphics/shader/shader.cpp
  • src/graphics/shader/shader.h
  • src/graphics/shader/shaderPixelParameter.cpp
  • tests/shaderCfgTests.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-19 22:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/643#pullrequestreview-5258025403) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `d4704a5e-6a7b-43af-8bd6-e63af20d27b1` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between da091907718cee1156aec46b59b7cd5de71e4ba6 and 49b987403b150e5493262bbb61524570955d30d8. </details> <details> <summary>📒 Files selected for processing (12)</summary> * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterAnalysis.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp` * `src/graphics/shader/shader.cpp` * `src/graphics/shader/shader.h` * `src/graphics/shader/shaderPixelParameter.cpp` * `tests/shaderCfgTests.cpp` </details> **Included review availability:** Your plan provides up to 10 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Author
Owner

@⁠carbonimax on GitHub · 2026-10-01 16:59 UTC · original
On src/graphics/host_gpu/renderer/renderDraw.cpp line 914 (outdated):

@@ -899,18 +903,29 @@ static void RefreshShaders(CommandBuffer& buffer, const DrawCallInfo& draw,
 			        .export_mapping;
 		}
 	}
+	// Centroid equals center only when every active attachment has one sample.
+	bool single_sample = true;
+	for (uint32_t i = 0; i < state.color_count; ++i) {
+		single_sample &= state.color_info[i].desc.info.samples == 1u;
+	}
+	if (state.depth_info.image_id) {
+		single_sample &= state.depth_info.desc.info.samples == 1u;
+	} else if (state.color_count == 0) {
+		single_sample = render_sample_count(ctx.GetAaConfig().msaa_num_samples) == 1u;

Addressed in the updated branch. Shader compilation initially identifies the active MRT outputs; after resolving the effective color/depth targets, PrepareDrawRenderState recomputes the sample count and refreshes the shaders if ps_single_sample differs. The second refresh now passes the current main color_output_mask as well. DrawUsesSingleSample uses the actual active attachment descriptions; the AA register is only the fallback when there is no attachment. The centroid tests and the complete shader_cfg_tests suite pass after the main merge.

**@⁠carbonimax** on GitHub · 2026-10-01 16:59 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/643#discussion_r4158161665) On `src/graphics/host_gpu/renderer/renderDraw.cpp` line 914 (outdated): ```diff @@ -899,18 +903,29 @@ static void RefreshShaders(CommandBuffer& buffer, const DrawCallInfo& draw, .export_mapping; } } + // Centroid equals center only when every active attachment has one sample. + bool single_sample = true; + for (uint32_t i = 0; i < state.color_count; ++i) { + single_sample &= state.color_info[i].desc.info.samples == 1u; + } + if (state.depth_info.image_id) { + single_sample &= state.depth_info.desc.info.samples == 1u; + } else if (state.color_count == 0) { + single_sample = render_sample_count(ctx.GetAaConfig().msaa_num_samples) == 1u; ``` Addressed in the updated branch. Shader compilation initially identifies the active MRT outputs; after resolving the effective color/depth targets, PrepareDrawRenderState recomputes the sample count and refreshes the shaders if ps_single_sample differs. The second refresh now passes the current main color_output_mask as well. DrawUsesSingleSample uses the actual active attachment descriptions; the AA register is only the fallback when there is no attachment. The centroid tests and the complete shader_cfg_tests suite pass after the main merge.
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-01 17:00 UTC · original
On src/graphics/host_gpu/renderer/renderDraw.cpp line 914 (outdated):

@@ -899,18 +903,29 @@ static void RefreshShaders(CommandBuffer& buffer, const DrawCallInfo& draw,
 			        .export_mapping;
 		}
 	}
+	// Centroid equals center only when every active attachment has one sample.
+	bool single_sample = true;
+	for (uint32_t i = 0; i < state.color_count; ++i) {
+		single_sample &= state.color_info[i].desc.info.samples == 1u;
+	}
+	if (state.depth_info.image_id) {
+		single_sample &= state.depth_info.desc.info.samples == 1u;
+	} else if (state.color_count == 0) {
+		single_sample = render_sample_count(ctx.GetAaConfig().msaa_num_samples) == 1u;

@carbonimax, the supplied code addresses this finding. PrepareDrawRenderState preserves shader-output-derived MRT discovery, then refreshes shaders if the resolved attachment sample count changes ps_single_sample. The second refresh passes color_output_mask, and DrawUsesSingleSample uses the AA register only when no attachment exists.

Thanks for confirming the test results.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-01 17:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/643#discussion_r4158166193) On `src/graphics/host_gpu/renderer/renderDraw.cpp` line 914 (outdated): ```diff @@ -899,18 +903,29 @@ static void RefreshShaders(CommandBuffer& buffer, const DrawCallInfo& draw, .export_mapping; } } + // Centroid equals center only when every active attachment has one sample. + bool single_sample = true; + for (uint32_t i = 0; i < state.color_count; ++i) { + single_sample &= state.color_info[i].desc.info.samples == 1u; + } + if (state.depth_info.image_id) { + single_sample &= state.depth_info.desc.info.samples == 1u; + } else if (state.color_count == 0) { + single_sample = render_sample_count(ctx.GetAaConfig().msaa_num_samples) == 1u; ``` `@carbonimax`, the supplied code addresses this finding. `PrepareDrawRenderState` preserves shader-output-derived MRT discovery, then refreshes shaders if the resolved attachment sample count changes `ps_single_sample`. The second refresh passes `color_output_mask`, and `DrawUsesSingleSample` uses the AA register only when no attachment exists. Thanks for confirming the test results. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Use%20resolved%20attachment%20sample%20counts%E2%80%94not%20the%20AA%20fallback%E2%80%94to%20choose%20the%20shader%E2%80%99s%20single-sample%20interpolation%20path.%20%40coderabbitai%E2%80%99s%20review%20helped%20catch%20this%3B%20try%20it%20for%20smarter%20code%20reviews!%20%F0%9F%90%B0&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F643%23discussion_r4054957008)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠carbonimax on GitHub · 2026-10-01 17:39 UTC · original

CI update: Windows and Linux builds pass. The macOS job builds successfully, then fails in the unchanged memory_tracker test (fixed VirtualAlloc failed), with 12/13 tests passing. Local x86_64 Release build and shader_cfg_tests pass for this head. The macOS job on main 44798085 also fails in page_manager on fixed low mach_vm_allocate. These PRs do not modify the reservation tests or their implementation.

I tried rerunning the failed job, but GitHub requires repository admin rights. Could a maintainer rerun the failed macOS job? No reservation-code workaround is included in this PR.

**@⁠carbonimax** on GitHub · 2026-10-01 17:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/643#issuecomment-5937012983) CI update: Windows and Linux builds pass. The macOS job builds successfully, then fails in the unchanged `memory_tracker` test (`fixed VirtualAlloc failed`), with 12/13 tests passing. Local x86_64 Release build and shader_cfg_tests pass for this head. The macOS job on main 44798085 also fails in `page_manager` on fixed low mach_vm_allocate. These PRs do not modify the reservation tests or their implementation. I tried rerunning the failed job, but GitHub requires repository admin rights. Could a maintainer rerun [the failed macOS job](https://github.com/KytyPS5/KytyPS5/actions/runs/36896073322)? No reservation-code workaround is included in this PR.
Author
Owner

@⁠carbonimax on GitHub · 2026-10-01 19:58 UTC · original

The macOS CI reservation failure is now addressed by a test-only fix. The tests no longer assume that the low address 0x200010000 is free: Mach chooses available memory while preserving the offset within the 4 MiB tracker region and checking that the allocation remains in the valid low guest range. The extended-range test keeps its fixed address.

A regression case deliberately occupies the preferred address, verifies relocation without overwriting that mapping, and retains the existing protection and region-boundary assertions. Both memory_tracker and page_manager fail with the fixed-address allocator and pass with the corrected allocator (2/2), on the same tests. The tested memory sources and helper are identical across #633, #643 and #741. No emulator runtime or submission protocol change is included.

The updated head triggers a fresh CI run; local success is not being reported as a GitHub CI result.

**@⁠carbonimax** on GitHub · 2026-10-01 19:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/643#issuecomment-5939453221) The macOS CI reservation failure is now addressed by a test-only fix. The tests no longer assume that the low address 0x200010000 is free: Mach chooses available memory while preserving the offset within the 4 MiB tracker region and checking that the allocation remains in the valid low guest range. The extended-range test keeps its fixed address. A regression case deliberately occupies the preferred address, verifies relocation without overwriting that mapping, and retains the existing protection and region-boundary assertions. Both memory_tracker and page_manager fail with the fixed-address allocator and pass with the corrected allocator (2/2), on the same tests. The tested memory sources and helper are identical across #633, #643 and #741. No emulator runtime or submission protocol change is included. The updated head triggers a fresh CI run; local success is not being reported as a GitHub CI result.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.