some work on pipeline setup, fixing up bash script
This commit is contained in:
parent
c700b40c86
commit
d16dbe63fa
43
build.sh
43
build.sh
@ -33,6 +33,18 @@ vma_compile_flags="-std=c++20 -I../external/vma"
|
|||||||
vma_out="-c -o"
|
vma_out="-c -o"
|
||||||
vma_obj="vma.o"
|
vma_obj="vma.o"
|
||||||
|
|
||||||
|
# glslc
|
||||||
|
glsl_compile="glslc"
|
||||||
|
glsl_flags="--target-spv=spv1.6 -std=460"
|
||||||
|
glsl_stage_vert="-fshader-stage=vert"
|
||||||
|
glsl_stage_frag="-fshader-stage=frag"
|
||||||
|
glsl_stage_tesc="-fshader-stage=tesc"
|
||||||
|
glsl_stage_tese="-fshader-stage=tese"
|
||||||
|
glsl_stage_geom="-fshader-stage=geom"
|
||||||
|
glsl_stage_comp="-fshader-stage=comp"
|
||||||
|
glsl_out="-o/build/shaders/glsl/"
|
||||||
|
|
||||||
|
|
||||||
clang_common="${include_flags} -g -Xclang -flto-visibility-public-std -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis -DVMA_STATIC_VULKAN_FUNCTIONS=0"
|
clang_common="${include_flags} -g -Xclang -flto-visibility-public-std -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis -DVMA_STATIC_VULKAN_FUNCTIONS=0"
|
||||||
clang_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common} ${auto_compile_flags}"
|
clang_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common} ${auto_compile_flags}"
|
||||||
clang_release="$compiler -g -O2 -DBUILD_DEBUG=0 ${clang_common} ${auto_compile_flags}"
|
clang_release="$compiler -g -O2 -DBUILD_DEBUG=0 ${clang_common} ${auto_compile_flags}"
|
||||||
@ -69,6 +81,37 @@ if [ ! -f $vma_obj ]; then
|
|||||||
$vma_ld
|
$vma_ld
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
mkdir -p ./shaders/glsl
|
||||||
|
for file in ../src/shaders/glsl/*.glsl; do
|
||||||
|
base_name=$(basename -- "$file" .glsl)
|
||||||
|
echo $base_name
|
||||||
|
echo $file
|
||||||
|
|
||||||
|
case base_name in
|
||||||
|
*.vert)
|
||||||
|
glsl_stage="${glsl_stage_vert}"
|
||||||
|
;;
|
||||||
|
*.frag)
|
||||||
|
glsl_stage="${glsl_stage_vert}"
|
||||||
|
;;
|
||||||
|
*.tesc)
|
||||||
|
glsl_stage="${glsl_stage_tesc}"
|
||||||
|
;;
|
||||||
|
*.tese)
|
||||||
|
glsl_stage="${glsl_stage_tese}"
|
||||||
|
;;
|
||||||
|
*.geom)
|
||||||
|
glsl_stage="${glsl_stage_geom}"
|
||||||
|
;;
|
||||||
|
*.comp)
|
||||||
|
glsl_stage="${glsl_stage_comp}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
$glsl_compile $glsl_flags $glsl_stage file "${glsl_out}${base_name}.spv"
|
||||||
|
done
|
||||||
|
|
||||||
$cpp_compiler $vma_compile_flags $vma_source_files $vma_out $vma_obj
|
$cpp_compiler $vma_compile_flags $vma_source_files $vma_out $vma_obj
|
||||||
|
|
||||||
ar rcs libvma.a vmastdc++.o
|
ar rcs libvma.a vmastdc++.o
|
||||||
|
|||||||
@ -63,3 +63,7 @@ b32 CreateWindow();
|
|||||||
Window *GetWindow();
|
Window *GetWindow();
|
||||||
b32 GetWindowEvent(WindowEvent *event);
|
b32 GetWindowEvent(WindowEvent *event);
|
||||||
WindowSize GetWindowSize();
|
WindowSize GetWindowSize();
|
||||||
|
|
||||||
|
// Directory Functions
|
||||||
|
b32 ChangeWorkingDir(const char *);
|
||||||
|
u8 *OpenFile(const char *);
|
||||||
|
|||||||
@ -288,3 +288,16 @@ b32 _GetWindowEvent(WindowEvent *event)
|
|||||||
return valid_event;
|
return valid_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b32 ChangeWorkingDir(const char *)
|
||||||
|
{
|
||||||
|
b32 success = false;
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 *OpenFile(const char *)
|
||||||
|
{
|
||||||
|
u8 *bytes;
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|||||||
@ -672,6 +672,18 @@ static b32 CreateDescriptors()
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static b32 CreatePipelines()
|
||||||
|
{
|
||||||
|
b32 success = true;
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VkShaderModule CreateShaderModule(const char *file_name)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void DestroyVulkan()
|
static void DestroyVulkan()
|
||||||
{
|
{
|
||||||
VkDevice device = renderer.vk.device;
|
VkDevice device = renderer.vk.device;
|
||||||
|
|||||||
@ -123,7 +123,7 @@ VK_DECLARE(vkDestroyDescriptorSetLayout);
|
|||||||
|
|
||||||
typedef enum Pipeline_e
|
typedef enum Pipeline_e
|
||||||
{
|
{
|
||||||
PIPELINE_QUAD,
|
PIPELINE_CUBE,
|
||||||
|
|
||||||
PIPELINE_MAX,
|
PIPELINE_MAX,
|
||||||
} PipelineHandle;
|
} PipelineHandle;
|
||||||
@ -256,6 +256,7 @@ static b32 CreateImmediateStructures();
|
|||||||
static b32 CreateSwapchain();
|
static b32 CreateSwapchain();
|
||||||
static VkFormat GetImageFormat();
|
static VkFormat GetImageFormat();
|
||||||
static b32 CreateDescriptors();
|
static b32 CreateDescriptors();
|
||||||
|
static b32 CreatePipelines();
|
||||||
|
|
||||||
// Destroy
|
// Destroy
|
||||||
static void DestroyVulkan();
|
static void DestroyVulkan();
|
||||||
|
|||||||
10
src/shaders/glsl/quad.frag.glsl
Normal file
10
src/shaders/glsl/quad.frag.glsl
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 fragColor;
|
||||||
|
|
||||||
|
layout (location = 0) out vec4 outColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
outColor = vec4(fragColor, 1.0);
|
||||||
|
}
|
||||||
21
src/shaders/glsl/quad.vert.glsl
Normal file
21
src/shaders/glsl/quad.vert.glsl
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#version 460
|
||||||
|
|
||||||
|
layout (location = 0) out vec3 fragColor;
|
||||||
|
|
||||||
|
vec2 triangle[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)
|
||||||
|
);
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
|
||||||
|
fragColor = colors[gl_VertexIndex];
|
||||||
|
}
|
||||||
@ -285,3 +285,105 @@ static VkPipelineLayoutCreateInfo pipeline_layout_create_info = {
|
|||||||
.pushConstantRangeCount = 1,
|
.pushConstantRangeCount = 1,
|
||||||
.pPushConstantRanges = &push_const_range,
|
.pPushConstantRanges = &push_const_range,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// PIPELINES
|
||||||
|
//
|
||||||
|
|
||||||
|
static VkDynamicState pipeline_dynamic_state[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
|
||||||
|
|
||||||
|
static const VkPipelineDynamicStateCreateInfo pipeline_default_dyn_state_info = {
|
||||||
|
.sType = STYPE(PIPELINE_DYNAMIC_STATE_CREATE_INFO),
|
||||||
|
.pDynamicStates = pipeline_dynamic_state,
|
||||||
|
.dynamicStateCount = Len(pipeline_dynamic_state),
|
||||||
|
};
|
||||||
|
|
||||||
|
const static VkPipelineInputAssemblyStateCreateInfo pipeline_default_assembly_info = {
|
||||||
|
.sType = STYPE(PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO),
|
||||||
|
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
|
||||||
|
.primitiveRestartEnable = VK_FALSE,
|
||||||
|
};
|
||||||
|
|
||||||
|
const static VkPipelineRasterizationStateCreateInfo pipeline_default_rasterization_info = {
|
||||||
|
.sType = STYPE(PIPELINE_RASTERIZATION_STATE_CREATE_INFO),
|
||||||
|
.polygonMode = VK_POLYGON_MODE_FILL,
|
||||||
|
.lineWidth = 1.0,
|
||||||
|
.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE,
|
||||||
|
};
|
||||||
|
|
||||||
|
const static VkPipelineMultisampleStateCreateInfo pipeline_default_multisample_info = {
|
||||||
|
.sType = STYPE(PIPELINE_MULTISAMPLE_STATE_CREATE_INFO),
|
||||||
|
.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT,
|
||||||
|
.minSampleShading = 1.0,
|
||||||
|
.alphaToCoverageEnable = VK_FALSE,
|
||||||
|
.alphaToOneEnable = VK_FALSE,
|
||||||
|
};
|
||||||
|
|
||||||
|
const static VkPipelineDepthStencilStateCreateInfo pipeline_default_depth_info = {
|
||||||
|
.sType = STYPE(PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO),
|
||||||
|
.depthTestEnable = VK_TRUE,
|
||||||
|
.depthWriteEnable = VK_TRUE,
|
||||||
|
.depthCompareOp = VK_COMPARE_OP_GREATER_OR_EQUAL,
|
||||||
|
.depthBoundsTestEnable = VK_FALSE,
|
||||||
|
.stencilTestEnable = VK_FALSE,
|
||||||
|
.minDepthBounds = 0.0,
|
||||||
|
.maxDepthBounds = 1.0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const static VkPipelineRenderingCreateInfo pipeline_default_rendering_info = {
|
||||||
|
.sType = STYPE(PIPELINE_RENDERING_CREATE_INFO),
|
||||||
|
.colorAttachmentCount = 1,
|
||||||
|
//.pColorAttachmentFormats = FORMAT
|
||||||
|
//.depthAttachmentFormat = DEPTH_FORMAT
|
||||||
|
// Do not forget these whatever you do
|
||||||
|
};
|
||||||
|
|
||||||
|
const static VkPipelineColorBlendAttachmentState pipeline_default_blend_attach_state = {
|
||||||
|
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
|
||||||
|
.blendEnable = VK_FALSE,
|
||||||
|
};
|
||||||
|
|
||||||
|
const static VkPipelineColorBlendStateCreateInfo pipeline_default_blend_info = {
|
||||||
|
.sType = STYPE(PIPELINE_COLOR_BLEND_STATE_CREATE_INFO),
|
||||||
|
.logicOpEnable = VK_FALSE,
|
||||||
|
.logicOp = VK_LOGIC_OP_COPY,
|
||||||
|
.attachmentCount = 1,
|
||||||
|
.pAttachments = &pipeline_default_blend_attach_state,
|
||||||
|
};
|
||||||
|
|
||||||
|
const static VkPipelineVertexInputStateCreateInfo pipeline_default_vertex_info = {
|
||||||
|
.sType = STYPE(PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO),
|
||||||
|
};
|
||||||
|
|
||||||
|
const static VkPipelineViewportStateCreateInfo pipeline_default_viewport_info = {
|
||||||
|
.sType = STYPE(PIPELINE_VIEWPORT_STATE_CREATE_INFO),
|
||||||
|
.viewportCount = 1,
|
||||||
|
.scissorCount = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define INIT_PIPELINE_DEFAULTS(pipeline) \
|
||||||
|
static VkPipelineDynamicStateCreateInfo pipeline##_dynamic_info = pipeline_default_dyn_state_info; \
|
||||||
|
static VkPipelineInputAssemblyStateCreateInfo pipeline##_assembly_info = pipeline_default_assembly_info; \
|
||||||
|
static VkPipelineRasterizationStateCreateInfo pipeline##_rasterization_info = pipeline_default_rasterization_info; \
|
||||||
|
static VkPipelineMultisampleStateCreateInfo pipeline##_multisample_info = pipeline_default_multisample_info; \
|
||||||
|
static VkPipelineDepthStencilStateCreateInfo pipeline##_depth_info = pipeline_default_depth_info; \
|
||||||
|
static VkPipelineRenderingCreateInfo pipeline##_rendering_info = pipeline_default_rendering_info; \
|
||||||
|
static VkPipelineColorBlendStateCreateInfo pipeline##_blend_info = pipeline_default_blend_info; \
|
||||||
|
static VkPipelineVertexInputStateCreateInfo pipeline##_vertex_info = pipeline_default_vertex_info; \
|
||||||
|
static VkPipelineViewportStateCreateInfo pipeline##_viewport_info = pipeline_default_viewport_info; \
|
||||||
|
static VkGraphicsPipelineCreateInfo pipeline##_create_info = { \
|
||||||
|
.sType = STYPE(GRAPHICS_PIPELINE_CREATE_INFO), \
|
||||||
|
.pNext = &pipeline##_rendering_info, \
|
||||||
|
.pVertexInputState = &pipeline##_vertex_info, \
|
||||||
|
.pInputAssemblyState = &pipeline##_assembly_info, \
|
||||||
|
.pViewportState = &pipeline##_viewport_info, \
|
||||||
|
.pRasterizationState = &pipeline##_rasterization_info,\
|
||||||
|
.pMultisampleState = &pipeline##_multisample_info, \
|
||||||
|
.pColorBlendState = &pipeline##_blend_info, \
|
||||||
|
.pDepthStencilState = &pipeline##_depth_info, \
|
||||||
|
.pDynamicState = &pipeline##_dynamic_info, \
|
||||||
|
};
|
||||||
|
|
||||||
|
INIT_PIPELINE_DEFAULTS(cube);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user