Skip to content

Update PVMetalViewController.swift - fix ulTron#2404

Merged
JoeMatt merged 3 commits intodevelopfrom
mrjschulte-ulTron-fix
Mar 3, 2025
Merged

Update PVMetalViewController.swift - fix ulTron#2404
JoeMatt merged 3 commits intodevelopfrom
mrjschulte-ulTron-fix

Conversation

@mrjschulte
Copy link
Collaborator

@mrjschulte mrjschulte commented Mar 2, 2025

User description

This adds ulTron back into the Metal CRT shader list


PR Type

Enhancement, Bug fix


Description

  • Reintroduced ulTron shader in the Metal CRT shader list.

  • Adjusted ulTron shader uniform calculations for source and output sizes.

  • Updated logic to enable ulTron shader functionality in PVMetalViewController.


Changes walkthrough 📝

Relevant files
Enhancement
PVMetalViewController.swift
Reintroduced and fixed `ulTron` shader functionality         

PVUI/Sources/PVUIBase/PVGLViewController/PVMetalViewController.swift

  • Re-added ulTron shader case in the shader switch statement.
  • Adjusted ulTron shader uniform calculations for source and output
    sizes.
  • Enabled ulTron shader functionality in rendering pipeline.
  • +5/-15   

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @mrjschulte mrjschulte added metal Related to the Metal GPU path in Provenance. Shaders labels Mar 2, 2025
    @qodo-code-review
    Copy link

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Incorrect Dimensions

    The new sourceSize calculation uses screenRect dimensions instead of inputTexture dimensions, which may cause incorrect shader rendering. The source size should be based on the input texture dimensions.

    let sourceSize = SIMD4<Float>.init(0, 0, Float(screenRect.size.width), Float(screenRect.size.height))
    let outputSize = SIMD4<Float>.init(Float(inputTexture.width), Float(inputTexture.height), Float(view.drawableSize.width), Float(view.drawableSize.height))
    Missing Reciprocals

    The new SIMD4 vectors for sourceSize and outputSize are missing the reciprocal (1.0/size) components that were present in the old code. This could affect shader calculations that rely on these values.

    let sourceSize = SIMD4<Float>.init(0, 0, Float(screenRect.size.width), Float(screenRect.size.height))
    let outputSize = SIMD4<Float>.init(Float(inputTexture.width), Float(inputTexture.height), Float(view.drawableSize.width), Float(view.drawableSize.height))

    @qodo-code-review
    Copy link

    qodo-code-review bot commented Mar 2, 2025

    Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here.

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix incorrect shader size calculation

    The source size calculation for ulTron shader is incorrect. The first two
    components should use the input texture dimensions instead of zero values, as
    these are needed for proper shader calculations.

    PVUI/Sources/PVUIBase/PVGLViewController/PVMetalViewController.swift [1501]

    -let sourceSize = SIMD4<Float>.init(0, 0, Float(screenRect.size.width), Float(screenRect.size.height))
    +let sourceSize = SIMD4<Float>.init(Float(inputTexture.width), Float(inputTexture.height), Float(screenRect.size.width), Float(screenRect.size.height))
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    __

    Why: The suggestion fixes a critical issue where the source size calculation uses incorrect zero values instead of proper texture dimensions, which could cause significant shader rendering problems.

    High
    Fix swapped shader output dimensions

    The output size calculation for ulTron shader swaps input and output dimensions.
    The first two components should use the screen dimensions for proper scaling.

    PVUI/Sources/PVUIBase/PVGLViewController/PVMetalViewController.swift [1502]

    -let outputSize = SIMD4<Float>.init(Float(inputTexture.width), Float(inputTexture.height), Float(view.drawableSize.width), Float(view.drawableSize.height))
    +let outputSize = SIMD4<Float>.init(Float(view.drawableSize.width), Float(view.drawableSize.height), Float(inputTexture.width), Float(inputTexture.height))
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion corrects an important issue where input and output dimensions are swapped in the shader calculations, which would lead to incorrect scaling and rendering artifacts.

    Medium
    • Update

    This adds ulTron back into the Metal CRT shader list
    Clean up header copy+paste double up.
    @JoeMatt JoeMatt force-pushed the mrjschulte-ulTron-fix branch from 3f97cce to c5ba712 Compare March 2, 2025 22:59
    @JoeMatt JoeMatt merged commit 69b7cb6 into develop Mar 3, 2025
    2 of 7 checks passed
    @JoeMatt JoeMatt deleted the mrjschulte-ulTron-fix branch March 3, 2025 00:43
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    metal Related to the Metal GPU path in Provenance. Review effort 2/5 Shaders

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants