Comments (1)
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)
- How to add a new OpName with DescriptorSet and Binding HOT 2
- spirv-opt fma folding causes large performance degradation on Adreno HOT 6
- how to remove the OpVariable inst??
- Implicit LOD functions can be supported when compute shader derivatives are supported HOT 6
- How to compile on arm platform HOT 3
- Disallows TypeManager::GetId on non unique types
- Slang produces spv that works on win/linux but not with MoltenVk
- Incorrect codegen when there is redundant `float16_t` conversion HOT 1
- spirv-opt: loop unroll pass with shader produces spirv-val failure
- Generator comment in spirv-dis output is failing to look up name from spir-v.xml HOT 5
- Inability to use system versions of dependencies. HOT 1
- spirv-tools build is failing for gcc 12.4 HOT 4
- SPIRV-Tools-toolsTargets.cmake references spirv-objdump but the file does not exist HOT 4
- spirv-opt unable to eliminate dead loads from raytracing library HOT 4
- spirv-link generates invalid debug ids with non semantic shader debug info HOT 2
- Change to CMake install rule for the include directory? HOT 1
- assert when calling SpirvToolsAnalyzeDeadOutputStores()
- SSARewriter needs to handle id overflows
- MSVC on arm64 generates incorrect code for function size_t spvtools::utils::CountSetBits(T word) with T=uint32_t
- OpSampledImage extra validation check does not properly handle shadow samplers. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spirv-tools.