anv: Remove unused field xfb_used from anv_pipeline
[mesa.git] / src / intel / vulkan / anv_nir_lower_ycbcr_textures.c
index 97cfe9454299dba61c738759d9cc601e0e05fa13..c31c229ff40d87bb88ae5a71b2eabe217e8398d2 100644 (file)
@@ -38,7 +38,7 @@ static nir_ssa_def *
 y_range(nir_builder *b,
         nir_ssa_def *y_channel,
         int bpc,
-        VkSamplerYcbcrRangeKHR range)
+        VkSamplerYcbcrRange range)
 {
    switch (range) {
    case VK_SAMPLER_YCBCR_RANGE_ITU_FULL:
@@ -60,7 +60,7 @@ static nir_ssa_def *
 chroma_range(nir_builder *b,
              nir_ssa_def *chroma_channel,
              int bpc,
-             VkSamplerYcbcrRangeKHR range)
+             VkSamplerYcbcrRange range)
 {
    switch (range) {
    case VK_SAMPLER_YCBCR_RANGE_ITU_FULL:
@@ -79,36 +79,40 @@ chroma_range(nir_builder *b,
    }
 }
 
-static const nir_const_value *
-ycbcr_model_to_rgb_matrix(VkSamplerYcbcrModelConversionKHR model)
+typedef struct nir_const_value_3_4 {
+   nir_const_value v[3][4];
+} nir_const_value_3_4;
+
+static const nir_const_value_3_4 *
+ycbcr_model_to_rgb_matrix(VkSamplerYcbcrModelConversion model)
 {
    switch (model) {
    case VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601: {
-      static const nir_const_value bt601[3] = {
-         { .f32 = {  1.402f,             1.0f,  0.0f,               0.0f } },
-         { .f32 = { -0.714136286201022f, 1.0f, -0.344136286201022f, 0.0f } },
-         { .f32 = {  0.0f,               1.0f,  1.772f,             0.0f } }
-      };
+      static const nir_const_value_3_4 bt601 = { {
+         { { .f32 =  1.402f             }, { .f32 = 1.0f }, { .f32 =  0.0f               }, { .f32 = 0.0f } },
+         { { .f32 = -0.714136286201022f }, { .f32 = 1.0f }, { .f32 = -0.344136286201022f }, { .f32 = 0.0f } },
+         { { .f32 =  0.0f               }, { .f32 = 1.0f }, { .f32 =  1.772f             }, { .f32 = 0.0f } },
+      } };
 
-      return bt601;
+      return &bt601;
    }
    case VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709: {
-      static const nir_const_value bt709[3] = {
-         { .f32 = {  1.5748031496063f,   1.0f,  0.0,                0.0f } },
-         { .f32 = { -0.468125209181067f, 1.0f, -0.187327487470334f, 0.0f } },
-         { .f32 = {  0.0f,               1.0f,  1.85563184264242f,  0.0f } }
-      };
+      static const nir_const_value_3_4 bt709 = { {
+         { { .f32 =  1.5748031496063f   }, { .f32 = 1.0f }, { .f32 =  0.0f               }, { .f32 = 0.0f } },
+         { { .f32 = -0.468125209181067f }, { .f32 = 1.0f }, { .f32 = -0.187327487470334f }, { .f32 = 0.0f } },
+         { { .f32 =  0.0f               }, { .f32 = 1.0f }, { .f32 =  1.85563184264242f  }, { .f32 = 0.0f } },
+      } };
 
-      return bt709;
+      return &bt709;
    }
    case VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020: {
-      static const nir_const_value bt2020[3] = {
-         { .f32 = { 1.4746f,             1.0f,  0.0f,               0.0f } },
-         { .f32 = { -0.571353126843658f, 1.0f, -0.164553126843658f, 0.0f } },
-         { .f32 = { 0.0f,                1.0f,  1.8814f,            0.0f } }
-      };
+      static const nir_const_value_3_4 bt2020 = { {
+         { { .f32 =  1.4746f            }, { .f32 = 1.0f }, { .f32 =  0.0f               }, { .f32 = 0.0f } },
+         { { .f32 = -0.571353126843658f }, { .f32 = 1.0f }, { .f32 = -0.164553126843658f }, { .f32 = 0.0f } },
+         { { .f32 =  0.0f               }, { .f32 = 1.0f }, { .f32 =  1.8814f            }, { .f32 = 0.0f } },
+      } };
 
-      return bt2020;
+      return &bt2020;
    }
    default:
       unreachable("missing Ycbcr model");
@@ -137,13 +141,13 @@ convert_ycbcr(struct ycbcr_state *state,
    if (conversion->ycbcr_model == VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY)
       return expanded_channels;
 
-   const nir_const_value *conversion_matrix =
+   const nir_const_value_3_4 *conversion_matrix =
       ycbcr_model_to_rgb_matrix(conversion->ycbcr_model);
 
    nir_ssa_def *converted_channels[] = {
-      nir_fdot4(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix[0])),
-      nir_fdot4(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix[1])),
-      nir_fdot4(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix[2]))
+      nir_fdot4(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[0])),
+      nir_fdot4(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[1])),
+      nir_fdot4(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[2]))
    };
 
    return nir_vec4(b,
@@ -267,8 +271,8 @@ create_plane_tex_instr_implicit(struct ycbcr_state *state,
    tex->component = old_tex->component;
 
    tex->texture_index = old_tex->texture_index;
-   tex->texture_array_size = old_tex->texture_array_size;
    tex->sampler_index = old_tex->sampler_index;
+   tex->is_array = old_tex->is_array;
 
    nir_ssa_dest_init(&tex->instr, &tex->dest,
                      old_tex->dest.ssa.num_components,
@@ -315,7 +319,7 @@ swizzle_channel(struct isl_swizzle swizzle, unsigned channel)
 }
 
 static bool
-try_lower_tex_ycbcr(struct anv_pipeline_layout *layout,
+try_lower_tex_ycbcr(const struct anv_pipeline_layout *layout,
                     nir_builder *builder,
                     nir_tex_instr *tex)
 {
@@ -443,7 +447,7 @@ try_lower_tex_ycbcr(struct anv_pipeline_layout *layout,
 
 bool
 anv_nir_lower_ycbcr_textures(nir_shader *shader,
-                             struct anv_pipeline_layout *layout)
+                             const struct anv_pipeline_layout *layout)
 {
    bool progress = false;