Skip to content

Commit f27f4af

Browse files
authored
Update vulkansdk to 1.2.176.1 and VK_KHR_portability_subset (KhronosGroup#436)
* Update information about iOS app signing. * Make compliant with VK_KHR_portability_subset. This change looks MUCH larger than it really is. The main change is in VulkanAppSDL.cpp and VulkanContext.h plus Texture.cpp is modified to check if it can use swizzle before doing so. The vast majority of the other changes are to streamline the vulkan.h & vulkan.hpp includes to minimize the number of places we have to prefix with VK_ENABLE_BETA_EXTENSIONS to access VK_KHR_portability_subset declarations. The changes in VulkanSwapChain.cpp and vulkantextoverlay.hpp are solely to workaround an overly strict validation rule.
1 parent 354f640 commit f27f4af

28 files changed

+219
-99
lines changed

.appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ environment:
2424
OPENGL_ES_EMULATOR_WIN: C:\Imagination\Windows_x86_64
2525
PVR_SDK_GH_VER: 4.3
2626
PVR_SDK_DL_VER: 2020_R1
27-
VULKAN_SDK_VER: 1.2.141.2
27+
VULKAN_SDK_VER: 1.2.176.1
2828

2929
branches:
3030
except:

.travis.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
dist: focal
2626
env:
2727
# NB: This must not have the fourth component of the version number.
28-
- VULKAN_SDK_VER="1.2.148"
28+
- VULKAN_SDK_VER="1.2.176"
2929
compiler: gcc # clang is tested by macOS build
3030
language: python
3131
python: '3.7'
@@ -35,8 +35,10 @@ jobs:
3535
- node
3636
- os: osx
3737
env:
38-
- VULKAN_SDK_VER="1.2.141.2"
39-
- VULKAN_SDK="/Volumes/vulkansdk-macos-$VULKAN_SDK_VER/macOS"
38+
- VULKAN_SDK_VER="1.2.176.1"
39+
# This is just to tell the install script where to install.
40+
- VULKAN_INSTALL_DIR="$HOME/VulkanSDK/$VULKAN_SDK_VER"
41+
- VULKAN_SDK="$VULKAN_INSTALL_DIR/macOS"
4042
compiler: clang
4143
osx_image: xcode12.4
4244

BUILDING.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ To sign the applications you need to set the following CMake variables:
166166
167167
| Name | Value |
168168
| :---: | :---: |
169-
| XCODE\_CODE\_SIGN\_IDENTITY | Owner of the _Developer ID Application_ certificate to use for signing |
170-
| XCODE\_DEVELOPMENT\_TEAM | Development team of the certificate owner
169+
| XCODE\_CODE\_SIGN\_IDENTITY | Owner of the _Developer ID Application_ certificate to use for signing. |
170+
| XCODE\_DEVELOPMENT\_TEAM | Development team of the certificate owner.
171171
172172
To sign the installation package you need to set the following variables:
173173
174174
| Name | Value |
175175
| :---: | :---: |
176-
| PRODUCTBUILD\_IDENTITY\_NAME | Owner of the _Developer ID Installer_ certificate to use for signing |
176+
| PRODUCTBUILD\_IDENTITY\_NAME | Owner of the _Developer ID Installer_ certificate to use for signing. |
177177
| PRODUCTBUILD\_KEYCHAIN\_PATH | Path to the keychain file with the certificate. Blank if its in the default keychain.
178178
179179
#### iOS
@@ -200,8 +200,8 @@ To sign the applications you need to set the following CMake variables:
200200
201201
| Name | Value |
202202
| :---: | :---: |
203-
| XCODE\_CODE\_SIGN\_IDENTITY | Owner of the _iPhone Developer_ certificate to use for signing |
204-
| XCODE\_DEVELOPMENT\_TEAM | Development team of the certificate owner
203+
| XCODE\_CODE\_SIGN\_IDENTITY | Owner of the _Apple Development_ certificate to use for signing. |
204+
| XCODE\_DEVELOPMENT\_TEAM | Development team used to create the Provisioning Profile. This may not be the same as the team of the _Apple Development_ certificate owner.
205205
| XCODE\_PROVISIONING\_PROFILE | Name of the profile to use.
206206
207207
### Web/Emscripten

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
497497
lib/basisu/encoder/basisu_enc.cpp
498498
PROPERTIES COMPILE_OPTIONS "-Wno-unused-variable;-Wno-sign-compare;-Wno-shorten-64-to-32"
499499
)
500-
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0")
500+
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0.5")
501501
set_source_files_properties( lib/basisu/encoder/basisu_kernels_sse.cpp
502502
PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter;-Wno-deprecated-copy;-Wno-uninitialized-const-reference"
503503
)

ci_scripts/install_macos.sh

+3
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ gem install xcpretty
1818
pushd ../..
1919
wget -O vulkansdk-macos-$VULKAN_SDK_VER.dmg https://sdk.lunarg.com/sdk/download/$VULKAN_SDK_VER/mac/vulkansdk-macos-$VULKAN_SDK_VER.dmg?Human=true
2020
hdiutil attach vulkansdk-macos-$VULKAN_SDK_VER.dmg
21+
sudo /Volumes/vulkansdk-macos-$VULKAN_SDK_VER/InstallVulkan.app/Contents/macOS/InstallVulkan --root "$VULKAN_INSTALL_DIR" --accept-licenses --default-answer --confirm-command install
22+
hdiutil detach /Volumes/vulkansdk-macos-$VULKAN_SDK_VER
23+
rm vulkansdk-macos-$VULKAN_SDK_VER.dmg
2124
popd

tests/loadtests/appfwSDL/VulkanAppSDL/VulkanAppSDL.cpp

+52-10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <sstream>
3333

3434
#include "VulkanAppSDL.h"
35+
3536
// Include this when vulkantools is removed.
3637
//#include "vulkancheckres.h"
3738
#include <SDL2/SDL_vulkan.h>
@@ -476,6 +477,21 @@ VulkanAppSDL::createInstance()
476477
return false;
477478
}
478479

480+
// Find out if device_properties2 is available. If so, enable it just
481+
// in case we later find we are running on a Portability Subset device
482+
// in which case this extension is required.
483+
std::vector<vk::ExtensionProperties> availableExtensions =
484+
vk::enumerateInstanceExtensionProperties(nullptr);
485+
for (auto& extension : availableExtensions) {
486+
if (!strncmp(extension.extensionName,
487+
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
488+
VK_MAX_EXTENSION_NAME_SIZE)) {
489+
extensionNames.push_back(
490+
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME
491+
);
492+
}
493+
}
494+
479495
if (validate)
480496
extensionNames.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
481497

@@ -674,6 +690,11 @@ VulkanAppSDL::createDevice()
674690

675691
wantedExtensions.push_back({VK_KHR_SWAPCHAIN_EXTENSION_NAME, required});
676692
wantedExtensions.push_back({VK_KHR_MAINTENANCE1_EXTENSION_NAME, required});
693+
#if VK_KHR_portability_subset
694+
// Portability must be enabled, if present.
695+
wantedExtensions.push_back({VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME, optional});
696+
#endif
697+
// And if present and enabled it requires this to be enabled.
677698
wantedExtensions.push_back({VK_IMG_FORMAT_PVRTC_EXTENSION_NAME, optional});
678699
#if 0
679700
wantedExtensions.push_back(
@@ -720,6 +741,11 @@ VulkanAppSDL::createDevice()
720741
if (!wantedExtensions[i].name.compare(VK_IMG_FORMAT_PVRTC_EXTENSION_NAME)) {
721742
vkctx.enabledDeviceExtensions.pvrtc = true;
722743
}
744+
#if VK_KHR_portability_subset
745+
if (!wantedExtensions[i].name.compare(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME)) {
746+
vkctx.gpuIsPortabilitySubsetDevice = true;
747+
}
748+
#endif
723749
break;
724750
}
725751
}
@@ -757,38 +783,47 @@ VulkanAppSDL::createDevice()
757783
queue_priorities
758784
);
759785

760-
vk::PhysicalDeviceFeatures deviceFeatures;
786+
vk::PhysicalDeviceFeatures deviceFeaturesToEnable;
761787
// Enable specific required and available features here.
762788
if (vkctx.gpuFeatures.samplerAnisotropy)
763-
deviceFeatures.samplerAnisotropy = true;
789+
deviceFeaturesToEnable.samplerAnisotropy = true;
764790
if (vkctx.gpuFeatures.textureCompressionASTC_LDR)
765-
deviceFeatures.textureCompressionASTC_LDR = true;
791+
deviceFeaturesToEnable.textureCompressionASTC_LDR = true;
766792
if (vkctx.gpuFeatures.textureCompressionBC)
767-
deviceFeatures.textureCompressionBC = true;
793+
deviceFeaturesToEnable.textureCompressionBC = true;
768794
if (vkctx.gpuFeatures.textureCompressionETC2)
769-
deviceFeatures.textureCompressionETC2 = true;
795+
deviceFeaturesToEnable.textureCompressionETC2 = true;
796+
797+
#if VK_KHR_portability_subset
798+
if (vkctx.gpuIsPortabilitySubsetDevice) {
799+
vk::PhysicalDeviceFeatures2 deviceFeatures;
800+
deviceFeatures.pNext = &vkctx.gpuPortabilityFeatures;
801+
vkctx.gpu.getFeatures2(&deviceFeatures);
802+
}
803+
#endif
804+
770805
#if 0
771-
// This needs PhysicalDeviceFeatures2 and proper understanding of how to
806+
// This needs PhysicaldeviceFeaturesToEnable2 and proper understanding of how to
772807
// navigate a structure chain. Maybe something also was necessary when the
773808
// gpuFeatures were queried.
774809
vk::BaseOutStructure* dfs = reinterpret_cast<vk::BaseOutStructure*>(&vkctx.gpuFeatures);
775810
while (dfs->pNext != NULL) {
776811
if (dfs->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES_EXT) {
777812
vk::PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT* ahf = dfs;
778813
if (afs->textureCompressionASTC_HDR) {
779-
// Add one of these structs to the requested deviceFeatures we
814+
// Add one of these structs to the requested deviceFeaturesToEnable we
780815
// are passing in and enable this feature.
781816
}
782817
}
783818
if (dfs->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_3D_FEATURES_EXT) {
784819
vk::PhysicalDeviceTextureCompressionASTC3DFeaturesEXT* ahf = dfs;
785820
if (afs->textureCompressionASTC_HDR) {
786-
// Add one of these structs to the requested deviceFeatures we
821+
// Add one of these structs to the requested deviceFeaturesToEnable we
787822
// are passing in and enable this feature.
788823
}
789824
}
790825
#endif
791-
826+
792827
vk::DeviceCreateInfo deviceInfo(
793828
{},
794829
1,
@@ -799,7 +834,14 @@ VulkanAppSDL::createDevice()
799834
: NULL),
800835
(uint32_t)extensionsToEnable.size(),
801836
(const char *const *)extensionsToEnable.data(),
802-
&deviceFeatures);
837+
&deviceFeaturesToEnable);
838+
839+
#if VK_KHR_portability_subset
840+
if (vkctx.gpuIsPortabilitySubsetDevice) {
841+
// Enable all available portability features.
842+
deviceInfo.pNext = &vkctx.gpuPortabilityFeatures;
843+
}
844+
#endif
803845

804846
err = vkctx.gpu.createDevice(&deviceInfo, NULL, &vkctx.device);
805847
if (err != vk::Result::eSuccess) {

tests/loadtests/appfwSDL/VulkanAppSDL/VulkanAppSDL.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <cstring>
1414
#include <new>
1515
#include <vector>
16+
// Needed to get PortabilitySubset definitions in vulkan.hpp.
17+
#define VK_ENABLE_BETA_EXTENSIONS 1
1618
#include <vulkan/vulkan.hpp>
1719

1820
#include "AppBaseSDL.h"

tests/loadtests/appfwSDL/VulkanAppSDL/VulkanContext.h

+15
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include <vector>
13+
#define VK_ENABLE_BETA_EXTENSIONS 1
1314
#include <vulkan/vulkan.hpp>
1415
#include "VulkanSwapchain.h"
1516

@@ -25,12 +26,17 @@ struct VulkanContext {
2526
vk::Instance instance;
2627
vk::PhysicalDevice gpu;
2728
vk::PhysicalDeviceFeatures gpuFeatures;
29+
#if VK_KHR_portability_subset
30+
vk::PhysicalDevicePortabilitySubsetFeaturesKHR gpuPortabilityFeatures;
31+
#endif
2832
vk::PhysicalDeviceProperties gpuProperties;
2933
vk::PhysicalDeviceMemoryProperties memoryProperties;
3034
vk::Device device;
3135
vk::CommandPool commandPool;
3236
vk::Queue queue;
3337

38+
bool gpuIsPortabilitySubsetDevice = false;
39+
3440
struct {
3541
bool pvrtc = false;
3642
bool astc_hdr = false;
@@ -114,6 +120,15 @@ struct VulkanContext {
114120
const char* const modname = "main");
115121
vk::ShaderModule loadShader(std::string filename);
116122
uint32_t* readSpv(const char *filename, size_t *pSize);
123+
124+
bool gpuSupportsSwizzle() {
125+
#if VK_KHR_portability_subset
126+
return !gpuIsPortabilitySubsetDevice
127+
|| gpuPortabilityFeatures.imageViewFormatSwizzle;
128+
#else
129+
return true;
130+
#endif
131+
}
117132
};
118133

119134
#endif /* VULKAN_TEXTURE_H_229895365400979164311947449304284143508 */

tests/loadtests/appfwSDL/VulkanAppSDL/VulkanSwapchain.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@ VulkanSwapchain::create(uint32_t *width, uint32_t *height,
349349
colorAttachmentView.pNext = NULL;
350350
colorAttachmentView.format = colorFormat;
351351
colorAttachmentView.components = {
352-
VK_COMPONENT_SWIZZLE_R,
353-
VK_COMPONENT_SWIZZLE_G,
354-
VK_COMPONENT_SWIZZLE_B,
355-
VK_COMPONENT_SWIZZLE_A
352+
VK_COMPONENT_SWIZZLE_IDENTITY,
353+
VK_COMPONENT_SWIZZLE_IDENTITY,
354+
VK_COMPONENT_SWIZZLE_IDENTITY,
355+
VK_COMPONENT_SWIZZLE_IDENTITY
356356
};
357357
colorAttachmentView.subresourceRange.aspectMask
358358
= VK_IMAGE_ASPECT_COLOR_BIT;

tests/loadtests/appfwSDL/VulkanAppSDL/vulkantextoverlay.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,12 @@ class VulkanTextOverlay
308308
imageViewInfo.image = image;
309309
imageViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
310310
imageViewInfo.format = imageInfo.format;
311-
imageViewInfo.components = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
311+
imageViewInfo.components = {
312+
VK_COMPONENT_SWIZZLE_IDENTITY,
313+
VK_COMPONENT_SWIZZLE_IDENTITY,
314+
VK_COMPONENT_SWIZZLE_IDENTITY,
315+
VK_COMPONENT_SWIZZLE_IDENTITY
316+
};
312317
imageViewInfo.subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 };
313318

314319
VK_CHECK_RESULT(vkCreateImageView(device, &imageViewInfo, nullptr, &view));

tests/loadtests/common/ltexceptions.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ class unsupported_ttype : public std::runtime_error {
2626
public:
2727
unsupported_ttype()
2828
: std::runtime_error("Implementation does not support needed operations on image format") { }
29+
unsupported_ttype(std::string& message) : std::runtime_error(message) { }
2930
};

tests/loadtests/glloadtests/shader-based/DrawTexture.cpp

+43-30
Original file line numberDiff line numberDiff line change
@@ -151,36 +151,49 @@ DrawTexture::DrawTexture(uint32_t width, uint32_t height,
151151
char* swizzleStr;
152152
ktxresult = ktxHashList_FindValue(&kTexture->kvDataHead, KTX_SWIZZLE_KEY,
153153
&swizzleLen, (void**)&swizzleStr);
154-
if (ktxresult == KTX_SUCCESS && swizzleLen == 4) {
155-
GLint swizzle[4];
156-
swizzle[0] = swizzleStr[0] == 'r' ? GL_RED
157-
: swizzleStr[0] == 'g' ? GL_GREEN
158-
: swizzleStr[0] == 'b' ? GL_BLUE
159-
: swizzleStr[0] == 'a' ? GL_ALPHA
160-
: swizzleStr[0] == '0' ? GL_ZERO
161-
: GL_ONE;
162-
swizzle[1] = swizzleStr[1] == 'r' ? GL_RED
163-
: swizzleStr[1] == 'g' ? GL_GREEN
164-
: swizzleStr[1] == 'b' ? GL_BLUE
165-
: swizzleStr[1] == 'a' ? GL_ALPHA
166-
: swizzleStr[1] == '0' ? GL_ZERO
167-
: GL_ONE;
168-
swizzle[2] = swizzleStr[2] == 'r' ? GL_RED
169-
: swizzleStr[2] == 'g' ? GL_GREEN
170-
: swizzleStr[2] == 'b' ? GL_BLUE
171-
: swizzleStr[2] == 'a' ? GL_ALPHA
172-
: swizzleStr[2] == '2' ? GL_ZERO
173-
: GL_ONE;
174-
swizzle[3] = swizzleStr[3] == 'r' ? GL_RED
175-
: swizzleStr[3] == 'g' ? GL_GREEN
176-
: swizzleStr[3] == 'b' ? GL_BLUE
177-
: swizzleStr[3] == 'a' ? GL_ALPHA
178-
: swizzleStr[3] == '3' ? GL_ZERO
179-
: GL_ONE;
180-
glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, swizzle[0]);
181-
glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, swizzle[1]);
182-
glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, swizzle[2]);
183-
glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, swizzle[3]);
154+
if (ktxresult == KTX_SUCCESS && swizzleLen == 5) {
155+
if (contextSupportsSwizzle()) {
156+
GLint swizzle[4];
157+
swizzle[0] = swizzleStr[0] == 'r' ? GL_RED
158+
: swizzleStr[0] == 'g' ? GL_GREEN
159+
: swizzleStr[0] == 'b' ? GL_BLUE
160+
: swizzleStr[0] == 'a' ? GL_ALPHA
161+
: swizzleStr[0] == '0' ? GL_ZERO
162+
: GL_ONE;
163+
swizzle[1] = swizzleStr[1] == 'r' ? GL_RED
164+
: swizzleStr[1] == 'g' ? GL_GREEN
165+
: swizzleStr[1] == 'b' ? GL_BLUE
166+
: swizzleStr[1] == 'a' ? GL_ALPHA
167+
: swizzleStr[1] == '0' ? GL_ZERO
168+
: GL_ONE;
169+
swizzle[2] = swizzleStr[2] == 'r' ? GL_RED
170+
: swizzleStr[2] == 'g' ? GL_GREEN
171+
: swizzleStr[2] == 'b' ? GL_BLUE
172+
: swizzleStr[2] == 'a' ? GL_ALPHA
173+
: swizzleStr[2] == '2' ? GL_ZERO
174+
: GL_ONE;
175+
swizzle[3] = swizzleStr[3] == 'r' ? GL_RED
176+
: swizzleStr[3] == 'g' ? GL_GREEN
177+
: swizzleStr[3] == 'b' ? GL_BLUE
178+
: swizzleStr[3] == 'a' ? GL_ALPHA
179+
: swizzleStr[3] == '3' ? GL_ZERO
180+
: GL_ONE;
181+
glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, swizzle[0]);
182+
glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, swizzle[1]);
183+
glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, swizzle[2]);
184+
glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, swizzle[3]);
185+
} else {
186+
std::stringstream message;
187+
message << "Input file has swizzle metadata but the "
188+
<< "GL context does not support swizzling.";
189+
// I have absolutely no idea why the following line makes clang
190+
// raise an error about no matching conversion from
191+
// std::__1::basic_stringstream to unsupported_ttype
192+
// so I've resorted to using a temporary variable.
193+
//throw(unsupported_ttype(message.str());
194+
std::string msg = message.str();
195+
throw(unsupported_ttype(msg));
196+
}
184197
}
185198

186199
assert(GL_NO_ERROR == glGetError());

0 commit comments

Comments
 (0)