anv: Break SAMPLE_PATTERN and MULTISAMPLE emit into helpers

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1887>
This commit is contained in:
Jason Ekstrand
2019-03-14 18:02:49 -05:00
committed by Marge Bot
parent 983cebb5d2
commit a02891fdfd
3 changed files with 63 additions and 51 deletions

View File

@@ -156,18 +156,7 @@ genX(init_device_state)(struct anv_device *device)
#if GEN_GEN >= 8
anv_batch_emit(&batch, GENX(3DSTATE_WM_CHROMAKEY), ck);
/* See the Vulkan 1.0 spec Table 24.1 "Standard sample locations" and
* VkPhysicalDeviceFeatures::standardSampleLocations.
*/
anv_batch_emit(&batch, GENX(3DSTATE_SAMPLE_PATTERN), sp) {
GEN_SAMPLE_POS_1X(sp._1xSample);
GEN_SAMPLE_POS_2X(sp._2xSample);
GEN_SAMPLE_POS_4X(sp._4xSample);
GEN_SAMPLE_POS_8X(sp._8xSample);
#if GEN_GEN >= 9
GEN_SAMPLE_POS_16X(sp._16xSample);
#endif
}
genX(emit_sample_pattern)(&batch);
/* The BDW+ docs describe how to use the 3DSTATE_WM_HZ_OP instruction in the
* section titled, "Optimized Depth Buffer Clear and/or Stencil Buffer
@@ -320,6 +309,61 @@ genX(init_device_state)(struct anv_device *device)
return anv_queue_submit_simple_batch(&device->queue, &batch);
}
void
genX(emit_multisample)(struct anv_batch *batch, uint32_t samples)
{
anv_batch_emit(batch, GENX(3DSTATE_MULTISAMPLE), ms) {
ms.NumberofMultisamples = __builtin_ffs(samples) - 1;
ms.PixelLocation = CENTER;
#if GEN_GEN >= 8
/* The PRM says that this bit is valid only for DX9:
*
* SW can choose to set this bit only for DX9 API. DX10/OGL API's
* should not have any effect by setting or not setting this bit.
*/
ms.PixelPositionOffsetEnable = false;
#else
switch (samples) {
case 1:
GEN_SAMPLE_POS_1X(ms.Sample);
break;
case 2:
GEN_SAMPLE_POS_2X(ms.Sample);
break;
case 4:
GEN_SAMPLE_POS_4X(ms.Sample);
break;
case 8:
GEN_SAMPLE_POS_8X(ms.Sample);
break;
default:
break;
}
#endif
}
}
#if GEN_GEN >= 8
void
genX(emit_sample_pattern)(struct anv_batch *batch)
{
/* See the Vulkan 1.0 spec Table 24.1 "Standard sample locations" and
* VkPhysicalDeviceFeatures::standardSampleLocations.
*/
anv_batch_emit(batch, GENX(3DSTATE_SAMPLE_PATTERN), sp) {
GEN_SAMPLE_POS_1X(sp._1xSample);
GEN_SAMPLE_POS_2X(sp._2xSample);
GEN_SAMPLE_POS_4X(sp._4xSample);
GEN_SAMPLE_POS_8X(sp._8xSample);
#if GEN_GEN >= 9
GEN_SAMPLE_POS_16X(sp._16xSample);
#endif
}
}
#endif
static uint32_t
vk_to_gen_tex_filter(VkFilter filter, bool anisotropyEnable)
{