Skip to content

Commit df1d0d5

Browse files
committed
renderer_vulkan: Restore Vulkan version to 1.3
1 parent 53ca64f commit df1d0d5

File tree

7 files changed

+55
-75
lines changed

7 files changed

+55
-75
lines changed

src/shader_recompiler/backend/spirv/emit_spirv.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ void DefineEntryPoint(const Info& info, EmitContext& ctx, Id main) {
335335
ctx.AddExecutionMode(main, spv::ExecutionMode::OriginUpperLeft);
336336
}
337337
if (info.has_discard) {
338-
ctx.AddExtension("SPV_EXT_demote_to_helper_invocation");
339-
ctx.AddCapability(spv::Capability::DemoteToHelperInvocationEXT);
338+
ctx.AddCapability(spv::Capability::DemoteToHelperInvocation);
340339
}
341340
if (info.stores.GetAny(IR::Attribute::Depth)) {
342341
ctx.AddExecutionMode(main, spv::ExecutionMode::DepthReplacing);

src/video_core/renderer_vulkan/host_passes/pp_pass.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void PostProcessingPass::Create(vk::Device device) {
7878
const std::array pp_color_formats{
7979
vk::Format::eB8G8R8A8Unorm, // swapchain.GetSurfaceFormat().format,
8080
};
81-
const vk::PipelineRenderingCreateInfoKHR pipeline_rendering_ci{
81+
const vk::PipelineRenderingCreateInfo pipeline_rendering_ci{
8282
.colorAttachmentCount = pp_color_formats.size(),
8383
.pColorAttachmentFormats = pp_color_formats.data(),
8484
};

src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,21 @@ GraphicsPipeline::GraphicsPipeline(
122122
};
123123

124124
boost::container::static_vector<vk::DynamicState, 20> dynamic_states = {
125-
vk::DynamicState::eViewportWithCountEXT, vk::DynamicState::eScissorWithCountEXT,
126-
vk::DynamicState::eBlendConstants, vk::DynamicState::eDepthTestEnableEXT,
127-
vk::DynamicState::eDepthWriteEnableEXT, vk::DynamicState::eDepthCompareOpEXT,
128-
vk::DynamicState::eDepthBiasEnableEXT, vk::DynamicState::eDepthBias,
129-
vk::DynamicState::eStencilTestEnableEXT, vk::DynamicState::eStencilReference,
130-
vk::DynamicState::eStencilCompareMask, vk::DynamicState::eStencilWriteMask,
131-
vk::DynamicState::eStencilOpEXT, vk::DynamicState::eCullModeEXT,
132-
vk::DynamicState::eFrontFaceEXT,
125+
vk::DynamicState::eViewportWithCount, vk::DynamicState::eScissorWithCount,
126+
vk::DynamicState::eBlendConstants, vk::DynamicState::eDepthTestEnable,
127+
vk::DynamicState::eDepthWriteEnable, vk::DynamicState::eDepthCompareOp,
128+
vk::DynamicState::eDepthBiasEnable, vk::DynamicState::eDepthBias,
129+
vk::DynamicState::eStencilTestEnable, vk::DynamicState::eStencilReference,
130+
vk::DynamicState::eStencilCompareMask, vk::DynamicState::eStencilWriteMask,
131+
vk::DynamicState::eStencilOp, vk::DynamicState::eCullMode,
132+
vk::DynamicState::eFrontFace,
133133
};
134134

135135
if (instance.IsPrimitiveRestartDisableSupported()) {
136-
dynamic_states.push_back(vk::DynamicState::ePrimitiveRestartEnableEXT);
136+
dynamic_states.push_back(vk::DynamicState::ePrimitiveRestartEnable);
137137
}
138138
if (instance.IsDepthBoundsSupported()) {
139-
dynamic_states.push_back(vk::DynamicState::eDepthBoundsTestEnableEXT);
139+
dynamic_states.push_back(vk::DynamicState::eDepthBoundsTestEnable);
140140
dynamic_states.push_back(vk::DynamicState::eDepthBounds);
141141
}
142142
if (instance.IsDynamicColorWriteMaskSupported()) {
@@ -145,7 +145,7 @@ GraphicsPipeline::GraphicsPipeline(
145145
if (instance.IsVertexInputDynamicState()) {
146146
dynamic_states.push_back(vk::DynamicState::eVertexInputEXT);
147147
} else if (!vertex_bindings.empty()) {
148-
dynamic_states.push_back(vk::DynamicState::eVertexInputBindingStrideEXT);
148+
dynamic_states.push_back(vk::DynamicState::eVertexInputBindingStride);
149149
}
150150

151151
const vk::PipelineDynamicStateCreateInfo dynamic_info = {
@@ -212,7 +212,7 @@ GraphicsPipeline::GraphicsPipeline(
212212
});
213213
}
214214

215-
const vk::PipelineRenderingCreateInfoKHR pipeline_rendering_ci = {
215+
const vk::PipelineRenderingCreateInfo pipeline_rendering_ci = {
216216
.colorAttachmentCount = key.num_color_attachments,
217217
.pColorAttachmentFormats = key.color_formats.data(),
218218
.depthAttachmentFormat = key.depth_format,

src/video_core/renderer_vulkan/vk_instance.cpp

+17-38
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,14 @@ std::string Instance::GetDriverVersionName() {
203203
}
204204

205205
bool Instance::CreateDevice() {
206-
const vk::StructureChain feature_chain = physical_device.getFeatures2<
207-
vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVulkan11Features,
208-
vk::PhysicalDeviceVulkan12Features, vk::PhysicalDeviceRobustness2FeaturesEXT,
209-
vk::PhysicalDeviceExtendedDynamicState3FeaturesEXT,
210-
vk::PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT,
211-
vk::PhysicalDevicePortabilitySubsetFeaturesKHR>();
206+
const vk::StructureChain feature_chain =
207+
physical_device
208+
.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVulkan11Features,
209+
vk::PhysicalDeviceVulkan12Features, vk::PhysicalDeviceVulkan13Features,
210+
vk::PhysicalDeviceRobustness2FeaturesEXT,
211+
vk::PhysicalDeviceExtendedDynamicState3FeaturesEXT,
212+
vk::PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT,
213+
vk::PhysicalDevicePortabilitySubsetFeaturesKHR>();
212214
features = feature_chain.get().features;
213215

214216
const vk::StructureChain properties_chain = physical_device.getProperties2<
@@ -240,18 +242,6 @@ bool Instance::CreateDevice() {
240242
return false;
241243
};
242244

243-
// These extensions are promoted by Vulkan 1.3, but for greater compatibility we use Vulkan 1.2
244-
// with extensions.
245-
ASSERT(add_extension(VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME));
246-
ASSERT(add_extension(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME));
247-
ASSERT(add_extension(VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME));
248-
ASSERT(add_extension(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME));
249-
ASSERT(add_extension(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME));
250-
ASSERT(add_extension(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME));
251-
ASSERT(add_extension(VK_EXT_TOOLING_INFO_EXTENSION_NAME) ||
252-
driver_id == vk::DriverId::eIntelProprietaryWindows);
253-
ASSERT(add_extension(VK_KHR_MAINTENANCE_4_EXTENSION_NAME));
254-
255245
// Required
256246
ASSERT(add_extension(VK_KHR_SWAPCHAIN_EXTENSION_NAME));
257247
ASSERT(add_extension(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME));
@@ -324,6 +314,7 @@ bool Instance::CreateDevice() {
324314
feature_chain.get<vk::PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT>();
325315
const auto vk11_features = feature_chain.get<vk::PhysicalDeviceVulkan11Features>();
326316
const auto vk12_features = feature_chain.get<vk::PhysicalDeviceVulkan12Features>();
317+
const auto vk13_features = feature_chain.get<vk::PhysicalDeviceVulkan13Features>();
327318
vk::StructureChain device_chain = {
328319
vk::DeviceCreateInfo{
329320
.queueCreateInfoCount = 1u,
@@ -372,26 +363,14 @@ bool Instance::CreateDevice() {
372363
.hostQueryReset = vk12_features.hostQueryReset,
373364
.timelineSemaphore = vk12_features.timelineSemaphore,
374365
},
375-
// Vulkan 1.3 promoted extensions
376-
vk::PhysicalDeviceDynamicRenderingFeaturesKHR{
377-
.dynamicRendering = true,
378-
},
379-
vk::PhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT{
380-
.shaderDemoteToHelperInvocation = true,
381-
},
382-
vk::PhysicalDeviceSynchronization2Features{
383-
.synchronization2 = true,
384-
},
385-
vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT{
386-
.extendedDynamicState = true,
387-
},
388-
vk::PhysicalDeviceExtendedDynamicState2FeaturesEXT{
389-
.extendedDynamicState2 = true,
390-
},
391-
vk::PhysicalDeviceMaintenance4FeaturesKHR{
392-
.maintenance4 = true,
366+
vk::PhysicalDeviceVulkan13Features{
367+
.robustImageAccess = vk13_features.robustImageAccess,
368+
.shaderDemoteToHelperInvocation = vk13_features.shaderDemoteToHelperInvocation,
369+
.synchronization2 = vk13_features.synchronization2,
370+
.dynamicRendering = vk13_features.dynamicRendering,
371+
.maintenance4 = vk13_features.maintenance4,
393372
},
394-
// Other extensions
373+
// Extensions
395374
vk::PhysicalDeviceCustomBorderColorFeaturesEXT{
396375
.customBorderColors = true,
397376
.customBorderColorWithoutFormat = true,
@@ -547,7 +526,7 @@ void Instance::CollectToolingInfo() {
547526
// Currently causes issues with Reshade on AMD proprietary, disabled until fix released.
548527
return;
549528
}
550-
const auto [tools_result, tools] = physical_device.getToolPropertiesEXT();
529+
const auto [tools_result, tools] = physical_device.getToolProperties();
551530
if (tools_result != vk::Result::eSuccess) {
552531
LOG_ERROR(Render_Vulkan, "Could not get Vulkan tool properties: {}",
553532
vk::to_string(tools_result));

src/video_core/renderer_vulkan/vk_pipeline_cache.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ using Shader::LogicalStage;
2626
using Shader::Stage;
2727
using Shader::VsOutput;
2828

29+
constexpr static auto SpirvVersion1_6 = 0x00010600U;
30+
2931
constexpr static std::array DescriptorHeapSizes = {
3032
vk::DescriptorPoolSize{vk::DescriptorType::eUniformBuffer, 8192},
3133
vk::DescriptorPoolSize{vk::DescriptorType::eStorageBuffer, 1024},
@@ -192,7 +194,7 @@ PipelineCache::PipelineCache(const Instance& instance_, Scheduler& scheduler_,
192194
desc_heap{instance, scheduler.GetMasterSemaphore(), DescriptorHeapSizes} {
193195
const auto& vk12_props = instance.GetVk12Properties();
194196
profile = Shader::Profile{
195-
.supported_spirv = instance.ApiVersion() >= VK_API_VERSION_1_3 ? 0x00010600U : 0x00010500U,
197+
.supported_spirv = SpirvVersion1_6,
196198
.subgroup_size = instance.SubgroupSize(),
197199
.support_fp32_denorm_preserve = bool(vk12_props.shaderDenormPreserveFloat32),
198200
.support_fp32_denorm_flush = bool(vk12_props.shaderDenormFlushToZeroFloat32),

src/video_core/renderer_vulkan/vk_platform.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class WindowSDL;
1818

1919
namespace Vulkan {
2020

21-
constexpr u32 TargetVulkanApiVersion = VK_API_VERSION_1_2;
21+
constexpr u32 TargetVulkanApiVersion = VK_API_VERSION_1_3;
2222

2323
vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::WindowSDL& emu_window);
2424

src/video_core/renderer_vulkan/vk_scheduler.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -170,29 +170,29 @@ void Scheduler::SubmitExecution(SubmitInfo& info) {
170170
void DynamicState::Commit(const Instance& instance, const vk::CommandBuffer& cmdbuf) {
171171
if (dirty_state.viewports) {
172172
dirty_state.viewports = false;
173-
cmdbuf.setViewportWithCountEXT(viewports);
173+
cmdbuf.setViewportWithCount(viewports);
174174
}
175175
if (dirty_state.scissors) {
176176
dirty_state.scissors = false;
177-
cmdbuf.setScissorWithCountEXT(scissors);
177+
cmdbuf.setScissorWithCount(scissors);
178178
}
179179
if (dirty_state.depth_test_enabled) {
180180
dirty_state.depth_test_enabled = false;
181-
cmdbuf.setDepthTestEnableEXT(depth_test_enabled);
181+
cmdbuf.setDepthTestEnable(depth_test_enabled);
182182
}
183183
if (dirty_state.depth_write_enabled) {
184184
dirty_state.depth_write_enabled = false;
185185
// Note that this must be set in a command buffer even if depth test is disabled.
186-
cmdbuf.setDepthWriteEnableEXT(depth_write_enabled);
186+
cmdbuf.setDepthWriteEnable(depth_write_enabled);
187187
}
188188
if (depth_test_enabled && dirty_state.depth_compare_op) {
189189
dirty_state.depth_compare_op = false;
190-
cmdbuf.setDepthCompareOpEXT(depth_compare_op);
190+
cmdbuf.setDepthCompareOp(depth_compare_op);
191191
}
192192
if (dirty_state.depth_bounds_test_enabled) {
193193
dirty_state.depth_bounds_test_enabled = false;
194194
if (instance.IsDepthBoundsSupported()) {
195-
cmdbuf.setDepthBoundsTestEnableEXT(depth_bounds_test_enabled);
195+
cmdbuf.setDepthBoundsTestEnable(depth_bounds_test_enabled);
196196
}
197197
}
198198
if (depth_bounds_test_enabled && dirty_state.depth_bounds) {
@@ -203,36 +203,36 @@ void DynamicState::Commit(const Instance& instance, const vk::CommandBuffer& cmd
203203
}
204204
if (dirty_state.depth_bias_enabled) {
205205
dirty_state.depth_bias_enabled = false;
206-
cmdbuf.setDepthBiasEnableEXT(depth_bias_enabled);
206+
cmdbuf.setDepthBiasEnable(depth_bias_enabled);
207207
}
208208
if (depth_bias_enabled && dirty_state.depth_bias) {
209209
dirty_state.depth_bias = false;
210210
cmdbuf.setDepthBias(depth_bias_constant, depth_bias_clamp, depth_bias_slope);
211211
}
212212
if (dirty_state.stencil_test_enabled) {
213213
dirty_state.stencil_test_enabled = false;
214-
cmdbuf.setStencilTestEnableEXT(stencil_test_enabled);
214+
cmdbuf.setStencilTestEnable(stencil_test_enabled);
215215
}
216216
if (stencil_test_enabled) {
217217
if (dirty_state.stencil_front_ops && dirty_state.stencil_back_ops &&
218218
stencil_front_ops == stencil_back_ops) {
219219
dirty_state.stencil_front_ops = false;
220220
dirty_state.stencil_back_ops = false;
221-
cmdbuf.setStencilOpEXT(vk::StencilFaceFlagBits::eFrontAndBack,
222-
stencil_front_ops.fail_op, stencil_front_ops.pass_op,
223-
stencil_front_ops.depth_fail_op, stencil_front_ops.compare_op);
221+
cmdbuf.setStencilOp(vk::StencilFaceFlagBits::eFrontAndBack, stencil_front_ops.fail_op,
222+
stencil_front_ops.pass_op, stencil_front_ops.depth_fail_op,
223+
stencil_front_ops.compare_op);
224224
} else {
225225
if (dirty_state.stencil_front_ops) {
226226
dirty_state.stencil_front_ops = false;
227-
cmdbuf.setStencilOpEXT(vk::StencilFaceFlagBits::eFront, stencil_front_ops.fail_op,
228-
stencil_front_ops.pass_op, stencil_front_ops.depth_fail_op,
229-
stencil_front_ops.compare_op);
227+
cmdbuf.setStencilOp(vk::StencilFaceFlagBits::eFront, stencil_front_ops.fail_op,
228+
stencil_front_ops.pass_op, stencil_front_ops.depth_fail_op,
229+
stencil_front_ops.compare_op);
230230
}
231231
if (dirty_state.stencil_back_ops) {
232232
dirty_state.stencil_back_ops = false;
233-
cmdbuf.setStencilOpEXT(vk::StencilFaceFlagBits::eBack, stencil_back_ops.fail_op,
234-
stencil_back_ops.pass_op, stencil_back_ops.depth_fail_op,
235-
stencil_back_ops.compare_op);
233+
cmdbuf.setStencilOp(vk::StencilFaceFlagBits::eBack, stencil_back_ops.fail_op,
234+
stencil_back_ops.pass_op, stencil_back_ops.depth_fail_op,
235+
stencil_back_ops.compare_op);
236236
}
237237
}
238238
if (dirty_state.stencil_front_reference && dirty_state.stencil_back_reference &&
@@ -291,16 +291,16 @@ void DynamicState::Commit(const Instance& instance, const vk::CommandBuffer& cmd
291291
if (dirty_state.primitive_restart_enable) {
292292
dirty_state.primitive_restart_enable = false;
293293
if (instance.IsPrimitiveRestartDisableSupported()) {
294-
cmdbuf.setPrimitiveRestartEnableEXT(primitive_restart_enable);
294+
cmdbuf.setPrimitiveRestartEnable(primitive_restart_enable);
295295
}
296296
}
297297
if (dirty_state.cull_mode) {
298298
dirty_state.cull_mode = false;
299-
cmdbuf.setCullModeEXT(cull_mode);
299+
cmdbuf.setCullMode(cull_mode);
300300
}
301301
if (dirty_state.front_face) {
302302
dirty_state.front_face = false;
303-
cmdbuf.setFrontFaceEXT(front_face);
303+
cmdbuf.setFrontFace(front_face);
304304
}
305305
if (dirty_state.blend_constants) {
306306
dirty_state.blend_constants = false;

0 commit comments

Comments
 (0)