mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-16 06:11:15 +00:00
[vulkan] Switch to vulkan 1.1/1.2 prop/feat structs
Since switching to the 1.2 api as a requirement, might as well use the relevant structs instead of extension struct (for multiview). Came up when double-checking the max views property due to running into what appears to be an nvidia bug where > 29 views (any bit pattern) cause a segfault when creating the pipeline.
This commit is contained in:
parent
7506117e43
commit
75ce49b1f0
11 changed files with 34 additions and 32 deletions
|
@ -42,9 +42,9 @@ typedef struct DARRAY_TYPE(const char *) qfv_debugstack_t;
|
|||
typedef struct qfv_physdev_s {
|
||||
struct qfv_instance_s *instance;
|
||||
VkPhysicalDevice dev;
|
||||
VkPhysicalDeviceProperties2 properties2;
|
||||
VkPhysicalDeviceProperties *properties;
|
||||
VkPhysicalDeviceMultiviewProperties multiViewProperties;
|
||||
VkPhysicalDeviceProperties2 p;
|
||||
VkPhysicalDeviceVulkan11Properties v11Properties;
|
||||
VkPhysicalDeviceVulkan12Properties v12Properties;
|
||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||
} qfv_physdev_t;
|
||||
|
||||
|
|
|
@ -149,19 +149,19 @@ QFV_CreateDevice (vulkan_ctx_t *ctx, const char **extensions)
|
|||
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, 0, 0,
|
||||
family, 1, &priority
|
||||
};
|
||||
VkPhysicalDeviceMultiviewFeatures multiview_features = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES,
|
||||
VkPhysicalDeviceVulkan12Features features12 = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
|
||||
.hostQueryReset = 1,
|
||||
};
|
||||
VkPhysicalDeviceVulkan11Features features11 = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES,
|
||||
.pNext = &features12,
|
||||
.multiview = 1,
|
||||
.multiviewGeometryShader = 1,
|
||||
};
|
||||
VkPhysicalDeviceVulkan12Features features12 = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
|
||||
.pNext = &multiview_features,
|
||||
.hostQueryReset = 1,
|
||||
};
|
||||
VkPhysicalDeviceFeatures2 features = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
||||
.pNext = &features12,
|
||||
.pNext = &features11,
|
||||
.features = {
|
||||
.imageCubeArray = 1,
|
||||
.independentBlend = 1,
|
||||
|
|
|
@ -279,15 +279,18 @@ QFV_CreateInstance (vulkan_ctx_t *ctx,
|
|||
qfv_physdev_t *dev = &inst->devices[i];
|
||||
dev->instance = inst;
|
||||
dev->dev = physDev;
|
||||
dev->properties2 = (VkPhysicalDeviceProperties2) {
|
||||
dev->p = (VkPhysicalDeviceProperties2) {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
|
||||
.pNext = &dev->multiViewProperties,
|
||||
.pNext = &dev->v11Properties,
|
||||
};
|
||||
dev->multiViewProperties = (VkPhysicalDeviceMultiviewProperties) {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES,
|
||||
dev->v11Properties = (VkPhysicalDeviceVulkan11Properties) {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES,
|
||||
.pNext = &dev->v12Properties,
|
||||
};
|
||||
ifunc->vkGetPhysicalDeviceProperties2 (physDev, &dev->properties2);
|
||||
dev->properties = &dev->properties2.properties;
|
||||
dev->v12Properties = (VkPhysicalDeviceVulkan12Properties) {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES,
|
||||
};
|
||||
ifunc->vkGetPhysicalDeviceProperties2 (physDev, &dev->p);
|
||||
ifunc->vkGetPhysicalDeviceMemoryProperties (physDev,
|
||||
&dev->memory_properties);
|
||||
}
|
||||
|
@ -314,8 +317,8 @@ QFV_GetMaxSampleCount (qfv_physdev_t *physdev)
|
|||
{
|
||||
VkSampleCountFlagBits maxSamples = VK_SAMPLE_COUNT_64_BIT;
|
||||
VkSampleCountFlagBits counts;
|
||||
counts = min (physdev->properties->limits.framebufferColorSampleCounts,
|
||||
physdev->properties->limits.framebufferDepthSampleCounts);
|
||||
counts = min (physdev->p.properties.limits.framebufferColorSampleCounts,
|
||||
physdev->p.properties.limits.framebufferDepthSampleCounts);
|
||||
while (maxSamples && maxSamples > counts) {
|
||||
maxSamples >>= 1;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ QFV_CreateResource (qfv_device_t *device, qfv_resource_t *resource)
|
|||
{
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
qfv_physdev_t *physdev = device->physDev;
|
||||
size_t atom = physdev->properties->limits.nonCoherentAtomSize;
|
||||
size_t atom = physdev->p.properties.limits.nonCoherentAtomSize;
|
||||
VkPhysicalDeviceMemoryProperties *memprops = &physdev->memory_properties;
|
||||
VkMemoryRequirements req;
|
||||
VkDeviceSize size = 0;
|
||||
|
|
|
@ -43,7 +43,7 @@ qfv_stagebuf_t *
|
|||
QFV_CreateStagingBuffer (qfv_device_t *device, const char *name, size_t size,
|
||||
VkCommandPool cmdPool)
|
||||
{
|
||||
size_t atom = device->physDev->properties->limits.nonCoherentAtomSize;
|
||||
size_t atom = device->physDev->p.properties.limits.nonCoherentAtomSize;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
dstring_t *str = dstring_new ();
|
||||
|
||||
|
|
|
@ -1038,7 +1038,7 @@ parse_object (vulkan_ctx_t *ctx, memsuper_t *memsuper, plitem_t *plist,
|
|||
{"frames", &qfv_renderframeset_t_type, &rctx->frames},
|
||||
{"msaaSamples", &VkSampleCountFlagBits_type, &ctx->msaaSamples},
|
||||
{"physDevLimits", &VkPhysicalDeviceLimits_type,
|
||||
&ctx->device->physDev->properties->limits },
|
||||
&ctx->device->physDev->p.properties.limits },
|
||||
{QFV_PROPERTIES, &cexpr_plitem, &parsectx.properties},
|
||||
{}
|
||||
};
|
||||
|
@ -1442,7 +1442,7 @@ QFV_ParseJobInfo (vulkan_ctx_t *ctx, plitem_t *item, qfv_renderctx_t *rctx)
|
|||
{"frames", &qfv_renderframeset_t_type, &rctx->frames},
|
||||
{"msaaSamples", &VkSampleCountFlagBits_type, &ctx->msaaSamples},
|
||||
{"physDevLimits", &VkPhysicalDeviceLimits_type,
|
||||
&ctx->device->physDev->properties->limits },
|
||||
&ctx->device->physDev->p.properties.limits },
|
||||
{}
|
||||
};
|
||||
exprctx.external_variables = QFV_CreateSymtab (item, "properties",
|
||||
|
@ -1489,7 +1489,7 @@ QFV_ParseSamplerInfo (vulkan_ctx_t *ctx, plitem_t *item, qfv_renderctx_t *rctx)
|
|||
|
||||
exprsym_t var_syms[] = {
|
||||
{"physDevLimits", &VkPhysicalDeviceLimits_type,
|
||||
&ctx->device->physDev->properties->limits },
|
||||
&ctx->device->physDev->p.properties.limits },
|
||||
{}
|
||||
};
|
||||
exprctx.external_variables = QFV_CreateSymtab (item, "properties",
|
||||
|
|
|
@ -504,7 +504,7 @@ Vulkan_BuildDisplayLists (model_t **models, int num_models, vulkan_ctx_t *ctx)
|
|||
}
|
||||
index_count *= 3;
|
||||
|
||||
size_t atom = device->physDev->properties->limits.nonCoherentAtomSize;
|
||||
size_t atom = device->physDev->p.properties.limits.nonCoherentAtomSize;
|
||||
size_t atom_mask = atom - 1;
|
||||
size_t frames = bctx->frames.size;
|
||||
size_t index_buffer_size = index_count * frames * sizeof (uint32_t);
|
||||
|
@ -975,7 +975,7 @@ bsp_flush (vulkan_ctx_t *ctx)
|
|||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
bspctx_t *bctx = ctx->bsp_context;
|
||||
bspframe_t *bframe = &bctx->frames.a[ctx->curFrame];
|
||||
size_t atom = device->physDev->properties->limits.nonCoherentAtomSize;
|
||||
size_t atom = device->physDev->p.properties.limits.nonCoherentAtomSize;
|
||||
size_t atom_mask = atom - 1;
|
||||
size_t index_offset = bframe->index_offset;
|
||||
size_t index_size = bframe->index_count * sizeof (uint32_t);
|
||||
|
@ -1456,7 +1456,7 @@ Vulkan_Bsp_Setup (vulkan_ctx_t *ctx)
|
|||
|
||||
size_t entid_count = Vulkan_Scene_MaxEntities (ctx);
|
||||
size_t entid_size = entid_count * sizeof (uint32_t);
|
||||
size_t atom = device->physDev->properties->limits.nonCoherentAtomSize;
|
||||
size_t atom = device->physDev->p.properties.limits.nonCoherentAtomSize;
|
||||
size_t atom_mask = atom - 1;
|
||||
entid_size = (entid_size + atom_mask) & ~atom_mask;
|
||||
bctx->entid_buffer
|
||||
|
|
|
@ -975,7 +975,7 @@ slice_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx)
|
|||
|
||||
qftVkScopedZone (taskctx->frame->qftVkCtx, taskctx->cmd, "slice_draw");
|
||||
VkDeviceMemory memory = dctx->draw_resource[1].memory;
|
||||
size_t atom = device->physDev->properties->limits.nonCoherentAtomSize;
|
||||
size_t atom = device->physDev->p.properties.limits.nonCoherentAtomSize;
|
||||
size_t atom_mask = atom - 1;
|
||||
#define a(x) (((x) + atom_mask) & ~atom_mask)
|
||||
VkMappedMemoryRange ranges[] = {
|
||||
|
@ -1012,7 +1012,7 @@ line_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx)
|
|||
}
|
||||
|
||||
VkDeviceMemory memory = dctx->draw_resource[1].memory;
|
||||
size_t atom = device->physDev->properties->limits.nonCoherentAtomSize;
|
||||
size_t atom = device->physDev->p.properties.limits.nonCoherentAtomSize;
|
||||
size_t atom_mask = atom - 1;
|
||||
#define a(x) (((x) + atom_mask) & ~atom_mask)
|
||||
VkMappedMemoryRange ranges[] = {
|
||||
|
|
|
@ -1719,7 +1719,7 @@ build_shadow_maps (lightingctx_t *lctx, vulkan_ctx_t *ctx)
|
|||
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_physdev_t *physDev = device->physDev;
|
||||
int maxLayers = physDev->properties->limits.maxImageArrayLayers;
|
||||
int maxLayers = physDev->p.properties.limits.maxImageArrayLayers;
|
||||
if (maxLayers > 2048) {
|
||||
maxLayers = 2048;
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ update_particles (const exprval_t **p, exprval_t *result, exprctx_t *ectx)
|
|||
|
||||
qfv_packet_t *packet = QFV_PacketAcquire (pctx->stage);
|
||||
|
||||
__auto_type limits = &device->physDev->properties->limits;
|
||||
__auto_type limits = &device->physDev->p.properties.limits;
|
||||
VkMemoryRequirements req = {
|
||||
.alignment = limits->minStorageBufferOffsetAlignment
|
||||
};
|
||||
|
|
|
@ -92,7 +92,6 @@ static cvar_t vulkan_oit_fragments_cvar = {
|
|||
|
||||
static const char *instance_extensions[] = {
|
||||
VK_KHR_SURFACE_EXTENSION_NAME,
|
||||
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
|
||||
0,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue