shader: take compute derivatives from four consecutive lanes #1686

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

@⁠Nawid3333 on GitHub · 2026-10-19 03:00 UTC · original
Nawid3333:shader/compute-derivatives-linear → main · +72 −15 · 3 files · 6 commits · closed without merging

A compute shader that uses image_get_lod (the only instruction that sets compute_derivatives) declared DerivativeGroupQuadsKHR. That mode builds each derivative quad from LocalInvocationId (x, y), (x+1, y), (x, y+1), (x+1, y+1). The hardware builds it from four consecutive lanes (4n top-left, 4n+1 top-right, 4n+2 bottom-left, 4n+3 bottom-right), which is DerivativeGroupLinearKHR. Mesa shows the same: RADV and radeonsi implement DerivativeGroupQuads by remapping LocalInvocationId into consecutive invocations and then compiling the shader as linear (nir_lower_system_values.c, shuffle_local_ids_for_quad_derivatives).

On a 64-wide host the guest thread IDs come from LocalInvocationId, so a workgroup whose X size is not 2 got different derivative quads than on the console. In an 8x8 group, lanes 0..3 are x = 0..3 of row 0 on the console; with quads they were (0,0), (1,0), (0,1), (1,1). Quads also needs both X and Y to be multiples of two, so a 64x1 group was invalid; linear needs the product to be a multiple of four, so every size that was valid before still is (a group such as 1x1 stays invalid, as before). The 32-wide host path already forced a 2 x N local size so that quads matched the lane order.

The device was also created without VK_KHR_compute_shader_derivatives and without its feature, which the Vulkan registry requires for this extension and capability.

Change:

  • Emit ComputeDerivativeGroupLinearKHR and DerivativeGroupLinearKHR; drop the 2 x N reshape on 32-wide hosts (no longer needed).
  • Enable VK_KHR_compute_shader_derivatives when the device has it and chain its feature struct when computeDerivativeGroupLinear is supported. This AMD 26.8.1 driver and the vulkan.gpuinfo.org reports I checked (NVIDIA 582 and 610, Intel Arc B580 on Windows) support both modes. The log prints Vulkan compute derivatives support: true/false.
  • The harness requests computeDerivativeGroupLinear instead of quads.

Not covered: hosts without the KHR extension and linear support (MoltenVK, older NVIDIA drivers that only have VK_NV_compute_shader_derivatives) still get a shader that declares it, as on main. Implicit-LOD samples in compute shaders still use an explicit LOD, as on main.

Tests

Windows, AMD Radeon RX 9070 XT (fork CI builds Windows, Linux and macOS and runs the CPU tests, all green on 7ffd3db2; CI runs no GPU tests):

  • New ImageGetLodComputeLaneQuads cases for 8x8, 64x1 and 16x16 groups in shader_recompiler_compute_tests, in --wave64-only and the full run: u = 0.25 * bit 1 of x on a 16x16 texture with mips. In each run of four lanes u is 0, 0, 0.25, 0.25, so only du/dy is non-zero (4 texels) and every LOD formula the spec allows gives exactly 2. On main the 8x8 and 16x16 cases return 0.0 for the clamped and -3.4e38 for the unclamped LOD in every lane (u is constant in each (x, y) quad, so the derivative is zero), and --wave64-only stops at the first. The 64x1 case does not get that far on main: its SPIR-V fails spirv-val (VUID-StandaloneSpirv-DerivativeGroupQuadsKHR-10151), so with shader validation enabled the emulator stops on such a shader (SPIR-V validation failed in pipelineCache.cpp). With this change all three pass, also under the validation layer (no messages).
  • The only other harness case with image_get_lod, ImageSampleAndGather, passes with quads and with linear on 64-wide and 32-wide hosts. No other case changes: both emitter changes depend on compute_derivatives.
  • shader_cfg passes on main and with this change.
  • After merging main (at c67352d5; main had meanwhile added the MinLod requirement next to the derivatives one in the harness and VK_EXT_extended_dynamic_state next to this extension): on the RX 9070 XT, natively and with the harness forced to 32-wide subgroups (a local switch), and on the Ryzen 7600X iGPU, only the three new cases change.
  • The emulator's own device creation (vulkanWindow.cpp) builds but was not run here (no game); the harness creates its device separately.

No game report names this yet. If you would rather handle this differently, feel free to close it and say what you would prefer.

AI use

I used Claude Code (AI agent) to find the cause, write the change and the test, and run the checks; I reviewed the diff and the results.

**@⁠Nawid3333** on GitHub · 2026-10-19 03:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1686) `Nawid3333:shader/compute-derivatives-linear` → `main` · +72 −15 · 3 files · 6 commits · closed without merging A compute shader that uses `image_get_lod` (the only instruction that sets `compute_derivatives`) declared `DerivativeGroupQuadsKHR`. That mode builds each derivative quad from `LocalInvocationId` (x, y), (x+1, y), (x, y+1), (x+1, y+1). The hardware builds it from four consecutive lanes (4n top-left, 4n+1 top-right, 4n+2 bottom-left, 4n+3 bottom-right), which is `DerivativeGroupLinearKHR`. Mesa shows the same: RADV and radeonsi implement `DerivativeGroupQuads` by remapping `LocalInvocationId` into consecutive invocations and then compiling the shader as linear (`nir_lower_system_values.c`, `shuffle_local_ids_for_quad_derivatives`). On a 64-wide host the guest thread IDs come from `LocalInvocationId`, so a workgroup whose X size is not 2 got different derivative quads than on the console. In an 8x8 group, lanes 0..3 are x = 0..3 of row 0 on the console; with quads they were (0,0), (1,0), (0,1), (1,1). Quads also needs both X and Y to be multiples of two, so a 64x1 group was invalid; linear needs the product to be a multiple of four, so every size that was valid before still is (a group such as 1x1 stays invalid, as before). The 32-wide host path already forced a 2 x N local size so that quads matched the lane order. The device was also created without `VK_KHR_compute_shader_derivatives` and without its feature, which the Vulkan registry requires for this extension and capability. **Change:** - Emit `ComputeDerivativeGroupLinearKHR` and `DerivativeGroupLinearKHR`; drop the 2 x N reshape on 32-wide hosts (no longer needed). - Enable `VK_KHR_compute_shader_derivatives` when the device has it and chain its feature struct when `computeDerivativeGroupLinear` is supported. This AMD 26.8.1 driver and the vulkan.gpuinfo.org reports I checked (NVIDIA 582 and 610, Intel Arc B580 on Windows) support both modes. The log prints `Vulkan compute derivatives support: true/false`. - The harness requests `computeDerivativeGroupLinear` instead of quads. Not covered: hosts without the KHR extension and linear support (MoltenVK, older NVIDIA drivers that only have `VK_NV_compute_shader_derivatives`) still get a shader that declares it, as on main. Implicit-LOD samples in compute shaders still use an explicit LOD, as on main. ## Tests Windows, AMD Radeon RX 9070 XT (fork CI builds Windows, Linux and macOS and runs the CPU tests, all green on 7ffd3db2; CI runs no GPU tests): - New `ImageGetLodComputeLaneQuads` cases for 8x8, 64x1 and 16x16 groups in `shader_recompiler_compute_tests`, in `--wave64-only` and the full run: u = 0.25 * bit 1 of x on a 16x16 texture with mips. In each run of four lanes u is 0, 0, 0.25, 0.25, so only du/dy is non-zero (4 texels) and every LOD formula the spec allows gives exactly 2. On main the 8x8 and 16x16 cases return 0.0 for the clamped and -3.4e38 for the unclamped LOD in every lane (u is constant in each (x, y) quad, so the derivative is zero), and `--wave64-only` stops at the first. The 64x1 case does not get that far on main: its SPIR-V fails `spirv-val` (`VUID-StandaloneSpirv-DerivativeGroupQuadsKHR-10151`), so with shader validation enabled the emulator stops on such a shader (`SPIR-V validation failed` in `pipelineCache.cpp`). With this change all three pass, also under the validation layer (no messages). - The only other harness case with `image_get_lod`, `ImageSampleAndGather`, passes with quads and with linear on 64-wide and 32-wide hosts. No other case changes: both emitter changes depend on `compute_derivatives`. - `shader_cfg` passes on main and with this change. - After merging main (at c67352d5; main had meanwhile added the MinLod requirement next to the derivatives one in the harness and VK_EXT_extended_dynamic_state next to this extension): on the RX 9070 XT, natively and with the harness forced to 32-wide subgroups (a local switch), and on the Ryzen 7600X iGPU, only the three new cases change. - The emulator's own device creation (`vulkanWindow.cpp`) builds but was not run here (no game); the harness creates its device separately. No game report names this yet. If you would rather handle this differently, feel free to close it and say what you would prefer. ## AI use I used Claude Code (AI agent) to find the cause, write the change and the test, and run the checks; I reviewed the diff and the results.
Compute shaders that query an image LOD declared DerivativeGroupQuadsKHR,
which builds each quad from LocalInvocationId (x, y), (x+1, y), (x, y+1),
(x+1, y+1). The hardware builds it from four consecutive lanes, which is
DerivativeGroupLinearKHR. On 64-wide hosts the guest thread IDs come from
LocalInvocationId, so a workgroup whose X size is not 2 got different
quads than on the console (an 8x8 group: LOD 1 instead of 2 in the new
test), and a 64x1 group broke the even-size rule of quads. The 32-wide host
path forced a 2 x N local size to make quads match the lane order; linear
needs no reshape.

The device was also created without VK_KHR_compute_shader_derivatives and
without its feature. Enable the extension when available and chain its
feature struct when computeDerivativeGroupLinear is supported.

ImageGetLodComputeLaneQuads (also in --wave64-only) returns LOD 1.0 in all
64 lanes on main and 2.0 with this change on an RX 9070 XT.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
u = 0.25 * bit 1 of x leaves only du/dy non-zero in each run of four
lanes, so every LOD formula the spec allows gives exactly 2 (the old
u = x / 8 also had a du/dx term, and AMD returns 2.16 for the
combination). Run it for 8x8, 64x1 and 16x16 groups.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/graphics/presentation/window/vulkanWindow.cpp
#	tests/ShaderRecompilerComputeTests.cpp
ImageGetLodComputeLaneQuads expects 2.0 and allowed 1/64; a conforming
implementation with the guaranteed 4 bits may be 1/16 off. Main's wrong
quads LOD (0.0 or -3.4e38) is still far outside that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/graphics/presentation/window/vulkanWindow.cpp
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:03:14 +00:00
github-bot closed this pull request 2026-11-26 10:03:14 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 03:07 UTC · original · edited 2026-11-03 19:52 UTC

Review in 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.

Walkthrough

Vulkan setup queries and conditionally enables linear compute derivatives. The SPIR-V emitter declares the linear derivative capability and execution mode for compute shaders that use derivatives. Lane-count-2 shaders use a flattened workgroup size with local_y and local_z set to 1. New image LOD compute tests cover three workgroup shapes and check results.

Suggested reviewers: claxten10

Change: Bug fix

Merge Risk: Minimal · previous review 7ffd3

The linear-derivative changes are ready to merge after normal checks. The test tolerance has been corrected; devices without linear-derivative support remain outside this change’s scope.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: compute derivatives now use four consecutive lanes instead of quad grouping.
Description check Passed The description is directly related to the changes. It explains the derivative-grouping change, Vulkan feature handling, workgroup behavior, limitations, and test 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 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files. (1 skipped: 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between cfdeb44d97 and 7ffd3db29a.

Files selected for processing: 1
  • tests/ShaderRecompilerComputeTests.cpp
Files skipped from review as they are similar to previous changes: 1
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 03:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1686#issuecomment-6258771243) · edited 2026-11-03 19:52 UTC <!-- coderabbit-ai-generated:v1 --> <!-- 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/1686?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></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. > > - Last reviewed commit: 7ffd3db29a9acb6be3870f0a9e5452e29cc82855 > - Latest commit, not reviewed: 64e35a8f6070706881eba0574023d984130f325f > > 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_status_start --> No actionable comments were generated in the recent review. <!-- recent_review_status_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> Vulkan setup queries and conditionally enables linear compute derivatives. The SPIR-V emitter declares the linear derivative capability and execution mode for compute shaders that use derivatives. Lane-count-2 shaders use a flattened workgroup size with `local_y` and `local_z` set to 1. New image LOD compute tests cover three workgroup shapes and check results. **Suggested reviewers:** `claxten10` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> <!-- change_assessment_commit:"7ffd3db29a9acb6be3870f0a9e5452e29cc82855" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · previous review <code>7ffd3</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `7ffd3` --> <!-- final_review_risk_coverage:{"sourceCommitId":"7ffd3db29a9acb6be3870f0a9e5452e29cc82855","coveredCommitId":"7ffd3db29a9acb6be3870f0a9e5452e29cc82855","kind":"reviewed"} --> The linear-derivative changes are ready to merge after normal checks. The test tolerance has been corrected; devices without linear-derivative support remain outside this change’s scope. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly summarizes the main change: compute derivatives now use four consecutive lanes instead of quad grouping. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description is directly related to the changes. It explains the derivative-grouping change, Vulkan feature handling, workgroup behavior, limitations, and test results. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | 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 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files. (1 skipped: 1 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </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=1686)! 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> <!-- tips_end --> <!-- verify_invitation_start --> ### CodeRabbit Verify - [ ] <!-- {"checkboxId":"run-qa-agent"} --> Run CodeRabbit Verify to test the changes in this pull request. <!-- verify_invitation_end --> <!-- recent_review_start --> <h6> <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/c67352d5d6dc6fc3fd375deed5c1a89b3e33974e/.coderabbit.yaml>) - **Commit**: [c67352d](<https://github.com/KytyPS5/KytyPS5/commit/c67352d5d6dc6fc3fd375deed5c1a89b3e33974e>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `97b43925-5776-48b0-9026-9878838b7e00` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between cfdeb44d973d10b80e7cd5d80ac11af5118efcb8 and 7ffd3db29a9acb6be3870f0a9e5452e29cc82855. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 1</strong></summary> <dl> <dd> * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-similar-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-similar.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files skipped from review as they are similar to previous changes: 1</strong></summary> <dl> <dd> * tests/ShaderRecompilerComputeTests.cpp </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 03:35 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Gate DerivativeGroupLinearKHR on the enabled feature. · spirvEmitterModule.cpp:857-859

src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp:857-859
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Gate DerivativeGroupLinearKHR on the enabled feature.

ImageQueryLod sets compute_derivatives, and the emitter then unconditionally adds DerivativeGroupLinearKHR. Device creation enables computeDerivativeGroupLinear only when the device supports it. On unsupported devices, compute dispatch still creates the shader module and pipeline. Vulkan can reject either operation, and the error reaches fatal handling. No fallback prevents this failure.

Pass the actual enabled capability into shader generation. Emit the linear derivative mode only when it is enabled. Otherwise use a supported derivative path or handle the unsupported shader before module or pipeline creation.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 21130d21-5339-4a27-9fa6-62c3305d9d39
📥 Commits

Reviewing files that changed from the base of the PR and between c1fab1544a and 5efd999691.

📒 Files selected for processing: 1
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 03:35 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1686#pullrequestreview-5566625811) · **reviewed** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong>🟠 Major</strong> · Gate <code>DerivativeGroupLinearKHR</code> on the enabled feature. · <code>spirvEmitterModule.cpp:857-859</code></summary><blockquote> > > `src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp:857-859` > **🩺 Stability & Availability** | **🟠 Major** | **🏗️ Heavy lift** > > **Gate `DerivativeGroupLinearKHR` on the enabled feature.** > > `ImageQueryLod` sets `compute_derivatives`, and the emitter then unconditionally adds `DerivativeGroupLinearKHR`. Device creation enables `computeDerivativeGroupLinear` only when the device supports it. On unsupported devices, compute dispatch still creates the shader module and pipeline. Vulkan can reject either operation, and the error reaches fatal handling. No fallback prevents this failure. > > Pass the actual enabled capability into shader generation. Emit the linear derivative mode only when it is enabled. Otherwise use a supported derivative path or handle the unsupported shader before module or pipeline creation. > > <!-- cr-comment:v1:e5f8bf1f059e363575b1f016 --> > > </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `21130d21-5339-4a27-9fa6-62c3305d9d39` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between c1fab1544a53d1f7906f2a7a654cedd197e863be and 5efd9996919041bea09905d03b1528ce710d8576. </details> <details> <summary>📒 Files selected for processing: 1</summary> * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=fc78842f-5482-422e-a182-5c32a78a1031 attempt=93cc874a-8248-4f63-9f92-334066a13cf5 batch=1/1 -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-19 03:48 UTC · original

This was already the case on main, which declared the quads capability without enabling any compute-derivatives extension. The description lists it under "Not covered": hosts without the KHR extension and linear support (MoltenVK, NVIDIA drivers that only have the NV extension) still get a shader that declares it. A fallback for them (for example an LOD computed from quad swaps) would be a separate change; MoltenVK does not get past device selection yet (#1068).

**@⁠Nawid3333** on GitHub · 2026-10-19 03:48 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1686#issuecomment-6259224939) This was already the case on main, which declared the quads capability without enabling any compute-derivatives extension. The description lists it under "Not covered": hosts without the KHR extension and linear support (MoltenVK, NVIDIA drivers that only have the NV extension) still get a shader that declares it. A fallback for them (for example an LOD computed from quad swaps) would be a separate change; MoltenVK does not get past device selection yet (#1068).
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-28 20:19 UTC · original · edited 2026-10-28 21:23 UTC
On tests/ShaderRecompilerComputeTests.cpp line 39756 (outdated):

@@ -39731,6 +39731,44 @@ TestCase ImageSampleAndGather() {
   return test;
 }
 
+TestCase ImageGetLodComputeLaneQuads(const char *name, u32 width_shift,
+                                     u32 height) {
+  using O = ShaderOpcode;
+  const u32 lanes = (1u << width_shift) * height;
+  std::vector<u32> code;
+  code.push_back(EncodeVop2(0x1b, 20, InlineU32(2), 0));
+  code.push_back(EncodeVop1(0x06, 20, Vgpr(20)));
+  AppendVMovLiteral(&code, 22, 0x3e000000u);
+  code.push_back(EncodeVop2(0x08, 20, Vgpr(20), 22));
+  AppendVMovLiteral(&code, 21, 0x3f000000u);
+  code.push_back(EncodeMimg0(0x60, 0x3));
+  code.push_back(EncodeMimg1(10, 20));
+  code.push_back(EncodeVop2(0x1a, 23, InlineU32(width_shift), 1));
+  code.push_back(EncodeVop2(0x25, 23, Vgpr(0), 23));
+  AppendStoreVgprAtLaneDwordOffset(&code, 10, 23, 0);
+  AppendStoreVgprAtLaneDwordOffset(&code, 11, 23, lanes);
+  AppendEnd(&code);
+
+  TestCase test;
+  test.name = name;
+  test.code = code;
+  test.expected.assign(2 * lanes, 0x40000000u);
+  test.expected_float_tolerance = 1.0f / 64.0f;

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

rg -n 'expected_float_tolerance|mipmapPrecisionBits' tests/ShaderRecompilerComputeTests.cpp | head -60
sed -n '39725,39780p' tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 2744


Script executed:

set -o pipefail
printf '%s\n' '--- tolerance comparison ---'
sed -n '1390,1420p' tests/ShaderRecompilerComputeTests.cpp
sed -n '22420,22450p' tests/ShaderRecompilerComputeTests.cpp

printf '%s\n' '--- IMAGE_GET_LOD references and nearby test declarations ---'
rg -n -F -- 'IMAGE_GET_LOD' tests/ShaderRecompilerComputeTests.cpp
sed -n '39190,39340p' tests/ShaderRecompilerComputeTests.cpp
sed -n '39690,39770p' tests/ShaderRecompilerComputeTests.cpp

printf '%s\n' '--- precision identifiers in the repository ---'
rg -n -F -- 'mipmapPrecisionBits' . || test "$?" -eq 1
rg -n -F -- 'limits' src/graphics tests/ShaderRecompilerComputeTests.cpp | head -100

printf '%s\n' '--- diff from requested merge base ---'
git diff --unified=20 c67352d5d6dc6fc3fd375deed5c1a89b3e33974e cfdeb44d973d10b80e7cd5d80ac11af5118efcb8 -- tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 39360


Web query:

Vulkan 1.3 specification mipmapPrecisionBits textureQueryLod OpImageQueryLod precision exact integer LOD

Result:

<source_evidence>
<source kind="find_in_page">
<title>SPIR-V Specification</title>
<location>https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html</location>
<excerpt>citeturn512513view0 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn398895search1&quot;,&quot;pattern&quot;:&quot;OpImageQueryLod&quot;}); Total lines: 11166
L5465: Query the image format of an image created with an Unknown 【66†Image Format】. Result Type must be a scalar 【203†integer type】. The resulting value is an enumerant from 【68†Image Channel Data Type】. Image must be an object whose type is 【220†OpTypeImage】.  | 【86†Capability】:
L5466: Kernel
L5467: 4  | 101  | &lt;id&gt;
L5468: Result Type  | 【205†Result &lt;id&gt;】  | &lt;id&gt;
L5469: Image
L5470: OpImageQueryOrder
L5471: Query the channel order of an image created with an Unknown 【66†Image Format】. Result Type must be a scalar 【203†integer type】. The resulting value is an enumerant from 【67†Image Channel Order】. Image must be an object whose type is 【220†OpTypeImage】.  | 【86†Capability】:
L5472: Kernel
L5473: 4  | 102  | &lt;id&gt;
L5474: Result Type  | 【205†Result &lt;id&gt;】  | &lt;id&gt;
L5475: Image
L5476: OpImageQuerySizeLod
L5477: Query the dimensions of Image for mipmap level for Level of Detail. Result Type must be an 【203†integer type】 scalar or vector. The number of components must be
L5478: 1 for the 1D 【63†dimensionality】,
L5479: 2 for the 2D and Cube 【63†dimensionalities】,
L5480: 3 for the 3D 【63†dimensionality】,
L5481: plus 1 more if the image type is arrayed. This vector is filled in with (width [, height] [, depth] [, elements]) where elements is the number of layers in an image array, or the number of cubes in a cube-map array. Image must be an object whose type is 【220†OpTypeImage】. Its 【63†Dim】 operand must be one of 1D, 2D, 3D, or Cube, and its MS must be 0. See 【741†OpImageQuerySize】 for querying image types without level of detail. See the client API specification for additional image type restrictions.
L5482: Level of Detail is used to compute which mipmap level to query and must be a 32-bit 【203†integer type】 scalar.  | 【86†Capability】:
L5483: Kernel, ImageQuery
L5484: 5  | 103  | &lt;id&gt;
L5485: Result Type  | 【205†Result &lt;id&gt;】  | &lt;id&gt;
L5486: Image  | &lt;id&gt;
L5487: Level of Detail
L5488: OpImageQuerySize
L5489: Query the dimensions of Image, with no level of detail. Result Type must be an 【203†integer type】 scalar or vector. The number of components must be:
L5490: 1 for the 1D and Buffer 【63†dimensionalities】,
L5491: 2 for the 2D, Cube, and Rect 【63†dimensionalities】,
L5492: 3 for the 3D 【63†dimensionality】,
L5493: plus 1 more if the image type is arrayed. This vector is filled in with (width [, height] [, elements]) where elements is the number of layers in an image array or the number of cubes in a cube-map array. Image must be an object whose type is 【220†OpTypeImage】. Its 【63†Dim】 operand must be one of those listed under Result Type, above. Additionally, if its Dim is 1D, 2D, 3D, or Cube, it must also have either an MS of 1 or a Sampled of 0 or 2.
L5494: There is no implicit level-of-detail consumed by this instruction. See 【742†OpImageQuerySizeLod】 for querying images having level of detail. See the client API specification for additional image type restrictions.  | 【86†Capability】:
L5495: Kernel, ImageQuery
L5496: 4  | 104  | &lt;id&gt;
L5497: Result Type  | 【205†Result &lt;id&gt;】  | &lt;id&gt;
L5498: Image
L5499: OpImageQueryLod
L5500: Query the mipmap level and the level of detail for a hypothetical sampling of Image at Coordinate using an implicit level of detail. An invocation will not execute a 【278†dynamic instance】 of this instruction (X&#39;) until all invocations in its 【362†derivative group】 have executed all 【278†dynamic instances】 that are 【740†program-ordered before】 X&#39;. Result Type must be a two-component 【202†floating-point type】 vector.
L5501: The first component of the result contains the mipmap array layer.
L5502: The second component of the result contains the implicit level of detail relative to the base level. Sampled Image must be an object whose type is 【227†OpTypeSampledImage】. Its 【220†OpTypeImage】 【63†Dim】 operand must be one of 1D, 2D, 3D, or Cube, and its MS must be 0. Coordinate must be a scalar or vector of 32-bit 【202†floating-point type】. It contains (u[, v] …​ ) as needed by the definition of Sampled Image, not including any array layer index.
L5503: This instruction is only valid in the Fragment 【58†Execution Model】. In addition, it consumes an implicit derivative that can be affected by code motion.  | 【86†Capability】:
L5504: ImageQuery
L5505: 5  | 105  | &lt;id&gt;
L5506: Result Type  | 【205†Result &lt;id&gt;】  | &lt;id&gt;
L5507: Sampled Image  | &lt;id&gt;
L5508: Coordinate
L5509: OpImageQueryLevels
L5510: Query the number of mipmap levels accessible through Image. Result Type must be a scalar 【203†integer type】. The result is the number of mipmap levels, as specified by the client API. Image must be an object whose type is 【220†OpTypeImage】. Its 【63†Dim】 operand must be one of 1D, 2D, 3D, or Cube, and its MS must be 0. See the client API specification for additional image type restrictions.  | 【86†Capability】:
L5511: Kernel, ImageQuery
L5512: 4  | 106  | &lt;id&gt;
L5513: Result Type  | 【205†Result &lt;id&gt;】  | &lt;id&gt;
L5514: Image
L5515: OpImageQuerySamples
L5516: Query the number of samples available per texel fetch in a multisample image. Result Type must be a scalar 【203†integer type】. The result is the number of samples. Image must be an object whose type is 【220†OpTypeImage】. Its 【63†Dim】 operand must be one of 2D and MS of 1.  | 【86†Capability】:
L5517: Kernel, ImageQuery
L5518: 4  | 107  | &lt;id&gt;
L5519: Result Type  | 【205†Result &lt;id&gt;】  | &lt;id&gt;
L5520: Image
L5521: OpImageSparseSampleImplicitLod
L5522: Sample a sparse image with an implicit level of detail. An invocation will not execute a 【278†dynamic instance】 of this instruction (X&#39;) until all invocations in its 【362†derivative group】 have executed all 【278†dynamic instances】 that are 【740†program-ordered before】 X&#39;. Result Type must be an 【317†OpTypeStruct】 with two members. The first member’s type must be an 【203†integer type】 scalar. It holds a Residency Code that can be passed to 【743†OpImageSparseTexelsResident】.
L5523: The second member must be a vector of four components of 【202†floating-point type】 or 【203†integer type】. Its components must be the same as Sampled Type of the underlying 【220†OpTypeImage】 (unless that underlying Sampled Type is OpTypeVoid). Sampled Image must be an object whose type is 【227†OpTypeSampledImage】. Its 【220†OpTypeImage】 must not have a 【63†Dim】 of Buffer. The MS operand of the underlying 【220†OpTypeImage】 must be 0. Coordinate must be a scalar or vector of 32-bit 【202†floating-point type】.
L5524: It contains (u[, v] …​ [, array layer]) as needed by the definition of Sampled Image. It may be a vector larger than needed, but all unused components appear after all used components. Image Operands encodes what operands follow, as per 【69†Image Operands】. This instruction is only valid in the Fragment 【58†Execution Model】. In addition, it consumes an implicit derivative that can be affected by code motion.  | 【86†Capability】:
L5525: SparseResidency
L5526: 5 + variable  | 305  | &lt;id&gt;
L5527: Result Type  | 【205†Result &lt;id&gt;】  | &lt;id&gt;
L5528: Sampled Image  | &lt;id&gt;
L5529: Coordinate  | Optional
L5530: 【69†Image Operands】
L5531:  | Optional
L5532: &lt;id&gt;, &lt;id&gt;, …​
L5533: OpImageSparseSampleExplicitLod
L5534: Sample a sparse image using an explicit level of detail. Result Type must be an 【317†OpTypeStruct】 with two members. The first member’s type must be an 【203†integer type】 scalar. It holds a Residency Code that can be passed to 【743†OpImageSparseTexelsResident】. The second member must be a vector of four components of 【202†floating-point type】 or 【203†integer type】. Its components must be the same as Sampled Type of the underlying 【220†OpTypeImage】 (unless that underlying Sampled Type is OpTypeVoid).
L5535: Sampled Image must be an object whose type is 【227†OpTypeSampledImage】. Its 【220†OpTypeImage】 must not have a 【63†Dim】 of Buffer. The MS operand of the underlying 【220†OpTypeImage】 must be 0. Coordinate must be a scalar or vector of 32-bit 【202†floating-point type】 or 32-bit 【203†integer type】. It contains (u[, v] …​ [, array layer]) as needed by the definition of Sampled Image. Unless the Kernel 【86†capability】 is declared, it must be floating point.
L5536: It may be a vector larger than needed, but all unused components appear after all used components. Image Operands encodes what operands follow, as per 【69†Image Operands】. Either Lod or Grad image operands must be present.  | 【86†Capability】:
L5537: SparseResidency
L5538: 7 + variable  | 306  | &lt;id&gt;
L5539: Result Type  | 【205†Result &lt;id&gt;】  | &lt;id&gt;
L5540: Sampled Image  | &lt;id&gt;
L5541: Coordinate  | 【69†Image Operands】
L5542:  | &lt;id&gt;
L9913:   * Khronos SPIR-V issue #60: 【280†OpControlBarrier】 synchronizes Output variables when used in tessellation-control shader.
L9914: 
L9915:   * Public SPIRV-Headers issue #1: Remove the Shader capability requirement from the Input 【62†Storage Class】.
L9916: 
L9917:   * Public SPIRV-Headers issue #10: Don’t say the (u [, v] [, w], q) has four components, as it can be closed up when the optional ones are missing. Seen in the 【396†projective image】 instructions.
L9918:   * Public SPIRV-Headers issues #12 and #13 and Khronos SPIR-V issue #65: Allow 【206†OpVariable】 as an initializer for another OpVariable instruction or the Base of an 【339†OpSpecConstantOp】 with an AccessChain opcode.
L9919: 
L9920:   * Public SPIRV-Headers issues #14: add Max enumerants of 0x7FFFFFFF to each of the non-mask enums in the C-based header files.
L9921: ### 4.8. Changes from Version 1.00, Revision 6
L9922: 
L9923:   * Khronos SPIR-V issue #63: Be clear that OpUndef can be used in sequence 9 (and is preferred to be) of the 【22†Logical Layout】 and can be part of partially-defined 【334†OpConstantComposite】.
L9924: 
L9925:   * Khronos SPIR-V issue #70: Don’t explicitly require operand truncation for integer operations when operating at 【37†RelaxedPrecision】.
L9926: 
L9927:   * Khronos SPIR-V issue #76: Include OpINotEqual in the list of allowed instructions for 【339†OpSpecConstantOp】.
L9928:   * Khronos SPIR-V issue #79: Remove implication that 【767†OpImageQueryLod】 should have a component for the array index.
L9929: 
L9930:   * Public SPIRV-Headers issue #17: 【75†Decorations】 NoPerspective, Flat, Patch, Centroid, and Sample can apply to a top-level member that is itself a structure, so don’t disallow it through restrictions to numeric types.
L9931: ### 4.9. Changes from Version 1.00, Revision 7
L9932: 
L9933:   * Khronos SPIR-V issue #69: 【409†OpImageSparseFetch】 editorial change in summary: include that it is sampled image.
L9934: 
L9935:   * Khronos SPIR-V issue #74: 【767†OpImageQueryLod】 requires a sampler.
L9936: 
L9937:   * Khronos SPIR-V issue #82: Clarification to the Float16Buffer 【86†Capability】.
L9938: 
L9939:   * Khronos SPIR-V issue #89: Editorial improvements to 【320†OpMemberDecorate】 and 【323†OpDecorationGroup】.
L9940: ### 4.10. Changes from Version 1.00, Revision 8
L9941: 
L9942:   * Add SPV_KHR_subgroup_vote tokens.
L9943: 
L9944:   * Typo: Change &quot;without a sampler&quot; to &quot;with a sampler&quot; for the description of the 【86†SampledBuffer】 Capability.
L9945: 
L9946:   * Khronos SPIR-V issue #61: Clarification of packet size and alignment on all instructions that use the 【86†Pipes】 Capability.
L9947: 
L9948:   * Khronos SPIR-V issue #99: Use &quot;invalid&quot; language to replace any &quot;compile-time error&quot; language.
L9949:   * Khronos SPIR-V issue #55: Distinguish between 【261†branch instructions】 and 【251†termination instructions】.
L9950: 
L9951:   * Khronos SPIR-V issue #94: Add missing 【768†OpSubgroupReadInvocationKHR】 enumerant.
L9952: 
L9953:   * Khronos SPIR-V issue #114: Header blocks 【766†strictly dominate】 their merge blocks.
L9954: 
L9955:   * Khronos SPIR-V issue #119: 【339†OpSpecConstantOp】 allows OpUndef where allowed by its opcode.
L9956: ### 4.11. Changes from Version 1.00, Revision 9
L9957: 
L9958:   * Khronos Vulkan issue #652: Remove statements about matrix offsets and padding. These are described correctly in the Vulkan API specifications.
L9959: 
L9960:   * Khronos SPIR-V issue #113: Remove the &quot;By Default&quot; statements in 【71†FP Rounding Mode】. These should be properly specified by the client API.
L9961: 
L9962:   * Add extension enumerants for
L9963: 
L9964:     * SPV_KHR_16bit_storage
L9965: 
L9966:     * SPV_KHR_device_group
L9967: 
L9968:     * SPV_KHR_multiview
L9969: 
L9970:     * SPV_NV_sample_mask_override_coverage
L9971:     * SPV_NV_geometry_shader_passthrough
L9972: 
L9973:     * SPV_NV_viewport_array2
L9974: 
L9975:     * SPV_NV_stereo_view_rendering
L9976: 
L9977:     * SPV_NVX_multiview_per_view_attributes
L9978: ### 4.12. Changes …[truncated]</excerpt>
</source>
<source kind="open_page">
<title>The OpenGL® Shading Language, Version 4.60.8</title>
<location>https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html</location>
<excerpt>citeturn215078view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;turn376994search0&quot;,&quot;lineno&quot;:null}); Total lines: 7039
L1260: If the image target type does not match the bound image in this manner, if the data type does not match the bound image, or if the format layout qualifier does not match the image unit format as described in section 8.25 “Texture Image Loads and Stores” of the 【82†OpenGL Specification】, the results of image accesses are undefined but cannot include program termination.
L2998: #### 4.7.1. Range and Precision
L2999: 
L3000: The precision of highp single- and double-precision floating-point variables is defined by the IEEE 754 standard for 32-bit and 64-bit floating-point numbers.
L3001: 
L3002: This includes support for NaNs (Not a Number) and Infs (positive or negative infinities) and positive and negative zeros.
L3003: The following rules apply to highp for both single and double-precision operations: Signed infinities and zeros are generated as dictated by IEEE, but subject to the precisions allowed in the following table. Any subnormal (denormalized) value input into a shader or potentially generated by any operation in a shader can be flushed to 0. The rounding mode cannot be set and is undefined but must not affect the result by more than 1 ULP. NaNs are not required to be generated.
L3022: Built-in functions defined in the specification with an equation built from the above operations inherit the above errors. These include, for example, the geometric functions, the common functions, and many of the matrix functions. Built-in functions not listed above and not defined as equations of the above have undefined precision. These include, for example, the trigonometric functions and determinant.
L3023: 
L3024: The precision of double-precision operations is at least that of single precision.
L3048: For this paragraph, “operation” includes operators, built-in functions, and constructors, and “operand” includes function arguments and constructor arguments. The precision qualification associated with any operation is the highest precision qualification of the operands consumed by the operation, if any operand has an associated precision. In cases where no operand has a precision qualifier, the precision qualifications of the operands of the next consuming operation in the expression will be used.
L4182: The variable gl_BaseInstance is a vertex shader input variable that holds the integer value passed to the baseInstance parameter of the command that resulted in the current shader invocation (see “Shader Inputs” in section 11.1.3.9 of the 【82†OpenGL Specification】).
L4291: gl_Layer is used to select a specific layer (or face and layer of a cube map) of a multi-layer framebuffer attachment. The actual layer used will come from one of the vertices in the primitive being shaded. Which vertex the layer comes from is determined as discussed in section 11.3.4.6 “Layer and Viewport Selection” of the 【82†OpenGL Specification】 but may be undefined, so it is best to write the same layer value for all vertices of a primitive.
L4292: If a shader statically assigns a value to gl_Layer, layered rendering mode is enabled. See section 11.3.4.5 “Geometry Shader Outputs” and section 9.4.9 “Layered Framebuffers” of the 【82†OpenGL Specification】 for more information. If a shader statically assigns a value to gl_Layer, and there is an execution path through the shader that does not set gl_Layer, then the value of gl_Layer is undefined for executions of the shader that take that path.
L4293: The output variable gl_Layer takes on a special value when used with an array of cube map textures. Instead of only referring to the layer, it is used to select a cube map face and a layer. Setting gl_Layer to the value layer*6+face will render to face face of the cube defined in layer layer. The face values are defined in table 9.3 of section 9.4.9 “Layered Fram…[truncated]</excerpt>
</source>
<source kind="search">
<title>VkPhysicalDeviceLimits(3) :: Vulkan Documentation Project</title>
<location>https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceLimits.html</location>
<excerpt>citeturn398895search0 [wordlim: 200] Crawled: 3 weeks ago; # VkPhysicalDeviceLimits(3) ...     `// Provided by VK_VERSION_1_0 ...         uint32_t              mipmapPrecisionBits;
Sub-texel values calculated during image sampling will snap to these locations when generating the filtered results.

  * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions.

  * `maxDrawIndexedIndexValue` is the maximum index value that can be used for indexed draw calls when using 32-bit indices. This excludes the primitive restart index value of 0xFFFFFFFF. See `fullDrawIndexUint32`.

  * `maxDrawIndirectCount` is the maximum draw count that is supported for indirect drawing calls. See `multiDrawIndirect`.

  * `maxSamplerLodBias` is the maximum absolute sampler LOD bias. The sum of the `mipLodBias` member of the VkSamplerCreateInfo structure and the `Bias` operand of image sampling operations in shader modules (or 0 if no `Bias` operand is provided to an image sampling operation) is clamped to the range [-`maxSamplerLodBias`,+`maxSamplerLodBias`]. See samplers-mipLodBias.

  * `maxSamplerAnisotropy` is the maximum degree of sampler anisotropy. The maximum degree of anisotropic filtering used for an image sampling operation is the minimum of the `maxAnisotropy` member of the VkSamplerCreateInfo structure and this limit. See samplers-maxAnisotropy.

</excerpt>
</source>
<source kind="search">
<title>SPIR-V Specification</title>
<location>https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html</location>
<excerpt>citeturn398895search1 [wordlim: 200] Published: last month; Crawled: last month; Note  | Up-to-date HTML and PDF versions of this specification may be found at the Khronos SPIR-V Registry. (https://www.khronos.org/registry/spir-v/) ... The full set of rules needed to consume SPIR-V in a particular environment comes from the combination of SPIR-V and that environment’s client API specification. ... For debugging portability of floating-point operations, OpQuantizeToF16 may be used to explicitly reduce the precision of a relaxed-precision result to 16-bit precision. ... OpImageQueryLod

### 2.14. Relaxed Precision

The RelaxedPrecision Decoration allows 32-bit integer and 32-bit floating-point operations to execute with a relaxed precision of somewhere between 16 and 32 bits.

For a floating-point operation, operating at relaxed precision means that the minimum requirements for range and precision are as follows:

  * the floating point range may be as small as (-2^{14}, 2^{14})

  * the floating point magnitude range includes 0.0 and [2^{-14}, 2^{14})

  * the relative floating point precision may be as small as 2^{-10}

The range notation here means the largest required magnitude is half of the relative precision less than the value given.

Relative floating-point precision is defined as the worst case (i.e. largest) ratio of the smallest step in relation to the value for all non-zero values in the required range:

Precision_{relative} = (abs(v_{1} - v_{2})_{min} / abs(v_{1}))_{max} for v_{1} ≠ 0, v_{2} ≠ 0, v_{1} ≠ v_{2}

It is therefore twice the maximum rounding error when converting from a real number. Subnormal numbers may be supported and may have lower relative precision.

For integer operations, operating at relaxed precision means that the operation is evaluated by an operation in which, for some N, 16 ≤ N ≤ 32:

  * the operation is executed as though its type were N bits in size, and

  * the result is zero or sign extended to 32 bits as determined by the signedness of the result type of the operation.

The RelaxedPrecision Decoration must only be applied to:

  * The &lt;id&gt; of an OpVariable, where it refers to the value of the variable.

  * The &lt;id&gt; of an OpFunctionParameter, where it refers to the value of the parameter.

  * The Result &lt;id&gt; of an instruction that reads or filters from an image. E.g. OpImageSampleExplicitLod, meaning the instruction is to operate at relaxed precision.

  * The Result &lt;id&gt; of an OpFunction, where it refers to the value returned by the function.

  * A structure-type member (through OpMemberDecorate).

  * The Result &lt;id&gt; of an OpFunctionCall, where it refers to the result of the function call.

  * The Result &lt;id&gt; of other instructions that operate on or produce numerical types, meaning the instruction is to operate at relaxed precision. The instruction’s operands may also be truncated to the relaxed precision.

In all cases, the types of the values that the RelaxedPrecision Decoration refers to must be:

  * a scalar, vector, or matrix, or array of scalars, vectors, or matrices, and all the components in the types must be a 32-bit numerical type,

  * a pointer to such a type, where it refers to the value pointed to.

The values that the RelaxedPrecision Decoration refers to can be truncated to relaxed precision.

When applied to a variable, function parameter, or structure member, all loads and stores from the decorated object may be treated as though they were decorated with RelaxedPrecision. Loads may also be decorated with RelaxedPrecision, in which case they are treated as operating at relaxed precision.

All loads and stores involving relaxed precision still read and write 32 bits of data, respectively. Floating-point data read or written in such a manner is written in full 32-bit floating-point format. However, a load or store might reduce the precision (as allowed by RelaxedPrecision) of the destination value.

For debugging portability of floating-point operations, OpQuantizeToF16 may be used to explicitly reduce the precision of a relaxed-precision result to 16-bit precision. (Integer-result precision can be reduced, for example, using left- and right-shift opcodes.)

For image-sampling operations, decorations can appear on both the sampling instruction and the image variable being sampled. If either is decorated, they both should be decorated, and if both are decorated their decorations must match. If only one is decorated, the sampling instruction can behave either as if both were decorated or neither were decorated.

Each gathered texel is identified by adding one of these array elements to the (u, v) sampled location. It is invalid for these to be outside a target-dependent allowed range. Only valid with OpImageGather, OpImageDrefGather, OpImageSparseGather, or OpImageSparseDrefGather. Not valid with the Cube dimension. An instruction must specify at most one of the ConstOffset, Offset, and ConstOffsets image operands.  | ImageGatherExtended
0x40  | Sample
A following operand is the sample number of the sample to use. Only valid with OpImageFetch, OpImageRead, OpImageWrite, OpImageSparseFetch, and OpImageSparseRead. The Sample operand must be used if and only if the underlying OpTypeImage has MS of 1. It must be a 32-bit integer type scalar.  | 
0x80  | MinLod
A following operand is the minimum level-of-detail to use when accessing the image. Only valid with Implicit instructions and Grad instructions. It must be a 32-bit floating-point type scalar using the IEEE 754 encoding. This must only be used with an OpTypeImage that has a Dim operand of 1D, 2D, 3D, or Cube, and the MS operand must be 0.  | MinLod
0x100  | MakeTexelAvailable (MakeTexelAvailableKHR)
Perform an availability operation on the texel locations after the store. A following operand is the memory scope that controls the availability operation. Requires NonPrivateTexel to also be set. Only valid with OpImageWrite.  | VulkanMemoryModel Missing before version 1.5. Also see extension: SPV_KHR_vulkan_memory_model
0x200  | MakeTexelVisible (MakeTexelVisibleKHR)
Perform a visibility operation on the texel locations before the load. A following operand is the memory scope that controls the visibility operation. Requires NonPrivateTexel to also be set. Only valid with OpImageRead and OpImageSparseRead.  | VulkanMemoryModel Missing before version 1.5. Also see extension: SPV_KHR_vulkan_memory_model
0x400  | NonPrivateTexel (NonPrivateTexelKHR)
The image access obeys inter-thread ordering, as specified by the client API.  | VulkanMemoryModel Missing before version 1.5. Also see extension: SPV_KHR_vulkan_memory_model
0x800  | VolatileTexel (VolatileTexelKHR)
This access cannot be eliminated, duplicated, or combined with other accesses.  | VulkanMemoryModel Missing before version 1.5. Also see extension: SPV_KHR_vulkan_memory_model
0x1000  | SignExtend
The texel value is converted to the target value via sign extension. Only valid if the texel value type is a scalar or vector of integer type:

4  | 100  | &lt;id&gt;
Result Type  | Result &lt;id&gt;  | &lt;id&gt;
Sampled Image
OpImageQueryFormat
Query the image format of an image created with an Unknown Image Format. Result Type must be a scalar integer type. The resulting value is an enumerant from Image Channel Data Type. Image must be an object whose type is OpTypeImage.  | Capability:
Kernel
4  | 101  | &lt;id&gt;
Result Type  | Result &lt;id&gt;  | &lt;id&gt;
Image
OpImageQueryOrder
Query the channel order of an image created with an Unknown Image Format. Result Type must be a scalar integer type. The resulting value is an enumerant from Image Channel Order. Image must be an object whose type is OpTypeImage.  | Capability:
Kernel
4  | 102  | &lt;id&gt;
Result Type  | Result &lt;id&gt;  | &lt;id&gt;
Image
OpImageQuerySizeLod
Query the dimensions of Image for mipmap level for Level of Detail. Result Type must be an integer type scalar or vector. The number of components must be
1 for the 1D dimensionality,
2 for the 2D and Cube dimensionalities,
3 for the 3D dimensionality,
plus 1 more if the image type is arrayed. This vector is filled in with (width [, height] [, depth] [, elements]) where elements is the number of layers in an image array, or the number of cubes in a cube-map array. Image must be an object whose type is OpTypeImage. Its Dim operand must be one of 1D, 2D, 3D, or Cube, and its MS must be 0. See OpImageQuerySize for querying image types without level of detail. See the client API specification for additional image type restrictions. Level of Detail is used to compute which mipmap level to query and must be a 32-bit integer type scalar.  | Capability:
Kernel, ImageQuery
5  | 103  | &lt;id&gt;
Result Type  | Result &lt;id&gt;  | &lt;id&gt;
Image  | &lt;id&gt;
Level of Detail
OpImageQuerySize
Query the dimensions of Image, with no level of detail. Result Type must be an integer type scalar or vector. The number of components must be:
1 for the 1D and Buffer dimensionalities,
2 for the 2D, Cube, and Rect dimensionalities,
3 for the 3D dimensionality,
plus 1 more if the image type is arrayed. This vector is filled in with (width [, height] [, elements]) where elements is the number of layers in an image array or the number of cubes in a cube-map array. Image must be an object whose type is OpTypeImage. Its Dim operand must be one of those listed under Result Type, above. Additionally, if its Dim is 1D, 2D, 3D, or Cube, it must also have either an MS of 1 or a Sampled of 0 or 2. There is no implicit level-of-detail consumed by this instruction. See OpImageQuerySizeLod for querying images having level of detail. See the client API specification for additional image type restrictions.  | Capability:
Kernel, ImageQuery
4  | 104  | &lt;id&gt;
Result Type  | Result &lt;id&gt;  | &lt;id&gt;
Image
OpImageQueryLod
Query the mipmap level and the level of detail for a hypothetical sampling of Image at Coordinate using an implicit level of detail. </excerpt>
</source>
<source kind="search">
<title>Vulkan Specification :: Vulkan Documentation Project</title>
<location>https://docs.vulkan.org/guide/latest/vulkan_spec.html</location>
<excerpt>citeturn398895search6 [wordlim: 200] Crawled: 5 days ago; For Vulkan 1.0 to 1.3, there was a dedicated version of the spec. ... The Vulkan SDK also comes with a PDF version (https://vulkan.lunarg.com/doc/sdk/1.4.341.1/windows/1.4-extensions/vkspec.pdf)
</excerpt>
</source>
<omitted_sources count="61">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceLimits.html?utm_source=openai
- 2: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html
- 3: https://docs.vulkan.org/guide/latest/vulkan_spec.html?utm_source=openai

Script executed:

printf '%s\n' '--- complete pre-existing ImageSampleAndGather ---'
sed -n '39640,39735p' tests/ShaderRecompilerComputeTests.cpp

printf '%s\n' '--- helper call sites and opcode definitions ---'
rg -n -F -e 'ImageGetLodComputeLaneQuads' -e 'EncodeMimg0' -e 'IMAGE_GET_LOD' tests/ShaderRecompilerComputeTests.cpp src/graphics/shader/recompiler
rg -n -F -- '0x60' src/graphics/shader/recompiler tests/ShaderRecompilerComputeTests.cpp | head -80

printf '%s\n' '--- relevant Vulkan limit declarations and local device-property plumbing ---'
rg -n -F -e 'PhysicalDeviceProperties' -e 'physical_device_properties' -e 'getProperties' tests/ShaderRecompilerComputeTests.cpp | head -120

Repository: KytyPS5/KytyPS5

Length of output: 23878


Script executed:

printf '%s\n' '--- IMAGE_GET_LOD translation ---'
sed -n '630,690p' src/graphics/shader/recompiler/frontend/translate/Memory.cpp
rg -n -F -e 'OpImageQueryLod' -e 'ImageQueryLod' -e 'IMAGE_GET_LOD' src/graphics/shader/recompiler/backend src/graphics/shader/recompiler/frontend

printf '%s\n' '--- relevant coordinate and opcode definitions ---'
sed -n '270,315p' src/graphics/shader/recompiler/frontend/decode/ImageOps.cpp
sed -n '680,715p' tests/ShaderRecompilerComputeTests.cpp
sed -n '39734,39764p' tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 8434


Web query:

Vulkan specification texture sampling mipmapPrecisionBits exact wording LOD calculation mipmap level contribution OpImageQueryLod

Result:

<source_evidence>
<source kind="open_page">
<title>Limits :: Vulkan Documentation Project</title>
<location>https://docs.vulkan.org/spec/latest/chapters/limits.html</location>
<excerpt>citeturn930442view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;turn211466search0&quot;,&quot;lineno&quot;:null}); Total lines: 5513
L154:   * `maxStorageBufferRange` is the maximum value that can be specified in the `range` member of a 【17†VkDescriptorBufferInfo】 structure passed to 【18†vkUpdateDescriptorSets】 for descriptors of type 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】. If the 【20†`shader64BitIndexing`】 feature is enabled, this limit does not apply.
L155:   * `maxPushConstantsSize` is the maximum size, in bytes, of the pool of push constant memory. For each of the push constant ranges indicated by the `pPushConstantRanges` member of the 【21†VkPipelineLayoutCreateInfo】 structure, (`offset` + `size`) must be less than or equal to this limit.
L156: 
L157:   * `maxMemoryAllocationCount` is the maximum number of device memory allocations, as created by 【22†vkAllocateMemory】, which can simultaneously exist.
L158:   * `maxSamplerAllocationCount` is the maximum number of sampler objects, as created by 【23†vkCreateSampler】, which can simultaneously exist on a device. If the 【24†`descriptorHeap`】 feature is enabled and the application intends to use embedded samplers, the number advertised here is effectively reduced by the quotient of 【25†`minSamplerHeapReservedRangeWithEmbedded`】 divided by 【26†`samplerDescriptorSize`】, to provide storage for embedded samplers when switching to heaps.
L163:   * `maxBoundDescriptorSets` is the maximum number of descriptor sets that can be simultaneously used by a pipeline. See 【34†Descriptor Sets】.
L164:   * `maxPerStageDescriptorSamplers` is the maximum number of samplers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_SAMPLER】 or 【19†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L166:   * `maxPerStageDescriptorUniformBuffers` is the maximum number of uniform buffers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L168:   * `maxPerStageDescriptorStorageBuffers` is the maximum number of storage buffers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L170:   * `maxPerStageDescriptorSampledImages` is the maximum number of sampled images that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】, 【19†VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE】, or 【19†VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L172:   * `maxPerStageDescriptorStorageImages` is the maximum number of storage images that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_IMAGE】, or 【19†VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L174:   * `maxPerStageDescriptorInputAttachments` is the maximum number of input attachments that can be accessible to a single shader stage in a pipeline layout, as well as the maximum usable input attachment index. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L181:   * `maxDescriptorSetSamplers` is the maximum number of samplers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_SAMPLER】 or 【19†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【36†Sampler】 and 【37†Combined Image Sampler】.
L182:   * `maxDescriptorSetUniformBuffers` is the maximum number of uniform buffers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【38†Uniform Buffer】 and 【39†Dynamic Uniform Buffer】.
L183:   * `maxDescriptorSetUniformBuffersDynamic` is the maximum number of dynamic uniform buffers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【39†Dynamic Uniform Buffer】.
L184:   * `maxDescriptorSetStorageBuffers` is the maximum number of storage buffers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【40†Storage Buffer】 and 【41†Dynamic Storage Buffer】.
L185:   * `maxDescriptorSetStorageBuffersDynamic` is the maximum number of dynamic storage buffers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【41†Dynamic Storage Buffer】.
L186:   * `maxDescriptorSetSampledImages` is the maximum number of sampled images that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】, 【19†VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE】, or 【19†VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L187: See 【37†Combined Image Sampler】, 【42†Sampled Image】, and 【43†Uniform Texel Buffer】.
L188:   * `maxDescriptorSetStorageImages` is the maximum number of storage images that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_IMAGE】, or 【19†VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【44†Storage Image】, and 【45†Storage Texel Buffer】.
L189:   * `maxDescriptorSetInputAttachments` is the maximum number of input attachments that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【46†Input Attachment】.
L190:   * `maxVertexInputAttributes` is the maximum number of vertex input attributes that can be specified for a graphics pipeline. These are described in the array of `VkVertexInputAttributeDescription` structures that are provided at graphics pipeline creation time via the `pVertexAttributeDescriptions` member of the 【48†VkPipelineVertexInputStateCreateInfo】 structure. See 【49†Vertex Attributes】 and 【50†Vertex Input Description】.
L191:   * `maxVertexInputBindings` is the maximum number of vertex buffers that can be specified for providing vertex attributes to a graphics pipeline. These are described in the array of `VkVertexInputBindingDescription` structures that are provided at graphics pipeline creation time via the `pVertexBindingDescriptions` member of the 【48†VkPipelineVertexInputStateCreateInfo】 structure. The `binding` member of `VkVertexInputBindingDescription` must be less than this limit. See 【50†Vertex Input Description】.
L192:   * `maxVertexInputAttributeOffset` is the maximum vertex input attribute offset that can be added to the vertex input binding stride. The `offset` member of the `VkVertexInputAttributeDescription` structure must be less than or equal to this limit. See 【50†Vertex Input Description】.
L193:   * `maxVertexInputBindingStride` is the maximum vertex input binding stride that can be specified in a vertex input binding. The `stride` member of the `VkVertexInputBindingDescription` structure must be less than or equal to this limit. See 【50†Vertex Input Description】.
L194: 
L195:   * `maxVertexOutputComponents` is the maximum number of components of output variables which can be output by a vertex shader. See 【51†Vertex Shaders】.
L196:   * `maxTessellationGenerationLevel` is the maximum tessellation generation level supported by the fixed-function tessellation primitive generator. See 【52†Tessellation】.
L197:   * `maxTessellationPatchSize` is the maximum patch size, in vertices, of patches that can be processed by the tessellation control shader and tessellation primitive generator. The `patchControlPoints` member of the 【53†VkPipelineTessellationStateCreateInfo】 structure specified at pipeline creation time and the value provided in the `OutputVertices` execution mode of shader modules must be less than or equal to this limit. See 【52†Tessellation】.
L198:   * `maxTessellationControlPerVertexInputComponents` is the maximum number of components of input variables which can be provided as per-vertex inputs to the tessellation control shader stage.
L199: 
L200:   * `maxTessellationControlPerVertexOutputComponents` is the maximum number of components of per-vertex output variables which can be output from the tessellation control shader stage.
L201:   * `maxTessellationControlPerPatchOutputComponents` is the maximum number of components of per-patch output variables which can be output from the tessellation control shader stage.
L202: 
L203:   * `maxTessellationControlTotalOutputComponents` is the maximum total number of components of per-vertex and per-patch output variables which can be output from the tessellation control shader stage.
L204:   * `maxTessellationEvaluationInputComponents` is the maximum number of components of input variables which can be provided as per-vertex inputs to the tessellation evaluation shader stage.
L205: 
L206:   * `maxTessellationEvaluationOutputComponents` is the maximum number of components of per-vertex output variables which can be output from the tessellation evaluation shader stage.
L207:   * `maxGeometryShaderInvocations` is the maximum invocation count supported for instanced geometry shaders. The value provided in the `Invocations` execution mode of shader modules must be less than or equal to this limit. See 【54†Geometry Shading】.
L208: 
L209:   * `maxGeometryInputComponents` is the maximum number of components of input variables which can be provided as inputs to the geometry shader stage.
L210:   * `maxGeometryOutputComponents` is the maximum number of components of output variables which can be output from the geometry shader stage.
L211: 
L212:   * `maxGeometryOutputVertices` is the maximum number of vertices which can be emitted by any geometry shader.
L213: 
L214:   * `maxGeometryTotalOutputComponents` is the maximum total number of components of output variables, across all emitted vertices, which can be output from the geometry shader stage.
L215:   * `maxFragmentInputComponents` is the maximum number of components of input variables which can be provided as inputs to the fragment shader stage.
L216: 
L217:   * `maxFragmentOutputAttachments` is the maximum number of output attachments which can be written to by the fragment shader stage.
L218:   * `maxFragmentDualSrcAttachments` is the maximum number of output attachments which can be written to by the fragment shader stage when blending is enabled and one of the dual source blend modes is in use. See 【55†Dual-Source Blending】 and 【56†`dualSrcBlend`】.
L219: 
L220:   * `maxFragmentCombinedOutputResources` is the total number of storage buffers, storage images, and output `Location` decorated color attachments (described in 【57†Fragment Output Interface】) which can be used in the fragment shader stage.
L221:   * `maxComputeSharedMemorySize` is the maximum total storage size, in bytes, available for variables declared with the `Workgroup` storage class in shader modules (or with the `shared` storage qualifier in GLSL) in the c…[truncated]</excerpt>
</source>
<source kind="search">
<title>Limits :: Vulkan Documentation Project</title>
<location>https://docs.vulkan.org/spec/latest/chapters/limits.html</location>
<excerpt>citeturn211466search0 [wordlim: 200] Crawled: 5 days ago;   * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions.

  * `maxDrawIndexedIndexValue` is the maximum index value that can be used for indexed draw calls when using 32-bit indices.
Sub-texel values calculated during image sampling will snap to these locations when generating the filtered results.

  * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions.

  * `maxDrawIndexedIndexValue` is the maximum index value that can be used for indexed draw calls when using 32-bit indices. This excludes the primitive restart index value of 0xFFFFFFFF. See `fullDrawIndexUint32`.

  * `maxDrawIndirectCount` is the maximum draw count that is supported for indirect drawing calls. See `multiDrawIndirect`.

  * `maxSamplerLodBias` is the maximum absolute sampler LOD bias. The sum of the `mipLodBias` member of the VkSamplerCreateInfo structure and the `Bias` operand of image sampling operations in shader modules (or 0 if no `Bias` operand is provided to an image sampling operation) is clamped to the range [-`maxSamplerLodBias`,+`maxSamplerLodBias`]. </excerpt>
</source>
<source kind="search">
<title>Sampling :: Vulkan Documentation Project</title>
<location>https://docs.vulkan.org/spec/latest/chapters/textures.html</location>
<excerpt>citeturn211466search1 [wordlim: 200] Crawled: 5 days ago; The LOD must be computed with `mipmapPrecisionBits` of accuracy. ... If the used sampler was created without VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT, `Cube` images ignore the wrap modes specified in the sampler.

## Normalized Texel Coordinate Operations

If the image sampler instruction provides normalized texel coordinates, some of the following operations are performed.

### Projection Operation

For `Proj` image operations, the normalized texel coordinates (s,t,r,q,a) and (if present) the D_{ref} coordinate are transformed as follows:

### Derivative Image Operations

Derivatives are used for LOD selection. These derivatives are either implicit (in an `ImplicitLod` image instruction in a mesh, task, compute, or fragment shader) or explicit (provided explicitly by shader to the image instruction in any shader).

For implicit derivatives image instructions, the derivatives of texel coordinates are calculated in the same manner as derivative operations. That is:

Partial derivatives not defined above for certain image dimensionalities are set to zero.

For explicit LOD image instructions, if the optional SPIR-V operand `Grad` is provided, then the operand values are used for the derivatives. The number of components present in each derivative for a given image dimensionality matches the number of partial derivatives computed above.

If the optional SPIR-V operand `Lod` is provided, then derivatives are set to zero, the cube map derivative transformation is skipped, and the scale factor operation is skipped. Instead, the floating-point scalar coordinate is directly assigned to λ_{base} as described in LOD Operation.

If the image or sampler object used by an implicit derivative image instruction is not uniform across the quad and `quadDivergentImplicitLod` is not supported, then the derivative and LOD values are undefined. Implicit derivatives are well-defined when the image and sampler and control flow are uniform across the quad, even if they diverge between different quads.

If `quadDivergentImplicitLod` is supported, then derivatives and implicit LOD values are well-defined even if the image or sampler object are not uniform within a quad. The derivatives are computed as specified above, and the implicit LOD calculation proceeds for each shader invocation using its respective image and sampler object.

### Cube Map Face Selection and Transformations

For cube map image instructions, the (s,t,r) coordinates are treated as a direction vector (r_{x},r_{y},r_{z}). The direction vector is used to select a cube map face. The direction vector is transformed to a per-face texel coordinate system (s_{face},t_{face}). The direction vector is also used to transform the derivatives to per-face derivatives.

### Cube Map Coordinate Transformation

### Cube Map Derivative Transformation

The partial derivatives of the Cube Map Coordinate Transformations can be computed as:

The other derivatives are simplified similarly, resulting in

### Scale Factor Operation, LOD Operation and Image Level(s) Selection

LOD selection can be either explicit (provided explicitly by the image instruction) or implicit (determined from a scale factor calculated from the derivatives). The LOD must be computed with `mipmapPrecisionBits` of accuracy.

#### Scale Factor Operation

The magnitude of the derivatives are calculated by:

    

m_{ux} = |∂s/∂x| × w_{base}

    

m_{vx} = |∂t/∂x| × h_{base}

    

m_{wx} = |∂r/∂x| × d_{base}
    

m_{uy} = |∂s/∂y| × w_{base}

    

m_{vy} = |∂t/∂y| × h_{base}

    

m_{wy} = |∂r/∂y| × d_{base}

where:

    

∂t/∂x = ∂t/∂y = 0 (for 1D images)

    

∂r/∂x = ∂r/∂y = 0 (for 1D, 2D, or Cube images)

and:

    

w_{base} = image.w

    

h_{base} = image.h

    

d_{base} = image.d

(for the `baseMipLevel`, from the image descriptor).

For corner-sampled images, the w_{base}, h_{base}, and d_{base} are instead:

    

w_{base} = image.w - 1

    

h_{base} = image.h - 1

    

d_{base} = image.d - 1

A point sampled in screen space has an elliptical footprint in texture space. The minimum and maximum scale factors (ρ_{min}, ρ_{max}) should be the minor and major axes of this ellipse.

The scale factors ρ_{x} and ρ_{y}, calculated from the magnitude of the derivatives in x and y, are used to compute the minimum and maximum scale factors.

ρ_{x} and ρ_{y} may be approximated with functions f_{x} and f_{y}, subject to the following constraints:

The minimum and maximum scale factors (ρ_{min},ρ_{max}) are determined by:

    

ρ_{max} = max(ρ_{x}, ρ_{y})

    

ρ_{min} = min(ρ_{x}, ρ_{y})

The ratio of anisotropy is determined by:

    

η = min(ρ_{max}/ρ_{min}, max_{Aniso})

where:

    

sampler.max_{Aniso} = `maxAnisotropy` (from sampler descriptor)
## Integer Texel Coordinate Operations

Integer texel coordinate operations may supply a LOD which texels are to be read from or written to using the optional SPIR-V operand `Lod`. If the `Lod` is provided then it must be an integer.

The image level selected is:

If d does not lie in the range [`baseMipLevel`, `baseMipLevel` + `levelCount`) or d is less than minLodInteger_{imageView}, then any values fetched are zero if the `robustImageAccess2` feature is enabled, otherwise are undefined, and any writes (if supported) are discarded.

## Image Sample Operations

### Wrapping Operation

If the used sampler was created without VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT, `Cube` images ignore the wrap modes specified in the sampler. Instead, if VK_FILTER_NEAREST is used within a mip level then VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE is used, and if VK_FILTER_LINEAR is used within a mip level then sampling at the edges is performed as described earlier in the Cube map edge handling section.

The first integer texel coordinate i is transformed based on the `addressModeU` parameter of the sampler.

where:

j (for 2D and Cube image) and k (for 3D image) are similarly transformed based on the `addressModeV` and `addressModeW` parameters of the sampler, respectively.

### Texel Gathering

SPIR-V instructions with `Gather` in the name return a vector derived from 4 texels in the base level of the image view.

The rules for the VK_FILTER_LINEAR minification filter are applied to identify the four selected texels for `OpImage*Gather` , and `OpImageGatherQCOM` with modes `GatherH2QCOM` and `GatherV2QCOM` .

If an `OpImage*Gather` operation does not use the `ConstOffsets` image operand then the four texels form the 2 × 2 rectangle used for texture filtering:

If an `OpImage*Gather` operation uses the `ConstOffsets` image operand then the offsets allow a custom filter to be defined:

If an `OpImageGatherQCOM` operation has a `Mode` equal to `GatherH2QCOM` or `GatherV2QCOM`, then it uses a predefined set of `ConstOffsets`.

The offsets used for `GatherH2QCOM` are:

The offsets used for `GatherV2QCOM` are:

The rules for the VK_FILTER_NEAREST minification filter are applied to identify the origin texel \tau_{{ij}} for `OpImageGatherQCOM` with modes equal to `Gather4x1QCOM` and `GatherDQCOM`. The filter used for these modes is defined as:

The offsets used for `Gather4x1QCOM` are:

The offsets used for `GatherDQCOM` are:

where:

Each texel is then converted to an RGBA value according to component substitution and then swizzled.

`OpImage*Gather` and `OpImageGatherQCOM` must not be used on a sampled image with sampler Y′C_{B}C_{R} conversion enabled.

If level_{base} &lt; minLodInteger_{imageView}, then any values fetched are zero if the `robustImageAccess2` feature is enabled. Otherwise values are undefined.

#### Texel Range Clamp

When `reductionMode` is VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_RANGECLAMP_QCOM, the weighted average is clamped to be within the component-wise minimum and maximum of the set of texels with non-zero weights.

#### Texel Mipmap Filtering

VK_SAMPLER_MIPMAP_MODE_NEAREST filtering returns the value of a single mipmap level,

τ = τ[d].

VK_SAMPLER_MIPMAP_MODE_LINEAR filtering combines the values of multiple mipmap levels (τ[hi] and τ[lo]), together with their linear weights.

The linear weights are derived from the fraction computed earlier:

The values of multiple mipmap levels, together with their weights, are combined to produce a final filtered value.

The VkSamplerReductionModeCreateInfo::`reductionMode` can control the process by which multiple texels, together with their weights, are combined to produce a filtered texture value.

When the `reductionMode` is set (explicitly or implicitly) to VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE, a weighted average is computed:
## Texel Footprint Evaluation

The SPIR-V instruction `OpImageSampleFootprintNV` evaluates the set of texels from a single mip level that would be accessed during a texel filtering operation. In addition to the inputs that would be accepted by an equivalent `OpImageSample*` instruction, `OpImageSampleFootprintNV` accepts two additional inputs. The `Granularity` input is an integer identifying the size of texel groups used to evaluate the footprint. Each bit in the returned footprint mask corresponds to an aligned block of texels whose size is given by the following table:

Table 5. Texel Footprint Granularity Values
`Granularity`  | `Dim` = 2D  | `Dim` = 3D
--- | --- | ---
0  | unsupported  | unsupported
1  | 2x2  | 2x2x2
2  | 4x2  | unsupported
3  | 4x4  | 4x4x2
4  | 8x4  | unsupported
5  | 8x8  | unsupported
6  | 16x8  | unsupported
7  | 16x16  | unsupported
8  | unsupported  | unsupported
9  | unsupported  | unsupported
10  | unsupported  | 16x16x16
11  | 64x64  | 32x16x16
12  | 128x64  | 32x32x16
13  | 128x128  | 32x32x32
14  | 256x128  | 64x32x32
15  | 256x256  | unsupported

The `Coarse` input is used to select between the two mip levels that may be accessed during texel filtering when using a `mipmapMode` of VK_SAMPLER_MIPMAP_MODE_LINEAR. When filtering between two mip levels, a `Coarse` value of `true` requests the footprint in the lower-resolution mip level (higher level number), while `false` requests the footprint in the higher-resolution mip level. If texel filtering would access only a single mip level, the footprint in that level would be returned when `Coarse` is `false`; an empty footprint would be returned when `Coarse` is `true`.

The footprint for `OpImageSampleFootprintNV` is returned in a structure with six members:

  * The first member is a boolean value that is true if the texel filtering operation would access only a single mip level.

  * The second member is a two- or three-component integer vector holding the footprint anchor location. For two-dimensional images, the returned components are in units of eight texel groups. </excerpt>
</source>
<source kind="search">
<title>Vulkan® 1.4.351 - A Specification (with all ratified extensions)</title>
<location>https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf</location>
<excerpt>citeturn211466search13 [wordlim: 200] Published: 5 months ago; OpImageQueryLod returns the LOD parameters that would be used in a sampling instruction with the given image and coordinates.
- Array Layer Selection: Performed by all OpImageSample, OpImageSparseSample, and OpImage*Gather instructions.
- Texel Gathering: Performed by OpImage*Gather instructions.
- Texel Filtering: Performed by all OpImageSample* and OpImageSparseSample* instructions.
- Sparse Residency: Performed by all OpImageSparse* instructions.

## 20.8. LOD Query

OpImageQueryLod returns the LOD parameters that would be used in a sampling instruction with the given image and coordinates. If the descriptor that would be accessed is a null descriptor then (0,0) is returned. Otherwise, the steps described in this chapter are performed as if for OpImageSampleImplicitLod, up to Scale Factor Operation, LOD Operation and Image Level(s) Selection. The return value is the vector (λ′, d_l - level_base). These values may be subject to implementation-specific maxima and minima for very large, out-of-range values.</excerpt>
</source>
<source kind="search">
<title>Vulkan® 1.4.349 - A Specification (with all registered extensions)</title>
<location>https://registry.khronos.org/vulkan/specs/latest/pdf/vkspec.pdf</location>
<excerpt>citeturn211466search12 [wordlim: 200] Published: 6 months ago; - Derivative Image Operations, Cube Map Operations, Scale Factor Operation, LOD Operation and Image Level(s) Selection, and Texel Anisotropic Filtering: Performed by all `OpImageSample*` and `OpImageSparseSample*` instructions. ... `OpImageQueryLod` returns the LOD parameters that would be used in a sampling instruction with the given image and coordinates.
- Texel Gathering: Performed by `OpImage*Gather` instructions.
- Texel Footprint Evaluation: Performed by `OpImageSampleFootprint` instructions.
- Texel Filtering: Performed by all `OpImageSample*` and `OpImageSparseSample*` instructions.
- Sparse Residency: Performed by all `OpImageSparse*` instructions.
- `(s,t,r,q,a)` to `(u,v,w,a)` Transformation, Wrapping, and Weight Image Sampling: Performed by `OpImageWeightedSample*` instructions.
- `(s,t,r,q,a)` to `(u,v,w,a)` Transformation, Wrapping, and Block Matching: Performed by `OpImageBlockMatch*` instructions.
- `(s,t,r,q,a)` to `(u,v,w,a)` Transformation, Wrapping, and Box Filter Sampling: Performed by `OpImageBoxFilter*` instructions.

## 20.12. LOD Query

`OpImageQueryLod` returns the LOD parameters that would be used in a sampling instruction with the given image and coordinates. If the descriptor that would be accessed is a null descriptor then `(0,0)` is returned. Otherwise, the steps described in this chapter are performed as if for `OpImageSampleImplicitLod`, up to Scale Factor Operation, LOD Operation and Image Level(s) Selection. The return value is the vector `(λ&#39;, d_l - level_base)`. These values may be subject to implementation-specific maxima and minima for very large, out-of-range values.

If the image is a weight image, the value returned by `OpImageQueryLod` is undefined.</excerpt>
</source>
<omitted_sources count="18">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://docs.vulkan.org/spec/latest/chapters/limits.html
- 2: https://docs.vulkan.org/spec/latest/chapters/textures.html?utm_source=openai
- 3: https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf?utm_source=openai

Web query:

Vulkan texture specification "LOD must be computed with mipmapPrecisionBits of accuracy" LOD Operation rounding exact integer lambda

Result:

<source_evidence>
<source kind="open_page">
<title>VkPhysicalDeviceLimits(3)</title>
<location>https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPhysicalDeviceLimits.html</location>
<excerpt>citeturn226468view2 [wordlim: 200] Crawled: 3 days ago; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;turn215248search6&quot;,&quot;lineno&quot;:null}); Total lines: 301
L125:   * `maxImageDimensionCube` is the largest dimension (`width` or `height`) that is guaranteed to be supported for all images created with an `imageType` of 【2†VK_IMAGE_TYPE_2D】 and with 【4†VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT】 set in `flags`. Some combinations of image parameters (format, usage, etc.) may allow support for larger dimensions, which can be queried using 【3†vkGetPhysicalDeviceImageFormatProperties】.
L126: 
L127:   * `maxImageArrayLayers` is the maximum number of layers (`arrayLayers`) for an image.
L128:   * `maxTexelBufferElements` is the maximum number of addressable texels for a buffer view created on a buffer which was created with the 【5†VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT】 or 【5†VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT】 usage flag set.
L129:   * `maxUniformBufferRange` is the maximum value that can be specified in the `range` member of a 【6†VkDescriptorBufferInfo】 structure passed to 【7†vkUpdateDescriptorSets】 for descriptors of type 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】.
L130:   * `maxStorageBufferRange` is the maximum value that can be specified in the `range` member of a 【6†VkDescriptorBufferInfo】 structure passed to 【7†vkUpdateDescriptorSets】 for descriptors of type 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】.
L131:   * `maxPushConstantsSize` is the maximum size, in bytes, of the pool of push constant memory. For each of the push constant ranges indicated by the `pPushConstantRanges` member of the 【9†VkPipelineLayoutCreateInfo】 structure, (`offset` + `size`) must be less than or equal to this limit.
L132: 
L133:   * `maxMemoryAllocationCount` is the maximum number of device memory allocations, as created by 【10†vkAllocateMemory】, which can simultaneously exist.
L134:   * `maxSamplerAllocationCount` is the maximum number of sampler objects, as created by 【11†vkCreateSampler】, which can simultaneously exist on a device.
L135: 
L136:   * `bufferImageGranularity` is the granularity, in bytes, at which buffer or linear image resources, and optimal image resources can be bound to adjacent offsets in the same `VkDeviceMemory` object without aliasing. See 【12†Buffer-Image Granularity】 for more details.
L137:   * `sparseAddressSpaceSize` is the total amount of address space available, in bytes, for sparse memory resources. This is an upper bound on the sum of the sizes of all sparse resources, regardless of whether any memory is bound to them.
L138: 
L139:   * `maxBoundDescriptorSets` is the maximum number of descriptor sets that can be simultaneously used by a pipeline. See 【13†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#descriptors-sets】.
L140:   * `maxPerStageDescriptorSamplers` is the maximum number of samplers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_SAMPLER】 or 【8†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L141: A descriptor is accessible to a shader stage when the `stageFlags` member of the `VkDescriptorSetLayoutBinding` structure has the bit for that shader stage set. See 【15†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#descriptors-sampler】 and 【16†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#descriptors-combinedimagesampler】.
L142:   * `maxPerStageDescriptorUniformBuffers` is the maximum number of uniform buffers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L144:   * `maxPerStageDescriptorStorageBuffers` is the maximum number of storage buffers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L146:   * `maxPerStageDescriptorSampledImages` is the maximum number of sampled images that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】, 【8†VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE】, or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L149:   * `maxPerStageDescriptorStorageImages` is the maximum number of storage images that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_IMAGE】, or 【8†VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L151:   * `maxPerStageDescriptorInputAttachments` is the maximum number of input attachments that can be accessible to a single shader stage in a pipeline layout, as well as the maximum usable input attachment index. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L153: Note  | `maxPerStageDescriptorInputAttachments` was originally only intended to limit the number of attachments per stage, not the number of available input indices across all shaders in a render pass. The input indices were allowed to be semi arbitrary for render pass objects, however some implementations have fixed limits for them. Applications already exist that exceed this limit, and they will continue to work where they already did, but will fail to render on some platforms.
L155:   * `maxPerStageResources` is the maximum number of resources that can be accessible to a single shader stage in a pipeline layout.
L158:   * `maxDescriptorSetSamplers` is the maximum number of samplers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_SAMPLER】 or 【8†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L160:   * `maxDescriptorSetUniformBuffers` is the maximum number of uniform buffers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L162:   * `maxDescriptorSetUniformBuffersDynamic` is the maximum number of dynamic uniform buffers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L164:   * `maxDescriptorSetStorageBuffers` is the maximum number of storage buffers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L166:   * `maxDescriptorSetStorageBuffersDynamic` is the maximum number of dynamic storage buffers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L168:   * `maxDescriptorSetSampledImages` is the maximum number of sampled images that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】, 【8†VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE】, or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L170:   * `maxDescriptorSetStorageImages` is the maximum number of storage images that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_IMAGE】, or 【8†VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit.
L172:   * `maxDescriptorSetInputAttachments` is the maximum number of input attachments that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【25†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#descriptors-inputattachment】.
L173:   * `maxVertexInputAttributes` is the maximum number of vertex input attributes that can be specified for a graphics pipeline. These are described in the array of `VkVertexInputAttributeDescription` structures that are provided at graphics pipeline creation time via the `pVertexAttributeDescriptions` member of the 【26†VkPipelineVertexInputStateCreateInfo】 structure.
L174: See 【27†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-attrib】 and 【28†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-input】.
L175:   * `maxVertexInputBindings` is the maximum number of vertex buffers that can be specified for providing vertex attributes to a graphics pipeline. These are described in the array of `VkVertexInputBindingDescription` structures that are provided at graphics pipeline creation time via the `pVertexBindingDescriptions` member of the 【26†VkPipelineVertexInputStateCreateInfo】 structure. The `binding` member of `VkVertexInputBindingDescription` must be less than this limit.
L176: See 【28†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-input】.
L177:   * `maxVertexInputAttributeOffset` is the maximum vertex input attribute offset that can be added to the vertex input binding stride. The `offset` member of the `VkVertexInputAttributeDescription` structure must be less than or equal to this limit. See 【28†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-input】.
L178:   * `maxVertexInputBindingStride` is the maximum vertex input binding stride that can be specified in a vertex input binding. The `stride` member of the `VkVertexInputBindingDescription` structure must be less than or equal to this limit. See 【28†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-input】.
L179:   * `maxVertexOutputComponents` is the maximum number of components of output variables which can be output by a vertex shader. See 【29†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#shaders-vertex】.
L180: 
L181:   * `maxTessellationGenerationLevel` is the maximum tessellation generation level supported by the fixed-function tessellation primitive generator. See 【30†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#tessellation】.
L182:   * `maxTessellationPatchSize` is the maximum patch size, in vertices, of patches that can be processed by the tessellation control shader and tessellation primitive generator. The `patchControlPoints` member of the 【31†VkPipelineTessellationStateCreateInfo】 structure specified at pipeline creation time and the value provided in the `OutputVertices` execution mode of shader modules must be less than or equal to this limit.
L183: See 【30†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#tessellation】.
L184:   * `maxTessellationControlPerVertexInputComponents` is the maximum number of components of input variables which can be provided as per-vertex inputs to the tessellation control shader stage.
L185: 
L186:   * `maxTessellationControlPerVertexOutputComponents` is the maximum number of components of per-vertex output variables which can be output from the tessellation control shader stage.
L187:   * `maxTessellationControlPerPatchOutputComponents` is the maximum number of components of per-patch output variables which can be output from the tessellation control shader stage.
L188: 
L189:   * `maxTessellationControlTotalOutputComponents` is the maximum total number of components of per-vertex and per-patch output variables which can be output from the tessellation control shader stage.
L190:   * `maxTessellationEvaluationInputComponents` is the maximum number of components of input variables which can be provided as per-vertex inputs to the tessellation evaluation shader stage.
L191: 
L192:   * `maxTessellationEvaluationOutputComponents` is the maximum number of components of per-vertex output variables which can be output from the tessellation evaluation shader stage.
L193:   * `maxGeometryShaderInvocations` is the maximum invocation count supported for instanced geometry shaders. The value provided in the `Invocations` execution mode of shader modules must be less than or equal to this limit. See 【32†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#geometry】.
L194: 
L195:   * `maxGeometryInputComponents` is the maximum number of components of input variables which can be provided as inputs to the geometry shader stage.
L196:   * `maxGeometryOutputComponents` is the maximum number of components of output variables which can be output from the geometry shader stage.
L197: 
L198:   * `maxGeometryOutputVertices` is the maximum number of vertices which can be emitted by any geometry shader.
L199: 
L200:   * `maxGeometryTotalOutputComponents` is the maximum total number of components of output variables, across all emitted vertices, which can be output from the geometry shader stage.
L201:   * `maxFragmentInputComponents` is the maximum number of components of input variables which can be provided as inputs to the fragment shader stage.
L202: 
L203:   * `maxFragmentOutputAttachments` is the maximum number of output attachments which can be written to by the fragment shader stage.
L204:   * `maxFragmentDualSrcAttachments` is the maximum number of output attachments which can be written to by the fragment shader stage when blending is enabled and one of the dual source blend modes is in use. See 【33†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#framebuffer-dsb】 and 【34†`dualSrcBlend`】.
L205:   * `maxFragmentCombinedOutputResources` is the total number of storage buffers, storage images, and output `Location` decorated color attachments (described in 【35†Fragment Output Interface】) which can be used in the fragment shader stage.
L206: 
L207:   * `maxComputeSharedMemorySize` is the maximum total storage size, in bytes, available for variables declared with the `Workgroup` storage class in shader modules (or with the `shared` storage qualifier in GLSL) in the compute shader stage.
L208:   * `maxComputeWorkGroupCount`[3] is the maximum number of local workgroups that can be dispatched by a single dispatching command. These three values represent the maximum number of local workgroups for the X, Y, and Z dimensions, respectively. The workgroup count parameters to the dispatching commands must be less than or equal to the corresponding limit. See 【36†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#dispatch】.
L209:   * `maxComputeWorkGroupInvocations` is the maximum total number of compute shader invocations in a single local workgroup. The product of the X, Y, and Z sizes, as specified by the `LocalSize` execution mode in shader modules or by the object decorated by the `WorkgroupSize` decoration, must be less than or equal to this limit.
L210:   * `maxComputeWorkGroupSize`[3] is the maximum size of a local compute workgroup, per dimension. These three values represent the maximum local workgroup size in the X, Y, and Z dimensions, respectively. The `x`, `y`, and `z` sizes, as specified by the `LocalSize` execution mode or by the object decorated by the `WorkgroupSize` decoration in shader modules, must be less than or equal to the corresponding limit.
L211:   * `subPixelPrecisionBits` is the number of bits of subpixel precision in framebuffer coordinates x_{f} and y_{f}. See 【37†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#primsrast】.
L212:   * `subTexelPrecisionBits` is the number of bits of precision in the division along an axis of an image used for minification and magnification filters. 2^{`subTexelPrecisionBits`} is the actual number of divisions along each axis of the image represented. Sub-texel values calculated during image sampling will snap to these locations when generating the filtered results.
L213:   * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions.
L214: 
L215:   * `maxDrawIndexedIndexValue` is the maximum index value that can be used for indexed draw calls when using 32-bit indices. This excludes the primitive restart index value of 0xFFFFFFFF. See 【38†`fullDrawIndexUint32`】.
L216:   * `maxDrawIndirectCount` is the maximum draw count that is supported for indirect drawing calls. See 【39†`multiDrawIndirect`】.
L217:   * `maxSamplerLodBias` is the maximum absolute sampler LOD bias. The sum of the `mipLodBias` member of the 【40†VkSamplerCreateInfo】 structure and the `Bias` operand of image sampling operations in shader modules (or 0 if no `Bias` operand is provided to an image sampling operation) are clamped to the range [-`maxSamplerLodBias`,+`maxSamplerLodBias`]. See 【41†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#samplers-mipLodBias】.
L218:   * `maxSamplerAnisotropy` is the maximum degree of sampler anisotropy. The maximum degree of anisotropic filtering used for an image sampling operation is the minimum of the `maxAnisotropy` member of the 【40†VkSamplerCreateInfo】 structure and this limit. See 【42†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#samplers-maxAnisotropy】.
L219:   * `maxViewports` is the maximum number of active viewports. The `viewportCount` member of the 【43†VkPipelineViewportStateCreateInfo】 structure that is provided at pipeline creation must be less than or equal to this limit.
L220:   * `maxViewportDimensions`[2] are the maximum viewport dimensions in the X (width) and Y (height) dimensions, respectively. The maximum viewport dimensions must be greater than or equal to the largest image which can be created and used as a framebuffer attachment. See 【44†Controlling the Viewport】.
L221:   * `viewportBoundsRange`[2] is the [minimum, maximum] range that the corners of a viewport must be contained in. This range must be at least [-2 × `size`, 2 × `size` - 1], where `size` = max(`maxViewportDimensions`[0], `maxViewportDimensions`[1]). See 【44†Controlling the Viewport】.
L222: Note  | The wide range of values required for `viewportBoundsRange` allows the viewport to be arbitrarily shifted relative to the output render target while still partially overlapping. However, the minimum range required to achieve this would actually be [-`size` + 1, 2 × `size` - 1]. As these limits in implementations are typically simple power-of-two values, the specification reflects this convention, rounding the lower bound accordingly.
L223:   * `viewportSubPixelBits` is the number of bits of subpixel precision for viewport bounds. The subpixel precision that floating-point viewport bounds are interpreted at is given by this limit.
L224:   * `minMemoryMapAlignment` is the minimum required alignment, in bytes, of host visible memory allocations within the host address space. When mapping a memory allocation with 【45†vkMapMemory】, subtracting `offset` bytes from the returned pointer will always produce an integer multiple of this limit. See 【46†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#memory-device-hostaccess】. The value must be a power of two.
L225:   * `minTexelBufferOffsetAlignment` is the minimum required alignment, in bytes, for the `offset` member of the 【47†VkBufferViewCreateInfo】 structure for texel buffers. The value must be a power of two.
L226: This limit is equivalent to the maximum of the 【48†`uniformTexelBufferOffsetAlignmentBytes`】 and 【49†`storageTexelBufferOffsetAlignmentBytes`】 members of 【50†VkPhysicalDeviceTexelBufferAlignmentProperties】, but smaller alignment is optionally allowed by 【51†`storageTexelBufferOffsetSingleTexelAlignment`】 and 【52†`uniformTexelBufferOffsetSingleTexelAlignment`】.
L227: For …[truncated]</excerpt>
</source>
<source kind="search">
<title>Vulkan® 1.4.351 - A Specification (with all ratified extensions)</title>
<location>https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf</location>
<excerpt>citeturn215248search12 [wordlim: 200] Published: 5 months ago; The LOD must be computed with `mipmapPrecisionBits` of accuracy.
The other derivatives are simplified similarly, resulting in

\[
\frac{\partial s_{face}}{\partial y} = \frac{1}{2}\times\left(\frac{|r_c|\times \partial s_c/\partial y - s_c\times \partial r_c/\partial y}{(r_c)^2}\right)
\]

\[
\frac{\partial t_{face}}{\partial x} = \frac{1}{2}\times\left(\frac{|r_c|\times \partial t_c/\partial x - t_c\times \partial r_c/\partial x}{(r_c)^2}\right)
\]

\[
\frac{\partial t_{face}}{\partial y} = \frac{1}{2}\times\left(\frac{|r_c|\times \partial t_c/\partial y - t_c\times \partial r_c/\partial y}{(r_c)^2}\right)
\]

## 20.3.7. Scale Factor Operation, LOD Operation and Image Level(s) Selection

LOD selection can be either explicit (provided explicitly by the image instruction) or implicit (determined from a scale factor calculated from the derivatives). The LOD must be computed with `mipmapPrecisionBits` of accuracy.

### Scale Factor Operation

The magnitude of the derivatives are calculated by:

\[
m_{ux} = |\partial s/\partial x| \times w_{base}
\]

\[
m_{vx} = |\partial t/\partial x| \times h_{base}
\]

\[
m_{wx} = |\partial r/\partial x| \times d_{base}
\]

\[
m_{uy} = |\partial s/\partial y| \times w_{base}
\]

\[
m_{vy} = |\partial t/\partial y| \times h_{base}
\]

\[
m_{wy} = |\partial r/\partial y| \times d_{base}
\]

where:</excerpt>
</source>
<source kind="search">
<title>Sampling :: Vulkan Documentation Project</title>
<location>https://docs.vulkan.org/spec/latest/chapters/textures.html</location>
<excerpt>citeturn215248search0 [wordlim: 200] Crawled: 5 days ago;   * The sampler was created with `flags` containing VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT and is used with a function that is not `OpImageSampleImplicitLod` or `OpImageSampleExplicitLod`, or is used with operands `Offset` or `ConstOffsets`. ... The derivatives are computed as specified above, and the implicit LOD calculation proceeds for each shader invocation using its respective image and sampler object. ... δ is the fractional value, quantized to the number of mipmap precision bits, used for linear filtering between levels.

If the optional SPIR-V operand `Lod` is provided, then derivatives are set to zero, the cube map derivative transformation is skipped, and the scale factor operation is skipped. Instead, the floating-point scalar coordinate is directly assigned to λ_{base} as described in LOD Operation.

If the image or sampler object used by an implicit derivative image instruction is not uniform across the quad and `quadDivergentImplicitLod` is not supported, then the derivative and LOD values are undefined. Implicit derivatives are well-defined when the image and sampler and control flow are uniform across the quad, even if they diverge between different quads.

If `quadDivergentImplicitLod` is supported, then derivatives and implicit LOD values are well-defined even if the image or sampler object are not uniform within a quad. The derivatives are computed as specified above, and the implicit LOD calculation proceeds for each shader invocation using its respective image and sampler object.

### Cube Map Face Selection and Transformations

For cube map image instructions, the (s,t,r) coordinates are treated as a direction vector (r_{x},r_{y},r_{z}). The direction vector is used to select a cube map face. The direction vector is transformed to a per-face texel coordinate system (s_{face},t_{face}). The direction vector is also used to transform the derivatives to per-face derivatives.

#### LOD Operation

The LOD parameter λ is computed as follows:

where:

and maxSamplerLodBias is the value of the VkPhysicalDeviceLimits feature `maxSamplerLodBias`.

#### Image Level(s) Selection

The image level(s) d, d_{hi}, and d_{lo} which texels are read from are determined by an image-level parameter d_{l}, which is computed based on the LOD parameter, as follows:

where:

and:

`baseMipLevel` and `levelCount` are taken from the `subresourceRange` of the image view.

minLod_{imageView} must be less than or equal to level_{base}
q.

If the sampler’s `mipmapMode` is VK_SAMPLER_MIPMAP_MODE_NEAREST, then the level selected is d = d_{l}.

If the sampler’s `mipmapMode` is VK_SAMPLER_MIPMAP_MODE_LINEAR, two neighboring levels are selected:

δ is the fractional value, quantized to the number of mipmap precision bits, used for linear filtering between levels.
</excerpt>
</source>
<source kind="search">
<title>VkPhysicalDeviceLimits(3)</title>
<location>https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPhysicalDeviceLimits.html</location>
<excerpt>citeturn215248search6 [wordlim: 200] Crawled: 3 months ago;   * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions.
</excerpt>
</source>
<source kind="search">
<title>Vulkan® SC 1.0.21 - A Specification (with all ratified Vulkan SC extensions) : Based on Vulkan 1.2.344</title>
<location>https://registry.khronos.org/VulkanSC/specs/latest-ratified/pdf/vkspec.pdf</location>
<excerpt>citeturn215248search13 [wordlim: 200] The LOD must be computed with mipmapPrecisionBits of accuracy.

s&lt;sub&gt;face&lt;/sub&gt; = 1/2 × s&lt;sub&gt;c&lt;/sub&gt; / |r&lt;sub&gt;c&lt;/sub&gt;| + 1/2

t&lt;sub&gt;face&lt;/sub&gt; = 1/2 × t&lt;sub&gt;c&lt;/sub&gt; / |r&lt;sub&gt;c&lt;/sub&gt;| + 1/2

17.3.6. Cube Map Derivative Transformation

The partial derivatives of the Cube Map Coordinate Transformations can be computed as:

∂s&lt;sub&gt;face&lt;/sub&gt; / ∂x = ∂/∂x (1/2 × s&lt;sub&gt;c&lt;/sub&gt; / |r&lt;sub&gt;c&lt;/sub&gt;| + 1/2)
= 1/2 × ∂/∂x (s&lt;sub&gt;c&lt;/sub&gt; / |r&lt;sub&gt;c&lt;/sub&gt;|)
= 1/2 × (|r&lt;sub&gt;c&lt;/sub&gt;| × ∂s&lt;sub&gt;c&lt;/sub&gt; / ∂x − s&lt;sub&gt;c&lt;/sub&gt; × ∂r&lt;sub&gt;c&lt;/sub&gt; / ∂x) / (r&lt;sub&gt;c&lt;/sub&gt;)&lt;sup&gt;2&lt;/sup&gt;

The other derivatives are simplified similarly, resulting in

∂s&lt;sub&gt;face&lt;/sub&gt; / ∂y = 1/2 × (|r&lt;sub&gt;c&lt;/sub&gt;| × ∂s&lt;sub&gt;c&lt;/sub&gt; / ∂y − s&lt;sub&gt;c&lt;/sub&gt; × ∂r&lt;sub&gt;c&lt;/sub&gt; / ∂y) / (r&lt;sub&gt;c&lt;/sub&gt;)&lt;sup&gt;2&lt;/sup&gt;

∂t&lt;sub&gt;face&lt;/sub&gt; / ∂x = 1/2 × (|r&lt;sub&gt;c&lt;/sub&gt;| × ∂t&lt;sub&gt;c&lt;/sub&gt; / ∂x − t&lt;sub&gt;c&lt;/sub&gt; × ∂r&lt;sub&gt;c&lt;/sub&gt; / ∂x) / (r&lt;sub&gt;c&lt;/sub&gt;)&lt;sup&gt;2&lt;/sup&gt;

∂t&lt;sub&gt;face&lt;/sub&gt; / ∂y = 1/2 × (|r&lt;sub&gt;c&lt;/sub&gt;| × ∂t&lt;sub&gt;c&lt;/sub&gt; / ∂y − t&lt;sub&gt;c&lt;/sub&gt; × ∂r&lt;sub&gt;c&lt;/sub&gt; / ∂y) / (r&lt;sub&gt;c&lt;/sub&gt;)&lt;sup&gt;2&lt;/sup&gt;

17.3.7. Scale Factor Operation, LOD Operation and Image Level(s) Selection

LOD selection can be either explicit (provided explicitly by the image instruction) or implicit (determined from a scale factor calculated from the derivatives). The LOD must be computed with mipmapPrecisionBits of accuracy.

Scale Factor Operation

The magnitude of the derivatives are calculated by:</excerpt>
</source>
<omitted_sources count="24">Additional source records were omitted from this bounded result.</omitted_sources>
</source_evidence>

Citations:

- 1: https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPhysicalDeviceLimits.html
- 2: https://docs.vulkan.org/spec/latest/chapters/textures.html?utm_source=openai
- 3: https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf?utm_source=openai

Use a tolerance compatible with mipmapPrecisionBits.

IMAGE_GET_LOD emits OpImageQueryLod, which performs the implicit LOD calculation. Vulkan permits only four mipmapPrecisionBits, while this test accepts an error of at most 1.0f / 64.0f. A conforming implementation may therefore return a valid LOD near 2.0f that this test rejects.

This is a minor portability issue, not a major regression. The fixed-tolerance pattern already exists, but the harness does not query mipmapPrecisionBits.

Use a tolerance compatible with the minimum Vulkan precision, or derive it from the device limit.

✅ Addressed in commit 7ffd3db

**@⁠coderabbitai[bot]** on GitHub · 2026-10-28 20:19 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1686#discussion_r4405640687) · edited 2026-10-28 21:23 UTC On `tests/ShaderRecompilerComputeTests.cpp` line 39756 (outdated): ```diff @@ -39731,6 +39731,44 @@ TestCase ImageSampleAndGather() { return test; } +TestCase ImageGetLodComputeLaneQuads(const char *name, u32 width_shift, + u32 height) { + using O = ShaderOpcode; + const u32 lanes = (1u << width_shift) * height; + std::vector<u32> code; + code.push_back(EncodeVop2(0x1b, 20, InlineU32(2), 0)); + code.push_back(EncodeVop1(0x06, 20, Vgpr(20))); + AppendVMovLiteral(&code, 22, 0x3e000000u); + code.push_back(EncodeVop2(0x08, 20, Vgpr(20), 22)); + AppendVMovLiteral(&code, 21, 0x3f000000u); + code.push_back(EncodeMimg0(0x60, 0x3)); + code.push_back(EncodeMimg1(10, 20)); + code.push_back(EncodeVop2(0x1a, 23, InlineU32(width_shift), 1)); + code.push_back(EncodeVop2(0x25, 23, Vgpr(0), 23)); + AppendStoreVgprAtLaneDwordOffset(&code, 10, 23, 0); + AppendStoreVgprAtLaneDwordOffset(&code, 11, 23, lanes); + AppendEnd(&code); + + TestCase test; + test.name = name; + test.code = code; + test.expected.assign(2 * lanes, 0x40000000u); + test.expected_float_tolerance = 1.0f / 64.0f; ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Functional Correctness** · **Quick win** <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details.svg" width="16" height="16" align="absmiddle" alt=""></picture> Supported by static analysis</summary> <dl> <dd> Script executed: ```bash rg -n 'expected_float_tolerance|mipmapPrecisionBits' tests/ShaderRecompilerComputeTests.cpp | head -60 sed -n '39725,39780p' tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 2744 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- tolerance comparison ---' sed -n '1390,1420p' tests/ShaderRecompilerComputeTests.cpp sed -n '22420,22450p' tests/ShaderRecompilerComputeTests.cpp printf '%s\n' '--- IMAGE_GET_LOD references and nearby test declarations ---' rg -n -F -- 'IMAGE_GET_LOD' tests/ShaderRecompilerComputeTests.cpp sed -n '39190,39340p' tests/ShaderRecompilerComputeTests.cpp sed -n '39690,39770p' tests/ShaderRecompilerComputeTests.cpp printf '%s\n' '--- precision identifiers in the repository ---' rg -n -F -- 'mipmapPrecisionBits' . || test "$?" -eq 1 rg -n -F -- 'limits' src/graphics tests/ShaderRecompilerComputeTests.cpp | head -100 printf '%s\n' '--- diff from requested merge base ---' git diff --unified=20 c67352d5d6dc6fc3fd375deed5c1a89b3e33974e cfdeb44d973d10b80e7cd5d80ac11af5118efcb8 -- tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 39360 --- Web query: `Vulkan 1.3 specification mipmapPrecisionBits textureQueryLod OpImageQueryLod precision exact integer LOD` Result: ``` <source_evidence> <source kind="find_in_page"> <title>SPIR-V Specification</title> <location>https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html</location> <excerpt>citeturn512513view0 [wordlim: 200] Crawled: today; Content type: text/html; Source: find({&quot;ref_id&quot;:&quot;turn398895search1&quot;,&quot;pattern&quot;:&quot;OpImageQueryLod&quot;}); Total lines: 11166 L5465: Query the image format of an image created with an Unknown 【66†Image Format】. Result Type must be a scalar 【203†integer type】. The resulting value is an enumerant from 【68†Image Channel Data Type】. Image must be an object whose type is 【220†OpTypeImage】. | 【86†Capability】: L5466: Kernel L5467: 4 | 101 | &lt;id&gt; L5468: Result Type | 【205†Result &lt;id&gt;】 | &lt;id&gt; L5469: Image L5470: OpImageQueryOrder L5471: Query the channel order of an image created with an Unknown 【66†Image Format】. Result Type must be a scalar 【203†integer type】. The resulting value is an enumerant from 【67†Image Channel Order】. Image must be an object whose type is 【220†OpTypeImage】. | 【86†Capability】: L5472: Kernel L5473: 4 | 102 | &lt;id&gt; L5474: Result Type | 【205†Result &lt;id&gt;】 | &lt;id&gt; L5475: Image L5476: OpImageQuerySizeLod L5477: Query the dimensions of Image for mipmap level for Level of Detail. Result Type must be an 【203†integer type】 scalar or vector. The number of components must be L5478: 1 for the 1D 【63†dimensionality】, L5479: 2 for the 2D and Cube 【63†dimensionalities】, L5480: 3 for the 3D 【63†dimensionality】, L5481: plus 1 more if the image type is arrayed. This vector is filled in with (width [, height] [, depth] [, elements]) where elements is the number of layers in an image array, or the number of cubes in a cube-map array. Image must be an object whose type is 【220†OpTypeImage】. Its 【63†Dim】 operand must be one of 1D, 2D, 3D, or Cube, and its MS must be 0. See 【741†OpImageQuerySize】 for querying image types without level of detail. See the client API specification for additional image type restrictions. L5482: Level of Detail is used to compute which mipmap level to query and must be a 32-bit 【203†integer type】 scalar. | 【86†Capability】: L5483: Kernel, ImageQuery L5484: 5 | 103 | &lt;id&gt; L5485: Result Type | 【205†Result &lt;id&gt;】 | &lt;id&gt; L5486: Image | &lt;id&gt; L5487: Level of Detail L5488: OpImageQuerySize L5489: Query the dimensions of Image, with no level of detail. Result Type must be an 【203†integer type】 scalar or vector. The number of components must be: L5490: 1 for the 1D and Buffer 【63†dimensionalities】, L5491: 2 for the 2D, Cube, and Rect 【63†dimensionalities】, L5492: 3 for the 3D 【63†dimensionality】, L5493: plus 1 more if the image type is arrayed. This vector is filled in with (width [, height] [, elements]) where elements is the number of layers in an image array or the number of cubes in a cube-map array. Image must be an object whose type is 【220†OpTypeImage】. Its 【63†Dim】 operand must be one of those listed under Result Type, above. Additionally, if its Dim is 1D, 2D, 3D, or Cube, it must also have either an MS of 1 or a Sampled of 0 or 2. L5494: There is no implicit level-of-detail consumed by this instruction. See 【742†OpImageQuerySizeLod】 for querying images having level of detail. See the client API specification for additional image type restrictions. | 【86†Capability】: L5495: Kernel, ImageQuery L5496: 4 | 104 | &lt;id&gt; L5497: Result Type | 【205†Result &lt;id&gt;】 | &lt;id&gt; L5498: Image L5499: OpImageQueryLod L5500: Query the mipmap level and the level of detail for a hypothetical sampling of Image at Coordinate using an implicit level of detail. An invocation will not execute a 【278†dynamic instance】 of this instruction (X&#39;) until all invocations in its 【362†derivative group】 have executed all 【278†dynamic instances】 that are 【740†program-ordered before】 X&#39;. Result Type must be a two-component 【202†floating-point type】 vector. L5501: The first component of the result contains the mipmap array layer. L5502: The second component of the result contains the implicit level of detail relative to the base level. Sampled Image must be an object whose type is 【227†OpTypeSampledImage】. Its 【220†OpTypeImage】 【63†Dim】 operand must be one of 1D, 2D, 3D, or Cube, and its MS must be 0. Coordinate must be a scalar or vector of 32-bit 【202†floating-point type】. It contains (u[, v] …​ ) as needed by the definition of Sampled Image, not including any array layer index. L5503: This instruction is only valid in the Fragment 【58†Execution Model】. In addition, it consumes an implicit derivative that can be affected by code motion. | 【86†Capability】: L5504: ImageQuery L5505: 5 | 105 | &lt;id&gt; L5506: Result Type | 【205†Result &lt;id&gt;】 | &lt;id&gt; L5507: Sampled Image | &lt;id&gt; L5508: Coordinate L5509: OpImageQueryLevels L5510: Query the number of mipmap levels accessible through Image. Result Type must be a scalar 【203†integer type】. The result is the number of mipmap levels, as specified by the client API. Image must be an object whose type is 【220†OpTypeImage】. Its 【63†Dim】 operand must be one of 1D, 2D, 3D, or Cube, and its MS must be 0. See the client API specification for additional image type restrictions. | 【86†Capability】: L5511: Kernel, ImageQuery L5512: 4 | 106 | &lt;id&gt; L5513: Result Type | 【205†Result &lt;id&gt;】 | &lt;id&gt; L5514: Image L5515: OpImageQuerySamples L5516: Query the number of samples available per texel fetch in a multisample image. Result Type must be a scalar 【203†integer type】. The result is the number of samples. Image must be an object whose type is 【220†OpTypeImage】. Its 【63†Dim】 operand must be one of 2D and MS of 1. | 【86†Capability】: L5517: Kernel, ImageQuery L5518: 4 | 107 | &lt;id&gt; L5519: Result Type | 【205†Result &lt;id&gt;】 | &lt;id&gt; L5520: Image L5521: OpImageSparseSampleImplicitLod L5522: Sample a sparse image with an implicit level of detail. An invocation will not execute a 【278†dynamic instance】 of this instruction (X&#39;) until all invocations in its 【362†derivative group】 have executed all 【278†dynamic instances】 that are 【740†program-ordered before】 X&#39;. Result Type must be an 【317†OpTypeStruct】 with two members. The first member’s type must be an 【203†integer type】 scalar. It holds a Residency Code that can be passed to 【743†OpImageSparseTexelsResident】. L5523: The second member must be a vector of four components of 【202†floating-point type】 or 【203†integer type】. Its components must be the same as Sampled Type of the underlying 【220†OpTypeImage】 (unless that underlying Sampled Type is OpTypeVoid). Sampled Image must be an object whose type is 【227†OpTypeSampledImage】. Its 【220†OpTypeImage】 must not have a 【63†Dim】 of Buffer. The MS operand of the underlying 【220†OpTypeImage】 must be 0. Coordinate must be a scalar or vector of 32-bit 【202†floating-point type】. L5524: It contains (u[, v] …​ [, array layer]) as needed by the definition of Sampled Image. It may be a vector larger than needed, but all unused components appear after all used components. Image Operands encodes what operands follow, as per 【69†Image Operands】. This instruction is only valid in the Fragment 【58†Execution Model】. In addition, it consumes an implicit derivative that can be affected by code motion. | 【86†Capability】: L5525: SparseResidency L5526: 5 + variable | 305 | &lt;id&gt; L5527: Result Type | 【205†Result &lt;id&gt;】 | &lt;id&gt; L5528: Sampled Image | &lt;id&gt; L5529: Coordinate | Optional L5530: 【69†Image Operands】 L5531: | Optional L5532: &lt;id&gt;, &lt;id&gt;, …​ L5533: OpImageSparseSampleExplicitLod L5534: Sample a sparse image using an explicit level of detail. Result Type must be an 【317†OpTypeStruct】 with two members. The first member’s type must be an 【203†integer type】 scalar. It holds a Residency Code that can be passed to 【743†OpImageSparseTexelsResident】. The second member must be a vector of four components of 【202†floating-point type】 or 【203†integer type】. Its components must be the same as Sampled Type of the underlying 【220†OpTypeImage】 (unless that underlying Sampled Type is OpTypeVoid). L5535: Sampled Image must be an object whose type is 【227†OpTypeSampledImage】. Its 【220†OpTypeImage】 must not have a 【63†Dim】 of Buffer. The MS operand of the underlying 【220†OpTypeImage】 must be 0. Coordinate must be a scalar or vector of 32-bit 【202†floating-point type】 or 32-bit 【203†integer type】. It contains (u[, v] …​ [, array layer]) as needed by the definition of Sampled Image. Unless the Kernel 【86†capability】 is declared, it must be floating point. L5536: It may be a vector larger than needed, but all unused components appear after all used components. Image Operands encodes what operands follow, as per 【69†Image Operands】. Either Lod or Grad image operands must be present. | 【86†Capability】: L5537: SparseResidency L5538: 7 + variable | 306 | &lt;id&gt; L5539: Result Type | 【205†Result &lt;id&gt;】 | &lt;id&gt; L5540: Sampled Image | &lt;id&gt; L5541: Coordinate | 【69†Image Operands】 L5542: | &lt;id&gt; L9913: * Khronos SPIR-V issue #60: 【280†OpControlBarrier】 synchronizes Output variables when used in tessellation-control shader. L9914: L9915: * Public SPIRV-Headers issue #1: Remove the Shader capability requirement from the Input 【62†Storage Class】. L9916: L9917: * Public SPIRV-Headers issue #10: Don’t say the (u [, v] [, w], q) has four components, as it can be closed up when the optional ones are missing. Seen in the 【396†projective image】 instructions. L9918: * Public SPIRV-Headers issues #12 and #13 and Khronos SPIR-V issue #65: Allow 【206†OpVariable】 as an initializer for another OpVariable instruction or the Base of an 【339†OpSpecConstantOp】 with an AccessChain opcode. L9919: L9920: * Public SPIRV-Headers issues #14: add Max enumerants of 0x7FFFFFFF to each of the non-mask enums in the C-based header files. L9921: ### 4.8. Changes from Version 1.00, Revision 6 L9922: L9923: * Khronos SPIR-V issue #63: Be clear that OpUndef can be used in sequence 9 (and is preferred to be) of the 【22†Logical Layout】 and can be part of partially-defined 【334†OpConstantComposite】. L9924: L9925: * Khronos SPIR-V issue #70: Don’t explicitly require operand truncation for integer operations when operating at 【37†RelaxedPrecision】. L9926: L9927: * Khronos SPIR-V issue #76: Include OpINotEqual in the list of allowed instructions for 【339†OpSpecConstantOp】. L9928: * Khronos SPIR-V issue #79: Remove implication that 【767†OpImageQueryLod】 should have a component for the array index. L9929: L9930: * Public SPIRV-Headers issue #17: 【75†Decorations】 NoPerspective, Flat, Patch, Centroid, and Sample can apply to a top-level member that is itself a structure, so don’t disallow it through restrictions to numeric types. L9931: ### 4.9. Changes from Version 1.00, Revision 7 L9932: L9933: * Khronos SPIR-V issue #69: 【409†OpImageSparseFetch】 editorial change in summary: include that it is sampled image. L9934: L9935: * Khronos SPIR-V issue #74: 【767†OpImageQueryLod】 requires a sampler. L9936: L9937: * Khronos SPIR-V issue #82: Clarification to the Float16Buffer 【86†Capability】. L9938: L9939: * Khronos SPIR-V issue #89: Editorial improvements to 【320†OpMemberDecorate】 and 【323†OpDecorationGroup】. L9940: ### 4.10. Changes from Version 1.00, Revision 8 L9941: L9942: * Add SPV_KHR_subgroup_vote tokens. L9943: L9944: * Typo: Change &quot;without a sampler&quot; to &quot;with a sampler&quot; for the description of the 【86†SampledBuffer】 Capability. L9945: L9946: * Khronos SPIR-V issue #61: Clarification of packet size and alignment on all instructions that use the 【86†Pipes】 Capability. L9947: L9948: * Khronos SPIR-V issue #99: Use &quot;invalid&quot; language to replace any &quot;compile-time error&quot; language. L9949: * Khronos SPIR-V issue #55: Distinguish between 【261†branch instructions】 and 【251†termination instructions】. L9950: L9951: * Khronos SPIR-V issue #94: Add missing 【768†OpSubgroupReadInvocationKHR】 enumerant. L9952: L9953: * Khronos SPIR-V issue #114: Header blocks 【766†strictly dominate】 their merge blocks. L9954: L9955: * Khronos SPIR-V issue #119: 【339†OpSpecConstantOp】 allows OpUndef where allowed by its opcode. L9956: ### 4.11. Changes from Version 1.00, Revision 9 L9957: L9958: * Khronos Vulkan issue #652: Remove statements about matrix offsets and padding. These are described correctly in the Vulkan API specifications. L9959: L9960: * Khronos SPIR-V issue #113: Remove the &quot;By Default&quot; statements in 【71†FP Rounding Mode】. These should be properly specified by the client API. L9961: L9962: * Add extension enumerants for L9963: L9964: * SPV_KHR_16bit_storage L9965: L9966: * SPV_KHR_device_group L9967: L9968: * SPV_KHR_multiview L9969: L9970: * SPV_NV_sample_mask_override_coverage L9971: * SPV_NV_geometry_shader_passthrough L9972: L9973: * SPV_NV_viewport_array2 L9974: L9975: * SPV_NV_stereo_view_rendering L9976: L9977: * SPV_NVX_multiview_per_view_attributes L9978: ### 4.12. Changes …[truncated]</excerpt> </source> <source kind="open_page"> <title>The OpenGL® Shading Language, Version 4.60.8</title> <location>https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html</location> <excerpt>citeturn215078view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;turn376994search0&quot;,&quot;lineno&quot;:null}); Total lines: 7039 L1260: If the image target type does not match the bound image in this manner, if the data type does not match the bound image, or if the format layout qualifier does not match the image unit format as described in section 8.25 “Texture Image Loads and Stores” of the 【82†OpenGL Specification】, the results of image accesses are undefined but cannot include program termination. L2998: #### 4.7.1. Range and Precision L2999: L3000: The precision of highp single- and double-precision floating-point variables is defined by the IEEE 754 standard for 32-bit and 64-bit floating-point numbers. L3001: L3002: This includes support for NaNs (Not a Number) and Infs (positive or negative infinities) and positive and negative zeros. L3003: The following rules apply to highp for both single and double-precision operations: Signed infinities and zeros are generated as dictated by IEEE, but subject to the precisions allowed in the following table. Any subnormal (denormalized) value input into a shader or potentially generated by any operation in a shader can be flushed to 0. The rounding mode cannot be set and is undefined but must not affect the result by more than 1 ULP. NaNs are not required to be generated. L3022: Built-in functions defined in the specification with an equation built from the above operations inherit the above errors. These include, for example, the geometric functions, the common functions, and many of the matrix functions. Built-in functions not listed above and not defined as equations of the above have undefined precision. These include, for example, the trigonometric functions and determinant. L3023: L3024: The precision of double-precision operations is at least that of single precision. L3048: For this paragraph, “operation” includes operators, built-in functions, and constructors, and “operand” includes function arguments and constructor arguments. The precision qualification associated with any operation is the highest precision qualification of the operands consumed by the operation, if any operand has an associated precision. In cases where no operand has a precision qualifier, the precision qualifications of the operands of the next consuming operation in the expression will be used. L4182: The variable gl_BaseInstance is a vertex shader input variable that holds the integer value passed to the baseInstance parameter of the command that resulted in the current shader invocation (see “Shader Inputs” in section 11.1.3.9 of the 【82†OpenGL Specification】). L4291: gl_Layer is used to select a specific layer (or face and layer of a cube map) of a multi-layer framebuffer attachment. The actual layer used will come from one of the vertices in the primitive being shaded. Which vertex the layer comes from is determined as discussed in section 11.3.4.6 “Layer and Viewport Selection” of the 【82†OpenGL Specification】 but may be undefined, so it is best to write the same layer value for all vertices of a primitive. L4292: If a shader statically assigns a value to gl_Layer, layered rendering mode is enabled. See section 11.3.4.5 “Geometry Shader Outputs” and section 9.4.9 “Layered Framebuffers” of the 【82†OpenGL Specification】 for more information. If a shader statically assigns a value to gl_Layer, and there is an execution path through the shader that does not set gl_Layer, then the value of gl_Layer is undefined for executions of the shader that take that path. L4293: The output variable gl_Layer takes on a special value when used with an array of cube map textures. Instead of only referring to the layer, it is used to select a cube map face and a layer. Setting gl_Layer to the value layer*6+face will render to face face of the cube defined in layer layer. The face values are defined in table 9.3 of section 9.4.9 “Layered Fram…[truncated]</excerpt> </source> <source kind="search"> <title>VkPhysicalDeviceLimits(3) :: Vulkan Documentation Project</title> <location>https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceLimits.html</location> <excerpt>citeturn398895search0 [wordlim: 200] Crawled: 3 weeks ago; # VkPhysicalDeviceLimits(3) ... `// Provided by VK_VERSION_1_0 ... uint32_t mipmapPrecisionBits; Sub-texel values calculated during image sampling will snap to these locations when generating the filtered results. * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions. * `maxDrawIndexedIndexValue` is the maximum index value that can be used for indexed draw calls when using 32-bit indices. This excludes the primitive restart index value of 0xFFFFFFFF. See `fullDrawIndexUint32`. * `maxDrawIndirectCount` is the maximum draw count that is supported for indirect drawing calls. See `multiDrawIndirect`. * `maxSamplerLodBias` is the maximum absolute sampler LOD bias. The sum of the `mipLodBias` member of the VkSamplerCreateInfo structure and the `Bias` operand of image sampling operations in shader modules (or 0 if no `Bias` operand is provided to an image sampling operation) is clamped to the range [-`maxSamplerLodBias`,+`maxSamplerLodBias`]. See samplers-mipLodBias. * `maxSamplerAnisotropy` is the maximum degree of sampler anisotropy. The maximum degree of anisotropic filtering used for an image sampling operation is the minimum of the `maxAnisotropy` member of the VkSamplerCreateInfo structure and this limit. See samplers-maxAnisotropy. </excerpt> </source> <source kind="search"> <title>SPIR-V Specification</title> <location>https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html</location> <excerpt>citeturn398895search1 [wordlim: 200] Published: last month; Crawled: last month; Note | Up-to-date HTML and PDF versions of this specification may be found at the Khronos SPIR-V Registry. (https://www.khronos.org/registry/spir-v/) ... The full set of rules needed to consume SPIR-V in a particular environment comes from the combination of SPIR-V and that environment’s client API specification. ... For debugging portability of floating-point operations, OpQuantizeToF16 may be used to explicitly reduce the precision of a relaxed-precision result to 16-bit precision. ... OpImageQueryLod ### 2.14. Relaxed Precision The RelaxedPrecision Decoration allows 32-bit integer and 32-bit floating-point operations to execute with a relaxed precision of somewhere between 16 and 32 bits. For a floating-point operation, operating at relaxed precision means that the minimum requirements for range and precision are as follows: * the floating point range may be as small as (-2^{14}, 2^{14}) * the floating point magnitude range includes 0.0 and [2^{-14}, 2^{14}) * the relative floating point precision may be as small as 2^{-10} The range notation here means the largest required magnitude is half of the relative precision less than the value given. Relative floating-point precision is defined as the worst case (i.e. largest) ratio of the smallest step in relation to the value for all non-zero values in the required range: Precision_{relative} = (abs(v_{1} - v_{2})_{min} / abs(v_{1}))_{max} for v_{1} ≠ 0, v_{2} ≠ 0, v_{1} ≠ v_{2} It is therefore twice the maximum rounding error when converting from a real number. Subnormal numbers may be supported and may have lower relative precision. For integer operations, operating at relaxed precision means that the operation is evaluated by an operation in which, for some N, 16 ≤ N ≤ 32: * the operation is executed as though its type were N bits in size, and * the result is zero or sign extended to 32 bits as determined by the signedness of the result type of the operation. The RelaxedPrecision Decoration must only be applied to: * The &lt;id&gt; of an OpVariable, where it refers to the value of the variable. * The &lt;id&gt; of an OpFunctionParameter, where it refers to the value of the parameter. * The Result &lt;id&gt; of an instruction that reads or filters from an image. E.g. OpImageSampleExplicitLod, meaning the instruction is to operate at relaxed precision. * The Result &lt;id&gt; of an OpFunction, where it refers to the value returned by the function. * A structure-type member (through OpMemberDecorate). * The Result &lt;id&gt; of an OpFunctionCall, where it refers to the result of the function call. * The Result &lt;id&gt; of other instructions that operate on or produce numerical types, meaning the instruction is to operate at relaxed precision. The instruction’s operands may also be truncated to the relaxed precision. In all cases, the types of the values that the RelaxedPrecision Decoration refers to must be: * a scalar, vector, or matrix, or array of scalars, vectors, or matrices, and all the components in the types must be a 32-bit numerical type, * a pointer to such a type, where it refers to the value pointed to. The values that the RelaxedPrecision Decoration refers to can be truncated to relaxed precision. When applied to a variable, function parameter, or structure member, all loads and stores from the decorated object may be treated as though they were decorated with RelaxedPrecision. Loads may also be decorated with RelaxedPrecision, in which case they are treated as operating at relaxed precision. All loads and stores involving relaxed precision still read and write 32 bits of data, respectively. Floating-point data read or written in such a manner is written in full 32-bit floating-point format. However, a load or store might reduce the precision (as allowed by RelaxedPrecision) of the destination value. For debugging portability of floating-point operations, OpQuantizeToF16 may be used to explicitly reduce the precision of a relaxed-precision result to 16-bit precision. (Integer-result precision can be reduced, for example, using left- and right-shift opcodes.) For image-sampling operations, decorations can appear on both the sampling instruction and the image variable being sampled. If either is decorated, they both should be decorated, and if both are decorated their decorations must match. If only one is decorated, the sampling instruction can behave either as if both were decorated or neither were decorated. Each gathered texel is identified by adding one of these array elements to the (u, v) sampled location. It is invalid for these to be outside a target-dependent allowed range. Only valid with OpImageGather, OpImageDrefGather, OpImageSparseGather, or OpImageSparseDrefGather. Not valid with the Cube dimension. An instruction must specify at most one of the ConstOffset, Offset, and ConstOffsets image operands. | ImageGatherExtended 0x40 | Sample A following operand is the sample number of the sample to use. Only valid with OpImageFetch, OpImageRead, OpImageWrite, OpImageSparseFetch, and OpImageSparseRead. The Sample operand must be used if and only if the underlying OpTypeImage has MS of 1. It must be a 32-bit integer type scalar. | 0x80 | MinLod A following operand is the minimum level-of-detail to use when accessing the image. Only valid with Implicit instructions and Grad instructions. It must be a 32-bit floating-point type scalar using the IEEE 754 encoding. This must only be used with an OpTypeImage that has a Dim operand of 1D, 2D, 3D, or Cube, and the MS operand must be 0. | MinLod 0x100 | MakeTexelAvailable (MakeTexelAvailableKHR) Perform an availability operation on the texel locations after the store. A following operand is the memory scope that controls the availability operation. Requires NonPrivateTexel to also be set. Only valid with OpImageWrite. | VulkanMemoryModel Missing before version 1.5. Also see extension: SPV_KHR_vulkan_memory_model 0x200 | MakeTexelVisible (MakeTexelVisibleKHR) Perform a visibility operation on the texel locations before the load. A following operand is the memory scope that controls the visibility operation. Requires NonPrivateTexel to also be set. Only valid with OpImageRead and OpImageSparseRead. | VulkanMemoryModel Missing before version 1.5. Also see extension: SPV_KHR_vulkan_memory_model 0x400 | NonPrivateTexel (NonPrivateTexelKHR) The image access obeys inter-thread ordering, as specified by the client API. | VulkanMemoryModel Missing before version 1.5. Also see extension: SPV_KHR_vulkan_memory_model 0x800 | VolatileTexel (VolatileTexelKHR) This access cannot be eliminated, duplicated, or combined with other accesses. | VulkanMemoryModel Missing before version 1.5. Also see extension: SPV_KHR_vulkan_memory_model 0x1000 | SignExtend The texel value is converted to the target value via sign extension. Only valid if the texel value type is a scalar or vector of integer type: 4 | 100 | &lt;id&gt; Result Type | Result &lt;id&gt; | &lt;id&gt; Sampled Image OpImageQueryFormat Query the image format of an image created with an Unknown Image Format. Result Type must be a scalar integer type. The resulting value is an enumerant from Image Channel Data Type. Image must be an object whose type is OpTypeImage. | Capability: Kernel 4 | 101 | &lt;id&gt; Result Type | Result &lt;id&gt; | &lt;id&gt; Image OpImageQueryOrder Query the channel order of an image created with an Unknown Image Format. Result Type must be a scalar integer type. The resulting value is an enumerant from Image Channel Order. Image must be an object whose type is OpTypeImage. | Capability: Kernel 4 | 102 | &lt;id&gt; Result Type | Result &lt;id&gt; | &lt;id&gt; Image OpImageQuerySizeLod Query the dimensions of Image for mipmap level for Level of Detail. Result Type must be an integer type scalar or vector. The number of components must be 1 for the 1D dimensionality, 2 for the 2D and Cube dimensionalities, 3 for the 3D dimensionality, plus 1 more if the image type is arrayed. This vector is filled in with (width [, height] [, depth] [, elements]) where elements is the number of layers in an image array, or the number of cubes in a cube-map array. Image must be an object whose type is OpTypeImage. Its Dim operand must be one of 1D, 2D, 3D, or Cube, and its MS must be 0. See OpImageQuerySize for querying image types without level of detail. See the client API specification for additional image type restrictions. Level of Detail is used to compute which mipmap level to query and must be a 32-bit integer type scalar. | Capability: Kernel, ImageQuery 5 | 103 | &lt;id&gt; Result Type | Result &lt;id&gt; | &lt;id&gt; Image | &lt;id&gt; Level of Detail OpImageQuerySize Query the dimensions of Image, with no level of detail. Result Type must be an integer type scalar or vector. The number of components must be: 1 for the 1D and Buffer dimensionalities, 2 for the 2D, Cube, and Rect dimensionalities, 3 for the 3D dimensionality, plus 1 more if the image type is arrayed. This vector is filled in with (width [, height] [, elements]) where elements is the number of layers in an image array or the number of cubes in a cube-map array. Image must be an object whose type is OpTypeImage. Its Dim operand must be one of those listed under Result Type, above. Additionally, if its Dim is 1D, 2D, 3D, or Cube, it must also have either an MS of 1 or a Sampled of 0 or 2. There is no implicit level-of-detail consumed by this instruction. See OpImageQuerySizeLod for querying images having level of detail. See the client API specification for additional image type restrictions. | Capability: Kernel, ImageQuery 4 | 104 | &lt;id&gt; Result Type | Result &lt;id&gt; | &lt;id&gt; Image OpImageQueryLod Query the mipmap level and the level of detail for a hypothetical sampling of Image at Coordinate using an implicit level of detail. </excerpt> </source> <source kind="search"> <title>Vulkan Specification :: Vulkan Documentation Project</title> <location>https://docs.vulkan.org/guide/latest/vulkan_spec.html</location> <excerpt>citeturn398895search6 [wordlim: 200] Crawled: 5 days ago; For Vulkan 1.0 to 1.3, there was a dedicated version of the spec. ... The Vulkan SDK also comes with a PDF version (https://vulkan.lunarg.com/doc/sdk/1.4.341.1/windows/1.4-extensions/vkspec.pdf) </excerpt> </source> <omitted_sources count="61">Additional source records were omitted from this bounded result.</omitted_sources> </source_evidence> Citations: - 1: https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceLimits.html?utm_source=openai - 2: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html - 3: https://docs.vulkan.org/guide/latest/vulkan_spec.html?utm_source=openai ``` --- Script executed: ```bash printf '%s\n' '--- complete pre-existing ImageSampleAndGather ---' sed -n '39640,39735p' tests/ShaderRecompilerComputeTests.cpp printf '%s\n' '--- helper call sites and opcode definitions ---' rg -n -F -e 'ImageGetLodComputeLaneQuads' -e 'EncodeMimg0' -e 'IMAGE_GET_LOD' tests/ShaderRecompilerComputeTests.cpp src/graphics/shader/recompiler rg -n -F -- '0x60' src/graphics/shader/recompiler tests/ShaderRecompilerComputeTests.cpp | head -80 printf '%s\n' '--- relevant Vulkan limit declarations and local device-property plumbing ---' rg -n -F -e 'PhysicalDeviceProperties' -e 'physical_device_properties' -e 'getProperties' tests/ShaderRecompilerComputeTests.cpp | head -120 ``` Repository: KytyPS5/KytyPS5 Length of output: 23878 --- Script executed: ```bash printf '%s\n' '--- IMAGE_GET_LOD translation ---' sed -n '630,690p' src/graphics/shader/recompiler/frontend/translate/Memory.cpp rg -n -F -e 'OpImageQueryLod' -e 'ImageQueryLod' -e 'IMAGE_GET_LOD' src/graphics/shader/recompiler/backend src/graphics/shader/recompiler/frontend printf '%s\n' '--- relevant coordinate and opcode definitions ---' sed -n '270,315p' src/graphics/shader/recompiler/frontend/decode/ImageOps.cpp sed -n '680,715p' tests/ShaderRecompilerComputeTests.cpp sed -n '39734,39764p' tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 8434 --- Web query: `Vulkan specification texture sampling mipmapPrecisionBits exact wording LOD calculation mipmap level contribution OpImageQueryLod` Result: ``` <source_evidence> <source kind="open_page"> <title>Limits :: Vulkan Documentation Project</title> <location>https://docs.vulkan.org/spec/latest/chapters/limits.html</location> <excerpt>citeturn930442view1 [wordlim: 200] Crawled: today; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;turn211466search0&quot;,&quot;lineno&quot;:null}); Total lines: 5513 L154: * `maxStorageBufferRange` is the maximum value that can be specified in the `range` member of a 【17†VkDescriptorBufferInfo】 structure passed to 【18†vkUpdateDescriptorSets】 for descriptors of type 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】. If the 【20†`shader64BitIndexing`】 feature is enabled, this limit does not apply. L155: * `maxPushConstantsSize` is the maximum size, in bytes, of the pool of push constant memory. For each of the push constant ranges indicated by the `pPushConstantRanges` member of the 【21†VkPipelineLayoutCreateInfo】 structure, (`offset` + `size`) must be less than or equal to this limit. L156: L157: * `maxMemoryAllocationCount` is the maximum number of device memory allocations, as created by 【22†vkAllocateMemory】, which can simultaneously exist. L158: * `maxSamplerAllocationCount` is the maximum number of sampler objects, as created by 【23†vkCreateSampler】, which can simultaneously exist on a device. If the 【24†`descriptorHeap`】 feature is enabled and the application intends to use embedded samplers, the number advertised here is effectively reduced by the quotient of 【25†`minSamplerHeapReservedRangeWithEmbedded`】 divided by 【26†`samplerDescriptorSize`】, to provide storage for embedded samplers when switching to heaps. L163: * `maxBoundDescriptorSets` is the maximum number of descriptor sets that can be simultaneously used by a pipeline. See 【34†Descriptor Sets】. L164: * `maxPerStageDescriptorSamplers` is the maximum number of samplers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_SAMPLER】 or 【19†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L166: * `maxPerStageDescriptorUniformBuffers` is the maximum number of uniform buffers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L168: * `maxPerStageDescriptorStorageBuffers` is the maximum number of storage buffers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L170: * `maxPerStageDescriptorSampledImages` is the maximum number of sampled images that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】, 【19†VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE】, or 【19†VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L172: * `maxPerStageDescriptorStorageImages` is the maximum number of storage images that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_IMAGE】, or 【19†VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L174: * `maxPerStageDescriptorInputAttachments` is the maximum number of input attachments that can be accessible to a single shader stage in a pipeline layout, as well as the maximum usable input attachment index. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L181: * `maxDescriptorSetSamplers` is the maximum number of samplers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_SAMPLER】 or 【19†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【36†Sampler】 and 【37†Combined Image Sampler】. L182: * `maxDescriptorSetUniformBuffers` is the maximum number of uniform buffers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【38†Uniform Buffer】 and 【39†Dynamic Uniform Buffer】. L183: * `maxDescriptorSetUniformBuffersDynamic` is the maximum number of dynamic uniform buffers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【39†Dynamic Uniform Buffer】. L184: * `maxDescriptorSetStorageBuffers` is the maximum number of storage buffers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【40†Storage Buffer】 and 【41†Dynamic Storage Buffer】. L185: * `maxDescriptorSetStorageBuffersDynamic` is the maximum number of dynamic storage buffers that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【41†Dynamic Storage Buffer】. L186: * `maxDescriptorSetSampledImages` is the maximum number of sampled images that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】, 【19†VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE】, or 【19†VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L187: See 【37†Combined Image Sampler】, 【42†Sampled Image】, and 【43†Uniform Texel Buffer】. L188: * `maxDescriptorSetStorageImages` is the maximum number of storage images that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_STORAGE_IMAGE】, or 【19†VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【44†Storage Image】, and 【45†Storage Texel Buffer】. L189: * `maxDescriptorSetInputAttachments` is the maximum number of input attachments that can be included in a pipeline layout. Descriptors with a type of 【19†VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT】 count against this limit. Only descriptors in descriptor set layouts created without the 【35†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【46†Input Attachment】. L190: * `maxVertexInputAttributes` is the maximum number of vertex input attributes that can be specified for a graphics pipeline. These are described in the array of `VkVertexInputAttributeDescription` structures that are provided at graphics pipeline creation time via the `pVertexAttributeDescriptions` member of the 【48†VkPipelineVertexInputStateCreateInfo】 structure. See 【49†Vertex Attributes】 and 【50†Vertex Input Description】. L191: * `maxVertexInputBindings` is the maximum number of vertex buffers that can be specified for providing vertex attributes to a graphics pipeline. These are described in the array of `VkVertexInputBindingDescription` structures that are provided at graphics pipeline creation time via the `pVertexBindingDescriptions` member of the 【48†VkPipelineVertexInputStateCreateInfo】 structure. The `binding` member of `VkVertexInputBindingDescription` must be less than this limit. See 【50†Vertex Input Description】. L192: * `maxVertexInputAttributeOffset` is the maximum vertex input attribute offset that can be added to the vertex input binding stride. The `offset` member of the `VkVertexInputAttributeDescription` structure must be less than or equal to this limit. See 【50†Vertex Input Description】. L193: * `maxVertexInputBindingStride` is the maximum vertex input binding stride that can be specified in a vertex input binding. The `stride` member of the `VkVertexInputBindingDescription` structure must be less than or equal to this limit. See 【50†Vertex Input Description】. L194: L195: * `maxVertexOutputComponents` is the maximum number of components of output variables which can be output by a vertex shader. See 【51†Vertex Shaders】. L196: * `maxTessellationGenerationLevel` is the maximum tessellation generation level supported by the fixed-function tessellation primitive generator. See 【52†Tessellation】. L197: * `maxTessellationPatchSize` is the maximum patch size, in vertices, of patches that can be processed by the tessellation control shader and tessellation primitive generator. The `patchControlPoints` member of the 【53†VkPipelineTessellationStateCreateInfo】 structure specified at pipeline creation time and the value provided in the `OutputVertices` execution mode of shader modules must be less than or equal to this limit. See 【52†Tessellation】. L198: * `maxTessellationControlPerVertexInputComponents` is the maximum number of components of input variables which can be provided as per-vertex inputs to the tessellation control shader stage. L199: L200: * `maxTessellationControlPerVertexOutputComponents` is the maximum number of components of per-vertex output variables which can be output from the tessellation control shader stage. L201: * `maxTessellationControlPerPatchOutputComponents` is the maximum number of components of per-patch output variables which can be output from the tessellation control shader stage. L202: L203: * `maxTessellationControlTotalOutputComponents` is the maximum total number of components of per-vertex and per-patch output variables which can be output from the tessellation control shader stage. L204: * `maxTessellationEvaluationInputComponents` is the maximum number of components of input variables which can be provided as per-vertex inputs to the tessellation evaluation shader stage. L205: L206: * `maxTessellationEvaluationOutputComponents` is the maximum number of components of per-vertex output variables which can be output from the tessellation evaluation shader stage. L207: * `maxGeometryShaderInvocations` is the maximum invocation count supported for instanced geometry shaders. The value provided in the `Invocations` execution mode of shader modules must be less than or equal to this limit. See 【54†Geometry Shading】. L208: L209: * `maxGeometryInputComponents` is the maximum number of components of input variables which can be provided as inputs to the geometry shader stage. L210: * `maxGeometryOutputComponents` is the maximum number of components of output variables which can be output from the geometry shader stage. L211: L212: * `maxGeometryOutputVertices` is the maximum number of vertices which can be emitted by any geometry shader. L213: L214: * `maxGeometryTotalOutputComponents` is the maximum total number of components of output variables, across all emitted vertices, which can be output from the geometry shader stage. L215: * `maxFragmentInputComponents` is the maximum number of components of input variables which can be provided as inputs to the fragment shader stage. L216: L217: * `maxFragmentOutputAttachments` is the maximum number of output attachments which can be written to by the fragment shader stage. L218: * `maxFragmentDualSrcAttachments` is the maximum number of output attachments which can be written to by the fragment shader stage when blending is enabled and one of the dual source blend modes is in use. See 【55†Dual-Source Blending】 and 【56†`dualSrcBlend`】. L219: L220: * `maxFragmentCombinedOutputResources` is the total number of storage buffers, storage images, and output `Location` decorated color attachments (described in 【57†Fragment Output Interface】) which can be used in the fragment shader stage. L221: * `maxComputeSharedMemorySize` is the maximum total storage size, in bytes, available for variables declared with the `Workgroup` storage class in shader modules (or with the `shared` storage qualifier in GLSL) in the c…[truncated]</excerpt> </source> <source kind="search"> <title>Limits :: Vulkan Documentation Project</title> <location>https://docs.vulkan.org/spec/latest/chapters/limits.html</location> <excerpt>citeturn211466search0 [wordlim: 200] Crawled: 5 days ago; * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions. * `maxDrawIndexedIndexValue` is the maximum index value that can be used for indexed draw calls when using 32-bit indices. Sub-texel values calculated during image sampling will snap to these locations when generating the filtered results. * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions. * `maxDrawIndexedIndexValue` is the maximum index value that can be used for indexed draw calls when using 32-bit indices. This excludes the primitive restart index value of 0xFFFFFFFF. See `fullDrawIndexUint32`. * `maxDrawIndirectCount` is the maximum draw count that is supported for indirect drawing calls. See `multiDrawIndirect`. * `maxSamplerLodBias` is the maximum absolute sampler LOD bias. The sum of the `mipLodBias` member of the VkSamplerCreateInfo structure and the `Bias` operand of image sampling operations in shader modules (or 0 if no `Bias` operand is provided to an image sampling operation) is clamped to the range [-`maxSamplerLodBias`,+`maxSamplerLodBias`]. </excerpt> </source> <source kind="search"> <title>Sampling :: Vulkan Documentation Project</title> <location>https://docs.vulkan.org/spec/latest/chapters/textures.html</location> <excerpt>citeturn211466search1 [wordlim: 200] Crawled: 5 days ago; The LOD must be computed with `mipmapPrecisionBits` of accuracy. ... If the used sampler was created without VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT, `Cube` images ignore the wrap modes specified in the sampler. ## Normalized Texel Coordinate Operations If the image sampler instruction provides normalized texel coordinates, some of the following operations are performed. ### Projection Operation For `Proj` image operations, the normalized texel coordinates (s,t,r,q,a) and (if present) the D_{ref} coordinate are transformed as follows: ### Derivative Image Operations Derivatives are used for LOD selection. These derivatives are either implicit (in an `ImplicitLod` image instruction in a mesh, task, compute, or fragment shader) or explicit (provided explicitly by shader to the image instruction in any shader). For implicit derivatives image instructions, the derivatives of texel coordinates are calculated in the same manner as derivative operations. That is: Partial derivatives not defined above for certain image dimensionalities are set to zero. For explicit LOD image instructions, if the optional SPIR-V operand `Grad` is provided, then the operand values are used for the derivatives. The number of components present in each derivative for a given image dimensionality matches the number of partial derivatives computed above. If the optional SPIR-V operand `Lod` is provided, then derivatives are set to zero, the cube map derivative transformation is skipped, and the scale factor operation is skipped. Instead, the floating-point scalar coordinate is directly assigned to λ_{base} as described in LOD Operation. If the image or sampler object used by an implicit derivative image instruction is not uniform across the quad and `quadDivergentImplicitLod` is not supported, then the derivative and LOD values are undefined. Implicit derivatives are well-defined when the image and sampler and control flow are uniform across the quad, even if they diverge between different quads. If `quadDivergentImplicitLod` is supported, then derivatives and implicit LOD values are well-defined even if the image or sampler object are not uniform within a quad. The derivatives are computed as specified above, and the implicit LOD calculation proceeds for each shader invocation using its respective image and sampler object. ### Cube Map Face Selection and Transformations For cube map image instructions, the (s,t,r) coordinates are treated as a direction vector (r_{x},r_{y},r_{z}). The direction vector is used to select a cube map face. The direction vector is transformed to a per-face texel coordinate system (s_{face},t_{face}). The direction vector is also used to transform the derivatives to per-face derivatives. ### Cube Map Coordinate Transformation ### Cube Map Derivative Transformation The partial derivatives of the Cube Map Coordinate Transformations can be computed as: The other derivatives are simplified similarly, resulting in ### Scale Factor Operation, LOD Operation and Image Level(s) Selection LOD selection can be either explicit (provided explicitly by the image instruction) or implicit (determined from a scale factor calculated from the derivatives). The LOD must be computed with `mipmapPrecisionBits` of accuracy. #### Scale Factor Operation The magnitude of the derivatives are calculated by: m_{ux} = |∂s/∂x| × w_{base} m_{vx} = |∂t/∂x| × h_{base} m_{wx} = |∂r/∂x| × d_{base} m_{uy} = |∂s/∂y| × w_{base} m_{vy} = |∂t/∂y| × h_{base} m_{wy} = |∂r/∂y| × d_{base} where: ∂t/∂x = ∂t/∂y = 0 (for 1D images) ∂r/∂x = ∂r/∂y = 0 (for 1D, 2D, or Cube images) and: w_{base} = image.w h_{base} = image.h d_{base} = image.d (for the `baseMipLevel`, from the image descriptor). For corner-sampled images, the w_{base}, h_{base}, and d_{base} are instead: w_{base} = image.w - 1 h_{base} = image.h - 1 d_{base} = image.d - 1 A point sampled in screen space has an elliptical footprint in texture space. The minimum and maximum scale factors (ρ_{min}, ρ_{max}) should be the minor and major axes of this ellipse. The scale factors ρ_{x} and ρ_{y}, calculated from the magnitude of the derivatives in x and y, are used to compute the minimum and maximum scale factors. ρ_{x} and ρ_{y} may be approximated with functions f_{x} and f_{y}, subject to the following constraints: The minimum and maximum scale factors (ρ_{min},ρ_{max}) are determined by: ρ_{max} = max(ρ_{x}, ρ_{y}) ρ_{min} = min(ρ_{x}, ρ_{y}) The ratio of anisotropy is determined by: η = min(ρ_{max}/ρ_{min}, max_{Aniso}) where: sampler.max_{Aniso} = `maxAnisotropy` (from sampler descriptor) ## Integer Texel Coordinate Operations Integer texel coordinate operations may supply a LOD which texels are to be read from or written to using the optional SPIR-V operand `Lod`. If the `Lod` is provided then it must be an integer. The image level selected is: If d does not lie in the range [`baseMipLevel`, `baseMipLevel` + `levelCount`) or d is less than minLodInteger_{imageView}, then any values fetched are zero if the `robustImageAccess2` feature is enabled, otherwise are undefined, and any writes (if supported) are discarded. ## Image Sample Operations ### Wrapping Operation If the used sampler was created without VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT, `Cube` images ignore the wrap modes specified in the sampler. Instead, if VK_FILTER_NEAREST is used within a mip level then VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE is used, and if VK_FILTER_LINEAR is used within a mip level then sampling at the edges is performed as described earlier in the Cube map edge handling section. The first integer texel coordinate i is transformed based on the `addressModeU` parameter of the sampler. where: j (for 2D and Cube image) and k (for 3D image) are similarly transformed based on the `addressModeV` and `addressModeW` parameters of the sampler, respectively. ### Texel Gathering SPIR-V instructions with `Gather` in the name return a vector derived from 4 texels in the base level of the image view. The rules for the VK_FILTER_LINEAR minification filter are applied to identify the four selected texels for `OpImage*Gather` , and `OpImageGatherQCOM` with modes `GatherH2QCOM` and `GatherV2QCOM` . If an `OpImage*Gather` operation does not use the `ConstOffsets` image operand then the four texels form the 2 × 2 rectangle used for texture filtering: If an `OpImage*Gather` operation uses the `ConstOffsets` image operand then the offsets allow a custom filter to be defined: If an `OpImageGatherQCOM` operation has a `Mode` equal to `GatherH2QCOM` or `GatherV2QCOM`, then it uses a predefined set of `ConstOffsets`. The offsets used for `GatherH2QCOM` are: The offsets used for `GatherV2QCOM` are: The rules for the VK_FILTER_NEAREST minification filter are applied to identify the origin texel \tau_{{ij}} for `OpImageGatherQCOM` with modes equal to `Gather4x1QCOM` and `GatherDQCOM`. The filter used for these modes is defined as: The offsets used for `Gather4x1QCOM` are: The offsets used for `GatherDQCOM` are: where: Each texel is then converted to an RGBA value according to component substitution and then swizzled. `OpImage*Gather` and `OpImageGatherQCOM` must not be used on a sampled image with sampler Y′C_{B}C_{R} conversion enabled. If level_{base} &lt; minLodInteger_{imageView}, then any values fetched are zero if the `robustImageAccess2` feature is enabled. Otherwise values are undefined. #### Texel Range Clamp When `reductionMode` is VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_RANGECLAMP_QCOM, the weighted average is clamped to be within the component-wise minimum and maximum of the set of texels with non-zero weights. #### Texel Mipmap Filtering VK_SAMPLER_MIPMAP_MODE_NEAREST filtering returns the value of a single mipmap level, τ = τ[d]. VK_SAMPLER_MIPMAP_MODE_LINEAR filtering combines the values of multiple mipmap levels (τ[hi] and τ[lo]), together with their linear weights. The linear weights are derived from the fraction computed earlier: The values of multiple mipmap levels, together with their weights, are combined to produce a final filtered value. The VkSamplerReductionModeCreateInfo::`reductionMode` can control the process by which multiple texels, together with their weights, are combined to produce a filtered texture value. When the `reductionMode` is set (explicitly or implicitly) to VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE, a weighted average is computed: ## Texel Footprint Evaluation The SPIR-V instruction `OpImageSampleFootprintNV` evaluates the set of texels from a single mip level that would be accessed during a texel filtering operation. In addition to the inputs that would be accepted by an equivalent `OpImageSample*` instruction, `OpImageSampleFootprintNV` accepts two additional inputs. The `Granularity` input is an integer identifying the size of texel groups used to evaluate the footprint. Each bit in the returned footprint mask corresponds to an aligned block of texels whose size is given by the following table: Table 5. Texel Footprint Granularity Values `Granularity` | `Dim` = 2D | `Dim` = 3D --- | --- | --- 0 | unsupported | unsupported 1 | 2x2 | 2x2x2 2 | 4x2 | unsupported 3 | 4x4 | 4x4x2 4 | 8x4 | unsupported 5 | 8x8 | unsupported 6 | 16x8 | unsupported 7 | 16x16 | unsupported 8 | unsupported | unsupported 9 | unsupported | unsupported 10 | unsupported | 16x16x16 11 | 64x64 | 32x16x16 12 | 128x64 | 32x32x16 13 | 128x128 | 32x32x32 14 | 256x128 | 64x32x32 15 | 256x256 | unsupported The `Coarse` input is used to select between the two mip levels that may be accessed during texel filtering when using a `mipmapMode` of VK_SAMPLER_MIPMAP_MODE_LINEAR. When filtering between two mip levels, a `Coarse` value of `true` requests the footprint in the lower-resolution mip level (higher level number), while `false` requests the footprint in the higher-resolution mip level. If texel filtering would access only a single mip level, the footprint in that level would be returned when `Coarse` is `false`; an empty footprint would be returned when `Coarse` is `true`. The footprint for `OpImageSampleFootprintNV` is returned in a structure with six members: * The first member is a boolean value that is true if the texel filtering operation would access only a single mip level. * The second member is a two- or three-component integer vector holding the footprint anchor location. For two-dimensional images, the returned components are in units of eight texel groups. </excerpt> </source> <source kind="search"> <title>Vulkan® 1.4.351 - A Specification (with all ratified extensions)</title> <location>https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf</location> <excerpt>citeturn211466search13 [wordlim: 200] Published: 5 months ago; OpImageQueryLod returns the LOD parameters that would be used in a sampling instruction with the given image and coordinates. - Array Layer Selection: Performed by all OpImageSample, OpImageSparseSample, and OpImage*Gather instructions. - Texel Gathering: Performed by OpImage*Gather instructions. - Texel Filtering: Performed by all OpImageSample* and OpImageSparseSample* instructions. - Sparse Residency: Performed by all OpImageSparse* instructions. ## 20.8. LOD Query OpImageQueryLod returns the LOD parameters that would be used in a sampling instruction with the given image and coordinates. If the descriptor that would be accessed is a null descriptor then (0,0) is returned. Otherwise, the steps described in this chapter are performed as if for OpImageSampleImplicitLod, up to Scale Factor Operation, LOD Operation and Image Level(s) Selection. The return value is the vector (λ′, d_l - level_base). These values may be subject to implementation-specific maxima and minima for very large, out-of-range values.</excerpt> </source> <source kind="search"> <title>Vulkan® 1.4.349 - A Specification (with all registered extensions)</title> <location>https://registry.khronos.org/vulkan/specs/latest/pdf/vkspec.pdf</location> <excerpt>citeturn211466search12 [wordlim: 200] Published: 6 months ago; - Derivative Image Operations, Cube Map Operations, Scale Factor Operation, LOD Operation and Image Level(s) Selection, and Texel Anisotropic Filtering: Performed by all `OpImageSample*` and `OpImageSparseSample*` instructions. ... `OpImageQueryLod` returns the LOD parameters that would be used in a sampling instruction with the given image and coordinates. - Texel Gathering: Performed by `OpImage*Gather` instructions. - Texel Footprint Evaluation: Performed by `OpImageSampleFootprint` instructions. - Texel Filtering: Performed by all `OpImageSample*` and `OpImageSparseSample*` instructions. - Sparse Residency: Performed by all `OpImageSparse*` instructions. - `(s,t,r,q,a)` to `(u,v,w,a)` Transformation, Wrapping, and Weight Image Sampling: Performed by `OpImageWeightedSample*` instructions. - `(s,t,r,q,a)` to `(u,v,w,a)` Transformation, Wrapping, and Block Matching: Performed by `OpImageBlockMatch*` instructions. - `(s,t,r,q,a)` to `(u,v,w,a)` Transformation, Wrapping, and Box Filter Sampling: Performed by `OpImageBoxFilter*` instructions. ## 20.12. LOD Query `OpImageQueryLod` returns the LOD parameters that would be used in a sampling instruction with the given image and coordinates. If the descriptor that would be accessed is a null descriptor then `(0,0)` is returned. Otherwise, the steps described in this chapter are performed as if for `OpImageSampleImplicitLod`, up to Scale Factor Operation, LOD Operation and Image Level(s) Selection. The return value is the vector `(λ&#39;, d_l - level_base)`. These values may be subject to implementation-specific maxima and minima for very large, out-of-range values. If the image is a weight image, the value returned by `OpImageQueryLod` is undefined.</excerpt> </source> <omitted_sources count="18">Additional source records were omitted from this bounded result.</omitted_sources> </source_evidence> Citations: - 1: https://docs.vulkan.org/spec/latest/chapters/limits.html - 2: https://docs.vulkan.org/spec/latest/chapters/textures.html?utm_source=openai - 3: https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf?utm_source=openai ``` --- Web query: `Vulkan texture specification "LOD must be computed with mipmapPrecisionBits of accuracy" LOD Operation rounding exact integer lambda` Result: ``` <source_evidence> <source kind="open_page"> <title>VkPhysicalDeviceLimits(3)</title> <location>https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPhysicalDeviceLimits.html</location> <excerpt>citeturn226468view2 [wordlim: 200] Crawled: 3 days ago; Content type: text/html; Source: open({&quot;ref_id&quot;:&quot;turn215248search6&quot;,&quot;lineno&quot;:null}); Total lines: 301 L125: * `maxImageDimensionCube` is the largest dimension (`width` or `height`) that is guaranteed to be supported for all images created with an `imageType` of 【2†VK_IMAGE_TYPE_2D】 and with 【4†VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT】 set in `flags`. Some combinations of image parameters (format, usage, etc.) may allow support for larger dimensions, which can be queried using 【3†vkGetPhysicalDeviceImageFormatProperties】. L126: L127: * `maxImageArrayLayers` is the maximum number of layers (`arrayLayers`) for an image. L128: * `maxTexelBufferElements` is the maximum number of addressable texels for a buffer view created on a buffer which was created with the 【5†VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT】 or 【5†VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT】 usage flag set. L129: * `maxUniformBufferRange` is the maximum value that can be specified in the `range` member of a 【6†VkDescriptorBufferInfo】 structure passed to 【7†vkUpdateDescriptorSets】 for descriptors of type 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】. L130: * `maxStorageBufferRange` is the maximum value that can be specified in the `range` member of a 【6†VkDescriptorBufferInfo】 structure passed to 【7†vkUpdateDescriptorSets】 for descriptors of type 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】. L131: * `maxPushConstantsSize` is the maximum size, in bytes, of the pool of push constant memory. For each of the push constant ranges indicated by the `pPushConstantRanges` member of the 【9†VkPipelineLayoutCreateInfo】 structure, (`offset` + `size`) must be less than or equal to this limit. L132: L133: * `maxMemoryAllocationCount` is the maximum number of device memory allocations, as created by 【10†vkAllocateMemory】, which can simultaneously exist. L134: * `maxSamplerAllocationCount` is the maximum number of sampler objects, as created by 【11†vkCreateSampler】, which can simultaneously exist on a device. L135: L136: * `bufferImageGranularity` is the granularity, in bytes, at which buffer or linear image resources, and optimal image resources can be bound to adjacent offsets in the same `VkDeviceMemory` object without aliasing. See 【12†Buffer-Image Granularity】 for more details. L137: * `sparseAddressSpaceSize` is the total amount of address space available, in bytes, for sparse memory resources. This is an upper bound on the sum of the sizes of all sparse resources, regardless of whether any memory is bound to them. L138: L139: * `maxBoundDescriptorSets` is the maximum number of descriptor sets that can be simultaneously used by a pipeline. See 【13†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#descriptors-sets】. L140: * `maxPerStageDescriptorSamplers` is the maximum number of samplers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_SAMPLER】 or 【8†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L141: A descriptor is accessible to a shader stage when the `stageFlags` member of the `VkDescriptorSetLayoutBinding` structure has the bit for that shader stage set. See 【15†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#descriptors-sampler】 and 【16†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#descriptors-combinedimagesampler】. L142: * `maxPerStageDescriptorUniformBuffers` is the maximum number of uniform buffers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L144: * `maxPerStageDescriptorStorageBuffers` is the maximum number of storage buffers that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L146: * `maxPerStageDescriptorSampledImages` is the maximum number of sampled images that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】, 【8†VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE】, or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L149: * `maxPerStageDescriptorStorageImages` is the maximum number of storage images that can be accessible to a single shader stage in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_IMAGE】, or 【8†VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L151: * `maxPerStageDescriptorInputAttachments` is the maximum number of input attachments that can be accessible to a single shader stage in a pipeline layout, as well as the maximum usable input attachment index. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L153: Note | `maxPerStageDescriptorInputAttachments` was originally only intended to limit the number of attachments per stage, not the number of available input indices across all shaders in a render pass. The input indices were allowed to be semi arbitrary for render pass objects, however some implementations have fixed limits for them. Applications already exist that exceed this limit, and they will continue to work where they already did, but will fail to render on some platforms. L155: * `maxPerStageResources` is the maximum number of resources that can be accessible to a single shader stage in a pipeline layout. L158: * `maxDescriptorSetSamplers` is the maximum number of samplers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_SAMPLER】 or 【8†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L160: * `maxDescriptorSetUniformBuffers` is the maximum number of uniform buffers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L162: * `maxDescriptorSetUniformBuffersDynamic` is the maximum number of dynamic uniform buffers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L164: * `maxDescriptorSetStorageBuffers` is the maximum number of storage buffers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER】 or 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L166: * `maxDescriptorSetStorageBuffersDynamic` is the maximum number of dynamic storage buffers that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L168: * `maxDescriptorSetSampledImages` is the maximum number of sampled images that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER】, 【8†VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE】, or 【8†VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L170: * `maxDescriptorSetStorageImages` is the maximum number of storage images that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_STORAGE_IMAGE】, or 【8†VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. L172: * `maxDescriptorSetInputAttachments` is the maximum number of input attachments that can be included in a pipeline layout. Descriptors with a type of 【8†VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT】 count against this limit. Only descriptors in descriptor set layouts created without the 【14†VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT】 bit set count against this limit. See 【25†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#descriptors-inputattachment】. L173: * `maxVertexInputAttributes` is the maximum number of vertex input attributes that can be specified for a graphics pipeline. These are described in the array of `VkVertexInputAttributeDescription` structures that are provided at graphics pipeline creation time via the `pVertexAttributeDescriptions` member of the 【26†VkPipelineVertexInputStateCreateInfo】 structure. L174: See 【27†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-attrib】 and 【28†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-input】. L175: * `maxVertexInputBindings` is the maximum number of vertex buffers that can be specified for providing vertex attributes to a graphics pipeline. These are described in the array of `VkVertexInputBindingDescription` structures that are provided at graphics pipeline creation time via the `pVertexBindingDescriptions` member of the 【26†VkPipelineVertexInputStateCreateInfo】 structure. The `binding` member of `VkVertexInputBindingDescription` must be less than this limit. L176: See 【28†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-input】. L177: * `maxVertexInputAttributeOffset` is the maximum vertex input attribute offset that can be added to the vertex input binding stride. The `offset` member of the `VkVertexInputAttributeDescription` structure must be less than or equal to this limit. See 【28†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-input】. L178: * `maxVertexInputBindingStride` is the maximum vertex input binding stride that can be specified in a vertex input binding. The `stride` member of the `VkVertexInputBindingDescription` structure must be less than or equal to this limit. See 【28†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#fxvertex-input】. L179: * `maxVertexOutputComponents` is the maximum number of components of output variables which can be output by a vertex shader. See 【29†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#shaders-vertex】. L180: L181: * `maxTessellationGenerationLevel` is the maximum tessellation generation level supported by the fixed-function tessellation primitive generator. See 【30†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#tessellation】. L182: * `maxTessellationPatchSize` is the maximum patch size, in vertices, of patches that can be processed by the tessellation control shader and tessellation primitive generator. The `patchControlPoints` member of the 【31†VkPipelineTessellationStateCreateInfo】 structure specified at pipeline creation time and the value provided in the `OutputVertices` execution mode of shader modules must be less than or equal to this limit. L183: See 【30†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#tessellation】. L184: * `maxTessellationControlPerVertexInputComponents` is the maximum number of components of input variables which can be provided as per-vertex inputs to the tessellation control shader stage. L185: L186: * `maxTessellationControlPerVertexOutputComponents` is the maximum number of components of per-vertex output variables which can be output from the tessellation control shader stage. L187: * `maxTessellationControlPerPatchOutputComponents` is the maximum number of components of per-patch output variables which can be output from the tessellation control shader stage. L188: L189: * `maxTessellationControlTotalOutputComponents` is the maximum total number of components of per-vertex and per-patch output variables which can be output from the tessellation control shader stage. L190: * `maxTessellationEvaluationInputComponents` is the maximum number of components of input variables which can be provided as per-vertex inputs to the tessellation evaluation shader stage. L191: L192: * `maxTessellationEvaluationOutputComponents` is the maximum number of components of per-vertex output variables which can be output from the tessellation evaluation shader stage. L193: * `maxGeometryShaderInvocations` is the maximum invocation count supported for instanced geometry shaders. The value provided in the `Invocations` execution mode of shader modules must be less than or equal to this limit. See 【32†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#geometry】. L194: L195: * `maxGeometryInputComponents` is the maximum number of components of input variables which can be provided as inputs to the geometry shader stage. L196: * `maxGeometryOutputComponents` is the maximum number of components of output variables which can be output from the geometry shader stage. L197: L198: * `maxGeometryOutputVertices` is the maximum number of vertices which can be emitted by any geometry shader. L199: L200: * `maxGeometryTotalOutputComponents` is the maximum total number of components of output variables, across all emitted vertices, which can be output from the geometry shader stage. L201: * `maxFragmentInputComponents` is the maximum number of components of input variables which can be provided as inputs to the fragment shader stage. L202: L203: * `maxFragmentOutputAttachments` is the maximum number of output attachments which can be written to by the fragment shader stage. L204: * `maxFragmentDualSrcAttachments` is the maximum number of output attachments which can be written to by the fragment shader stage when blending is enabled and one of the dual source blend modes is in use. See 【33†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#framebuffer-dsb】 and 【34†`dualSrcBlend`】. L205: * `maxFragmentCombinedOutputResources` is the total number of storage buffers, storage images, and output `Location` decorated color attachments (described in 【35†Fragment Output Interface】) which can be used in the fragment shader stage. L206: L207: * `maxComputeSharedMemorySize` is the maximum total storage size, in bytes, available for variables declared with the `Workgroup` storage class in shader modules (or with the `shared` storage qualifier in GLSL) in the compute shader stage. L208: * `maxComputeWorkGroupCount`[3] is the maximum number of local workgroups that can be dispatched by a single dispatching command. These three values represent the maximum number of local workgroups for the X, Y, and Z dimensions, respectively. The workgroup count parameters to the dispatching commands must be less than or equal to the corresponding limit. See 【36†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#dispatch】. L209: * `maxComputeWorkGroupInvocations` is the maximum total number of compute shader invocations in a single local workgroup. The product of the X, Y, and Z sizes, as specified by the `LocalSize` execution mode in shader modules or by the object decorated by the `WorkgroupSize` decoration, must be less than or equal to this limit. L210: * `maxComputeWorkGroupSize`[3] is the maximum size of a local compute workgroup, per dimension. These three values represent the maximum local workgroup size in the X, Y, and Z dimensions, respectively. The `x`, `y`, and `z` sizes, as specified by the `LocalSize` execution mode or by the object decorated by the `WorkgroupSize` decoration in shader modules, must be less than or equal to the corresponding limit. L211: * `subPixelPrecisionBits` is the number of bits of subpixel precision in framebuffer coordinates x_{f} and y_{f}. See 【37†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#primsrast】. L212: * `subTexelPrecisionBits` is the number of bits of precision in the division along an axis of an image used for minification and magnification filters. 2^{`subTexelPrecisionBits`} is the actual number of divisions along each axis of the image represented. Sub-texel values calculated during image sampling will snap to these locations when generating the filtered results. L213: * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions. L214: L215: * `maxDrawIndexedIndexValue` is the maximum index value that can be used for indexed draw calls when using 32-bit indices. This excludes the primitive restart index value of 0xFFFFFFFF. See 【38†`fullDrawIndexUint32`】. L216: * `maxDrawIndirectCount` is the maximum draw count that is supported for indirect drawing calls. See 【39†`multiDrawIndirect`】. L217: * `maxSamplerLodBias` is the maximum absolute sampler LOD bias. The sum of the `mipLodBias` member of the 【40†VkSamplerCreateInfo】 structure and the `Bias` operand of image sampling operations in shader modules (or 0 if no `Bias` operand is provided to an image sampling operation) are clamped to the range [-`maxSamplerLodBias`,+`maxSamplerLodBias`]. See 【41†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#samplers-mipLodBias】. L218: * `maxSamplerAnisotropy` is the maximum degree of sampler anisotropy. The maximum degree of anisotropic filtering used for an image sampling operation is the minimum of the `maxAnisotropy` member of the 【40†VkSamplerCreateInfo】 structure and this limit. See 【42†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#samplers-maxAnisotropy】. L219: * `maxViewports` is the maximum number of active viewports. The `viewportCount` member of the 【43†VkPipelineViewportStateCreateInfo】 structure that is provided at pipeline creation must be less than or equal to this limit. L220: * `maxViewportDimensions`[2] are the maximum viewport dimensions in the X (width) and Y (height) dimensions, respectively. The maximum viewport dimensions must be greater than or equal to the largest image which can be created and used as a framebuffer attachment. See 【44†Controlling the Viewport】. L221: * `viewportBoundsRange`[2] is the [minimum, maximum] range that the corners of a viewport must be contained in. This range must be at least [-2 × `size`, 2 × `size` - 1], where `size` = max(`maxViewportDimensions`[0], `maxViewportDimensions`[1]). See 【44†Controlling the Viewport】. L222: Note | The wide range of values required for `viewportBoundsRange` allows the viewport to be arbitrarily shifted relative to the output render target while still partially overlapping. However, the minimum range required to achieve this would actually be [-`size` + 1, 2 × `size` - 1]. As these limits in implementations are typically simple power-of-two values, the specification reflects this convention, rounding the lower bound accordingly. L223: * `viewportSubPixelBits` is the number of bits of subpixel precision for viewport bounds. The subpixel precision that floating-point viewport bounds are interpreted at is given by this limit. L224: * `minMemoryMapAlignment` is the minimum required alignment, in bytes, of host visible memory allocations within the host address space. When mapping a memory allocation with 【45†vkMapMemory】, subtracting `offset` bytes from the returned pointer will always produce an integer multiple of this limit. See 【46†https://registry.khronos.org/vulkansc/specs/1.0-extensions/html/vkspec.html#memory-device-hostaccess】. The value must be a power of two. L225: * `minTexelBufferOffsetAlignment` is the minimum required alignment, in bytes, for the `offset` member of the 【47†VkBufferViewCreateInfo】 structure for texel buffers. The value must be a power of two. L226: This limit is equivalent to the maximum of the 【48†`uniformTexelBufferOffsetAlignmentBytes`】 and 【49†`storageTexelBufferOffsetAlignmentBytes`】 members of 【50†VkPhysicalDeviceTexelBufferAlignmentProperties】, but smaller alignment is optionally allowed by 【51†`storageTexelBufferOffsetSingleTexelAlignment`】 and 【52†`uniformTexelBufferOffsetSingleTexelAlignment`】. L227: For …[truncated]</excerpt> </source> <source kind="search"> <title>Vulkan® 1.4.351 - A Specification (with all ratified extensions)</title> <location>https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf</location> <excerpt>citeturn215248search12 [wordlim: 200] Published: 5 months ago; The LOD must be computed with `mipmapPrecisionBits` of accuracy. The other derivatives are simplified similarly, resulting in \[ \frac{\partial s_{face}}{\partial y} = \frac{1}{2}\times\left(\frac{|r_c|\times \partial s_c/\partial y - s_c\times \partial r_c/\partial y}{(r_c)^2}\right) \] \[ \frac{\partial t_{face}}{\partial x} = \frac{1}{2}\times\left(\frac{|r_c|\times \partial t_c/\partial x - t_c\times \partial r_c/\partial x}{(r_c)^2}\right) \] \[ \frac{\partial t_{face}}{\partial y} = \frac{1}{2}\times\left(\frac{|r_c|\times \partial t_c/\partial y - t_c\times \partial r_c/\partial y}{(r_c)^2}\right) \] ## 20.3.7. Scale Factor Operation, LOD Operation and Image Level(s) Selection LOD selection can be either explicit (provided explicitly by the image instruction) or implicit (determined from a scale factor calculated from the derivatives). The LOD must be computed with `mipmapPrecisionBits` of accuracy. ### Scale Factor Operation The magnitude of the derivatives are calculated by: \[ m_{ux} = |\partial s/\partial x| \times w_{base} \] \[ m_{vx} = |\partial t/\partial x| \times h_{base} \] \[ m_{wx} = |\partial r/\partial x| \times d_{base} \] \[ m_{uy} = |\partial s/\partial y| \times w_{base} \] \[ m_{vy} = |\partial t/\partial y| \times h_{base} \] \[ m_{wy} = |\partial r/\partial y| \times d_{base} \] where:</excerpt> </source> <source kind="search"> <title>Sampling :: Vulkan Documentation Project</title> <location>https://docs.vulkan.org/spec/latest/chapters/textures.html</location> <excerpt>citeturn215248search0 [wordlim: 200] Crawled: 5 days ago; * The sampler was created with `flags` containing VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT and is used with a function that is not `OpImageSampleImplicitLod` or `OpImageSampleExplicitLod`, or is used with operands `Offset` or `ConstOffsets`. ... The derivatives are computed as specified above, and the implicit LOD calculation proceeds for each shader invocation using its respective image and sampler object. ... δ is the fractional value, quantized to the number of mipmap precision bits, used for linear filtering between levels. If the optional SPIR-V operand `Lod` is provided, then derivatives are set to zero, the cube map derivative transformation is skipped, and the scale factor operation is skipped. Instead, the floating-point scalar coordinate is directly assigned to λ_{base} as described in LOD Operation. If the image or sampler object used by an implicit derivative image instruction is not uniform across the quad and `quadDivergentImplicitLod` is not supported, then the derivative and LOD values are undefined. Implicit derivatives are well-defined when the image and sampler and control flow are uniform across the quad, even if they diverge between different quads. If `quadDivergentImplicitLod` is supported, then derivatives and implicit LOD values are well-defined even if the image or sampler object are not uniform within a quad. The derivatives are computed as specified above, and the implicit LOD calculation proceeds for each shader invocation using its respective image and sampler object. ### Cube Map Face Selection and Transformations For cube map image instructions, the (s,t,r) coordinates are treated as a direction vector (r_{x},r_{y},r_{z}). The direction vector is used to select a cube map face. The direction vector is transformed to a per-face texel coordinate system (s_{face},t_{face}). The direction vector is also used to transform the derivatives to per-face derivatives. #### LOD Operation The LOD parameter λ is computed as follows: where: and maxSamplerLodBias is the value of the VkPhysicalDeviceLimits feature `maxSamplerLodBias`. #### Image Level(s) Selection The image level(s) d, d_{hi}, and d_{lo} which texels are read from are determined by an image-level parameter d_{l}, which is computed based on the LOD parameter, as follows: where: and: `baseMipLevel` and `levelCount` are taken from the `subresourceRange` of the image view. minLod_{imageView} must be less than or equal to level_{base} q. If the sampler’s `mipmapMode` is VK_SAMPLER_MIPMAP_MODE_NEAREST, then the level selected is d = d_{l}. If the sampler’s `mipmapMode` is VK_SAMPLER_MIPMAP_MODE_LINEAR, two neighboring levels are selected: δ is the fractional value, quantized to the number of mipmap precision bits, used for linear filtering between levels. </excerpt> </source> <source kind="search"> <title>VkPhysicalDeviceLimits(3)</title> <location>https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPhysicalDeviceLimits.html</location> <excerpt>citeturn215248search6 [wordlim: 200] Crawled: 3 months ago; * `mipmapPrecisionBits` is the number of bits of division that the LOD calculation for mipmap fetching get snapped to when determining the contribution from each mip level to the mip filtered results. 2^{`mipmapPrecisionBits`} is the actual number of divisions. </excerpt> </source> <source kind="search"> <title>Vulkan® SC 1.0.21 - A Specification (with all ratified Vulkan SC extensions) : Based on Vulkan 1.2.344</title> <location>https://registry.khronos.org/VulkanSC/specs/latest-ratified/pdf/vkspec.pdf</location> <excerpt>citeturn215248search13 [wordlim: 200] The LOD must be computed with mipmapPrecisionBits of accuracy. s&lt;sub&gt;face&lt;/sub&gt; = 1/2 × s&lt;sub&gt;c&lt;/sub&gt; / |r&lt;sub&gt;c&lt;/sub&gt;| + 1/2 t&lt;sub&gt;face&lt;/sub&gt; = 1/2 × t&lt;sub&gt;c&lt;/sub&gt; / |r&lt;sub&gt;c&lt;/sub&gt;| + 1/2 17.3.6. Cube Map Derivative Transformation The partial derivatives of the Cube Map Coordinate Transformations can be computed as: ∂s&lt;sub&gt;face&lt;/sub&gt; / ∂x = ∂/∂x (1/2 × s&lt;sub&gt;c&lt;/sub&gt; / |r&lt;sub&gt;c&lt;/sub&gt;| + 1/2) = 1/2 × ∂/∂x (s&lt;sub&gt;c&lt;/sub&gt; / |r&lt;sub&gt;c&lt;/sub&gt;|) = 1/2 × (|r&lt;sub&gt;c&lt;/sub&gt;| × ∂s&lt;sub&gt;c&lt;/sub&gt; / ∂x − s&lt;sub&gt;c&lt;/sub&gt; × ∂r&lt;sub&gt;c&lt;/sub&gt; / ∂x) / (r&lt;sub&gt;c&lt;/sub&gt;)&lt;sup&gt;2&lt;/sup&gt; The other derivatives are simplified similarly, resulting in ∂s&lt;sub&gt;face&lt;/sub&gt; / ∂y = 1/2 × (|r&lt;sub&gt;c&lt;/sub&gt;| × ∂s&lt;sub&gt;c&lt;/sub&gt; / ∂y − s&lt;sub&gt;c&lt;/sub&gt; × ∂r&lt;sub&gt;c&lt;/sub&gt; / ∂y) / (r&lt;sub&gt;c&lt;/sub&gt;)&lt;sup&gt;2&lt;/sup&gt; ∂t&lt;sub&gt;face&lt;/sub&gt; / ∂x = 1/2 × (|r&lt;sub&gt;c&lt;/sub&gt;| × ∂t&lt;sub&gt;c&lt;/sub&gt; / ∂x − t&lt;sub&gt;c&lt;/sub&gt; × ∂r&lt;sub&gt;c&lt;/sub&gt; / ∂x) / (r&lt;sub&gt;c&lt;/sub&gt;)&lt;sup&gt;2&lt;/sup&gt; ∂t&lt;sub&gt;face&lt;/sub&gt; / ∂y = 1/2 × (|r&lt;sub&gt;c&lt;/sub&gt;| × ∂t&lt;sub&gt;c&lt;/sub&gt; / ∂y − t&lt;sub&gt;c&lt;/sub&gt; × ∂r&lt;sub&gt;c&lt;/sub&gt; / ∂y) / (r&lt;sub&gt;c&lt;/sub&gt;)&lt;sup&gt;2&lt;/sup&gt; 17.3.7. Scale Factor Operation, LOD Operation and Image Level(s) Selection LOD selection can be either explicit (provided explicitly by the image instruction) or implicit (determined from a scale factor calculated from the derivatives). The LOD must be computed with mipmapPrecisionBits of accuracy. Scale Factor Operation The magnitude of the derivatives are calculated by:</excerpt> </source> <omitted_sources count="24">Additional source records were omitted from this bounded result.</omitted_sources> </source_evidence> Citations: - 1: https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPhysicalDeviceLimits.html - 2: https://docs.vulkan.org/spec/latest/chapters/textures.html?utm_source=openai - 3: https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf?utm_source=openai ``` --- </dd> </dl> </details> **Use a tolerance compatible with `mipmapPrecisionBits`.** `IMAGE_GET_LOD` emits `OpImageQueryLod`, which performs the implicit LOD calculation. Vulkan permits only four `mipmapPrecisionBits`, while this test accepts an error of at most `1.0f / 64.0f`. A conforming implementation may therefore return a valid LOD near `2.0f` that this test rejects. This is a minor portability issue, not a major regression. The fixed-tolerance pattern already exists, but the harness does not query `mipmapPrecisionBits`. Use a tolerance compatible with the minimum Vulkan precision, or derive it from the device limit. <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d13110f5e7d52c8204e7f740 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Addressed in commit 7ffd3db
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-28 20:19 UTC · original · reviewed

Actionable comments posted: 1


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 2aefa69935 and cfdeb44d97.

Files selected for processing: 3
  • src/graphics/presentation/window/vulkanWindow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-28 20:19 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1686#pullrequestreview-5689135904) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/c67352d5d6dc6fc3fd375deed5c1a89b3e33974e/.coderabbit.yaml>) - **Commit**: [c67352d](<https://github.com/KytyPS5/KytyPS5/commit/c67352d5d6dc6fc3fd375deed5c1a89b3e33974e>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `ded346b9-a035-43f3-89aa-ceb6205451c4` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 2aefa69935d2af111254533e28eb75915f27a7b1 and cfdeb44d973d10b80e7cd5d80ac11af5118efcb8. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 3</summary> <dl> <dd> * `src/graphics/presentation/window/vulkanWindow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=1791acd4-0992-4f46-b2e8-5d97e226d7bd attempt=8645345c-fb73-4194-8b00-2df3a338f094 batch=1/1 -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-28 21:23 UTC · original
On tests/ShaderRecompilerComputeTests.cpp line 39756 (outdated):

@@ -39731,6 +39731,44 @@ TestCase ImageSampleAndGather() {
   return test;
 }
 
+TestCase ImageGetLodComputeLaneQuads(const char *name, u32 width_shift,
+                                     u32 height) {
+  using O = ShaderOpcode;
+  const u32 lanes = (1u << width_shift) * height;
+  std::vector<u32> code;
+  code.push_back(EncodeVop2(0x1b, 20, InlineU32(2), 0));
+  code.push_back(EncodeVop1(0x06, 20, Vgpr(20)));
+  AppendVMovLiteral(&code, 22, 0x3e000000u);
+  code.push_back(EncodeVop2(0x08, 20, Vgpr(20), 22));
+  AppendVMovLiteral(&code, 21, 0x3f000000u);
+  code.push_back(EncodeMimg0(0x60, 0x3));
+  code.push_back(EncodeMimg1(10, 20));
+  code.push_back(EncodeVop2(0x1a, 23, InlineU32(width_shift), 1));
+  code.push_back(EncodeVop2(0x25, 23, Vgpr(0), 23));
+  AppendStoreVgprAtLaneDwordOffset(&code, 10, 23, 0);
+  AppendStoreVgprAtLaneDwordOffset(&code, 11, 23, lanes);
+  AppendEnd(&code);
+
+  TestCase test;
+  test.name = name;
+  test.code = code;
+  test.expected.assign(2 * lanes, 0x40000000u);
+  test.expected_float_tolerance = 1.0f / 64.0f;

Agreed. 7ffd3db2 allows 1/16 (Vulkan's minimum of 4 mipmapPrecisionBits) instead of 1/64. The three cases still pass on the RX 9070 XT (natively and with 32-wide subgroups) and the Ryzen 7600X iGPU, and main's wrong LOD (0.0 or -3.4e38) stays far outside that.

**@⁠Nawid3333** on GitHub · 2026-10-28 21:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1686#discussion_r4406229024) On `tests/ShaderRecompilerComputeTests.cpp` line 39756 (outdated): ```diff @@ -39731,6 +39731,44 @@ TestCase ImageSampleAndGather() { return test; } +TestCase ImageGetLodComputeLaneQuads(const char *name, u32 width_shift, + u32 height) { + using O = ShaderOpcode; + const u32 lanes = (1u << width_shift) * height; + std::vector<u32> code; + code.push_back(EncodeVop2(0x1b, 20, InlineU32(2), 0)); + code.push_back(EncodeVop1(0x06, 20, Vgpr(20))); + AppendVMovLiteral(&code, 22, 0x3e000000u); + code.push_back(EncodeVop2(0x08, 20, Vgpr(20), 22)); + AppendVMovLiteral(&code, 21, 0x3f000000u); + code.push_back(EncodeMimg0(0x60, 0x3)); + code.push_back(EncodeMimg1(10, 20)); + code.push_back(EncodeVop2(0x1a, 23, InlineU32(width_shift), 1)); + code.push_back(EncodeVop2(0x25, 23, Vgpr(0), 23)); + AppendStoreVgprAtLaneDwordOffset(&code, 10, 23, 0); + AppendStoreVgprAtLaneDwordOffset(&code, 11, 23, lanes); + AppendEnd(&code); + + TestCase test; + test.name = name; + test.code = code; + test.expected.assign(2 * lanes, 0x40000000u); + test.expected_float_tolerance = 1.0f / 64.0f; ``` Agreed. 7ffd3db2 allows 1/16 (Vulkan's minimum of 4 `mipmapPrecisionBits`) instead of 1/64. The three cases still pass on the RX 9070 XT (natively and with 32-wide subgroups) and the Ryzen 7600X iGPU, and main's wrong LOD (0.0 or -3.4e38) stays far outside that.
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-28 21:23 UTC · original
On tests/ShaderRecompilerComputeTests.cpp line 39756 (outdated):

@@ -39731,6 +39731,44 @@ TestCase ImageSampleAndGather() {
   return test;
 }
 
+TestCase ImageGetLodComputeLaneQuads(const char *name, u32 width_shift,
+                                     u32 height) {
+  using O = ShaderOpcode;
+  const u32 lanes = (1u << width_shift) * height;
+  std::vector<u32> code;
+  code.push_back(EncodeVop2(0x1b, 20, InlineU32(2), 0));
+  code.push_back(EncodeVop1(0x06, 20, Vgpr(20)));
+  AppendVMovLiteral(&code, 22, 0x3e000000u);
+  code.push_back(EncodeVop2(0x08, 20, Vgpr(20), 22));
+  AppendVMovLiteral(&code, 21, 0x3f000000u);
+  code.push_back(EncodeMimg0(0x60, 0x3));
+  code.push_back(EncodeMimg1(10, 20));
+  code.push_back(EncodeVop2(0x1a, 23, InlineU32(width_shift), 1));
+  code.push_back(EncodeVop2(0x25, 23, Vgpr(0), 23));
+  AppendStoreVgprAtLaneDwordOffset(&code, 10, 23, 0);
+  AppendStoreVgprAtLaneDwordOffset(&code, 11, 23, lanes);
+  AppendEnd(&code);
+
+  TestCase test;
+  test.name = name;
+  test.code = code;
+  test.expected.assign(2 * lanes, 0x40000000u);
+  test.expected_float_tolerance = 1.0f / 64.0f;

@⁠Nawid3333 Thanks. The 1/16 tolerance addresses the precision concern. Your reported GPU results also confirm that the three cases still pass, while the incorrect LOD values from main remain outside the tolerance.


✏️ Learnings added
Learnt from: Nawid3333
Repo: KytyPS5/KytyPS5 PR: 1686
File: tests/ShaderRecompilerComputeTests.cpp:0-0
Timestamp: 2026-10-28T21:23:48.121Z
Learning: Within repository "KytyPS5/KytyPS5", only for files matching one of ["tests/ShaderRecompilerComputeTests.cpp"]: When reviewing implicit LOD query tests in tests/ShaderRecompilerComputeTests.cpp, check that the float tolerance accommodates Vulkan's minimum four mipmapPrecisionBits (1/16), unless the test derives its tolerance from the queried device limit. Also check that the tolerance still rejects the incorrect LOD values the test targets.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


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-28 21:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1686#discussion_r4406233699) On `tests/ShaderRecompilerComputeTests.cpp` line 39756 (outdated): ```diff @@ -39731,6 +39731,44 @@ TestCase ImageSampleAndGather() { return test; } +TestCase ImageGetLodComputeLaneQuads(const char *name, u32 width_shift, + u32 height) { + using O = ShaderOpcode; + const u32 lanes = (1u << width_shift) * height; + std::vector<u32> code; + code.push_back(EncodeVop2(0x1b, 20, InlineU32(2), 0)); + code.push_back(EncodeVop1(0x06, 20, Vgpr(20))); + AppendVMovLiteral(&code, 22, 0x3e000000u); + code.push_back(EncodeVop2(0x08, 20, Vgpr(20), 22)); + AppendVMovLiteral(&code, 21, 0x3f000000u); + code.push_back(EncodeMimg0(0x60, 0x3)); + code.push_back(EncodeMimg1(10, 20)); + code.push_back(EncodeVop2(0x1a, 23, InlineU32(width_shift), 1)); + code.push_back(EncodeVop2(0x25, 23, Vgpr(0), 23)); + AppendStoreVgprAtLaneDwordOffset(&code, 10, 23, 0); + AppendStoreVgprAtLaneDwordOffset(&code, 11, 23, lanes); + AppendEnd(&code); + + TestCase test; + test.name = name; + test.code = code; + test.expected.assign(2 * lanes, 0x40000000u); + test.expected_float_tolerance = 1.0f / 64.0f; ``` <!-- coderabbit-ai-generated:v1 --> @⁠Nawid3333 Thanks. The `1/16` tolerance addresses the precision concern. Your reported GPU results also confirm that the three cases still pass, while the incorrect LOD values from `main` remain outside the tolerance. --- <details> <summary>✏️ Learnings added</summary> <dl> <dd> ``` Learnt from: Nawid3333 Repo: KytyPS5/KytyPS5 PR: 1686 File: tests/ShaderRecompilerComputeTests.cpp:0-0 Timestamp: 2026-10-28T21:23:48.121Z Learning: Within repository "KytyPS5/KytyPS5", only for files matching one of ["tests/ShaderRecompilerComputeTests.cpp"]: When reviewing implicit LOD query tests in tests/ShaderRecompilerComputeTests.cpp, check that the float tolerance accommodates Vulkan's minimum four mipmapPrecisionBits (1/16), unless the test derives its tolerance from the queried device limit. Also check that the tolerance still rejects the incorrect LOD values the test targets. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </dd> </dl> </details> --- <!-- 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=IMAGE_GET_LOD%20tests%20now%20use%20Vulkan%E2%80%99s%20minimum-precision-compatible%201%2F16%20tolerance%E2%80%94portable%20across%20GPUs%20while%20still%20catching%20incorrect%20LODs.%20Try%20%40coderabbitai%20for%20actionable%20code%20reviews!%20%F0%9F%8E%AF&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1686%23discussion_r4405640687)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. <sub><i>You are interacting with an AI system.</i></sub> <!-- This is an auto-generated reply by CodeRabbit -->

Pull request closed

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