/* Copyright (c) 2024 LunarG, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "debug_printf_pass.h" #include "module.h" #include "gpu/shaders/gpu_error_header.h" #include <spirv/unified1/NonSemanticDebugPrintf.h> #include <cstring> #include <iostream> namespace gpu { namespace spirv { // All functions are a list of uint32_t // The difference is just how many are passed in uint32_t DebugPrintfPass::GetLinkFunctionId(uint32_t argument_count) { … } bool DebugPrintfPass::AnalyzeInstruction(const Instruction& inst) { … } // Takes the various arguments and casts them to a valid uint32_t to be passed as a parameter in the function void DebugPrintfPass::CreateFunctionParams(uint32_t argument_id, const Type& argument_type, std::vector<uint32_t>& params, BasicBlock& block, InstructionIt* inst_it) { … } void DebugPrintfPass::CreateFunctionCall(BasicBlockIt block_it, InstructionIt* inst_it) { … } void DebugPrintfPass::CreateDescriptorSet() { … } void DebugPrintfPass::CreateBufferWriteFunction(uint32_t argument_count, uint32_t function_id) { … } // Used between injections of a function void DebugPrintfPass::Reset() { … } bool DebugPrintfPass::Run() { … } void DebugPrintfPass::PrintDebugInfo() { … } // Strictly speaking - the format given in GLSL_EXT_debug_printf is a client side implementation of SPIR-V // NonSemantic.DebugPrintf There is nothing stopping someone from creating a debug printf implementation // that goes `printf("Use this &q to print int", myInt)` but this requires both having // a different HLL and Tool consuming it. // Currently RenderDoc and the Validation Layers both follow the same syntax, but that also could possibly change. // Therefore, we validate these here based on the VVL implementation only bool DebugPrintfPass::Validate(const Function& current_function) { … } } // namespace spirv } // namespace gpu