Adding some very basic shaders and a pipeline to compile them

This commit is contained in:
Darragh Coy 2021-01-04 16:15:49 -08:00
parent 5b118dcaa8
commit 6376cbaca2
6 changed files with 128 additions and 1 deletions

View File

@ -99,7 +99,7 @@ def run_demo(psydoom_path, cue_file_path, demos_dir, demo_and_result):
sys.exit(1)
# High level script logic
def main():
def main():
# Verify program args
if len(sys.argv) != 4:
print("Usage: python run_demo_tests.py <demoset|all> <psydoom_path> <demos_dir>")

View File

@ -0,0 +1,11 @@
#version 460
//----------------------------------------------------------------------------------------------------------------------
// Simple fragment shader that outputs input vertex colors
//----------------------------------------------------------------------------------------------------------------------
layout(location = 0) in vec4 in_color;
layout(location = 0) out vec4 out_color;
void main() {
out_color = in_color;
}

View File

@ -0,0 +1,18 @@
#version 460
//----------------------------------------------------------------------------------------------------------------------
// Simple vertex shader that transforms input vertices with color by a model view projection matrix.
// The vertices are then output with the same input color.
//----------------------------------------------------------------------------------------------------------------------
layout(push_constant) uniform Constants {
mat4 mvpMatrix;
} constants;
layout(location = 0) in vec3 in_position;
layout(location = 1) in vec4 in_color;
layout(location = 0) out vec4 out_color;
void main() {
out_color = in_color;
gl_Position = constants.mvpMatrix * vec4(in_position, 1);
}

View File

@ -0,0 +1,39 @@
#!python
############################################################################################################################################
# This script compiles all of the Vulkan GLSL format shaders for the project to SPIR-V binary code.
# The SPIR-V generated is saved in the format of C header files which can then be embedded in the application.
#
# Requirements:
# (1) The Vulkan SDK 'glslangvalidator' tool must be invokable.
# Install the SDK and ensure this tool is on your current system's BIN path.
# (2) This script must be executed from the shaders directory.
############################################################################################################################################
import os
import subprocess
import sys
# Job-specs for all the files to compile.
# Corresponds to the 3 arguments of 'compile_shader'
files_to_compile = [
[ "colored.vert", "compiled/SPIRV_colored_vert.h", "gSPIRV_colored_vert" ],
[ "colored.frag", "compiled/SPIRV_colored_frag.h", "gSPIRV_colored_frag" ],
]
# Compiles the input GLSL file to an output .h file with the specified name.
# The C-Array for the shader is given the specified name.
def compile_shader(input_glsl_file, output_c_file, c_var_name):
result = subprocess.call(
["glslangvalidator", "--vn", c_var_name, "-V", "-x", "-o", output_c_file, input_glsl_file]
)
if result != 0:
print("Compile FAILED for file: {0:s}!".format(input_glsl_file))
sys.exit(1)
# Main script logic: compiles all of the shaders
def main():
for job_spec in files_to_compile:
compile_shader(job_spec[0], job_spec[1], job_spec[2])
main()

View File

@ -0,0 +1,16 @@
// 1011.0.0
#pragma once
const uint32_t gSPIRV_colored_frag[] = {
0x07230203,0x00010000,0x0008000a,0x0000000d,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000b,0x00030010,
0x00000004,0x00000007,0x00030003,0x00000002,0x000001cc,0x00040005,0x00000004,0x6e69616d,
0x00000000,0x00050005,0x00000009,0x5f74756f,0x6f6c6f63,0x00000072,0x00050005,0x0000000b,
0x635f6e69,0x726f6c6f,0x00000000,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,
0x0000000b,0x0000001e,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,
0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,
0x00000008,0x00000003,0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040020,
0x0000000a,0x00000001,0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,0x00050036,
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d,0x00000007,
0x0000000c,0x0000000b,0x0003003e,0x00000009,0x0000000c,0x000100fd,0x00010038
};

View File

@ -0,0 +1,43 @@
// 1011.0.0
#pragma once
const uint32_t gSPIRV_colored_vert[] = {
0x07230203,0x00010000,0x0008000a,0x00000027,0x00000000,0x00020011,0x00000001,0x0006000b,
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
0x0009000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000b,0x00000012,
0x0000001e,0x00030003,0x00000002,0x000001cc,0x00040005,0x00000004,0x6e69616d,0x00000000,
0x00050005,0x00000009,0x5f74756f,0x6f6c6f63,0x00000072,0x00050005,0x0000000b,0x635f6e69,
0x726f6c6f,0x00000000,0x00060005,0x00000010,0x505f6c67,0x65567265,0x78657472,0x00000000,
0x00060006,0x00000010,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00070006,0x00000010,
0x00000001,0x505f6c67,0x746e696f,0x657a6953,0x00000000,0x00070006,0x00000010,0x00000002,
0x435f6c67,0x4470696c,0x61747369,0x0065636e,0x00070006,0x00000010,0x00000003,0x435f6c67,
0x446c6c75,0x61747369,0x0065636e,0x00030005,0x00000012,0x00000000,0x00050005,0x00000016,
0x736e6f43,0x746e6174,0x00000073,0x00060006,0x00000016,0x00000000,0x4d70766d,0x69727461,
0x00000078,0x00050005,0x00000018,0x736e6f63,0x746e6174,0x00000073,0x00050005,0x0000001e,
0x705f6e69,0x7469736f,0x006e6f69,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,
0x0000000b,0x0000001e,0x00000001,0x00050048,0x00000010,0x00000000,0x0000000b,0x00000000,
0x00050048,0x00000010,0x00000001,0x0000000b,0x00000001,0x00050048,0x00000010,0x00000002,
0x0000000b,0x00000003,0x00050048,0x00000010,0x00000003,0x0000000b,0x00000004,0x00030047,
0x00000010,0x00000002,0x00040048,0x00000016,0x00000000,0x00000005,0x00050048,0x00000016,
0x00000000,0x00000023,0x00000000,0x00050048,0x00000016,0x00000000,0x00000007,0x00000010,
0x00030047,0x00000016,0x00000002,0x00040047,0x0000001e,0x0000001e,0x00000000,0x00020013,
0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,
0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,0x00000007,0x0004003b,
0x00000008,0x00000009,0x00000003,0x00040020,0x0000000a,0x00000001,0x00000007,0x0004003b,
0x0000000a,0x0000000b,0x00000001,0x00040015,0x0000000d,0x00000020,0x00000000,0x0004002b,
0x0000000d,0x0000000e,0x00000001,0x0004001c,0x0000000f,0x00000006,0x0000000e,0x0006001e,
0x00000010,0x00000007,0x00000006,0x0000000f,0x0000000f,0x00040020,0x00000011,0x00000003,
0x00000010,0x0004003b,0x00000011,0x00000012,0x00000003,0x00040015,0x00000013,0x00000020,
0x00000001,0x0004002b,0x00000013,0x00000014,0x00000000,0x00040018,0x00000015,0x00000007,
0x00000004,0x0003001e,0x00000016,0x00000015,0x00040020,0x00000017,0x00000009,0x00000016,
0x0004003b,0x00000017,0x00000018,0x00000009,0x00040020,0x00000019,0x00000009,0x00000015,
0x00040017,0x0000001c,0x00000006,0x00000003,0x00040020,0x0000001d,0x00000001,0x0000001c,
0x0004003b,0x0000001d,0x0000001e,0x00000001,0x0004002b,0x00000006,0x00000020,0x3f800000,
0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d,
0x00000007,0x0000000c,0x0000000b,0x0003003e,0x00000009,0x0000000c,0x00050041,0x00000019,
0x0000001a,0x00000018,0x00000014,0x0004003d,0x00000015,0x0000001b,0x0000001a,0x0004003d,
0x0000001c,0x0000001f,0x0000001e,0x00050051,0x00000006,0x00000021,0x0000001f,0x00000000,
0x00050051,0x00000006,0x00000022,0x0000001f,0x00000001,0x00050051,0x00000006,0x00000023,
0x0000001f,0x00000002,0x00070050,0x00000007,0x00000024,0x00000021,0x00000022,0x00000023,
0x00000020,0x00050091,0x00000007,0x00000025,0x0000001b,0x00000024,0x00050041,0x00000008,
0x00000026,0x00000012,0x00000014,0x0003003e,0x00000026,0x00000025,0x000100fd,0x00010038
};