Add VulkanRenderer, shaders, and build scripts

This commit is contained in:
ubuntu1804 2025-11-10 15:13:04 +08:00
parent 9e15d9fab8
commit 5dea0554b3
26 changed files with 2985 additions and 11 deletions

View File

@ -128,8 +128,14 @@ set(HEADERS
# Add Vulkan widget if Vulkan is available # Add Vulkan widget if Vulkan is available
if(VULKAN_FOUND) if(VULKAN_FOUND)
list(APPEND SOURCES src/vulkanwidget.cpp) list(APPEND SOURCES
list(APPEND HEADERS src/vulkanwidget.h) src/vulkanwidget.cpp
src/vulkanrenderer.cpp
)
list(APPEND HEADERS
src/vulkanwidget.h
src/vulkanrenderer.h
)
add_definitions(-DENABLE_VULKAN_WIDGET) add_definitions(-DENABLE_VULKAN_WIDGET)
endif() endif()

39
VERIFY.txt Normal file
View File

@ -0,0 +1,39 @@
Vulkan渲染器验证指南
====================
已完成修复:
✅ VulkanRenderer已集成到VulkanWidget
✅ 动画参数更新rotation, wavePhase
✅ 几何体缓冲区在命令录制前创建
✅ 锁屏统计追踪
预期效果:
---------
1. 动态渐变背景 - 颜色随时间变化
2. 8个旋转圆圈 - 围绕中心旋转,颜色动态变化
3. 2条波浪线 - 正弦波动画
运行步骤:
---------
1. cd ScreenLockDetector
2. ./build/bin/ScreenLockDetector
3. 切换到 "Vulkan Widget" 标签页
4. 点击 "Enable Rendering" 按钮
5. 观察渲染效果
调试信息:
---------
控制台会输出:
- "VulkanRenderer initialized successfully!"
- "Vulkan rendering ENABLED"
- 帧数和动画参数更新
如果只看到背景:
---------------
可能原因:
1. 几何体管线创建失败 - 检查着色器编译
2. 顶点缓冲区创建失败 - 检查内存分配
3. 圆圈在窗口外 - 检查坐标转换
调试命令:
./build/bin/ScreenLockDetector 2>&1 | grep -E "(Vulkan|Error|Failed)"

140
compile_shaders.py Executable file
View File

@ -0,0 +1,140 @@
#!/usr/bin/env python3
"""
Shader compilation script for Vulkan SPIR-V shaders
"""
import os
import struct
import subprocess
import sys
def find_glsl_compiler():
home = os.path.expanduser("~")
custom_paths = [
os.path.join(home, "sdk/glslang-13.0.0/bin/glslang"),
os.path.join(home, "sdk/glslang-13.0.0/bin/glslangValidator"),
]
for compiler_path in custom_paths:
if os.path.exists(compiler_path) and os.access(compiler_path, os.X_OK):
print("Found custom compiler: " + compiler_path)
return compiler_path
compilers = ["glslc", "glslangValidator", "glslang"]
for compiler in compilers:
try:
subprocess.check_output([compiler, "--version"], stderr=subprocess.STDOUT)
return compiler
except (subprocess.CalledProcessError, FileNotFoundError, OSError):
continue
return None
def compile_shader(compiler, shader_file, output_file):
print("Compiling " + shader_file + " -> " + output_file)
env = os.environ.copy()
if "/usr/local/lib64" not in env.get("LD_LIBRARY_PATH", ""):
env["LD_LIBRARY_PATH"] = "/usr/local/lib64:" + env.get("LD_LIBRARY_PATH", "")
compiler_name = os.path.basename(compiler)
try:
if compiler_name == "glslc":
cmd = [compiler, shader_file, "-o", output_file]
else:
cmd = [compiler, "-V", shader_file, "-o", output_file]
subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env)
print(" SUCCESS")
return True
except subprocess.CalledProcessError as e:
print(" FAILED: " + e.output.decode('utf-8', errors='ignore'))
return False
except (FileNotFoundError, OSError):
print(" FAILED: Compiler not found")
return False
def generate_cpp_include(spirv_file, output_inc):
with open(spirv_file, "rb") as f:
spirv_data = f.read()
num_words = len(spirv_data) // 4
if len(spirv_data) % 4 != 0:
spirv_data += b"\x00" * (4 - len(spirv_data) % 4)
num_words = len(spirv_data) // 4
words = struct.unpack("<{}I".format(num_words), spirv_data)
cpp_code = "// Auto-generated from {}\n".format(os.path.basename(spirv_file))
cpp_code += "// Size: {} bytes ({} words)\n".format(len(spirv_data), num_words)
for i in range(0, num_words, 8):
chunk = words[i : i + 8]
if i == 0:
cpp_code += " "
else:
cpp_code += ",\n "
cpp_code += ", ".join("0x{:08x}u".format(w) for w in chunk)
with open(output_inc, "w") as f:
f.write(cpp_code + "\n")
print(" Generated " + output_inc)
def main():
script_dir = os.path.dirname(os.path.abspath(__file__))
shaders_dir = os.path.join(script_dir, "shaders")
spirv_dir = os.path.join(script_dir, "src", "shaders_spirv")
os.makedirs(spirv_dir, exist_ok=True)
compiler = find_glsl_compiler()
if not compiler:
print("ERROR: No GLSL compiler found!")
print("Or install to: ~/sdk/glslang-13.0.0/bin/glslang")
sys.exit(1)
print("Using {} compiler\n".format(compiler))
print("=" * 60)
shaders = [
("background.vert", "background_vert.inc"),
("background.frag", "background_frag.inc"),
("geometry.vert", "geometry_vert.inc"),
("geometry.frag", "geometry_frag.inc"),
("text.vert", "text_vert.inc"),
("text.frag", "text_frag.inc"),
]
success_count = 0
fail_count = 0
for shader_name, inc_name in shaders:
shader_path = os.path.join(shaders_dir, shader_name)
spirv_path = os.path.join(spirv_dir, shader_name + ".spv")
inc_path = os.path.join(spirv_dir, inc_name)
if not os.path.exists(shader_path):
print("WARNING: {} not found, skipping".format(shader_path))
fail_count += 1
continue
if compile_shader(compiler, shader_path, spirv_path):
generate_cpp_include(spirv_path, inc_path)
success_count += 1
else:
fail_count += 1
print("=" * 60)
print("\nCompilation complete: {} succeeded, {} failed".format(success_count, fail_count))
if fail_count > 0:
sys.exit(1)
if __name__ == "__main__":
main()

177
compile_shaders.sh Executable file
View File

@ -0,0 +1,177 @@
#!/bin/bash
# Shader compilation script for Vulkan
# Sets up environment and compiles GLSL shaders to SPIR-V
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SHADERS_DIR="$SCRIPT_DIR/shaders"
OUTPUT_DIR="$SCRIPT_DIR/src/shaders_spirv"
# Set up library path for custom libstdc++
export LD_LIBRARY_PATH="/usr/local/lib64:$LD_LIBRARY_PATH"
# Find glslang compiler
GLSLANG=""
# Check custom paths first
if [ -x "$HOME/sdk/glslang-13.0.0/bin/glslang" ]; then
GLSLANG="$HOME/sdk/glslang-13.0.0/bin/glslang"
echo "Found glslang at: $GLSLANG"
elif [ -x "$HOME/sdk/glslang-13.0.0/bin/glslangValidator" ]; then
GLSLANG="$HOME/sdk/glslang-13.0.0/bin/glslangValidator"
echo "Found glslangValidator at: $GLSLANG"
elif command -v glslc &> /dev/null; then
GLSLANG="glslc"
echo "Using system glslc"
elif command -v glslangValidator &> /dev/null; then
GLSLANG="glslangValidator"
echo "Using system glslangValidator"
elif command -v glslang &> /dev/null; then
GLSLANG="glslang"
echo "Using system glslang"
else
echo "ERROR: No GLSL compiler found!"
echo "Please install:"
echo " - Vulkan SDK (provides glslc)"
echo " - or glslang to ~/sdk/glslang-13.0.0/bin/"
exit 1
fi
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Compilation function
compile_shader() {
local shader_file="$1"
local output_name="$2"
local spirv_file="$OUTPUT_DIR/${shader_file}.spv"
local inc_file="$OUTPUT_DIR/${output_name}"
echo "Compiling $shader_file..."
# Determine compiler command
if [[ "$GLSLANG" == *"glslc"* ]]; then
"$GLSLANG" "$SHADERS_DIR/$shader_file" -o "$spirv_file"
else
"$GLSLANG" -V "$SHADERS_DIR/$shader_file" -o "$spirv_file"
fi
if [ $? -ne 0 ]; then
echo " FAILED to compile $shader_file"
return 1
fi
echo " SUCCESS - Generated $spirv_file"
# Generate C++ include file
echo " Generating $inc_file..."
generate_include "$spirv_file" "$inc_file"
return 0
}
# Generate C++ include file from SPIR-V
generate_include() {
local spirv_file="$1"
local inc_file="$2"
# Use Python if available for better formatting
if command -v python3 &> /dev/null; then
python3 -c "
import struct
import sys
with open('$spirv_file', 'rb') as f:
data = f.read()
num_words = len(data) // 4
words = struct.unpack('<{}I'.format(num_words), data[:num_words*4])
print('// Auto-generated from $(basename $spirv_file)')
print('// Size: {} bytes ({} words)'.format(len(data), num_words))
for i in range(0, num_words, 8):
chunk = words[i:i+8]
if i == 0:
sys.stdout.write(' ')
else:
sys.stdout.write(',\n ')
sys.stdout.write(', '.join('0x{:08x}u'.format(w) for w in chunk))
print()
" > "$inc_file"
else
# Fallback: simple hexdump
echo "// Auto-generated from $(basename $spirv_file)" > "$inc_file"
xxd -i < "$spirv_file" | sed 's/unsigned char/uint32_t/' >> "$inc_file"
fi
echo " Generated $inc_file"
}
echo "========================================"
echo "Compiling Vulkan Shaders"
echo "========================================"
echo "Shaders directory: $SHADERS_DIR"
echo "Output directory: $OUTPUT_DIR"
echo "Compiler: $GLSLANG"
echo "========================================"
echo ""
# Compile all shaders
SUCCESS=0
FAILED=0
# Background shaders
if compile_shader "background.vert" "background_vert.inc"; then
((SUCCESS++))
else
((FAILED++))
fi
if compile_shader "background.frag" "background_frag.inc"; then
((SUCCESS++))
else
((FAILED++))
fi
# Geometry shaders
if compile_shader "geometry.vert" "geometry_vert.inc"; then
((SUCCESS++))
else
((FAILED++))
fi
if compile_shader "geometry.frag" "geometry_frag.inc"; then
((SUCCESS++))
else
((FAILED++))
fi
# Text shaders
if compile_shader "text.vert" "text_vert.inc"; then
((SUCCESS++))
else
((FAILED++))
fi
if compile_shader "text.frag" "text_frag.inc"; then
((SUCCESS++))
else
((FAILED++))
fi
echo ""
echo "========================================"
echo "Compilation Summary"
echo "========================================"
echo "Success: $SUCCESS"
echo "Failed: $FAILED"
echo "========================================"
if [ $FAILED -gt 0 ]; then
exit 1
fi
echo ""
echo "All shaders compiled successfully!"
exit 0

38
shaders/background.frag Normal file
View File

@ -0,0 +1,38 @@
#version 450
layout(location = 0) in vec4 fragColor;
layout(location = 1) in vec2 fragTexCoord;
layout(location = 2) in vec2 fragPosition;
layout(location = 0) out vec4 outColor;
layout(binding = 0) uniform UniformBufferObject {
float time;
vec2 resolution;
float rotation;
float wavePhase;
} ubo;
void main() {
// Normalize position to 0-1 range
vec2 uv = (fragPosition + 1.0) * 0.5;
// Create dynamic gradient based on time
float t = ubo.time / 360.0;
// Calculate color components with sine waves
float r = 0.39 + 0.20 * sin(t * 6.28318);
float g = 0.59 + 0.20 * sin(t * 6.28318 + 1.047);
float b = 0.78 + 0.22 * sin(t * 6.28318 + 2.094);
vec3 color1 = vec3(r, g, b);
vec3 color2 = vec3(0.12, 0.12, 0.24);
// Linear gradient from top-left to bottom-right
float gradient = uv.x * 0.5 + uv.y * 0.5;
// Mix colors
vec3 finalColor = mix(color1, color2, gradient);
outColor = vec4(finalColor, 1.0);
}

23
shaders/background.vert Normal file
View File

@ -0,0 +1,23 @@
#version 450
layout(location = 0) in vec2 inPosition;
layout(location = 1) in vec4 inColor;
layout(location = 2) in vec2 inTexCoord;
layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec2 fragTexCoord;
layout(location = 2) out vec2 fragPosition;
layout(binding = 0) uniform UniformBufferObject {
float time;
vec2 resolution;
float rotation;
float wavePhase;
} ubo;
void main() {
gl_Position = vec4(inPosition, 0.0, 1.0);
fragColor = inColor;
fragTexCoord = inTexCoord;
fragPosition = inPosition;
}

18
shaders/geometry.frag Normal file
View File

@ -0,0 +1,18 @@
#version 450
layout(location = 0) in vec4 fragColor;
layout(location = 1) in vec2 fragTexCoord;
layout(location = 0) out vec4 outColor;
layout(binding = 0) uniform UniformBufferObject {
float time;
vec2 resolution;
float rotation;
float wavePhase;
} ubo;
void main() {
// Simple pass-through with vertex color
outColor = fragColor;
}

30
shaders/geometry.vert Normal file
View File

@ -0,0 +1,30 @@
#version 450
layout(location = 0) in vec2 inPosition;
layout(location = 1) in vec4 inColor;
layout(location = 2) in vec2 inTexCoord;
layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec2 fragTexCoord;
layout(binding = 0) uniform UniformBufferObject {
float time;
vec2 resolution;
float rotation;
float wavePhase;
} ubo;
void main() {
// Transform position from pixel coordinates to normalized device coordinates
vec2 pos = inPosition;
// Convert to NDC: (0, 0) to (width, height) -> (-1, -1) to (1, 1)
vec2 ndc = (pos / ubo.resolution) * 2.0 - 1.0;
// Flip Y axis (Vulkan has Y down, we want Y up for easier math)
ndc.y = -ndc.y;
gl_Position = vec4(ndc, 0.0, 1.0);
fragColor = inColor;
fragTexCoord = inTexCoord;
}

23
shaders/text.frag Normal file
View File

@ -0,0 +1,23 @@
#version 450
layout(location = 0) in vec4 fragColor;
layout(location = 1) in vec2 fragTexCoord;
layout(location = 0) out vec4 outColor;
layout(binding = 0) uniform UniformBufferObject {
float time;
vec2 resolution;
float rotation;
float wavePhase;
} ubo;
layout(binding = 1) uniform sampler2D texSampler;
void main() {
// Sample the font texture atlas
float alpha = texture(texSampler, fragTexCoord).r;
// Apply color with alpha from texture
outColor = vec4(fragColor.rgb, fragColor.a * alpha);
}

30
shaders/text.vert Normal file
View File

@ -0,0 +1,30 @@
#version 450
layout(location = 0) in vec2 inPosition;
layout(location = 1) in vec4 inColor;
layout(location = 2) in vec2 inTexCoord;
layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec2 fragTexCoord;
layout(binding = 0) uniform UniformBufferObject {
float time;
vec2 resolution;
float rotation;
float wavePhase;
} ubo;
void main() {
// Transform position from pixel coordinates to normalized device coordinates
vec2 pos = inPosition;
// Convert to NDC: (0, 0) to (width, height) -> (-1, -1) to (1, 1)
vec2 ndc = (pos / ubo.resolution) * 2.0 - 1.0;
// Flip Y axis (Vulkan has Y down, we want Y up for easier math)
ndc.y = -ndc.y;
gl_Position = vec4(ndc, 0.0, 1.0);
fragColor = inColor;
fragTexCoord = inTexCoord;
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,80 @@
// Auto-generated from background.frag.spv
// Size: 2488 bytes (622 words)
0x07230203u, 0x00010000u, 0x0008000bu, 0x00000061u, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu,
0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u,
0x0009000fu, 0x00000004u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x0000000bu, 0x00000058u, 0x0000005fu,
0x00000060u, 0x00030010u, 0x00000004u, 0x00000007u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u,
0x00000004u, 0x6e69616du, 0x00000000u, 0x00030005u, 0x00000009u, 0x00007675u, 0x00060005u, 0x0000000bu,
0x67617266u, 0x69736f50u, 0x6e6f6974u, 0x00000000u, 0x00030005u, 0x00000013u, 0x00000074u, 0x00070005u,
0x00000014u, 0x66696e55u, 0x426d726fu, 0x65666675u, 0x6a624f72u, 0x00746365u, 0x00050006u, 0x00000014u,
0x00000000u, 0x656d6974u, 0x00000000u, 0x00060006u, 0x00000014u, 0x00000001u, 0x6f736572u, 0x6974756cu,
0x00006e6fu, 0x00060006u, 0x00000014u, 0x00000002u, 0x61746f72u, 0x6e6f6974u, 0x00000000u, 0x00060006u,
0x00000014u, 0x00000003u, 0x65766177u, 0x73616850u, 0x00000065u, 0x00030005u, 0x00000016u, 0x006f6275u,
0x00030005u, 0x0000001eu, 0x00000072u, 0x00030005u, 0x00000027u, 0x00000067u, 0x00030005u, 0x00000030u,
0x00000062u, 0x00040005u, 0x0000003cu, 0x6f6c6f63u, 0x00003172u, 0x00040005u, 0x00000041u, 0x6f6c6f63u,
0x00003272u, 0x00050005u, 0x00000045u, 0x64617267u, 0x746e6569u, 0x00000000u, 0x00050005u, 0x00000050u,
0x616e6966u, 0x6c6f436cu, 0x0000726fu, 0x00050005u, 0x00000058u, 0x4374756fu, 0x726f6c6fu, 0x00000000u,
0x00050005u, 0x0000005fu, 0x67617266u, 0x6f6c6f43u, 0x00000072u, 0x00060005u, 0x00000060u, 0x67617266u,
0x43786554u, 0x64726f6fu, 0x00000000u, 0x00040047u, 0x0000000bu, 0x0000001eu, 0x00000002u, 0x00050048u,
0x00000014u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x00000014u, 0x00000001u, 0x00000023u,
0x00000008u, 0x00050048u, 0x00000014u, 0x00000002u, 0x00000023u, 0x00000010u, 0x00050048u, 0x00000014u,
0x00000003u, 0x00000023u, 0x00000014u, 0x00030047u, 0x00000014u, 0x00000002u, 0x00040047u, 0x00000016u,
0x00000022u, 0x00000000u, 0x00040047u, 0x00000016u, 0x00000021u, 0x00000000u, 0x00040047u, 0x00000058u,
0x0000001eu, 0x00000000u, 0x00040047u, 0x0000005fu, 0x0000001eu, 0x00000000u, 0x00040047u, 0x00000060u,
0x0000001eu, 0x00000001u, 0x00020013u, 0x00000002u, 0x00030021u, 0x00000003u, 0x00000002u, 0x00030016u,
0x00000006u, 0x00000020u, 0x00040017u, 0x00000007u, 0x00000006u, 0x00000002u, 0x00040020u, 0x00000008u,
0x00000007u, 0x00000007u, 0x00040020u, 0x0000000au, 0x00000001u, 0x00000007u, 0x0004003bu, 0x0000000au,
0x0000000bu, 0x00000001u, 0x0004002bu, 0x00000006u, 0x0000000du, 0x3f800000u, 0x0004002bu, 0x00000006u,
0x00000010u, 0x3f000000u, 0x00040020u, 0x00000012u, 0x00000007u, 0x00000006u, 0x0006001eu, 0x00000014u,
0x00000006u, 0x00000007u, 0x00000006u, 0x00000006u, 0x00040020u, 0x00000015u, 0x00000002u, 0x00000014u,
0x0004003bu, 0x00000015u, 0x00000016u, 0x00000002u, 0x00040015u, 0x00000017u, 0x00000020u, 0x00000001u,
0x0004002bu, 0x00000017u, 0x00000018u, 0x00000000u, 0x00040020u, 0x00000019u, 0x00000002u, 0x00000006u,
0x0004002bu, 0x00000006u, 0x0000001cu, 0x43b40000u, 0x0004002bu, 0x00000006u, 0x0000001fu, 0x3ec7ae14u,
0x0004002bu, 0x00000006u, 0x00000020u, 0x3e4ccccdu, 0x0004002bu, 0x00000006u, 0x00000022u, 0x40c90fd0u,
0x0004002bu, 0x00000006u, 0x00000028u, 0x3f170a3du, 0x0004002bu, 0x00000006u, 0x0000002bu, 0x3f860419u,
0x0004002bu, 0x00000006u, 0x00000031u, 0x3f47ae14u, 0x0004002bu, 0x00000006u, 0x00000032u, 0x3e6147aeu,
0x0004002bu, 0x00000006u, 0x00000035u, 0x40060419u, 0x00040017u, 0x0000003au, 0x00000006u, 0x00000003u,
0x00040020u, 0x0000003bu, 0x00000007u, 0x0000003au, 0x0004002bu, 0x00000006u, 0x00000042u, 0x3df5c28fu,
0x0004002bu, 0x00000006u, 0x00000043u, 0x3e75c28fu, 0x0006002cu, 0x0000003au, 0x00000044u, 0x00000042u,
0x00000042u, 0x00000043u, 0x00040015u, 0x00000046u, 0x00000020u, 0x00000000u, 0x0004002bu, 0x00000046u,
0x00000047u, 0x00000000u, 0x0004002bu, 0x00000046u, 0x0000004bu, 0x00000001u, 0x00040017u, 0x00000056u,
0x00000006u, 0x00000004u, 0x00040020u, 0x00000057u, 0x00000003u, 0x00000056u, 0x0004003bu, 0x00000057u,
0x00000058u, 0x00000003u, 0x00040020u, 0x0000005eu, 0x00000001u, 0x00000056u, 0x0004003bu, 0x0000005eu,
0x0000005fu, 0x00000001u, 0x0004003bu, 0x0000000au, 0x00000060u, 0x00000001u, 0x00050036u, 0x00000002u,
0x00000004u, 0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u, 0x0004003bu, 0x00000008u, 0x00000009u,
0x00000007u, 0x0004003bu, 0x00000012u, 0x00000013u, 0x00000007u, 0x0004003bu, 0x00000012u, 0x0000001eu,
0x00000007u, 0x0004003bu, 0x00000012u, 0x00000027u, 0x00000007u, 0x0004003bu, 0x00000012u, 0x00000030u,
0x00000007u, 0x0004003bu, 0x0000003bu, 0x0000003cu, 0x00000007u, 0x0004003bu, 0x0000003bu, 0x00000041u,
0x00000007u, 0x0004003bu, 0x00000012u, 0x00000045u, 0x00000007u, 0x0004003bu, 0x0000003bu, 0x00000050u,
0x00000007u, 0x0004003du, 0x00000007u, 0x0000000cu, 0x0000000bu, 0x00050050u, 0x00000007u, 0x0000000eu,
0x0000000du, 0x0000000du, 0x00050081u, 0x00000007u, 0x0000000fu, 0x0000000cu, 0x0000000eu, 0x0005008eu,
0x00000007u, 0x00000011u, 0x0000000fu, 0x00000010u, 0x0003003eu, 0x00000009u, 0x00000011u, 0x00050041u,
0x00000019u, 0x0000001au, 0x00000016u, 0x00000018u, 0x0004003du, 0x00000006u, 0x0000001bu, 0x0000001au,
0x00050088u, 0x00000006u, 0x0000001du, 0x0000001bu, 0x0000001cu, 0x0003003eu, 0x00000013u, 0x0000001du,
0x0004003du, 0x00000006u, 0x00000021u, 0x00000013u, 0x00050085u, 0x00000006u, 0x00000023u, 0x00000021u,
0x00000022u, 0x0006000cu, 0x00000006u, 0x00000024u, 0x00000001u, 0x0000000du, 0x00000023u, 0x00050085u,
0x00000006u, 0x00000025u, 0x00000020u, 0x00000024u, 0x00050081u, 0x00000006u, 0x00000026u, 0x0000001fu,
0x00000025u, 0x0003003eu, 0x0000001eu, 0x00000026u, 0x0004003du, 0x00000006u, 0x00000029u, 0x00000013u,
0x00050085u, 0x00000006u, 0x0000002au, 0x00000029u, 0x00000022u, 0x00050081u, 0x00000006u, 0x0000002cu,
0x0000002au, 0x0000002bu, 0x0006000cu, 0x00000006u, 0x0000002du, 0x00000001u, 0x0000000du, 0x0000002cu,
0x00050085u, 0x00000006u, 0x0000002eu, 0x00000020u, 0x0000002du, 0x00050081u, 0x00000006u, 0x0000002fu,
0x00000028u, 0x0000002eu, 0x0003003eu, 0x00000027u, 0x0000002fu, 0x0004003du, 0x00000006u, 0x00000033u,
0x00000013u, 0x00050085u, 0x00000006u, 0x00000034u, 0x00000033u, 0x00000022u, 0x00050081u, 0x00000006u,
0x00000036u, 0x00000034u, 0x00000035u, 0x0006000cu, 0x00000006u, 0x00000037u, 0x00000001u, 0x0000000du,
0x00000036u, 0x00050085u, 0x00000006u, 0x00000038u, 0x00000032u, 0x00000037u, 0x00050081u, 0x00000006u,
0x00000039u, 0x00000031u, 0x00000038u, 0x0003003eu, 0x00000030u, 0x00000039u, 0x0004003du, 0x00000006u,
0x0000003du, 0x0000001eu, 0x0004003du, 0x00000006u, 0x0000003eu, 0x00000027u, 0x0004003du, 0x00000006u,
0x0000003fu, 0x00000030u, 0x00060050u, 0x0000003au, 0x00000040u, 0x0000003du, 0x0000003eu, 0x0000003fu,
0x0003003eu, 0x0000003cu, 0x00000040u, 0x0003003eu, 0x00000041u, 0x00000044u, 0x00050041u, 0x00000012u,
0x00000048u, 0x00000009u, 0x00000047u, 0x0004003du, 0x00000006u, 0x00000049u, 0x00000048u, 0x00050085u,
0x00000006u, 0x0000004au, 0x00000049u, 0x00000010u, 0x00050041u, 0x00000012u, 0x0000004cu, 0x00000009u,
0x0000004bu, 0x0004003du, 0x00000006u, 0x0000004du, 0x0000004cu, 0x00050085u, 0x00000006u, 0x0000004eu,
0x0000004du, 0x00000010u, 0x00050081u, 0x00000006u, 0x0000004fu, 0x0000004au, 0x0000004eu, 0x0003003eu,
0x00000045u, 0x0000004fu, 0x0004003du, 0x0000003au, 0x00000051u, 0x0000003cu, 0x0004003du, 0x0000003au,
0x00000052u, 0x00000041u, 0x0004003du, 0x00000006u, 0x00000053u, 0x00000045u, 0x00060050u, 0x0000003au,
0x00000054u, 0x00000053u, 0x00000053u, 0x00000053u, 0x0008000cu, 0x0000003au, 0x00000055u, 0x00000001u,
0x0000002eu, 0x00000051u, 0x00000052u, 0x00000054u, 0x0003003eu, 0x00000050u, 0x00000055u, 0x0004003du,
0x0000003au, 0x00000059u, 0x00000050u, 0x00050051u, 0x00000006u, 0x0000005au, 0x00000059u, 0x00000000u,
0x00050051u, 0x00000006u, 0x0000005bu, 0x00000059u, 0x00000001u, 0x00050051u, 0x00000006u, 0x0000005cu,
0x00000059u, 0x00000002u, 0x00070050u, 0x00000056u, 0x0000005du, 0x0000005au, 0x0000005bu, 0x0000005cu,
0x0000000du, 0x0003003eu, 0x00000058u, 0x0000005du, 0x000100fdu, 0x00010038u

View File

@ -0,0 +1,50 @@
// Auto-generated from background.vert.spv
// Size: 1536 bytes (384 words)
0x07230203u, 0x00010000u, 0x0008000bu, 0x00000028u, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu,
0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u,
0x000c000fu, 0x00000000u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x0000000du, 0x00000012u, 0x0000001bu,
0x0000001du, 0x00000020u, 0x00000021u, 0x00000023u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u,
0x00000004u, 0x6e69616du, 0x00000000u, 0x00060005u, 0x0000000bu, 0x505f6c67u, 0x65567265u, 0x78657472u,
0x00000000u, 0x00060006u, 0x0000000bu, 0x00000000u, 0x505f6c67u, 0x7469736fu, 0x006e6f69u, 0x00070006u,
0x0000000bu, 0x00000001u, 0x505f6c67u, 0x746e696fu, 0x657a6953u, 0x00000000u, 0x00070006u, 0x0000000bu,
0x00000002u, 0x435f6c67u, 0x4470696cu, 0x61747369u, 0x0065636eu, 0x00070006u, 0x0000000bu, 0x00000003u,
0x435f6c67u, 0x446c6c75u, 0x61747369u, 0x0065636eu, 0x00030005u, 0x0000000du, 0x00000000u, 0x00050005u,
0x00000012u, 0x6f506e69u, 0x69746973u, 0x00006e6fu, 0x00050005u, 0x0000001bu, 0x67617266u, 0x6f6c6f43u,
0x00000072u, 0x00040005u, 0x0000001du, 0x6f436e69u, 0x00726f6cu, 0x00060005u, 0x00000020u, 0x67617266u,
0x43786554u, 0x64726f6fu, 0x00000000u, 0x00050005u, 0x00000021u, 0x65546e69u, 0x6f6f4378u, 0x00006472u,
0x00060005u, 0x00000023u, 0x67617266u, 0x69736f50u, 0x6e6f6974u, 0x00000000u, 0x00070005u, 0x00000025u,
0x66696e55u, 0x426d726fu, 0x65666675u, 0x6a624f72u, 0x00746365u, 0x00050006u, 0x00000025u, 0x00000000u,
0x656d6974u, 0x00000000u, 0x00060006u, 0x00000025u, 0x00000001u, 0x6f736572u, 0x6974756cu, 0x00006e6fu,
0x00060006u, 0x00000025u, 0x00000002u, 0x61746f72u, 0x6e6f6974u, 0x00000000u, 0x00060006u, 0x00000025u,
0x00000003u, 0x65766177u, 0x73616850u, 0x00000065u, 0x00030005u, 0x00000027u, 0x006f6275u, 0x00050048u,
0x0000000bu, 0x00000000u, 0x0000000bu, 0x00000000u, 0x00050048u, 0x0000000bu, 0x00000001u, 0x0000000bu,
0x00000001u, 0x00050048u, 0x0000000bu, 0x00000002u, 0x0000000bu, 0x00000003u, 0x00050048u, 0x0000000bu,
0x00000003u, 0x0000000bu, 0x00000004u, 0x00030047u, 0x0000000bu, 0x00000002u, 0x00040047u, 0x00000012u,
0x0000001eu, 0x00000000u, 0x00040047u, 0x0000001bu, 0x0000001eu, 0x00000000u, 0x00040047u, 0x0000001du,
0x0000001eu, 0x00000001u, 0x00040047u, 0x00000020u, 0x0000001eu, 0x00000001u, 0x00040047u, 0x00000021u,
0x0000001eu, 0x00000002u, 0x00040047u, 0x00000023u, 0x0000001eu, 0x00000002u, 0x00050048u, 0x00000025u,
0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x00000025u, 0x00000001u, 0x00000023u, 0x00000008u,
0x00050048u, 0x00000025u, 0x00000002u, 0x00000023u, 0x00000010u, 0x00050048u, 0x00000025u, 0x00000003u,
0x00000023u, 0x00000014u, 0x00030047u, 0x00000025u, 0x00000002u, 0x00040047u, 0x00000027u, 0x00000022u,
0x00000000u, 0x00040047u, 0x00000027u, 0x00000021u, 0x00000000u, 0x00020013u, 0x00000002u, 0x00030021u,
0x00000003u, 0x00000002u, 0x00030016u, 0x00000006u, 0x00000020u, 0x00040017u, 0x00000007u, 0x00000006u,
0x00000004u, 0x00040015u, 0x00000008u, 0x00000020u, 0x00000000u, 0x0004002bu, 0x00000008u, 0x00000009u,
0x00000001u, 0x0004001cu, 0x0000000au, 0x00000006u, 0x00000009u, 0x0006001eu, 0x0000000bu, 0x00000007u,
0x00000006u, 0x0000000au, 0x0000000au, 0x00040020u, 0x0000000cu, 0x00000003u, 0x0000000bu, 0x0004003bu,
0x0000000cu, 0x0000000du, 0x00000003u, 0x00040015u, 0x0000000eu, 0x00000020u, 0x00000001u, 0x0004002bu,
0x0000000eu, 0x0000000fu, 0x00000000u, 0x00040017u, 0x00000010u, 0x00000006u, 0x00000002u, 0x00040020u,
0x00000011u, 0x00000001u, 0x00000010u, 0x0004003bu, 0x00000011u, 0x00000012u, 0x00000001u, 0x0004002bu,
0x00000006u, 0x00000014u, 0x00000000u, 0x0004002bu, 0x00000006u, 0x00000015u, 0x3f800000u, 0x00040020u,
0x00000019u, 0x00000003u, 0x00000007u, 0x0004003bu, 0x00000019u, 0x0000001bu, 0x00000003u, 0x00040020u,
0x0000001cu, 0x00000001u, 0x00000007u, 0x0004003bu, 0x0000001cu, 0x0000001du, 0x00000001u, 0x00040020u,
0x0000001fu, 0x00000003u, 0x00000010u, 0x0004003bu, 0x0000001fu, 0x00000020u, 0x00000003u, 0x0004003bu,
0x00000011u, 0x00000021u, 0x00000001u, 0x0004003bu, 0x0000001fu, 0x00000023u, 0x00000003u, 0x0006001eu,
0x00000025u, 0x00000006u, 0x00000010u, 0x00000006u, 0x00000006u, 0x00040020u, 0x00000026u, 0x00000002u,
0x00000025u, 0x0004003bu, 0x00000026u, 0x00000027u, 0x00000002u, 0x00050036u, 0x00000002u, 0x00000004u,
0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u, 0x0004003du, 0x00000010u, 0x00000013u, 0x00000012u,
0x00050051u, 0x00000006u, 0x00000016u, 0x00000013u, 0x00000000u, 0x00050051u, 0x00000006u, 0x00000017u,
0x00000013u, 0x00000001u, 0x00070050u, 0x00000007u, 0x00000018u, 0x00000016u, 0x00000017u, 0x00000014u,
0x00000015u, 0x00050041u, 0x00000019u, 0x0000001au, 0x0000000du, 0x0000000fu, 0x0003003eu, 0x0000001au,
0x00000018u, 0x0004003du, 0x00000007u, 0x0000001eu, 0x0000001du, 0x0003003eu, 0x0000001bu, 0x0000001eu,
0x0004003du, 0x00000010u, 0x00000022u, 0x00000021u, 0x0003003eu, 0x00000020u, 0x00000022u, 0x0004003du,
0x00000010u, 0x00000024u, 0x00000012u, 0x0003003eu, 0x00000023u, 0x00000024u, 0x000100fdu, 0x00010038u

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,27 @@
// Auto-generated from geometry.frag.spv
// Size: 784 bytes (196 words)
0x07230203u, 0x00010000u, 0x0008000bu, 0x00000013u, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu,
0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u,
0x0008000fu, 0x00000004u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x00000009u, 0x0000000bu, 0x0000000fu,
0x00030010u, 0x00000004u, 0x00000007u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u, 0x00000004u,
0x6e69616du, 0x00000000u, 0x00050005u, 0x00000009u, 0x4374756fu, 0x726f6c6fu, 0x00000000u, 0x00050005u,
0x0000000bu, 0x67617266u, 0x6f6c6f43u, 0x00000072u, 0x00060005u, 0x0000000fu, 0x67617266u, 0x43786554u,
0x64726f6fu, 0x00000000u, 0x00070005u, 0x00000010u, 0x66696e55u, 0x426d726fu, 0x65666675u, 0x6a624f72u,
0x00746365u, 0x00050006u, 0x00000010u, 0x00000000u, 0x656d6974u, 0x00000000u, 0x00060006u, 0x00000010u,
0x00000001u, 0x6f736572u, 0x6974756cu, 0x00006e6fu, 0x00060006u, 0x00000010u, 0x00000002u, 0x61746f72u,
0x6e6f6974u, 0x00000000u, 0x00060006u, 0x00000010u, 0x00000003u, 0x65766177u, 0x73616850u, 0x00000065u,
0x00030005u, 0x00000012u, 0x006f6275u, 0x00040047u, 0x00000009u, 0x0000001eu, 0x00000000u, 0x00040047u,
0x0000000bu, 0x0000001eu, 0x00000000u, 0x00040047u, 0x0000000fu, 0x0000001eu, 0x00000001u, 0x00050048u,
0x00000010u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x00000010u, 0x00000001u, 0x00000023u,
0x00000008u, 0x00050048u, 0x00000010u, 0x00000002u, 0x00000023u, 0x00000010u, 0x00050048u, 0x00000010u,
0x00000003u, 0x00000023u, 0x00000014u, 0x00030047u, 0x00000010u, 0x00000002u, 0x00040047u, 0x00000012u,
0x00000022u, 0x00000000u, 0x00040047u, 0x00000012u, 0x00000021u, 0x00000000u, 0x00020013u, 0x00000002u,
0x00030021u, 0x00000003u, 0x00000002u, 0x00030016u, 0x00000006u, 0x00000020u, 0x00040017u, 0x00000007u,
0x00000006u, 0x00000004u, 0x00040020u, 0x00000008u, 0x00000003u, 0x00000007u, 0x0004003bu, 0x00000008u,
0x00000009u, 0x00000003u, 0x00040020u, 0x0000000au, 0x00000001u, 0x00000007u, 0x0004003bu, 0x0000000au,
0x0000000bu, 0x00000001u, 0x00040017u, 0x0000000du, 0x00000006u, 0x00000002u, 0x00040020u, 0x0000000eu,
0x00000001u, 0x0000000du, 0x0004003bu, 0x0000000eu, 0x0000000fu, 0x00000001u, 0x0006001eu, 0x00000010u,
0x00000006u, 0x0000000du, 0x00000006u, 0x00000006u, 0x00040020u, 0x00000011u, 0x00000002u, 0x00000010u,
0x0004003bu, 0x00000011u, 0x00000012u, 0x00000002u, 0x00050036u, 0x00000002u, 0x00000004u, 0x00000000u,
0x00000003u, 0x000200f8u, 0x00000005u, 0x0004003du, 0x00000007u, 0x0000000cu, 0x0000000bu, 0x0003003eu,
0x00000009u, 0x0000000cu, 0x000100fdu, 0x00010038u

View File

@ -0,0 +1,60 @@
// Auto-generated from geometry.vert.spv
// Size: 1840 bytes (460 words)
0x07230203u, 0x00010000u, 0x0008000bu, 0x00000039u, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu,
0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u,
0x000b000fu, 0x00000000u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x0000000bu, 0x00000028u, 0x00000031u,
0x00000033u, 0x00000036u, 0x00000037u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u, 0x00000004u,
0x6e69616du, 0x00000000u, 0x00030005u, 0x00000009u, 0x00736f70u, 0x00050005u, 0x0000000bu, 0x6f506e69u,
0x69746973u, 0x00006e6fu, 0x00030005u, 0x0000000du, 0x0063646eu, 0x00070005u, 0x0000000fu, 0x66696e55u,
0x426d726fu, 0x65666675u, 0x6a624f72u, 0x00746365u, 0x00050006u, 0x0000000fu, 0x00000000u, 0x656d6974u,
0x00000000u, 0x00060006u, 0x0000000fu, 0x00000001u, 0x6f736572u, 0x6974756cu, 0x00006e6fu, 0x00060006u,
0x0000000fu, 0x00000002u, 0x61746f72u, 0x6e6f6974u, 0x00000000u, 0x00060006u, 0x0000000fu, 0x00000003u,
0x65766177u, 0x73616850u, 0x00000065u, 0x00030005u, 0x00000011u, 0x006f6275u, 0x00060005u, 0x00000026u,
0x505f6c67u, 0x65567265u, 0x78657472u, 0x00000000u, 0x00060006u, 0x00000026u, 0x00000000u, 0x505f6c67u,
0x7469736fu, 0x006e6f69u, 0x00070006u, 0x00000026u, 0x00000001u, 0x505f6c67u, 0x746e696fu, 0x657a6953u,
0x00000000u, 0x00070006u, 0x00000026u, 0x00000002u, 0x435f6c67u, 0x4470696cu, 0x61747369u, 0x0065636eu,
0x00070006u, 0x00000026u, 0x00000003u, 0x435f6c67u, 0x446c6c75u, 0x61747369u, 0x0065636eu, 0x00030005u,
0x00000028u, 0x00000000u, 0x00050005u, 0x00000031u, 0x67617266u, 0x6f6c6f43u, 0x00000072u, 0x00040005u,
0x00000033u, 0x6f436e69u, 0x00726f6cu, 0x00060005u, 0x00000036u, 0x67617266u, 0x43786554u, 0x64726f6fu,
0x00000000u, 0x00050005u, 0x00000037u, 0x65546e69u, 0x6f6f4378u, 0x00006472u, 0x00040047u, 0x0000000bu,
0x0000001eu, 0x00000000u, 0x00050048u, 0x0000000fu, 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u,
0x0000000fu, 0x00000001u, 0x00000023u, 0x00000008u, 0x00050048u, 0x0000000fu, 0x00000002u, 0x00000023u,
0x00000010u, 0x00050048u, 0x0000000fu, 0x00000003u, 0x00000023u, 0x00000014u, 0x00030047u, 0x0000000fu,
0x00000002u, 0x00040047u, 0x00000011u, 0x00000022u, 0x00000000u, 0x00040047u, 0x00000011u, 0x00000021u,
0x00000000u, 0x00050048u, 0x00000026u, 0x00000000u, 0x0000000bu, 0x00000000u, 0x00050048u, 0x00000026u,
0x00000001u, 0x0000000bu, 0x00000001u, 0x00050048u, 0x00000026u, 0x00000002u, 0x0000000bu, 0x00000003u,
0x00050048u, 0x00000026u, 0x00000003u, 0x0000000bu, 0x00000004u, 0x00030047u, 0x00000026u, 0x00000002u,
0x00040047u, 0x00000031u, 0x0000001eu, 0x00000000u, 0x00040047u, 0x00000033u, 0x0000001eu, 0x00000001u,
0x00040047u, 0x00000036u, 0x0000001eu, 0x00000001u, 0x00040047u, 0x00000037u, 0x0000001eu, 0x00000002u,
0x00020013u, 0x00000002u, 0x00030021u, 0x00000003u, 0x00000002u, 0x00030016u, 0x00000006u, 0x00000020u,
0x00040017u, 0x00000007u, 0x00000006u, 0x00000002u, 0x00040020u, 0x00000008u, 0x00000007u, 0x00000007u,
0x00040020u, 0x0000000au, 0x00000001u, 0x00000007u, 0x0004003bu, 0x0000000au, 0x0000000bu, 0x00000001u,
0x0006001eu, 0x0000000fu, 0x00000006u, 0x00000007u, 0x00000006u, 0x00000006u, 0x00040020u, 0x00000010u,
0x00000002u, 0x0000000fu, 0x0004003bu, 0x00000010u, 0x00000011u, 0x00000002u, 0x00040015u, 0x00000012u,
0x00000020u, 0x00000001u, 0x0004002bu, 0x00000012u, 0x00000013u, 0x00000001u, 0x00040020u, 0x00000014u,
0x00000002u, 0x00000007u, 0x0004002bu, 0x00000006u, 0x00000018u, 0x40000000u, 0x0004002bu, 0x00000006u,
0x0000001au, 0x3f800000u, 0x00040015u, 0x0000001du, 0x00000020u, 0x00000000u, 0x0004002bu, 0x0000001du,
0x0000001eu, 0x00000001u, 0x00040020u, 0x0000001fu, 0x00000007u, 0x00000006u, 0x00040017u, 0x00000024u,
0x00000006u, 0x00000004u, 0x0004001cu, 0x00000025u, 0x00000006u, 0x0000001eu, 0x0006001eu, 0x00000026u,
0x00000024u, 0x00000006u, 0x00000025u, 0x00000025u, 0x00040020u, 0x00000027u, 0x00000003u, 0x00000026u,
0x0004003bu, 0x00000027u, 0x00000028u, 0x00000003u, 0x0004002bu, 0x00000012u, 0x00000029u, 0x00000000u,
0x0004002bu, 0x00000006u, 0x0000002bu, 0x00000000u, 0x00040020u, 0x0000002fu, 0x00000003u, 0x00000024u,
0x0004003bu, 0x0000002fu, 0x00000031u, 0x00000003u, 0x00040020u, 0x00000032u, 0x00000001u, 0x00000024u,
0x0004003bu, 0x00000032u, 0x00000033u, 0x00000001u, 0x00040020u, 0x00000035u, 0x00000003u, 0x00000007u,
0x0004003bu, 0x00000035u, 0x00000036u, 0x00000003u, 0x0004003bu, 0x0000000au, 0x00000037u, 0x00000001u,
0x00050036u, 0x00000002u, 0x00000004u, 0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u, 0x0004003bu,
0x00000008u, 0x00000009u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x0000000du, 0x00000007u, 0x0004003du,
0x00000007u, 0x0000000cu, 0x0000000bu, 0x0003003eu, 0x00000009u, 0x0000000cu, 0x0004003du, 0x00000007u,
0x0000000eu, 0x00000009u, 0x00050041u, 0x00000014u, 0x00000015u, 0x00000011u, 0x00000013u, 0x0004003du,
0x00000007u, 0x00000016u, 0x00000015u, 0x00050088u, 0x00000007u, 0x00000017u, 0x0000000eu, 0x00000016u,
0x0005008eu, 0x00000007u, 0x00000019u, 0x00000017u, 0x00000018u, 0x00050050u, 0x00000007u, 0x0000001bu,
0x0000001au, 0x0000001au, 0x00050083u, 0x00000007u, 0x0000001cu, 0x00000019u, 0x0000001bu, 0x0003003eu,
0x0000000du, 0x0000001cu, 0x00050041u, 0x0000001fu, 0x00000020u, 0x0000000du, 0x0000001eu, 0x0004003du,
0x00000006u, 0x00000021u, 0x00000020u, 0x0004007fu, 0x00000006u, 0x00000022u, 0x00000021u, 0x00050041u,
0x0000001fu, 0x00000023u, 0x0000000du, 0x0000001eu, 0x0003003eu, 0x00000023u, 0x00000022u, 0x0004003du,
0x00000007u, 0x0000002au, 0x0000000du, 0x00050051u, 0x00000006u, 0x0000002cu, 0x0000002au, 0x00000000u,
0x00050051u, 0x00000006u, 0x0000002du, 0x0000002au, 0x00000001u, 0x00070050u, 0x00000024u, 0x0000002eu,
0x0000002cu, 0x0000002du, 0x0000002bu, 0x0000001au, 0x00050041u, 0x0000002fu, 0x00000030u, 0x00000028u,
0x00000029u, 0x0003003eu, 0x00000030u, 0x0000002eu, 0x0004003du, 0x00000024u, 0x00000034u, 0x00000033u,
0x0003003eu, 0x00000031u, 0x00000034u, 0x0004003du, 0x00000007u, 0x00000038u, 0x00000037u, 0x0003003eu,
0x00000036u, 0x00000038u, 0x000100fdu, 0x00010038u

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,44 @@
// Auto-generated from text.frag.spv
// Size: 1320 bytes (330 words)
0x07230203u, 0x00010000u, 0x0008000bu, 0x0000002bu, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu,
0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u,
0x0008000fu, 0x00000004u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x00000010u, 0x00000018u, 0x0000001au,
0x00030010u, 0x00000004u, 0x00000007u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u, 0x00000004u,
0x6e69616du, 0x00000000u, 0x00040005u, 0x00000008u, 0x68706c61u, 0x00000061u, 0x00050005u, 0x0000000cu,
0x53786574u, 0x6c706d61u, 0x00007265u, 0x00060005u, 0x00000010u, 0x67617266u, 0x43786554u, 0x64726f6fu,
0x00000000u, 0x00050005u, 0x00000018u, 0x4374756fu, 0x726f6c6fu, 0x00000000u, 0x00050005u, 0x0000001au,
0x67617266u, 0x6f6c6f43u, 0x00000072u, 0x00070005u, 0x00000028u, 0x66696e55u, 0x426d726fu, 0x65666675u,
0x6a624f72u, 0x00746365u, 0x00050006u, 0x00000028u, 0x00000000u, 0x656d6974u, 0x00000000u, 0x00060006u,
0x00000028u, 0x00000001u, 0x6f736572u, 0x6974756cu, 0x00006e6fu, 0x00060006u, 0x00000028u, 0x00000002u,
0x61746f72u, 0x6e6f6974u, 0x00000000u, 0x00060006u, 0x00000028u, 0x00000003u, 0x65766177u, 0x73616850u,
0x00000065u, 0x00030005u, 0x0000002au, 0x006f6275u, 0x00040047u, 0x0000000cu, 0x00000022u, 0x00000000u,
0x00040047u, 0x0000000cu, 0x00000021u, 0x00000001u, 0x00040047u, 0x00000010u, 0x0000001eu, 0x00000001u,
0x00040047u, 0x00000018u, 0x0000001eu, 0x00000000u, 0x00040047u, 0x0000001au, 0x0000001eu, 0x00000000u,
0x00050048u, 0x00000028u, 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u, 0x00000028u, 0x00000001u,
0x00000023u, 0x00000008u, 0x00050048u, 0x00000028u, 0x00000002u, 0x00000023u, 0x00000010u, 0x00050048u,
0x00000028u, 0x00000003u, 0x00000023u, 0x00000014u, 0x00030047u, 0x00000028u, 0x00000002u, 0x00040047u,
0x0000002au, 0x00000022u, 0x00000000u, 0x00040047u, 0x0000002au, 0x00000021u, 0x00000000u, 0x00020013u,
0x00000002u, 0x00030021u, 0x00000003u, 0x00000002u, 0x00030016u, 0x00000006u, 0x00000020u, 0x00040020u,
0x00000007u, 0x00000007u, 0x00000006u, 0x00090019u, 0x00000009u, 0x00000006u, 0x00000001u, 0x00000000u,
0x00000000u, 0x00000000u, 0x00000001u, 0x00000000u, 0x0003001bu, 0x0000000au, 0x00000009u, 0x00040020u,
0x0000000bu, 0x00000000u, 0x0000000au, 0x0004003bu, 0x0000000bu, 0x0000000cu, 0x00000000u, 0x00040017u,
0x0000000eu, 0x00000006u, 0x00000002u, 0x00040020u, 0x0000000fu, 0x00000001u, 0x0000000eu, 0x0004003bu,
0x0000000fu, 0x00000010u, 0x00000001u, 0x00040017u, 0x00000012u, 0x00000006u, 0x00000004u, 0x00040015u,
0x00000014u, 0x00000020u, 0x00000000u, 0x0004002bu, 0x00000014u, 0x00000015u, 0x00000000u, 0x00040020u,
0x00000017u, 0x00000003u, 0x00000012u, 0x0004003bu, 0x00000017u, 0x00000018u, 0x00000003u, 0x00040020u,
0x00000019u, 0x00000001u, 0x00000012u, 0x0004003bu, 0x00000019u, 0x0000001au, 0x00000001u, 0x00040017u,
0x0000001bu, 0x00000006u, 0x00000003u, 0x0004002bu, 0x00000014u, 0x0000001eu, 0x00000003u, 0x00040020u,
0x0000001fu, 0x00000001u, 0x00000006u, 0x0006001eu, 0x00000028u, 0x00000006u, 0x0000000eu, 0x00000006u,
0x00000006u, 0x00040020u, 0x00000029u, 0x00000002u, 0x00000028u, 0x0004003bu, 0x00000029u, 0x0000002au,
0x00000002u, 0x00050036u, 0x00000002u, 0x00000004u, 0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u,
0x0004003bu, 0x00000007u, 0x00000008u, 0x00000007u, 0x0004003du, 0x0000000au, 0x0000000du, 0x0000000cu,
0x0004003du, 0x0000000eu, 0x00000011u, 0x00000010u, 0x00050057u, 0x00000012u, 0x00000013u, 0x0000000du,
0x00000011u, 0x00050051u, 0x00000006u, 0x00000016u, 0x00000013u, 0x00000000u, 0x0003003eu, 0x00000008u,
0x00000016u, 0x0004003du, 0x00000012u, 0x0000001cu, 0x0000001au, 0x0008004fu, 0x0000001bu, 0x0000001du,
0x0000001cu, 0x0000001cu, 0x00000000u, 0x00000001u, 0x00000002u, 0x00050041u, 0x0000001fu, 0x00000020u,
0x0000001au, 0x0000001eu, 0x0004003du, 0x00000006u, 0x00000021u, 0x00000020u, 0x0004003du, 0x00000006u,
0x00000022u, 0x00000008u, 0x00050085u, 0x00000006u, 0x00000023u, 0x00000021u, 0x00000022u, 0x00050051u,
0x00000006u, 0x00000024u, 0x0000001du, 0x00000000u, 0x00050051u, 0x00000006u, 0x00000025u, 0x0000001du,
0x00000001u, 0x00050051u, 0x00000006u, 0x00000026u, 0x0000001du, 0x00000002u, 0x00070050u, 0x00000012u,
0x00000027u, 0x00000024u, 0x00000025u, 0x00000026u, 0x00000023u, 0x0003003eu, 0x00000018u, 0x00000027u,
0x000100fdu, 0x00010038u

View File

@ -0,0 +1,60 @@
// Auto-generated from text.vert.spv
// Size: 1840 bytes (460 words)
0x07230203u, 0x00010000u, 0x0008000bu, 0x00000039u, 0x00000000u, 0x00020011u, 0x00000001u, 0x0006000bu,
0x00000001u, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0x00000000u, 0x0003000eu, 0x00000000u, 0x00000001u,
0x000b000fu, 0x00000000u, 0x00000004u, 0x6e69616du, 0x00000000u, 0x0000000bu, 0x00000028u, 0x00000031u,
0x00000033u, 0x00000036u, 0x00000037u, 0x00030003u, 0x00000002u, 0x000001c2u, 0x00040005u, 0x00000004u,
0x6e69616du, 0x00000000u, 0x00030005u, 0x00000009u, 0x00736f70u, 0x00050005u, 0x0000000bu, 0x6f506e69u,
0x69746973u, 0x00006e6fu, 0x00030005u, 0x0000000du, 0x0063646eu, 0x00070005u, 0x0000000fu, 0x66696e55u,
0x426d726fu, 0x65666675u, 0x6a624f72u, 0x00746365u, 0x00050006u, 0x0000000fu, 0x00000000u, 0x656d6974u,
0x00000000u, 0x00060006u, 0x0000000fu, 0x00000001u, 0x6f736572u, 0x6974756cu, 0x00006e6fu, 0x00060006u,
0x0000000fu, 0x00000002u, 0x61746f72u, 0x6e6f6974u, 0x00000000u, 0x00060006u, 0x0000000fu, 0x00000003u,
0x65766177u, 0x73616850u, 0x00000065u, 0x00030005u, 0x00000011u, 0x006f6275u, 0x00060005u, 0x00000026u,
0x505f6c67u, 0x65567265u, 0x78657472u, 0x00000000u, 0x00060006u, 0x00000026u, 0x00000000u, 0x505f6c67u,
0x7469736fu, 0x006e6f69u, 0x00070006u, 0x00000026u, 0x00000001u, 0x505f6c67u, 0x746e696fu, 0x657a6953u,
0x00000000u, 0x00070006u, 0x00000026u, 0x00000002u, 0x435f6c67u, 0x4470696cu, 0x61747369u, 0x0065636eu,
0x00070006u, 0x00000026u, 0x00000003u, 0x435f6c67u, 0x446c6c75u, 0x61747369u, 0x0065636eu, 0x00030005u,
0x00000028u, 0x00000000u, 0x00050005u, 0x00000031u, 0x67617266u, 0x6f6c6f43u, 0x00000072u, 0x00040005u,
0x00000033u, 0x6f436e69u, 0x00726f6cu, 0x00060005u, 0x00000036u, 0x67617266u, 0x43786554u, 0x64726f6fu,
0x00000000u, 0x00050005u, 0x00000037u, 0x65546e69u, 0x6f6f4378u, 0x00006472u, 0x00040047u, 0x0000000bu,
0x0000001eu, 0x00000000u, 0x00050048u, 0x0000000fu, 0x00000000u, 0x00000023u, 0x00000000u, 0x00050048u,
0x0000000fu, 0x00000001u, 0x00000023u, 0x00000008u, 0x00050048u, 0x0000000fu, 0x00000002u, 0x00000023u,
0x00000010u, 0x00050048u, 0x0000000fu, 0x00000003u, 0x00000023u, 0x00000014u, 0x00030047u, 0x0000000fu,
0x00000002u, 0x00040047u, 0x00000011u, 0x00000022u, 0x00000000u, 0x00040047u, 0x00000011u, 0x00000021u,
0x00000000u, 0x00050048u, 0x00000026u, 0x00000000u, 0x0000000bu, 0x00000000u, 0x00050048u, 0x00000026u,
0x00000001u, 0x0000000bu, 0x00000001u, 0x00050048u, 0x00000026u, 0x00000002u, 0x0000000bu, 0x00000003u,
0x00050048u, 0x00000026u, 0x00000003u, 0x0000000bu, 0x00000004u, 0x00030047u, 0x00000026u, 0x00000002u,
0x00040047u, 0x00000031u, 0x0000001eu, 0x00000000u, 0x00040047u, 0x00000033u, 0x0000001eu, 0x00000001u,
0x00040047u, 0x00000036u, 0x0000001eu, 0x00000001u, 0x00040047u, 0x00000037u, 0x0000001eu, 0x00000002u,
0x00020013u, 0x00000002u, 0x00030021u, 0x00000003u, 0x00000002u, 0x00030016u, 0x00000006u, 0x00000020u,
0x00040017u, 0x00000007u, 0x00000006u, 0x00000002u, 0x00040020u, 0x00000008u, 0x00000007u, 0x00000007u,
0x00040020u, 0x0000000au, 0x00000001u, 0x00000007u, 0x0004003bu, 0x0000000au, 0x0000000bu, 0x00000001u,
0x0006001eu, 0x0000000fu, 0x00000006u, 0x00000007u, 0x00000006u, 0x00000006u, 0x00040020u, 0x00000010u,
0x00000002u, 0x0000000fu, 0x0004003bu, 0x00000010u, 0x00000011u, 0x00000002u, 0x00040015u, 0x00000012u,
0x00000020u, 0x00000001u, 0x0004002bu, 0x00000012u, 0x00000013u, 0x00000001u, 0x00040020u, 0x00000014u,
0x00000002u, 0x00000007u, 0x0004002bu, 0x00000006u, 0x00000018u, 0x40000000u, 0x0004002bu, 0x00000006u,
0x0000001au, 0x3f800000u, 0x00040015u, 0x0000001du, 0x00000020u, 0x00000000u, 0x0004002bu, 0x0000001du,
0x0000001eu, 0x00000001u, 0x00040020u, 0x0000001fu, 0x00000007u, 0x00000006u, 0x00040017u, 0x00000024u,
0x00000006u, 0x00000004u, 0x0004001cu, 0x00000025u, 0x00000006u, 0x0000001eu, 0x0006001eu, 0x00000026u,
0x00000024u, 0x00000006u, 0x00000025u, 0x00000025u, 0x00040020u, 0x00000027u, 0x00000003u, 0x00000026u,
0x0004003bu, 0x00000027u, 0x00000028u, 0x00000003u, 0x0004002bu, 0x00000012u, 0x00000029u, 0x00000000u,
0x0004002bu, 0x00000006u, 0x0000002bu, 0x00000000u, 0x00040020u, 0x0000002fu, 0x00000003u, 0x00000024u,
0x0004003bu, 0x0000002fu, 0x00000031u, 0x00000003u, 0x00040020u, 0x00000032u, 0x00000001u, 0x00000024u,
0x0004003bu, 0x00000032u, 0x00000033u, 0x00000001u, 0x00040020u, 0x00000035u, 0x00000003u, 0x00000007u,
0x0004003bu, 0x00000035u, 0x00000036u, 0x00000003u, 0x0004003bu, 0x0000000au, 0x00000037u, 0x00000001u,
0x00050036u, 0x00000002u, 0x00000004u, 0x00000000u, 0x00000003u, 0x000200f8u, 0x00000005u, 0x0004003bu,
0x00000008u, 0x00000009u, 0x00000007u, 0x0004003bu, 0x00000008u, 0x0000000du, 0x00000007u, 0x0004003du,
0x00000007u, 0x0000000cu, 0x0000000bu, 0x0003003eu, 0x00000009u, 0x0000000cu, 0x0004003du, 0x00000007u,
0x0000000eu, 0x00000009u, 0x00050041u, 0x00000014u, 0x00000015u, 0x00000011u, 0x00000013u, 0x0004003du,
0x00000007u, 0x00000016u, 0x00000015u, 0x00050088u, 0x00000007u, 0x00000017u, 0x0000000eu, 0x00000016u,
0x0005008eu, 0x00000007u, 0x00000019u, 0x00000017u, 0x00000018u, 0x00050050u, 0x00000007u, 0x0000001bu,
0x0000001au, 0x0000001au, 0x00050083u, 0x00000007u, 0x0000001cu, 0x00000019u, 0x0000001bu, 0x0003003eu,
0x0000000du, 0x0000001cu, 0x00050041u, 0x0000001fu, 0x00000020u, 0x0000000du, 0x0000001eu, 0x0004003du,
0x00000006u, 0x00000021u, 0x00000020u, 0x0004007fu, 0x00000006u, 0x00000022u, 0x00000021u, 0x00050041u,
0x0000001fu, 0x00000023u, 0x0000000du, 0x0000001eu, 0x0003003eu, 0x00000023u, 0x00000022u, 0x0004003du,
0x00000007u, 0x0000002au, 0x0000000du, 0x00050051u, 0x00000006u, 0x0000002cu, 0x0000002au, 0x00000000u,
0x00050051u, 0x00000006u, 0x0000002du, 0x0000002au, 0x00000001u, 0x00070050u, 0x00000024u, 0x0000002eu,
0x0000002cu, 0x0000002du, 0x0000002bu, 0x0000001au, 0x00050041u, 0x0000002fu, 0x00000030u, 0x00000028u,
0x00000029u, 0x0003003eu, 0x00000030u, 0x0000002eu, 0x0004003du, 0x00000024u, 0x00000034u, 0x00000033u,
0x0003003eu, 0x00000031u, 0x00000034u, 0x0004003du, 0x00000007u, 0x00000038u, 0x00000037u, 0x0003003eu,
0x00000036u, 0x00000038u, 0x000100fdu, 0x00010038u

1557
src/vulkanrenderer.cpp Normal file

File diff suppressed because it is too large Load Diff

370
src/vulkanrenderer.h Normal file
View File

@ -0,0 +1,370 @@
#ifndef VULKANRENDERER_H
#define VULKANRENDERER_H
#include <vector>
#include <string>
#include <map>
#include <memory>
#include <cstdint>
// Forward declare Vulkan types
typedef struct VkDevice_T* VkDevice;
typedef struct VkPhysicalDevice_T* VkPhysicalDevice;
typedef struct VkCommandBuffer_T* VkCommandBuffer;
typedef struct VkRenderPass_T* VkRenderPass;
typedef struct VkFramebuffer_T* VkFramebuffer;
typedef struct VkPipeline_T* VkPipeline;
typedef struct VkPipelineLayout_T* VkPipelineLayout;
typedef struct VkDescriptorSetLayout_T* VkDescriptorSetLayout;
typedef struct VkDescriptorPool_T* VkDescriptorPool;
typedef struct VkDescriptorSet_T* VkDescriptorSet;
typedef struct VkBuffer_T* VkBuffer;
typedef struct VkDeviceMemory_T* VkDeviceMemory;
typedef struct VkImage_T* VkImage;
typedef struct VkImageView_T* VkImageView;
typedef struct VkSampler_T* VkSampler;
typedef struct VkShaderModule_T* VkShaderModule;
typedef struct VkQueue_T* VkQueue;
typedef struct VkCommandPool_T* VkCommandPool;
/**
* @brief
*/
struct Vertex {
float pos[2]; // 位置 (x, y)
float color[4]; // 颜色 (r, g, b, a)
float texCoord[2]; // 纹理坐标 (u, v)
};
/**
* @brief Uniform Buffer
*/
struct UniformBufferObject {
float time; // 当前时间/帧数
float resolution[2]; // 分辨率 (width, height)
float rotation; // 旋转角度
float wavePhase; // 波浪相位
float padding[2]; // 对齐到 16 字节边界
};
/**
* @brief
*/
struct CharInfo {
float texCoords[4]; // x, y, width, height in texture atlas
float size[2]; // width, height in pixels
float bearing[2]; // bearing x, y
float advance; // advance for next character
};
/**
* @brief Vulkan渲染器类
*
* Vulkan渲染操作
*/
class VulkanRenderer
{
public:
VulkanRenderer();
~VulkanRenderer();
/**
* @brief
* @param device Vulkan逻辑设备
* @param physicalDevice Vulkan物理设备
* @param graphicsQueue
* @param queueFamilyIndex
* @param swapchainFormat
* @param width
* @param height
* @return true表示成功
*/
bool initialize(VkDevice device, VkPhysicalDevice physicalDevice,
VkQueue graphicsQueue, uint32_t queueFamilyIndex,
uint32_t swapchainFormat, uint32_t width, uint32_t height);
/**
* @brief
*/
void cleanup();
/**
* @brief
* @param width
* @param height
* @return true表示成功
*/
bool resize(uint32_t width, uint32_t height);
/**
* @brief
* @param commandBuffer
* @param imageIndex
* @param imageView
* @param frameCount
* @param rotationAngle
* @param wavePhase
* @param paintingEnabled
* @param lockInfo
*/
void recordCommandBuffer(VkCommandBuffer commandBuffer,
uint32_t imageIndex,
VkImageView imageView,
int frameCount,
double rotationAngle,
double wavePhase,
bool paintingEnabled,
const std::string& lockInfo);
/**
* @brief
* @param frameCount
* @param rotation
* @param wavePhase
*/
void updateAnimationParams(int frameCount, double rotation, double wavePhase);
/**
* @brief
*/
VkRenderPass getRenderPass() const { return m_renderPass; }
/**
* @brief
*/
VkFramebuffer getFramebuffer(uint32_t index) const;
/**
* @brief
*/
void setErrorCallback(void (*callback)(const char*)) { m_errorCallback = callback; }
private:
/**
* @brief
*/
bool createRenderPass();
/**
* @brief
*/
bool createFramebuffers();
/**
* @brief
*/
VkShaderModule createShaderModule(const std::vector<char>& code);
/**
* @brief 线
*/
bool createBackgroundPipeline();
/**
* @brief 线fallback
*/
bool createBackgroundPipelineSimple();
/**
* @brief 线 -
*/
bool createGeometryPipeline();
/**
* @brief 线线线
*/
bool createLinePipeline();
/**
* @brief 线
*/
bool createTextPipeline();
/**
* @brief
*/
bool createDescriptorSetLayout();
/**
* @brief
*/
bool createDescriptorPool();
/**
* @brief
*/
bool createDescriptorSets();
/**
* @brief Uniform Buffer
*/
bool createUniformBuffers();
/**
* @brief Uniform Buffer
*/
void updateUniformBuffer(uint32_t currentImage);
/**
* @brief
*/
bool createVertexBuffer(const std::vector<Vertex>& vertices,
VkBuffer& buffer, VkDeviceMemory& memory);
/**
* @brief
*/
bool createIndexBuffer(const std::vector<uint16_t>& indices,
VkBuffer& buffer, VkDeviceMemory& memory);
/**
* @brief
*/
bool createBuffer(uint64_t size, uint32_t usage, uint32_t properties,
VkBuffer& buffer, VkDeviceMemory& memory);
/**
* @brief
*/
bool copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, uint64_t size);
/**
* @brief
*/
uint32_t findMemoryType(uint32_t typeFilter, uint32_t properties);
/**
* @brief
*/
bool initializeTextRendering();
/**
* @brief
*/
bool createFontAtlas();
/**
* @brief
*/
void generateBackgroundQuad(std::vector<Vertex>& vertices,
std::vector<uint16_t>& indices);
/**
* @brief
*/
void generateRotatingCircles(std::vector<Vertex>& vertices,
std::vector<uint16_t>& indices,
double rotation);
/**
* @brief
*/
void generateWaveEffect(std::vector<Vertex>& vertices,
std::vector<uint16_t>& indices,
double wavePhase);
/**
* @brief
*/
void generateTextQuads(const std::string& text, float x, float y,
float scale, const float color[4],
std::vector<Vertex>& vertices,
std::vector<uint16_t>& indices);
/**
* @brief
*/
void drawBackground(VkCommandBuffer commandBuffer, int frameCount);
/**
* @brief
*/
void drawGeometry(VkCommandBuffer commandBuffer, double rotation, double wavePhase);
/**
* @brief
*/
void drawText(VkCommandBuffer commandBuffer, int frameCount,
bool paintingEnabled, const std::string& lockInfo);
/**
* @brief
*/
void logError(const char* message);
private:
// Vulkan 对象
VkDevice m_device;
VkPhysicalDevice m_physicalDevice;
VkQueue m_graphicsQueue;
uint32_t m_queueFamilyIndex;
VkCommandPool m_transferCommandPool;
VkRenderPass m_renderPass;
std::vector<VkFramebuffer> m_framebuffers;
std::vector<VkImageView> m_imageViews;
// 管线对象
VkPipeline m_backgroundPipeline;
VkPipelineLayout m_backgroundPipelineLayout;
VkPipeline m_geometryPipeline;
VkPipelineLayout m_geometryPipelineLayout;
VkPipeline m_linePipeline;
VkPipelineLayout m_linePipelineLayout;
VkPipeline m_textPipeline;
VkPipelineLayout m_textPipelineLayout;
// 描述符对象
VkDescriptorSetLayout m_descriptorSetLayout;
VkDescriptorPool m_descriptorPool;
std::vector<VkDescriptorSet> m_descriptorSets;
// Uniform Buffer
std::vector<VkBuffer> m_uniformBuffers;
std::vector<VkDeviceMemory> m_uniformBuffersMemory;
std::vector<void*> m_uniformBuffersMapped;
// 几何体缓冲区
VkBuffer m_backgroundVertexBuffer;
VkDeviceMemory m_backgroundVertexMemory;
VkBuffer m_backgroundIndexBuffer;
VkDeviceMemory m_backgroundIndexMemory;
uint32_t m_backgroundIndexCount;
VkBuffer m_circleVertexBuffer;
VkDeviceMemory m_circleVertexMemory;
VkBuffer m_circleIndexBuffer;
VkDeviceMemory m_circleIndexMemory;
uint32_t m_circleIndexCount;
VkBuffer m_waveVertexBuffer;
VkDeviceMemory m_waveVertexMemory;
VkBuffer m_waveIndexBuffer;
VkDeviceMemory m_waveIndexMemory;
uint32_t m_waveIndexCount;
// 文本渲染资源
VkImage m_fontTexture;
VkDeviceMemory m_fontTextureMemory;
VkImageView m_fontTextureView;
VkSampler m_fontSampler;
std::map<char, CharInfo> m_charInfoMap;
// 渲染目标尺寸
uint32_t m_width;
uint32_t m_height;
uint32_t m_swapchainFormat;
// 动画参数
UniformBufferObject m_ubo;
// 初始化状态
bool m_initialized;
// 错误回调
void (*m_errorCallback)(const char*);
// 最大帧数
static const int MAX_FRAMES_IN_FLIGHT = 2;
};
#endif // VULKANRENDERER_H

View File

@ -1,4 +1,5 @@
#include "vulkanwidget.h" #include "vulkanwidget.h"
#include "vulkanrenderer.h"
#include <QDebug> #include <QDebug>
#include <QShowEvent> #include <QShowEvent>
#include <QHideEvent> #include <QHideEvent>
@ -13,6 +14,10 @@
#define VK_NO_PROTOTYPES #define VK_NO_PROTOTYPES
#include "../../third_party/volk/volk.h" #include "../../third_party/volk/volk.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
// Platform-specific headers // Platform-specific headers
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
@ -38,6 +43,14 @@ VulkanWidget::VulkanWidget(QWidget *parent)
, m_surfaceWidth(0) , m_surfaceWidth(0)
, m_surfaceHeight(0) , m_surfaceHeight(0)
, m_renderTimer(nullptr) , m_renderTimer(nullptr)
, m_renderer(nullptr)
, m_rotationAngle(0.0)
, m_wavePhase(0.0)
, m_startTime(QDateTime::currentDateTime())
, m_lastLockDuration(0)
, m_lastLockFrameCount(0)
, m_lockPaintFrameCount(0)
, m_lockCount(0)
{ {
// Set widget attributes for native window // Set widget attributes for native window
setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_NativeWindow);
@ -59,6 +72,13 @@ VulkanWidget::~VulkanWidget()
m_renderTimer->stop(); m_renderTimer->stop();
} }
// Clean up renderer first
if (m_renderer) {
m_renderer->cleanup();
delete m_renderer;
m_renderer = nullptr;
}
cleanupVulkan(); cleanupVulkan();
qDebug() << "VulkanWidget destroyed"; qDebug() << "VulkanWidget destroyed";
@ -121,9 +141,40 @@ bool VulkanWidget::initializeVulkan()
return false; return false;
} }
m_initialized = true; // Step 9: Create VulkanRenderer - but only if we have reasonable dimensions
qDebug() << "Vulkan initialization successful"; if (m_surfaceWidth >= 100 && m_surfaceHeight >= 100) {
m_renderer = new VulkanRenderer();
// Get swapchain format
VkSurfaceFormatKHR surfaceFormat;
uint32_t formatCount = 0;
vkGetPhysicalDeviceSurfaceFormatsKHR(m_physicalDevice, m_surface, &formatCount, nullptr);
if (formatCount > 0) {
std::vector<VkSurfaceFormatKHR> formats(formatCount);
vkGetPhysicalDeviceSurfaceFormatsKHR(m_physicalDevice, m_surface, &formatCount, formats.data());
surfaceFormat = formats[0];
}
// Initialize renderer
if (!m_renderer->initialize(m_device, m_physicalDevice,
m_queue, m_queueFamilyIndex,
static_cast<uint32_t>(surfaceFormat.format),
m_surfaceWidth, m_surfaceHeight)) {
setError("Failed to initialize VulkanRenderer");
delete m_renderer;
m_renderer = nullptr;
return false;
}
qDebug() << "VulkanRenderer initialized successfully!";
qDebug() << "Widget size:" << width() << "x" << height()
<< "| Surface size:" << m_surfaceWidth << "x" << m_surfaceHeight;
} else {
qDebug() << "VulkanRenderer initialization deferred - window too small:" << m_surfaceWidth << "x" << m_surfaceHeight;
}
m_initialized = true;
qDebug() << "Vulkan initialization successful!";
return true; return true;
} }
@ -424,6 +475,33 @@ bool VulkanWidget::createSwapchain()
vkGetSwapchainImagesKHR(m_device, m_swapchain, &imageCount, vkGetSwapchainImagesKHR(m_device, m_swapchain, &imageCount,
reinterpret_cast<VkImage*>(m_swapchainImages.data())); reinterpret_cast<VkImage*>(m_swapchainImages.data()));
// Create image views for swapchain images
m_swapchainImageViews.resize(imageCount);
for (uint32_t i = 0; i < imageCount; i++) {
VkImageViewCreateInfo viewInfo = {};
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
viewInfo.image = reinterpret_cast<VkImage>(m_swapchainImages[i]);
viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
viewInfo.format = surfaceFormat.format;
viewInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
viewInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
viewInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
viewInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
viewInfo.subresourceRange.baseMipLevel = 0;
viewInfo.subresourceRange.levelCount = 1;
viewInfo.subresourceRange.baseArrayLayer = 0;
viewInfo.subresourceRange.layerCount = 1;
VkImageView imageView;
result = vkCreateImageView(m_device, &viewInfo, nullptr, &imageView);
if (result != VK_SUCCESS) {
qDebug() << "Failed to create image view" << i << ", error code:" << result;
return false;
}
m_swapchainImageViews[i] = reinterpret_cast<void*>(imageView);
}
qDebug() << "Swapchain created successfully with" << imageCount << "images, size:" qDebug() << "Swapchain created successfully with" << imageCount << "images, size:"
<< m_surfaceWidth << "x" << m_surfaceHeight; << m_surfaceWidth << "x" << m_surfaceHeight;
@ -507,6 +585,12 @@ bool VulkanWidget::recreateSwapchain()
return false; return false;
} }
// Update renderer with new surface dimensions
if (m_renderer) {
qDebug() << "Updating VulkanRenderer to surface size:" << m_surfaceWidth << "x" << m_surfaceHeight;
m_renderer->resize(m_surfaceWidth, m_surfaceHeight);
}
qDebug() << "Swapchain recreated successfully"; qDebug() << "Swapchain recreated successfully";
return true; return true;
} }
@ -589,12 +673,70 @@ void VulkanWidget::renderFrame()
void VulkanWidget::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) void VulkanWidget::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex)
{ {
// Initialize renderer now if we didn't do it earlier (window was too small)
if (!m_renderer && m_surfaceWidth >= 100 && m_surfaceHeight >= 100) {
qDebug() << "Creating deferred VulkanRenderer with actual surface size:" << m_surfaceWidth << "x" << m_surfaceHeight;
m_renderer = new VulkanRenderer();
VkSurfaceFormatKHR surfaceFormat;
uint32_t formatCount = 0;
vkGetPhysicalDeviceSurfaceFormatsKHR(m_physicalDevice, m_surface, &formatCount, nullptr);
if (formatCount > 0) {
std::vector<VkSurfaceFormatKHR> formats(formatCount);
vkGetPhysicalDeviceSurfaceFormatsKHR(m_physicalDevice, m_surface, &formatCount, formats.data());
surfaceFormat = formats[0];
}
if (!m_renderer->initialize(m_device, m_physicalDevice,
m_queue, m_queueFamilyIndex,
static_cast<uint32_t>(surfaceFormat.format),
m_surfaceWidth, m_surfaceHeight)) {
qDebug() << "Failed to initialize deferred VulkanRenderer";
delete m_renderer;
m_renderer = nullptr;
} else {
qDebug() << "Deferred VulkanRenderer initialized successfully with surface size:"
<< m_surfaceWidth << "x" << m_surfaceHeight;
}
}
// Use VulkanRenderer if available
if (m_renderer) {
if (imageIndex >= m_swapchainImageViews.size()) {
qDebug() << "ERROR: imageIndex out of bounds!";
return;
}
VkImageView imageView = reinterpret_cast<VkImageView>(m_swapchainImageViews[imageIndex]);
// Build lock info string
QString lockInfo;
if (m_lastLockTime.isValid()) {
lockInfo = QString("Last Lock: %1\nDuration: %2s\nLock Count: %3")
.arg(m_lastLockTime.toString("hh:mm:ss"))
.arg(m_lastLockDuration)
.arg(m_lockCount);
}
// Debug: Print dimensions occasionally to check for mismatch
static int debugCounter = 0;
if (debugCounter++ % 300 == 0) { // Every ~5 seconds at 60fps
qDebug() << "Rendering - Widget:" << width() << "x" << height()
<< "| Surface:" << m_surfaceWidth << "x" << m_surfaceHeight;
}
m_renderer->recordCommandBuffer(commandBuffer, imageIndex, imageView,
m_frameCount, m_rotationAngle, m_wavePhase,
m_renderingEnabled, lockInfo.toStdString());
return;
}
// Fallback: Simple clear color pass
VkCommandBufferBeginInfo beginInfo = {}; VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
vkBeginCommandBuffer(commandBuffer, &beginInfo); vkBeginCommandBuffer(commandBuffer, &beginInfo);
// Simple clear color pass - cycle through colors based on frame count
VkClearColorValue clearColor; VkClearColorValue clearColor;
float hue = (m_frameCount % 360) / 360.0f; float hue = (m_frameCount % 360) / 360.0f;
float r = std::abs(std::sin(hue * 6.28318f)); float r = std::abs(std::sin(hue * 6.28318f));
@ -614,7 +756,6 @@ void VulkanWidget::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t i
VkImage image = reinterpret_cast<VkImage>(m_swapchainImages[imageIndex]); VkImage image = reinterpret_cast<VkImage>(m_swapchainImages[imageIndex]);
// Transition to transfer dst
VkImageMemoryBarrier barrier1 = {}; VkImageMemoryBarrier barrier1 = {};
barrier1.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; barrier1.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
barrier1.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; barrier1.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
@ -629,11 +770,9 @@ void VulkanWidget::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t i
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier1); VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier1);
// Clear image
vkCmdClearColorImage(commandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, vkCmdClearColorImage(commandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
&clearColor, 1, &range); &clearColor, 1, &range);
// Transition to present
VkImageMemoryBarrier barrier2 = {}; VkImageMemoryBarrier barrier2 = {};
barrier2.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; barrier2.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
barrier2.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; barrier2.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
@ -653,13 +792,20 @@ void VulkanWidget::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t i
void VulkanWidget::cleanupSwapchain() void VulkanWidget::cleanupSwapchain()
{ {
// Destroy image views first
for (void* imageView : m_swapchainImageViews) {
if (imageView != nullptr) {
vkDestroyImageView(m_device, reinterpret_cast<VkImageView>(imageView), nullptr);
}
}
m_swapchainImageViews.clear();
if (m_swapchain != VK_NULL_HANDLE) { if (m_swapchain != VK_NULL_HANDLE) {
vkDestroySwapchainKHR(m_device, m_swapchain, nullptr); vkDestroySwapchainKHR(m_device, m_swapchain, nullptr);
m_swapchain = VK_NULL_HANDLE; m_swapchain = VK_NULL_HANDLE;
} }
m_swapchainImages.clear(); m_swapchainImages.clear();
m_swapchainImageViews.clear();
} }
void VulkanWidget::cleanupVulkan() void VulkanWidget::cleanupVulkan()
@ -721,11 +867,32 @@ void VulkanWidget::setRenderingEnabled(bool enabled)
m_renderingEnabled = enabled; m_renderingEnabled = enabled;
if (m_renderingEnabled) { if (m_renderingEnabled) {
qDebug() << "Vulkan rendering enabled"; qDebug() << "Vulkan rendering ENABLED - Resuming animations";
m_renderTimer->start(16); // ~60 FPS m_renderTimer->start(16); // ~60 FPS
// Unlocked: calculate lock duration
if (m_lastLockTime.isValid()) {
QDateTime unlockTime = QDateTime::currentDateTime();
m_lastLockDuration = m_lastLockTime.secsTo(unlockTime);
m_lockPaintFrameCount = m_frameCount - m_lastLockFrameCount;
qDebug() << "Screen was locked for" << m_lastLockDuration << "seconds";
qDebug() << "Frames at lock:" << m_lastLockFrameCount
<< "- Frames painted during lock:" << m_lockPaintFrameCount;
}
m_startTime = QDateTime::currentDateTime();
} else { } else {
qDebug() << "Vulkan rendering disabled"; qDebug() << "Vulkan rendering DISABLED - Stopping animations";
m_renderTimer->stop(); m_renderTimer->stop();
// Locked: record lock time
m_pauseTime = QDateTime::currentDateTime();
m_lastLockTime = m_pauseTime;
m_lastLockFrameCount = m_frameCount;
m_lockCount++;
qDebug() << "Screen locked at" << m_lastLockTime.toString("yyyy-MM-dd hh:mm:ss")
<< "- Lock count:" << m_lockCount
<< "- Frame count at lock:" << m_lastLockFrameCount;
} }
} }
@ -766,6 +933,10 @@ void VulkanWidget::resizeEvent(QResizeEvent *event)
if (m_initialized) { if (m_initialized) {
m_needsResize = true; m_needsResize = true;
// Note: Don't update renderer size here - it will be updated after swapchain recreation
// The renderer must use the actual surface dimensions (m_surfaceWidth/Height),
// not the widget dimensions, which may differ on high DPI displays
} }
} }
@ -783,6 +954,19 @@ QPaintEngine* VulkanWidget::paintEngine() const
void VulkanWidget::onRenderTimer() void VulkanWidget::onRenderTimer()
{ {
if (m_renderingEnabled) {
// Update animation parameters
m_rotationAngle += 2.0;
if (m_rotationAngle >= 360.0) {
m_rotationAngle -= 360.0;
}
m_wavePhase += 0.05;
if (m_wavePhase >= 2 * M_PI) {
m_wavePhase -= 2 * M_PI;
}
}
renderFrame(); renderFrame();
} }

View File

@ -4,8 +4,12 @@
#include <QWidget> #include <QWidget>
#include <QString> #include <QString>
#include <QTimer> #include <QTimer>
#include <QDateTime>
#include <vector> #include <vector>
// Forward declare VulkanRenderer
class VulkanRenderer;
// Forward declare Vulkan types to avoid including volk.h in header // Forward declare Vulkan types to avoid including volk.h in header
typedef struct VkInstance_T* VkInstance; typedef struct VkInstance_T* VkInstance;
typedef struct VkPhysicalDevice_T* VkPhysicalDevice; typedef struct VkPhysicalDevice_T* VkPhysicalDevice;
@ -243,6 +247,20 @@ private:
// 定时器 // 定时器
QTimer *m_renderTimer; QTimer *m_renderTimer;
// VulkanRenderer
VulkanRenderer *m_renderer;
// 动画参数
double m_rotationAngle;
double m_wavePhase;
QDateTime m_startTime;
QDateTime m_pauseTime;
QDateTime m_lastLockTime;
qint64 m_lastLockDuration;
int m_lastLockFrameCount;
int m_lockPaintFrameCount;
int m_lockCount;
// 常量 // 常量
static const int MAX_FRAMES_IN_FLIGHT = 2; static const int MAX_FRAMES_IN_FLIGHT = 2;
}; };