Skip to content

Commit e97687b

Browse files
Fix vulkan scaling issue (maplibre#3489)
1 parent fece07e commit e97687b

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

src/mbgl/vulkan/pipeline.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace mbgl {
77
namespace vulkan {
88

9+
#define USE_DYNAMIC_VIEWPORT 0
10+
911
vk::Format PipelineInfo::vulkanFormat(const gfx::AttributeDataType& value) {
1012
switch (value) {
1113
case gfx::AttributeDataType::Byte:
@@ -398,6 +400,10 @@ std::size_t PipelineInfo::hash() const {
398400
stencilDepthFail,
399401
wideLines,
400402
VkRenderPass(renderPass),
403+
#if !USE_DYNAMIC_VIEWPORT
404+
viewExtent.width,
405+
viewExtent.height,
406+
#endif
401407
vertexInputHash);
402408
}
403409

@@ -415,6 +421,14 @@ void PipelineInfo::setDynamicValues(const RendererBackend& backend, const vk::Un
415421
if (backend.getDeviceFeatures().wideLines && wideLines) {
416422
buffer->setLineWidth(dynamicValues.lineWidth);
417423
}
424+
425+
#if USE_DYNAMIC_VIEWPORT
426+
const vk::Viewport viewport(0.0f, 0.0f, viewExtent.width, viewExtent.height, 0.0f, 1.0f);
427+
const vk::Rect2D scissorRect({}, {viewExtent.width, viewExtent.height});
428+
429+
buffer->setViewport(0, viewport);
430+
buffer->setScissor(0, scissorRect);
431+
#endif
418432
}
419433

420434
std::vector<vk::DynamicState> PipelineInfo::getDynamicStates(const RendererBackend& backend) const {
@@ -434,6 +448,11 @@ std::vector<vk::DynamicState> PipelineInfo::getDynamicStates(const RendererBacke
434448
dynamicStates.push_back(vk::DynamicState::eLineWidth);
435449
}
436450

451+
#if USE_DYNAMIC_VIEWPORT
452+
dynamicStates.push_back(vk::DynamicState::eViewport);
453+
dynamicStates.push_back(vk::DynamicState::eScissor);
454+
#endif
455+
437456
return dynamicStates;
438457
}
439458

src/mbgl/vulkan/renderable_resource.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void SurfaceRenderableResource::initDepthStencil() {
230230

231231
depthAllocation->imageView = device->createImageViewUnique(imageViewCreateInfo);
232232

233-
backend.setDebugName(vk::Image(depthAllocation->image), "SwapchainDepthImage");
233+
backend.setDebugName(depthAllocation->image, "SwapchainDepthImage");
234234
backend.setDebugName(depthAllocation->imageView.get(), "SwapchainDepthImageView");
235235
}
236236

@@ -309,8 +309,8 @@ void SurfaceRenderableResource::init(uint32_t w, uint32_t h) {
309309
swapchainImageViews.push_back(device->createImageViewUnique(imageViewCreateInfo));
310310

311311
const size_t index = swapchainImageViews.size() - 1;
312-
backend.setDebugName(vk::Image(image), "SwapchainImage_" + std::to_string(index));
313-
backend.setDebugName(vk::Image(image), "SwapchainImageView_" + std::to_string(index));
312+
backend.setDebugName(image, "SwapchainImage_" + std::to_string(index));
313+
backend.setDebugName(image, "SwapchainImageView_" + std::to_string(index));
314314
}
315315

316316
// depth resources

src/mbgl/vulkan/renderer_backend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ void RendererBackend::initDebug() {
331331
const vk::DebugUtilsMessageTypeFlagsEXT type = vk::DebugUtilsMessageTypeFlagsEXT() |
332332
vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral |
333333
vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation |
334-
vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance |
335-
vk::DebugUtilsMessageTypeFlagBitsEXT::eDeviceAddressBinding;
334+
vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance;
336335

337336
const auto createInfo =
338337
vk::DebugUtilsMessengerCreateInfoEXT().setMessageSeverity(severity).setMessageType(type).setPfnUserCallback(

0 commit comments

Comments
 (0)