// // Copyright (C) 2018 Google, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // // Neither the name of 3Dlabs Inc. Ltd. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // Post-processing for SPIR-V IR, in internal form, not standard binary form. // #include <cassert> #include <cstdlib> #include <unordered_map> #include <unordered_set> #include <algorithm> #include "SpvBuilder.h" #include "spirv.hpp" namespace spv { #include "GLSL.std.450.h" #include "GLSL.ext.KHR.h" #include "GLSL.ext.EXT.h" #include "GLSL.ext.AMD.h" #include "GLSL.ext.NV.h" #include "GLSL.ext.ARM.h" #include "GLSL.ext.QCOM.h" } namespace spv { // Hook to visit each operand type and result type of an instruction. // Will be called multiple times for one instruction, once for each typed // operand and the result. void Builder::postProcessType(const Instruction& inst, Id typeId) { … } // Called for each instruction that resides in a block. void Builder::postProcess(Instruction& inst) { … } // comment in header void Builder::postProcessCFG() { … } // comment in header void Builder::postProcessFeatures() { … } // SPIR-V requires that any instruction consuming the result of an OpSampledImage // be in the same block as the OpSampledImage instruction. This pass goes finds // uses of OpSampledImage where that is not the case and duplicates the // OpSampledImage to be immediately before the instruction that consumes it. // The old OpSampledImage is left in place, potentially with no users. void Builder::postProcessSamplers() { … } // comment in header void Builder::postProcess(bool compileOnly) { … } }; // end spv namespace