anv/meta: Teach meta how to blit from a 1D image
authorChad Versace <chad.versace@intel.com>
Tue, 5 Jan 2016 22:37:45 +0000 (14:37 -0800)
committerChad Versace <chad.versace@intel.com>
Wed, 6 Jan 2016 17:38:57 +0000 (09:38 -0800)
Meta needed a VkShader with a 1D sampler type.

src/vulkan/anv_meta.c
src/vulkan/anv_private.h

index 75473a1..e351db0 100644 (file)
@@ -95,8 +95,9 @@ build_nir_copy_fragment_shader(enum glsl_sampler_dim tex_dim)
    tex->src[0].src = nir_src_for_ssa(nir_load_var(&b, tex_pos_in));
    tex->dest_type = nir_type_float; /* TODO */
 
-   if (tex_dim == GLSL_SAMPLER_DIM_2D)
+   if (tex_dim != GLSL_SAMPLER_DIM_3D)
       tex->is_array = true;
+
    tex->coord_components = 3;
 
    tex->sampler = nir_deref_var_create(tex, sampler);
@@ -228,6 +229,10 @@ anv_device_init_meta_blit_state(struct anv_device *device)
       .nir = build_nir_vertex_shader(false),
    };
 
+   struct anv_shader_module fs_1d = {
+      .nir = build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_1D),
+   };
+
    struct anv_shader_module fs_2d = {
       .nir = build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_2D),
    };
@@ -390,13 +395,21 @@ anv_device_init_meta_blit_state(struct anv_device *device)
       .use_rectlist = true
    };
 
+   pipeline_shader_stages[1].module = anv_shader_module_to_handle(&fs_1d);
+   result = anv_graphics_pipeline_create(anv_device_to_handle(device),
+      VK_NULL_HANDLE,
+      &vk_pipeline_info, &anv_pipeline_info,
+      NULL, &device->meta_state.blit.pipeline_1d_src);
+   if (result != VK_SUCCESS)
+      goto fail_pipeline_layout;
+
    pipeline_shader_stages[1].module = anv_shader_module_to_handle(&fs_2d);
    result = anv_graphics_pipeline_create(anv_device_to_handle(device),
       VK_NULL_HANDLE,
       &vk_pipeline_info, &anv_pipeline_info,
       NULL, &device->meta_state.blit.pipeline_2d_src);
    if (result != VK_SUCCESS)
-      goto fail_pipeline_layout;
+      goto fail_pipeline_1d;
 
    pipeline_shader_stages[1].module = anv_shader_module_to_handle(&fs_3d);
    result = anv_graphics_pipeline_create(anv_device_to_handle(device),
@@ -407,6 +420,7 @@ anv_device_init_meta_blit_state(struct anv_device *device)
       goto fail_pipeline_2d;
 
    ralloc_free(vs.nir);
+   ralloc_free(fs_1d.nir);
    ralloc_free(fs_2d.nir);
    ralloc_free(fs_3d.nir);
 
@@ -415,6 +429,11 @@ anv_device_init_meta_blit_state(struct anv_device *device)
  fail_pipeline_2d:
    anv_DestroyPipeline(anv_device_to_handle(device),
                        device->meta_state.blit.pipeline_2d_src, NULL);
+
+ fail_pipeline_1d:
+   anv_DestroyPipeline(anv_device_to_handle(device),
+                       device->meta_state.blit.pipeline_1d_src, NULL);
+
  fail_pipeline_layout:
    anv_DestroyPipelineLayout(anv_device_to_handle(device),
                              device->meta_state.blit.pipeline_layout, NULL);
@@ -426,6 +445,7 @@ anv_device_init_meta_blit_state(struct anv_device *device)
                          device->meta_state.blit.render_pass, NULL);
 
    ralloc_free(vs.nir);
+   ralloc_free(fs_1d.nir);
    ralloc_free(fs_2d.nir);
    ralloc_free(fs_3d.nir);
  fail:
@@ -595,8 +615,7 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
 
    switch (src_image->type) {
    case VK_IMAGE_TYPE_1D:
-      anv_finishme("VK_IMAGE_TYPE_1D");
-      pipeline = device->meta_state.blit.pipeline_2d_src;
+      pipeline = device->meta_state.blit.pipeline_1d_src;
       break;
    case VK_IMAGE_TYPE_2D:
       pipeline = device->meta_state.blit.pipeline_2d_src;
@@ -1385,6 +1404,8 @@ anv_device_finish_meta(struct anv_device *device)
    anv_DestroyRenderPass(anv_device_to_handle(device),
                          device->meta_state.blit.render_pass, NULL);
    anv_DestroyPipeline(anv_device_to_handle(device),
+                       device->meta_state.blit.pipeline_1d_src, NULL);
+   anv_DestroyPipeline(anv_device_to_handle(device),
                        device->meta_state.blit.pipeline_2d_src, NULL);
    anv_DestroyPipeline(anv_device_to_handle(device),
                        device->meta_state.blit.pipeline_3d_src, NULL);
index 59e8005..5bd5025 100644 (file)
@@ -558,6 +558,9 @@ struct anv_meta_state {
    struct {
       VkRenderPass render_pass;
 
+      /** Pipeline that blits from a 1D image. */
+      VkPipeline pipeline_1d_src;
+
       /** Pipeline that blits from a 2D image. */
       VkPipeline pipeline_2d_src;