mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
comp: Don't initialize unused fields in Vulkan structs.
In order to save redundancy with initializing empty fields with NULL / 0
values and improve readability of the Vulkan code.
This patch also uses struct initializers where possible.
This essentially reverts 1eae45212e
.
This commit is contained in:
parent
65d6ade6f3
commit
b6d8d4b458
|
@ -278,7 +278,6 @@ vk_create_image_from_fd(struct vk_bundle *vk,
|
||||||
|
|
||||||
VkExternalMemoryImageCreateInfoKHR external_memory_image_create_info = {
|
VkExternalMemoryImageCreateInfoKHR external_memory_image_create_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR,
|
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR,
|
||||||
.pNext = NULL,
|
|
||||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -304,7 +303,6 @@ vk_create_image_from_fd(struct vk_bundle *vk,
|
||||||
VkImageCreateInfo info = {
|
VkImageCreateInfo info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||||
.pNext = &external_memory_image_create_info,
|
.pNext = &external_memory_image_create_info,
|
||||||
.flags = 0,
|
|
||||||
.imageType = VK_IMAGE_TYPE_2D,
|
.imageType = VK_IMAGE_TYPE_2D,
|
||||||
.format = (VkFormat)format,
|
.format = (VkFormat)format,
|
||||||
.extent = {.width = width, .height = height, .depth = 1},
|
.extent = {.width = width, .height = height, .depth = 1},
|
||||||
|
@ -314,8 +312,6 @@ vk_create_image_from_fd(struct vk_bundle *vk,
|
||||||
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||||
.usage = image_usage,
|
.usage = image_usage,
|
||||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||||
.queueFamilyIndexCount = 0,
|
|
||||||
.pQueueFamilyIndices = NULL,
|
|
||||||
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -399,8 +395,6 @@ vk_create_view(struct vk_bundle *vk,
|
||||||
|
|
||||||
VkImageViewCreateInfo imageView = {
|
VkImageViewCreateInfo imageView = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.image = image,
|
.image = image,
|
||||||
.viewType = VK_IMAGE_VIEW_TYPE_2D,
|
.viewType = VK_IMAGE_VIEW_TYPE_2D,
|
||||||
.format = format,
|
.format = format,
|
||||||
|
@ -441,7 +435,6 @@ vk_init_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer *out_cmd_buffer)
|
||||||
// Allocate the command buffer.
|
// Allocate the command buffer.
|
||||||
VkCommandBufferAllocateInfo cmd_buffer_info = {
|
VkCommandBufferAllocateInfo cmd_buffer_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.commandPool = vk->cmd_pool,
|
.commandPool = vk->cmd_pool,
|
||||||
.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
|
.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
|
||||||
.commandBufferCount = 1,
|
.commandBufferCount = 1,
|
||||||
|
@ -459,9 +452,6 @@ vk_init_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer *out_cmd_buffer)
|
||||||
// Start the command buffer as well.
|
// Start the command buffer as well.
|
||||||
VkCommandBufferBeginInfo begin_info = {
|
VkCommandBufferBeginInfo begin_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
|
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.pInheritanceInfo = NULL,
|
|
||||||
};
|
};
|
||||||
ret = vk->vkBeginCommandBuffer(cmd_buffer, &begin_info);
|
ret = vk->vkBeginCommandBuffer(cmd_buffer, &begin_info);
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
|
@ -492,7 +482,6 @@ vk_set_image_layout(struct vk_bundle *vk,
|
||||||
{
|
{
|
||||||
VkImageMemoryBarrier barrier = {
|
VkImageMemoryBarrier barrier = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
.pNext = 0,
|
|
||||||
.srcAccessMask = src_access_mask,
|
.srcAccessMask = src_access_mask,
|
||||||
.dstAccessMask = dst_access_mask,
|
.dstAccessMask = dst_access_mask,
|
||||||
.oldLayout = old_layout,
|
.oldLayout = old_layout,
|
||||||
|
@ -518,19 +507,11 @@ vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer)
|
||||||
VkFence fence;
|
VkFence fence;
|
||||||
VkFenceCreateInfo fence_info = {
|
VkFenceCreateInfo fence_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
};
|
};
|
||||||
VkSubmitInfo submitInfo = {
|
VkSubmitInfo submitInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.waitSemaphoreCount = 0,
|
|
||||||
.pWaitSemaphores = NULL,
|
|
||||||
.pWaitDstStageMask = NULL,
|
|
||||||
.commandBufferCount = 1,
|
.commandBufferCount = 1,
|
||||||
.pCommandBuffers = &cmd_buffer,
|
.pCommandBuffers = &cmd_buffer,
|
||||||
.signalSemaphoreCount = 0,
|
|
||||||
.pSignalSemaphores = NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Finish the command buffer first.
|
// Finish the command buffer first.
|
||||||
|
@ -551,7 +532,6 @@ vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the actual submitting.
|
// Do the actual submitting.
|
||||||
|
|
||||||
ret = vk->vkQueueSubmit(queue, 1, &submitInfo, fence);
|
ret = vk->vkQueueSubmit(queue, 1, &submitInfo, fence);
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
VK_ERROR(vk, "Error: Could not submit queue.\n");
|
VK_ERROR(vk, "Error: Could not submit queue.\n");
|
||||||
|
@ -580,7 +560,6 @@ vk_init_cmd_pool(struct vk_bundle *vk)
|
||||||
{
|
{
|
||||||
VkCommandPoolCreateInfo cmd_pool_info = {
|
VkCommandPoolCreateInfo cmd_pool_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
|
.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
|
||||||
.queueFamilyIndex = vk->queue_family_index,
|
.queueFamilyIndex = vk->queue_family_index,
|
||||||
};
|
};
|
||||||
|
@ -651,10 +630,8 @@ vk_init_validation_callback(struct vk_bundle *vk)
|
||||||
|
|
||||||
VkDebugReportCallbackCreateInfoEXT info = {
|
VkDebugReportCallbackCreateInfoEXT info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT,
|
.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.pfnCallback = _validation_cb,
|
.pfnCallback = _validation_cb,
|
||||||
.pUserData = NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
vk->vkCreateDebugReportCallbackEXT(vk->instance, &info, NULL,
|
vk->vkCreateDebugReportCallbackEXT(vk->instance, &info, NULL,
|
||||||
|
@ -959,14 +936,10 @@ vk_create_device(struct vk_bundle *vk, int forced_index)
|
||||||
float queue_priority = 0.0f;
|
float queue_priority = 0.0f;
|
||||||
VkDeviceQueueCreateInfo queue_create_info = {
|
VkDeviceQueueCreateInfo queue_create_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.queueFamilyIndex = 0, // assigned valid value later
|
|
||||||
.queueCount = 1,
|
.queueCount = 1,
|
||||||
.pQueuePriorities = &queue_priority,
|
.pQueuePriorities = &queue_priority,
|
||||||
};
|
};
|
||||||
|
|
||||||
//! @todo why not vk->queue_family_index ?
|
|
||||||
ret = vk_find_graphics_queue(vk, &queue_create_info.queueFamilyIndex);
|
ret = vk_find_graphics_queue(vk, &queue_create_info.queueFamilyIndex);
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -987,12 +960,8 @@ vk_create_device(struct vk_bundle *vk, int forced_index)
|
||||||
|
|
||||||
VkDeviceCreateInfo device_create_info = {
|
VkDeviceCreateInfo device_create_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.queueCreateInfoCount = 1,
|
.queueCreateInfoCount = 1,
|
||||||
.pQueueCreateInfos = &queue_create_info,
|
.pQueueCreateInfos = &queue_create_info,
|
||||||
.enabledLayerCount = 0,
|
|
||||||
.ppEnabledLayerNames = NULL,
|
|
||||||
.enabledExtensionCount = ARRAY_SIZE(device_extensions),
|
.enabledExtensionCount = ARRAY_SIZE(device_extensions),
|
||||||
.ppEnabledExtensionNames = device_extensions,
|
.ppEnabledExtensionNames = device_extensions,
|
||||||
.pEnabledFeatures = enabled_features,
|
.pEnabledFeatures = enabled_features,
|
||||||
|
|
|
@ -414,11 +414,8 @@ create_instance(struct comp_compositor *c)
|
||||||
|
|
||||||
VkApplicationInfo app_info = {
|
VkApplicationInfo app_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.pApplicationName = "Collabora Compositor",
|
.pApplicationName = "Collabora Compositor",
|
||||||
.applicationVersion = 0,
|
|
||||||
.pEngineName = "Monado",
|
.pEngineName = "Monado",
|
||||||
.engineVersion = 0,
|
|
||||||
.apiVersion = VK_MAKE_VERSION(1, 0, 2),
|
.apiVersion = VK_MAKE_VERSION(1, 0, 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -432,11 +429,7 @@ create_instance(struct comp_compositor *c)
|
||||||
|
|
||||||
VkInstanceCreateInfo instance_info = {
|
VkInstanceCreateInfo instance_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.pApplicationInfo = &app_info,
|
.pApplicationInfo = &app_info,
|
||||||
.enabledLayerCount = 0,
|
|
||||||
.ppEnabledLayerNames = NULL,
|
|
||||||
.enabledExtensionCount = num_extensions,
|
.enabledExtensionCount = num_extensions,
|
||||||
.ppEnabledExtensionNames = instance_extensions,
|
.ppEnabledExtensionNames = instance_extensions,
|
||||||
};
|
};
|
||||||
|
@ -555,10 +548,6 @@ compositor_check_vulkan_caps(struct comp_compositor *c)
|
||||||
VkInstanceCreateInfo instance_create_info = {
|
VkInstanceCreateInfo instance_create_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
.pNext = NULL,
|
||||||
.flags = 0,
|
|
||||||
.pApplicationInfo = NULL,
|
|
||||||
.enabledLayerCount = 0,
|
|
||||||
.ppEnabledLayerNames = NULL,
|
|
||||||
.enabledExtensionCount = ARRAY_SIZE(extension_names),
|
.enabledExtensionCount = ARRAY_SIZE(extension_names),
|
||||||
.ppEnabledExtensionNames = extension_names,
|
.ppEnabledExtensionNames = extension_names,
|
||||||
};
|
};
|
||||||
|
|
|
@ -147,8 +147,6 @@ _shader_load(struct vk_bundle *vk,
|
||||||
|
|
||||||
VkShaderModuleCreateInfo info = {
|
VkShaderModuleCreateInfo info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.codeSize = size,
|
.codeSize = size,
|
||||||
.pCode = code,
|
.pCode = code,
|
||||||
};
|
};
|
||||||
|
@ -161,12 +159,9 @@ _shader_load(struct vk_bundle *vk,
|
||||||
|
|
||||||
return (VkPipelineShaderStageCreateInfo){
|
return (VkPipelineShaderStageCreateInfo){
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.stage = flags,
|
.stage = flags,
|
||||||
.module = module,
|
.module = module,
|
||||||
.pName = "main",
|
.pName = "main",
|
||||||
.pSpecializationInfo = NULL,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,101 +260,55 @@ comp_distortion_init_pipeline(struct comp_distortion *d,
|
||||||
VkPipelineInputAssemblyStateCreateInfo input_assembly_state = {
|
VkPipelineInputAssemblyStateCreateInfo input_assembly_state = {
|
||||||
.sType =
|
.sType =
|
||||||
VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.topology = topology,
|
.topology = topology,
|
||||||
.primitiveRestartEnable = VK_FALSE,
|
.primitiveRestartEnable = VK_FALSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
VkPipelineRasterizationStateCreateInfo rasterization_state = {
|
VkPipelineRasterizationStateCreateInfo rasterization_state = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.depthClampEnable = VK_FALSE,
|
.depthClampEnable = VK_FALSE,
|
||||||
.rasterizerDiscardEnable = VK_FALSE,
|
.rasterizerDiscardEnable = VK_FALSE,
|
||||||
.polygonMode = polygonMode,
|
.polygonMode = polygonMode,
|
||||||
.cullMode = VK_CULL_MODE_BACK_BIT,
|
.cullMode = VK_CULL_MODE_BACK_BIT,
|
||||||
.frontFace = VK_FRONT_FACE_CLOCKWISE,
|
.frontFace = VK_FRONT_FACE_CLOCKWISE,
|
||||||
.depthBiasEnable = VK_FALSE,
|
|
||||||
.depthBiasConstantFactor = 0.f,
|
|
||||||
.depthBiasClamp = 0.f,
|
|
||||||
.depthBiasSlopeFactor = 0.f,
|
|
||||||
.lineWidth = 1.0f,
|
.lineWidth = 1.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
VkPipelineColorBlendAttachmentState blend_attachment_state = {0};
|
VkPipelineColorBlendAttachmentState blend_attachment_state = {
|
||||||
blend_attachment_state.blendEnable = VK_FALSE;
|
.blendEnable = VK_FALSE,
|
||||||
blend_attachment_state.colorWriteMask = 0xf;
|
.colorWriteMask = 0xf,
|
||||||
|
};
|
||||||
|
|
||||||
VkPipelineColorBlendStateCreateInfo color_blend_state = {
|
VkPipelineColorBlendStateCreateInfo color_blend_state = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.logicOpEnable = VK_FALSE,
|
|
||||||
.logicOp = VK_LOGIC_OP_CLEAR,
|
|
||||||
.attachmentCount = 1,
|
.attachmentCount = 1,
|
||||||
.pAttachments = &blend_attachment_state,
|
.pAttachments = &blend_attachment_state,
|
||||||
//! @todo what's the right value for blendConstants?
|
|
||||||
.blendConstants = {1.f, 1.f, 1.f, 1.f},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VkPipelineDepthStencilStateCreateInfo depth_stencil_state = {
|
VkPipelineDepthStencilStateCreateInfo depth_stencil_state = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.depthTestEnable = VK_TRUE,
|
.depthTestEnable = VK_TRUE,
|
||||||
.depthWriteEnable = VK_TRUE,
|
.depthWriteEnable = VK_TRUE,
|
||||||
.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL,
|
.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL,
|
||||||
.depthBoundsTestEnable = VK_FALSE,
|
|
||||||
.stencilTestEnable = VK_FALSE,
|
|
||||||
.front =
|
.front =
|
||||||
{
|
{
|
||||||
.failOp = VK_STENCIL_OP_KEEP,
|
.compareOp = VK_COMPARE_OP_ALWAYS,
|
||||||
.passOp = VK_STENCIL_OP_KEEP,
|
|
||||||
.depthFailOp = VK_STENCIL_OP_KEEP,
|
|
||||||
.compareOp = VK_COMPARE_OP_ALWAYS, // this is the only
|
|
||||||
// meaningful value here.
|
|
||||||
.compareMask = 0,
|
|
||||||
.writeMask = 0,
|
|
||||||
.reference = 0,
|
|
||||||
},
|
},
|
||||||
.back =
|
.back =
|
||||||
{
|
{
|
||||||
.failOp = VK_STENCIL_OP_KEEP,
|
.compareOp = VK_COMPARE_OP_ALWAYS,
|
||||||
.passOp = VK_STENCIL_OP_KEEP,
|
|
||||||
.depthFailOp = VK_STENCIL_OP_KEEP,
|
|
||||||
.compareOp = VK_COMPARE_OP_ALWAYS, // this is the only
|
|
||||||
// meaningful value here.
|
|
||||||
.compareMask = 0,
|
|
||||||
.writeMask = 0,
|
|
||||||
.reference = 0,
|
|
||||||
},
|
},
|
||||||
.minDepthBounds = 0.f,
|
|
||||||
.maxDepthBounds = 0.f,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VkPipelineViewportStateCreateInfo viewport_state = {
|
VkPipelineViewportStateCreateInfo viewport_state = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.viewportCount = 1,
|
.viewportCount = 1,
|
||||||
.pViewports = NULL, // assigned valid value later
|
|
||||||
.scissorCount = 1,
|
.scissorCount = 1,
|
||||||
.pScissors = NULL, // assigned valid value later
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VkPipelineMultisampleStateCreateInfo multisample_state = {
|
VkPipelineMultisampleStateCreateInfo multisample_state = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT};
|
||||||
.flags = 0,
|
|
||||||
.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT,
|
|
||||||
.sampleShadingEnable = VK_FALSE,
|
|
||||||
.minSampleShading = 0,
|
|
||||||
.pSampleMask = NULL,
|
|
||||||
.alphaToCoverageEnable = VK_FALSE,
|
|
||||||
.alphaToOneEnable = VK_FALSE,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
VkDynamicState dynamic_states[] = {
|
VkDynamicState dynamic_states[] = {
|
||||||
VK_DYNAMIC_STATE_VIEWPORT,
|
VK_DYNAMIC_STATE_VIEWPORT,
|
||||||
|
@ -368,8 +317,6 @@ comp_distortion_init_pipeline(struct comp_distortion *d,
|
||||||
|
|
||||||
VkPipelineDynamicStateCreateInfo dynamic_state = {
|
VkPipelineDynamicStateCreateInfo dynamic_state = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.dynamicStateCount = 2,
|
.dynamicStateCount = 2,
|
||||||
.pDynamicStates = dynamic_states,
|
.pDynamicStates = dynamic_states,
|
||||||
};
|
};
|
||||||
|
@ -388,12 +335,6 @@ comp_distortion_init_pipeline(struct comp_distortion *d,
|
||||||
*/
|
*/
|
||||||
VkPipelineVertexInputStateCreateInfo vertex_input_state = {
|
VkPipelineVertexInputStateCreateInfo vertex_input_state = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.vertexBindingDescriptionCount = 0,
|
|
||||||
.pVertexBindingDescriptions = NULL,
|
|
||||||
.vertexAttributeDescriptionCount = 0,
|
|
||||||
.pVertexAttributeDescriptions = NULL,
|
|
||||||
};
|
};
|
||||||
const uint32_t *vertex_shader_code = shaders_distortion_vert;
|
const uint32_t *vertex_shader_code = shaders_distortion_vert;
|
||||||
size_t vertex_shader_size = sizeof(shaders_distortion_vert);
|
size_t vertex_shader_size = sizeof(shaders_distortion_vert);
|
||||||
|
@ -451,17 +392,13 @@ comp_distortion_init_pipeline(struct comp_distortion *d,
|
||||||
VK_SHADER_STAGE_FRAGMENT_BIT),
|
VK_SHADER_STAGE_FRAGMENT_BIT),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo pipeline_info = {
|
VkGraphicsPipelineCreateInfo pipeline_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.stageCount = ARRAY_SIZE(shader_stages),
|
.stageCount = ARRAY_SIZE(shader_stages),
|
||||||
.pStages = shader_stages,
|
.pStages = shader_stages,
|
||||||
.pVertexInputState = &vertex_input_state,
|
.pVertexInputState = &vertex_input_state,
|
||||||
.pInputAssemblyState = &input_assembly_state,
|
.pInputAssemblyState = &input_assembly_state,
|
||||||
.pTessellationState = NULL,
|
|
||||||
.pViewportState = &viewport_state,
|
.pViewportState = &viewport_state,
|
||||||
.pRasterizationState = &rasterization_state,
|
.pRasterizationState = &rasterization_state,
|
||||||
.pMultisampleState = &multisample_state,
|
.pMultisampleState = &multisample_state,
|
||||||
|
@ -470,7 +407,6 @@ comp_distortion_init_pipeline(struct comp_distortion *d,
|
||||||
.pDynamicState = &dynamic_state,
|
.pDynamicState = &dynamic_state,
|
||||||
.layout = d->pipeline_layout,
|
.layout = d->pipeline_layout,
|
||||||
.renderPass = render_pass,
|
.renderPass = render_pass,
|
||||||
.subpass = 0, //! @todo
|
|
||||||
.basePipelineHandle = VK_NULL_HANDLE,
|
.basePipelineHandle = VK_NULL_HANDLE,
|
||||||
.basePipelineIndex = -1,
|
.basePipelineIndex = -1,
|
||||||
};
|
};
|
||||||
|
@ -492,15 +428,11 @@ comp_distortion_get_uniform_write_descriptor_set(struct comp_distortion *d,
|
||||||
{
|
{
|
||||||
return (VkWriteDescriptorSet){
|
return (VkWriteDescriptorSet){
|
||||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
.pNext = NULL,
|
|
||||||
.dstSet = d->descriptor_sets[eye],
|
.dstSet = d->descriptor_sets[eye],
|
||||||
.dstBinding = binding,
|
.dstBinding = binding,
|
||||||
.dstArrayElement = 0, //! @todo
|
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||||
.pImageInfo = NULL,
|
|
||||||
.pBufferInfo = &d->ubo_handle.descriptor,
|
.pBufferInfo = &d->ubo_handle.descriptor,
|
||||||
.pTexelBufferView = NULL,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,15 +443,11 @@ comp_distortion_get_uniform_write_descriptor_set_vp(struct comp_distortion *d,
|
||||||
{
|
{
|
||||||
return (VkWriteDescriptorSet){
|
return (VkWriteDescriptorSet){
|
||||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
.pNext = NULL,
|
|
||||||
.dstSet = d->descriptor_sets[eye],
|
.dstSet = d->descriptor_sets[eye],
|
||||||
.dstBinding = binding,
|
.dstBinding = binding,
|
||||||
.dstArrayElement = 0, //! @todo
|
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||||
.pImageInfo = NULL,
|
|
||||||
.pBufferInfo = &d->ubo_viewport_handles[eye].descriptor,
|
.pBufferInfo = &d->ubo_viewport_handles[eye].descriptor,
|
||||||
.pTexelBufferView = NULL,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,15 +459,11 @@ comp_distortion_get_image_write_descriptor_set(
|
||||||
{
|
{
|
||||||
return (VkWriteDescriptorSet){
|
return (VkWriteDescriptorSet){
|
||||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
.pNext = NULL,
|
|
||||||
.dstSet = descriptor_set,
|
.dstSet = descriptor_set,
|
||||||
.dstBinding = binding,
|
.dstBinding = binding,
|
||||||
.dstArrayElement = 0, //! @todo
|
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||||
.pImageInfo = descriptor_position,
|
.pImageInfo = descriptor_position,
|
||||||
.pBufferInfo = NULL,
|
|
||||||
.pTexelBufferView = NULL,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +476,6 @@ comp_distortion_init_descriptor_sets(struct comp_distortion *d,
|
||||||
|
|
||||||
VkDescriptorSetAllocateInfo alloc_info = {
|
VkDescriptorSetAllocateInfo alloc_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.descriptorPool = descriptor_pool,
|
.descriptorPool = descriptor_pool,
|
||||||
.descriptorSetCount = 1,
|
.descriptorSetCount = 1,
|
||||||
.pSetLayouts = &d->descriptor_set_layout,
|
.pSetLayouts = &d->descriptor_set_layout,
|
||||||
|
@ -621,7 +544,6 @@ comp_distortion_init_descriptor_set_layout(struct comp_distortion *d)
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||||
.pImmutableSamplers = NULL,
|
|
||||||
},
|
},
|
||||||
// Binding 1 : Fragment shader uniform buffer
|
// Binding 1 : Fragment shader uniform buffer
|
||||||
{
|
{
|
||||||
|
@ -629,7 +551,6 @@ comp_distortion_init_descriptor_set_layout(struct comp_distortion *d)
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||||
.pImmutableSamplers = NULL,
|
|
||||||
},
|
},
|
||||||
// binding 2: viewport index
|
// binding 2: viewport index
|
||||||
{
|
{
|
||||||
|
@ -637,14 +558,11 @@ comp_distortion_init_descriptor_set_layout(struct comp_distortion *d)
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 1,
|
||||||
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
|
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
|
||||||
.pImmutableSamplers = NULL,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo set_layout_info = {
|
VkDescriptorSetLayoutCreateInfo set_layout_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.bindingCount = ARRAY_SIZE(set_layout_bindings),
|
.bindingCount = ARRAY_SIZE(set_layout_bindings),
|
||||||
.pBindings = set_layout_bindings,
|
.pBindings = set_layout_bindings,
|
||||||
};
|
};
|
||||||
|
@ -664,12 +582,9 @@ comp_distortion_init_pipeline_layout(struct comp_distortion *d)
|
||||||
|
|
||||||
VkPipelineLayoutCreateInfo pipeline_layout_info = {
|
VkPipelineLayoutCreateInfo pipeline_layout_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.setLayoutCount = 1,
|
.setLayoutCount = 1,
|
||||||
.pSetLayouts = &d->descriptor_set_layout,
|
.pSetLayouts = &d->descriptor_set_layout,
|
||||||
.pushConstantRangeCount = 0,
|
};
|
||||||
.pPushConstantRanges = NULL};
|
|
||||||
|
|
||||||
ret = vk->vkCreatePipelineLayout(d->vk->device, &pipeline_layout_info,
|
ret = vk->vkCreatePipelineLayout(d->vk->device, &pipeline_layout_info,
|
||||||
NULL, &d->pipeline_layout);
|
NULL, &d->pipeline_layout);
|
||||||
|
@ -811,13 +726,8 @@ _create_buffer(struct vk_bundle *vk,
|
||||||
// Create the buffer handle.
|
// Create the buffer handle.
|
||||||
VkBufferCreateInfo buffer_info = {
|
VkBufferCreateInfo buffer_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.size = size,
|
.size = size,
|
||||||
.usage = usage_flags,
|
.usage = usage_flags,
|
||||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
|
||||||
.queueFamilyIndexCount = 0,
|
|
||||||
.pQueueFamilyIndices = NULL,
|
|
||||||
};
|
};
|
||||||
ret =
|
ret =
|
||||||
vk->vkCreateBuffer(vk->device, &buffer_info, NULL, &buffer->buffer);
|
vk->vkCreateBuffer(vk->device, &buffer_info, NULL, &buffer->buffer);
|
||||||
|
@ -838,7 +748,6 @@ _create_buffer(struct vk_bundle *vk,
|
||||||
|
|
||||||
VkMemoryAllocateInfo mem_alloc = {
|
VkMemoryAllocateInfo mem_alloc = {
|
||||||
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||||
.pNext = NULL,
|
|
||||||
.allocationSize = mem_reqs.size,
|
.allocationSize = mem_reqs.size,
|
||||||
.memoryTypeIndex = memory_type_index,
|
.memoryTypeIndex = memory_type_index,
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,7 +70,6 @@ get_device_memory_fd(struct comp_compositor *c,
|
||||||
// vkGetMemoryFdKHR parameter
|
// vkGetMemoryFdKHR parameter
|
||||||
VkMemoryGetFdInfoKHR fd_info = {
|
VkMemoryGetFdInfoKHR fd_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR,
|
.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR,
|
||||||
.pNext = NULL,
|
|
||||||
.memory = device_memory,
|
.memory = device_memory,
|
||||||
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
||||||
};
|
};
|
||||||
|
@ -114,7 +113,6 @@ create_image_fd(struct comp_compositor *c,
|
||||||
|
|
||||||
VkExternalMemoryImageCreateInfoKHR external_memory_image_create_info = {
|
VkExternalMemoryImageCreateInfoKHR external_memory_image_create_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR,
|
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR,
|
||||||
.pNext = NULL,
|
|
||||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,7 +138,6 @@ create_image_fd(struct comp_compositor *c,
|
||||||
VkImageCreateInfo info = {
|
VkImageCreateInfo info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||||
.pNext = &external_memory_image_create_info,
|
.pNext = &external_memory_image_create_info,
|
||||||
.flags = 0,
|
|
||||||
.imageType = VK_IMAGE_TYPE_2D,
|
.imageType = VK_IMAGE_TYPE_2D,
|
||||||
.format = (VkFormat)format,
|
.format = (VkFormat)format,
|
||||||
.extent = {.width = width, .height = height, .depth = 1},
|
.extent = {.width = width, .height = height, .depth = 1},
|
||||||
|
@ -150,8 +147,6 @@ create_image_fd(struct comp_compositor *c,
|
||||||
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||||
.usage = image_usage,
|
.usage = image_usage,
|
||||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||||
.queueFamilyIndexCount = 0,
|
|
||||||
.pQueueFamilyIndices = NULL,
|
|
||||||
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -154,8 +154,6 @@ vk_swapchain_create(struct vk_swapchain *sc,
|
||||||
|
|
||||||
VkSwapchainCreateInfoKHR swap_chain_info = {
|
VkSwapchainCreateInfoKHR swap_chain_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
|
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.surface = sc->surface,
|
.surface = sc->surface,
|
||||||
.minImageCount = surface_caps.minImageCount,
|
.minImageCount = surface_caps.minImageCount,
|
||||||
.imageFormat = sc->surface_format.format,
|
.imageFormat = sc->surface_format.format,
|
||||||
|
@ -169,7 +167,6 @@ vk_swapchain_create(struct vk_swapchain *sc,
|
||||||
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||||
.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||||
.queueFamilyIndexCount = 0,
|
.queueFamilyIndexCount = 0,
|
||||||
.pQueueFamilyIndices = NULL,
|
|
||||||
.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR,
|
.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR,
|
||||||
.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
|
.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
|
||||||
.presentMode = sc->present_mode,
|
.presentMode = sc->present_mode,
|
||||||
|
@ -249,13 +246,11 @@ vk_swapchain_present(struct vk_swapchain *sc,
|
||||||
{
|
{
|
||||||
VkPresentInfoKHR presentInfo = {
|
VkPresentInfoKHR presentInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
||||||
.pNext = NULL,
|
|
||||||
.waitSemaphoreCount = 1,
|
.waitSemaphoreCount = 1,
|
||||||
.pWaitSemaphores = &semaphore,
|
.pWaitSemaphores = &semaphore,
|
||||||
.swapchainCount = 1,
|
.swapchainCount = 1,
|
||||||
.pSwapchains = &sc->swap_chain,
|
.pSwapchains = &sc->swap_chain,
|
||||||
.pImageIndices = &index,
|
.pImageIndices = &index,
|
||||||
.pResults = NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return sc->vk->vkQueuePresentKHR(queue, &presentInfo);
|
return sc->vk->vkQueuePresentKHR(queue, &presentInfo);
|
||||||
|
|
Loading…
Reference in a new issue