mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[vulkan] Use the msaaSamples cvar
That took a bit of fiddling with the render pass to get things working for both sampling and no sampling (ie, msaaSamples = 1).
This commit is contained in:
parent
d6b678ac78
commit
ebb73e19b2
4 changed files with 100 additions and 27 deletions
|
@ -135,12 +135,15 @@ vulkan_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
framebuffer->imageAvailableSemaphore,
|
||||
0, &imageIndex);
|
||||
|
||||
__auto_type attachments = DARRAY_ALLOCFIXED (qfv_imageviewset_t, 3,
|
||||
alloca);
|
||||
int attachCount = vulkan_ctx->msaaSamples > 1 ? 3 : 2;
|
||||
__auto_type attachments = DARRAY_ALLOCFIXED (qfv_imageviewset_t,
|
||||
attachCount, alloca);
|
||||
qfv_swapchain_t *sc = vulkan_ctx->swapchain;
|
||||
attachments->a[0] = vulkan_ctx->renderpass.colorImage->view;
|
||||
attachments->a[0] = sc->imageViews->a[imageIndex];
|
||||
attachments->a[1] = vulkan_ctx->renderpass.depthImage->view;
|
||||
attachments->a[2] = sc->imageViews->a[imageIndex];
|
||||
if (attachCount > 2) {
|
||||
attachments->a[2] = vulkan_ctx->renderpass.colorImage->view;
|
||||
}
|
||||
|
||||
VkRenderPass renderpass = vulkan_ctx->renderpass.renderpass;
|
||||
framebuffer->framebuffer = QFV_CreateFramebuffer (device, renderpass,
|
||||
|
@ -157,15 +160,16 @@ vulkan_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
|
||||
VkCommandBufferBeginInfo beginInfo
|
||||
= { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };
|
||||
VkClearValue clearValues[2] = {
|
||||
VkClearValue clearValues[3] = {
|
||||
{ { {0.0, 0.0, 0.0, 1.0} } },
|
||||
{ { {1.0, 0.0} } },
|
||||
{ { {0.0, 0.0, 0.0, 1.0} } },
|
||||
};
|
||||
VkRenderPassBeginInfo renderPassInfo = {
|
||||
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, 0,
|
||||
vulkan_ctx->renderpass.renderpass, 0,
|
||||
{ {0, 0}, sc->extent },
|
||||
2, clearValues
|
||||
3, clearValues
|
||||
};
|
||||
|
||||
dfunc->vkBeginCommandBuffer (framebuffer->cmdBuffer, &beginInfo);
|
||||
|
|
|
@ -707,13 +707,75 @@
|
|||
{
|
||||
flags = 0;
|
||||
format = $swapchain.format;
|
||||
samples = $msaaSamples;
|
||||
samples = 1;
|
||||
loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
},
|
||||
{
|
||||
flags = 0;
|
||||
format = VK_FORMAT_D32_SFLOAT;
|
||||
samples = 1;
|
||||
loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
},
|
||||
);
|
||||
subpasses = (
|
||||
{
|
||||
pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
colorAttachments = (
|
||||
{
|
||||
attachment = 0;
|
||||
layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
);
|
||||
depthStencilAttachment = {
|
||||
attachment = 1;
|
||||
layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
};
|
||||
preserveAttachments = ();
|
||||
},
|
||||
);
|
||||
dependencies = (
|
||||
{
|
||||
srcSubpass = VK_SUBPASS_EXTERNAL;
|
||||
dstSubpass = 0;
|
||||
srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
},
|
||||
{
|
||||
srcSubpass = 0;
|
||||
dstSubpass = VK_SUBPASS_EXTERNAL;
|
||||
srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||
dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||
srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||
dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
|
||||
},
|
||||
);
|
||||
};
|
||||
renderpass.msaa = {
|
||||
attachments = (
|
||||
{
|
||||
flags = 0;
|
||||
format = $swapchain.format;
|
||||
samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
},
|
||||
{
|
||||
flags = 0;
|
||||
|
@ -729,13 +791,13 @@
|
|||
{
|
||||
flags = 0;
|
||||
format = $swapchain.format;
|
||||
samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
samples = $msaaSamples;
|
||||
loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
},
|
||||
);
|
||||
subpasses = (
|
||||
|
@ -743,13 +805,13 @@
|
|||
pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
colorAttachments = (
|
||||
{
|
||||
attachment = 0;
|
||||
attachment = 2;
|
||||
layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
);
|
||||
resolveAttachments = (
|
||||
{
|
||||
attachment = 2;
|
||||
attachment = 0;
|
||||
layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
}
|
||||
);
|
||||
|
|
|
@ -106,9 +106,13 @@ QFV_CreateRenderPass (qfv_device_t *device,
|
|||
const VkAttachmentReference *ref = &sp->pColorAttachments[j];
|
||||
Sys_Printf (" c %d %d\n", ref->attachment, ref->layout);
|
||||
}
|
||||
if (sp->pResolveAttachments) {
|
||||
for (size_t j = 0; j < sp->colorAttachmentCount; j++) {
|
||||
const VkAttachmentReference *ref = &sp->pResolveAttachments[j];
|
||||
Sys_Printf (" r %d %d\n", ref->attachment, ref->layout);
|
||||
const VkAttachmentReference *ref
|
||||
= &sp->pResolveAttachments[j];
|
||||
Sys_Printf (" r %d %d\n", ref->attachment,
|
||||
ref->layout);
|
||||
}
|
||||
}
|
||||
Sys_Printf (" pDepthStencilAttachment: %p\n",
|
||||
sp->pDepthStencilAttachment);
|
||||
|
|
|
@ -240,28 +240,31 @@ Vulkan_CreateRenderPass (vulkan_ctx_t *ctx)
|
|||
{
|
||||
qfv_load_pipeline (ctx);
|
||||
const char *name = "renderpass";//FIXME
|
||||
|
||||
plitem_t *item = ctx->pipelineDef;
|
||||
if (!item || !(item = PL_ObjectForKey (item, name))) {
|
||||
Sys_Printf ("error loading renderpass\n");
|
||||
return;
|
||||
} else {
|
||||
Sys_Printf ("Found renderpass def\n");
|
||||
}
|
||||
qfv_device_t *device = ctx->device;
|
||||
VkDevice dev = device->dev;
|
||||
qfv_devfuncs_t *df = device->funcs;
|
||||
VkCommandBuffer cmd = ctx->cmdbuffer;
|
||||
qfv_swapchain_t *sc = ctx->swapchain;
|
||||
|
||||
ctx->msaaSamples = min ((VkSampleCountFlagBits) msaaSamples->int_val,
|
||||
QFV_GetMaxSampleCount (device->physDev));
|
||||
if (ctx->msaaSamples > 1) {
|
||||
name = "renderpass.msaa";
|
||||
}
|
||||
|
||||
plitem_t *item = ctx->pipelineDef;
|
||||
if (!item || !(item = PL_ObjectForKey (item, name))) {
|
||||
Sys_Printf ("error loading renderpass: %s\n", name);
|
||||
return;
|
||||
} else {
|
||||
Sys_Printf ("Found renderpass def: %s\n", name);
|
||||
}
|
||||
|
||||
qfv_imageresource_t *colorImage = malloc (sizeof (*colorImage));
|
||||
qfv_imageresource_t *depthImage = malloc (sizeof (*depthImage));
|
||||
|
||||
VkExtent3D extent = {sc->extent.width, sc->extent.height, 1};
|
||||
|
||||
//FIXME incorporate cvar setting
|
||||
ctx->msaaSamples = QFV_GetMaxSampleCount (device->physDev);
|
||||
|
||||
Sys_MaskPrintf (SYS_VULKAN, "color resource\n");
|
||||
colorImage->image
|
||||
= QFV_CreateImage (device, 0, VK_IMAGE_TYPE_2D,
|
||||
|
|
Loading…
Reference in a new issue