|
|
|
@ -8,49 +8,11 @@ VkResult create_hex_context(
|
|
|
|
|
RenderContext* gpu,
|
|
|
|
|
HexContext* context) {
|
|
|
|
|
VkResult result;
|
|
|
|
|
|
|
|
|
|
// Compute Pipeline
|
|
|
|
|
|
|
|
|
|
VkShaderModule compute_shader = load_shader_file("shader/hex.comp.spv", gpu->device);
|
|
|
|
|
if(compute_shader == VK_NULL_HANDLE) {
|
|
|
|
|
return VK_ERROR_UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VkPipelineShaderStageCreateInfo compute_shader_stage = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
|
|
|
|
.stage = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
|
|
|
.pName = "main",
|
|
|
|
|
.module = compute_shader,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VkPushConstantRange compute_push = {
|
|
|
|
|
.size = sizeof(HexPushConstant),
|
|
|
|
|
.offset = 0,
|
|
|
|
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VkPipelineLayoutCreateInfo compute_layout_info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
|
|
|
|
.pPushConstantRanges = &compute_push,
|
|
|
|
|
.pushConstantRangeCount = 1,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VK_RESULT(vkCreatePipelineLayout(gpu->device, &compute_layout_info, NULL, &context->compute.layout));
|
|
|
|
|
|
|
|
|
|
VkComputePipelineCreateInfo compute_pipeline_info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
|
|
|
|
|
.stage = compute_shader_stage,
|
|
|
|
|
.layout = context->compute.layout,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VK_RESULT(vkCreateComputePipelines(gpu->device, VK_NULL_HANDLE, 1, &compute_pipeline_info, NULL, &context->compute.pipeline));
|
|
|
|
|
|
|
|
|
|
// Graphics Pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkShaderModule vert_shader = load_shader_file("shader/hex.vert.spv", gpu->device);
|
|
|
|
|
VkShaderModule frag_shader = load_shader_file("shader/hex.frag.spv", gpu->device);
|
|
|
|
|
|
|
|
|
|
VkPipelineShaderStageCreateInfo graphics_stages[] = {
|
|
|
|
|
VkPipelineShaderStageCreateInfo stages[] = {
|
|
|
|
|
{
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
|
|
|
|
.stage = VK_SHADER_STAGE_VERTEX_BIT,
|
|
|
|
@ -65,19 +27,19 @@ VkResult create_hex_context(
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VkPushConstantRange graphics_push = {
|
|
|
|
|
VkPushConstantRange push = {
|
|
|
|
|
.size = sizeof(HexPushConstant),
|
|
|
|
|
.offset = 0,
|
|
|
|
|
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VkPipelineLayoutCreateInfo graphics_layout_info = {
|
|
|
|
|
VkPipelineLayoutCreateInfo layout_info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
|
|
|
|
.pPushConstantRanges = &graphics_push,
|
|
|
|
|
.pPushConstantRanges = &push,
|
|
|
|
|
.pushConstantRangeCount = 1,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VK_RESULT(vkCreatePipelineLayout(gpu->device, &graphics_layout_info, NULL, &context->graphics.layout));
|
|
|
|
|
VK_RESULT(vkCreatePipelineLayout(gpu->device, &layout_info, NULL, &context->graphics.layout));
|
|
|
|
|
|
|
|
|
|
VkPipelineVertexInputStateCreateInfo vertex_info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
|
|
|
@ -177,8 +139,8 @@ VkResult create_hex_context(
|
|
|
|
|
VkGraphicsPipelineCreateInfo graphics_pipeline_info = {
|
|
|
|
|
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
|
|
|
|
|
.layout = context->graphics.layout,
|
|
|
|
|
.stageCount = sizeof(graphics_stages)/sizeof(VkPipelineShaderStageCreateInfo),
|
|
|
|
|
.pStages = graphics_stages,
|
|
|
|
|
.stageCount = sizeof(stages)/sizeof(VkPipelineShaderStageCreateInfo),
|
|
|
|
|
.pStages = stages,
|
|
|
|
|
.pVertexInputState = &vertex_info,
|
|
|
|
|
.pInputAssemblyState = &input_info,
|
|
|
|
|
.pViewportState = &viewport_info,
|
|
|
|
|