blob: 807aa9f69653482e563d1f5d7c09846d85f18744 [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001// Copyright 2020 The Dawn & Tint Authors
James Price8f9ea962023-05-04 01:31:36 +00002//
Austin Engcc2516a2023-10-17 20:57:54 +00003// Redistribution and use in source and binary forms, with or without
4// modification, are permitted provided that the following conditions are met:
James Price8f9ea962023-05-04 01:31:36 +00005//
Austin Engcc2516a2023-10-17 20:57:54 +00006// 1. Redistributions of source code must retain the above copyright notice, this
7// list of conditions and the following disclaimer.
James Price8f9ea962023-05-04 01:31:36 +00008//
Austin Engcc2516a2023-10-17 20:57:54 +00009// 2. Redistributions in binary form must reproduce the above copyright notice,
10// this list of conditions and the following disclaimer in the documentation
11// and/or other materials provided with the distribution.
12//
13// 3. Neither the name of the copyright holder nor the names of its
14// contributors may be used to endorse or promote products derived from
15// this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
James Price8f9ea962023-05-04 01:31:36 +000027
James Price2280cc62023-07-21 03:42:48 +000028#ifndef SRC_TINT_LANG_SPIRV_WRITER_WRITER_H_
29#define SRC_TINT_LANG_SPIRV_WRITER_WRITER_H_
James Price8f9ea962023-05-04 01:31:36 +000030
James Price85b138e2023-08-01 13:18:35 +000031#include <string>
32
dan sinclair24b81092023-11-21 16:02:47 +000033#include "src/tint/lang/core/ir/module.h"
Ben Claytone95c77a2023-08-01 00:37:35 +000034#include "src/tint/lang/spirv/writer/common/options.h"
James Price85b138e2023-08-01 13:18:35 +000035#include "src/tint/lang/spirv/writer/output.h"
Ben Clayton16fb2542023-09-25 11:43:19 +000036#include "src/tint/utils/diagnostic/diagnostic.h"
James Price85b138e2023-08-01 13:18:35 +000037#include "src/tint/utils/result/result.h"
James Price8f9ea962023-05-04 01:31:36 +000038
39// Forward declarations
dan sinclair2dddb192023-07-26 20:31:48 +000040namespace tint {
41class Program;
42}
James Price8f9ea962023-05-04 01:31:36 +000043
dan sinclair2dddb192023-07-26 20:31:48 +000044namespace tint::spirv::writer {
James Price8f9ea962023-05-04 01:31:36 +000045
dan sinclair2dddb192023-07-26 20:31:48 +000046/// Generate SPIR-V for a program, according to a set of configuration options.
Ben Clayton16fb2542023-09-25 11:43:19 +000047/// The result will contain the SPIR-V or failure.
dan sinclair24b81092023-11-21 16:02:47 +000048/// @param ir the IR module to translate to SPIR-V
49/// @param options the configuration options to use when generating SPIR-V
50/// @returns the resulting SPIR-V and supplementary information, or failure.
51Result<Output> Generate(core::ir::Module& ir, const Options& options);
52
53/// Generate SPIR-V for a program, according to a set of configuration options.
54/// The result will contain the SPIR-V or failure.
dan sinclair2dddb192023-07-26 20:31:48 +000055/// @param program the program to translate to SPIR-V
56/// @param options the configuration options to use when generating SPIR-V
Ben Clayton16fb2542023-09-25 11:43:19 +000057/// @returns the resulting SPIR-V and supplementary information, or failure.
58Result<Output> Generate(const Program& program, const Options& options);
James Price8f9ea962023-05-04 01:31:36 +000059
dan sinclair2dddb192023-07-26 20:31:48 +000060} // namespace tint::spirv::writer
James Price8f9ea962023-05-04 01:31:36 +000061
James Price2280cc62023-07-21 03:42:48 +000062#endif // SRC_TINT_LANG_SPIRV_WRITER_WRITER_H_