meta,i965: Rip GL_EXT_texture_multisample_blit_scaled support out of meta
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 17 Apr 2020 19:18:35 +0000 (14:18 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Apr 2020 03:02:23 +0000 (03:02 +0000)
i965 is the only driver that ever linked to this code and it's been
doing it in BLORP for a long time now.  The only possible case where it
would have fallen back to meta was for depth/stencil but that should
have ended starting with 6cec618e82aa2.  Rip out the dead code.

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4622>

src/mesa/drivers/common/meta.h
src/mesa/drivers/common/meta_blit.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/gen6_multisample_state.c
src/mesa/main/mtypes.h

index dbe8a9af02f3101fbf5507cc9a77367c33162d5d..d4c50305356f5357ecf6f38c7eecda23245d4853 100644 (file)
@@ -282,14 +282,6 @@ enum blit_msaa_shader {
    BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_COPY_UINT,
    BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_DEPTH_RESOLVE,
    BLIT_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_DEPTH_COPY,
-   BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE,
-   BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE,
-   BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE,
-   BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE,
-   BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_SCALED_RESOLVE,
-   BLIT_4X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_SCALED_RESOLVE,
-   BLIT_8X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_SCALED_RESOLVE,
-   BLIT_16X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_SCALED_RESOLVE,
    BLIT_MSAA_SHADER_COUNT,
 };
 
index b349af235e22e4a350deeda5ec11e368e526ec40..dfa215aa384702c924472ce04b5873b96baefe4b 100644 (file)
 /** Return offset in bytes of the field within a vertex struct */
 #define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
 
-static void
-setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
-                                   struct blit_state *blit,
-                                   struct gl_renderbuffer *src_rb,
-                                   GLenum target)
-{
-   GLint loc_src_width, loc_src_height;
-   int i, samples;
-   int shader_offset = 0;
-   void *mem_ctx = ralloc_context(NULL);
-   char *fs_source;
-   char *name, *sample_number;
-   const uint8_t *sample_map;
-   char *sample_map_str = rzalloc_size(mem_ctx, 1);
-   char *sample_map_expr = rzalloc_size(mem_ctx, 1);
-   char *texel_fetch_macro = rzalloc_size(mem_ctx, 1);
-   const char *sampler_array_suffix = "";
-   float x_scale, y_scale;
-   enum blit_msaa_shader shader_index;
-
-   assert(src_rb);
-   samples = MAX2(src_rb->NumSamples, 1);
-
-   if (samples == 16)
-      x_scale = 4.0;
-   else
-      x_scale = 2.0;
-   y_scale = samples / x_scale;
-
-   /* We expect only power of 2 samples in source multisample buffer. */
-   assert(samples > 0 && util_is_power_of_two_nonzero(samples));
-   while (samples >> (shader_offset + 1)) {
-      shader_offset++;
-   }
-   /* Update the assert if we plan to support more than 16X MSAA. */
-   assert(shader_offset > 0 && shader_offset <= 4);
-
-   assert(target == GL_TEXTURE_2D_MULTISAMPLE ||
-          target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
-
-   shader_index = BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE +
-                  shader_offset - 1;
-
-   if (target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {
-      shader_index += BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_ARRAY_SCALED_RESOLVE -
-                      BLIT_2X_MSAA_SHADER_2D_MULTISAMPLE_SCALED_RESOLVE;
-      sampler_array_suffix = "Array";
-   }
-
-   if (blit->msaa_shaders[shader_index]) {
-      _mesa_meta_use_program(ctx, blit->msaa_shaders[shader_index]);
-      /* Update the uniform values. */
-      loc_src_width =
-         _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_width");
-      loc_src_height =
-         _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_height");
-      _mesa_Uniform1f(loc_src_width, src_rb->Width);
-      _mesa_Uniform1f(loc_src_height, src_rb->Height);
-      return;
-   }
-
-   name = ralloc_asprintf(mem_ctx, "vec4 MSAA scaled resolve");
-
-   /* Below switch is used to setup the shader expression, which computes
-    * sample index and map it to to a sample number on hardware.
-    */
-   switch(samples) {
-   case 2:
-      sample_number =  "sample_map[int(2 * fract(coord.x))]";
-      sample_map = ctx->Const.SampleMap2x;
-      break;
-   case 4:
-      sample_number =  "sample_map[int(2 * fract(coord.x) + 4 * fract(coord.y))]";
-      sample_map = ctx->Const.SampleMap4x;
-      break;
-   case 8:
-      sample_number =  "sample_map[int(2 * fract(coord.x) + 8 * fract(coord.y))]";
-      sample_map = ctx->Const.SampleMap8x;
-      break;
-   case 16:
-      sample_number =  "sample_map[int(4 * fract(coord.x) + 16 * fract(coord.y))]";
-      sample_map = ctx->Const.SampleMap16x;
-      break;
-   default:
-      sample_number = NULL;
-      sample_map = NULL;
-      _mesa_problem(ctx, "Unsupported sample count %d\n", samples);
-      unreachable("Unsupported sample count");
-   }
-
-   /* Create sample map string. */
-   for (i = 0 ; i < samples - 1; i++) {
-      ralloc_asprintf_append(&sample_map_str, "%d, ", sample_map[i]);
-   }
-   ralloc_asprintf_append(&sample_map_str, "%d", sample_map[samples - 1]);
-
-   /* Create sample map expression using above string. */
-   ralloc_asprintf_append(&sample_map_expr,
-                          "   const int sample_map[%d] = int[%d](%s);\n",
-                          samples, samples, sample_map_str);
-
-   if (target == GL_TEXTURE_2D_MULTISAMPLE) {
-      ralloc_asprintf_append(&texel_fetch_macro,
-                             "#define TEXEL_FETCH(coord) texelFetch(texSampler, ivec2(coord), %s);\n",
-                             sample_number);
-   } else {
-      ralloc_asprintf_append(&texel_fetch_macro,
-                             "#define TEXEL_FETCH(coord) texelFetch(texSampler, ivec3(coord, layer), %s);\n",
-                             sample_number);
-   }
-
-   static const char vs_source[] =
-                               "#version 130\n"
-                               "#extension GL_ARB_explicit_attrib_location: enable\n"
-                               "layout(location = 0) in vec2 position;\n"
-                               "layout(location = 1) in vec3 textureCoords;\n"
-                               "out vec2 texCoords;\n"
-                               "flat out int layer;\n"
-                               "void main()\n"
-                               "{\n"
-                               "   texCoords = textureCoords.xy;\n"
-                               "   layer = int(textureCoords.z);\n"
-                               "   gl_Position = vec4(position, 0.0, 1.0);\n"
-                               "}\n"
-      ;
-
-   fs_source = ralloc_asprintf(mem_ctx,
-                               "#version 130\n"
-                               "#extension GL_ARB_texture_multisample : enable\n"
-                               "uniform sampler2DMS%s texSampler;\n"
-                               "uniform float src_width, src_height;\n"
-                               "in vec2 texCoords;\n"
-                               "flat in int layer;\n"
-                               "out vec4 out_color;\n"
-                               "\n"
-                               "void main()\n"
-                               "{\n"
-                               "%s"
-                               "   vec2 interp;\n"
-                               "   const vec2 scale = vec2(%ff, %ff);\n"
-                               "   const vec2 scale_inv = vec2(%ff, %ff);\n"
-                               "   const vec2 s_0_offset = vec2(%ff, %ff);\n"
-                               "   vec2 s_0_coord, s_1_coord, s_2_coord, s_3_coord;\n"
-                               "   vec4 s_0_color, s_1_color, s_2_color, s_3_color;\n"
-                               "   vec4 x_0_color, x_1_color;\n"
-                               "   vec2 tex_coord = texCoords - s_0_offset;\n"
-                               "\n"
-                               "   tex_coord *= scale;\n"
-                               "   tex_coord.x = clamp(tex_coord.x, 0.0f, scale.x * src_width - 1.0f);\n"
-                               "   tex_coord.y = clamp(tex_coord.y, 0.0f, scale.y * src_height - 1.0f);\n"
-                               "   interp = fract(tex_coord);\n"
-                               "   tex_coord = ivec2(tex_coord) * scale_inv;\n"
-                               "\n"
-                               "   /* Compute the sample coordinates used for filtering. */\n"
-                               "   s_0_coord = tex_coord;\n"
-                               "   s_1_coord = tex_coord + vec2(scale_inv.x, 0.0f);\n"
-                               "   s_2_coord = tex_coord + vec2(0.0f, scale_inv.y);\n"
-                               "   s_3_coord = tex_coord + vec2(scale_inv.x, scale_inv.y);\n"
-                               "\n"
-                               "   /* Fetch sample color values. */\n"
-                               "%s"
-                               "   s_0_color = TEXEL_FETCH(s_0_coord)\n"
-                               "   s_1_color = TEXEL_FETCH(s_1_coord)\n"
-                               "   s_2_color = TEXEL_FETCH(s_2_coord)\n"
-                               "   s_3_color = TEXEL_FETCH(s_3_coord)\n"
-                               "#undef TEXEL_FETCH\n"
-                               "\n"
-                               "   /* Do bilinear filtering on sample colors. */\n"
-                               "   x_0_color = mix(s_0_color, s_1_color, interp.x);\n"
-                               "   x_1_color = mix(s_2_color, s_3_color, interp.x);\n"
-                               "   out_color = mix(x_0_color, x_1_color, interp.y);\n"
-                               "}\n",
-                               sampler_array_suffix,
-                               sample_map_expr,
-                               x_scale, y_scale,
-                               1.0f / x_scale, 1.0f / y_scale,
-                               0.5f / x_scale, 0.5f / y_scale,
-                               texel_fetch_macro);
-
-   _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, name,
-                                       &blit->msaa_shaders[shader_index]);
-   loc_src_width =
-      _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_width");
-   loc_src_height =
-      _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_height");
-   _mesa_Uniform1f(loc_src_width, src_rb->Width);
-   _mesa_Uniform1f(loc_src_height, src_rb->Height);
-
-   ralloc_free(mem_ctx);
-}
-
 static void
 setup_glsl_msaa_blit_shader(struct gl_context *ctx,
                             struct blit_state *blit,
@@ -568,8 +377,6 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx,
    unsigned texcoord_size;
    bool is_target_multisample = target == GL_TEXTURE_2D_MULTISAMPLE ||
                                 target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
-   bool is_filter_scaled_resolve = filter == GL_SCALED_RESOLVE_FASTEST_EXT ||
-                                   filter == GL_SCALED_RESOLVE_NICEST_EXT;
 
    /* target = GL_TEXTURE_RECTANGLE is not supported in GLES 3.0 */
    assert(_mesa_is_desktop_gl(ctx) || target == GL_TEXTURE_2D);
@@ -579,9 +386,7 @@ setup_glsl_blit_framebuffer(struct gl_context *ctx,
    _mesa_meta_setup_vertex_objects(ctx, &blit->VAO, &blit->buf_obj, true,
                                    2, texcoord_size, 0);
 
-   if (is_target_multisample && is_filter_scaled_resolve && is_scaled_blit) {
-      setup_glsl_msaa_blit_scaled_shader(ctx, blit, src_rb, target);
-   } else if (is_target_multisample) {
+   if (is_target_multisample) {
       setup_glsl_msaa_blit_shader(ctx, blit, drawFb, src_rb, target);
    } else {
       _mesa_meta_setup_blit_shader(ctx, target, do_depth,
index 5deff66d8177f4c465b41f7366849376e2b64c0b..c9fd56c547e404cb1ff9b482638dab548e52e1a1 100644 (file)
@@ -602,14 +602,6 @@ brw_initialize_context_constants(struct brw_context *brw)
    ctx->Const.MaxIntegerSamples = max_samples;
    ctx->Const.MaxImageSamples = 0;
 
-   /* gen6_set_sample_maps() sets SampleMap{2,4,8}x variables which are used
-    * to map indices of rectangular grid to sample numbers within a pixel.
-    * These variables are used by GL_EXT_framebuffer_multisample_blit_scaled
-    * extension implementation. For more details see the comment above
-    * gen6_set_sample_maps() definition.
-    */
-   gen6_set_sample_maps(ctx);
-
    ctx->Const.MinLineWidth = 1.0;
    ctx->Const.MinLineWidthAA = 1.0;
    if (devinfo->gen >= 6) {
index 6f731f2371227a802e0a4931bb97d06a3288be3a..d3755eb2e4b699506cedb6a9cd0c6bd8d5ace647 100644 (file)
@@ -1513,8 +1513,6 @@ gen6_get_sample_position(struct gl_context *ctx,
                          struct gl_framebuffer *fb,
                          GLuint index,
                          GLfloat *result);
-void
-gen6_set_sample_maps(struct gl_context *ctx);
 
 /* gen8_multisample_state.c */
 void gen8_emit_3dstate_sample_pattern(struct brw_context *brw);
index 3ce47f423ba1d0af1f120ef9983cdc548f15d76f..785fc21eeaa50f0480a8da120e0f89f64fc66b16 100644 (file)
@@ -59,62 +59,3 @@ gen6_get_sample_position(struct gl_context *ctx,
    result[0] = ((bits >> 4) & 0xf) / 16.0f;
    result[1] = (bits & 0xf) / 16.0f;
 }
-
-/**
- * Sample index layout shows the numbering of slots in a rectangular
- * grid of samples with in a pixel. Sample number layout shows the
- * rectangular grid of samples roughly corresponding to the real sample
- * locations with in a pixel. Sample number layout matches the sample
- * index layout in case of 2X and 4x MSAA, but they are different in
- * case of 8X MSAA.
- *
- * 8X MSAA sample index layout    8x MSAA sample number layout
- *           ---------                      ---------
- *           | 0 | 1 |                      | 1 | 0 |
- *           ---------                      ---------
- *
- * 4X MSAA sample index / number layout
- *           ---------
- *           | 0 | 1 |
- *           ---------
- *           | 2 | 3 |
- *           ---------
- *
- * 8X MSAA sample index layout    8x MSAA sample number layout
- *           ---------                      ---------
- *           | 0 | 1 |                      | 5 | 2 |
- *           ---------                      ---------
- *           | 2 | 3 |                      | 4 | 6 |
- *           ---------                      ---------
- *           | 4 | 5 |                      | 0 | 3 |
- *           ---------                      ---------
- *           | 6 | 7 |                      | 7 | 1 |
- *           ---------                      ---------
- *
- * 16X MSAA sample index layout  16x MSAA sample number layout
- *         -----------------            -----------------
- *         | 0 | 1 | 2 | 3 |            |15 |10 | 9 | 7 |
- *         -----------------            -----------------
- *         | 4 | 5 | 6 | 7 |            | 4 | 1 | 3 |13 |
- *         -----------------            -----------------
- *         | 8 | 9 |10 |11 |            |12 | 2 | 0 | 6 |
- *         -----------------            -----------------
- *         |12 |13 |14 |15 |            |11 | 8 | 5 |14 |
- *         -----------------            -----------------
- *
- * A sample map is used to map sample indices to sample numbers.
- */
-void
-gen6_set_sample_maps(struct gl_context *ctx)
-{
-   uint8_t map_2x[2] = {1, 0};
-   uint8_t map_4x[4] = {0, 1, 2, 3};
-   uint8_t map_8x[8] = {3, 7, 5, 0, 1, 2, 4, 6};
-   uint8_t map_16x[16] = { 15, 10, 9, 7, 4, 1, 3, 13,
-                           12, 2, 0, 6, 11, 8, 5, 14 };
-
-   memcpy(ctx->Const.SampleMap2x, map_2x, sizeof(map_2x));
-   memcpy(ctx->Const.SampleMap4x, map_4x, sizeof(map_4x));
-   memcpy(ctx->Const.SampleMap8x, map_8x, sizeof(map_8x));
-   memcpy(ctx->Const.SampleMap16x, map_16x, sizeof(map_16x));
-}
index de10ba39a29afaf26867de453b4e4942649be380..62f1e9be5bc687ccb755725d0d2d72bb5f786b0d 100644 (file)
@@ -4063,51 +4063,6 @@ struct gl_constants
    } SupportedMultisampleModes[40];
    GLint NumSupportedMultisampleModes;
 
-   /**
-    * GL_EXT_texture_multisample_blit_scaled implementation assumes that
-    * samples are laid out in a rectangular grid roughly corresponding to
-    * sample locations within a pixel. Below SampleMap{2,4,8}x variables
-    * are used to map indices of rectangular grid to sample numbers within
-    * a pixel. This mapping of indices to sample numbers must be initialized
-    * by the driver for the target hardware. For example, if we have the 8X
-    * MSAA sample number layout (sample positions) for XYZ hardware:
-    *
-    *        sample indices layout          sample number layout
-    *            ---------                      ---------
-    *            | 0 | 1 |                      | a | b |
-    *            ---------                      ---------
-    *            | 2 | 3 |                      | c | d |
-    *            ---------                      ---------
-    *            | 4 | 5 |                      | e | f |
-    *            ---------                      ---------
-    *            | 6 | 7 |                      | g | h |
-    *            ---------                      ---------
-    *
-    * Where a,b,c,d,e,f,g,h are integers between [0-7].
-    *
-    * Then, initialize the SampleMap8x variable for XYZ hardware as shown
-    * below:
-    *    SampleMap8x = {a, b, c, d, e, f, g, h};
-    *
-    * Follow the logic for sample counts 2-8.
-    *
-    * For 16x the sample indices layout as a 4x4 grid as follows:
-    *
-    *            -----------------
-    *            | 0 | 1 | 2 | 3 |
-    *            -----------------
-    *            | 4 | 5 | 6 | 7 |
-    *            -----------------
-    *            | 8 | 9 |10 |11 |
-    *            -----------------
-    *            |12 |13 |14 |15 |
-    *            -----------------
-    */
-   uint8_t SampleMap2x[2];
-   uint8_t SampleMap4x[4];
-   uint8_t SampleMap8x[8];
-   uint8_t SampleMap16x[16];
-
    /** GL_ARB_shader_atomic_counters */
    GLuint MaxAtomicBufferBindings;
    GLuint MaxAtomicBufferSize;