mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-26 00:41:33 +11:00
Basic Vulkan header hookup and automation
This commit is contained in:
parent
878a12c594
commit
7f30e22a05
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
/target/
|
||||||
|
native/test
|
||||||
|
native/test.o
|
||||||
|
native/vulkan
|
||||||
|
src/original.rs
|
||||||
|
**/*.rs.bk
|
||||||
|
Cargo.lock
|
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "portability"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Dzmitry Malyshau <kvark@mozilla.com>"]
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "vulkan"
|
||||||
|
crate-type = ["dylib"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
gfx_core = { path = "../gfx/src/core" }
|
||||||
|
gfx_backend_vulkan = { path = "../gfx/src/backend/vulkan" }
|
23
Makefile
Normal file
23
Makefile
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
HEADER=native/vulkan/vulkan.h
|
||||||
|
BINDING=src/original.rs
|
||||||
|
TARGET=native/test
|
||||||
|
OBJECTS=native/test.o
|
||||||
|
OUTPUT_DIR=target/debug
|
||||||
|
OUTPUT=${OUTPUT_DIR}/libvulkan.a
|
||||||
|
|
||||||
|
all: ${TARGET}
|
||||||
|
|
||||||
|
${BINDING}: ${HEADER}
|
||||||
|
bindgen --no-layout-tests --rustfmt-bindings ${HEADER} -o ${BINDING}
|
||||||
|
|
||||||
|
portability: ${BINDING}
|
||||||
|
cargo build
|
||||||
|
|
||||||
|
${TARGET}: portability ${OBJECTS}
|
||||||
|
gcc -o ${TARGET} -L${OUTPUT_DIR} -lvulkan ${OBJECTS}
|
||||||
|
|
||||||
|
run: ${TARGET}
|
||||||
|
${TARGET}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f ${OBJECTS} ${TARGET} ${BINDING}
|
31
native/test.c
Normal file
31
native/test.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include "vulkan/vulkan.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
VkInstanceCreateInfo inst_info = {};
|
||||||
|
inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||||
|
inst_info.pNext = NULL;
|
||||||
|
inst_info.flags = 0;
|
||||||
|
inst_info.pApplicationInfo = NULL;
|
||||||
|
inst_info.enabledExtensionCount = 0;
|
||||||
|
inst_info.ppEnabledExtensionNames = NULL;
|
||||||
|
inst_info.enabledLayerCount = 0;
|
||||||
|
inst_info.ppEnabledLayerNames = NULL;
|
||||||
|
|
||||||
|
VkInstance inst;
|
||||||
|
VkResult res;
|
||||||
|
|
||||||
|
res = vkCreateInstance(&inst_info, NULL, &inst);
|
||||||
|
if (res == VK_ERROR_INCOMPATIBLE_DRIVER) {
|
||||||
|
printf("cannot find a compatible Vulkan ICD\n");
|
||||||
|
exit(-1);
|
||||||
|
} else if (res) {
|
||||||
|
printf("unknown error\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
vkDestroyInstance(inst, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
7815
src/lib.rs
Normal file
7815
src/lib.rs
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue