Browse Source

[vk] SL complete removal

eds-true-adreno-fixes
CamilleLaVey 3 weeks ago
committed by Caio Oliveira
parent
commit
7e875e9072
No known key found for this signature in database GPG Key ID: AAAE6C7FD4186B0C
  1. 37
      src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
  2. 103
      src/video_core/renderer_vulkan/vk_rasterizer.cpp
  3. 13
      src/video_core/renderer_vulkan/vk_rasterizer.h
  4. 8
      src/video_core/renderer_vulkan/vk_state_tracker.cpp
  5. 5
      src/video_core/renderer_vulkan/vk_state_tracker.h
  6. 6
      src/video_core/renderer_vulkan/vk_texture_cache.cpp
  7. 11
      src/video_core/vulkan_common/vulkan_device.cpp
  8. 17
      src/video_core/vulkan_common/vulkan_device.h
  9. 1
      src/video_core/vulkan_common/vulkan_wrapper.cpp
  10. 5
      src/video_core/vulkan_common/vulkan_wrapper.h

37
src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp

@ -862,9 +862,6 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
const bool alpha_to_one_supported = device.SupportsAlphaToOne();
const auto msaa_mode = key.state.msaa_mode.Value();
const VkSampleCountFlagBits vk_samples = MaxwellToVK::MsaaMode(msaa_mode);
const bool supports_sample_locations =
device.IsExtSampleLocationsSupported() && device.SupportsSampleLocationsFor(vk_samples);
VkPipelineMultisampleStateCreateInfo multisample_ci{
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
.pNext = nullptr,
@ -879,36 +876,6 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
key.state.alpha_to_one_enabled != 0 ? VK_TRUE : VK_FALSE,
};
struct SampleLocationsChain {
std::array<VkSampleLocationEXT, VideoCommon::MaxSampleLocationSlots> locations;
VkSampleLocationsInfoEXT info;
VkPipelineSampleLocationsStateCreateInfoEXT create;
};
std::optional<SampleLocationsChain> sample_locations_chain;
if (supports_sample_locations) {
sample_locations_chain.emplace();
auto& chain = *sample_locations_chain;
const auto [grid_width, grid_height] = VideoCommon::SampleLocationGridSize(msaa_mode);
const u32 samples_per_pixel = static_cast<u32>(VideoCommon::NumSamples(msaa_mode));
const u32 sample_locations_count = grid_width * grid_height * samples_per_pixel;
chain.locations.fill(VkSampleLocationEXT{0.5f, 0.5f});
chain.info = VkSampleLocationsInfoEXT{
.sType = VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT,
.pNext = nullptr,
.sampleLocationsPerPixel = vk_samples,
.sampleLocationGridSize = VkExtent2D{grid_width, grid_height},
.sampleLocationsCount = sample_locations_count,
.pSampleLocations = chain.locations.data(),
};
chain.create = VkPipelineSampleLocationsStateCreateInfoEXT{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT,
.pNext = nullptr,
.sampleLocationsEnable = VK_TRUE,
.sampleLocationsInfo = chain.info,
};
chain.create.sampleLocationsInfo.pSampleLocations = chain.locations.data();
chain.create.pNext = std::exchange(multisample_ci.pNext, &chain.create);
}
const VkPipelineDepthStencilStateCreateInfo depth_stencil_ci{
.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
@ -995,10 +962,6 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
VK_DYNAMIC_STATE_LINE_WIDTH,
};
if (supports_sample_locations) {
dynamic_states.push_back(VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT);
}
if (device.UsesAdvancedCoreDynamicState()) {
static constexpr std::array core_dynamic_states{
VK_DYNAMIC_STATE_BLEND_CONSTANTS,

103
src/video_core/renderer_vulkan/vk_rasterizer.cpp

@ -37,7 +37,6 @@
#include "video_core/renderer_vulkan/vk_update_descriptor.h"
#include "video_core/shader_cache.h"
#include "video_core/texture_cache/texture_cache_base.h"
#include "video_core/texture_cache/samples_helper.h"
#include "video_core/polygon_mode_utils.h"
#include "video_core/vulkan_common/vulkan_device.h"
#include "video_core/vulkan_common/vulkan_wrapper.h"
@ -51,33 +50,6 @@ using VideoCommon::ImageViewType;
namespace {
constexpr float SAMPLE_LOCATION_SCALE = 1.0f / 16.0f;
bool SampleLocationsEqual(const std::array<VkSampleLocationEXT, VideoCommon::MaxSampleLocationSlots>& lhs,
const std::array<VkSampleLocationEXT, VideoCommon::MaxSampleLocationSlots>& rhs,
u32 count) {
return std::equal(lhs.begin(), lhs.begin() + count, rhs.begin(), rhs.begin() + count,
[](const VkSampleLocationEXT& a, const VkSampleLocationEXT& b) {
return a.x == b.x && a.y == b.y;
});
}
std::array<VkSampleLocationEXT, VideoCommon::MaxSampleLocationSlots>
DecodeSampleLocationRegisters(const Maxwell& regs) {
std::array<VkSampleLocationEXT, VideoCommon::MaxSampleLocationSlots> decoded{};
size_t index = 0;
for (const auto& packed : regs.multisample_sample_locations) {
for (int slot = 0; slot < 4 && index < decoded.size(); ++slot, ++index) {
const auto [raw_x, raw_y] = packed.Location(slot);
decoded[index] = VkSampleLocationEXT{
.x = static_cast<float>(raw_x) * SAMPLE_LOCATION_SCALE,
.y = static_cast<float>(raw_y) * SAMPLE_LOCATION_SCALE,
};
}
}
return decoded;
}
struct DrawParams {
u32 base_instance;
u32 num_instances;
@ -1046,8 +1018,6 @@ void RasterizerVulkan::UpdateDynamicStates() {
UpdateDepthBounds(regs);
UpdateStencilFaces(regs);
UpdateLineWidth(regs);
UpdateSampleLocations(regs);
// EDS1: CullMode, DepthCompare, FrontFace, StencilOp, DepthBoundsTest, DepthTest, DepthWrite, StencilTest
if (device.IsExtExtendedDynamicStateSupported()) {
UpdateCullMode(regs);
@ -1706,79 +1676,6 @@ void RasterizerVulkan::UpdateStencilOp(Tegra::Engines::Maxwell3D::Regs& regs) {
}
}
void RasterizerVulkan::UpdateSampleLocations(Maxwell& regs) {
if (!device.IsExtSampleLocationsSupported()) {
return;
}
const auto msaa_mode = regs.anti_alias_samples_mode;
const VkSampleCountFlagBits vk_samples = MaxwellToVK::MsaaMode(msaa_mode);
if (!device.SupportsSampleLocationsFor(vk_samples)) {
return;
}
const auto [grid_width_u32, grid_height_u32] = VideoCommon::SampleLocationGridSize(msaa_mode);
const u32 grid_width = grid_width_u32;
const u32 grid_height = grid_height_u32;
const u32 samples_per_pixel = static_cast<u32>(VideoCommon::NumSamples(msaa_mode));
const u32 grid_cells = grid_width * grid_height;
const u32 sample_locations_count = grid_cells * samples_per_pixel;
ASSERT(sample_locations_count <= VideoCommon::MaxSampleLocationSlots);
const auto raw_locations = DecodeSampleLocationRegisters(regs);
std::array<VkSampleLocationEXT, VideoCommon::MaxSampleLocationSlots> resolved{};
for (u32 cell = 0; cell < grid_cells; ++cell) {
const u32 slot_base = cell * samples_per_pixel;
const u32 cell_x = cell % grid_width;
const u32 cell_y = cell / grid_width;
for (u32 sample = 0; sample < samples_per_pixel; ++sample) {
const VkSampleLocationEXT raw = raw_locations[slot_base + sample];
resolved[slot_base + sample] = VkSampleLocationEXT{
.x = static_cast<float>(cell_x) + raw.x,
.y = static_cast<float>(cell_y) + raw.y,
};
}
}
const VkExtent2D grid_size{
.width = grid_width,
.height = grid_height,
};
const bool pattern_changed =
!sample_location_state.initialized || sample_location_state.msaa_mode != msaa_mode ||
sample_location_state.grid_size.width != grid_size.width ||
sample_location_state.grid_size.height != grid_size.height ||
sample_location_state.samples_per_pixel != vk_samples ||
sample_location_state.locations_count != sample_locations_count ||
!SampleLocationsEqual(sample_location_state.locations, resolved, sample_locations_count);
const bool dirty = state_tracker.TouchSampleLocations() || pattern_changed;
if (!dirty) {
return;
}
scheduler.Record([resolved, grid_size, vk_samples, sample_locations_count](
vk::CommandBuffer cmdbuf) {
VkSampleLocationsInfoEXT info{
.sType = VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT,
.pNext = nullptr,
.sampleLocationsPerPixel = vk_samples,
.sampleLocationGridSize = grid_size,
.sampleLocationsCount = sample_locations_count,
.pSampleLocations = resolved.data(),
};
cmdbuf.SetSampleLocationsEXT(info);
});
sample_location_state.msaa_mode = msaa_mode;
sample_location_state.grid_size = grid_size;
sample_location_state.samples_per_pixel = vk_samples;
sample_location_state.locations_count = sample_locations_count;
sample_location_state.locations = resolved;
sample_location_state.initialized = true;
}
void RasterizerVulkan::UpdateLogicOp(Tegra::Engines::Maxwell3D::Regs& regs) {
if (!state_tracker.TouchLogicOp()) {
return;

13
src/video_core/renderer_vulkan/vk_rasterizer.h

@ -169,8 +169,6 @@ private:
void UpdateDepthBounds(Tegra::Engines::Maxwell3D::Regs& regs);
void UpdateStencilFaces(Tegra::Engines::Maxwell3D::Regs& regs);
void UpdateLineWidth(Tegra::Engines::Maxwell3D::Regs& regs);
void UpdateSampleLocations(Tegra::Engines::Maxwell3D::Regs& regs);
void UpdateCullMode(Tegra::Engines::Maxwell3D::Regs& regs);
void UpdateDepthBoundsTestEnable(Tegra::Engines::Maxwell3D::Regs& regs);
void UpdateDepthTestEnable(Tegra::Engines::Maxwell3D::Regs& regs);
@ -195,17 +193,6 @@ private:
void UpdateVertexInput(Tegra::Engines::Maxwell3D::Regs& regs);
struct SampleLocationState {
Tegra::Texture::MsaaMode msaa_mode{Tegra::Texture::MsaaMode::Msaa1x1};
VkExtent2D grid_size{1u, 1u};
VkSampleCountFlagBits samples_per_pixel{VK_SAMPLE_COUNT_1_BIT};
u32 locations_count{VideoCommon::MaxSampleLocationSlots};
std::array<VkSampleLocationEXT, VideoCommon::MaxSampleLocationSlots> locations{};
bool initialized = false;
};
SampleLocationState sample_location_state{};
Tegra::GPU& gpu;
Tegra::MaxwellDeviceMemoryManager& device_memory;

8
src/video_core/renderer_vulkan/vk_state_tracker.cpp

@ -40,7 +40,6 @@ Flags MakeInvalidationFlags() {
StencilWriteMask,
StencilCompare,
LineWidth,
SampleLocations,
CullMode,
DepthBoundsEnable,
DepthTestEnable,
@ -130,12 +129,6 @@ void SetupDirtyLineWidth(Tables& tables) {
tables[0][OFF(line_width_aliased)] = LineWidth;
}
void SetupDirtySampleLocations(Tables& tables) {
FillBlock(tables[0], OFF(multisample_sample_locations),
NUM(multisample_sample_locations), SampleLocations);
tables[0][OFF(anti_alias_samples_mode)] = SampleLocations;
}
void SetupDirtyCullMode(Tables& tables) {
auto& table = tables[0];
table[OFF(gl_cull_face)] = CullMode;
@ -253,7 +246,6 @@ void StateTracker::SetupTables(Tegra::Control::ChannelState& channel_state) {
SetupDirtyDepthBounds(tables);
SetupDirtyStencilProperties(tables);
SetupDirtyLineWidth(tables);
SetupDirtySampleLocations(tables);
SetupDirtyCullMode(tables);
SetupDirtyStateEnable(tables);
SetupDirtyDepthCompareOp(tables);

5
src/video_core/renderer_vulkan/vk_state_tracker.h

@ -42,7 +42,6 @@ enum : u8 {
StencilWriteMask,
StencilCompare,
LineWidth,
SampleLocations,
CullMode,
DepthBoundsEnable,
@ -186,10 +185,6 @@ public:
return Exchange(Dirty::LineWidth, false);
}
bool TouchSampleLocations() const {
return Exchange(Dirty::SampleLocations, false);
}
bool TouchCullMode() {
return Exchange(Dirty::CullMode, false);
}

6
src/video_core/renderer_vulkan/vk_texture_cache.cpp

@ -163,11 +163,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
(surface_type == VideoCore::Surface::SurfaceType::Depth ||
surface_type == VideoCore::Surface::SurfaceType::Stencil ||
surface_type == VideoCore::Surface::SurfaceType::DepthStencil);
const bool needs_sample_location_compat =
is_depth_stencil_attachment && device.SupportsSampleLocationsFor(sample_count);
if (needs_sample_location_compat) {
flags |= VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT;
}
const auto [samples_x, samples_y] = VideoCommon::SamplesLog2(info.num_samples);
return VkImageCreateInfo{
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,

11
src/video_core/vulkan_common/vulkan_device.cpp

@ -1204,11 +1204,6 @@ 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;
@ -1486,12 +1481,6 @@ void Device::RemoveUnsuitableExtensions() {
RemoveExtensionFeatureIfUnsuitable(extensions.transform_feedback, features.transform_feedback,
VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME);
// VK_EXT_sample_locations
extensions.sample_locations =
loaded_extensions.contains(VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME);
RemoveExtensionIfUnsuitable(extensions.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;

17
src/video_core/vulkan_common/vulkan_device.h

@ -80,7 +80,6 @@ VK_DEFINE_HANDLE(VmaAllocator)
EXTENSION(EXT, DEPTH_RANGE_UNRESTRICTED, depth_range_unrestricted) \
EXTENSION(EXT, MEMORY_BUDGET, memory_budget) \
EXTENSION(EXT, ROBUSTNESS_2, robustness_2) \
EXTENSION(EXT, SAMPLE_LOCATIONS, sample_locations) \
EXTENSION(EXT, SAMPLER_FILTER_MINMAX, sampler_filter_minmax) \
EXTENSION(EXT, SHADER_STENCIL_EXPORT, shader_stencil_export) \
EXTENSION(EXT, SHADER_VIEWPORT_INDEX_LAYER, shader_viewport_index_layer) \
@ -345,10 +344,6 @@ 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 {
@ -578,17 +573,6 @@ public:
return extensions.transform_feedback;
}
/// 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 {
return features.transform_feedback.geometryStreams;
@ -1063,7 +1047,6 @@ private:
VkPhysicalDevicePushDescriptorPropertiesKHR push_descriptor{};
VkPhysicalDeviceSubgroupSizeControlProperties subgroup_size_control{};
VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback{};
VkPhysicalDeviceSampleLocationsPropertiesEXT sample_locations{};
VkPhysicalDeviceMaintenance5PropertiesKHR maintenance5{};
VkPhysicalDeviceMultiDrawPropertiesEXT multi_draw{};

1
src/video_core/vulkan_common/vulkan_wrapper.cpp

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

5
src/video_core/vulkan_common/vulkan_wrapper.h

@ -266,7 +266,6 @@ struct DeviceDispatch : InstanceDispatch {
PFN_vkCmdSetColorWriteMaskEXT vkCmdSetColorWriteMaskEXT{};
PFN_vkCmdSetColorBlendEnableEXT vkCmdSetColorBlendEnableEXT{};
PFN_vkCmdSetColorBlendEquationEXT vkCmdSetColorBlendEquationEXT{};
PFN_vkCmdSetSampleLocationsEXT vkCmdSetSampleLocationsEXT{};
PFN_vkCmdWaitEvents vkCmdWaitEvents{};
PFN_vkCreateBuffer vkCreateBuffer{};
PFN_vkCreateBufferView vkCreateBufferView{};
@ -1526,10 +1525,6 @@ 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);
}

Loading…
Cancel
Save