mesa/src/intel
Danylo Piliaiev c8abe03f3b i965,iris,anv: Make alpha to coverage work with sample mask
From "Alpha Coverage" section of SKL PRM Volume 7:
 "If Pixel Shader outputs oMask, AlphaToCoverage is disabled in
  hardware, regardless of the state setting for this feature."

From OpenGL spec 4.6, "15.2 Shader Execution":
 "The built-in integer array gl_SampleMask can be used to change
 the sample coverage for a fragment from within the shader."

From OpenGL spec 4.6, "17.3.1 Alpha To Coverage":
 "If SAMPLE_ALPHA_TO_COVERAGE is enabled, a temporary coverage value
  is generated where each bit is determined by the alpha value at the
  corresponding sample location. The temporary coverage value is then
  ANDed with the fragment coverage value to generate a new fragment
  coverage value."

Similar wording could be found in Vulkan spec 1.1.100
"25.6. Multisample Coverage"

Thus we need to compute alpha to coverage dithering manually in shader
and replace sample mask store with the bitwise-AND of sample mask and
alpha to coverage dithering.

The following formula is used to compute final sample mask:
  m = int(16.0 * clamp(src0_alpha, 0.0, 1.0))
  dither_mask = 0x1111 * ((0xfea80 >> (m & ~3)) & 0xf) |
     0x0808 * (m & 2) | 0x0100 * (m & 1)
  sample_mask = sample_mask & dither_mask
Credits to Francisco Jerez <currojerez@riseup.net> for creating it.

It gives a number of ones proportional to the alpha for 2, 4, 8 or 16
least significant bits of the result.

GEN6 hardware does not have issue with simultaneous usage of sample mask
and alpha to coverage however due to the wrong sending order of oMask
and src0_alpha it is still affected by it.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109743

Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
2019-03-25 13:54:55 -07:00
..
blorp intel/blorp: Make swizzle_color_value public. 2019-03-20 16:46:25 -07:00
common intel/decoders: silence uninitialized variable warnings in gen_print_batch() 2019-03-08 10:23:11 -07:00
compiler i965,iris,anv: Make alpha to coverage work with sample mask 2019-03-25 13:54:55 -07:00
dev intel: fix urb size for CFL GT1 2019-02-22 11:53:49 +00:00
genxml anv/icl: Add WA_2204188704 to disable pixel shader panic dispatch 2019-03-19 14:42:19 -07:00
isl intel/isl: Add isl_format_has_color_component() function. 2019-03-20 16:46:25 -07:00
tools intel/error2aub: support older style engine names 2019-03-08 11:01:14 +00:00
vulkan i965,iris,anv: Make alpha to coverage work with sample mask 2019-03-25 13:54:55 -07:00
Android.blorp.mk intel: android: remove libdrm_intel requirement 2017-03-30 19:07:23 +01:00
Android.common.mk android: static link with libexpat with Android O+ 2019-03-25 10:11:57 +02:00
Android.compiler.mk android: fix build issues with brw_nir_trig_workarounds.c 2017-10-04 07:39:05 +03:00
Android.dev.mk drm-uapi: use local files, not system libdrm 2019-02-14 11:20:00 +00:00
Android.genxml.mk intel/genxml/icl: Generate packing headers 2018-02-15 16:14:55 -08:00
Android.isl.mk android: intel/isl: remove redundant building rules 2019-02-22 07:56:11 +02:00
Android.mk intel: Add missing includes for building on Android 2018-03-06 00:14:22 -08:00
Android.vulkan.mk android: static link with libexpat with Android O+ 2019-03-25 10:11:57 +02:00
Makefile.am build: move imgui out of src/intel/tools to be reused 2019-02-21 18:06:05 +00:00
Makefile.blorp.am blorp: automake: add TODO to the tarball 2017-02-24 17:37:00 +00:00
Makefile.common.am automake: intel: correctly append to the LIBADD variable 2017-11-08 14:23:57 +00:00
Makefile.compiler.am i965/vec4/dce: Don't narrow the write mask if the flags are used 2018-12-17 13:47:06 -08:00
Makefile.dev.am intel: Split gen_device_info out into libintel_dev 2018-03-05 09:47:37 -08:00
Makefile.genxml.am intel: genxml: automake: include gen_bits_header.py in the tarball 2017-04-05 13:16:28 +01:00
Makefile.isl.am isl: fix automake build when sse41 is not supported 2019-03-18 08:51:57 +02:00
Makefile.sources intel/fs: Drop the fs_surface_builder 2019-02-28 16:58:20 -06:00
Makefile.tools.am intel/tools: new i965_disasm tool 2018-08-29 11:19:55 -07:00
Makefile.vulkan.am drm-uapi: use local files, not system libdrm 2019-02-14 11:20:00 +00:00
meson.build intel: compiler option msse2 and mstackrealign 2018-09-07 13:45:46 +01:00