Merge remote-tracking branch 'public/master' into vulkan
[mesa.git] / src / intel / vulkan / anv_meta_resolve.c
index 8eb2548b5aecc8720dd7bd339dd7f64edb915700..7d2a75bb7529476be72129b1542d1c7a0fecc03d 100644 (file)
@@ -41,12 +41,7 @@ static void
 meta_resolve_save(struct anv_meta_saved_state *saved_state,
                   struct anv_cmd_buffer *cmd_buffer)
 {
-   anv_meta_save(saved_state, cmd_buffer,
-                 (1 << VK_DYNAMIC_STATE_VIEWPORT) |
-                 (1 << VK_DYNAMIC_STATE_SCISSOR));
-
-   cmd_buffer->state.dynamic.viewport.count = 0;
-   cmd_buffer->state.dynamic.scissor.count = 0;
+   anv_meta_save(saved_state, cmd_buffer, 0);
 }
 
 static void
@@ -164,7 +159,7 @@ build_nir_fs(uint32_t num_samples)
       tex->dest_type = nir_type_float;
       tex->is_array = false;
       tex->coord_components = 3;
-      nir_ssa_dest_init(&tex->instr, &tex->dest, /*num_components*/ 4, "tex");
+      nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, "tex");
       nir_builder_instr_insert(&b, &tex->instr);
 
       accum = nir_fadd(&b, accum, &tex->dest.ssa);
@@ -345,8 +340,6 @@ create_pipeline(struct anv_device *device,
       &(struct anv_graphics_pipeline_create_info) {
          .color_attachment_count = -1,
          .use_repclear = false,
-         .disable_viewport = true,
-         .disable_scissor = true,
          .disable_vs = true,
          .use_rectlist = true
       },
@@ -481,7 +474,6 @@ emit_resolve(struct anv_cmd_buffer *cmd_buffer,
    struct anv_device *device = cmd_buffer->device;
    VkDevice device_h = anv_device_to_handle(device);
    VkCommandBuffer cmd_buffer_h = anv_cmd_buffer_to_handle(cmd_buffer);
-   const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
    const struct anv_image *src_image = src_iview->image;
 
    const struct vertex_attrs vertex_data[3] = {
@@ -609,30 +601,6 @@ emit_resolve(struct anv_cmd_buffer *cmd_buffer,
       /*copyCount*/ 0,
       /*copies */ NULL);
 
-   ANV_CALL(CmdSetViewport)(cmd_buffer_h,
-      /*firstViewport*/ 0,
-      /*viewportCount*/ 1,
-      (VkViewport[]) {
-         {
-            .x = 0,
-            .y = 0,
-            .width = fb->width,
-            .height = fb->height,
-            .minDepth = 0.0,
-            .maxDepth = 1.0,
-         },
-      });
-
-   ANV_CALL(CmdSetScissor)(cmd_buffer_h,
-      /*firstScissor*/ 0,
-      /*scissorCount*/ 1,
-      (VkRect2D[]) {
-         {
-            .offset = { 0, 0 },
-            .extent = (VkExtent2D) { fb->width, fb->height },
-         },
-      });
-
    VkPipeline pipeline_h = *get_pipeline_h(device, src_image->samples);
    ANV_FROM_HANDLE(anv_pipeline, pipeline, pipeline_h);
 
@@ -719,6 +687,27 @@ void anv_CmdResolveImage(
          anv_meta_get_iview_layer(dest_image, &region->dstSubresource,
                                   &region->dstOffset);
 
+      /**
+       * From Vulkan 1.0.6 spec: 18.6 Resolving Multisample Images
+       *
+       *    extent is the size in texels of the source image to resolve in width,
+       *    height and depth. 1D images use only x and width. 2D images use x, y,
+       *    width and height. 3D images use x, y, z, width, height and depth.
+       *
+       *    srcOffset and dstOffset select the initial x, y, and z offsets in
+       *    texels of the sub-regions of the source and destination image data.
+       *    extent is the size in texels of the source image to resolve in width,
+       *    height and depth. 1D images use only x and width. 2D images use x, y,
+       *    width and height. 3D images use x, y, z, width, height and depth.
+       */
+      const struct VkExtent3D extent =
+         anv_sanitize_image_extent(src_image->type, region->extent);
+      const struct VkOffset3D srcOffset =
+         anv_sanitize_image_offset(src_image->type, region->srcOffset);
+      const struct VkOffset3D dstOffset =
+         anv_sanitize_image_offset(dest_image->type, region->dstOffset);
+
+
       for (uint32_t layer = 0; layer < region->srcSubresource.layerCount;
            ++layer) {
 
@@ -737,7 +726,7 @@ void anv_CmdResolveImage(
                   .layerCount = 1,
                },
             },
-            cmd_buffer, 0);
+            cmd_buffer, VK_IMAGE_USAGE_SAMPLED_BIT);
 
          struct anv_image_view dest_iview;
          anv_image_view_init(&dest_iview, cmd_buffer->device,
@@ -754,7 +743,7 @@ void anv_CmdResolveImage(
                   .layerCount = 1,
                },
             },
-            cmd_buffer, 0);
+            cmd_buffer, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
 
          VkFramebuffer fb_h;
          anv_CreateFramebuffer(device_h,
@@ -780,12 +769,12 @@ void anv_CmdResolveImage(
                .framebuffer = fb_h,
                .renderArea = {
                   .offset = {
-                     region->dstOffset.x,
-                     region->dstOffset.y,
+                     dstOffset.x,
+                     dstOffset.y,
                   },
                   .extent = {
-                     region->extent.width,
-                     region->extent.height,
+                     extent.width,
+                     extent.height,
                   }
                },
                .clearValueCount = 0,
@@ -796,17 +785,17 @@ void anv_CmdResolveImage(
          emit_resolve(cmd_buffer,
              &src_iview,
              &(VkOffset2D) {
-               .x = region->srcOffset.x,
-               .y = region->srcOffset.y,
+               .x = srcOffset.x,
+               .y = srcOffset.y,
              },
              &dest_iview,
              &(VkOffset2D) {
-               .x = region->dstOffset.x,
-               .y = region->dstOffset.y,
+               .x = dstOffset.x,
+               .y = dstOffset.y,
              },
              &(VkExtent2D) {
-               .width = region->extent.width,
-               .height = region->extent.height,
+               .width = extent.width,
+               .height = extent.height,
              });
 
          ANV_CALL(CmdEndRenderPass)(cmd_buffer_h);