1// Copyright 2022 Georg Lehmann 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5= VK_EXT_non_seamless_cube_map 6:toc: left 7:refpage: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/ 8:sectnums: 9 10== Problem Statement 11 12Other graphics APIs, such as OpenGL and D3D9, have cube maps without seamless edge handling. 13When sampling near an edge, instead of interpolating between two texels on the neighboring cube map faces the usual sampler address modes are applied within a single face. 14Vulkan only has cube maps with seamless edge handling. 15 16This proposal aims to provide functionality to support non seamless cube maps. 17 18== Solution Space 19 20=== Emulation With 2D Array Textures 21 22The idea behind this solution is to represent cube map textures as 2D array textures with 6 layers, one for each cube map face. 23Cube map coordinates can then be transformed to a face index and a 2D coordinate within this face, so that then the fixed function sampling takes care of applying the sampler address modes. 24A problem is correct LOD selection while preserving anisotropic filtering. Emulation of implicit derivatives with LOD offset cannot be easily emulated with explicit derivatives. 25Additionally, having pipeline variants depending on if seamless cube sampling is used prevents precompiling pipelines if any cubes are used as this information is only known at draw time. 26With advanced OpenGL features it is also not possible to know if a sampling operation is seamless even at draw time, so emulation needs extra descriptors, uniforms and branches. 27 28 29=== A Per Sampler Seamless Setting 30 31A new per sampler setting to allow to select if cube map edge sampling is seamless can be introduced. 32This can commonly be handled by fixed function hardware, which allows identical behavior to the other graphics APIs. 33 34This solution is adopted for this problem. 35 36== Proposal 37 38```c 39typedef struct VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT { 40 VkStructureType sType; 41 void* pNext; 42 VkBool32 nonSeamlessCubeMap; 43} VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT; 44``` 45 46`nonSeamlessCubeMap` is the feature enabling this extension’s functionality. 47 48Using `VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT` disables seamless cube map edge handling. 49 50== Example 51 52As an example, if an application creates a cube map and wants to always clamp to the edge within the selected cube face, `VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT` together with `VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE` can be used. 53 54== Issues 55 56No known issues. 57