| 1 |
// Copyright (c) 2023 Google LLC. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
#ifndef INCLUDE_SPIRV_TOOLS_EXTRACT_SOURCE_HPP_ |
| 16 |
#define INCLUDE_SPIRV_TOOLS_EXTRACT_SOURCE_HPP_ |
| 17 |
|
| 18 |
#include <stdint.h> |
| 19 |
#include <string> |
| 20 |
#include <unordered_map> |
| 21 |
#include <vector> |
| 22 |
|
| 23 |
// Parse a SPIR-V module, and extracts all HLSL source code from it. |
| 24 |
// This function doesn't lift the SPIR-V code, but only relies on debug symbols. |
| 25 |
// This means if the compiler didn't include some files, they won't show up. |
| 26 |
// |
| 27 |
// Returns a map of <filename, source_code> extracted from it. |
| 28 |
// - `binary`: a vector containing the whole SPIR-V binary to extract source |
| 29 |
// from. |
| 30 |
// - `output`: <filename, source_code> mapping, mapping each filename |
| 31 |
// (if defined) to its code. |
| 32 |
// |
| 33 |
// Returns `true` if the extraction succeeded, `false` otherwise. |
| 34 |
// `output` value is undefined if `false` is returned. |
| 35 |
bool ExtractSourceFromModule( |
| 36 |
const std::vector<uint32_t>& binary, |
| 37 |
std::unordered_map<std::string, std::string>* output); |
| 38 |
|
| 39 |
#endif // INCLUDE_SPIRV_TOOLS_EXTRACT_SOURCE_HPP_ |