mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-12-24 11:58:41 +00:00
gpu_renderer: add virglrenderer bindings
These bindings are needed for virtio-gpu 3D capabilities. All the rust files under gpu_renderer/src/generated are generated via the gpu_renderer/src/generated/generate script. The gpu_renderer/src/lib.rs file contains the Renderer and Context structs, which are the main interfaces to virglrenderer. They encapsulate the global state of virglrenderer (Renderer) and each context ID (Context). The command_buffer module is included only for basic testing and is not intended for production use. The pipe_format_fourcc module is provided for the conversion of virglrenderer specifc formats to standard fourcc formats. BUG=chromium:837073 TEST=cargo build -p gpu_renderer CQ-DEPEND=CL:1144406 Change-Id: Iad153390f618309bf493e92e76432c0b1c4a8a93 Reviewed-on: https://chromium-review.googlesource.com/1043447 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
parent
86fdb1dc50
commit
f40bb190ec
14 changed files with 33907 additions and 0 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -58,6 +58,7 @@ dependencies = [
|
|||
"devices 0.1.0",
|
||||
"gpu_buffer 0.1.0",
|
||||
"gpu_display 0.1.0",
|
||||
"gpu_renderer 0.1.0",
|
||||
"io_jail 0.1.0",
|
||||
"kernel_cmdline 0.1.0",
|
||||
"kernel_loader 0.1.0",
|
||||
|
@ -143,6 +144,15 @@ dependencies = [
|
|||
"sys_util 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gpu_renderer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"data_model 0.1.0",
|
||||
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sys_util 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io_jail"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -19,6 +19,7 @@ arch = { path = "arch" }
|
|||
devices = { path = "devices" }
|
||||
gpu_buffer = { path = "gpu_buffer", optional = true }
|
||||
gpu_display = { path = "gpu_display", optional = true }
|
||||
gpu_renderer = { path = "gpu_renderer", optional = true }
|
||||
io_jail = { path = "io_jail" }
|
||||
kvm = { path = "kvm" }
|
||||
kvm_sys = { path = "kvm_sys" }
|
||||
|
|
9
gpu_renderer/Cargo.toml
Normal file
9
gpu_renderer/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "gpu_renderer"
|
||||
version = "0.1.0"
|
||||
authors = ["The Chromium OS Authors"]
|
||||
|
||||
[dependencies]
|
||||
data_model = { path = "../data_model" }
|
||||
libc = "*"
|
||||
sys_util = { path = "../sys_util" }
|
131
gpu_renderer/src/command_buffer.rs
Normal file
131
gpu_renderer/src/command_buffer.rs
Normal file
|
@ -0,0 +1,131 @@
|
|||
// Copyright 2018 The Chromium OS Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
use std::mem::size_of;
|
||||
use std::os::raw::c_void;
|
||||
use std::slice::{from_raw_parts, from_raw_parts_mut};
|
||||
|
||||
use generated::virgl_protocol::*;
|
||||
|
||||
use Resource;
|
||||
|
||||
/// Helper struct for making a virgl command buffer.
|
||||
#[derive(Default)]
|
||||
pub struct CommandBufferBuilder {
|
||||
cbuf: Vec<u32>,
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for CommandBufferBuilder {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
// Safe because the returned slice is a trivial reinterpretation of the same number of
|
||||
// bytes.
|
||||
unsafe {
|
||||
from_raw_parts(self.cbuf.as_ptr() as *const u8,
|
||||
self.cbuf.len() * size_of::<u32>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<[u8]> for CommandBufferBuilder {
|
||||
fn as_mut(&mut self) -> &mut [u8] {
|
||||
// Safe because the returned slice is a trivial reinterpretation of the same number of
|
||||
// bytes.
|
||||
unsafe {
|
||||
from_raw_parts_mut(self.cbuf.as_mut_ptr() as *mut u8,
|
||||
self.cbuf.len() * size_of::<u32>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl CommandBufferBuilder {
|
||||
/// Constructs an empty command
|
||||
pub fn new() -> CommandBufferBuilder {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn push(&mut self, dw: u32) {
|
||||
self.cbuf.push(dw);
|
||||
}
|
||||
|
||||
fn push_qw(&mut self, qw: u64) {
|
||||
self.cbuf.push(qw as u32);
|
||||
self.cbuf.push((qw >> 32) as u32);
|
||||
}
|
||||
|
||||
fn push_cmd(&mut self, cmd: u32, obj_type: u32, len: u32) {
|
||||
self.cbuf.push((cmd & 0xff) | ((obj_type & 0xff) << 8) | ((len & 0xffff) << 16));
|
||||
}
|
||||
|
||||
/// Gets the command buffer as a pointer to the beginning.
|
||||
pub fn as_mut_ptr(&mut self) -> *mut c_void {
|
||||
self.cbuf.as_mut_ptr() as *mut c_void
|
||||
}
|
||||
|
||||
/// Gets the size of the command buffer content in dwords.
|
||||
pub fn dword_count(&self) -> usize {
|
||||
self.cbuf.len()
|
||||
}
|
||||
|
||||
/// Clears the command buffer content.
|
||||
pub fn clear(&mut self) {
|
||||
self.cbuf.clear();
|
||||
}
|
||||
|
||||
/// Checks that the command buffer is well formed.
|
||||
pub fn is_valid(&self) -> bool {
|
||||
let mut i = 0;
|
||||
while i < self.cbuf.len() {
|
||||
i += 1 + (self.cbuf[i] >> 16) as usize;
|
||||
}
|
||||
i == self.cbuf.len()
|
||||
}
|
||||
|
||||
/// Pushes a clear command to this command buffer.
|
||||
pub fn e_clear(&mut self, buffers: u32, color: [f32; 4], depth: f64, stencil: u32) {
|
||||
self.push_cmd(VIRGL_CCMD_CLEAR, 0, VIRGL_OBJ_CLEAR_SIZE);
|
||||
self.push(buffers);
|
||||
for &c in color.iter() {
|
||||
self.push(c.to_bits())
|
||||
}
|
||||
self.push_qw(depth.to_bits());
|
||||
self.push(stencil);
|
||||
assert!(self.is_valid());
|
||||
}
|
||||
|
||||
/// Pushes a create surface command to this command buffer.
|
||||
pub fn e_create_surface(&mut self,
|
||||
new_id: u32,
|
||||
res: &Resource,
|
||||
format: u32,
|
||||
level: u32,
|
||||
first_layer: u32,
|
||||
last_layer: u32) {
|
||||
self.push_cmd(VIRGL_CCMD_CREATE_OBJECT,
|
||||
VIRGL_OBJECT_SURFACE,
|
||||
VIRGL_OBJ_SURFACE_SIZE);
|
||||
self.push(new_id);
|
||||
self.push(res.id());
|
||||
self.push(format);
|
||||
self.push(level);
|
||||
self.push(first_layer | (last_layer << 16));
|
||||
assert!(self.is_valid());
|
||||
}
|
||||
|
||||
/// Pushes a set framebuffer state command to this command buffer.
|
||||
pub fn e_set_fb_state(&mut self, surface_handles: &[u32], zbuf: Option<u32>) {
|
||||
fn cmd_set_fb_state_size(surface_count: u32) -> u32 {
|
||||
2 + surface_count
|
||||
}
|
||||
self.push_cmd(VIRGL_CCMD_SET_FRAMEBUFFER_STATE,
|
||||
0,
|
||||
cmd_set_fb_state_size(surface_handles.len() as u32));
|
||||
self.push(surface_handles.len() as u32);
|
||||
self.push(zbuf.unwrap_or(0));
|
||||
for &surface_handle in surface_handles {
|
||||
self.push(surface_handle);
|
||||
}
|
||||
assert!(self.is_valid());
|
||||
}
|
||||
}
|
31324
gpu_renderer/src/generated/epoxy_egl.rs
Normal file
31324
gpu_renderer/src/generated/epoxy_egl.rs
Normal file
File diff suppressed because it is too large
Load diff
1
gpu_renderer/src/generated/generate
Symbolic link
1
gpu_renderer/src/generated/generate
Symbolic link
|
@ -0,0 +1 @@
|
|||
generate.py
|
182
gpu_renderer/src/generated/generate.py
Executable file
182
gpu_renderer/src/generated/generate.py
Executable file
|
@ -0,0 +1,182 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright 2018 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""Generates bindings that are used gpu_renderer.
|
||||
|
||||
A sysroot and virglrenderer source checkout is required. The defaults to the
|
||||
root directory.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import argparse
|
||||
import multiprocessing.pool
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
# Bright green.
|
||||
PASS_COLOR = '\033[1;32m'
|
||||
# Bright red.
|
||||
FAIL_COLOR = '\033[1;31m'
|
||||
# Default color.
|
||||
END_COLOR = '\033[0m'
|
||||
|
||||
verbose = False
|
||||
|
||||
def generate_module(module_name, whitelist, header, clang_args, lib_name):
|
||||
args = [
|
||||
'bindgen',
|
||||
'--no-layout-tests',
|
||||
'--whitelist-function', whitelist,
|
||||
'--whitelist-var', whitelist,
|
||||
'--whitelist-type', whitelist,
|
||||
'--no-prepend-enum-name',
|
||||
'--no-rustfmt-bindings',
|
||||
'-o', module_name + '.rs',
|
||||
];
|
||||
|
||||
if lib_name:
|
||||
args.extend(['--raw-line',
|
||||
'#[link(name = "{}")] extern {{}}'.format(lib_name)])
|
||||
|
||||
args.extend([header, '--'])
|
||||
args.extend(clang_args)
|
||||
|
||||
if verbose:
|
||||
print(' '.join(args))
|
||||
|
||||
if subprocess.Popen(args).wait() == 0:
|
||||
return 'pass'
|
||||
else:
|
||||
return 'bindgen failed'
|
||||
|
||||
|
||||
def download_virgl(src, dst, branch):
|
||||
virgl_src = tempfile.TemporaryDirectory(prefix='virglrenderer-src')
|
||||
|
||||
args = ['git', 'clone']
|
||||
|
||||
if branch:
|
||||
args.extend(['-b', branch])
|
||||
|
||||
args.extend([src, dst])
|
||||
|
||||
if verbose:
|
||||
print(' '.join(args))
|
||||
|
||||
if subprocess.Popen(args).wait() == 0:
|
||||
return True
|
||||
else:
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def get_parser():
|
||||
"""Gets the argument parser"""
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--sysroot',
|
||||
default='/',
|
||||
help='sysroot directory (default=%(default)s)')
|
||||
parser.add_argument('--virglrenderer',
|
||||
default='git://git.freedesktop.org/git/virglrenderer',
|
||||
help='virglrenderer src dir/repo (default=%(default)s)')
|
||||
parser.add_argument('--virgl_branch',
|
||||
default='master',
|
||||
help='virglrenderer branch name (default=%(default)s)')
|
||||
parser.add_argument('--verbose', '-v',
|
||||
action='store_true',
|
||||
help='enable verbose output (default=%(default)s)')
|
||||
return parser
|
||||
|
||||
|
||||
def main(argv):
|
||||
global verbose
|
||||
os.chdir(os.path.dirname(sys.argv[0]))
|
||||
opts = get_parser().parse_args(argv)
|
||||
if opts.verbose:
|
||||
verbose = True
|
||||
|
||||
virgl_src_dir = opts.virglrenderer
|
||||
virgl_src_dir_temp = None
|
||||
if '://' in opts.virglrenderer:
|
||||
virgl_src_dir_temp = tempfile.TemporaryDirectory(prefix='virglrenderer-src')
|
||||
virgl_src_dir = virgl_src_dir_temp.name
|
||||
if not download_virgl(opts.virglrenderer, virgl_src_dir, opts.virgl_branch):
|
||||
print('failed to clone \'{}\' to \'{}\''.format(virgl_src_dir,
|
||||
opts.virgl_branch))
|
||||
sys.exit(1)
|
||||
|
||||
clang_args = ['-I', os.path.join(opts.sysroot, 'usr/include')]
|
||||
|
||||
modules = (
|
||||
(
|
||||
'virglrenderer',
|
||||
'virgl_.+',
|
||||
os.path.join(opts.sysroot, 'usr/include/virgl/virglrenderer.h'),
|
||||
clang_args,
|
||||
'virglrenderer',
|
||||
),
|
||||
(
|
||||
'epoxy_egl',
|
||||
'(E?GL)|(epoxy)_.+',
|
||||
os.path.join(opts.sysroot, 'usr/include/epoxy/egl.h'),
|
||||
clang_args,
|
||||
'epoxy',
|
||||
),
|
||||
(
|
||||
'virgl_protocol',
|
||||
'(virgl)|(VIRGL)_.+',
|
||||
os.path.join(virgl_src_dir, 'src/virgl_protocol.h'),
|
||||
clang_args,
|
||||
None,
|
||||
),
|
||||
(
|
||||
'p_defines',
|
||||
'(pipe)|(PIPE).+',
|
||||
os.path.join(virgl_src_dir, 'src/gallium/include/pipe/p_defines.h'),
|
||||
clang_args,
|
||||
None,
|
||||
),
|
||||
(
|
||||
'p_format',
|
||||
'pipe_format',
|
||||
os.path.join(virgl_src_dir, 'src/gallium/include/pipe/p_format.h'),
|
||||
clang_args,
|
||||
None,
|
||||
),
|
||||
)
|
||||
|
||||
pool = multiprocessing.pool.Pool(len(modules))
|
||||
results = pool.starmap(generate_module, modules, 1)
|
||||
|
||||
return_fail = False
|
||||
print('---')
|
||||
print('generate module summary:')
|
||||
for module, result in zip(modules, results):
|
||||
result_color = FAIL_COLOR
|
||||
if result == 'pass':
|
||||
result_color = PASS_COLOR
|
||||
else:
|
||||
return_fail = True
|
||||
|
||||
print('%15s: %s%s%s' %
|
||||
(module[0], result_color, result, END_COLOR))
|
||||
|
||||
if return_fail:
|
||||
sys.exit(1)
|
||||
|
||||
with open('mod.rs', 'w') as f:
|
||||
print('/* generated by generate.py */', file=f)
|
||||
print('#![allow(dead_code)]', file=f)
|
||||
print('#![allow(non_camel_case_types)]', file=f)
|
||||
print('#![allow(non_snake_case)]', file=f)
|
||||
print('#![allow(non_upper_case_globals)]', file=f)
|
||||
for module in modules:
|
||||
print('pub mod', module[0] + ';', file=f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
10
gpu_renderer/src/generated/mod.rs
Normal file
10
gpu_renderer/src/generated/mod.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* generated by generate.py */
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
pub mod virglrenderer;
|
||||
pub mod epoxy_egl;
|
||||
pub mod virgl_protocol;
|
||||
pub mod p_defines;
|
||||
pub mod p_format;
|
604
gpu_renderer/src/generated/p_defines.rs
Normal file
604
gpu_renderer/src/generated/p_defines.rs
Normal file
|
@ -0,0 +1,604 @@
|
|||
/* automatically generated by rust-bindgen */
|
||||
|
||||
pub const _POSIX_PIPE_BUF: u32 = 512;
|
||||
pub const PIPE_BUF: u32 = 4096;
|
||||
pub const PIPE_BLENDFACTOR_ONE: u32 = 1;
|
||||
pub const PIPE_BLENDFACTOR_SRC_COLOR: u32 = 2;
|
||||
pub const PIPE_BLENDFACTOR_SRC_ALPHA: u32 = 3;
|
||||
pub const PIPE_BLENDFACTOR_DST_ALPHA: u32 = 4;
|
||||
pub const PIPE_BLENDFACTOR_DST_COLOR: u32 = 5;
|
||||
pub const PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: u32 = 6;
|
||||
pub const PIPE_BLENDFACTOR_CONST_COLOR: u32 = 7;
|
||||
pub const PIPE_BLENDFACTOR_CONST_ALPHA: u32 = 8;
|
||||
pub const PIPE_BLENDFACTOR_SRC1_COLOR: u32 = 9;
|
||||
pub const PIPE_BLENDFACTOR_SRC1_ALPHA: u32 = 10;
|
||||
pub const PIPE_BLENDFACTOR_ZERO: u32 = 17;
|
||||
pub const PIPE_BLENDFACTOR_INV_SRC_COLOR: u32 = 18;
|
||||
pub const PIPE_BLENDFACTOR_INV_SRC_ALPHA: u32 = 19;
|
||||
pub const PIPE_BLENDFACTOR_INV_DST_ALPHA: u32 = 20;
|
||||
pub const PIPE_BLENDFACTOR_INV_DST_COLOR: u32 = 21;
|
||||
pub const PIPE_BLENDFACTOR_INV_CONST_COLOR: u32 = 23;
|
||||
pub const PIPE_BLENDFACTOR_INV_CONST_ALPHA: u32 = 24;
|
||||
pub const PIPE_BLENDFACTOR_INV_SRC1_COLOR: u32 = 25;
|
||||
pub const PIPE_BLENDFACTOR_INV_SRC1_ALPHA: u32 = 26;
|
||||
pub const PIPE_BLEND_ADD: u32 = 0;
|
||||
pub const PIPE_BLEND_SUBTRACT: u32 = 1;
|
||||
pub const PIPE_BLEND_REVERSE_SUBTRACT: u32 = 2;
|
||||
pub const PIPE_BLEND_MIN: u32 = 3;
|
||||
pub const PIPE_BLEND_MAX: u32 = 4;
|
||||
pub const PIPE_LOGICOP_CLEAR: u32 = 0;
|
||||
pub const PIPE_LOGICOP_NOR: u32 = 1;
|
||||
pub const PIPE_LOGICOP_AND_INVERTED: u32 = 2;
|
||||
pub const PIPE_LOGICOP_COPY_INVERTED: u32 = 3;
|
||||
pub const PIPE_LOGICOP_AND_REVERSE: u32 = 4;
|
||||
pub const PIPE_LOGICOP_INVERT: u32 = 5;
|
||||
pub const PIPE_LOGICOP_XOR: u32 = 6;
|
||||
pub const PIPE_LOGICOP_NAND: u32 = 7;
|
||||
pub const PIPE_LOGICOP_AND: u32 = 8;
|
||||
pub const PIPE_LOGICOP_EQUIV: u32 = 9;
|
||||
pub const PIPE_LOGICOP_NOOP: u32 = 10;
|
||||
pub const PIPE_LOGICOP_OR_INVERTED: u32 = 11;
|
||||
pub const PIPE_LOGICOP_COPY: u32 = 12;
|
||||
pub const PIPE_LOGICOP_OR_REVERSE: u32 = 13;
|
||||
pub const PIPE_LOGICOP_OR: u32 = 14;
|
||||
pub const PIPE_LOGICOP_SET: u32 = 15;
|
||||
pub const PIPE_MASK_R: u32 = 1;
|
||||
pub const PIPE_MASK_G: u32 = 2;
|
||||
pub const PIPE_MASK_B: u32 = 4;
|
||||
pub const PIPE_MASK_A: u32 = 8;
|
||||
pub const PIPE_MASK_RGBA: u32 = 15;
|
||||
pub const PIPE_MASK_Z: u32 = 16;
|
||||
pub const PIPE_MASK_S: u32 = 32;
|
||||
pub const PIPE_MASK_ZS: u32 = 48;
|
||||
pub const PIPE_MASK_RGBAZS: u32 = 63;
|
||||
pub const PIPE_FUNC_NEVER: u32 = 0;
|
||||
pub const PIPE_FUNC_LESS: u32 = 1;
|
||||
pub const PIPE_FUNC_EQUAL: u32 = 2;
|
||||
pub const PIPE_FUNC_LEQUAL: u32 = 3;
|
||||
pub const PIPE_FUNC_GREATER: u32 = 4;
|
||||
pub const PIPE_FUNC_NOTEQUAL: u32 = 5;
|
||||
pub const PIPE_FUNC_GEQUAL: u32 = 6;
|
||||
pub const PIPE_FUNC_ALWAYS: u32 = 7;
|
||||
pub const PIPE_POLYGON_MODE_FILL: u32 = 0;
|
||||
pub const PIPE_POLYGON_MODE_LINE: u32 = 1;
|
||||
pub const PIPE_POLYGON_MODE_POINT: u32 = 2;
|
||||
pub const PIPE_FACE_NONE: u32 = 0;
|
||||
pub const PIPE_FACE_FRONT: u32 = 1;
|
||||
pub const PIPE_FACE_BACK: u32 = 2;
|
||||
pub const PIPE_FACE_FRONT_AND_BACK: u32 = 3;
|
||||
pub const PIPE_STENCIL_OP_KEEP: u32 = 0;
|
||||
pub const PIPE_STENCIL_OP_ZERO: u32 = 1;
|
||||
pub const PIPE_STENCIL_OP_REPLACE: u32 = 2;
|
||||
pub const PIPE_STENCIL_OP_INCR: u32 = 3;
|
||||
pub const PIPE_STENCIL_OP_DECR: u32 = 4;
|
||||
pub const PIPE_STENCIL_OP_INCR_WRAP: u32 = 5;
|
||||
pub const PIPE_STENCIL_OP_DECR_WRAP: u32 = 6;
|
||||
pub const PIPE_STENCIL_OP_INVERT: u32 = 7;
|
||||
pub const PIPE_TEX_FACE_POS_X: u32 = 0;
|
||||
pub const PIPE_TEX_FACE_NEG_X: u32 = 1;
|
||||
pub const PIPE_TEX_FACE_POS_Y: u32 = 2;
|
||||
pub const PIPE_TEX_FACE_NEG_Y: u32 = 3;
|
||||
pub const PIPE_TEX_FACE_POS_Z: u32 = 4;
|
||||
pub const PIPE_TEX_FACE_NEG_Z: u32 = 5;
|
||||
pub const PIPE_TEX_FACE_MAX: u32 = 6;
|
||||
pub const PIPE_TEX_WRAP_REPEAT: u32 = 0;
|
||||
pub const PIPE_TEX_WRAP_CLAMP: u32 = 1;
|
||||
pub const PIPE_TEX_WRAP_CLAMP_TO_EDGE: u32 = 2;
|
||||
pub const PIPE_TEX_WRAP_CLAMP_TO_BORDER: u32 = 3;
|
||||
pub const PIPE_TEX_WRAP_MIRROR_REPEAT: u32 = 4;
|
||||
pub const PIPE_TEX_WRAP_MIRROR_CLAMP: u32 = 5;
|
||||
pub const PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: u32 = 6;
|
||||
pub const PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: u32 = 7;
|
||||
pub const PIPE_TEX_MIPFILTER_NEAREST: u32 = 0;
|
||||
pub const PIPE_TEX_MIPFILTER_LINEAR: u32 = 1;
|
||||
pub const PIPE_TEX_MIPFILTER_NONE: u32 = 2;
|
||||
pub const PIPE_TEX_FILTER_NEAREST: u32 = 0;
|
||||
pub const PIPE_TEX_FILTER_LINEAR: u32 = 1;
|
||||
pub const PIPE_TEX_COMPARE_NONE: u32 = 0;
|
||||
pub const PIPE_TEX_COMPARE_R_TO_TEXTURE: u32 = 1;
|
||||
pub const PIPE_CLEAR_DEPTH: u32 = 1;
|
||||
pub const PIPE_CLEAR_STENCIL: u32 = 2;
|
||||
pub const PIPE_CLEAR_COLOR0: u32 = 4;
|
||||
pub const PIPE_CLEAR_COLOR1: u32 = 8;
|
||||
pub const PIPE_CLEAR_COLOR2: u32 = 16;
|
||||
pub const PIPE_CLEAR_COLOR3: u32 = 32;
|
||||
pub const PIPE_CLEAR_COLOR4: u32 = 64;
|
||||
pub const PIPE_CLEAR_COLOR5: u32 = 128;
|
||||
pub const PIPE_CLEAR_COLOR6: u32 = 256;
|
||||
pub const PIPE_CLEAR_COLOR7: u32 = 512;
|
||||
pub const PIPE_CLEAR_COLOR: u32 = 1020;
|
||||
pub const PIPE_CLEAR_DEPTHSTENCIL: u32 = 3;
|
||||
pub const PIPE_BARRIER_MAPPED_BUFFER: u32 = 1;
|
||||
pub const PIPE_BIND_DEPTH_STENCIL: u32 = 1;
|
||||
pub const PIPE_BIND_RENDER_TARGET: u32 = 2;
|
||||
pub const PIPE_BIND_BLENDABLE: u32 = 4;
|
||||
pub const PIPE_BIND_SAMPLER_VIEW: u32 = 8;
|
||||
pub const PIPE_BIND_VERTEX_BUFFER: u32 = 16;
|
||||
pub const PIPE_BIND_INDEX_BUFFER: u32 = 32;
|
||||
pub const PIPE_BIND_CONSTANT_BUFFER: u32 = 64;
|
||||
pub const PIPE_BIND_DISPLAY_TARGET: u32 = 256;
|
||||
pub const PIPE_BIND_TRANSFER_WRITE: u32 = 512;
|
||||
pub const PIPE_BIND_TRANSFER_READ: u32 = 1024;
|
||||
pub const PIPE_BIND_STREAM_OUTPUT: u32 = 2048;
|
||||
pub const PIPE_BIND_CURSOR: u32 = 65536;
|
||||
pub const PIPE_BIND_CUSTOM: u32 = 131072;
|
||||
pub const PIPE_BIND_GLOBAL: u32 = 262144;
|
||||
pub const PIPE_BIND_SHADER_RESOURCE: u32 = 524288;
|
||||
pub const PIPE_BIND_COMPUTE_RESOURCE: u32 = 1048576;
|
||||
pub const PIPE_BIND_COMMAND_ARGS_BUFFER: u32 = 2097152;
|
||||
pub const PIPE_BIND_SCANOUT: u32 = 16384;
|
||||
pub const PIPE_BIND_SHARED: u32 = 32768;
|
||||
pub const PIPE_BIND_LINEAR: u32 = 2097152;
|
||||
pub const PIPE_RESOURCE_FLAG_MAP_PERSISTENT: u32 = 1;
|
||||
pub const PIPE_RESOURCE_FLAG_MAP_COHERENT: u32 = 2;
|
||||
pub const PIPE_RESOURCE_FLAG_DRV_PRIV: u32 = 65536;
|
||||
pub const PIPE_RESOURCE_FLAG_ST_PRIV: u32 = 16777216;
|
||||
pub const PIPE_USAGE_DEFAULT: u32 = 0;
|
||||
pub const PIPE_USAGE_IMMUTABLE: u32 = 1;
|
||||
pub const PIPE_USAGE_DYNAMIC: u32 = 2;
|
||||
pub const PIPE_USAGE_STREAM: u32 = 3;
|
||||
pub const PIPE_USAGE_STAGING: u32 = 4;
|
||||
pub const PIPE_SHADER_VERTEX: u32 = 0;
|
||||
pub const PIPE_SHADER_FRAGMENT: u32 = 1;
|
||||
pub const PIPE_SHADER_GEOMETRY: u32 = 2;
|
||||
pub const PIPE_SHADER_TESS_CTRL: u32 = 3;
|
||||
pub const PIPE_SHADER_TESS_EVAL: u32 = 4;
|
||||
pub const PIPE_SHADER_COMPUTE: u32 = 5;
|
||||
pub const PIPE_SHADER_TYPES: u32 = 6;
|
||||
pub const PIPE_PRIM_POINTS: u32 = 0;
|
||||
pub const PIPE_PRIM_LINES: u32 = 1;
|
||||
pub const PIPE_PRIM_LINE_LOOP: u32 = 2;
|
||||
pub const PIPE_PRIM_LINE_STRIP: u32 = 3;
|
||||
pub const PIPE_PRIM_TRIANGLES: u32 = 4;
|
||||
pub const PIPE_PRIM_TRIANGLE_STRIP: u32 = 5;
|
||||
pub const PIPE_PRIM_TRIANGLE_FAN: u32 = 6;
|
||||
pub const PIPE_PRIM_QUADS: u32 = 7;
|
||||
pub const PIPE_PRIM_QUAD_STRIP: u32 = 8;
|
||||
pub const PIPE_PRIM_POLYGON: u32 = 9;
|
||||
pub const PIPE_PRIM_LINES_ADJACENCY: u32 = 10;
|
||||
pub const PIPE_PRIM_LINE_STRIP_ADJACENCY: u32 = 11;
|
||||
pub const PIPE_PRIM_TRIANGLES_ADJACENCY: u32 = 12;
|
||||
pub const PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: u32 = 13;
|
||||
pub const PIPE_PRIM_PATCHES: u32 = 14;
|
||||
pub const PIPE_PRIM_MAX: u32 = 15;
|
||||
pub const PIPE_TESS_SPACING_FRACTIONAL_ODD: u32 = 0;
|
||||
pub const PIPE_TESS_SPACING_FRACTIONAL_EVEN: u32 = 1;
|
||||
pub const PIPE_TESS_SPACING_EQUAL: u32 = 2;
|
||||
pub const PIPE_QUERY_OCCLUSION_COUNTER: u32 = 0;
|
||||
pub const PIPE_QUERY_OCCLUSION_PREDICATE: u32 = 1;
|
||||
pub const PIPE_QUERY_TIMESTAMP: u32 = 2;
|
||||
pub const PIPE_QUERY_TIMESTAMP_DISJOINT: u32 = 3;
|
||||
pub const PIPE_QUERY_TIME_ELAPSED: u32 = 4;
|
||||
pub const PIPE_QUERY_PRIMITIVES_GENERATED: u32 = 5;
|
||||
pub const PIPE_QUERY_PRIMITIVES_EMITTED: u32 = 6;
|
||||
pub const PIPE_QUERY_SO_STATISTICS: u32 = 7;
|
||||
pub const PIPE_QUERY_SO_OVERFLOW_PREDICATE: u32 = 8;
|
||||
pub const PIPE_QUERY_GPU_FINISHED: u32 = 9;
|
||||
pub const PIPE_QUERY_PIPELINE_STATISTICS: u32 = 10;
|
||||
pub const PIPE_QUERY_TYPES: u32 = 11;
|
||||
pub const PIPE_QUERY_DRIVER_SPECIFIC: u32 = 256;
|
||||
pub const PIPE_RENDER_COND_WAIT: u32 = 0;
|
||||
pub const PIPE_RENDER_COND_NO_WAIT: u32 = 1;
|
||||
pub const PIPE_RENDER_COND_BY_REGION_WAIT: u32 = 2;
|
||||
pub const PIPE_RENDER_COND_BY_REGION_NO_WAIT: u32 = 3;
|
||||
pub const PIPE_SPRITE_COORD_UPPER_LEFT: u32 = 0;
|
||||
pub const PIPE_SPRITE_COORD_LOWER_LEFT: u32 = 1;
|
||||
pub const PIPE_SWIZZLE_RED: u32 = 0;
|
||||
pub const PIPE_SWIZZLE_GREEN: u32 = 1;
|
||||
pub const PIPE_SWIZZLE_BLUE: u32 = 2;
|
||||
pub const PIPE_SWIZZLE_ALPHA: u32 = 3;
|
||||
pub const PIPE_SWIZZLE_ZERO: u32 = 4;
|
||||
pub const PIPE_SWIZZLE_ONE: u32 = 5;
|
||||
pub const PIPE_TIMEOUT_INFINITE: i32 = -1;
|
||||
pub const PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50: u32 = 1;
|
||||
pub const PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600: u32 = 2;
|
||||
pub type boolean = ::std::os::raw::c_uchar;
|
||||
pub const PIPE_OK: pipe_error = 0;
|
||||
/// < Generic error
|
||||
pub const PIPE_ERROR: pipe_error = -1;
|
||||
pub const PIPE_ERROR_BAD_INPUT: pipe_error = -2;
|
||||
pub const PIPE_ERROR_OUT_OF_MEMORY: pipe_error = -3;
|
||||
pub const PIPE_ERROR_RETRY: pipe_error = -4;
|
||||
/// Gallium error codes.
|
||||
///
|
||||
/// - A zero value always means success.
|
||||
/// - A negative value always means failure.
|
||||
/// - The meaning of a positive value is function dependent.
|
||||
pub type pipe_error = i32;
|
||||
pub const PIPE_BUFFER: pipe_texture_target = 0;
|
||||
pub const PIPE_TEXTURE_1D: pipe_texture_target = 1;
|
||||
pub const PIPE_TEXTURE_2D: pipe_texture_target = 2;
|
||||
pub const PIPE_TEXTURE_3D: pipe_texture_target = 3;
|
||||
pub const PIPE_TEXTURE_CUBE: pipe_texture_target = 4;
|
||||
pub const PIPE_TEXTURE_RECT: pipe_texture_target = 5;
|
||||
pub const PIPE_TEXTURE_1D_ARRAY: pipe_texture_target = 6;
|
||||
pub const PIPE_TEXTURE_2D_ARRAY: pipe_texture_target = 7;
|
||||
pub const PIPE_TEXTURE_CUBE_ARRAY: pipe_texture_target = 8;
|
||||
pub const PIPE_MAX_TEXTURE_TYPES: pipe_texture_target = 9;
|
||||
/// Texture types.
|
||||
/// See the documentation for info on PIPE_TEXTURE_RECT vs PIPE_TEXTURE_2D
|
||||
pub type pipe_texture_target = u32;
|
||||
/// Resource contents read back (or accessed directly) at transfer
|
||||
/// create time.
|
||||
pub const PIPE_TRANSFER_READ: pipe_transfer_usage = 1;
|
||||
/// Resource contents will be written back at transfer_unmap
|
||||
/// time (or modified as a result of being accessed directly).
|
||||
pub const PIPE_TRANSFER_WRITE: pipe_transfer_usage = 2;
|
||||
/// Read/modify/write
|
||||
pub const PIPE_TRANSFER_READ_WRITE: pipe_transfer_usage = 3;
|
||||
/// The transfer should map the texture storage directly. The driver may
|
||||
/// return NULL if that isn't possible, and the state tracker needs to cope
|
||||
/// with that and use an alternative path without this flag.
|
||||
///
|
||||
/// E.g. the state tracker could have a simpler path which maps textures and
|
||||
/// does read/modify/write cycles on them directly, and a more complicated
|
||||
/// path which uses minimal read and write transfers.
|
||||
pub const PIPE_TRANSFER_MAP_DIRECTLY: pipe_transfer_usage = 4;
|
||||
/// Discards the memory within the mapped region.
|
||||
///
|
||||
/// It should not be used with PIPE_TRANSFER_READ.
|
||||
///
|
||||
/// See also:
|
||||
/// - OpenGL's ARB_map_buffer_range extension, MAP_INVALIDATE_RANGE_BIT flag.
|
||||
pub const PIPE_TRANSFER_DISCARD_RANGE: pipe_transfer_usage = 256;
|
||||
/// Fail if the resource cannot be mapped immediately.
|
||||
///
|
||||
/// See also:
|
||||
/// - Direct3D's D3DLOCK_DONOTWAIT flag.
|
||||
/// - Mesa3D's MESA_MAP_NOWAIT_BIT flag.
|
||||
/// - WDDM's D3DDDICB_LOCKFLAGS.DonotWait flag.
|
||||
pub const PIPE_TRANSFER_DONTBLOCK: pipe_transfer_usage = 512;
|
||||
/// Do not attempt to synchronize pending operations on the resource when mapping.
|
||||
///
|
||||
/// It should not be used with PIPE_TRANSFER_READ.
|
||||
///
|
||||
/// See also:
|
||||
/// - OpenGL's ARB_map_buffer_range extension, MAP_UNSYNCHRONIZED_BIT flag.
|
||||
/// - Direct3D's D3DLOCK_NOOVERWRITE flag.
|
||||
/// - WDDM's D3DDDICB_LOCKFLAGS.IgnoreSync flag.
|
||||
pub const PIPE_TRANSFER_UNSYNCHRONIZED: pipe_transfer_usage = 1024;
|
||||
/// Written ranges will be notified later with
|
||||
/// pipe_context::transfer_flush_region.
|
||||
///
|
||||
/// It should not be used with PIPE_TRANSFER_READ.
|
||||
///
|
||||
/// See also:
|
||||
/// - pipe_context::transfer_flush_region
|
||||
/// - OpenGL's ARB_map_buffer_range extension, MAP_FLUSH_EXPLICIT_BIT flag.
|
||||
pub const PIPE_TRANSFER_FLUSH_EXPLICIT: pipe_transfer_usage = 2048;
|
||||
/// Discards all memory backing the resource.
|
||||
///
|
||||
/// It should not be used with PIPE_TRANSFER_READ.
|
||||
///
|
||||
/// This is equivalent to:
|
||||
/// - OpenGL's ARB_map_buffer_range extension, MAP_INVALIDATE_BUFFER_BIT
|
||||
/// - BufferData(NULL) on a GL buffer
|
||||
/// - Direct3D's D3DLOCK_DISCARD flag.
|
||||
/// - WDDM's D3DDDICB_LOCKFLAGS.Discard flag.
|
||||
/// - D3D10 DDI's D3D10_DDI_MAP_WRITE_DISCARD flag
|
||||
/// - D3D10's D3D10_MAP_WRITE_DISCARD flag.
|
||||
pub const PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE: pipe_transfer_usage = 4096;
|
||||
/// Allows the resource to be used for rendering while mapped.
|
||||
///
|
||||
/// PIPE_RESOURCE_FLAG_MAP_PERSISTENT must be set when creating
|
||||
/// the resource.
|
||||
///
|
||||
/// If COHERENT is not set, memory_barrier(PIPE_BARRIER_MAPPED_BUFFER)
|
||||
/// must be called to ensure the device can see what the CPU has written.
|
||||
pub const PIPE_TRANSFER_PERSISTENT: pipe_transfer_usage = 8192;
|
||||
/// If PERSISTENT is set, this ensures any writes done by the device are
|
||||
/// immediately visible to the CPU and vice versa.
|
||||
///
|
||||
/// PIPE_RESOURCE_FLAG_MAP_COHERENT must be set when creating
|
||||
/// the resource.
|
||||
pub const PIPE_TRANSFER_COHERENT: pipe_transfer_usage = 16384;
|
||||
/// Transfer object usage flags
|
||||
pub type pipe_transfer_usage = u32;
|
||||
pub const PIPE_FLUSH_END_OF_FRAME: pipe_flush_flags = 1;
|
||||
/// Flags for the flush function.
|
||||
pub type pipe_flush_flags = u32;
|
||||
pub const PIPE_CAP_NPOT_TEXTURES: pipe_cap = 1;
|
||||
pub const PIPE_CAP_TWO_SIDED_STENCIL: pipe_cap = 2;
|
||||
pub const PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: pipe_cap = 4;
|
||||
pub const PIPE_CAP_ANISOTROPIC_FILTER: pipe_cap = 5;
|
||||
pub const PIPE_CAP_POINT_SPRITE: pipe_cap = 6;
|
||||
pub const PIPE_CAP_MAX_RENDER_TARGETS: pipe_cap = 7;
|
||||
pub const PIPE_CAP_OCCLUSION_QUERY: pipe_cap = 8;
|
||||
pub const PIPE_CAP_QUERY_TIME_ELAPSED: pipe_cap = 9;
|
||||
pub const PIPE_CAP_TEXTURE_SHADOW_MAP: pipe_cap = 10;
|
||||
pub const PIPE_CAP_TEXTURE_SWIZZLE: pipe_cap = 11;
|
||||
pub const PIPE_CAP_MAX_TEXTURE_2D_LEVELS: pipe_cap = 12;
|
||||
pub const PIPE_CAP_MAX_TEXTURE_3D_LEVELS: pipe_cap = 13;
|
||||
pub const PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: pipe_cap = 14;
|
||||
pub const PIPE_CAP_TEXTURE_MIRROR_CLAMP: pipe_cap = 25;
|
||||
pub const PIPE_CAP_BLEND_EQUATION_SEPARATE: pipe_cap = 28;
|
||||
pub const PIPE_CAP_SM3: pipe_cap = 29;
|
||||
pub const PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: pipe_cap = 30;
|
||||
pub const PIPE_CAP_PRIMITIVE_RESTART: pipe_cap = 31;
|
||||
/// blend enables and write masks per rendertarget
|
||||
pub const PIPE_CAP_INDEP_BLEND_ENABLE: pipe_cap = 33;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_INDEP_BLEND_FUNC: pipe_cap = 34;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS: pipe_cap = 36;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: pipe_cap = 37;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: pipe_cap = 38;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: pipe_cap = 39;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: pipe_cap = 40;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_DEPTH_CLIP_DISABLE: pipe_cap = 41;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_SHADER_STENCIL_EXPORT: pipe_cap = 42;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_INSTANCEID: pipe_cap = 43;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR: pipe_cap = 44;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_FRAGMENT_COLOR_CLAMPED: pipe_cap = 45;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MIXED_COLORBUFFER_FORMATS: pipe_cap = 46;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_SEAMLESS_CUBE_MAP: pipe_cap = 47;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE: pipe_cap = 48;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MIN_TEXEL_OFFSET: pipe_cap = 50;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_TEXEL_OFFSET: pipe_cap = 51;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_CONDITIONAL_RENDER: pipe_cap = 52;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TEXTURE_BARRIER: pipe_cap = 53;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS: pipe_cap = 55;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS: pipe_cap = 56;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME: pipe_cap = 57;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS: pipe_cap = 59;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_VERTEX_COLOR_UNCLAMPED: pipe_cap = 60;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_VERTEX_COLOR_CLAMPED: pipe_cap = 61;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_GLSL_FEATURE_LEVEL: pipe_cap = 62;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: pipe_cap = 63;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_USER_VERTEX_BUFFERS: pipe_cap = 64;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY: pipe_cap = 65;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY: pipe_cap = 66;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY: pipe_cap = 67;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_COMPUTE: pipe_cap = 68;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_USER_INDEX_BUFFERS: pipe_cap = 69;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_USER_CONSTANT_BUFFERS: pipe_cap = 70;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT: pipe_cap = 71;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_START_INSTANCE: pipe_cap = 72;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_QUERY_TIMESTAMP: pipe_cap = 73;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TEXTURE_MULTISAMPLE: pipe_cap = 74;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: pipe_cap = 75;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_CUBE_MAP_ARRAY: pipe_cap = 76;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TEXTURE_BUFFER_OBJECTS: pipe_cap = 77;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: pipe_cap = 78;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_TEXCOORD: pipe_cap = 79;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER: pipe_cap = 80;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_QUERY_PIPELINE_STATISTICS: pipe_cap = 81;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK: pipe_cap = 82;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: pipe_cap = 83;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_VIEWPORTS: pipe_cap = 84;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_ENDIANNESS: pipe_cap = 85;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: pipe_cap = 86;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_VS_LAYER_VIEWPORT: pipe_cap = 87;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES: pipe_cap = 88;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: pipe_cap = 89;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: pipe_cap = 90;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TEXTURE_GATHER_SM5: pipe_cap = 91;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: pipe_cap = 92;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_FAKE_SW_MSAA: pipe_cap = 93;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TEXTURE_QUERY_LOD: pipe_cap = 94;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET: pipe_cap = 95;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET: pipe_cap = 96;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_SAMPLE_SHADING: pipe_cap = 97;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TEXTURE_GATHER_OFFSETS: pipe_cap = 98;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION: pipe_cap = 99;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_VERTEX_STREAMS: pipe_cap = 100;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_DRAW_INDIRECT: pipe_cap = 101;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_TGSI_FS_FINE_DERIVATIVE: pipe_cap = 102;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_VENDOR_ID: pipe_cap = 103;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_DEVICE_ID: pipe_cap = 104;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_ACCELERATED: pipe_cap = 105;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_VIDEO_MEMORY: pipe_cap = 106;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_UMA: pipe_cap = 107;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_CONDITIONAL_RENDER_INVERTED: pipe_cap = 108;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE: pipe_cap = 109;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_SAMPLER_VIEW_TARGET: pipe_cap = 110;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_CLIP_HALFZ: pipe_cap = 111;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_VERTEXID_NOBASE: pipe_cap = 112;
|
||||
/// different blend funcs per rendertarget
|
||||
pub const PIPE_CAP_POLYGON_OFFSET_CLAMP: pipe_cap = 113;
|
||||
/// Implementation capabilities/limits which are queried through
|
||||
/// pipe_screen::get_param()
|
||||
pub type pipe_cap = u32;
|
||||
pub const PIPE_ENDIAN_LITTLE: pipe_endian = 0;
|
||||
pub const PIPE_ENDIAN_BIG: pipe_endian = 1;
|
||||
pub const PIPE_ENDIAN_NATIVE: pipe_endian = 0;
|
||||
pub type pipe_endian = u32;
|
||||
pub const PIPE_CAPF_MAX_LINE_WIDTH: pipe_capf = 0;
|
||||
pub const PIPE_CAPF_MAX_LINE_WIDTH_AA: pipe_capf = 1;
|
||||
pub const PIPE_CAPF_MAX_POINT_WIDTH: pipe_capf = 2;
|
||||
pub const PIPE_CAPF_MAX_POINT_WIDTH_AA: pipe_capf = 3;
|
||||
pub const PIPE_CAPF_MAX_TEXTURE_ANISOTROPY: pipe_capf = 4;
|
||||
pub const PIPE_CAPF_MAX_TEXTURE_LOD_BIAS: pipe_capf = 5;
|
||||
pub const PIPE_CAPF_GUARD_BAND_LEFT: pipe_capf = 6;
|
||||
pub const PIPE_CAPF_GUARD_BAND_TOP: pipe_capf = 7;
|
||||
pub const PIPE_CAPF_GUARD_BAND_RIGHT: pipe_capf = 8;
|
||||
pub const PIPE_CAPF_GUARD_BAND_BOTTOM: pipe_capf = 9;
|
||||
/// Implementation limits which are queried through
|
||||
/// pipe_screen::get_paramf()
|
||||
pub type pipe_capf = u32;
|
||||
pub const PIPE_SHADER_CAP_MAX_INSTRUCTIONS: pipe_shader_cap = 0;
|
||||
pub const PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: pipe_shader_cap = 1;
|
||||
pub const PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: pipe_shader_cap = 2;
|
||||
pub const PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: pipe_shader_cap = 3;
|
||||
pub const PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: pipe_shader_cap = 4;
|
||||
pub const PIPE_SHADER_CAP_MAX_INPUTS: pipe_shader_cap = 5;
|
||||
pub const PIPE_SHADER_CAP_MAX_OUTPUTS: pipe_shader_cap = 6;
|
||||
pub const PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE: pipe_shader_cap = 7;
|
||||
pub const PIPE_SHADER_CAP_MAX_CONST_BUFFERS: pipe_shader_cap = 8;
|
||||
pub const PIPE_SHADER_CAP_MAX_TEMPS: pipe_shader_cap = 9;
|
||||
pub const PIPE_SHADER_CAP_MAX_PREDS: pipe_shader_cap = 10;
|
||||
pub const PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED: pipe_shader_cap = 11;
|
||||
pub const PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: pipe_shader_cap = 12;
|
||||
pub const PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: pipe_shader_cap = 13;
|
||||
pub const PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: pipe_shader_cap = 14;
|
||||
pub const PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: pipe_shader_cap = 15;
|
||||
pub const PIPE_SHADER_CAP_SUBROUTINES: pipe_shader_cap = 16;
|
||||
pub const PIPE_SHADER_CAP_INTEGERS: pipe_shader_cap = 17;
|
||||
pub const PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: pipe_shader_cap = 18;
|
||||
pub const PIPE_SHADER_CAP_PREFERRED_IR: pipe_shader_cap = 19;
|
||||
pub const PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: pipe_shader_cap = 20;
|
||||
pub const PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: pipe_shader_cap = 21;
|
||||
pub const PIPE_SHADER_CAP_DOUBLES: pipe_shader_cap = 22;
|
||||
pub type pipe_shader_cap = u32;
|
||||
pub const PIPE_SHADER_IR_TGSI: pipe_shader_ir = 0;
|
||||
pub const PIPE_SHADER_IR_LLVM: pipe_shader_ir = 1;
|
||||
pub const PIPE_SHADER_IR_NATIVE: pipe_shader_ir = 2;
|
||||
/// Shader intermediate representation.
|
||||
pub type pipe_shader_ir = u32;
|
||||
pub const PIPE_COMPUTE_CAP_IR_TARGET: pipe_compute_cap = 0;
|
||||
pub const PIPE_COMPUTE_CAP_GRID_DIMENSION: pipe_compute_cap = 1;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_GRID_SIZE: pipe_compute_cap = 2;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE: pipe_compute_cap = 3;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK: pipe_compute_cap = 4;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE: pipe_compute_cap = 5;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE: pipe_compute_cap = 6;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE: pipe_compute_cap = 7;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_INPUT_SIZE: pipe_compute_cap = 8;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE: pipe_compute_cap = 9;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY: pipe_compute_cap = 10;
|
||||
pub const PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS: pipe_compute_cap = 11;
|
||||
pub const PIPE_COMPUTE_CAP_IMAGES_SUPPORTED: pipe_compute_cap = 12;
|
||||
/// Compute-specific implementation capability. They can be queried
|
||||
/// using pipe_screen::get_compute_param.
|
||||
pub type pipe_compute_cap = u32;
|
||||
/// Query result for PIPE_QUERY_SO_STATISTICS.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct pipe_query_data_so_statistics {
|
||||
pub num_primitives_written: u64,
|
||||
pub primitives_storage_needed: u64,
|
||||
}
|
||||
/// Query result for PIPE_QUERY_TIMESTAMP_DISJOINT.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct pipe_query_data_timestamp_disjoint {
|
||||
pub frequency: u64,
|
||||
pub disjoint: boolean,
|
||||
}
|
||||
/// Query result for PIPE_QUERY_PIPELINE_STATISTICS.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct pipe_query_data_pipeline_statistics {
|
||||
/// < Num vertices read by the vertex fetcher.
|
||||
pub ia_vertices: u64,
|
||||
/// < Num primitives read by the vertex fetcher.
|
||||
pub ia_primitives: u64,
|
||||
/// < Num vertex shader invocations.
|
||||
pub vs_invocations: u64,
|
||||
/// < Num geometry shader invocations.
|
||||
pub gs_invocations: u64,
|
||||
/// < Num primitives output by a geometry shader.
|
||||
pub gs_primitives: u64,
|
||||
/// < Num primitives sent to the rasterizer.
|
||||
pub c_invocations: u64,
|
||||
/// < Num primitives that were rendered.
|
||||
pub c_primitives: u64,
|
||||
/// < Num pixel shader invocations.
|
||||
pub ps_invocations: u64,
|
||||
/// < Num hull shader invocations.
|
||||
pub hs_invocations: u64,
|
||||
/// < Num domain shader invocations.
|
||||
pub ds_invocations: u64,
|
||||
/// < Num compute shader invocations.
|
||||
pub cs_invocations: u64,
|
||||
}
|
||||
/// Query result (returned by pipe_context::get_query_result).
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub union pipe_query_result {
|
||||
pub b: boolean,
|
||||
pub u64: u64,
|
||||
pub so_statistics: pipe_query_data_so_statistics,
|
||||
pub timestamp_disjoint: pipe_query_data_timestamp_disjoint,
|
||||
pub pipeline_statistics: pipe_query_data_pipeline_statistics,
|
||||
_bindgen_union_align: [u64; 11usize],
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub union pipe_color_union {
|
||||
pub f: [f32; 4usize],
|
||||
pub i: [::std::os::raw::c_int; 4usize],
|
||||
pub ui: [::std::os::raw::c_uint; 4usize],
|
||||
_bindgen_union_align: [u32; 4usize],
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct pipe_driver_query_info {
|
||||
pub name: *const ::std::os::raw::c_char,
|
||||
pub query_type: ::std::os::raw::c_uint,
|
||||
pub max_value: u64,
|
||||
pub uses_byte_units: boolean,
|
||||
}
|
275
gpu_renderer/src/generated/p_format.rs
Normal file
275
gpu_renderer/src/generated/p_format.rs
Normal file
|
@ -0,0 +1,275 @@
|
|||
/* automatically generated by rust-bindgen */
|
||||
|
||||
pub const PIPE_FORMAT_NONE: pipe_format = 0;
|
||||
pub const PIPE_FORMAT_B8G8R8A8_UNORM: pipe_format = 1;
|
||||
pub const PIPE_FORMAT_B8G8R8X8_UNORM: pipe_format = 2;
|
||||
pub const PIPE_FORMAT_A8R8G8B8_UNORM: pipe_format = 3;
|
||||
pub const PIPE_FORMAT_X8R8G8B8_UNORM: pipe_format = 4;
|
||||
pub const PIPE_FORMAT_B5G5R5A1_UNORM: pipe_format = 5;
|
||||
pub const PIPE_FORMAT_B4G4R4A4_UNORM: pipe_format = 6;
|
||||
pub const PIPE_FORMAT_B5G6R5_UNORM: pipe_format = 7;
|
||||
pub const PIPE_FORMAT_R10G10B10A2_UNORM: pipe_format = 8;
|
||||
/// < ubyte luminance
|
||||
pub const PIPE_FORMAT_L8_UNORM: pipe_format = 9;
|
||||
/// < ubyte alpha
|
||||
pub const PIPE_FORMAT_A8_UNORM: pipe_format = 10;
|
||||
/// < ubyte intensity
|
||||
pub const PIPE_FORMAT_I8_UNORM: pipe_format = 11;
|
||||
/// < ubyte alpha, luminance
|
||||
pub const PIPE_FORMAT_L8A8_UNORM: pipe_format = 12;
|
||||
/// < ushort luminance
|
||||
pub const PIPE_FORMAT_L16_UNORM: pipe_format = 13;
|
||||
pub const PIPE_FORMAT_UYVY: pipe_format = 14;
|
||||
pub const PIPE_FORMAT_YUYV: pipe_format = 15;
|
||||
pub const PIPE_FORMAT_Z16_UNORM: pipe_format = 16;
|
||||
pub const PIPE_FORMAT_Z32_UNORM: pipe_format = 17;
|
||||
pub const PIPE_FORMAT_Z32_FLOAT: pipe_format = 18;
|
||||
pub const PIPE_FORMAT_Z24_UNORM_S8_UINT: pipe_format = 19;
|
||||
pub const PIPE_FORMAT_S8_UINT_Z24_UNORM: pipe_format = 20;
|
||||
pub const PIPE_FORMAT_Z24X8_UNORM: pipe_format = 21;
|
||||
pub const PIPE_FORMAT_X8Z24_UNORM: pipe_format = 22;
|
||||
/// < ubyte stencil
|
||||
pub const PIPE_FORMAT_S8_UINT: pipe_format = 23;
|
||||
pub const PIPE_FORMAT_R64_FLOAT: pipe_format = 24;
|
||||
pub const PIPE_FORMAT_R64G64_FLOAT: pipe_format = 25;
|
||||
pub const PIPE_FORMAT_R64G64B64_FLOAT: pipe_format = 26;
|
||||
pub const PIPE_FORMAT_R64G64B64A64_FLOAT: pipe_format = 27;
|
||||
pub const PIPE_FORMAT_R32_FLOAT: pipe_format = 28;
|
||||
pub const PIPE_FORMAT_R32G32_FLOAT: pipe_format = 29;
|
||||
pub const PIPE_FORMAT_R32G32B32_FLOAT: pipe_format = 30;
|
||||
pub const PIPE_FORMAT_R32G32B32A32_FLOAT: pipe_format = 31;
|
||||
pub const PIPE_FORMAT_R32_UNORM: pipe_format = 32;
|
||||
pub const PIPE_FORMAT_R32G32_UNORM: pipe_format = 33;
|
||||
pub const PIPE_FORMAT_R32G32B32_UNORM: pipe_format = 34;
|
||||
pub const PIPE_FORMAT_R32G32B32A32_UNORM: pipe_format = 35;
|
||||
pub const PIPE_FORMAT_R32_USCALED: pipe_format = 36;
|
||||
pub const PIPE_FORMAT_R32G32_USCALED: pipe_format = 37;
|
||||
pub const PIPE_FORMAT_R32G32B32_USCALED: pipe_format = 38;
|
||||
pub const PIPE_FORMAT_R32G32B32A32_USCALED: pipe_format = 39;
|
||||
pub const PIPE_FORMAT_R32_SNORM: pipe_format = 40;
|
||||
pub const PIPE_FORMAT_R32G32_SNORM: pipe_format = 41;
|
||||
pub const PIPE_FORMAT_R32G32B32_SNORM: pipe_format = 42;
|
||||
pub const PIPE_FORMAT_R32G32B32A32_SNORM: pipe_format = 43;
|
||||
pub const PIPE_FORMAT_R32_SSCALED: pipe_format = 44;
|
||||
pub const PIPE_FORMAT_R32G32_SSCALED: pipe_format = 45;
|
||||
pub const PIPE_FORMAT_R32G32B32_SSCALED: pipe_format = 46;
|
||||
pub const PIPE_FORMAT_R32G32B32A32_SSCALED: pipe_format = 47;
|
||||
pub const PIPE_FORMAT_R16_UNORM: pipe_format = 48;
|
||||
pub const PIPE_FORMAT_R16G16_UNORM: pipe_format = 49;
|
||||
pub const PIPE_FORMAT_R16G16B16_UNORM: pipe_format = 50;
|
||||
pub const PIPE_FORMAT_R16G16B16A16_UNORM: pipe_format = 51;
|
||||
pub const PIPE_FORMAT_R16_USCALED: pipe_format = 52;
|
||||
pub const PIPE_FORMAT_R16G16_USCALED: pipe_format = 53;
|
||||
pub const PIPE_FORMAT_R16G16B16_USCALED: pipe_format = 54;
|
||||
pub const PIPE_FORMAT_R16G16B16A16_USCALED: pipe_format = 55;
|
||||
pub const PIPE_FORMAT_R16_SNORM: pipe_format = 56;
|
||||
pub const PIPE_FORMAT_R16G16_SNORM: pipe_format = 57;
|
||||
pub const PIPE_FORMAT_R16G16B16_SNORM: pipe_format = 58;
|
||||
pub const PIPE_FORMAT_R16G16B16A16_SNORM: pipe_format = 59;
|
||||
pub const PIPE_FORMAT_R16_SSCALED: pipe_format = 60;
|
||||
pub const PIPE_FORMAT_R16G16_SSCALED: pipe_format = 61;
|
||||
pub const PIPE_FORMAT_R16G16B16_SSCALED: pipe_format = 62;
|
||||
pub const PIPE_FORMAT_R16G16B16A16_SSCALED: pipe_format = 63;
|
||||
pub const PIPE_FORMAT_R8_UNORM: pipe_format = 64;
|
||||
pub const PIPE_FORMAT_R8G8_UNORM: pipe_format = 65;
|
||||
pub const PIPE_FORMAT_R8G8B8_UNORM: pipe_format = 66;
|
||||
pub const PIPE_FORMAT_R8G8B8A8_UNORM: pipe_format = 67;
|
||||
pub const PIPE_FORMAT_X8B8G8R8_UNORM: pipe_format = 68;
|
||||
pub const PIPE_FORMAT_R8_USCALED: pipe_format = 69;
|
||||
pub const PIPE_FORMAT_R8G8_USCALED: pipe_format = 70;
|
||||
pub const PIPE_FORMAT_R8G8B8_USCALED: pipe_format = 71;
|
||||
pub const PIPE_FORMAT_R8G8B8A8_USCALED: pipe_format = 72;
|
||||
pub const PIPE_FORMAT_R8_SNORM: pipe_format = 74;
|
||||
pub const PIPE_FORMAT_R8G8_SNORM: pipe_format = 75;
|
||||
pub const PIPE_FORMAT_R8G8B8_SNORM: pipe_format = 76;
|
||||
pub const PIPE_FORMAT_R8G8B8A8_SNORM: pipe_format = 77;
|
||||
pub const PIPE_FORMAT_R8_SSCALED: pipe_format = 82;
|
||||
pub const PIPE_FORMAT_R8G8_SSCALED: pipe_format = 83;
|
||||
pub const PIPE_FORMAT_R8G8B8_SSCALED: pipe_format = 84;
|
||||
pub const PIPE_FORMAT_R8G8B8A8_SSCALED: pipe_format = 85;
|
||||
pub const PIPE_FORMAT_R32_FIXED: pipe_format = 87;
|
||||
pub const PIPE_FORMAT_R32G32_FIXED: pipe_format = 88;
|
||||
pub const PIPE_FORMAT_R32G32B32_FIXED: pipe_format = 89;
|
||||
pub const PIPE_FORMAT_R32G32B32A32_FIXED: pipe_format = 90;
|
||||
pub const PIPE_FORMAT_R16_FLOAT: pipe_format = 91;
|
||||
pub const PIPE_FORMAT_R16G16_FLOAT: pipe_format = 92;
|
||||
pub const PIPE_FORMAT_R16G16B16_FLOAT: pipe_format = 93;
|
||||
pub const PIPE_FORMAT_R16G16B16A16_FLOAT: pipe_format = 94;
|
||||
pub const PIPE_FORMAT_L8_SRGB: pipe_format = 95;
|
||||
pub const PIPE_FORMAT_L8A8_SRGB: pipe_format = 96;
|
||||
pub const PIPE_FORMAT_R8G8B8_SRGB: pipe_format = 97;
|
||||
pub const PIPE_FORMAT_A8B8G8R8_SRGB: pipe_format = 98;
|
||||
pub const PIPE_FORMAT_X8B8G8R8_SRGB: pipe_format = 99;
|
||||
pub const PIPE_FORMAT_B8G8R8A8_SRGB: pipe_format = 100;
|
||||
pub const PIPE_FORMAT_B8G8R8X8_SRGB: pipe_format = 101;
|
||||
pub const PIPE_FORMAT_A8R8G8B8_SRGB: pipe_format = 102;
|
||||
pub const PIPE_FORMAT_X8R8G8B8_SRGB: pipe_format = 103;
|
||||
pub const PIPE_FORMAT_R8G8B8A8_SRGB: pipe_format = 104;
|
||||
pub const PIPE_FORMAT_DXT1_RGB: pipe_format = 105;
|
||||
pub const PIPE_FORMAT_DXT1_RGBA: pipe_format = 106;
|
||||
pub const PIPE_FORMAT_DXT3_RGBA: pipe_format = 107;
|
||||
pub const PIPE_FORMAT_DXT5_RGBA: pipe_format = 108;
|
||||
pub const PIPE_FORMAT_DXT1_SRGB: pipe_format = 109;
|
||||
pub const PIPE_FORMAT_DXT1_SRGBA: pipe_format = 110;
|
||||
pub const PIPE_FORMAT_DXT3_SRGBA: pipe_format = 111;
|
||||
pub const PIPE_FORMAT_DXT5_SRGBA: pipe_format = 112;
|
||||
pub const PIPE_FORMAT_RGTC1_UNORM: pipe_format = 113;
|
||||
pub const PIPE_FORMAT_RGTC1_SNORM: pipe_format = 114;
|
||||
pub const PIPE_FORMAT_RGTC2_UNORM: pipe_format = 115;
|
||||
pub const PIPE_FORMAT_RGTC2_SNORM: pipe_format = 116;
|
||||
pub const PIPE_FORMAT_R8G8_B8G8_UNORM: pipe_format = 117;
|
||||
pub const PIPE_FORMAT_G8R8_G8B8_UNORM: pipe_format = 118;
|
||||
pub const PIPE_FORMAT_R8SG8SB8UX8U_NORM: pipe_format = 119;
|
||||
pub const PIPE_FORMAT_R5SG5SB6U_NORM: pipe_format = 120;
|
||||
pub const PIPE_FORMAT_A8B8G8R8_UNORM: pipe_format = 121;
|
||||
pub const PIPE_FORMAT_B5G5R5X1_UNORM: pipe_format = 122;
|
||||
pub const PIPE_FORMAT_R10G10B10A2_USCALED: pipe_format = 123;
|
||||
pub const PIPE_FORMAT_R11G11B10_FLOAT: pipe_format = 124;
|
||||
pub const PIPE_FORMAT_R9G9B9E5_FLOAT: pipe_format = 125;
|
||||
pub const PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: pipe_format = 126;
|
||||
pub const PIPE_FORMAT_R1_UNORM: pipe_format = 127;
|
||||
pub const PIPE_FORMAT_R10G10B10X2_USCALED: pipe_format = 128;
|
||||
pub const PIPE_FORMAT_R10G10B10X2_SNORM: pipe_format = 129;
|
||||
pub const PIPE_FORMAT_L4A4_UNORM: pipe_format = 130;
|
||||
pub const PIPE_FORMAT_B10G10R10A2_UNORM: pipe_format = 131;
|
||||
pub const PIPE_FORMAT_R10SG10SB10SA2U_NORM: pipe_format = 132;
|
||||
pub const PIPE_FORMAT_R8G8Bx_SNORM: pipe_format = 133;
|
||||
pub const PIPE_FORMAT_R8G8B8X8_UNORM: pipe_format = 134;
|
||||
pub const PIPE_FORMAT_B4G4R4X4_UNORM: pipe_format = 135;
|
||||
pub const PIPE_FORMAT_X24S8_UINT: pipe_format = 136;
|
||||
pub const PIPE_FORMAT_S8X24_UINT: pipe_format = 137;
|
||||
pub const PIPE_FORMAT_X32_S8X24_UINT: pipe_format = 138;
|
||||
pub const PIPE_FORMAT_B2G3R3_UNORM: pipe_format = 139;
|
||||
pub const PIPE_FORMAT_L16A16_UNORM: pipe_format = 140;
|
||||
pub const PIPE_FORMAT_A16_UNORM: pipe_format = 141;
|
||||
pub const PIPE_FORMAT_I16_UNORM: pipe_format = 142;
|
||||
pub const PIPE_FORMAT_LATC1_UNORM: pipe_format = 143;
|
||||
pub const PIPE_FORMAT_LATC1_SNORM: pipe_format = 144;
|
||||
pub const PIPE_FORMAT_LATC2_UNORM: pipe_format = 145;
|
||||
pub const PIPE_FORMAT_LATC2_SNORM: pipe_format = 146;
|
||||
pub const PIPE_FORMAT_A8_SNORM: pipe_format = 147;
|
||||
pub const PIPE_FORMAT_L8_SNORM: pipe_format = 148;
|
||||
pub const PIPE_FORMAT_L8A8_SNORM: pipe_format = 149;
|
||||
pub const PIPE_FORMAT_I8_SNORM: pipe_format = 150;
|
||||
pub const PIPE_FORMAT_A16_SNORM: pipe_format = 151;
|
||||
pub const PIPE_FORMAT_L16_SNORM: pipe_format = 152;
|
||||
pub const PIPE_FORMAT_L16A16_SNORM: pipe_format = 153;
|
||||
pub const PIPE_FORMAT_I16_SNORM: pipe_format = 154;
|
||||
pub const PIPE_FORMAT_A16_FLOAT: pipe_format = 155;
|
||||
pub const PIPE_FORMAT_L16_FLOAT: pipe_format = 156;
|
||||
pub const PIPE_FORMAT_L16A16_FLOAT: pipe_format = 157;
|
||||
pub const PIPE_FORMAT_I16_FLOAT: pipe_format = 158;
|
||||
pub const PIPE_FORMAT_A32_FLOAT: pipe_format = 159;
|
||||
pub const PIPE_FORMAT_L32_FLOAT: pipe_format = 160;
|
||||
pub const PIPE_FORMAT_L32A32_FLOAT: pipe_format = 161;
|
||||
pub const PIPE_FORMAT_I32_FLOAT: pipe_format = 162;
|
||||
pub const PIPE_FORMAT_YV12: pipe_format = 163;
|
||||
pub const PIPE_FORMAT_YV16: pipe_format = 164;
|
||||
/// < aka I420
|
||||
pub const PIPE_FORMAT_IYUV: pipe_format = 165;
|
||||
pub const PIPE_FORMAT_NV12: pipe_format = 166;
|
||||
pub const PIPE_FORMAT_NV21: pipe_format = 167;
|
||||
pub const PIPE_FORMAT_A4R4_UNORM: pipe_format = 168;
|
||||
pub const PIPE_FORMAT_R4A4_UNORM: pipe_format = 169;
|
||||
pub const PIPE_FORMAT_R8A8_UNORM: pipe_format = 170;
|
||||
pub const PIPE_FORMAT_A8R8_UNORM: pipe_format = 171;
|
||||
pub const PIPE_FORMAT_R10G10B10A2_SSCALED: pipe_format = 172;
|
||||
pub const PIPE_FORMAT_R10G10B10A2_SNORM: pipe_format = 173;
|
||||
pub const PIPE_FORMAT_B10G10R10A2_USCALED: pipe_format = 174;
|
||||
pub const PIPE_FORMAT_B10G10R10A2_SSCALED: pipe_format = 175;
|
||||
pub const PIPE_FORMAT_B10G10R10A2_SNORM: pipe_format = 176;
|
||||
pub const PIPE_FORMAT_R8_UINT: pipe_format = 177;
|
||||
pub const PIPE_FORMAT_R8G8_UINT: pipe_format = 178;
|
||||
pub const PIPE_FORMAT_R8G8B8_UINT: pipe_format = 179;
|
||||
pub const PIPE_FORMAT_R8G8B8A8_UINT: pipe_format = 180;
|
||||
pub const PIPE_FORMAT_R8_SINT: pipe_format = 181;
|
||||
pub const PIPE_FORMAT_R8G8_SINT: pipe_format = 182;
|
||||
pub const PIPE_FORMAT_R8G8B8_SINT: pipe_format = 183;
|
||||
pub const PIPE_FORMAT_R8G8B8A8_SINT: pipe_format = 184;
|
||||
pub const PIPE_FORMAT_R16_UINT: pipe_format = 185;
|
||||
pub const PIPE_FORMAT_R16G16_UINT: pipe_format = 186;
|
||||
pub const PIPE_FORMAT_R16G16B16_UINT: pipe_format = 187;
|
||||
pub const PIPE_FORMAT_R16G16B16A16_UINT: pipe_format = 188;
|
||||
pub const PIPE_FORMAT_R16_SINT: pipe_format = 189;
|
||||
pub const PIPE_FORMAT_R16G16_SINT: pipe_format = 190;
|
||||
pub const PIPE_FORMAT_R16G16B16_SINT: pipe_format = 191;
|
||||
pub const PIPE_FORMAT_R16G16B16A16_SINT: pipe_format = 192;
|
||||
pub const PIPE_FORMAT_R32_UINT: pipe_format = 193;
|
||||
pub const PIPE_FORMAT_R32G32_UINT: pipe_format = 194;
|
||||
pub const PIPE_FORMAT_R32G32B32_UINT: pipe_format = 195;
|
||||
pub const PIPE_FORMAT_R32G32B32A32_UINT: pipe_format = 196;
|
||||
pub const PIPE_FORMAT_R32_SINT: pipe_format = 197;
|
||||
pub const PIPE_FORMAT_R32G32_SINT: pipe_format = 198;
|
||||
pub const PIPE_FORMAT_R32G32B32_SINT: pipe_format = 199;
|
||||
pub const PIPE_FORMAT_R32G32B32A32_SINT: pipe_format = 200;
|
||||
pub const PIPE_FORMAT_A8_UINT: pipe_format = 201;
|
||||
pub const PIPE_FORMAT_I8_UINT: pipe_format = 202;
|
||||
pub const PIPE_FORMAT_L8_UINT: pipe_format = 203;
|
||||
pub const PIPE_FORMAT_L8A8_UINT: pipe_format = 204;
|
||||
pub const PIPE_FORMAT_A8_SINT: pipe_format = 205;
|
||||
pub const PIPE_FORMAT_I8_SINT: pipe_format = 206;
|
||||
pub const PIPE_FORMAT_L8_SINT: pipe_format = 207;
|
||||
pub const PIPE_FORMAT_L8A8_SINT: pipe_format = 208;
|
||||
pub const PIPE_FORMAT_A16_UINT: pipe_format = 209;
|
||||
pub const PIPE_FORMAT_I16_UINT: pipe_format = 210;
|
||||
pub const PIPE_FORMAT_L16_UINT: pipe_format = 211;
|
||||
pub const PIPE_FORMAT_L16A16_UINT: pipe_format = 212;
|
||||
pub const PIPE_FORMAT_A16_SINT: pipe_format = 213;
|
||||
pub const PIPE_FORMAT_I16_SINT: pipe_format = 214;
|
||||
pub const PIPE_FORMAT_L16_SINT: pipe_format = 215;
|
||||
pub const PIPE_FORMAT_L16A16_SINT: pipe_format = 216;
|
||||
pub const PIPE_FORMAT_A32_UINT: pipe_format = 217;
|
||||
pub const PIPE_FORMAT_I32_UINT: pipe_format = 218;
|
||||
pub const PIPE_FORMAT_L32_UINT: pipe_format = 219;
|
||||
pub const PIPE_FORMAT_L32A32_UINT: pipe_format = 220;
|
||||
pub const PIPE_FORMAT_A32_SINT: pipe_format = 221;
|
||||
pub const PIPE_FORMAT_I32_SINT: pipe_format = 222;
|
||||
pub const PIPE_FORMAT_L32_SINT: pipe_format = 223;
|
||||
pub const PIPE_FORMAT_L32A32_SINT: pipe_format = 224;
|
||||
pub const PIPE_FORMAT_B10G10R10A2_UINT: pipe_format = 225;
|
||||
pub const PIPE_FORMAT_ETC1_RGB8: pipe_format = 226;
|
||||
pub const PIPE_FORMAT_R8G8_R8B8_UNORM: pipe_format = 227;
|
||||
pub const PIPE_FORMAT_G8R8_B8R8_UNORM: pipe_format = 228;
|
||||
pub const PIPE_FORMAT_R8G8B8X8_SNORM: pipe_format = 229;
|
||||
pub const PIPE_FORMAT_R8G8B8X8_SRGB: pipe_format = 230;
|
||||
pub const PIPE_FORMAT_R8G8B8X8_UINT: pipe_format = 231;
|
||||
pub const PIPE_FORMAT_R8G8B8X8_SINT: pipe_format = 232;
|
||||
pub const PIPE_FORMAT_B10G10R10X2_UNORM: pipe_format = 233;
|
||||
pub const PIPE_FORMAT_R16G16B16X16_UNORM: pipe_format = 234;
|
||||
pub const PIPE_FORMAT_R16G16B16X16_SNORM: pipe_format = 235;
|
||||
pub const PIPE_FORMAT_R16G16B16X16_FLOAT: pipe_format = 236;
|
||||
pub const PIPE_FORMAT_R16G16B16X16_UINT: pipe_format = 237;
|
||||
pub const PIPE_FORMAT_R16G16B16X16_SINT: pipe_format = 238;
|
||||
pub const PIPE_FORMAT_R32G32B32X32_FLOAT: pipe_format = 239;
|
||||
pub const PIPE_FORMAT_R32G32B32X32_UINT: pipe_format = 240;
|
||||
pub const PIPE_FORMAT_R32G32B32X32_SINT: pipe_format = 241;
|
||||
pub const PIPE_FORMAT_R8A8_SNORM: pipe_format = 242;
|
||||
pub const PIPE_FORMAT_R16A16_UNORM: pipe_format = 243;
|
||||
pub const PIPE_FORMAT_R16A16_SNORM: pipe_format = 244;
|
||||
pub const PIPE_FORMAT_R16A16_FLOAT: pipe_format = 245;
|
||||
pub const PIPE_FORMAT_R32A32_FLOAT: pipe_format = 246;
|
||||
pub const PIPE_FORMAT_R8A8_UINT: pipe_format = 247;
|
||||
pub const PIPE_FORMAT_R8A8_SINT: pipe_format = 248;
|
||||
pub const PIPE_FORMAT_R16A16_UINT: pipe_format = 249;
|
||||
pub const PIPE_FORMAT_R16A16_SINT: pipe_format = 250;
|
||||
pub const PIPE_FORMAT_R32A32_UINT: pipe_format = 251;
|
||||
pub const PIPE_FORMAT_R32A32_SINT: pipe_format = 252;
|
||||
pub const PIPE_FORMAT_R10G10B10A2_UINT: pipe_format = 253;
|
||||
pub const PIPE_FORMAT_B5G6R5_SRGB: pipe_format = 254;
|
||||
pub const PIPE_FORMAT_BPTC_RGBA_UNORM: pipe_format = 255;
|
||||
pub const PIPE_FORMAT_BPTC_SRGBA: pipe_format = 256;
|
||||
pub const PIPE_FORMAT_BPTC_RGB_FLOAT: pipe_format = 257;
|
||||
pub const PIPE_FORMAT_BPTC_RGB_UFLOAT: pipe_format = 258;
|
||||
pub const PIPE_FORMAT_A8L8_UNORM: pipe_format = 259;
|
||||
pub const PIPE_FORMAT_A8L8_SNORM: pipe_format = 260;
|
||||
pub const PIPE_FORMAT_A8L8_SRGB: pipe_format = 261;
|
||||
pub const PIPE_FORMAT_A16L16_UNORM: pipe_format = 262;
|
||||
pub const PIPE_FORMAT_G8R8_UNORM: pipe_format = 263;
|
||||
pub const PIPE_FORMAT_G8R8_SNORM: pipe_format = 264;
|
||||
pub const PIPE_FORMAT_G16R16_UNORM: pipe_format = 265;
|
||||
pub const PIPE_FORMAT_G16R16_SNORM: pipe_format = 266;
|
||||
pub const PIPE_FORMAT_A8B8G8R8_SNORM: pipe_format = 267;
|
||||
pub const PIPE_FORMAT_X8B8G8R8_SNORM: pipe_format = 268;
|
||||
pub const PIPE_FORMAT_COUNT: pipe_format = 269;
|
||||
/// Formats for textures, surfaces and vertex data
|
||||
pub type pipe_format = u32;
|
239
gpu_renderer/src/generated/virgl_protocol.rs
Normal file
239
gpu_renderer/src/generated/virgl_protocol.rs
Normal file
|
@ -0,0 +1,239 @@
|
|||
/* automatically generated by rust-bindgen */
|
||||
|
||||
pub const VIRGL_QUERY_STATE_NEW: u32 = 0;
|
||||
pub const VIRGL_QUERY_STATE_DONE: u32 = 1;
|
||||
pub const VIRGL_QUERY_STATE_WAIT_HOST: u32 = 2;
|
||||
pub const VIRGL_MAX_COLOR_BUFS: u32 = 8;
|
||||
pub const VIRGL_MAX_CLIP_PLANES: u32 = 8;
|
||||
pub const VIRGL_OBJ_CREATE_HEADER: u32 = 0;
|
||||
pub const VIRGL_OBJ_CREATE_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_BIND_HEADER: u32 = 0;
|
||||
pub const VIRGL_OBJ_BIND_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_DESTROY_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_BLEND_SIZE: u32 = 11;
|
||||
pub const VIRGL_OBJ_BLEND_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_BLEND_S0: u32 = 2;
|
||||
pub const VIRGL_OBJ_BLEND_S1: u32 = 3;
|
||||
pub const VIRGL_OBJ_DSA_SIZE: u32 = 5;
|
||||
pub const VIRGL_OBJ_DSA_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_DSA_S0: u32 = 2;
|
||||
pub const VIRGL_OBJ_DSA_S1: u32 = 3;
|
||||
pub const VIRGL_OBJ_DSA_S2: u32 = 4;
|
||||
pub const VIRGL_OBJ_DSA_ALPHA_REF: u32 = 5;
|
||||
pub const VIRGL_OBJ_RS_SIZE: u32 = 9;
|
||||
pub const VIRGL_OBJ_RS_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_RS_S0: u32 = 2;
|
||||
pub const VIRGL_OBJ_RS_POINT_SIZE: u32 = 3;
|
||||
pub const VIRGL_OBJ_RS_SPRITE_COORD_ENABLE: u32 = 4;
|
||||
pub const VIRGL_OBJ_RS_S3: u32 = 5;
|
||||
pub const VIRGL_OBJ_RS_LINE_WIDTH: u32 = 6;
|
||||
pub const VIRGL_OBJ_RS_OFFSET_UNITS: u32 = 7;
|
||||
pub const VIRGL_OBJ_RS_OFFSET_SCALE: u32 = 8;
|
||||
pub const VIRGL_OBJ_RS_OFFSET_CLAMP: u32 = 9;
|
||||
pub const VIRGL_OBJ_CLEAR_SIZE: u32 = 8;
|
||||
pub const VIRGL_OBJ_CLEAR_BUFFERS: u32 = 1;
|
||||
pub const VIRGL_OBJ_CLEAR_COLOR_0: u32 = 2;
|
||||
pub const VIRGL_OBJ_CLEAR_COLOR_1: u32 = 3;
|
||||
pub const VIRGL_OBJ_CLEAR_COLOR_2: u32 = 4;
|
||||
pub const VIRGL_OBJ_CLEAR_COLOR_3: u32 = 5;
|
||||
pub const VIRGL_OBJ_CLEAR_DEPTH_0: u32 = 6;
|
||||
pub const VIRGL_OBJ_CLEAR_DEPTH_1: u32 = 7;
|
||||
pub const VIRGL_OBJ_CLEAR_STENCIL: u32 = 8;
|
||||
pub const VIRGL_OBJ_SHADER_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_SHADER_TYPE: u32 = 2;
|
||||
pub const VIRGL_OBJ_SHADER_OFFSET: u32 = 3;
|
||||
pub const VIRGL_OBJ_SHADER_OFFSET_CONT: u32 = 2147483648;
|
||||
pub const VIRGL_OBJ_SHADER_NUM_TOKENS: u32 = 4;
|
||||
pub const VIRGL_OBJ_SHADER_SO_NUM_OUTPUTS: u32 = 5;
|
||||
pub const VIRGL_SET_VIEWPORT_START_SLOT: u32 = 1;
|
||||
pub const VIRGL_SET_FRAMEBUFFER_STATE_NR_CBUFS: u32 = 1;
|
||||
pub const VIRGL_SET_FRAMEBUFFER_STATE_NR_ZSURF_HANDLE: u32 = 2;
|
||||
pub const VIRGL_OBJ_VERTEX_ELEMENTS_HANDLE: u32 = 1;
|
||||
pub const VIRGL_SET_INDEX_BUFFER_HANDLE: u32 = 1;
|
||||
pub const VIRGL_SET_INDEX_BUFFER_INDEX_SIZE: u32 = 2;
|
||||
pub const VIRGL_SET_INDEX_BUFFER_OFFSET: u32 = 3;
|
||||
pub const VIRGL_SET_CONSTANT_BUFFER_SHADER_TYPE: u32 = 1;
|
||||
pub const VIRGL_SET_CONSTANT_BUFFER_INDEX: u32 = 2;
|
||||
pub const VIRGL_SET_CONSTANT_BUFFER_DATA_START: u32 = 3;
|
||||
pub const VIRGL_SET_UNIFORM_BUFFER_SIZE: u32 = 5;
|
||||
pub const VIRGL_SET_UNIFORM_BUFFER_SHADER_TYPE: u32 = 1;
|
||||
pub const VIRGL_SET_UNIFORM_BUFFER_INDEX: u32 = 2;
|
||||
pub const VIRGL_SET_UNIFORM_BUFFER_OFFSET: u32 = 3;
|
||||
pub const VIRGL_SET_UNIFORM_BUFFER_LENGTH: u32 = 4;
|
||||
pub const VIRGL_SET_UNIFORM_BUFFER_RES_HANDLE: u32 = 5;
|
||||
pub const VIRGL_DRAW_VBO_SIZE: u32 = 12;
|
||||
pub const VIRGL_DRAW_VBO_START: u32 = 1;
|
||||
pub const VIRGL_DRAW_VBO_COUNT: u32 = 2;
|
||||
pub const VIRGL_DRAW_VBO_MODE: u32 = 3;
|
||||
pub const VIRGL_DRAW_VBO_INDEXED: u32 = 4;
|
||||
pub const VIRGL_DRAW_VBO_INSTANCE_COUNT: u32 = 5;
|
||||
pub const VIRGL_DRAW_VBO_INDEX_BIAS: u32 = 6;
|
||||
pub const VIRGL_DRAW_VBO_START_INSTANCE: u32 = 7;
|
||||
pub const VIRGL_DRAW_VBO_PRIMITIVE_RESTART: u32 = 8;
|
||||
pub const VIRGL_DRAW_VBO_RESTART_INDEX: u32 = 9;
|
||||
pub const VIRGL_DRAW_VBO_MIN_INDEX: u32 = 10;
|
||||
pub const VIRGL_DRAW_VBO_MAX_INDEX: u32 = 11;
|
||||
pub const VIRGL_DRAW_VBO_COUNT_FROM_SO: u32 = 12;
|
||||
pub const VIRGL_OBJ_SURFACE_SIZE: u32 = 5;
|
||||
pub const VIRGL_OBJ_SURFACE_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_SURFACE_RES_HANDLE: u32 = 2;
|
||||
pub const VIRGL_OBJ_SURFACE_FORMAT: u32 = 3;
|
||||
pub const VIRGL_OBJ_SURFACE_BUFFER_FIRST_ELEMENT: u32 = 4;
|
||||
pub const VIRGL_OBJ_SURFACE_BUFFER_LAST_ELEMENT: u32 = 5;
|
||||
pub const VIRGL_OBJ_SURFACE_TEXTURE_LEVEL: u32 = 4;
|
||||
pub const VIRGL_OBJ_SURFACE_TEXTURE_LAYERS: u32 = 5;
|
||||
pub const VIRGL_OBJ_STREAMOUT_SIZE: u32 = 4;
|
||||
pub const VIRGL_OBJ_STREAMOUT_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_STREAMOUT_RES_HANDLE: u32 = 2;
|
||||
pub const VIRGL_OBJ_STREAMOUT_BUFFER_OFFSET: u32 = 3;
|
||||
pub const VIRGL_OBJ_STREAMOUT_BUFFER_SIZE: u32 = 4;
|
||||
pub const VIRGL_OBJ_SAMPLER_STATE_SIZE: u32 = 9;
|
||||
pub const VIRGL_OBJ_SAMPLER_STATE_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_SAMPLER_STATE_S0: u32 = 2;
|
||||
pub const VIRGL_OBJ_SAMPLER_STATE_LOD_BIAS: u32 = 3;
|
||||
pub const VIRGL_OBJ_SAMPLER_STATE_MIN_LOD: u32 = 4;
|
||||
pub const VIRGL_OBJ_SAMPLER_STATE_MAX_LOD: u32 = 5;
|
||||
pub const VIRGL_OBJ_SAMPLER_VIEW_SIZE: u32 = 6;
|
||||
pub const VIRGL_OBJ_SAMPLER_VIEW_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_SAMPLER_VIEW_RES_HANDLE: u32 = 2;
|
||||
pub const VIRGL_OBJ_SAMPLER_VIEW_FORMAT: u32 = 3;
|
||||
pub const VIRGL_OBJ_SAMPLER_VIEW_BUFFER_FIRST_ELEMENT: u32 = 4;
|
||||
pub const VIRGL_OBJ_SAMPLER_VIEW_BUFFER_LAST_ELEMENT: u32 = 5;
|
||||
pub const VIRGL_OBJ_SAMPLER_VIEW_TEXTURE_LAYER: u32 = 4;
|
||||
pub const VIRGL_OBJ_SAMPLER_VIEW_TEXTURE_LEVEL: u32 = 5;
|
||||
pub const VIRGL_OBJ_SAMPLER_VIEW_SWIZZLE: u32 = 6;
|
||||
pub const VIRGL_SET_SAMPLER_VIEWS_SHADER_TYPE: u32 = 1;
|
||||
pub const VIRGL_SET_SAMPLER_VIEWS_START_SLOT: u32 = 2;
|
||||
pub const VIRGL_SET_SAMPLER_VIEWS_V0_HANDLE: u32 = 3;
|
||||
pub const VIRGL_BIND_SAMPLER_STATES_SHADER_TYPE: u32 = 1;
|
||||
pub const VIRGL_BIND_SAMPLER_STATES_START_SLOT: u32 = 2;
|
||||
pub const VIRGL_BIND_SAMPLER_STATES_S0_HANDLE: u32 = 3;
|
||||
pub const VIRGL_SET_STENCIL_REF_SIZE: u32 = 1;
|
||||
pub const VIRGL_SET_STENCIL_REF: u32 = 1;
|
||||
pub const VIRGL_SET_BLEND_COLOR_SIZE: u32 = 4;
|
||||
pub const VIRGL_SET_SCISSOR_START_SLOT: u32 = 1;
|
||||
pub const VIRGL_CMD_RESOURCE_COPY_REGION_SIZE: u32 = 13;
|
||||
pub const VIRGL_CMD_RCR_DST_RES_HANDLE: u32 = 1;
|
||||
pub const VIRGL_CMD_RCR_DST_LEVEL: u32 = 2;
|
||||
pub const VIRGL_CMD_RCR_DST_X: u32 = 3;
|
||||
pub const VIRGL_CMD_RCR_DST_Y: u32 = 4;
|
||||
pub const VIRGL_CMD_RCR_DST_Z: u32 = 5;
|
||||
pub const VIRGL_CMD_RCR_SRC_RES_HANDLE: u32 = 6;
|
||||
pub const VIRGL_CMD_RCR_SRC_LEVEL: u32 = 7;
|
||||
pub const VIRGL_CMD_RCR_SRC_X: u32 = 8;
|
||||
pub const VIRGL_CMD_RCR_SRC_Y: u32 = 9;
|
||||
pub const VIRGL_CMD_RCR_SRC_Z: u32 = 10;
|
||||
pub const VIRGL_CMD_RCR_SRC_W: u32 = 11;
|
||||
pub const VIRGL_CMD_RCR_SRC_H: u32 = 12;
|
||||
pub const VIRGL_CMD_RCR_SRC_D: u32 = 13;
|
||||
pub const VIRGL_CMD_BLIT_SIZE: u32 = 21;
|
||||
pub const VIRGL_CMD_BLIT_S0: u32 = 1;
|
||||
pub const VIRGL_CMD_BLIT_SCISSOR_MINX_MINY: u32 = 2;
|
||||
pub const VIRGL_CMD_BLIT_SCISSOR_MAXX_MAXY: u32 = 3;
|
||||
pub const VIRGL_CMD_BLIT_DST_RES_HANDLE: u32 = 4;
|
||||
pub const VIRGL_CMD_BLIT_DST_LEVEL: u32 = 5;
|
||||
pub const VIRGL_CMD_BLIT_DST_FORMAT: u32 = 6;
|
||||
pub const VIRGL_CMD_BLIT_DST_X: u32 = 7;
|
||||
pub const VIRGL_CMD_BLIT_DST_Y: u32 = 8;
|
||||
pub const VIRGL_CMD_BLIT_DST_Z: u32 = 9;
|
||||
pub const VIRGL_CMD_BLIT_DST_W: u32 = 10;
|
||||
pub const VIRGL_CMD_BLIT_DST_H: u32 = 11;
|
||||
pub const VIRGL_CMD_BLIT_DST_D: u32 = 12;
|
||||
pub const VIRGL_CMD_BLIT_SRC_RES_HANDLE: u32 = 13;
|
||||
pub const VIRGL_CMD_BLIT_SRC_LEVEL: u32 = 14;
|
||||
pub const VIRGL_CMD_BLIT_SRC_FORMAT: u32 = 15;
|
||||
pub const VIRGL_CMD_BLIT_SRC_X: u32 = 16;
|
||||
pub const VIRGL_CMD_BLIT_SRC_Y: u32 = 17;
|
||||
pub const VIRGL_CMD_BLIT_SRC_Z: u32 = 18;
|
||||
pub const VIRGL_CMD_BLIT_SRC_W: u32 = 19;
|
||||
pub const VIRGL_CMD_BLIT_SRC_H: u32 = 20;
|
||||
pub const VIRGL_CMD_BLIT_SRC_D: u32 = 21;
|
||||
pub const VIRGL_OBJ_QUERY_SIZE: u32 = 4;
|
||||
pub const VIRGL_OBJ_QUERY_HANDLE: u32 = 1;
|
||||
pub const VIRGL_OBJ_QUERY_TYPE_INDEX: u32 = 2;
|
||||
pub const VIRGL_OBJ_QUERY_OFFSET: u32 = 3;
|
||||
pub const VIRGL_OBJ_QUERY_RES_HANDLE: u32 = 4;
|
||||
pub const VIRGL_QUERY_BEGIN_HANDLE: u32 = 1;
|
||||
pub const VIRGL_QUERY_END_HANDLE: u32 = 1;
|
||||
pub const VIRGL_QUERY_RESULT_HANDLE: u32 = 1;
|
||||
pub const VIRGL_QUERY_RESULT_WAIT: u32 = 2;
|
||||
pub const VIRGL_RENDER_CONDITION_SIZE: u32 = 3;
|
||||
pub const VIRGL_RENDER_CONDITION_HANDLE: u32 = 1;
|
||||
pub const VIRGL_RENDER_CONDITION_CONDITION: u32 = 2;
|
||||
pub const VIRGL_RENDER_CONDITION_MODE: u32 = 3;
|
||||
pub const VIRGL_RESOURCE_IW_RES_HANDLE: u32 = 1;
|
||||
pub const VIRGL_RESOURCE_IW_LEVEL: u32 = 2;
|
||||
pub const VIRGL_RESOURCE_IW_USAGE: u32 = 3;
|
||||
pub const VIRGL_RESOURCE_IW_STRIDE: u32 = 4;
|
||||
pub const VIRGL_RESOURCE_IW_LAYER_STRIDE: u32 = 5;
|
||||
pub const VIRGL_RESOURCE_IW_X: u32 = 6;
|
||||
pub const VIRGL_RESOURCE_IW_Y: u32 = 7;
|
||||
pub const VIRGL_RESOURCE_IW_Z: u32 = 8;
|
||||
pub const VIRGL_RESOURCE_IW_W: u32 = 9;
|
||||
pub const VIRGL_RESOURCE_IW_H: u32 = 10;
|
||||
pub const VIRGL_RESOURCE_IW_D: u32 = 11;
|
||||
pub const VIRGL_RESOURCE_IW_DATA_START: u32 = 12;
|
||||
pub const VIRGL_SET_STREAMOUT_TARGETS_APPEND_BITMASK: u32 = 1;
|
||||
pub const VIRGL_SET_STREAMOUT_TARGETS_H0: u32 = 2;
|
||||
pub const VIRGL_SET_SAMPLE_MASK_SIZE: u32 = 1;
|
||||
pub const VIRGL_SET_SAMPLE_MASK_MASK: u32 = 1;
|
||||
pub const VIRGL_SET_CLIP_STATE_SIZE: u32 = 32;
|
||||
pub const VIRGL_SET_CLIP_STATE_C0: u32 = 1;
|
||||
pub const VIRGL_POLYGON_STIPPLE_SIZE: u32 = 32;
|
||||
pub const VIRGL_POLYGON_STIPPLE_P0: u32 = 1;
|
||||
pub const VIRGL_BIND_SHADER_SIZE: u32 = 2;
|
||||
pub const VIRGL_BIND_SHADER_HANDLE: u32 = 1;
|
||||
pub const VIRGL_BIND_SHADER_TYPE: u32 = 2;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct virgl_host_query_state {
|
||||
pub query_state: u32,
|
||||
pub result_size: u32,
|
||||
pub result: u64,
|
||||
}
|
||||
pub const VIRGL_OBJECT_NULL: virgl_object_type = 0;
|
||||
pub const VIRGL_OBJECT_BLEND: virgl_object_type = 1;
|
||||
pub const VIRGL_OBJECT_RASTERIZER: virgl_object_type = 2;
|
||||
pub const VIRGL_OBJECT_DSA: virgl_object_type = 3;
|
||||
pub const VIRGL_OBJECT_SHADER: virgl_object_type = 4;
|
||||
pub const VIRGL_OBJECT_VERTEX_ELEMENTS: virgl_object_type = 5;
|
||||
pub const VIRGL_OBJECT_SAMPLER_VIEW: virgl_object_type = 6;
|
||||
pub const VIRGL_OBJECT_SAMPLER_STATE: virgl_object_type = 7;
|
||||
pub const VIRGL_OBJECT_SURFACE: virgl_object_type = 8;
|
||||
pub const VIRGL_OBJECT_QUERY: virgl_object_type = 9;
|
||||
pub const VIRGL_OBJECT_STREAMOUT_TARGET: virgl_object_type = 10;
|
||||
pub const VIRGL_MAX_OBJECTS: virgl_object_type = 11;
|
||||
pub type virgl_object_type = u32;
|
||||
pub const VIRGL_CCMD_NOP: virgl_context_cmd = 0;
|
||||
pub const VIRGL_CCMD_CREATE_OBJECT: virgl_context_cmd = 1;
|
||||
pub const VIRGL_CCMD_BIND_OBJECT: virgl_context_cmd = 2;
|
||||
pub const VIRGL_CCMD_DESTROY_OBJECT: virgl_context_cmd = 3;
|
||||
pub const VIRGL_CCMD_SET_VIEWPORT_STATE: virgl_context_cmd = 4;
|
||||
pub const VIRGL_CCMD_SET_FRAMEBUFFER_STATE: virgl_context_cmd = 5;
|
||||
pub const VIRGL_CCMD_SET_VERTEX_BUFFERS: virgl_context_cmd = 6;
|
||||
pub const VIRGL_CCMD_CLEAR: virgl_context_cmd = 7;
|
||||
pub const VIRGL_CCMD_DRAW_VBO: virgl_context_cmd = 8;
|
||||
pub const VIRGL_CCMD_RESOURCE_INLINE_WRITE: virgl_context_cmd = 9;
|
||||
pub const VIRGL_CCMD_SET_SAMPLER_VIEWS: virgl_context_cmd = 10;
|
||||
pub const VIRGL_CCMD_SET_INDEX_BUFFER: virgl_context_cmd = 11;
|
||||
pub const VIRGL_CCMD_SET_CONSTANT_BUFFER: virgl_context_cmd = 12;
|
||||
pub const VIRGL_CCMD_SET_STENCIL_REF: virgl_context_cmd = 13;
|
||||
pub const VIRGL_CCMD_SET_BLEND_COLOR: virgl_context_cmd = 14;
|
||||
pub const VIRGL_CCMD_SET_SCISSOR_STATE: virgl_context_cmd = 15;
|
||||
pub const VIRGL_CCMD_BLIT: virgl_context_cmd = 16;
|
||||
pub const VIRGL_CCMD_RESOURCE_COPY_REGION: virgl_context_cmd = 17;
|
||||
pub const VIRGL_CCMD_BIND_SAMPLER_STATES: virgl_context_cmd = 18;
|
||||
pub const VIRGL_CCMD_BEGIN_QUERY: virgl_context_cmd = 19;
|
||||
pub const VIRGL_CCMD_END_QUERY: virgl_context_cmd = 20;
|
||||
pub const VIRGL_CCMD_GET_QUERY_RESULT: virgl_context_cmd = 21;
|
||||
pub const VIRGL_CCMD_SET_POLYGON_STIPPLE: virgl_context_cmd = 22;
|
||||
pub const VIRGL_CCMD_SET_CLIP_STATE: virgl_context_cmd = 23;
|
||||
pub const VIRGL_CCMD_SET_SAMPLE_MASK: virgl_context_cmd = 24;
|
||||
pub const VIRGL_CCMD_SET_STREAMOUT_TARGETS: virgl_context_cmd = 25;
|
||||
pub const VIRGL_CCMD_SET_RENDER_CONDITION: virgl_context_cmd = 26;
|
||||
pub const VIRGL_CCMD_SET_UNIFORM_BUFFER: virgl_context_cmd = 27;
|
||||
pub const VIRGL_CCMD_SET_SUB_CTX: virgl_context_cmd = 28;
|
||||
pub const VIRGL_CCMD_CREATE_SUB_CTX: virgl_context_cmd = 29;
|
||||
pub const VIRGL_CCMD_DESTROY_SUB_CTX: virgl_context_cmd = 30;
|
||||
pub const VIRGL_CCMD_BIND_SHADER: virgl_context_cmd = 31;
|
||||
pub type virgl_context_cmd = u32;
|
221
gpu_renderer/src/generated/virglrenderer.rs
Normal file
221
gpu_renderer/src/generated/virglrenderer.rs
Normal file
|
@ -0,0 +1,221 @@
|
|||
/* automatically generated by rust-bindgen */
|
||||
|
||||
#[link(name = "virglrenderer")]
|
||||
extern "C" {}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct virgl_box {
|
||||
_unused: [u8; 0],
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct iovec {
|
||||
_unused: [u8; 0],
|
||||
}
|
||||
pub type virgl_renderer_gl_context = *mut ::std::os::raw::c_void;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct virgl_renderer_gl_ctx_param {
|
||||
pub version: ::std::os::raw::c_int,
|
||||
pub shared: bool,
|
||||
pub major_ver: ::std::os::raw::c_int,
|
||||
pub minor_ver: ::std::os::raw::c_int,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct virgl_renderer_callbacks {
|
||||
pub version: ::std::os::raw::c_int,
|
||||
pub write_fence: ::std::option::Option<
|
||||
unsafe extern "C" fn(cookie: *mut ::std::os::raw::c_void, fence: u32),
|
||||
>,
|
||||
pub create_gl_context: ::std::option::Option<
|
||||
unsafe extern "C" fn(
|
||||
cookie: *mut ::std::os::raw::c_void,
|
||||
scanout_idx: ::std::os::raw::c_int,
|
||||
param: *mut virgl_renderer_gl_ctx_param,
|
||||
) -> virgl_renderer_gl_context,
|
||||
>,
|
||||
pub destroy_gl_context: ::std::option::Option<
|
||||
unsafe extern "C" fn(cookie: *mut ::std::os::raw::c_void, ctx: virgl_renderer_gl_context),
|
||||
>,
|
||||
pub make_current: ::std::option::Option<
|
||||
unsafe extern "C" fn(
|
||||
cookie: *mut ::std::os::raw::c_void,
|
||||
scanout_idx: ::std::os::raw::c_int,
|
||||
ctx: virgl_renderer_gl_context,
|
||||
) -> ::std::os::raw::c_int,
|
||||
>,
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_init(
|
||||
cookie: *mut ::std::os::raw::c_void,
|
||||
flags: ::std::os::raw::c_int,
|
||||
cb: *mut virgl_renderer_callbacks,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_poll();
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_get_cursor_data(
|
||||
resource_id: u32,
|
||||
width: *mut u32,
|
||||
height: *mut u32,
|
||||
) -> *mut ::std::os::raw::c_void;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_get_rect(
|
||||
resource_id: ::std::os::raw::c_int,
|
||||
iov: *mut iovec,
|
||||
num_iovs: ::std::os::raw::c_uint,
|
||||
offset: u32,
|
||||
x: ::std::os::raw::c_int,
|
||||
y: ::std::os::raw::c_int,
|
||||
width: ::std::os::raw::c_int,
|
||||
height: ::std::os::raw::c_int,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_get_fd_for_texture(
|
||||
tex_id: u32,
|
||||
fd: *mut ::std::os::raw::c_int,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct virgl_renderer_resource_create_args {
|
||||
pub handle: u32,
|
||||
pub target: u32,
|
||||
pub format: u32,
|
||||
pub bind: u32,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub depth: u32,
|
||||
pub array_size: u32,
|
||||
pub last_level: u32,
|
||||
pub nr_samples: u32,
|
||||
pub flags: u32,
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_resource_create(
|
||||
args: *mut virgl_renderer_resource_create_args,
|
||||
iov: *mut iovec,
|
||||
num_iovs: u32,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_resource_unref(res_handle: u32);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_context_create(
|
||||
handle: u32,
|
||||
nlen: u32,
|
||||
name: *const ::std::os::raw::c_char,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_context_destroy(handle: u32);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_submit_cmd(
|
||||
buffer: *mut ::std::os::raw::c_void,
|
||||
ctx_id: ::std::os::raw::c_int,
|
||||
ndw: ::std::os::raw::c_int,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_transfer_read_iov(
|
||||
handle: u32,
|
||||
ctx_id: u32,
|
||||
level: u32,
|
||||
stride: u32,
|
||||
layer_stride: u32,
|
||||
box_: *mut virgl_box,
|
||||
offset: u64,
|
||||
iov: *mut iovec,
|
||||
iovec_cnt: ::std::os::raw::c_int,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_transfer_write_iov(
|
||||
handle: u32,
|
||||
ctx_id: u32,
|
||||
level: ::std::os::raw::c_int,
|
||||
stride: u32,
|
||||
layer_stride: u32,
|
||||
box_: *mut virgl_box,
|
||||
offset: u64,
|
||||
iovec: *mut iovec,
|
||||
iovec_cnt: ::std::os::raw::c_uint,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_get_cap_set(set: u32, max_ver: *mut u32, max_size: *mut u32);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_fill_caps(set: u32, version: u32, caps: *mut ::std::os::raw::c_void);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_resource_attach_iov(
|
||||
res_handle: ::std::os::raw::c_int,
|
||||
iov: *mut iovec,
|
||||
num_iovs: ::std::os::raw::c_int,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_resource_detach_iov(
|
||||
res_handle: ::std::os::raw::c_int,
|
||||
iov: *mut *mut iovec,
|
||||
num_iovs: *mut ::std::os::raw::c_int,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_create_fence(
|
||||
client_fence_id: ::std::os::raw::c_int,
|
||||
ctx_id: u32,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_force_ctx_0();
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_ctx_attach_resource(
|
||||
ctx_id: ::std::os::raw::c_int,
|
||||
res_handle: ::std::os::raw::c_int,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_ctx_detach_resource(
|
||||
ctx_id: ::std::os::raw::c_int,
|
||||
res_handle: ::std::os::raw::c_int,
|
||||
);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct virgl_renderer_resource_info {
|
||||
pub handle: u32,
|
||||
pub virgl_format: u32,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub depth: u32,
|
||||
pub flags: u32,
|
||||
pub tex_id: u32,
|
||||
pub stride: u32,
|
||||
pub drm_fourcc: ::std::os::raw::c_int,
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_resource_get_info(
|
||||
res_handle: ::std::os::raw::c_int,
|
||||
info: *mut virgl_renderer_resource_info,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_cleanup(cookie: *mut ::std::os::raw::c_void);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_reset();
|
||||
}
|
||||
extern "C" {
|
||||
pub fn virgl_renderer_get_poll_fd() -> ::std::os::raw::c_int;
|
||||
}
|
880
gpu_renderer/src/lib.rs
Normal file
880
gpu_renderer/src/lib.rs
Normal file
|
@ -0,0 +1,880 @@
|
|||
// Copyright 2018 The Chromium OS Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
//! A crate for using hardware acceleration to render virtio-gpu's virgl command streams.
|
||||
|
||||
extern crate data_model;
|
||||
extern crate libc;
|
||||
extern crate sys_util;
|
||||
|
||||
mod generated;
|
||||
mod pipe_format_fourcc;
|
||||
mod command_buffer;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::fmt;
|
||||
use std::fs::File;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem::{size_of, transmute, uninitialized};
|
||||
use std::ops::Deref;
|
||||
use std::os::raw::{c_void, c_int, c_uint, c_char};
|
||||
use std::os::unix::io::FromRawFd;
|
||||
use std::ptr::{null, null_mut};
|
||||
use std::rc::Rc;
|
||||
use std::result;
|
||||
use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};
|
||||
|
||||
use data_model::{VolatileMemory, VolatileSlice};
|
||||
use sys_util::{GuestAddress, GuestMemory};
|
||||
|
||||
use generated::virglrenderer::*;
|
||||
pub use generated::virglrenderer::{virgl_renderer_resource_create_args,
|
||||
virgl_renderer_resource_info};
|
||||
use generated::epoxy_egl::{EGL_CONTEXT_CLIENT_VERSION, EGL_SURFACE_TYPE, EGL_OPENGL_ES_API,
|
||||
EGL_NONE, EGL_GL_TEXTURE_2D_KHR, EGLDEBUGPROCKHR, EGLAttrib,
|
||||
EGLuint64KHR, EGLNativeDisplayType, EGLConfig, EGLContext, EGLDisplay,
|
||||
EGLSurface, EGLClientBuffer, EGLBoolean, EGLint, EGLenum, EGLImageKHR};
|
||||
use generated::p_defines::{PIPE_TEXTURE_1D, PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW};
|
||||
use generated::p_format::PIPE_FORMAT_B8G8R8X8_UNORM;
|
||||
pub use pipe_format_fourcc::pipe_format_fourcc as format_fourcc;
|
||||
pub use command_buffer::CommandBufferBuilder;
|
||||
|
||||
/// Arguments used in `Renderer::create_resource`..
|
||||
pub type ResourceCreateArgs = virgl_renderer_resource_create_args;
|
||||
/// Information returned from `Resource::get_info`.
|
||||
pub type ResourceInfo = virgl_renderer_resource_info;
|
||||
|
||||
/// An error generated while using this crate.
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
/// Inidcates `Renderer` was already initialized, and only one renderer per process is allowed.
|
||||
AlreadyInitialized,
|
||||
/// Indicates libeopoxy was unable to load the EGL function with the given name.
|
||||
MissingEGLFunction(&'static str),
|
||||
/// A call to eglGetDisplay indicated failure.
|
||||
EGLGetDisplay,
|
||||
/// A call to eglInitialize indicated failure.
|
||||
EGLInitialize,
|
||||
/// A call to eglChooseConfig indicated failure.
|
||||
EGLChooseConfig,
|
||||
/// A call to eglBindAPI indicated failure.
|
||||
EGLBindAPI,
|
||||
/// A call to eglCreateContext indicated failure.
|
||||
EGLCreateContext,
|
||||
/// A call to eglMakeCurrent indicated failure.
|
||||
EGLMakeCurrent,
|
||||
/// An internal virglrenderer error was returned.
|
||||
Virglrenderer(i32),
|
||||
/// An EGLIMageKHR could not be created, indicating a EGL driver error.
|
||||
CreateImage,
|
||||
/// The EGL driver failed to export an EGLImageKHR as a dmabuf.
|
||||
ExportedResourceDmabuf,
|
||||
/// The indicated region of guest memory is invalid.
|
||||
InvalidIovec,
|
||||
/// A command size was submitted that was invalid.
|
||||
InvalidCommandSize(usize),
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use Error::*;
|
||||
match *self {
|
||||
AlreadyInitialized => write!(f, "global gpu renderer was already initailized"),
|
||||
MissingEGLFunction(name) => write!(f, "egl function `{}` was missing", name),
|
||||
EGLGetDisplay => write!(f, "call to eglGetDisplay failed"),
|
||||
EGLInitialize => write!(f, "call to eglInitialize failed"),
|
||||
EGLChooseConfig => write!(f, "call to eglChooseConfig failed"),
|
||||
EGLBindAPI => write!(f, "call to eglBindAPI failed"),
|
||||
EGLCreateContext => write!(f, "call to eglCreateContext failed"),
|
||||
EGLMakeCurrent => write!(f, "call to eglMakeCurrent failed"),
|
||||
Virglrenderer(ret) => write!(f, "virglrenderer failed with error {}", ret),
|
||||
CreateImage => write!(f, "failed to create EGLImage"),
|
||||
ExportedResourceDmabuf => write!(f, "failed to export dmabuf from EGLImageKHR"),
|
||||
InvalidIovec => write!(f, "an iovec is outside of guest memory's range"),
|
||||
InvalidCommandSize(s) => write!(f, "command buffer submitted with invalid size: {}", s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The result of an operation in this crate.
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
fn ret_to_res(ret: i32) -> Result<()> {
|
||||
match ret {
|
||||
0 => Ok(()),
|
||||
_ => Err(Error::Virglrenderer(ret)),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
struct VirglVec {
|
||||
base: *mut c_void,
|
||||
len: usize,
|
||||
}
|
||||
|
||||
/// An axis aligned box in 3 dimensional space.
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
pub struct Box3 {
|
||||
pub x: u32,
|
||||
pub y: u32,
|
||||
pub z: u32,
|
||||
pub w: u32,
|
||||
pub h: u32,
|
||||
pub d: u32,
|
||||
}
|
||||
|
||||
impl Box3 {
|
||||
/// Constructs a 2 dimensional XY box in 3 dimensional space with unit depth and zero
|
||||
/// displacement on the Z axis.
|
||||
pub fn new_2d(x: u32, w: u32, y: u32, h: u32) -> Box3 {
|
||||
Box3 {
|
||||
x,
|
||||
y,
|
||||
z: 0,
|
||||
w,
|
||||
h,
|
||||
d: 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct VirglCookie {
|
||||
display: EGLDisplay,
|
||||
egl_config: EGLConfig,
|
||||
egl_funcs: EGLFunctions,
|
||||
}
|
||||
|
||||
unsafe extern "C" fn create_gl_context(cookie: *mut c_void,
|
||||
scanout_idx: c_int,
|
||||
param: *mut virgl_renderer_gl_ctx_param)
|
||||
-> virgl_renderer_gl_context {
|
||||
let _ = scanout_idx;
|
||||
let cookie = &*(cookie as *mut VirglCookie);
|
||||
|
||||
let shared = if (*param).shared {
|
||||
(cookie.egl_funcs.GetCurrentContext)()
|
||||
} else {
|
||||
null_mut()
|
||||
};
|
||||
let context_attribs = [EGL_CONTEXT_CLIENT_VERSION as i32, 3, EGL_NONE as i32];
|
||||
(cookie.egl_funcs.CreateContext)(cookie.display,
|
||||
cookie.egl_config,
|
||||
shared,
|
||||
context_attribs.as_ptr())
|
||||
}
|
||||
|
||||
unsafe extern "C" fn make_current(cookie: *mut c_void,
|
||||
scanout_idx: c_int,
|
||||
ctx: virgl_renderer_gl_context)
|
||||
-> c_int {
|
||||
let _ = scanout_idx;
|
||||
let cookie = &*(cookie as *mut VirglCookie);
|
||||
|
||||
(cookie.egl_funcs.MakeCurrent)(cookie.display, null_mut(), null_mut(), ctx) as c_int
|
||||
}
|
||||
|
||||
unsafe extern "C" fn destroy_gl_context(cookie: *mut c_void, ctx: virgl_renderer_gl_context) {
|
||||
let cookie = &*(cookie as *mut VirglCookie);
|
||||
(cookie.egl_funcs.DestroyContext)(cookie.display, ctx);
|
||||
}
|
||||
|
||||
const VIRGL_RENDERER_CALLBACKS: &virgl_renderer_callbacks =
|
||||
&virgl_renderer_callbacks {
|
||||
version: 1,
|
||||
write_fence: None,
|
||||
create_gl_context: Some(create_gl_context),
|
||||
destroy_gl_context: Some(destroy_gl_context),
|
||||
make_current: Some(make_current),
|
||||
};
|
||||
|
||||
unsafe extern "C" fn error_callback(error: c_uint,
|
||||
command: *const c_char,
|
||||
_: c_int,
|
||||
_: *mut c_void,
|
||||
_: *mut c_void,
|
||||
message: *const c_char) {
|
||||
eprint!("EGL ERROR {}: {:?}", error, CStr::from_ptr(command));
|
||||
if !message.is_null() {
|
||||
eprint!(": {:?}", CStr::from_ptr(message));
|
||||
}
|
||||
eprintln!();
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
struct EGLFunctionsInner {
|
||||
BindAPI: unsafe extern "C" fn(api: EGLenum) -> EGLBoolean,
|
||||
ChooseConfig: unsafe extern "C" fn(dpy: EGLDisplay,
|
||||
attrib_list: *const EGLint,
|
||||
configs: *mut EGLConfig,
|
||||
config_size: EGLint,
|
||||
num_config: *mut EGLint)
|
||||
-> EGLBoolean,
|
||||
CreateContext: unsafe extern "C" fn(dpy: EGLDisplay,
|
||||
config: EGLConfig,
|
||||
share_context: EGLContext,
|
||||
attrib_list: *const EGLint)
|
||||
-> EGLContext,
|
||||
CreateImageKHR: unsafe extern "C" fn(dpy: EGLDisplay,
|
||||
ctx: EGLContext,
|
||||
target: EGLenum,
|
||||
buffer: EGLClientBuffer,
|
||||
attrib_list: *const EGLint)
|
||||
-> EGLImageKHR,
|
||||
DebugMessageControlKHR:
|
||||
unsafe extern "C" fn(callback: EGLDEBUGPROCKHR, attrib_list: *const EGLAttrib) -> EGLint,
|
||||
DestroyContext: unsafe extern "C" fn(dpy: EGLDisplay, ctx: EGLContext) -> EGLBoolean,
|
||||
DestroyImageKHR: unsafe extern "C" fn(dpy: EGLDisplay, image: EGLImageKHR) -> EGLBoolean,
|
||||
ExportDRMImageMESA: unsafe extern "C" fn(dpy: EGLDisplay,
|
||||
image: EGLImageKHR,
|
||||
fds: *mut ::std::os::raw::c_int,
|
||||
strides: *mut EGLint,
|
||||
offsets: *mut EGLint)
|
||||
-> EGLBoolean,
|
||||
ExportDMABUFImageQueryMESA: unsafe extern "C" fn(dpy: EGLDisplay,
|
||||
image: EGLImageKHR,
|
||||
fourcc: *mut ::std::os::raw::c_int,
|
||||
num_planes: *mut ::std::os::raw::c_int,
|
||||
modifiers: *mut EGLuint64KHR)
|
||||
-> EGLBoolean,
|
||||
GetCurrentContext: unsafe extern "C" fn() -> EGLContext,
|
||||
GetCurrentDisplay: unsafe extern "C" fn() -> EGLDisplay,
|
||||
GetDisplay: unsafe extern "C" fn(display_id: EGLNativeDisplayType) -> EGLDisplay,
|
||||
Initialize:
|
||||
unsafe extern "C" fn(dpy: EGLDisplay, major: *mut EGLint, minor: *mut EGLint) -> EGLBoolean,
|
||||
MakeCurrent: unsafe extern "C" fn(dpy: EGLDisplay,
|
||||
draw: EGLSurface,
|
||||
read: EGLSurface,
|
||||
ctx: EGLContext)
|
||||
-> EGLBoolean,
|
||||
no_sync_send: PhantomData<*mut ()>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct EGLFunctions(Rc<EGLFunctionsInner>);
|
||||
|
||||
impl EGLFunctions {
|
||||
fn new() -> Result<EGLFunctions> {
|
||||
use generated::epoxy_egl::{epoxy_eglBindAPI, epoxy_eglChooseConfig,
|
||||
epoxy_eglCreateContext, epoxy_eglCreateImageKHR,
|
||||
epoxy_eglDebugMessageControlKHR, epoxy_eglDestroyContext,
|
||||
epoxy_eglDestroyImageKHR, epoxy_eglExportDRMImageMESA,
|
||||
epoxy_eglExportDMABUFImageQueryMESA,
|
||||
epoxy_eglGetCurrentContext, epoxy_eglGetCurrentDisplay,
|
||||
epoxy_eglGetDisplay, epoxy_eglInitialize, epoxy_eglMakeCurrent};
|
||||
// This is unsafe because it is reading mutable static variables exported by epoxy. These
|
||||
// variables are initialized during the binary's init and never modified again, so it should
|
||||
// be safe to read them now.
|
||||
unsafe {
|
||||
Ok(EGLFunctions(Rc::new(EGLFunctionsInner {
|
||||
BindAPI: epoxy_eglBindAPI.ok_or(Error::MissingEGLFunction("eglBindAPI"))?,
|
||||
ChooseConfig: epoxy_eglChooseConfig.ok_or(Error::MissingEGLFunction("eglChooseConfig"))?,
|
||||
CreateContext: epoxy_eglCreateContext.ok_or(Error::MissingEGLFunction("eglCreateContext"))?,
|
||||
CreateImageKHR: epoxy_eglCreateImageKHR.ok_or(Error::MissingEGLFunction("eglCreateImageKHR"))?,
|
||||
DebugMessageControlKHR: epoxy_eglDebugMessageControlKHR.ok_or(Error::MissingEGLFunction("eglDebugMessageControlKHR"))?,
|
||||
DestroyContext: epoxy_eglDestroyContext.ok_or(Error::MissingEGLFunction("eglDestroyContext"))?,
|
||||
DestroyImageKHR: epoxy_eglDestroyImageKHR.ok_or(Error::MissingEGLFunction("eglDestroyImageKHR"))?,
|
||||
ExportDRMImageMESA: epoxy_eglExportDRMImageMESA.ok_or(Error::MissingEGLFunction("eglExportDRMImageMESA"))?,
|
||||
ExportDMABUFImageQueryMESA: epoxy_eglExportDMABUFImageQueryMESA.ok_or(Error::MissingEGLFunction("eglExportDMABUFImageQueryMESA"))?,
|
||||
GetCurrentContext: epoxy_eglGetCurrentContext.ok_or(Error::MissingEGLFunction("eglGetCurrentContext"))?,
|
||||
GetCurrentDisplay: epoxy_eglGetCurrentDisplay.ok_or(Error::MissingEGLFunction("eglGetCurrentDisplay"))?,
|
||||
GetDisplay: epoxy_eglGetDisplay.ok_or(Error::MissingEGLFunction("eglGetDisplay"))?,
|
||||
Initialize: epoxy_eglInitialize.ok_or(Error::MissingEGLFunction("eglInitialize"))?,
|
||||
MakeCurrent: epoxy_eglMakeCurrent.ok_or(Error::MissingEGLFunction("eglMakeCurrent"))?,
|
||||
no_sync_send: PhantomData,
|
||||
})))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for EGLFunctions {
|
||||
type Target = EGLFunctionsInner;
|
||||
fn deref(&self) -> &EGLFunctionsInner {
|
||||
self.0.deref()
|
||||
}
|
||||
}
|
||||
|
||||
/// The global renderer handle used to query capability sets, and create resources and contexts.
|
||||
pub struct Renderer {
|
||||
no_sync_send: PhantomData<*mut ()>,
|
||||
egl_funcs: EGLFunctions,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
/// Initializes the renderer and returns a handle to it.
|
||||
///
|
||||
/// This may only be called once per process. Calls after the first will return an error.
|
||||
pub fn init() -> Result<Renderer> {
|
||||
// virglrenderer is a global state backed library that uses thread bound OpenGL contexts.
|
||||
// Initialize it only once and use the non-send/non-sync Renderer struct to keep things tied
|
||||
// to whichever thread called this function first.
|
||||
static INIT_ONCE: AtomicBool = ATOMIC_BOOL_INIT;
|
||||
if INIT_ONCE.compare_and_swap(false, true, Ordering::Acquire) {
|
||||
return Err(Error::AlreadyInitialized);
|
||||
}
|
||||
|
||||
let egl_funcs = EGLFunctions::new()?;
|
||||
|
||||
// Safe because only valid callbacks are given and only one thread can execute this
|
||||
// function.
|
||||
unsafe {
|
||||
(egl_funcs.DebugMessageControlKHR)(Some(error_callback), null());
|
||||
}
|
||||
|
||||
// Trivially safe.
|
||||
let display = unsafe { (egl_funcs.GetDisplay)(null_mut()) };
|
||||
if display.is_null() {
|
||||
return Err(Error::EGLGetDisplay);
|
||||
}
|
||||
|
||||
// Safe because only a valid display is given.
|
||||
let ret = unsafe { (egl_funcs.Initialize)(display, null_mut(), null_mut()) };
|
||||
if ret == 0 {
|
||||
return Err(Error::EGLInitialize);
|
||||
}
|
||||
|
||||
let config_attribs = [EGL_SURFACE_TYPE as i32, -1, EGL_NONE as i32];
|
||||
// Safe because these uninitialized variables get initialized by the ChooseConfig function.
|
||||
let mut egl_config: *mut c_void = unsafe { uninitialized() };
|
||||
let mut num_configs = unsafe { uninitialized() };
|
||||
// Safe because only a valid, initialized display is used, along with validly sized
|
||||
// pointers to stack variables.
|
||||
let ret = unsafe {
|
||||
(egl_funcs.ChooseConfig)(display,
|
||||
config_attribs.as_ptr(),
|
||||
&mut egl_config,
|
||||
1,
|
||||
&mut num_configs /* unused but can't be null */)
|
||||
};
|
||||
if ret == 0 {
|
||||
return Err(Error::EGLChooseConfig);
|
||||
}
|
||||
|
||||
// Cookie is intentionally never freed because virglrenderer never gets uninitialized.
|
||||
// Otherwise, Resource and Context would become invalid because their lifetime is not tied
|
||||
// to the Renderer instance. Doing so greatly simplifies the ownership for users of this
|
||||
// library.
|
||||
let cookie: *mut VirglCookie = Box::into_raw(Box::new(VirglCookie {
|
||||
display,
|
||||
egl_config,
|
||||
egl_funcs: egl_funcs.clone(),
|
||||
}));
|
||||
|
||||
// Safe because EGL was properly initialized before here..
|
||||
let ret = unsafe { (egl_funcs.BindAPI)(EGL_OPENGL_ES_API) };
|
||||
if ret == 0 {
|
||||
return Err(Error::EGLBindAPI);
|
||||
}
|
||||
|
||||
let context_attribs = [EGL_CONTEXT_CLIENT_VERSION as i32, 3, EGL_NONE as i32];
|
||||
// Safe because a valid display, config, and config_attribs pointer are given.
|
||||
let ctx = unsafe {
|
||||
(egl_funcs.CreateContext)(display, egl_config, null_mut(), context_attribs.as_ptr())
|
||||
};
|
||||
if ctx.is_null() {
|
||||
return Err(Error::EGLCreateContext);
|
||||
}
|
||||
|
||||
// Safe because a valid display and context is used, and the two null surfaces are not
|
||||
// used.
|
||||
let ret = unsafe { (egl_funcs.MakeCurrent)(display, null_mut(), null_mut(), ctx) };
|
||||
if ret == 0 {
|
||||
return Err(Error::EGLMakeCurrent);
|
||||
}
|
||||
|
||||
// Safe because a valid cookie and set of callbacks is used and the result is checked for
|
||||
// error.
|
||||
let ret = unsafe {
|
||||
virgl_renderer_init(cookie as *mut c_void,
|
||||
0,
|
||||
transmute(VIRGL_RENDERER_CALLBACKS))
|
||||
};
|
||||
ret_to_res(ret)?;
|
||||
|
||||
Ok(Renderer {
|
||||
no_sync_send: PhantomData,
|
||||
egl_funcs,
|
||||
})
|
||||
}
|
||||
|
||||
/// Gets the version and size for the given capability set ID.
|
||||
pub fn get_cap_set_info(&self, id: u32) -> (u32, u32) {
|
||||
let mut version = 0;
|
||||
let mut size = 0;
|
||||
// Safe because virglrenderer is initialized by now and properly size stack variables are
|
||||
// used for the pointers.
|
||||
unsafe {
|
||||
virgl_renderer_get_cap_set(id, &mut version, &mut size);
|
||||
}
|
||||
(version, size)
|
||||
}
|
||||
|
||||
/// Gets the capability set for the given ID and version.
|
||||
pub fn get_cap_set(&self, id: u32, version: u32) -> Vec<u8> {
|
||||
let (_, max_size) = self.get_cap_set_info(id);
|
||||
let mut buf = vec![0u8; max_size as usize];
|
||||
// Safe because virglrenderer is initialized by now and the given buffer is sized properly
|
||||
// for the given cap id/version.
|
||||
unsafe {
|
||||
virgl_renderer_fill_caps(id, version, buf.as_mut_ptr() as *mut c_void);
|
||||
}
|
||||
buf
|
||||
}
|
||||
|
||||
/// Creates a rendering context with the given id.
|
||||
pub fn create_context(&self, id: u32) -> Result<Context> {
|
||||
const CONTEXT_NAME: &[u8] = b"gpu_renderer";
|
||||
// Safe because virglrenderer is initialized by now and the context name is statically
|
||||
// allocated. The return value is checked before returning a new context.
|
||||
let ret = unsafe {
|
||||
virgl_renderer_context_create(id,
|
||||
CONTEXT_NAME.len() as u32,
|
||||
CONTEXT_NAME.as_ptr() as *const c_char)
|
||||
};
|
||||
ret_to_res(ret)?;
|
||||
Ok(Context {
|
||||
id,
|
||||
no_sync_send: PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
/// Creates a resource with the given arguments.
|
||||
pub fn create_resource(&self,
|
||||
mut args: virgl_renderer_resource_create_args)
|
||||
-> Result<Resource> {
|
||||
// Safe because virglrenderer is initialized by now, and the return value is checked before
|
||||
// returning a new resource. The backing buffers are not supplied with this call.
|
||||
let ret = unsafe { virgl_renderer_resource_create(&mut args, null_mut(), 0) };
|
||||
ret_to_res(ret)?;
|
||||
Ok(Resource {
|
||||
id: args.handle,
|
||||
backing_iovecs: Vec::new(),
|
||||
backing_mem: None,
|
||||
egl_funcs: self.egl_funcs.clone(),
|
||||
no_sync_send: PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
/// Helper that creates a simple 1 dimensional resource with basic metadata.
|
||||
pub fn create_tex_1d(&self, id: u32, width: u32) -> Result<Resource> {
|
||||
self.create_resource(virgl_renderer_resource_create_args {
|
||||
handle: id,
|
||||
target: PIPE_TEXTURE_1D,
|
||||
format: PIPE_FORMAT_B8G8R8X8_UNORM,
|
||||
width,
|
||||
height: 1,
|
||||
depth: 1,
|
||||
array_size: 1,
|
||||
last_level: 0,
|
||||
nr_samples: 0,
|
||||
bind: PIPE_BIND_SAMPLER_VIEW,
|
||||
flags: 0,
|
||||
})
|
||||
}
|
||||
|
||||
/// Helper that creates a simple 2 dimensional resource with basic metadata.
|
||||
pub fn create_tex_2d(&self, id: u32, width: u32, height: u32) -> Result<Resource> {
|
||||
self.create_resource(virgl_renderer_resource_create_args {
|
||||
handle: id,
|
||||
target: PIPE_TEXTURE_2D,
|
||||
format: PIPE_FORMAT_B8G8R8X8_UNORM,
|
||||
width,
|
||||
height,
|
||||
depth: 1,
|
||||
array_size: 1,
|
||||
last_level: 0,
|
||||
nr_samples: 0,
|
||||
bind: PIPE_BIND_SAMPLER_VIEW,
|
||||
flags: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// A context in which resources can be attached/detached and commands can be submitted.
|
||||
pub struct Context {
|
||||
id: u32,
|
||||
no_sync_send: PhantomData<*mut ()>,
|
||||
}
|
||||
|
||||
impl Context {
|
||||
/// Gets the ID assigned to this context when it was created.
|
||||
pub fn id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
/// Submits a command stream to this rendering context.
|
||||
pub fn submit<T: AsMut<[u8]>>(&mut self, mut buf: T) -> Result<()> {
|
||||
let buf = buf.as_mut();
|
||||
if buf.len() % size_of::<u32>() != 0 {
|
||||
return Err(Error::InvalidCommandSize(buf.len()));
|
||||
}
|
||||
let dword_count = (buf.len() / size_of::<u32>()) as i32;
|
||||
// Safe because the context and buffer are valid and virglrenderer will have been
|
||||
// initialized if there are Context instances.
|
||||
let ret = unsafe {
|
||||
virgl_renderer_submit_cmd(buf.as_mut_ptr() as *mut c_void, self.id as i32, dword_count)
|
||||
};
|
||||
ret_to_res(ret)
|
||||
}
|
||||
|
||||
/// Attaches the given resource to this rendering context.
|
||||
pub fn attach(&mut self, res: &Resource) {
|
||||
// The context id and resource id must be valid because the respective instances ensure
|
||||
// their lifetime.
|
||||
unsafe {
|
||||
virgl_renderer_ctx_attach_resource(self.id as i32, res.id() as i32);
|
||||
}
|
||||
}
|
||||
|
||||
/// Detaches a previously attached resource from this rendering context.
|
||||
pub fn detach(&mut self, res: &Resource) {
|
||||
// The context id and resource id must be valid because the respective instances ensure
|
||||
// their lifetime.
|
||||
unsafe {
|
||||
virgl_renderer_ctx_detach_resource(self.id as i32, res.id() as i32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Context {
|
||||
fn drop(&mut self) {
|
||||
// The context is safe to destroy because nothing else can be referencing it.
|
||||
unsafe {
|
||||
virgl_renderer_context_destroy(self.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A DMABUF file descriptor handle and metadata returned from `Resource::export`.
|
||||
#[derive(Debug)]
|
||||
pub struct ExportedResource {
|
||||
/// The file descriptor that represents the DMABUF kernel object.
|
||||
pub dmabuf: File,
|
||||
/// The width in pixels of the exported resource.
|
||||
pub width: u32,
|
||||
/// The height in pixels of the exported resource.
|
||||
pub height: u32,
|
||||
/// The fourcc identifier for the format of the resource.
|
||||
pub fourcc: u32,
|
||||
/// Extra modifiers for the format.
|
||||
pub modifiers: u64,
|
||||
/// The number of bytes between successive rows in the exported resource.
|
||||
pub stride: u32,
|
||||
/// The number of bytes from the start of the exported resource to the first pixel.
|
||||
pub offset: u32,
|
||||
}
|
||||
|
||||
/// A resource handle used by the renderer.
|
||||
pub struct Resource {
|
||||
id: u32,
|
||||
backing_iovecs: Vec<VirglVec>,
|
||||
backing_mem: Option<GuestMemory>,
|
||||
egl_funcs: EGLFunctions,
|
||||
no_sync_send: PhantomData<*mut ()>,
|
||||
}
|
||||
|
||||
impl Resource {
|
||||
/// Gets the ID assigned to this resource when it was created.
|
||||
pub fn id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
/// Retrieves metadata about this resource.
|
||||
pub fn get_info(&self) -> Result<ResourceInfo> {
|
||||
// Safe because the resource info is filled in by the virgl call and only returned if it was
|
||||
// successful.
|
||||
let mut res_info = unsafe { uninitialized() };
|
||||
let ret = unsafe { virgl_renderer_resource_get_info(self.id as i32, &mut res_info) };
|
||||
ret_to_res(ret)?;
|
||||
Ok(res_info)
|
||||
}
|
||||
|
||||
/// Performs an export of this resource so that it may be imported by other processes.
|
||||
pub fn export(&self) -> Result<ExportedResource> {
|
||||
let res_info = self.get_info()?;
|
||||
let mut fourcc = 0;
|
||||
let mut modifiers = 0;
|
||||
let mut fd = -1;
|
||||
let mut stride = 0;
|
||||
let mut offset = 0;
|
||||
// Always safe on the same thread with an already initialized virglrenderer.
|
||||
unsafe {
|
||||
virgl_renderer_force_ctx_0();
|
||||
}
|
||||
// These are trivially safe and always return successfully because we bind the context in
|
||||
// the previous line.
|
||||
let egl_dpy: EGLDisplay = unsafe { (self.egl_funcs.GetCurrentDisplay)() };
|
||||
let egl_ctx: EGLContext = unsafe { (self.egl_funcs.GetCurrentContext)() };
|
||||
|
||||
// Safe because a valid display, context, and texture ID are given. The attribute list is
|
||||
// not needed. The result is checked to ensure the returned image is valid.
|
||||
let image = unsafe {
|
||||
(self.egl_funcs.CreateImageKHR)(egl_dpy,
|
||||
egl_ctx,
|
||||
EGL_GL_TEXTURE_2D_KHR,
|
||||
res_info.tex_id as EGLClientBuffer,
|
||||
null())
|
||||
};
|
||||
|
||||
if image.is_null() {
|
||||
return Err(Error::CreateImage);
|
||||
}
|
||||
|
||||
// Safe because the display and image are valid and each function call is checked for
|
||||
// success. The returned image parameters are stored in stack variables of the correct type.
|
||||
let export_success = unsafe {
|
||||
(self.egl_funcs.ExportDMABUFImageQueryMESA)(egl_dpy,
|
||||
image,
|
||||
&mut fourcc,
|
||||
null_mut(),
|
||||
&mut modifiers) != 0 &&
|
||||
(self.egl_funcs.ExportDRMImageMESA)(egl_dpy,
|
||||
image,
|
||||
&mut fd,
|
||||
&mut stride,
|
||||
&mut offset) != 0
|
||||
};
|
||||
|
||||
// Safe because we checked that the image was valid and nobody else owns it. The image does
|
||||
// not need to be around for the dmabuf to be valid.
|
||||
unsafe {
|
||||
(self.egl_funcs.DestroyImageKHR)(egl_dpy, image);
|
||||
}
|
||||
|
||||
if !export_success || fd < 0 {
|
||||
return Err(Error::ExportedResourceDmabuf);
|
||||
}
|
||||
|
||||
// Safe because the FD was just returned by a successful EGL call so it must be valid and
|
||||
// owned by us.
|
||||
let dmabuf = unsafe { File::from_raw_fd(fd) };
|
||||
Ok(ExportedResource {
|
||||
dmabuf,
|
||||
width: res_info.width,
|
||||
height: res_info.height,
|
||||
fourcc: fourcc as u32,
|
||||
modifiers: modifiers,
|
||||
stride: stride as u32,
|
||||
offset: offset as u32,
|
||||
})
|
||||
}
|
||||
|
||||
/// Attaches a scatter-gather mapping of guest memory to this resource which used for transfers.
|
||||
pub fn attach_backing(&mut self,
|
||||
iovecs: &[(GuestAddress, usize)],
|
||||
mem: &GuestMemory)
|
||||
-> Result<()> {
|
||||
if iovecs
|
||||
.iter()
|
||||
.any(|&(addr, len)| mem.get_slice(addr.offset(), len as u64).is_err()) {
|
||||
return Err(Error::InvalidIovec);
|
||||
}
|
||||
self.detach_backing();
|
||||
self.backing_mem = Some(mem.clone());
|
||||
for &(addr, len) in iovecs.iter() {
|
||||
// Unwrap will not panic because we already checked the slices.
|
||||
let slice = mem.get_slice(addr.offset(), len as u64).unwrap();
|
||||
self.backing_iovecs
|
||||
.push(VirglVec {
|
||||
base: slice.as_ptr() as *mut c_void,
|
||||
len,
|
||||
});
|
||||
}
|
||||
// Safe because the backing is into guest memory that we store a reference count for.
|
||||
let ret = unsafe {
|
||||
virgl_renderer_resource_attach_iov(self.id as i32,
|
||||
self.backing_iovecs.as_mut_ptr() as *mut iovec,
|
||||
self.backing_iovecs.len() as i32)
|
||||
};
|
||||
let res = ret_to_res(ret);
|
||||
if res.is_err() {
|
||||
// Not strictly necessary, but it's good to clear out our collection of pointers to
|
||||
// memory we don't own or need.
|
||||
self.backing_iovecs.clear();
|
||||
self.backing_mem = None;
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
/// Detaches previously attached scatter-gather memory from this resource.
|
||||
pub fn detach_backing(&mut self) {
|
||||
// Safe as we don't need the old backing iovecs returned and the reference to the guest
|
||||
// memory can be dropped as it will no longer be needed for this resource.
|
||||
unsafe {
|
||||
virgl_renderer_resource_detach_iov(self.id as i32, null_mut(), null_mut());
|
||||
}
|
||||
self.backing_iovecs.clear();
|
||||
self.backing_mem = None;
|
||||
}
|
||||
|
||||
/// Performs a transfer to the given resource from its backing in guest memory.
|
||||
pub fn transfer_write(&self,
|
||||
ctx: Option<&Context>,
|
||||
level: u32,
|
||||
stride: u32,
|
||||
layer_stride: u32,
|
||||
mut transfer_box: Box3,
|
||||
offset: u64)
|
||||
-> Result<()> {
|
||||
// Safe because only stack variables of the appropriate type are used.
|
||||
let ret = unsafe {
|
||||
virgl_renderer_transfer_write_iov(self.id,
|
||||
ctx.map(Context::id).unwrap_or(0),
|
||||
level as i32,
|
||||
stride,
|
||||
layer_stride,
|
||||
&mut transfer_box as *mut Box3 as *mut virgl_box,
|
||||
offset,
|
||||
null_mut(),
|
||||
0)
|
||||
};
|
||||
ret_to_res(ret)
|
||||
}
|
||||
|
||||
/// Performs a transfer from the given resource to its backing in guest memory.
|
||||
pub fn transfer_read(&self,
|
||||
ctx: Option<&Context>,
|
||||
level: u32,
|
||||
stride: u32,
|
||||
layer_stride: u32,
|
||||
mut transfer_box: Box3,
|
||||
offset: u64)
|
||||
-> Result<()> {
|
||||
// Safe because only stack variables of the appropriate type are used.
|
||||
let ret = unsafe {
|
||||
virgl_renderer_transfer_read_iov(self.id,
|
||||
ctx.map(Context::id).unwrap_or(0),
|
||||
level,
|
||||
stride,
|
||||
layer_stride,
|
||||
&mut transfer_box as *mut Box3 as *mut virgl_box,
|
||||
offset,
|
||||
null_mut(),
|
||||
0)
|
||||
};
|
||||
ret_to_res(ret)
|
||||
}
|
||||
|
||||
/// Performs a transfer from the given resource to the provided `buf`
|
||||
pub fn transfer_read_buf(&self,
|
||||
ctx: Option<&Context>,
|
||||
level: u32,
|
||||
stride: u32,
|
||||
layer_stride: u32,
|
||||
mut transfer_box: Box3,
|
||||
offset: u64,
|
||||
buf: &mut [u8])
|
||||
-> Result<()> {
|
||||
let mut iov = VirglVec {
|
||||
base: buf.as_mut_ptr() as *mut c_void,
|
||||
len: buf.len(),
|
||||
};
|
||||
// Safe because only stack variables of the appropriate type are used, along with a properly
|
||||
// sized buffer.
|
||||
let ret = unsafe {
|
||||
virgl_renderer_transfer_read_iov(self.id,
|
||||
ctx.map(Context::id).unwrap_or(0),
|
||||
level,
|
||||
stride,
|
||||
layer_stride,
|
||||
&mut transfer_box as *mut Box3 as *mut virgl_box,
|
||||
offset,
|
||||
&mut iov as *mut VirglVec as *mut iovec,
|
||||
1)
|
||||
};
|
||||
ret_to_res(ret)
|
||||
}
|
||||
|
||||
/// Reads from this resource to a volatile slice of memory.
|
||||
pub fn read_to_volatile(&self,
|
||||
ctx: Option<&Context>,
|
||||
level: u32,
|
||||
stride: u32,
|
||||
layer_stride: u32,
|
||||
mut transfer_box: Box3,
|
||||
offset: u64,
|
||||
buf: VolatileSlice)
|
||||
-> Result<()> {
|
||||
let mut iov = VirglVec {
|
||||
base: buf.as_ptr() as *mut c_void,
|
||||
len: buf.size() as usize,
|
||||
};
|
||||
// Safe because only stack variables of the appropriate type are used, along with a properly
|
||||
// sized buffer.
|
||||
let ret = unsafe {
|
||||
virgl_renderer_transfer_read_iov(self.id,
|
||||
ctx.map(Context::id).unwrap_or(0),
|
||||
level,
|
||||
stride,
|
||||
layer_stride,
|
||||
&mut transfer_box as *mut Box3 as *mut virgl_box,
|
||||
offset,
|
||||
&mut iov as *mut VirglVec as *mut iovec,
|
||||
1)
|
||||
};
|
||||
ret_to_res(ret)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Resource {
|
||||
fn drop(&mut self) {
|
||||
// The resource is safe to unreference destroy because no user of these bindings can still
|
||||
// be holding a reference.
|
||||
unsafe {
|
||||
virgl_renderer_resource_unref(self.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use generated::p_defines::PIPE_CLEAR_COLOR0;
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
// Make sure a simple buffer clear works by using a command stream.
|
||||
fn simple_clear() {
|
||||
let render = Renderer::init().expect("failed to initialize virglrenderer");
|
||||
let mut ctx = render
|
||||
.create_context(1)
|
||||
.expect("failed to create context");
|
||||
|
||||
// Create a 50x50 texture with id=2.
|
||||
let resource = render
|
||||
.create_tex_2d(2, 50, 50)
|
||||
.expect("failed to create texture");
|
||||
ctx.attach(&resource);
|
||||
|
||||
// Create a command buffer that uses the resource as a render target and clears it.
|
||||
const CLEAR_COLOR: [f32; 4] = [0.5, 0.4, 0.3, 0.2];
|
||||
let mut cbuf = CommandBufferBuilder::new();
|
||||
cbuf.e_create_surface(1, &resource, PIPE_FORMAT_B8G8R8X8_UNORM, 0, 0, 0);
|
||||
cbuf.e_set_fb_state(&[1], None);
|
||||
cbuf.e_clear(PIPE_CLEAR_COLOR0, CLEAR_COLOR, 0.0, 0);
|
||||
ctx.submit(&mut cbuf)
|
||||
.expect("failed to submit command buffer to context");
|
||||
|
||||
// Read the result of the rendering into a buffer.
|
||||
let mut pix_buf = [0; 50 * 50 * 4];
|
||||
resource
|
||||
.transfer_read_buf(Some(&ctx),
|
||||
0,
|
||||
50,
|
||||
0,
|
||||
Box3::new_2d(0, 5, 0, 1),
|
||||
0,
|
||||
&mut pix_buf[..])
|
||||
.expect("failed to read back resource data");
|
||||
|
||||
// Check that the pixels are the color we cleared to. The red and blue channels are switched
|
||||
// because the surface was created with the BGR format, but the colors are RGB order in the
|
||||
// command stream.
|
||||
assert_eq!(pix_buf[0], (256.0 * CLEAR_COLOR[2]) as u8);
|
||||
assert_eq!(pix_buf[1], (256.0 * CLEAR_COLOR[1]) as u8);
|
||||
assert_eq!(pix_buf[2], (256.0 * CLEAR_COLOR[0]) as u8);
|
||||
assert_eq!(pix_buf[3], (256.0 * CLEAR_COLOR[3]) as u8);
|
||||
}
|
||||
}
|
20
gpu_renderer/src/pipe_format_fourcc.rs
Normal file
20
gpu_renderer/src/pipe_format_fourcc.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2018 The Chromium OS Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
use generated::p_format;
|
||||
|
||||
macro_rules! fourcc {
|
||||
($a:expr, $b:expr, $c:expr, $d:expr) => (
|
||||
Some($a as u32 | ($b as u32) << 8 | ($c as u32) << 16 | ($d as u32) << 24)
|
||||
)
|
||||
}
|
||||
|
||||
/// Gets the fourcc that corresponds to the given pipe format, or `None` if the format is
|
||||
/// unrecognized.
|
||||
pub fn pipe_format_fourcc(f: p_format::pipe_format) -> Option<u32> {
|
||||
match f {
|
||||
p_format::PIPE_FORMAT_B8G8R8X8_UNORM => fourcc!('X', 'R', '2', '4'),
|
||||
_ => None,
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue