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,
};
char *sample_map_expr = rzalloc_size(mem_ctx, 1);
char *texel_fetch_macro = rzalloc_size(mem_ctx, 1);
const char *sampler_array_suffix = "";
- float y_scale;
+ float x_scale, y_scale;
enum blit_msaa_shader shader_index;
assert(src_rb);
samples = MAX2(src_rb->NumSamples, 1);
- y_scale = samples * 0.5;
+
+ 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 && _mesa_is_pow_two(samples));
while (samples >> (shader_offset + 1)) {
shader_offset++;
}
- /* Update the assert if we plan to support more than 8X MSAA. */
- assert(shader_offset > 0 && shader_offset < 4);
+ /* 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);
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;
"{\n"
"%s"
" vec2 interp;\n"
- " const vec2 scale = vec2(2.0f, %ff);\n"
- " const vec2 scale_inv = vec2(0.5f, %ff);\n"
- " const vec2 s_0_offset = vec2(0.25f, %ff);\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"
"}\n",
sampler_array_suffix,
sample_map_expr,
- y_scale,
- 1.0f / y_scale,
- 1.0f / samples,
+ 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,
* | 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
uint8_t map_2x[2] = {0, 1};
uint8_t map_4x[4] = {0, 1, 2, 3};
uint8_t map_8x[8] = {5, 2, 4, 6, 0, 3, 7, 1};
+ 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));
}
/**
* below:
* SampleMap8x = {a, b, c, d, e, f, g, h};
*
- * Follow the logic for other sample counts.
+ * 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;