1
0
mirror of https://github.com/elima/gpu-playground.git synced 2025-06-06 15:36:35 +00:00

Adds a vulkan triangle example

Uses xcb as WSI with minimum integration (resize, fullscreen, etc).
This commit is contained in:
Eduardo Lima Mitev 2016-09-23 09:21:58 +02:00
parent 7eadd11e3e
commit a731e75f93
6 changed files with 1476 additions and 0 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ frag.spv
render-nodes-minimal/render-nodes-minimal render-nodes-minimal/render-nodes-minimal
vulkan-minimal/vulkan-minimal vulkan-minimal/vulkan-minimal
vulkan-triangle/vulkan-triangle

View File

@ -1,7 +1,9 @@
all: Makefile all: Makefile
make -C render-nodes-minimal all make -C render-nodes-minimal all
make -C vulkan-minimal all make -C vulkan-minimal all
make -C vulkan-triangle all
clean: clean:
make -C render-nodes-minimal clean make -C render-nodes-minimal clean
make -C vulkan-minimal clean make -C vulkan-minimal clean
make -C vulkan-triangle clean

26
vulkan-triangle/Makefile Normal file
View File

@ -0,0 +1,26 @@
TARGET=vulkan-triangle
GLSL_VALIDATOR=../glslangValidator
VULKAN_SO_NAME=vulkan_intel
VULKAN_SO_PATH=~/devel/build/lib
all: Makefile $(TARGET) vert.spv frag.spv
vert.spv: shader.vert
$(GLSL_VALIDATOR) -V shader.vert
frag.spv: shader.frag
$(GLSL_VALIDATOR) -V shader.frag
$(TARGET): main.c vert.spv frag.spv
gcc -ggdb -O0 -Wall -std=c99 \
-DCURRENT_DIR=\"`pwd`\" \
`pkg-config --libs --cflags xcb` \
-L $(VULKAN_SO_PATH) \
-l$(VULKAN_SO_NAME) \
-o $(TARGET) \
main.c
clean:
rm -f $(TARGET) vert.spv frag.spv

1413
vulkan-triangle/main.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) out highp vec4 outColor;
layout(location = 0) in vec3 color;
void main() {
outColor = vec4(color, 1.0);
}

View File

@ -0,0 +1,25 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
out gl_PerVertex {
vec4 gl_Position;
};
vec2 positions[3] = vec2[](
vec2( 0.0, -0.5),
vec2( 0.5, 0.5),
vec2(-0.5, 0.5)
);
vec3 colors[3] = vec3[] (
vec3(1.0, 0.0, 0.0),
vec3(0.0, 1.0, 0.0),
vec3(0.0, 0.0, 1.0)
);
layout(location = 0) out vec3 color;
void main() {
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
color = colors[gl_VertexIndex];
}