Giter VIP home page Giter VIP logo

Comments (1)

greg-lunarg avatar greg-lunarg commented on August 22, 2024

Some input and output arrays are not trimmed by EliminateDead*Components because sometimes it is not safe to do so given the current design.

Input arrays in vertex shaders can always be safely trimmed as with arrIn[] pointed out by @mbechard . Same for output arrays in frag shaders. Any others can potentially break a shader interface given the current design.

EliminateDeadInputComponents (EDIC) and EliminateDeadOutputComponents (EDOC) only operate on one shader at a time. So the workflow has to depend on EDOC and EDIC trimming the same elements on both sides of a shader interface so to not break the interface. In the workflow this can always be guaranteed for structs, but not for arrays. This is because structs can only be indexed with constants, but arrays can be indexed with variables. ED*C cannot trim an array that is indexed with a variable because it has to assume any element might be referenced. So, if on one side of an interface an array is indexed only with constants and on the other side is indexed with a variable, the array may be trimmed differently on either side and break the interface. For this reason EDIC and EDOC do not trim arrays except for the special cases mentioned.

My best idea is to create a new all_array mode in the EDOC and EDOC passes which would trim all arrays with only constant indices. This mode would be controlled with a bool argument. The default would be false.

In order to make sure it is safe to use the all_array mode, I propose new passes called EliminateDeadInputComponentsArraySafe(bool &safe) and EliminateDeadOutputComponentsArraySafe(bool &safe) . These passes would return true if no Input/Output arrays are indexed with variables in the shader. In the workflow, when optimizing shaders A & B, it would be safe to use this new all_array mode if both A & B are ArraySafe. The new all_array mode would need to be used on both shaders.

The control here is fairly coarse-grained (per shader), but since (I believe) it is fairly rare for input/output arrays to be indexed with variables, I don't think this would be too prohibitive. Someone can add more fine-grained control (per array) if it is needed. My design above would be sufficient for this issue.

from spirv-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.