zink: zero-init structs with ISO C
authorHoe Hao Cheng <haochengho12907@gmail.com>
Tue, 15 Jun 2021 10:51:44 +0000 (18:51 +0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 15 Jun 2021 12:33:03 +0000 (12:33 +0000)
zero-initing with empty braces is a GNU extension, MSVC does not like
it.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11376>

19 files changed:
src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
src/gallium/drivers/zink/zink_batch.c
src/gallium/drivers/zink/zink_blit.c
src/gallium/drivers/zink/zink_clear.c
src/gallium/drivers/zink/zink_compiler.c
src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_descriptors.c
src/gallium/drivers/zink/zink_descriptors_lazy.c
src/gallium/drivers/zink/zink_device_info.py
src/gallium/drivers/zink/zink_draw.c
src/gallium/drivers/zink/zink_framebuffer.c
src/gallium/drivers/zink/zink_instance.py
src/gallium/drivers/zink/zink_pipeline.c
src/gallium/drivers/zink/zink_program.c
src/gallium/drivers/zink/zink_query.c
src/gallium/drivers/zink/zink_render_pass.c
src/gallium/drivers/zink/zink_resource.c
src/gallium/drivers/zink/zink_screen.c
src/gallium/drivers/zink/zink_surface.c

index 5846dfa..c3d9dd0 100644 (file)
@@ -3567,7 +3567,7 @@ nir_to_spirv(struct nir_shader *s, const struct zink_so_info *so_info, uint32_t
 {
    struct spirv_shader *ret = NULL;
 
-   struct ntv_context ctx = {};
+   struct ntv_context ctx = {0};
    ctx.mem_ctx = ralloc_context(NULL);
    ctx.builder.mem_ctx = ctx.mem_ctx;
    assert(spirv_version >= SPIRV_VERSION(1, 0));
index d81d295..03833cb 100644 (file)
@@ -152,14 +152,14 @@ create_batch_state(struct zink_context *ctx)
    struct zink_screen *screen = zink_screen(ctx->base.screen);
    struct zink_batch_state *bs = rzalloc(NULL, struct zink_batch_state);
    bs->have_timelines = ctx->have_timelines;
-   VkCommandPoolCreateInfo cpci = {};
+   VkCommandPoolCreateInfo cpci = {0};
    cpci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
    cpci.queueFamilyIndex = screen->gfx_queue;
    cpci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
    if (vkCreateCommandPool(screen->dev, &cpci, NULL, &bs->cmdpool) != VK_SUCCESS)
       goto fail;
 
-   VkCommandBufferAllocateInfo cbai = {};
+   VkCommandBufferAllocateInfo cbai = {0};
    cbai.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
    cbai.commandPool = bs->cmdpool;
    cbai.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
@@ -191,7 +191,7 @@ create_batch_state(struct zink_context *ctx)
    if (!screen->batch_descriptor_init(screen, bs))
       goto fail;
 
-   VkFenceCreateInfo fci = {};
+   VkFenceCreateInfo fci = {0};
    fci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
 
    if (vkCreateFence(screen->dev, &fci, NULL, &bs->fence.fence) != VK_SUCCESS)
@@ -276,7 +276,7 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
 {
    zink_reset_batch(ctx, batch);
 
-   VkCommandBufferBeginInfo cbbi = {};
+   VkCommandBufferBeginInfo cbbi = {0};
    cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
    cbbi.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
    if (vkBeginCommandBuffer(batch->state->cmdbuf, &cbbi) != VK_SUCCESS)
@@ -313,7 +313,7 @@ static void
 submit_queue(void *data, int thread_index)
 {
    struct zink_batch_state *bs = data;
-   VkSubmitInfo si = {};
+   VkSubmitInfo si = {0};
    uint64_t batch_id = bs->fence.batch_id;
    si.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
    si.waitSemaphoreCount = 0;
@@ -328,7 +328,7 @@ submit_queue(void *data, int thread_index)
    };
    si.pCommandBuffers = bs->has_barriers ? cmdbufs : &cmdbufs[1];
 
-   VkTimelineSemaphoreSubmitInfo tsi = {};
+   VkTimelineSemaphoreSubmitInfo tsi = {0};
    if (bs->have_timelines) {
       tsi.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO;
       si.pNext = &tsi;
@@ -360,7 +360,7 @@ submit_queue(void *data, int thread_index)
 static void
 copy_scanout(struct zink_context *ctx, struct zink_resource *res)
 {
-   VkImageCopy region = {};
+   VkImageCopy region = {0};
    struct pipe_box box = {0, 0, 0,
                           u_minify(res->base.b.width0, 0),
                           u_minify(res->base.b.height0, 0), res->base.b.array_size};
index d565a4c..45a9cb6 100644 (file)
@@ -58,7 +58,7 @@ blit_resolve(struct zink_context *ctx, const struct pipe_blit_info *info)
 
    zink_resource_setup_transfer_layouts(ctx, src, dst);
 
-   VkImageResolve region = {};
+   VkImageResolve region = {0};
 
    region.srcSubresource.aspectMask = src->aspect;
    region.srcSubresource.mipLevel = info->src.level;
@@ -164,7 +164,7 @@ blit_native(struct zink_context *ctx, const struct pipe_blit_info *info)
    if (info->dst.resource->target == PIPE_BUFFER)
       util_range_add(info->dst.resource, &dst->valid_buffer_range,
                      info->dst.box.x, info->dst.box.x + info->dst.box.width);
-   VkImageBlit region = {};
+   VkImageBlit region = {0};
    region.srcSubresource.aspectMask = src->aspect;
    region.srcSubresource.mipLevel = info->src.level;
    region.srcOffsets[0].x = info->src.box.x;
index 416693f..3594396 100644 (file)
@@ -103,7 +103,7 @@ clear_in_rp(struct pipe_context *pctx,
       ++num_attachments;
    }
 
-   VkClearRect cr = {};
+   VkClearRect cr = {0};
    if (scissor_state) {
       cr.rect.offset.x = scissor_state->minx;
       cr.rect.offset.y = scissor_state->miny;
@@ -123,7 +123,7 @@ static void
 clear_color_no_rp(struct zink_context *ctx, struct zink_resource *res, const union pipe_color_union *pcolor, unsigned level, unsigned layer, unsigned layerCount)
 {
    struct zink_batch *batch = zink_batch_no_rp(ctx);
-   VkImageSubresourceRange range = {};
+   VkImageSubresourceRange range = {0};
    range.baseMipLevel = level;
    range.levelCount = 1;
    range.baseArrayLayer = layer;
@@ -147,7 +147,7 @@ static void
 clear_zs_no_rp(struct zink_context *ctx, struct zink_resource *res, VkImageAspectFlags aspects, double depth, unsigned stencil, unsigned level, unsigned layer, unsigned layerCount)
 {
    struct zink_batch *batch = zink_batch_no_rp(ctx);
-   VkImageSubresourceRange range = {};
+   VkImageSubresourceRange range = {0};
    range.baseMipLevel = level;
    range.levelCount = 1;
    range.baseArrayLayer = layer;
@@ -177,7 +177,7 @@ get_clear_data(struct zink_context *ctx, struct zink_framebuffer_clear *fb_clear
          clear = last_clear;
    }
    if (!clear) {
-      struct zink_framebuffer_clear_data cd = {};
+      struct zink_framebuffer_clear_data cd = {0};
       util_dynarray_append(&fb_clear->clears, struct zink_framebuffer_clear_data, cd);
       clear = zink_fb_clear_element(fb_clear, zink_fb_clear_count(fb_clear) - 1);
    }
index 5fff56d..5dea261 100644 (file)
@@ -476,7 +476,7 @@ static void
 update_so_info(struct zink_shader *zs, const struct pipe_stream_output_info *so_info,
                uint64_t outputs_written, bool have_psiz)
 {
-   uint8_t reverse_map[64] = {};
+   uint8_t reverse_map[64] = {0};
    unsigned slot = 0;
    /* semi-copied from iris */
    while (outputs_written) {
@@ -658,7 +658,7 @@ zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, struct z
       }
    }
 
-   VkShaderModuleCreateInfo smci = {};
+   VkShaderModuleCreateInfo smci = {0};
    smci.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
    smci.codeSize = spirv->num_words * sizeof(uint32_t);
    smci.pCode = spirv->words;
@@ -979,7 +979,7 @@ zink_shader_finalize(struct pipe_screen *pscreen, void *nirptr, bool optimize)
    nir_shader *nir = nirptr;
 
    if (!screen->info.feats.features.shaderImageGatherExtended) {
-      nir_lower_tex_options tex_opts = {};
+      nir_lower_tex_options tex_opts = {0};
       tex_opts.lower_tg4_offsets = true;
       NIR_PASS_V(nir, nir_lower_tex, &tex_opts);
    }
index f4b9706..6d8d379 100644 (file)
@@ -282,8 +282,8 @@ zink_create_sampler_state(struct pipe_context *pctx,
    struct zink_screen *screen = zink_screen(pctx->screen);
    bool need_custom = false;
 
-   VkSamplerCreateInfo sci = {};
-   VkSamplerCustomBorderColorCreateInfoEXT cbci = {};
+   VkSamplerCreateInfo sci = {0};
+   VkSamplerCustomBorderColorCreateInfoEXT cbci = {0};
    sci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
    sci.magFilter = zink_filter(state->mag_img_filter);
    sci.minFilter = zink_filter(state->min_img_filter);
@@ -593,7 +593,7 @@ get_buffer_view(struct zink_context *ctx, struct zink_resource *res, enum pipe_f
 {
    struct zink_screen *screen = zink_screen(ctx->base.screen);
    struct zink_buffer_view *buffer_view = NULL;
-   VkBufferViewCreateInfo bvci = {};
+   VkBufferViewCreateInfo bvci = {0};
    bvci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
    bvci.buffer = res->obj->buffer;
    bvci.format = zink_get_format(screen, format);
@@ -675,7 +675,7 @@ zink_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *pres,
    if (state->target != PIPE_BUFFER) {
       VkImageViewCreateInfo ivci;
 
-      struct pipe_surface templ = {};
+      struct pipe_surface templ = {0};
       templ.u.tex.level = state->u.tex.first_level;
       templ.format = state->format;
       if (state->target != PIPE_TEXTURE_3D) {
@@ -1208,7 +1208,7 @@ zink_set_shader_images(struct pipe_context *pctx,
             zink_resource_buffer_barrier(ctx, NULL, res, access,
                                          zink_pipeline_flags_from_stage(zink_shader_stage(p_stage)));
          } else {
-            struct pipe_surface tmpl = {};
+            struct pipe_surface tmpl = {0};
             tmpl.format = images[i].format;
             tmpl.nr_samples = 1;
             tmpl.u.tex.level = images[i].u.tex.level;
@@ -1469,9 +1469,9 @@ static struct zink_framebuffer *
 get_framebuffer(struct zink_context *ctx)
 {
    struct zink_screen *screen = zink_screen(ctx->base.screen);
-   struct pipe_surface *attachments[PIPE_MAX_COLOR_BUFS + 1] = {};
+   struct pipe_surface *attachments[PIPE_MAX_COLOR_BUFS + 1] = {0};
 
-   struct zink_framebuffer_state state = {};
+   struct zink_framebuffer_state state = {0};
    for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
       struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
       state.attachments[i] = psurf ? zink_surface(psurf)->image_view : VK_NULL_HANDLE;
@@ -1560,7 +1560,7 @@ begin_render_pass(struct zink_context *ctx)
    struct zink_batch *batch = &ctx->batch;
    struct pipe_framebuffer_state *fb_state = &ctx->fb_state;
 
-   VkRenderPassBeginInfo rpbi = {};
+   VkRenderPassBeginInfo rpbi = {0};
    rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
    rpbi.renderPass = ctx->gfx_pipeline_state.render_pass->render_pass;
    rpbi.renderArea.offset.x = 0;
@@ -1568,7 +1568,7 @@ begin_render_pass(struct zink_context *ctx)
    rpbi.renderArea.extent.width = fb_state->width;
    rpbi.renderArea.extent.height = fb_state->height;
 
-   VkClearValue clears[PIPE_MAX_COLOR_BUFS + 1] = {};
+   VkClearValue clears[PIPE_MAX_COLOR_BUFS + 1] = {0};
    unsigned clear_buffers = 0;
    uint32_t clear_validate = 0;
    for (int i = 0; i < fb_state->nr_cbufs; i++) {
@@ -2759,7 +2759,7 @@ zink_copy_image_buffer(struct zink_context *ctx, struct zink_batch *batch, struc
       util_range_add(&dst->base.b, &dst->valid_buffer_range, dstx, dstx + src_box->width);
    }
 
-   VkBufferImageCopy region = {};
+   VkBufferImageCopy region = {0};
    region.bufferOffset = buf2img ? src_box->x : dstx;
    region.bufferRowLength = 0;
    region.bufferImageHeight = 0;
@@ -2842,7 +2842,7 @@ zink_resource_copy_region(struct pipe_context *pctx,
    struct zink_resource *src = zink_resource(psrc);
    struct zink_context *ctx = zink_context(pctx);
    if (dst->base.b.target != PIPE_BUFFER && src->base.b.target != PIPE_BUFFER) {
-      VkImageCopy region = {};
+      VkImageCopy region = {0};
       if (util_format_get_num_planes(src->base.b.format) == 1 &&
           util_format_get_num_planes(dst->base.b.format) == 1) {
       /* If neither the calling command’s srcImage nor the calling command’s dstImage
index 3999739..617c192 100644 (file)
@@ -252,7 +252,7 @@ descriptor_pool_create(struct zink_screen *screen, enum zink_descriptor_type typ
 
    util_dynarray_init(&pool->alloc_desc_sets, NULL);
 
-   VkDescriptorPoolCreateInfo dpci = {};
+   VkDescriptorPoolCreateInfo dpci = {0};
    dpci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
    dpci.pPoolSizes = sizes;
    dpci.poolSizeCount = num_type_sizes;
@@ -273,10 +273,10 @@ static VkDescriptorSetLayout
 descriptor_layout_create(struct zink_screen *screen, enum zink_descriptor_type t, VkDescriptorSetLayoutBinding *bindings, unsigned num_bindings)
 {
    VkDescriptorSetLayout dsl;
-   VkDescriptorSetLayoutCreateInfo dcslci = {};
+   VkDescriptorSetLayoutCreateInfo dcslci = {0};
    dcslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
    dcslci.pNext = NULL;
-   VkDescriptorSetLayoutBindingFlagsCreateInfo fci = {};
+   VkDescriptorSetLayoutBindingFlagsCreateInfo fci = {0};
    VkDescriptorBindingFlags flags[num_bindings];
    if (screen->lazy_descriptors) {
       /* FIXME */
@@ -754,9 +754,9 @@ bool
 zink_descriptor_program_init(struct zink_context *ctx, struct zink_program *pg)
 {
    VkDescriptorSetLayoutBinding bindings[ZINK_DESCRIPTOR_TYPES][PIPE_SHADER_TYPES * 32];
-   unsigned num_bindings[ZINK_DESCRIPTOR_TYPES] = {};
+   unsigned num_bindings[ZINK_DESCRIPTOR_TYPES] = {0};
 
-   VkDescriptorPoolSize sizes[6] = {};
+   VkDescriptorPoolSize sizes[6] = {0};
    int type_map[12];
    unsigned num_types = 0;
    memset(type_map, -1, sizeof(type_map));
@@ -809,7 +809,7 @@ zink_descriptor_program_init(struct zink_context *ctx, struct zink_program *pg)
       sizes[i].descriptorCount *= ZINK_DEFAULT_MAX_DESCS;
 
    bool found_descriptors = false;
-   struct zink_descriptor_layout_key *layout_key[ZINK_DESCRIPTOR_TYPES] = {};
+   struct zink_descriptor_layout_key *layout_key[ZINK_DESCRIPTOR_TYPES] = {0};
    for (unsigned i = ZINK_DESCRIPTOR_TYPES - 1; i < ZINK_DESCRIPTOR_TYPES; i--) {
       if (!num_bindings[i]) {
          if (!found_descriptors)
@@ -835,7 +835,7 @@ zink_descriptor_program_init(struct zink_context *ctx, struct zink_program *pg)
       }
       found_descriptors = true;
 
-      VkDescriptorPoolSize type_sizes[2] = {};
+      VkDescriptorPoolSize type_sizes[2] = {0};
       int num_type_sizes = 0;
       switch (i) {
       case ZINK_DESCRIPTOR_TYPE_UBO:
index f27bee3..2943301 100644 (file)
@@ -232,7 +232,7 @@ zink_descriptor_program_init_lazy(struct zink_context *ctx, struct zink_program
    if (!num_bindings && !push_count)
       return true;
 
-   VkDescriptorUpdateTemplateCreateInfo template[2] = {};
+   VkDescriptorUpdateTemplateCreateInfo template[2] = {0};
    VkDescriptorUpdateTemplateType types[2] = {
       VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET,
       have_push ? VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR : VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET
@@ -276,7 +276,7 @@ static VkDescriptorPool
 create_pool(struct zink_screen *screen, unsigned num_type_sizes, VkDescriptorPoolSize *sizes, unsigned flags)
 {
    VkDescriptorPool pool;
-   VkDescriptorPoolCreateInfo dpci = {};
+   VkDescriptorPoolCreateInfo dpci = {0};
    dpci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
    dpci.pPoolSizes = sizes;
    dpci.poolSizeCount = num_type_sizes;
index 3c5af02..94feeaf 100644 (file)
@@ -384,7 +384,7 @@ zink_get_physical_device_info(struct zink_screen *screen)
 
    // check for device properties
    if (screen->vk.GetPhysicalDeviceProperties2) {
-      VkPhysicalDeviceProperties2 props = {};
+      VkPhysicalDeviceProperties2 props = {0};
       props.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
 
 %for version in versions:
index 2111498..fc5da15 100644 (file)
@@ -67,9 +67,9 @@ zink_emit_stream_output_targets(struct pipe_context *pctx)
    struct zink_context *ctx = zink_context(pctx);
    struct zink_screen *screen = zink_screen(pctx->screen);
    struct zink_batch *batch = &ctx->batch;
-   VkBuffer buffers[PIPE_MAX_SO_OUTPUTS] = {};
-   VkDeviceSize buffer_offsets[PIPE_MAX_SO_OUTPUTS] = {};
-   VkDeviceSize buffer_sizes[PIPE_MAX_SO_OUTPUTS] = {};
+   VkBuffer buffers[PIPE_MAX_SO_OUTPUTS] = {0};
+   VkDeviceSize buffer_offsets[PIPE_MAX_SO_OUTPUTS] = {0};
+   VkDeviceSize buffer_sizes[PIPE_MAX_SO_OUTPUTS] = {0};
 
    for (unsigned i = 0; i < ctx->num_so_targets; i++) {
       struct zink_so_target *t = (struct zink_so_target *)ctx->so_targets[i];
index 6464944..b409fab 100644 (file)
@@ -72,7 +72,7 @@ zink_init_framebuffer(struct zink_screen *screen, struct zink_framebuffer *fb, s
       goto out;
    }
 
-   VkFramebufferCreateInfo fci = {};
+   VkFramebufferCreateInfo fci = {0};
    fci.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
    fci.renderPass = rp->render_pass;
    fci.attachmentCount = fb->state.num_attachments;
index 9431a20..1cbffd1 100644 (file)
@@ -204,7 +204,7 @@ zink_create_instance(struct zink_instance_info *instance_info)
    }
 %endfor
 
-   VkApplicationInfo ai = {};
+   VkApplicationInfo ai = {0};
    ai.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
 
    char proc_name[128];
@@ -216,7 +216,7 @@ zink_create_instance(struct zink_instance_info *instance_info)
    ai.pEngineName = "mesa zink";
    ai.apiVersion = instance_info->loader_version;
 
-   VkInstanceCreateInfo ici = {};
+   VkInstanceCreateInfo ici = {0};
    ici.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    ici.pApplicationInfo = &ai;
    ici.ppEnabledExtensionNames = extensions;
index 27c9cbf..b7c0d84 100644 (file)
@@ -41,14 +41,14 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
                          struct zink_gfx_pipeline_state *state,
                          VkPrimitiveTopology primitive_topology)
 {
-   VkPipelineVertexInputStateCreateInfo vertex_input_state = {};
+   VkPipelineVertexInputStateCreateInfo vertex_input_state = {0};
    vertex_input_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
    vertex_input_state.pVertexBindingDescriptions = state->element_state->bindings;
    vertex_input_state.vertexBindingDescriptionCount = state->element_state->num_bindings;
    vertex_input_state.pVertexAttributeDescriptions = state->element_state->attribs;
    vertex_input_state.vertexAttributeDescriptionCount = state->element_state->num_attribs;
 
-   VkPipelineVertexInputDivisorStateCreateInfoEXT vdiv_state = {};
+   VkPipelineVertexInputDivisorStateCreateInfoEXT vdiv_state = {0};
    if (state->element_state->divisors_present) {
        vertex_input_state.pNext = &vdiv_state;
        vdiv_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT;
@@ -56,7 +56,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
        vdiv_state.pVertexBindingDivisors = state->element_state->divisors;
    }
 
-   VkPipelineInputAssemblyStateCreateInfo primitive_state = {};
+   VkPipelineInputAssemblyStateCreateInfo primitive_state = {0};
    primitive_state.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
    primitive_state.topology = primitive_topology;
    switch (primitive_topology) {
@@ -74,14 +74,14 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
       primitive_state.primitiveRestartEnable = state->primitive_restart ? VK_TRUE : VK_FALSE;
    }
 
-   VkPipelineColorBlendStateCreateInfo blend_state = {};
+   VkPipelineColorBlendStateCreateInfo blend_state = {0};
    blend_state.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
    blend_state.pAttachments = state->blend_state->attachments;
    blend_state.attachmentCount = state->num_attachments;
    blend_state.logicOpEnable = state->blend_state->logicop_enable;
    blend_state.logicOp = state->blend_state->logicop_func;
 
-   VkPipelineMultisampleStateCreateInfo ms_state = {};
+   VkPipelineMultisampleStateCreateInfo ms_state = {0};
    ms_state.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
    ms_state.rasterizationSamples = state->rast_samples;
    ms_state.alphaToCoverageEnable = state->blend_state->alpha_to_coverage;
@@ -92,14 +92,14 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
       ms_state.minSampleShading = 1.0;
    }
 
-   VkPipelineViewportStateCreateInfo viewport_state = {};
+   VkPipelineViewportStateCreateInfo viewport_state = {0};
    viewport_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
    viewport_state.viewportCount = state->num_viewports;
    viewport_state.pViewports = NULL;
    viewport_state.scissorCount = state->num_viewports;
    viewport_state.pScissors = NULL;
 
-   VkPipelineRasterizationStateCreateInfo rast_state = {};
+   VkPipelineRasterizationStateCreateInfo rast_state = {0};
    rast_state.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
 
    rast_state.depthClampEnable = state->rast_state->depth_clamp;
@@ -123,7 +123,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
       rast_state.pNext = &pv_state;
    }
 
-   VkPipelineDepthStencilStateCreateInfo depth_stencil_state = {};
+   VkPipelineDepthStencilStateCreateInfo depth_stencil_state = {0};
    depth_stencil_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
    depth_stencil_state.depthTestEnable = state->depth_stencil_alpha_state->depth_test;
    depth_stencil_state.depthCompareOp = state->depth_stencil_alpha_state->depth_compare_op;
@@ -163,12 +163,12 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
       dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_SCISSOR;
    }
 
-   VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo = {};
+   VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo = {0};
    pipelineDynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
    pipelineDynamicStateCreateInfo.pDynamicStates = dynamicStateEnables;
    pipelineDynamicStateCreateInfo.dynamicStateCount = state_count;
 
-   VkGraphicsPipelineCreateInfo pci = {};
+   VkGraphicsPipelineCreateInfo pci = {0};
    pci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
    pci.layout = prog->base.layout;
    pci.renderPass = state->render_pass->render_pass;
@@ -181,8 +181,8 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
    pci.pDepthStencilState = &depth_stencil_state;
    pci.pDynamicState = &pipelineDynamicStateCreateInfo;
 
-   VkPipelineTessellationStateCreateInfo tci = {};
-   VkPipelineTessellationDomainOriginStateCreateInfo tdci = {};
+   VkPipelineTessellationStateCreateInfo tci = {0};
+   VkPipelineTessellationDomainOriginStateCreateInfo tdci = {0};
    if (prog->shaders[PIPE_SHADER_TESS_CTRL] && prog->shaders[PIPE_SHADER_TESS_EVAL]) {
       tci.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
       tci.patchControlPoints = state->vertices_per_patch;
@@ -198,7 +198,7 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
       if (!prog->modules[i])
          continue;
 
-      VkPipelineShaderStageCreateInfo stage = {};
+      VkPipelineShaderStageCreateInfo stage = {0};
       stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
       stage.stage = zink_shader_stage(i);
       stage.module = prog->modules[i]->shader;
@@ -223,17 +223,17 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
 VkPipeline
 zink_create_compute_pipeline(struct zink_screen *screen, struct zink_compute_program *comp, struct zink_compute_pipeline_state *state)
 {
-   VkComputePipelineCreateInfo pci = {};
+   VkComputePipelineCreateInfo pci = {0};
    pci.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
    pci.layout = comp->base.layout;
 
-   VkPipelineShaderStageCreateInfo stage = {};
+   VkPipelineShaderStageCreateInfo stage = {0};
    stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
    stage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
    stage.module = comp->module->shader;
    stage.pName = "main";
 
-   VkSpecializationInfo sinfo = {};
+   VkSpecializationInfo sinfo = {0};
    VkSpecializationMapEntry me[3];
    if (state->use_local_size) {
       stage.pSpecializationInfo = &sinfo;
index 8bf3a87..fda755e 100644 (file)
@@ -207,7 +207,7 @@ get_shader_module_for_stage(struct zink_context *ctx, struct zink_shader *zs, st
 {
    gl_shader_stage stage = zs->nir->info.stage;
    enum pipe_shader_type pstage = pipe_shader_type_from_mesa(stage);
-   struct zink_shader_key key = {};
+   struct zink_shader_key key = {0};
    VkShaderModule mod;
    struct zink_shader_module *zm;
    struct zink_shader_module **default_zm = NULL;
@@ -495,13 +495,13 @@ zink_update_gfx_program(struct zink_context *ctx, struct zink_gfx_program *prog)
 VkPipelineLayout
 zink_pipeline_layout_create(struct zink_screen *screen, struct zink_program *pg)
 {
-   VkPipelineLayoutCreateInfo plci = {};
+   VkPipelineLayoutCreateInfo plci = {0};
    plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
 
    plci.pSetLayouts = pg->dsl;
    plci.setLayoutCount = pg->num_dsl;
 
-   VkPushConstantRange pcr[2] = {};
+   VkPushConstantRange pcr[2] = {0};
    if (pg->is_compute) {
       if (((struct zink_compute_program*)pg)->shader->nir->info.stage == MESA_SHADER_KERNEL) {
          pcr[0].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
index 9dcc138..4dac0f2 100644 (file)
@@ -273,7 +273,7 @@ zink_create_query(struct pipe_context *pctx,
 {
    struct zink_screen *screen = zink_screen(pctx->screen);
    struct zink_query *query = CALLOC_STRUCT(zink_query);
-   VkQueryPoolCreateInfo pool_create = {};
+   VkQueryPoolCreateInfo pool_create = {0};
 
    if (!query)
       return NULL;
@@ -853,7 +853,7 @@ zink_start_conditional_render(struct zink_context *ctx)
    VkConditionalRenderingFlagsEXT begin_flags = 0;
    if (ctx->render_condition.inverted)
       begin_flags = VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT;
-   VkConditionalRenderingBeginInfoEXT begin_info = {};
+   VkConditionalRenderingBeginInfoEXT begin_info = {0};
    begin_info.sType = VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT;
    begin_info.buffer = ctx->render_condition.query->predicate->obj->buffer;
    begin_info.flags = begin_flags;
@@ -1002,7 +1002,7 @@ zink_get_timestamp(struct pipe_context *pctx)
    struct zink_screen *screen = zink_screen(pctx->screen);
    uint64_t timestamp, deviation;
    assert(screen->info.have_EXT_calibrated_timestamps);
-   VkCalibratedTimestampInfoEXT cti = {};
+   VkCalibratedTimestampInfoEXT cti = {0};
    cti.sType = VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT;
    cti.timeDomain = VK_TIME_DOMAIN_DEVICE_EXT;
    screen->vk.GetCalibratedTimestampsEXT(screen->dev, 1, &cti, &timestamp, &deviation);
index 95a9f1e..84228d3 100644 (file)
@@ -92,13 +92,13 @@ create_render_pass(VkDevice dev, struct zink_render_pass_state *state)
       [1] = {0, VK_SUBPASS_EXTERNAL, dep_pipeline, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, dep_access, 0, VK_DEPENDENCY_BY_REGION_BIT}
    };
 
-   VkSubpassDescription subpass = {};
+   VkSubpassDescription subpass = {0};
    subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
    subpass.colorAttachmentCount = state->num_cbufs;
    subpass.pColorAttachments = color_refs;
    subpass.pDepthStencilAttachment = state->have_zsbuf ? &zs_ref : NULL;
 
-   VkRenderPassCreateInfo rpci = {};
+   VkRenderPassCreateInfo rpci = {0};
    rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
    rpci.attachmentCount = num_attachments;
    rpci.pAttachments = attachments;
index d37a93b..6d6baa8 100644 (file)
@@ -215,7 +215,7 @@ aspect_from_format(enum pipe_format fmt)
 static VkBufferCreateInfo
 create_bci(struct zink_screen *screen, const struct pipe_resource *templ, unsigned bind)
 {
-   VkBufferCreateInfo bci = {};
+   VkBufferCreateInfo bci = {0};
    bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
    bci.size = templ->width0;
    assert(bci.size > 0);
@@ -302,9 +302,9 @@ check_ici(struct zink_screen *screen, VkImageCreateInfo *ici)
    VkImageFormatProperties image_props;
    VkResult ret;
    if (screen->vk.GetPhysicalDeviceImageFormatProperties2) {
-      VkImageFormatProperties2 props2 = {};
+      VkImageFormatProperties2 props2 = {0};
       props2.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2;
-      VkPhysicalDeviceImageFormatInfo2 info = {};
+      VkPhysicalDeviceImageFormatInfo2 info = {0};
       info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2;
       info.format = ici->format;
       info.type = ici->imageType;
@@ -322,7 +322,7 @@ check_ici(struct zink_screen *screen, VkImageCreateInfo *ici)
 static VkImageCreateInfo
 create_ici(struct zink_screen *screen, const struct pipe_resource *templ, unsigned bind)
 {
-   VkImageCreateInfo ici = {};
+   VkImageCreateInfo ici = {0};
    ici.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
    ici.flags = bind & (PIPE_BIND_SCANOUT | PIPE_BIND_DEPTH_STENCIL) ? 0 : VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
 
@@ -419,7 +419,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
    if (!obj)
       return NULL;
 
-   VkMemoryRequirements reqs = {};
+   VkMemoryRequirements reqs = {0};
    VkMemoryPropertyFlags flags;
    bool scanout = templ->bind & PIPE_BIND_SCANOUT;
    bool shared = templ->bind & PIPE_BIND_SHARED;
@@ -443,7 +443,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
       obj->transfer_dst = true;
    } else {
       VkImageCreateInfo ici = create_ici(screen, templ, templ->bind);
-      VkExternalMemoryImageCreateInfo emici = {};
+      VkExternalMemoryImageCreateInfo emici = {0};
 
       if (templ->bind & PIPE_BIND_SHARED) {
          emici.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO;
@@ -496,7 +496,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
             templ->usage == PIPE_USAGE_STAGING)
       flags |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
 
-   VkMemoryAllocateInfo mai = {};
+   VkMemoryAllocateInfo mai = {0};
    mai.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
    mai.allocationSize = reqs.size;
    mai.memoryTypeIndex = get_memory_type_index(screen, &reqs, flags);
@@ -514,7 +514,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
          mai.allocationSize = reqs.size = align(reqs.size, screen->info.props.limits.nonCoherentAtomSize);
    }
 
-   VkExportMemoryAllocateInfo emai = {};
+   VkExportMemoryAllocateInfo emai = {0};
    if (templ->bind & PIPE_BIND_SHARED && shared) {
       emai.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO;
       emai.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
@@ -673,8 +673,8 @@ zink_resource_get_handle(struct pipe_screen *pscreen,
    struct zink_resource_object *obj = res->scanout_obj ? res->scanout_obj : res->obj;
 
    if (res->base.b.target != PIPE_BUFFER) {
-      VkImageSubresource sub_res = {};
-      VkSubresourceLayout sub_res_layout = {};
+      VkImageSubresource sub_res = {0};
+      VkSubresourceLayout sub_res_layout = {0};
 
       sub_res.aspectMask = res->aspect;
 
@@ -685,7 +685,7 @@ zink_resource_get_handle(struct pipe_screen *pscreen,
 
    if (whandle->type == WINSYS_HANDLE_TYPE_FD) {
 #ifdef ZINK_USE_DMABUF
-      VkMemoryGetFdInfoKHR fd_info = {};
+      VkMemoryGetFdInfoKHR fd_info = {0};
       int fd;
       fd_info.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR;
       //TODO: remove for wsi
index abbdaaf..f290f90 100644 (file)
@@ -1363,7 +1363,7 @@ populate_format_props(struct zink_screen *screen)
       if (!format)
          continue;
       if (screen->vk.GetPhysicalDeviceFormatProperties2) {
-         VkFormatProperties2 props = {};
+         VkFormatProperties2 props = {0};
          props.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
          screen->vk.GetPhysicalDeviceFormatProperties2(screen->pdev, format, &props);
          screen->format_props[i] = props.formatProperties;
@@ -1375,8 +1375,8 @@ populate_format_props(struct zink_screen *screen)
 bool
 zink_screen_init_semaphore(struct zink_screen *screen)
 {
-   VkSemaphoreCreateInfo sci = {};
-   VkSemaphoreTypeCreateInfo tci = {};
+   VkSemaphoreCreateInfo sci = {0};
+   VkSemaphoreTypeCreateInfo tci = {0};
    VkSemaphore sem;
    sci.pNext = &tci;
    sci.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
@@ -1400,7 +1400,7 @@ zink_screen_init_semaphore(struct zink_screen *screen)
 bool
 zink_screen_timeline_wait(struct zink_screen *screen, uint32_t batch_id, uint64_t timeout)
 {
-   VkSemaphoreWaitInfo wi = {};
+   VkSemaphoreWaitInfo wi = {0};
    wi.sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO;
    wi.semaphoreCount = 1;
    /* handle batch_id overflow */
@@ -1443,10 +1443,10 @@ zink_query_memory_info(struct pipe_screen *pscreen, struct pipe_memory_info *inf
    struct zink_screen *screen = zink_screen(pscreen);
    memset(info, 0, sizeof(struct pipe_memory_info));
    if (screen->info.have_EXT_memory_budget && screen->vk.GetPhysicalDeviceMemoryProperties2) {
-      VkPhysicalDeviceMemoryProperties2 mem = {};
+      VkPhysicalDeviceMemoryProperties2 mem = {0};
       mem.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
 
-      VkPhysicalDeviceMemoryBudgetPropertiesEXT budget = {};
+      VkPhysicalDeviceMemoryBudgetPropertiesEXT budget = {0};
       budget.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT;
       mem.pNext = &budget;
       screen->vk.GetPhysicalDeviceMemoryProperties2(screen->pdev, &mem);
@@ -1485,14 +1485,14 @@ zink_create_logical_device(struct zink_screen *screen)
 {
    VkDevice dev = VK_NULL_HANDLE;
 
-   VkDeviceQueueCreateInfo qci = {};
+   VkDeviceQueueCreateInfo qci = {0};
    float dummy = 0.0f;
    qci.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
    qci.queueFamilyIndex = screen->gfx_queue;
    qci.queueCount = screen->threaded && screen->max_queues > 1 ? 2 : 1;
    qci.pQueuePriorities = &dummy;
 
-   VkDeviceCreateInfo dci = {};
+   VkDeviceCreateInfo dci = {0};
    dci.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
    dci.queueCreateInfoCount = 1;
    dci.pQueueCreateInfos = &qci;
index b64316a..825cd60 100644 (file)
@@ -37,7 +37,7 @@ create_ivci(struct zink_screen *screen,
             const struct pipe_surface *templ,
             enum pipe_texture_target target)
 {
-   VkImageViewCreateInfo ivci = {};
+   VkImageViewCreateInfo ivci = {0};
    ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
    ivci.image = res->obj->image;
 
@@ -285,10 +285,10 @@ zink_rebind_surface(struct zink_context *ctx, struct pipe_surface **psurface)
 struct pipe_surface *
 zink_surface_create_null(struct zink_context *ctx, enum pipe_texture_target target, unsigned width, unsigned height, unsigned samples)
 {
-   struct pipe_surface surf_templ = {};
+   struct pipe_surface surf_templ = {0};
 
    struct pipe_resource *pres;
-   struct pipe_resource templ = {};
+   struct pipe_resource templ = {0};
    templ.width0 = width;
    templ.height0 = height;
    templ.depth0 = 1;