[maxwell, vk] VK_EXT_Sample_Locations

This commit is contained in:
CamilleLaVey 2025-11-26 00:01:42 -04:00 committed by lizzie
parent 48ea546f5c
commit 4109b4f4e4
9 changed files with 133 additions and 2 deletions

View file

@ -1081,6 +1081,11 @@ bool Device::GetSuitability(bool requires_swapchain) {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
SetNext(next, properties.transform_feedback);
}
if (extensions.sample_locations) {
properties.sample_locations.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT;
SetNext(next, properties.sample_locations);
}
if (extensions.maintenance5) {
properties.maintenance5.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR;
@ -1315,6 +1320,11 @@ void Device::RemoveUnsuitableExtensions() {
RemoveExtensionFeatureIfUnsuitable(extensions.transform_feedback, features.transform_feedback,
VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME);
// VK_EXT_sample_locations
extensions.sample_locations = features.sample_locations.sampleLocations;
RemoveExtensionFeatureIfUnsuitable(extensions.sample_locations, features.sample_locations,
VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME);
// VK_EXT_vertex_input_dynamic_state
extensions.vertex_input_dynamic_state =
features.vertex_input_dynamic_state.vertexInputDynamicState;

View file

@ -62,6 +62,7 @@ VK_DEFINE_HANDLE(VmaAllocator)
FEATURE(EXT, ProvokingVertex, PROVOKING_VERTEX, provoking_vertex) \
FEATURE(EXT, Robustness2, ROBUSTNESS_2, robustness2) \
FEATURE(EXT, TransformFeedback, TRANSFORM_FEEDBACK, transform_feedback) \
FEATURE(EXT, SampleLocations, SAMPLE_LOCATIONS, sample_locations) \
FEATURE(EXT, VertexInputDynamicState, VERTEX_INPUT_DYNAMIC_STATE, vertex_input_dynamic_state) \
FEATURE(KHR, Maintenance5, MAINTENANCE_5, maintenance5) \
FEATURE(KHR, Maintenance6, MAINTENANCE_6, maintenance6) \
@ -340,6 +341,11 @@ public:
return properties.float_controls;
}
/// Returns sample location properties (VK_EXT_sample_locations).
const VkPhysicalDeviceSampleLocationsPropertiesEXT& SampleLocationProperties() const {
return properties.sample_locations;
}
/// Returns true if ASTC is natively supported.
bool IsOptimalAstcSupported() const {
return features.features.textureCompressionASTC_LDR;
@ -548,6 +554,17 @@ public:
return extensions.transform_feedback &&
properties.transform_feedback.transformFeedbackQueries;
}
/// Returns true if the device supports VK_EXT_sample_locations.
bool IsExtSampleLocationsSupported() const {
return extensions.sample_locations;
}
/// Returns true if the device supports custom sample locations for the given sample count.
bool SupportsSampleLocationsFor(VkSampleCountFlagBits samples) const {
return extensions.sample_locations &&
(properties.sample_locations.sampleLocationSampleCounts & samples) != 0;
}
/// Returns true if the device supports VK_EXT_transform_feedback properly.
bool AreTransformFeedbackGeometryStreamsSupported() const {
@ -995,6 +1012,7 @@ private:
VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor{};
VkPhysicalDeviceSubgroupSizeControlProperties subgroup_size_control{};
VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback{};
VkPhysicalDeviceSampleLocationsPropertiesEXT sample_locations{};
VkPhysicalDeviceMaintenance5PropertiesKHR maintenance5{};
VkPhysicalDeviceProperties properties{};

View file

@ -164,6 +164,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept {
X(vkCmdSetColorWriteMaskEXT);
X(vkCmdSetColorBlendEnableEXT);
X(vkCmdSetColorBlendEquationEXT);
X(vkCmdSetSampleLocationsEXT);
X(vkCmdResolveImage);
X(vkCreateBuffer);
X(vkCreateBufferView);

View file

@ -266,6 +266,7 @@ struct DeviceDispatch : InstanceDispatch {
PFN_vkCmdSetColorWriteMaskEXT vkCmdSetColorWriteMaskEXT{};
PFN_vkCmdSetColorBlendEnableEXT vkCmdSetColorBlendEnableEXT{};
PFN_vkCmdSetColorBlendEquationEXT vkCmdSetColorBlendEquationEXT{};
PFN_vkCmdSetSampleLocationsEXT vkCmdSetSampleLocationsEXT{};
PFN_vkCmdWaitEvents vkCmdWaitEvents{};
PFN_vkCreateBuffer vkCreateBuffer{};
PFN_vkCreateBufferView vkCreateBufferView{};
@ -1513,6 +1514,10 @@ public:
dld->vkCmdSetColorBlendEquationEXT(handle, first, equations.size(), equations.data());
}
void SetSampleLocationsEXT(const VkSampleLocationsInfoEXT& info) const noexcept {
dld->vkCmdSetSampleLocationsEXT(handle, &info);
}
void SetLineWidth(float line_width) const noexcept {
dld->vkCmdSetLineWidth(handle, line_width);
}