radv: implement VK_EXT_sample_locations and disable it

Basically, this extension allows applications to use custom
sample locations. It doesn't support variable sample locations
during subpass. Note that we don't have to upload the user
sample locations because the spec doesn't allow this.

The extension is currently disabled because the driver needs to
support variable sample locations during layout transitions. The
depth decompress needs to know them and that's a bit invasive.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
Samuel Pitoiset
2019-05-16 11:55:02 +02:00
parent e917bb7ad4
commit da26013eb7
6 changed files with 315 additions and 7 deletions

View File

@@ -1267,6 +1267,8 @@ static unsigned radv_dynamic_state_mask(VkDynamicState state)
return RADV_DYNAMIC_STENCIL_REFERENCE;
case VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT:
return RADV_DYNAMIC_DISCARD_RECTANGLE;
case VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT:
return RADV_DYNAMIC_SAMPLE_LOCATIONS;
default:
unreachable("Unhandled dynamic state");
}
@@ -1297,6 +1299,11 @@ static uint32_t radv_pipeline_needed_dynamic_state(const VkGraphicsPipelineCreat
if (!vk_find_struct_const(pCreateInfo->pNext, PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT))
states &= ~RADV_DYNAMIC_DISCARD_RECTANGLE;
if (!pCreateInfo->pMultisampleState ||
!vk_find_struct_const(pCreateInfo->pMultisampleState->pNext,
PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT))
states &= ~RADV_DYNAMIC_SAMPLE_LOCATIONS;
/* TODO: blend constants & line width. */
return states;
@@ -1426,6 +1433,29 @@ radv_pipeline_init_dynamic_state(struct radv_pipeline *pipeline,
}
}
if (needed_states & RADV_DYNAMIC_SAMPLE_LOCATIONS) {
const VkPipelineSampleLocationsStateCreateInfoEXT *sample_location_info =
vk_find_struct_const(pCreateInfo->pMultisampleState->pNext,
PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT);
/* If sampleLocationsEnable is VK_FALSE, the default sample
* locations are used and the values specified in
* sampleLocationsInfo are ignored.
*/
if (sample_location_info->sampleLocationsEnable) {
const VkSampleLocationsInfoEXT *pSampleLocationsInfo =
&sample_location_info->sampleLocationsInfo;
assert(pSampleLocationsInfo->sampleLocationsCount <= MAX_SAMPLE_LOCATIONS);
dynamic->sample_location.per_pixel = pSampleLocationsInfo->sampleLocationsPerPixel;
dynamic->sample_location.grid_size = pSampleLocationsInfo->sampleLocationGridSize;
dynamic->sample_location.count = pSampleLocationsInfo->sampleLocationsCount;
typed_memcpy(&dynamic->sample_location.locations[0],
pSampleLocationsInfo->pSampleLocations,
pSampleLocationsInfo->sampleLocationsCount);
}
}
pipeline->dynamic_state.mask = states;
}