blob: d67d357adedef0d5f2d54c36d2b4dd072f91edfd [file] [log] [blame]
// Copyright 2023 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. 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.
//
// 3. Neither the name of the copyright holder 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 HOLDER 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.
syntax = "proto3";
package tint.core.ir.binary.pb;
message Module {
repeated TypeDecl types = 1;
repeated Value values = 2;
Block root_block = 3;
repeated Function functions = 4;
repeated Block blocks = 5;
}
////////////////////////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////////////////////////
message TypeDecl {
oneof kind {
BasicType basic = 1;
VectorType vector = 2;
MatrixType matrix = 3;
ArrayType array = 4;
uint32 atomic = 5; // Module.types
// TODO: textures, samplers
}
}
// Non-compound types
enum BasicType {
void = 0;
bool = 1;
i32 = 2;
u32 = 3;
f32 = 4;
f16 = 5;
}
message VectorType {
uint32 width = 1;
uint32 element_type = 2; // Module.types
}
message MatrixType {
uint32 num_columns = 1;
uint32 num_width = 2;
uint32 element_type = 3; // Module.types
}
message ArrayType {
uint32 count = 1;
uint32 element_type = 2; // Module.types
}
////////////////////////////////////////////////////////////////////////////////
// Values
////////////////////////////////////////////////////////////////////////////////
message Value {
ValueKind kind = 1;
uint32 type = 2; // Module.types
optional string name = 3;
}
enum ValueKind {
instruction_result = 0;
function_parameter = 1;
}
////////////////////////////////////////////////////////////////////////////////
// Functions
////////////////////////////////////////////////////////////////////////////////
message Function {
optional string name = 1;
uint32 return_type = 2;
optional PipelineStage pipeline_stage = 3;
optional WorkgroupSize workgroup_size = 4;
repeated uint32 parameters = 5; // Module.values
uint32 block = 6; // Module.blocks
}
enum PipelineStage {
Compute = 0;
Fragment = 1;
Vertex = 2;
}
message WorkgroupSize {
uint32 x = 1;
uint32 y = 2;
uint32 z = 3;
}
////////////////////////////////////////////////////////////////////////////////
// Blocks
////////////////////////////////////////////////////////////////////////////////
message Block {
repeated uint32 parameters = 1; // Module.values
repeated Instruction instructions = 2;
}
////////////////////////////////////////////////////////////////////////////////
// Instructions
////////////////////////////////////////////////////////////////////////////////
message Instruction {
InstructionKind kind = 1;
repeated uint32 operands = 2;
repeated uint32 results = 3;
}
enum InstructionKind {
Return = 0;
UnaryOp = 1;
BinaryOp = 2;
Builtin = 3;
Constructor = 4;
Discard = 5;
}