diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 8179a35906c..1c384cde1ff 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -3540,8 +3540,10 @@ VkResult anv_CreateDevice( if (result != VK_SUCCESS) goto fail_ray_query_bo; - if (device->info->ver >= 12 && - device->vk.enabled_extensions.KHR_fragment_shading_rate) { + /* Emit the CPS states before running the initialization batch as those + * structures are referenced. + */ + if (device->info->ver >= 12) { uint32_t n_cps_states = 3 * 3; /* All combinaisons of X by Y CP sizes (1, 2, 4) */ if (device->info->has_coarse_pixel_primitive_and_cb) diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c index b084ece843a..92ba28b0f32 100644 --- a/src/intel/vulkan/genX_state.c +++ b/src/intel/vulkan/genX_state.c @@ -178,7 +178,10 @@ init_common_queue_state(struct anv_queue *queue, struct anv_batch *batch) device->l3_config = cfg; #endif -#if GFX_VERx10 >= 125 + /* Emit STATE_BASE_ADDRESS on Gfx12+ because we set a default CPS_STATE and + * those are relative to STATE_BASE_ADDRESS::DynamicStateBaseAddress. + */ +#if GFX_VERx >= 12 /* GEN:BUG:1607854226: * * Non-pipelined state has issues with not applying in MEDIA/GPGPU mode. @@ -452,6 +455,21 @@ init_render_queue_state(struct anv_queue *queue) init_common_queue_state(queue, &batch); + /* Because 3DSTATE_CPS::CoarsePixelShadingStateArrayPointer is relative to + * the dynamic state base address we need to emit this instruction after + * STATE_BASE_ADDRESS in init_common_queue_state(). + */ +#if GFX_VER == 11 + anv_batch_emit(&batch, GENX(3DSTATE_CPS), cps); +#elif GFX_VER >= 12 + anv_batch_emit(&batch, GENX(3DSTATE_CPS_POINTERS), cps) { + assert(device->cps_states.alloc_size != 0); + /* Offset 0 is the disabled state */ + cps.CoarsePixelShadingStateArrayPointer = + device->cps_states.offset; + } +#endif + anv_batch_emit(&batch, GENX(MI_BATCH_BUFFER_END), bbe); assert(batch.next <= batch.end); @@ -542,15 +560,19 @@ genX(init_cps_device_state)(struct anv_device *device) /* Disabled CPS mode */ for (uint32_t __v = 0; __v < MAX_VIEWPORTS; __v++) { + /* ICL PRMs, Volume 2d: Command Reference: Structures: 3DSTATE_CPS_BODY: + * + * "It is an INVALID configuration to set the CPS mode other than + * CPS_MODE_NONE and request per-sample dispatch in 3DSTATE_PS_EXTRA. + * Such configuration should be disallowed at the API level, and + * rendering results are undefined." + * + * Since we select this state when per coarse pixel is disabled and that + * includes when per-sample dispatch is enabled, we need to ensure this + * is set to NONE. + */ struct GENX(CPS_STATE) cps_state = { - .CoarsePixelShadingMode = CPS_MODE_CONSTANT, - .MinCPSizeX = 1, - .MinCPSizeY = 1, -#if GFX_VERx10 >= 125 - .Combiner0OpcodeforCPsize = PASSTHROUGH, - .Combiner1OpcodeforCPsize = PASSTHROUGH, -#endif /* GFX_VERx10 >= 125 */ - + .CoarsePixelShadingMode = CPS_MODE_NONE, }; GENX(CPS_STATE_pack)(NULL, cps_state_ptr, &cps_state);