Switch vulkan backend to use the zvulkan library

This commit is contained in:
Magnus Norddahl 2022-12-03 06:40:04 +01:00 committed by Christoph Oelckers
parent 854c57611f
commit 6a005e3a2a
203 changed files with 17691 additions and 7996 deletions

View file

@ -324,9 +324,7 @@ option(FORCE_INTERNAL_ASMJIT "Use internal asmjit" ON)
mark_as_advanced( FORCE_INTERNAL_ASMJIT ) mark_as_advanced( FORCE_INTERNAL_ASMJIT )
if (HAVE_VULKAN) if (HAVE_VULKAN)
add_subdirectory( libraries/glslang/glslang) add_subdirectory( libraries/ZVulkan )
add_subdirectory( libraries/glslang/spirv )
add_subdirectory( libraries/glslang/OGLCompilersDLL )
endif() endif()
add_subdirectory( libraries/discordrpc EXCLUDE_FROM_ALL ) add_subdirectory( libraries/discordrpc EXCLUDE_FROM_ALL )

View file

@ -0,0 +1,199 @@
cmake_minimum_required(VERSION 3.15)
project(zvulkan)
set(ZVULKAN_SOURCES
src/vulkanbuilders.cpp
src/vulkandevice.cpp
src/vulkaninstance.cpp
src/vulkansurface.cpp
src/vulkanswapchain.cpp
src/vk_mem_alloc/vk_mem_alloc.cpp
src/vk_mem_alloc/vk_mem_alloc.natvis
src/volk/volk.c
src/glslang/glslang/MachineIndependent/SymbolTable.h
src/glslang/glslang/MachineIndependent/propagateNoContraction.cpp
src/glslang/glslang/MachineIndependent/PoolAlloc.cpp
src/glslang/glslang/MachineIndependent/Intermediate.cpp
src/glslang/glslang/MachineIndependent/gl_types.h
src/glslang/glslang/MachineIndependent/parseVersions.h
src/glslang/glslang/MachineIndependent/attribute.cpp
src/glslang/glslang/MachineIndependent/Scan.cpp
src/glslang/glslang/MachineIndependent/iomapper.h
src/glslang/glslang/MachineIndependent/ParseHelper.h
src/glslang/glslang/MachineIndependent/glslang_tab.cpp.h
src/glslang/glslang/MachineIndependent/SymbolTable.cpp
src/glslang/glslang/MachineIndependent/RemoveTree.cpp
src/glslang/glslang/MachineIndependent/Versions.h
src/glslang/glslang/MachineIndependent/reflection.cpp
src/glslang/glslang/MachineIndependent/LiveTraverser.h
src/glslang/glslang/MachineIndependent/iomapper.cpp
src/glslang/glslang/MachineIndependent/intermOut.cpp
src/glslang/glslang/MachineIndependent/Versions.cpp
src/glslang/glslang/MachineIndependent/Initialize.h
src/glslang/glslang/MachineIndependent/linkValidate.cpp
src/glslang/glslang/MachineIndependent/InfoSink.cpp
src/glslang/glslang/MachineIndependent/Constant.cpp
src/glslang/glslang/MachineIndependent/IntermTraverse.cpp
src/glslang/glslang/MachineIndependent/propagateNoContraction.h
src/glslang/glslang/MachineIndependent/glslang_tab.cpp
src/glslang/glslang/MachineIndependent/ShaderLang.cpp
src/glslang/glslang/MachineIndependent/preprocessor/Pp.cpp
src/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h
src/glslang/glslang/MachineIndependent/preprocessor/PpAtom.cpp
src/glslang/glslang/MachineIndependent/preprocessor/PpContext.cpp
src/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp
src/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp
src/glslang/glslang/MachineIndependent/preprocessor/PpContext.h
src/glslang/glslang/MachineIndependent/attribute.h
src/glslang/glslang/MachineIndependent/localintermediate.h
src/glslang/glslang/MachineIndependent/parseConst.cpp
src/glslang/glslang/MachineIndependent/Initialize.cpp
src/glslang/glslang/MachineIndependent/limits.cpp
src/glslang/glslang/MachineIndependent/ParseContextBase.cpp
src/glslang/glslang/MachineIndependent/RemoveTree.h
src/glslang/glslang/MachineIndependent/ParseHelper.cpp
src/glslang/glslang/MachineIndependent/Scan.h
src/glslang/glslang/MachineIndependent/reflection.h
src/glslang/glslang/MachineIndependent/ScanContext.h
src/glslang/glslang/MachineIndependent/SpirvIntrinsics.cpp
src/glslang/glslang/OSDependent/osinclude.h
src/glslang/glslang/GenericCodeGen/Link.cpp
src/glslang/glslang/GenericCodeGen/CodeGen.cpp
src/glslang/glslang/Public/ShaderLang.h
src/glslang/glslang/Include/ConstantUnion.h
src/glslang/glslang/Include/InitializeGlobals.h
src/glslang/glslang/Include/Common.h
src/glslang/glslang/Include/PoolAlloc.h
src/glslang/glslang/Include/arrays.h
src/glslang/glslang/Include/ShHandle.h
src/glslang/glslang/Include/InfoSink.h
src/glslang/glslang/Include/ResourceLimits.h
src/glslang/glslang/Include/Types.h
src/glslang/glslang/Include/BaseTypes.h
src/glslang/glslang/Include/intermediate.h
src/glslang/glslang/Include/SpirvIntrinsics.h
src/glslang/glslang/Include/build_info.h
src/glslang/glslang/OSDependent/osinclude.h
src/glslang/spirv/Logger.h
src/glslang/spirv/GlslangToSpv.cpp
src/glslang/spirv/SPVRemapper.h
src/glslang/spirv/GLSL.ext.EXT.h
src/glslang/spirv/hex_float.h
src/glslang/spirv/doc.cpp
src/glslang/spirv/disassemble.cpp
src/glslang/spirv/SpvPostProcess.cpp
src/glslang/spirv/bitutils.h
src/glslang/spirv/InReadableOrder.cpp
src/glslang/spirv/GLSL.ext.AMD.h
src/glslang/spirv/GLSL.ext.NV.h
src/glslang/spirv/SPVRemapper.cpp
src/glslang/spirv/SpvBuilder.h
src/glslang/spirv/GLSL.ext.KHR.h
src/glslang/spirv/disassemble.h
src/glslang/spirv/SpvBuilder.cpp
src/glslang/spirv/GlslangToSpv.h
src/glslang/spirv/doc.h
src/glslang/spirv/SpvTools.cpp
src/glslang/spirv/spvIR.h
src/glslang/spirv/Logger.cpp
src/glslang/spirv/SpvTools.h
src/glslang/spirv/GLSL.std.450.h
src/glslang/spirv/NonSemanticDebugPrintf.h
src/glslang/OGLCompilersDLL/InitializeDll.cpp
src/glslang/OGLCompilersDLL/InitializeDll.h
)
set(ZVULKAN_INCLUDES
include/zvulkan/vulkanbuilders.h
include/zvulkan/vulkancompatibledevice.h
include/zvulkan/vulkandevice.h
include/zvulkan/vulkaninstance.h
include/zvulkan/vulkanobjects.h
include/zvulkan/vulkansurface.h
include/zvulkan/vulkanswapchain.h
include/zvulkan/volk/volk.h
include/zvulkan/vk_mem_alloc/vk_mem_alloc.h
)
set(ZVULKAN_WIN32_SOURCES
src/glslang/glslang/OSDependent/Windows/ossource.cpp
)
set(ZVULKAN_UNIX_SOURCES
src/glslang/glslang/OSDependent/Unix/ossource.cpp
)
set(VULKAN_INCLUDES
include/vulkan/vk_enum_string_helper.h
include/vulkan/vk_icd.h
include/vulkan/vk_layer.h
include/vulkan/vk_layer_dispatch_table.h
include/vulkan/vk_platform.h
include/vulkan/vk_sdk_platform.h
include/vulkan/vulkan.h
include/vulkan/vulkan_android.h
include/vulkan/vulkan_beta.h
include/vulkan/vulkan_core.h
include/vulkan/vulkan_directfb.h
include/vulkan/vulkan_fuchsia.h
include/vulkan/vulkan_ggp.h
include/vulkan/vulkan_ios.h
include/vulkan/vulkan_macos.h
include/vulkan/vulkan_metal.h
include/vulkan/vulkan_mir.h
include/vulkan/vulkan_screen.h
include/vulkan/vulkan_vi.h
include/vulkan/vulkan_wayland.h
include/vulkan/vulkan_win32.h
include/vulkan/vulkan_xcb.h
include/vulkan/vulkan_xlib.h
include/vulkan/vulkan_xlib_xrandr.h
)
source_group("src" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/.+")
source_group("src\\glslang" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/.+")
source_group("src\\glslang\\glslang" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/.+")
source_group("src\\glslang\\glslang\\GenericCodeGen" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/GenericCodeGen/.+")
source_group("src\\glslang\\glslang\\Include" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/Include/.+")
source_group("src\\glslang\\glslang\\MachineIndependent" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/MachineIndependent/.+")
source_group("src\\glslang\\glslang\\MachineIndependent\\preprocessor" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/MachineIndependent/preprocessor/.+")
source_group("src\\glslang\\glslang\\OSDependent" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/OSDependent/.+")
source_group("src\\glslang\\glslang\\OSDependent\\Unix" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/OSDependent/Unix/.+")
source_group("src\\glslang\\glslang\\OSDependent\\Web" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/OSDependent/Web/.+")
source_group("src\\glslang\\glslang\\OSDependent\\Windows" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/OSDependent/Windows/.+")
source_group("src\\glslang\\glslang\\Public" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/glslang/Public/.+")
source_group("src\\glslang\\OGLCompilersDLL" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/OGLCompilersDLL/.+")
source_group("src\\glslang\\spirv" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/glslang/spirv/.+")
source_group("src\\vk_mem_alloc" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/vk_mem_alloc/.+")
source_group("src\\volk" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/src/volk/.+")
source_group("include" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/include/zvulkan/.+")
source_group("include\\vk_mem_alloc" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/include/zvulkan/vk_mem_alloc/.+")
source_group("include\\volk" REGULAR_EXPRESSION "${CMAKE_CURRENT_SOURCE_DIR}/include/zvulkan/volk/.+")
include_directories(include include/zvulkan src)
if(WIN32)
set(ZVULKAN_SOURCES ${ZVULKAN_SOURCES} ${ZVULKAN_WIN32_SOURCES})
add_definitions(-DUNICODE -D_UNICODE)
else()
set(ZVULKAN_SOURCES ${ZVULKAN_SOURCES} ${ZVULKAN_UNIX_SOURCES})
set(ZVULKAN_LIBS ${CMAKE_DL_LIBS} -ldl)
add_definitions(-DUNIX -D_UNIX)
add_link_options(-pthread)
endif()
if(MSVC)
# Use all cores for compilation
set(CMAKE_CXX_FLAGS "/MP ${CMAKE_CXX_FLAGS}")
# Ignore warnings in third party code
#set_source_files_properties(${ZVULKAN_SOURCES} PROPERTIES COMPILE_FLAGS "/wd4244 /wd4267 /wd4005 /wd4018 -D_CRT_SECURE_NO_WARNINGS")
endif()
add_library(zvulkan STATIC ${ZVULKAN_SOURCES} ${ZVULKAN_INCLUDES} ${VULKAN_INCLUDES})
target_link_libraries(zvulkan ${ZVULKAN_LIBS})
set_target_properties(zvulkan PROPERTIES CXX_STANDARD 17)
if(MSVC)
set_property(TARGET zvulkan PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

View file

@ -0,0 +1,90 @@
# License information
## License for ZVulkan itself
// Copyright (c) 2016-2022 Magnus Norddahl
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
## License for src/vk_mem_alloc
// Copyright (c) 2017-2018 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
## License for src/volk
/**
* Copyright (c) 2018-2019 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
## License for include/zvulkan/vulkan
/*
** Copyright (c) 2015-2019 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
## License for src/glslang
See src/glslang/LICENSE.txt

View file

@ -0,0 +1,2 @@
# ZVulkan
A framework for building vulkan applications

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,525 @@
// *** THIS FILE IS GENERATED - DO NOT EDIT ***
// See loader_extension_generator.py for modifications
/*
* Copyright (c) 2015-2017 The Khronos Group Inc.
* Copyright (c) 2015-2017 Valve Corporation
* Copyright (c) 2015-2017 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Mark Lobodzinski <mark@lunarg.com>
* Author: Mark Young <marky@lunarg.com>
*/
#pragma once
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
// Instance function pointer dispatch table
typedef struct VkLayerInstanceDispatchTable_ {
// Manually add in GetPhysicalDeviceProcAddr entry
PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr;
// ---- Core 1_0 commands
PFN_vkCreateInstance CreateInstance;
PFN_vkDestroyInstance DestroyInstance;
PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
PFN_vkCreateDevice CreateDevice;
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
PFN_vkEnumerateInstanceLayerProperties EnumerateInstanceLayerProperties;
PFN_vkEnumerateDeviceLayerProperties EnumerateDeviceLayerProperties;
PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
// ---- Core 1_1 commands
PFN_vkEnumerateInstanceVersion EnumerateInstanceVersion;
PFN_vkEnumeratePhysicalDeviceGroups EnumeratePhysicalDeviceGroups;
PFN_vkGetPhysicalDeviceFeatures2 GetPhysicalDeviceFeatures2;
PFN_vkGetPhysicalDeviceProperties2 GetPhysicalDeviceProperties2;
PFN_vkGetPhysicalDeviceFormatProperties2 GetPhysicalDeviceFormatProperties2;
PFN_vkGetPhysicalDeviceImageFormatProperties2 GetPhysicalDeviceImageFormatProperties2;
PFN_vkGetPhysicalDeviceQueueFamilyProperties2 GetPhysicalDeviceQueueFamilyProperties2;
PFN_vkGetPhysicalDeviceMemoryProperties2 GetPhysicalDeviceMemoryProperties2;
PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 GetPhysicalDeviceSparseImageFormatProperties2;
PFN_vkGetPhysicalDeviceExternalBufferProperties GetPhysicalDeviceExternalBufferProperties;
PFN_vkGetPhysicalDeviceExternalFenceProperties GetPhysicalDeviceExternalFenceProperties;
PFN_vkGetPhysicalDeviceExternalSemaphoreProperties GetPhysicalDeviceExternalSemaphoreProperties;
// ---- VK_KHR_surface extension commands
PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR;
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR;
// ---- VK_KHR_swapchain extension commands
PFN_vkGetPhysicalDevicePresentRectanglesKHR GetPhysicalDevicePresentRectanglesKHR;
// ---- VK_KHR_display extension commands
PFN_vkGetPhysicalDeviceDisplayPropertiesKHR GetPhysicalDeviceDisplayPropertiesKHR;
PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR GetPhysicalDeviceDisplayPlanePropertiesKHR;
PFN_vkGetDisplayPlaneSupportedDisplaysKHR GetDisplayPlaneSupportedDisplaysKHR;
PFN_vkGetDisplayModePropertiesKHR GetDisplayModePropertiesKHR;
PFN_vkCreateDisplayModeKHR CreateDisplayModeKHR;
PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR;
PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR;
// ---- VK_KHR_xlib_surface extension commands
#ifdef VK_USE_PLATFORM_XLIB_KHR
PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR;
#endif // VK_USE_PLATFORM_XLIB_KHR
#ifdef VK_USE_PLATFORM_XLIB_KHR
PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR GetPhysicalDeviceXlibPresentationSupportKHR;
#endif // VK_USE_PLATFORM_XLIB_KHR
// ---- VK_KHR_xcb_surface extension commands
#ifdef VK_USE_PLATFORM_XCB_KHR
PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR;
#endif // VK_USE_PLATFORM_XCB_KHR
#ifdef VK_USE_PLATFORM_XCB_KHR
PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR GetPhysicalDeviceXcbPresentationSupportKHR;
#endif // VK_USE_PLATFORM_XCB_KHR
// ---- VK_KHR_wayland_surface extension commands
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR;
#endif // VK_USE_PLATFORM_WAYLAND_KHR
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR GetPhysicalDeviceWaylandPresentationSupportKHR;
#endif // VK_USE_PLATFORM_WAYLAND_KHR
// ---- VK_KHR_mir_surface extension commands
#ifdef VK_USE_PLATFORM_MIR_KHR
PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR;
#endif // VK_USE_PLATFORM_MIR_KHR
#ifdef VK_USE_PLATFORM_MIR_KHR
PFN_vkGetPhysicalDeviceMirPresentationSupportKHR GetPhysicalDeviceMirPresentationSupportKHR;
#endif // VK_USE_PLATFORM_MIR_KHR
// ---- VK_KHR_android_surface extension commands
#ifdef VK_USE_PLATFORM_ANDROID_KHR
PFN_vkCreateAndroidSurfaceKHR CreateAndroidSurfaceKHR;
#endif // VK_USE_PLATFORM_ANDROID_KHR
// ---- VK_KHR_win32_surface extension commands
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR;
#endif // VK_USE_PLATFORM_WIN32_KHR
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR GetPhysicalDeviceWin32PresentationSupportKHR;
#endif // VK_USE_PLATFORM_WIN32_KHR
// ---- VK_KHR_get_physical_device_properties2 extension commands
PFN_vkGetPhysicalDeviceFeatures2KHR GetPhysicalDeviceFeatures2KHR;
PFN_vkGetPhysicalDeviceProperties2KHR GetPhysicalDeviceProperties2KHR;
PFN_vkGetPhysicalDeviceFormatProperties2KHR GetPhysicalDeviceFormatProperties2KHR;
PFN_vkGetPhysicalDeviceImageFormatProperties2KHR GetPhysicalDeviceImageFormatProperties2KHR;
PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR GetPhysicalDeviceQueueFamilyProperties2KHR;
PFN_vkGetPhysicalDeviceMemoryProperties2KHR GetPhysicalDeviceMemoryProperties2KHR;
PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR GetPhysicalDeviceSparseImageFormatProperties2KHR;
// ---- VK_KHR_device_group_creation extension commands
PFN_vkEnumeratePhysicalDeviceGroupsKHR EnumeratePhysicalDeviceGroupsKHR;
// ---- VK_KHR_external_memory_capabilities extension commands
PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR GetPhysicalDeviceExternalBufferPropertiesKHR;
// ---- VK_KHR_external_semaphore_capabilities extension commands
PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR GetPhysicalDeviceExternalSemaphorePropertiesKHR;
// ---- VK_KHR_external_fence_capabilities extension commands
PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR GetPhysicalDeviceExternalFencePropertiesKHR;
// ---- VK_KHR_get_surface_capabilities2 extension commands
PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR GetPhysicalDeviceSurfaceCapabilities2KHR;
PFN_vkGetPhysicalDeviceSurfaceFormats2KHR GetPhysicalDeviceSurfaceFormats2KHR;
// ---- VK_KHR_get_display_properties2 extension commands
PFN_vkGetPhysicalDeviceDisplayProperties2KHR GetPhysicalDeviceDisplayProperties2KHR;
PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR GetPhysicalDeviceDisplayPlaneProperties2KHR;
PFN_vkGetDisplayModeProperties2KHR GetDisplayModeProperties2KHR;
PFN_vkGetDisplayPlaneCapabilities2KHR GetDisplayPlaneCapabilities2KHR;
// ---- VK_EXT_debug_report extension commands
PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT;
PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT;
PFN_vkDebugReportMessageEXT DebugReportMessageEXT;
// ---- VK_NV_external_memory_capabilities extension commands
PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV GetPhysicalDeviceExternalImageFormatPropertiesNV;
// ---- VK_NN_vi_surface extension commands
#ifdef VK_USE_PLATFORM_VI_NN
PFN_vkCreateViSurfaceNN CreateViSurfaceNN;
#endif // VK_USE_PLATFORM_VI_NN
// ---- VK_NVX_device_generated_commands extension commands
PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX GetPhysicalDeviceGeneratedCommandsPropertiesNVX;
// ---- VK_EXT_direct_mode_display extension commands
PFN_vkReleaseDisplayEXT ReleaseDisplayEXT;
// ---- VK_EXT_acquire_xlib_display extension commands
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
PFN_vkAcquireXlibDisplayEXT AcquireXlibDisplayEXT;
#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
PFN_vkGetRandROutputDisplayEXT GetRandROutputDisplayEXT;
#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT
// ---- VK_EXT_display_surface_counter extension commands
PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT GetPhysicalDeviceSurfaceCapabilities2EXT;
// ---- VK_MVK_ios_surface extension commands
#ifdef VK_USE_PLATFORM_IOS_MVK
PFN_vkCreateIOSSurfaceMVK CreateIOSSurfaceMVK;
#endif // VK_USE_PLATFORM_IOS_MVK
// ---- VK_MVK_macos_surface extension commands
#ifdef VK_USE_PLATFORM_MACOS_MVK
PFN_vkCreateMacOSSurfaceMVK CreateMacOSSurfaceMVK;
#endif // VK_USE_PLATFORM_MACOS_MVK
// ---- VK_EXT_debug_utils extension commands
PFN_vkCreateDebugUtilsMessengerEXT CreateDebugUtilsMessengerEXT;
PFN_vkDestroyDebugUtilsMessengerEXT DestroyDebugUtilsMessengerEXT;
PFN_vkSubmitDebugUtilsMessageEXT SubmitDebugUtilsMessageEXT;
// ---- VK_EXT_sample_locations extension commands
PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT GetPhysicalDeviceMultisamplePropertiesEXT;
} VkLayerInstanceDispatchTable;
// Device function pointer dispatch table
typedef struct VkLayerDispatchTable_ {
// ---- Core 1_0 commands
PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
PFN_vkDestroyDevice DestroyDevice;
PFN_vkGetDeviceQueue GetDeviceQueue;
PFN_vkQueueSubmit QueueSubmit;
PFN_vkQueueWaitIdle QueueWaitIdle;
PFN_vkDeviceWaitIdle DeviceWaitIdle;
PFN_vkAllocateMemory AllocateMemory;
PFN_vkFreeMemory FreeMemory;
PFN_vkMapMemory MapMemory;
PFN_vkUnmapMemory UnmapMemory;
PFN_vkFlushMappedMemoryRanges FlushMappedMemoryRanges;
PFN_vkInvalidateMappedMemoryRanges InvalidateMappedMemoryRanges;
PFN_vkGetDeviceMemoryCommitment GetDeviceMemoryCommitment;
PFN_vkBindBufferMemory BindBufferMemory;
PFN_vkBindImageMemory BindImageMemory;
PFN_vkGetBufferMemoryRequirements GetBufferMemoryRequirements;
PFN_vkGetImageMemoryRequirements GetImageMemoryRequirements;
PFN_vkGetImageSparseMemoryRequirements GetImageSparseMemoryRequirements;
PFN_vkQueueBindSparse QueueBindSparse;
PFN_vkCreateFence CreateFence;
PFN_vkDestroyFence DestroyFence;
PFN_vkResetFences ResetFences;
PFN_vkGetFenceStatus GetFenceStatus;
PFN_vkWaitForFences WaitForFences;
PFN_vkCreateSemaphore CreateSemaphore;
PFN_vkDestroySemaphore DestroySemaphore;
PFN_vkCreateEvent CreateEvent;
PFN_vkDestroyEvent DestroyEvent;
PFN_vkGetEventStatus GetEventStatus;
PFN_vkSetEvent SetEvent;
PFN_vkResetEvent ResetEvent;
PFN_vkCreateQueryPool CreateQueryPool;
PFN_vkDestroyQueryPool DestroyQueryPool;
PFN_vkGetQueryPoolResults GetQueryPoolResults;
PFN_vkCreateBuffer CreateBuffer;
PFN_vkDestroyBuffer DestroyBuffer;
PFN_vkCreateBufferView CreateBufferView;
PFN_vkDestroyBufferView DestroyBufferView;
PFN_vkCreateImage CreateImage;
PFN_vkDestroyImage DestroyImage;
PFN_vkGetImageSubresourceLayout GetImageSubresourceLayout;
PFN_vkCreateImageView CreateImageView;
PFN_vkDestroyImageView DestroyImageView;
PFN_vkCreateShaderModule CreateShaderModule;
PFN_vkDestroyShaderModule DestroyShaderModule;
PFN_vkCreatePipelineCache CreatePipelineCache;
PFN_vkDestroyPipelineCache DestroyPipelineCache;
PFN_vkGetPipelineCacheData GetPipelineCacheData;
PFN_vkMergePipelineCaches MergePipelineCaches;
PFN_vkCreateGraphicsPipelines CreateGraphicsPipelines;
PFN_vkCreateComputePipelines CreateComputePipelines;
PFN_vkDestroyPipeline DestroyPipeline;
PFN_vkCreatePipelineLayout CreatePipelineLayout;
PFN_vkDestroyPipelineLayout DestroyPipelineLayout;
PFN_vkCreateSampler CreateSampler;
PFN_vkDestroySampler DestroySampler;
PFN_vkCreateDescriptorSetLayout CreateDescriptorSetLayout;
PFN_vkDestroyDescriptorSetLayout DestroyDescriptorSetLayout;
PFN_vkCreateDescriptorPool CreateDescriptorPool;
PFN_vkDestroyDescriptorPool DestroyDescriptorPool;
PFN_vkResetDescriptorPool ResetDescriptorPool;
PFN_vkAllocateDescriptorSets AllocateDescriptorSets;
PFN_vkFreeDescriptorSets FreeDescriptorSets;
PFN_vkUpdateDescriptorSets UpdateDescriptorSets;
PFN_vkCreateFramebuffer CreateFramebuffer;
PFN_vkDestroyFramebuffer DestroyFramebuffer;
PFN_vkCreateRenderPass CreateRenderPass;
PFN_vkDestroyRenderPass DestroyRenderPass;
PFN_vkGetRenderAreaGranularity GetRenderAreaGranularity;
PFN_vkCreateCommandPool CreateCommandPool;
PFN_vkDestroyCommandPool DestroyCommandPool;
PFN_vkResetCommandPool ResetCommandPool;
PFN_vkAllocateCommandBuffers AllocateCommandBuffers;
PFN_vkFreeCommandBuffers FreeCommandBuffers;
PFN_vkBeginCommandBuffer BeginCommandBuffer;
PFN_vkEndCommandBuffer EndCommandBuffer;
PFN_vkResetCommandBuffer ResetCommandBuffer;
PFN_vkCmdBindPipeline CmdBindPipeline;
PFN_vkCmdSetViewport CmdSetViewport;
PFN_vkCmdSetScissor CmdSetScissor;
PFN_vkCmdSetLineWidth CmdSetLineWidth;
PFN_vkCmdSetDepthBias CmdSetDepthBias;
PFN_vkCmdSetBlendConstants CmdSetBlendConstants;
PFN_vkCmdSetDepthBounds CmdSetDepthBounds;
PFN_vkCmdSetStencilCompareMask CmdSetStencilCompareMask;
PFN_vkCmdSetStencilWriteMask CmdSetStencilWriteMask;
PFN_vkCmdSetStencilReference CmdSetStencilReference;
PFN_vkCmdBindDescriptorSets CmdBindDescriptorSets;
PFN_vkCmdBindIndexBuffer CmdBindIndexBuffer;
PFN_vkCmdBindVertexBuffers CmdBindVertexBuffers;
PFN_vkCmdDraw CmdDraw;
PFN_vkCmdDrawIndexed CmdDrawIndexed;
PFN_vkCmdDrawIndirect CmdDrawIndirect;
PFN_vkCmdDrawIndexedIndirect CmdDrawIndexedIndirect;
PFN_vkCmdDispatch CmdDispatch;
PFN_vkCmdDispatchIndirect CmdDispatchIndirect;
PFN_vkCmdCopyBuffer CmdCopyBuffer;
PFN_vkCmdCopyImage CmdCopyImage;
PFN_vkCmdBlitImage CmdBlitImage;
PFN_vkCmdCopyBufferToImage CmdCopyBufferToImage;
PFN_vkCmdCopyImageToBuffer CmdCopyImageToBuffer;
PFN_vkCmdUpdateBuffer CmdUpdateBuffer;
PFN_vkCmdFillBuffer CmdFillBuffer;
PFN_vkCmdClearColorImage CmdClearColorImage;
PFN_vkCmdClearDepthStencilImage CmdClearDepthStencilImage;
PFN_vkCmdClearAttachments CmdClearAttachments;
PFN_vkCmdResolveImage CmdResolveImage;
PFN_vkCmdSetEvent CmdSetEvent;
PFN_vkCmdResetEvent CmdResetEvent;
PFN_vkCmdWaitEvents CmdWaitEvents;
PFN_vkCmdPipelineBarrier CmdPipelineBarrier;
PFN_vkCmdBeginQuery CmdBeginQuery;
PFN_vkCmdEndQuery CmdEndQuery;
PFN_vkCmdResetQueryPool CmdResetQueryPool;
PFN_vkCmdWriteTimestamp CmdWriteTimestamp;
PFN_vkCmdCopyQueryPoolResults CmdCopyQueryPoolResults;
PFN_vkCmdPushConstants CmdPushConstants;
PFN_vkCmdBeginRenderPass CmdBeginRenderPass;
PFN_vkCmdNextSubpass CmdNextSubpass;
PFN_vkCmdEndRenderPass CmdEndRenderPass;
PFN_vkCmdExecuteCommands CmdExecuteCommands;
// ---- Core 1_1 commands
PFN_vkBindBufferMemory2 BindBufferMemory2;
PFN_vkBindImageMemory2 BindImageMemory2;
PFN_vkGetDeviceGroupPeerMemoryFeatures GetDeviceGroupPeerMemoryFeatures;
PFN_vkCmdSetDeviceMask CmdSetDeviceMask;
PFN_vkCmdDispatchBase CmdDispatchBase;
PFN_vkGetImageMemoryRequirements2 GetImageMemoryRequirements2;
PFN_vkGetBufferMemoryRequirements2 GetBufferMemoryRequirements2;
PFN_vkGetImageSparseMemoryRequirements2 GetImageSparseMemoryRequirements2;
PFN_vkTrimCommandPool TrimCommandPool;
PFN_vkGetDeviceQueue2 GetDeviceQueue2;
PFN_vkCreateSamplerYcbcrConversion CreateSamplerYcbcrConversion;
PFN_vkDestroySamplerYcbcrConversion DestroySamplerYcbcrConversion;
PFN_vkCreateDescriptorUpdateTemplate CreateDescriptorUpdateTemplate;
PFN_vkDestroyDescriptorUpdateTemplate DestroyDescriptorUpdateTemplate;
PFN_vkUpdateDescriptorSetWithTemplate UpdateDescriptorSetWithTemplate;
PFN_vkGetDescriptorSetLayoutSupport GetDescriptorSetLayoutSupport;
// ---- VK_KHR_swapchain extension commands
PFN_vkCreateSwapchainKHR CreateSwapchainKHR;
PFN_vkDestroySwapchainKHR DestroySwapchainKHR;
PFN_vkGetSwapchainImagesKHR GetSwapchainImagesKHR;
PFN_vkAcquireNextImageKHR AcquireNextImageKHR;
PFN_vkQueuePresentKHR QueuePresentKHR;
PFN_vkGetDeviceGroupPresentCapabilitiesKHR GetDeviceGroupPresentCapabilitiesKHR;
PFN_vkGetDeviceGroupSurfacePresentModesKHR GetDeviceGroupSurfacePresentModesKHR;
PFN_vkAcquireNextImage2KHR AcquireNextImage2KHR;
// ---- VK_KHR_display_swapchain extension commands
PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR;
// ---- VK_KHR_device_group extension commands
PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR GetDeviceGroupPeerMemoryFeaturesKHR;
PFN_vkCmdSetDeviceMaskKHR CmdSetDeviceMaskKHR;
PFN_vkCmdDispatchBaseKHR CmdDispatchBaseKHR;
// ---- VK_KHR_maintenance1 extension commands
PFN_vkTrimCommandPoolKHR TrimCommandPoolKHR;
// ---- VK_KHR_external_memory_win32 extension commands
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetMemoryWin32HandleKHR GetMemoryWin32HandleKHR;
#endif // VK_USE_PLATFORM_WIN32_KHR
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetMemoryWin32HandlePropertiesKHR GetMemoryWin32HandlePropertiesKHR;
#endif // VK_USE_PLATFORM_WIN32_KHR
// ---- VK_KHR_external_memory_fd extension commands
PFN_vkGetMemoryFdKHR GetMemoryFdKHR;
PFN_vkGetMemoryFdPropertiesKHR GetMemoryFdPropertiesKHR;
// ---- VK_KHR_external_semaphore_win32 extension commands
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkImportSemaphoreWin32HandleKHR ImportSemaphoreWin32HandleKHR;
#endif // VK_USE_PLATFORM_WIN32_KHR
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetSemaphoreWin32HandleKHR GetSemaphoreWin32HandleKHR;
#endif // VK_USE_PLATFORM_WIN32_KHR
// ---- VK_KHR_external_semaphore_fd extension commands
PFN_vkImportSemaphoreFdKHR ImportSemaphoreFdKHR;
PFN_vkGetSemaphoreFdKHR GetSemaphoreFdKHR;
// ---- VK_KHR_push_descriptor extension commands
PFN_vkCmdPushDescriptorSetKHR CmdPushDescriptorSetKHR;
PFN_vkCmdPushDescriptorSetWithTemplateKHR CmdPushDescriptorSetWithTemplateKHR;
// ---- VK_KHR_descriptor_update_template extension commands
PFN_vkCreateDescriptorUpdateTemplateKHR CreateDescriptorUpdateTemplateKHR;
PFN_vkDestroyDescriptorUpdateTemplateKHR DestroyDescriptorUpdateTemplateKHR;
PFN_vkUpdateDescriptorSetWithTemplateKHR UpdateDescriptorSetWithTemplateKHR;
// ---- VK_KHR_shared_presentable_image extension commands
PFN_vkGetSwapchainStatusKHR GetSwapchainStatusKHR;
// ---- VK_KHR_external_fence_win32 extension commands
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkImportFenceWin32HandleKHR ImportFenceWin32HandleKHR;
#endif // VK_USE_PLATFORM_WIN32_KHR
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetFenceWin32HandleKHR GetFenceWin32HandleKHR;
#endif // VK_USE_PLATFORM_WIN32_KHR
// ---- VK_KHR_external_fence_fd extension commands
PFN_vkImportFenceFdKHR ImportFenceFdKHR;
PFN_vkGetFenceFdKHR GetFenceFdKHR;
// ---- VK_KHR_get_memory_requirements2 extension commands
PFN_vkGetImageMemoryRequirements2KHR GetImageMemoryRequirements2KHR;
PFN_vkGetBufferMemoryRequirements2KHR GetBufferMemoryRequirements2KHR;
PFN_vkGetImageSparseMemoryRequirements2KHR GetImageSparseMemoryRequirements2KHR;
// ---- VK_KHR_sampler_ycbcr_conversion extension commands
PFN_vkCreateSamplerYcbcrConversionKHR CreateSamplerYcbcrConversionKHR;
PFN_vkDestroySamplerYcbcrConversionKHR DestroySamplerYcbcrConversionKHR;
// ---- VK_KHR_bind_memory2 extension commands
PFN_vkBindBufferMemory2KHR BindBufferMemory2KHR;
PFN_vkBindImageMemory2KHR BindImageMemory2KHR;
// ---- VK_KHR_maintenance3 extension commands
PFN_vkGetDescriptorSetLayoutSupportKHR GetDescriptorSetLayoutSupportKHR;
// ---- VK_KHR_draw_indirect_count extension commands
PFN_vkCmdDrawIndirectCountKHR CmdDrawIndirectCountKHR;
PFN_vkCmdDrawIndexedIndirectCountKHR CmdDrawIndexedIndirectCountKHR;
// ---- VK_EXT_debug_marker extension commands
PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT;
PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT;
PFN_vkCmdDebugMarkerBeginEXT CmdDebugMarkerBeginEXT;
PFN_vkCmdDebugMarkerEndEXT CmdDebugMarkerEndEXT;
PFN_vkCmdDebugMarkerInsertEXT CmdDebugMarkerInsertEXT;
// ---- VK_AMD_draw_indirect_count extension commands
PFN_vkCmdDrawIndirectCountAMD CmdDrawIndirectCountAMD;
PFN_vkCmdDrawIndexedIndirectCountAMD CmdDrawIndexedIndirectCountAMD;
// ---- VK_AMD_shader_info extension commands
PFN_vkGetShaderInfoAMD GetShaderInfoAMD;
// ---- VK_NV_external_memory_win32 extension commands
#ifdef VK_USE_PLATFORM_WIN32_KHR
PFN_vkGetMemoryWin32HandleNV GetMemoryWin32HandleNV;
#endif // VK_USE_PLATFORM_WIN32_KHR
// ---- VK_NVX_device_generated_commands extension commands
PFN_vkCmdProcessCommandsNVX CmdProcessCommandsNVX;
PFN_vkCmdReserveSpaceForCommandsNVX CmdReserveSpaceForCommandsNVX;
PFN_vkCreateIndirectCommandsLayoutNVX CreateIndirectCommandsLayoutNVX;
PFN_vkDestroyIndirectCommandsLayoutNVX DestroyIndirectCommandsLayoutNVX;
PFN_vkCreateObjectTableNVX CreateObjectTableNVX;
PFN_vkDestroyObjectTableNVX DestroyObjectTableNVX;
PFN_vkRegisterObjectsNVX RegisterObjectsNVX;
PFN_vkUnregisterObjectsNVX UnregisterObjectsNVX;
// ---- VK_NV_clip_space_w_scaling extension commands
PFN_vkCmdSetViewportWScalingNV CmdSetViewportWScalingNV;
// ---- VK_EXT_display_control extension commands
PFN_vkDisplayPowerControlEXT DisplayPowerControlEXT;
PFN_vkRegisterDeviceEventEXT RegisterDeviceEventEXT;
PFN_vkRegisterDisplayEventEXT RegisterDisplayEventEXT;
PFN_vkGetSwapchainCounterEXT GetSwapchainCounterEXT;
// ---- VK_GOOGLE_display_timing extension commands
PFN_vkGetRefreshCycleDurationGOOGLE GetRefreshCycleDurationGOOGLE;
PFN_vkGetPastPresentationTimingGOOGLE GetPastPresentationTimingGOOGLE;
// ---- VK_EXT_discard_rectangles extension commands
PFN_vkCmdSetDiscardRectangleEXT CmdSetDiscardRectangleEXT;
// ---- VK_EXT_hdr_metadata extension commands
PFN_vkSetHdrMetadataEXT SetHdrMetadataEXT;
// ---- VK_EXT_debug_utils extension commands
PFN_vkSetDebugUtilsObjectNameEXT SetDebugUtilsObjectNameEXT;
PFN_vkSetDebugUtilsObjectTagEXT SetDebugUtilsObjectTagEXT;
PFN_vkQueueBeginDebugUtilsLabelEXT QueueBeginDebugUtilsLabelEXT;
PFN_vkQueueEndDebugUtilsLabelEXT QueueEndDebugUtilsLabelEXT;
PFN_vkQueueInsertDebugUtilsLabelEXT QueueInsertDebugUtilsLabelEXT;
PFN_vkCmdBeginDebugUtilsLabelEXT CmdBeginDebugUtilsLabelEXT;
PFN_vkCmdEndDebugUtilsLabelEXT CmdEndDebugUtilsLabelEXT;
PFN_vkCmdInsertDebugUtilsLabelEXT CmdInsertDebugUtilsLabelEXT;
// ---- VK_ANDROID_external_memory_android_hardware_buffer extension commands
#ifdef VK_USE_PLATFORM_ANDROID_KHR
PFN_vkGetAndroidHardwareBufferPropertiesANDROID GetAndroidHardwareBufferPropertiesANDROID;
#endif // VK_USE_PLATFORM_ANDROID_KHR
#ifdef VK_USE_PLATFORM_ANDROID_KHR
PFN_vkGetMemoryAndroidHardwareBufferANDROID GetMemoryAndroidHardwareBufferANDROID;
#endif // VK_USE_PLATFORM_ANDROID_KHR
// ---- VK_EXT_sample_locations extension commands
PFN_vkCmdSetSampleLocationsEXT CmdSetSampleLocationsEXT;
// ---- VK_EXT_validation_cache extension commands
PFN_vkCreateValidationCacheEXT CreateValidationCacheEXT;
PFN_vkDestroyValidationCacheEXT DestroyValidationCacheEXT;
PFN_vkMergeValidationCachesEXT MergeValidationCachesEXT;
PFN_vkGetValidationCacheDataEXT GetValidationCacheDataEXT;
// ---- VK_EXT_external_memory_host extension commands
PFN_vkGetMemoryHostPointerPropertiesEXT GetMemoryHostPointerPropertiesEXT;
// ---- VK_AMD_buffer_marker extension commands
PFN_vkCmdWriteBufferMarkerAMD CmdWriteBufferMarkerAMD;
} VkLayerDispatchTable;

View file

@ -0,0 +1,65 @@
#ifndef VULKAN_MIR_H_
#define VULKAN_MIR_H_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2015-2018 The Khronos Group Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#define VK_KHR_mir_surface 1
#define VK_KHR_MIR_SURFACE_SPEC_VERSION 4
#define VK_KHR_MIR_SURFACE_EXTENSION_NAME "VK_KHR_mir_surface"
typedef VkFlags VkMirSurfaceCreateFlagsKHR;
typedef struct VkMirSurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkMirSurfaceCreateFlagsKHR flags;
MirConnection* connection;
MirSurface* mirSurface;
} VkMirSurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateMirSurfaceKHR)(VkInstance instance, const VkMirSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection* connection);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
VkInstance instance,
const VkMirSurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex,
MirConnection* connection);
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,8 +1,123 @@
#pragma once #pragma once
#include "vk_objects.h" #include "vulkanobjects.h"
#include "zstring.h"
#include <cassert> #include <cassert>
#include <set>
class VulkanCompatibleDevice;
class VulkanInstanceBuilder
{
public:
VulkanInstanceBuilder();
VulkanInstanceBuilder& ApiVersionsToTry(const std::vector<uint32_t>& versions);
VulkanInstanceBuilder& RequireExtension(const std::string& extensionName);
VulkanInstanceBuilder& RequireSurfaceExtensions(bool enable = true);
VulkanInstanceBuilder& OptionalExtension(const std::string& extensionName);
VulkanInstanceBuilder& DebugLayer(bool enable = true);
std::shared_ptr<VulkanInstance> Create();
private:
std::vector<uint32_t> apiVersionsToTry;
std::set<std::string> requiredExtensions;
std::set<std::string> optionalExtensions;
bool debugLayer = false;
};
class VulkanSurfaceBuilder
{
public:
VulkanSurfaceBuilder();
#ifdef VK_USE_PLATFORM_WIN32_KHR
VulkanSurfaceBuilder& Win32Window(HWND handle);
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
VulkanSurfaceBuilder& X11Window(Display* disp, Window wind);
#endif
std::shared_ptr<VulkanSurface> Create(std::shared_ptr<VulkanInstance> instance);
private:
#ifdef VK_USE_PLATFORM_WIN32_KHR
HWND hwnd = {};
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
Display* disp = nullptr;
Window wind = {};
#endif
};
class VulkanDeviceBuilder
{
public:
VulkanDeviceBuilder();
VulkanDeviceBuilder& RequireExtension(const std::string& extensionName);
VulkanDeviceBuilder& OptionalExtension(const std::string& extensionName);
VulkanDeviceBuilder& OptionalRayQuery();
VulkanDeviceBuilder& OptionalDescriptorIndexing();
VulkanDeviceBuilder& Surface(std::shared_ptr<VulkanSurface> surface);
VulkanDeviceBuilder& SelectDevice(int index);
std::vector<VulkanCompatibleDevice> FindDevices(const std::shared_ptr<VulkanInstance>& instance);
std::shared_ptr<VulkanDevice> Create(std::shared_ptr<VulkanInstance> instance);
private:
std::set<std::string> requiredDeviceExtensions;
std::set<std::string> optionalDeviceExtensions;
std::shared_ptr<VulkanSurface> surface;
int deviceIndex = 0;
};
class VulkanSwapChainBuilder
{
public:
VulkanSwapChainBuilder();
std::shared_ptr<VulkanSwapChain> Create(VulkanDevice* device);
};
class CommandPoolBuilder
{
public:
CommandPoolBuilder();
CommandPoolBuilder& QueueFamily(int index);
CommandPoolBuilder& DebugName(const char* name) { debugName = name; return *this; }
std::unique_ptr<VulkanCommandPool> Create(VulkanDevice* device);
private:
const char* debugName = nullptr;
int queueFamilyIndex = -1;
};
class SemaphoreBuilder
{
public:
SemaphoreBuilder();
SemaphoreBuilder& DebugName(const char* name) { debugName = name; return *this; }
std::unique_ptr<VulkanSemaphore> Create(VulkanDevice* device);
private:
const char* debugName = nullptr;
};
class FenceBuilder
{
public:
FenceBuilder();
FenceBuilder& DebugName(const char* name) { debugName = name; return *this; }
std::unique_ptr<VulkanFence> Create(VulkanDevice* device);
private:
const char* debugName = nullptr;
};
class ImageBuilder class ImageBuilder
{ {
@ -55,6 +170,7 @@ public:
SamplerBuilder& MagFilter(VkFilter magFilter); SamplerBuilder& MagFilter(VkFilter magFilter);
SamplerBuilder& MipmapMode(VkSamplerMipmapMode mode); SamplerBuilder& MipmapMode(VkSamplerMipmapMode mode);
SamplerBuilder& Anisotropy(float maxAnisotropy); SamplerBuilder& Anisotropy(float maxAnisotropy);
SamplerBuilder& MipLodBias(float bias);
SamplerBuilder& MaxLod(float value); SamplerBuilder& MaxLod(float value);
SamplerBuilder& DebugName(const char* name) { debugName = name; return *this; } SamplerBuilder& DebugName(const char* name) { debugName = name; return *this; }
@ -88,14 +204,17 @@ class ShaderBuilder
public: public:
ShaderBuilder(); ShaderBuilder();
ShaderBuilder& VertexShader(const FString &code); static void Init();
ShaderBuilder& FragmentShader(const FString &code); static void Deinit();
ShaderBuilder& VertexShader(const std::string &code);
ShaderBuilder& FragmentShader(const std::string&code);
ShaderBuilder& DebugName(const char* name) { debugName = name; return *this; } ShaderBuilder& DebugName(const char* name) { debugName = name; return *this; }
std::unique_ptr<VulkanShader> Create(const char *shadername, VulkanDevice *device); std::unique_ptr<VulkanShader> Create(const char *shadername, VulkanDevice *device);
private: private:
FString code; std::string code;
int stage = 0; int stage = 0;
const char* debugName = nullptr; const char* debugName = nullptr;
}; };
@ -139,14 +258,17 @@ class DescriptorSetLayoutBuilder
public: public:
DescriptorSetLayoutBuilder(); DescriptorSetLayoutBuilder();
DescriptorSetLayoutBuilder& AddBinding(int binding, VkDescriptorType type, int arrayCount, VkShaderStageFlags stageFlags); DescriptorSetLayoutBuilder& Flags(VkDescriptorSetLayoutCreateFlags flags);
DescriptorSetLayoutBuilder& AddBinding(int binding, VkDescriptorType type, int arrayCount, VkShaderStageFlags stageFlags, VkDescriptorBindingFlags flags = 0);
DescriptorSetLayoutBuilder& DebugName(const char* name) { debugName = name; return *this; } DescriptorSetLayoutBuilder& DebugName(const char* name) { debugName = name; return *this; }
std::unique_ptr<VulkanDescriptorSetLayout> Create(VulkanDevice *device); std::unique_ptr<VulkanDescriptorSetLayout> Create(VulkanDevice *device);
private: private:
VkDescriptorSetLayoutCreateInfo layoutInfo = {}; VkDescriptorSetLayoutCreateInfo layoutInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO };
TArray<VkDescriptorSetLayoutBinding> bindings; VkDescriptorSetLayoutBindingFlagsCreateInfoEXT bindingFlagsInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT };
std::vector<VkDescriptorSetLayoutBinding> bindings;
std::vector<VkDescriptorBindingFlags> bindingFlags;
const char* debugName = nullptr; const char* debugName = nullptr;
}; };
@ -155,6 +277,7 @@ class DescriptorPoolBuilder
public: public:
DescriptorPoolBuilder(); DescriptorPoolBuilder();
DescriptorPoolBuilder& Flags(VkDescriptorPoolCreateFlags flags);
DescriptorPoolBuilder& MaxSets(int value); DescriptorPoolBuilder& MaxSets(int value);
DescriptorPoolBuilder& AddPoolSize(VkDescriptorType type, int count); DescriptorPoolBuilder& AddPoolSize(VkDescriptorType type, int count);
DescriptorPoolBuilder& DebugName(const char* name) { debugName = name; return *this; } DescriptorPoolBuilder& DebugName(const char* name) { debugName = name; return *this; }
@ -201,8 +324,6 @@ private:
const char* debugName = nullptr; const char* debugName = nullptr;
}; };
union FRenderStyle;
class GraphicsPipelineBuilder class GraphicsPipelineBuilder
{ {
public: public:
@ -226,7 +347,6 @@ public:
GraphicsPipelineBuilder& AdditiveBlendMode(); GraphicsPipelineBuilder& AdditiveBlendMode();
GraphicsPipelineBuilder& AlphaBlendMode(); GraphicsPipelineBuilder& AlphaBlendMode();
GraphicsPipelineBuilder& BlendMode(const FRenderStyle &style);
GraphicsPipelineBuilder& BlendMode(VkBlendOp op, VkBlendFactor src, VkBlendFactor dst); GraphicsPipelineBuilder& BlendMode(VkBlendOp op, VkBlendFactor src, VkBlendFactor dst);
GraphicsPipelineBuilder& SubpassColorAttachmentCount(int count); GraphicsPipelineBuilder& SubpassColorAttachmentCount(int count);
@ -364,6 +484,7 @@ public:
WriteDescriptors& AddBuffer(VulkanDescriptorSet *descriptorSet, int binding, VkDescriptorType type, VulkanBuffer *buffer, size_t offset, size_t range); WriteDescriptors& AddBuffer(VulkanDescriptorSet *descriptorSet, int binding, VkDescriptorType type, VulkanBuffer *buffer, size_t offset, size_t range);
WriteDescriptors& AddStorageImage(VulkanDescriptorSet *descriptorSet, int binding, VulkanImageView *view, VkImageLayout imageLayout); WriteDescriptors& AddStorageImage(VulkanDescriptorSet *descriptorSet, int binding, VulkanImageView *view, VkImageLayout imageLayout);
WriteDescriptors& AddCombinedImageSampler(VulkanDescriptorSet *descriptorSet, int binding, VulkanImageView *view, VulkanSampler *sampler, VkImageLayout imageLayout); WriteDescriptors& AddCombinedImageSampler(VulkanDescriptorSet *descriptorSet, int binding, VulkanImageView *view, VulkanSampler *sampler, VkImageLayout imageLayout);
WriteDescriptors& AddCombinedImageSampler(VulkanDescriptorSet* descriptorSet, int binding, int arrayIndex, VulkanImageView* view, VulkanSampler* sampler, VkImageLayout imageLayout);
WriteDescriptors& AddAccelerationStructure(VulkanDescriptorSet* descriptorSet, int binding, VulkanAccelerationStructure* accelStruct); WriteDescriptors& AddAccelerationStructure(VulkanDescriptorSet* descriptorSet, int binding, VulkanAccelerationStructure* accelStruct);
void Execute(VulkanDevice *device); void Execute(VulkanDevice *device);

View file

@ -0,0 +1,19 @@
#pragma once
#include "vulkaninstance.h"
class VulkanSurface;
class VulkanCompatibleDevice
{
public:
VulkanPhysicalDevice* Device = nullptr;
int GraphicsFamily = -1;
int PresentFamily = -1;
bool GraphicsTimeQueries = false;
std::set<std::string> EnabledDeviceExtensions;
VulkanDeviceFeatures EnabledFeatures;
};

View file

@ -0,0 +1,52 @@
#pragma once
#include "vulkaninstance.h"
#include <functional>
#include <mutex>
#include <vector>
#include <algorithm>
#include <memory>
class VulkanSwapChain;
class VulkanSemaphore;
class VulkanFence;
class VulkanPhysicalDevice;
class VulkanSurface;
class VulkanCompatibleDevice;
class VulkanDevice
{
public:
VulkanDevice(std::shared_ptr<VulkanInstance> instance, std::shared_ptr<VulkanSurface> surface, const VulkanCompatibleDevice& selectedDevice);
~VulkanDevice();
std::set<std::string> EnabledDeviceExtensions;
VulkanDeviceFeatures EnabledFeatures;
VulkanPhysicalDevice PhysicalDevice;
std::shared_ptr<VulkanInstance> Instance;
std::shared_ptr<VulkanSurface> Surface;
VkDevice device = VK_NULL_HANDLE;
VmaAllocator allocator = VK_NULL_HANDLE;
VkQueue GraphicsQueue = VK_NULL_HANDLE;
VkQueue PresentQueue = VK_NULL_HANDLE;
int GraphicsFamily = -1;
int PresentFamily = -1;
bool GraphicsTimeQueries = false;
bool SupportsDeviceExtension(const char* ext) const;
void SetObjectName(const char* name, uint64_t handle, VkObjectType type);
private:
bool DebugLayerActive = false;
void CreateDevice();
void CreateAllocator();
void ReleaseResources();
};

View file

@ -0,0 +1,96 @@
#pragma once
#if defined(_WIN32)
#define VK_USE_PLATFORM_WIN32_KHR
#elif defined(__APPLE__)
#define VK_USE_PLATFORM_MACOS_MVK
#define VK_USE_PLATFORM_METAL_EXT
#else
#define VK_USE_PLATFORM_XLIB_KHR
#endif
#include "volk/volk.h"
#include "vk_mem_alloc/vk_mem_alloc.h"
#if defined(_WIN32)
#undef min
#undef max
#endif
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <set>
class VulkanDeviceFeatures
{
public:
VkPhysicalDeviceFeatures Features = {};
VkPhysicalDeviceBufferDeviceAddressFeatures BufferDeviceAddress = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES };
VkPhysicalDeviceAccelerationStructureFeaturesKHR AccelerationStructure = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR };
VkPhysicalDeviceRayQueryFeaturesKHR RayQuery = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR };
VkPhysicalDeviceDescriptorIndexingFeatures DescriptorIndexing = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT };
};
class VulkanPhysicalDevice
{
public:
VkPhysicalDevice Device = VK_NULL_HANDLE;
std::vector<VkExtensionProperties> Extensions;
std::vector<VkQueueFamilyProperties> QueueFamilies;
VkPhysicalDeviceProperties Properties = {};
VkPhysicalDeviceMemoryProperties MemoryProperties = {};
VulkanDeviceFeatures Features;
};
class VulkanInstance
{
public:
VulkanInstance(std::vector<uint32_t> apiVersionsToTry, std::set<std::string> requiredExtensions, std::set<std::string> optionalExtensions, bool wantDebugLayer);
~VulkanInstance();
std::vector<uint32_t> ApiVersionsToTry;
std::set<std::string> RequiredExtensions;
std::set<std::string> OptionalExtensions;
std::vector<VkLayerProperties> AvailableLayers;
std::vector<VkExtensionProperties> AvailableExtensions;
std::set<std::string> EnabledValidationLayers;
std::set<std::string> EnabledExtensions;
std::vector<VulkanPhysicalDevice> PhysicalDevices;
uint32_t ApiVersion = {};
VkInstance Instance = VK_NULL_HANDLE;
bool DebugLayerActive = false;
private:
bool WantDebugLayer = false;
VkDebugUtilsMessengerEXT debugMessenger = VK_NULL_HANDLE;
void CreateInstance();
void ReleaseResources();
static void InitVolk();
static std::vector<VkLayerProperties> GetAvailableLayers();
static std::vector<VkExtensionProperties> GetExtensions();
static std::vector<VulkanPhysicalDevice> GetPhysicalDevices(VkInstance instance, uint32_t apiVersion);
static VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData);
static std::vector<std::string> SplitString(const std::string& s, const std::string& seperator);
};
std::string VkResultToString(VkResult result);
void VulkanPrintLog(const char* typestr, const std::string& msg);
void VulkanError(const char* text);
inline void CheckVulkanError(VkResult result, const char* text)
{
if (result >= VK_SUCCESS) return;
VulkanError((text + std::string(": ") + VkResultToString(result)).c_str());
}

View file

@ -1,10 +1,10 @@
#pragma once #pragma once
#include "vk_device.h" #include "vulkandevice.h"
#include "engineerrors.h"
class VulkanCommandPool; class VulkanCommandPool;
class VulkanDescriptorPool; class VulkanDescriptorPool;
class VulkanCommandBuffer;
class VulkanSemaphore class VulkanSemaphore
{ {
@ -12,7 +12,7 @@ public:
VulkanSemaphore(VulkanDevice *device); VulkanSemaphore(VulkanDevice *device);
~VulkanSemaphore(); ~VulkanSemaphore();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)semaphore, VK_OBJECT_TYPE_SEMAPHORE); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)semaphore, VK_OBJECT_TYPE_SEMAPHORE); }
VulkanDevice *device = nullptr; VulkanDevice *device = nullptr;
VkSemaphore semaphore = VK_NULL_HANDLE; VkSemaphore semaphore = VK_NULL_HANDLE;
@ -28,7 +28,7 @@ public:
VulkanFence(VulkanDevice *device); VulkanFence(VulkanDevice *device);
~VulkanFence(); ~VulkanFence();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)fence, VK_OBJECT_TYPE_FENCE); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)fence, VK_OBJECT_TYPE_FENCE); }
VulkanDevice *device = nullptr; VulkanDevice *device = nullptr;
VkFence fence = VK_NULL_HANDLE; VkFence fence = VK_NULL_HANDLE;
@ -52,10 +52,10 @@ public:
} }
#ifdef _DEBUG #ifdef _DEBUG
void SetDebugName(const char* name) { debugName = name; device->SetDebugObjectName(name, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER); } void SetDebugName(const char* name) { debugName = name; device->SetObjectName(name, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER); }
std::string debugName; std::string debugName;
#else #else
void SetDebugName(const char* name) { device->SetDebugObjectName(name, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER); } void SetDebugName(const char* name) { device->SetObjectName(name, (uint64_t)buffer, VK_OBJECT_TYPE_BUFFER); }
#endif #endif
VulkanDevice *device = nullptr; VulkanDevice *device = nullptr;
@ -78,7 +78,7 @@ public:
VulkanFramebuffer(VulkanDevice *device, VkFramebuffer framebuffer); VulkanFramebuffer(VulkanDevice *device, VkFramebuffer framebuffer);
~VulkanFramebuffer(); ~VulkanFramebuffer();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)framebuffer, VK_OBJECT_TYPE_FRAMEBUFFER); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)framebuffer, VK_OBJECT_TYPE_FRAMEBUFFER); }
VulkanDevice *device; VulkanDevice *device;
VkFramebuffer framebuffer; VkFramebuffer framebuffer;
@ -94,7 +94,7 @@ public:
VulkanImage(VulkanDevice *device, VkImage image, VmaAllocation allocation, int width, int height, int mipLevels, int layerCount); VulkanImage(VulkanDevice *device, VkImage image, VmaAllocation allocation, int width, int height, int mipLevels, int layerCount);
~VulkanImage(); ~VulkanImage();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)image, VK_OBJECT_TYPE_IMAGE); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)image, VK_OBJECT_TYPE_IMAGE); }
VkImage image = VK_NULL_HANDLE; VkImage image = VK_NULL_HANDLE;
int width = 0; int width = 0;
@ -119,7 +119,7 @@ public:
VulkanImageView(VulkanDevice *device, VkImageView view); VulkanImageView(VulkanDevice *device, VkImageView view);
~VulkanImageView(); ~VulkanImageView();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)view, VK_OBJECT_TYPE_IMAGE_VIEW); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)view, VK_OBJECT_TYPE_IMAGE_VIEW); }
VkImageView view = VK_NULL_HANDLE; VkImageView view = VK_NULL_HANDLE;
@ -136,7 +136,7 @@ public:
VulkanSampler(VulkanDevice *device, VkSampler sampler); VulkanSampler(VulkanDevice *device, VkSampler sampler);
~VulkanSampler(); ~VulkanSampler();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)sampler, VK_OBJECT_TYPE_SAMPLER); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)sampler, VK_OBJECT_TYPE_SAMPLER); }
VkSampler sampler = VK_NULL_HANDLE; VkSampler sampler = VK_NULL_HANDLE;
@ -153,7 +153,7 @@ public:
VulkanShader(VulkanDevice *device, VkShaderModule module); VulkanShader(VulkanDevice *device, VkShaderModule module);
~VulkanShader(); ~VulkanShader();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)module, VK_OBJECT_TYPE_SHADER_MODULE); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)module, VK_OBJECT_TYPE_SHADER_MODULE); }
VkShaderModule module = VK_NULL_HANDLE; VkShaderModule module = VK_NULL_HANDLE;
@ -170,7 +170,7 @@ public:
VulkanDescriptorSetLayout(VulkanDevice *device, VkDescriptorSetLayout layout); VulkanDescriptorSetLayout(VulkanDevice *device, VkDescriptorSetLayout layout);
~VulkanDescriptorSetLayout(); ~VulkanDescriptorSetLayout();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)layout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)layout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT); }
VulkanDevice *device; VulkanDevice *device;
VkDescriptorSetLayout layout; VkDescriptorSetLayout layout;
@ -187,10 +187,10 @@ public:
~VulkanDescriptorSet(); ~VulkanDescriptorSet();
#ifdef _DEBUG #ifdef _DEBUG
void SetDebugName(const char* name) { debugName = name; device->SetDebugObjectName(name, (uint64_t)set, VK_OBJECT_TYPE_DESCRIPTOR_SET); } void SetDebugName(const char* name) { debugName = name; device->SetObjectName(name, (uint64_t)set, VK_OBJECT_TYPE_DESCRIPTOR_SET); }
std::string debugName; std::string debugName;
#else #else
void SetDebugName(const char* name) { device->SetDebugObjectName(name, (uint64_t)set, VK_OBJECT_TYPE_DESCRIPTOR_SET); } void SetDebugName(const char* name) { device->SetObjectName(name, (uint64_t)set, VK_OBJECT_TYPE_DESCRIPTOR_SET); }
#endif #endif
VulkanDevice *device; VulkanDevice *device;
@ -209,19 +209,25 @@ public:
~VulkanDescriptorPool(); ~VulkanDescriptorPool();
#ifdef _DEBUG #ifdef _DEBUG
void SetDebugName(const char* name) { debugName = name; device->SetDebugObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_DESCRIPTOR_POOL); } void SetDebugName(const char* name) { debugName = name; device->SetObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_DESCRIPTOR_POOL); }
std::string debugName; std::string debugName;
#else #else
void SetDebugName(const char* name) { device->SetDebugObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_DESCRIPTOR_POOL); } void SetDebugName(const char* name) { device->SetObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_DESCRIPTOR_POOL); }
#endif #endif
std::unique_ptr<VulkanDescriptorSet> tryAllocate(VulkanDescriptorSetLayout *layout); std::unique_ptr<VulkanDescriptorSet> tryAllocate(VulkanDescriptorSetLayout *layout);
std::unique_ptr<VulkanDescriptorSet> tryAllocate(VulkanDescriptorSetLayout* layout, uint32_t bindlessCount);
std::unique_ptr<VulkanDescriptorSet> allocate(VulkanDescriptorSetLayout *layout); std::unique_ptr<VulkanDescriptorSet> allocate(VulkanDescriptorSetLayout *layout);
std::unique_ptr<VulkanDescriptorSet> allocate(VulkanDescriptorSetLayout* layout, uint32_t bindlessCount);
VulkanDevice *device; VulkanDevice *device;
VkDescriptorPool pool; VkDescriptorPool pool;
private: private:
enum class AllocType { TryAllocate, AlwaysAllocate };
std::unique_ptr<VulkanDescriptorSet> allocate(VulkanDescriptorSetLayout* layout, AllocType allocType);
std::unique_ptr<VulkanDescriptorSet> allocate(VulkanDescriptorSetLayout* layout, uint32_t bindlessCount, AllocType allocType);
VulkanDescriptorPool(const VulkanDescriptorPool &) = delete; VulkanDescriptorPool(const VulkanDescriptorPool &) = delete;
VulkanDescriptorPool &operator=(const VulkanDescriptorPool &) = delete; VulkanDescriptorPool &operator=(const VulkanDescriptorPool &) = delete;
}; };
@ -232,7 +238,7 @@ public:
VulkanQueryPool(VulkanDevice *device, VkQueryPool pool); VulkanQueryPool(VulkanDevice *device, VkQueryPool pool);
~VulkanQueryPool(); ~VulkanQueryPool();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_QUERY_POOL); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_QUERY_POOL); }
bool getResults(uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void *data, VkDeviceSize stride, VkQueryResultFlags flags); bool getResults(uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void *data, VkDeviceSize stride, VkQueryResultFlags flags);
@ -257,7 +263,7 @@ public:
return vkGetAccelerationStructureDeviceAddressKHR(device->device, &addressInfo); return vkGetAccelerationStructureDeviceAddressKHR(device->device, &addressInfo);
} }
void SetDebugName(const char* name) { device->SetDebugObjectName(name, (uint64_t)accelstruct, VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR); } void SetDebugName(const char* name) { device->SetObjectName(name, (uint64_t)accelstruct, VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR); }
VulkanDevice* device; VulkanDevice* device;
VkAccelerationStructureKHR accelstruct; VkAccelerationStructureKHR accelstruct;
@ -273,7 +279,7 @@ public:
VulkanPipeline(VulkanDevice *device, VkPipeline pipeline); VulkanPipeline(VulkanDevice *device, VkPipeline pipeline);
~VulkanPipeline(); ~VulkanPipeline();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)pipeline, VK_OBJECT_TYPE_PIPELINE); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)pipeline, VK_OBJECT_TYPE_PIPELINE); }
VulkanDevice *device; VulkanDevice *device;
VkPipeline pipeline; VkPipeline pipeline;
@ -289,7 +295,7 @@ public:
VulkanPipelineLayout(VulkanDevice *device, VkPipelineLayout layout); VulkanPipelineLayout(VulkanDevice *device, VkPipelineLayout layout);
~VulkanPipelineLayout(); ~VulkanPipelineLayout();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)layout, VK_OBJECT_TYPE_PIPELINE_LAYOUT); }
VulkanDevice *device; VulkanDevice *device;
VkPipelineLayout layout; VkPipelineLayout layout;
@ -305,7 +311,7 @@ public:
VulkanRenderPass(VulkanDevice *device, VkRenderPass renderPass); VulkanRenderPass(VulkanDevice *device, VkRenderPass renderPass);
~VulkanRenderPass(); ~VulkanRenderPass();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)renderPass, VK_OBJECT_TYPE_RENDER_PASS); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)renderPass, VK_OBJECT_TYPE_RENDER_PASS); }
VulkanDevice *device; VulkanDevice *device;
VkRenderPass renderPass; VkRenderPass renderPass;
@ -320,13 +326,15 @@ class RenderPassBegin
public: public:
RenderPassBegin(); RenderPassBegin();
void setRenderPass(VulkanRenderPass *renderpass); RenderPassBegin& RenderPass(VulkanRenderPass* renderpass);
void setRenderArea(int x, int y, int width, int height); RenderPassBegin& RenderArea(int x, int y, int width, int height);
void setFramebuffer(VulkanFramebuffer *framebuffer); RenderPassBegin& Framebuffer(VulkanFramebuffer* framebuffer);
void addClearColor(float r, float g, float b, float a); RenderPassBegin& AddClearColor(float r, float g, float b, float a);
void addClearDepth(float value); RenderPassBegin& AddClearDepth(float value);
void addClearStencil(int value); RenderPassBegin& AddClearStencil(int value);
void addClearDepthStencil(float depthValue, int stencilValue); RenderPassBegin& AddClearDepthStencil(float depthValue, int stencilValue);
void Execute(VulkanCommandBuffer* cmdbuffer, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE);
VkRenderPassBeginInfo renderPassInfo = {}; VkRenderPassBeginInfo renderPassInfo = {};
@ -421,7 +429,7 @@ public:
VulkanCommandPool(VulkanDevice *device, int queueFamilyIndex); VulkanCommandPool(VulkanDevice *device, int queueFamilyIndex);
~VulkanCommandPool(); ~VulkanCommandPool();
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_COMMAND_POOL); } void SetDebugName(const char *name) { device->SetObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_COMMAND_POOL); }
std::unique_ptr<VulkanCommandBuffer> createBuffer(); std::unique_ptr<VulkanCommandBuffer> createBuffer();
@ -519,35 +527,39 @@ inline RenderPassBegin::RenderPassBegin()
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
} }
inline void RenderPassBegin::setRenderPass(VulkanRenderPass *renderPass) inline RenderPassBegin& RenderPassBegin::RenderPass(VulkanRenderPass* renderPass)
{ {
renderPassInfo.renderPass = renderPass->renderPass; renderPassInfo.renderPass = renderPass->renderPass;
return *this;
} }
inline void RenderPassBegin::setRenderArea(int x, int y, int width, int height) inline RenderPassBegin& RenderPassBegin::RenderArea(int x, int y, int width, int height)
{ {
renderPassInfo.renderArea.offset.x = x; renderPassInfo.renderArea.offset.x = x;
renderPassInfo.renderArea.offset.y = y; renderPassInfo.renderArea.offset.y = y;
renderPassInfo.renderArea.extent.width = width; renderPassInfo.renderArea.extent.width = width;
renderPassInfo.renderArea.extent.height = height; renderPassInfo.renderArea.extent.height = height;
return *this;
} }
inline void RenderPassBegin::setFramebuffer(VulkanFramebuffer *framebuffer) inline RenderPassBegin& RenderPassBegin::Framebuffer(VulkanFramebuffer* framebuffer)
{ {
renderPassInfo.framebuffer = framebuffer->framebuffer; renderPassInfo.framebuffer = framebuffer->framebuffer;
return *this;
} }
inline void RenderPassBegin::addClearColor(float r, float g, float b, float a) inline RenderPassBegin& RenderPassBegin::AddClearColor(float r, float g, float b, float a)
{ {
VkClearValue clearValue = { }; VkClearValue clearValue = { };
clearValue.color = { {r, g, b, a} }; clearValue.color = { r, g, b, a };
clearValues.push_back(clearValue); clearValues.push_back(clearValue);
renderPassInfo.clearValueCount = (uint32_t)clearValues.size(); renderPassInfo.clearValueCount = (uint32_t)clearValues.size();
renderPassInfo.pClearValues = clearValues.data(); renderPassInfo.pClearValues = clearValues.data();
return *this;
} }
inline void RenderPassBegin::addClearDepth(float value) inline RenderPassBegin& RenderPassBegin::AddClearDepth(float value)
{ {
VkClearValue clearValue = { }; VkClearValue clearValue = { };
clearValue.depthStencil.depth = value; clearValue.depthStencil.depth = value;
@ -555,9 +567,10 @@ inline void RenderPassBegin::addClearDepth(float value)
renderPassInfo.clearValueCount = (uint32_t)clearValues.size(); renderPassInfo.clearValueCount = (uint32_t)clearValues.size();
renderPassInfo.pClearValues = clearValues.data(); renderPassInfo.pClearValues = clearValues.data();
return *this;
} }
inline void RenderPassBegin::addClearStencil(int value) inline RenderPassBegin& RenderPassBegin::AddClearStencil(int value)
{ {
VkClearValue clearValue = { }; VkClearValue clearValue = { };
clearValue.depthStencil.stencil = value; clearValue.depthStencil.stencil = value;
@ -565,9 +578,10 @@ inline void RenderPassBegin::addClearStencil(int value)
renderPassInfo.clearValueCount = (uint32_t)clearValues.size(); renderPassInfo.clearValueCount = (uint32_t)clearValues.size();
renderPassInfo.pClearValues = clearValues.data(); renderPassInfo.pClearValues = clearValues.data();
return *this;
} }
inline void RenderPassBegin::addClearDepthStencil(float depthValue, int stencilValue) inline RenderPassBegin& RenderPassBegin::AddClearDepthStencil(float depthValue, int stencilValue)
{ {
VkClearValue clearValue = { }; VkClearValue clearValue = { };
clearValue.depthStencil.depth = depthValue; clearValue.depthStencil.depth = depthValue;
@ -576,6 +590,12 @@ inline void RenderPassBegin::addClearDepthStencil(float depthValue, int stencilV
renderPassInfo.clearValueCount = (uint32_t)clearValues.size(); renderPassInfo.clearValueCount = (uint32_t)clearValues.size();
renderPassInfo.pClearValues = clearValues.data(); renderPassInfo.pClearValues = clearValues.data();
return *this;
}
inline void RenderPassBegin::Execute(VulkanCommandBuffer* cmdbuffer, VkSubpassContents contents)
{
cmdbuffer->beginRenderPass(&renderPassInfo, contents);
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -945,7 +965,7 @@ inline void VulkanCommandBuffer::writeAccelerationStructuresProperties(uint32_t
inline void VulkanCommandBuffer::SetDebugName(const char *name) inline void VulkanCommandBuffer::SetDebugName(const char *name)
{ {
pool->device->SetDebugObjectName(name, (uint64_t)buffer, VK_OBJECT_TYPE_COMMAND_BUFFER); pool->device->SetObjectName(name, (uint64_t)buffer, VK_OBJECT_TYPE_COMMAND_BUFFER);
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -992,35 +1012,60 @@ inline VulkanDescriptorPool::~VulkanDescriptorPool()
vkDestroyDescriptorPool(device->device, pool, nullptr); vkDestroyDescriptorPool(device->device, pool, nullptr);
} }
inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::tryAllocate(VulkanDescriptorSetLayout *layout) inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::allocate(VulkanDescriptorSetLayout* layout, AllocType allocType)
{ {
VkDescriptorSetAllocateInfo allocInfo = {}; VkDescriptorSetAllocateInfo allocInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO };
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
allocInfo.descriptorPool = pool; allocInfo.descriptorPool = pool;
allocInfo.descriptorSetCount = 1; allocInfo.descriptorSetCount = 1;
allocInfo.pSetLayouts = &layout->layout; allocInfo.pSetLayouts = &layout->layout;
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
VkResult result = vkAllocateDescriptorSets(device->device, &allocInfo, &descriptorSet); VkResult result = vkAllocateDescriptorSets(device->device, &allocInfo, &descriptorSet);
if (result != VK_SUCCESS) if (allocType == AllocType::TryAllocate && result != VK_SUCCESS)
return nullptr; return nullptr;
else
CheckVulkanError(result, "Could not allocate descriptor sets");
return std::make_unique<VulkanDescriptorSet>(device, this, descriptorSet); return std::make_unique<VulkanDescriptorSet>(device, this, descriptorSet);
} }
inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::allocate(VulkanDescriptorSetLayout* layout, uint32_t bindlessCount, AllocType allocType)
{
VkDescriptorSetAllocateInfo allocInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO };
VkDescriptorSetVariableDescriptorCountAllocateInfoEXT countInfo{ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO_EXT };
allocInfo.descriptorPool = pool;
allocInfo.descriptorSetCount = 1;
allocInfo.pSetLayouts = &layout->layout;
allocInfo.pNext = &countInfo;
countInfo.descriptorSetCount = 1;
countInfo.pDescriptorCounts = &bindlessCount;
VkDescriptorSet descriptorSet;
VkResult result = vkAllocateDescriptorSets(device->device, &allocInfo, &descriptorSet);
if (allocType == AllocType::TryAllocate && result != VK_SUCCESS)
return nullptr;
else
CheckVulkanError(result, "Could not allocate descriptor sets");
return std::make_unique<VulkanDescriptorSet>(device, this, descriptorSet);
}
inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::tryAllocate(VulkanDescriptorSetLayout *layout)
{
return allocate(layout, AllocType::TryAllocate);
}
inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::allocate(VulkanDescriptorSetLayout *layout) inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::allocate(VulkanDescriptorSetLayout *layout)
{ {
VkDescriptorSetAllocateInfo allocInfo = {}; return allocate(layout, AllocType::AlwaysAllocate);
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; }
allocInfo.descriptorPool = pool;
allocInfo.descriptorSetCount = 1;
allocInfo.pSetLayouts = &layout->layout;
VkDescriptorSet descriptorSet; inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::tryAllocate(VulkanDescriptorSetLayout* layout, uint32_t bindlessCount)
VkResult result = vkAllocateDescriptorSets(device->device, &allocInfo, &descriptorSet); {
CheckVulkanError(result, "Could not allocate descriptor sets"); return allocate(layout, bindlessCount, AllocType::TryAllocate);
}
return std::make_unique<VulkanDescriptorSet>(device, this, descriptorSet); inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::allocate(VulkanDescriptorSetLayout* layout, uint32_t bindlessCount)
{
return allocate(layout, bindlessCount, AllocType::AlwaysAllocate);
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -1060,7 +1105,8 @@ inline VulkanImage::VulkanImage(VulkanDevice *device, VkImage image, VmaAllocati
inline VulkanImage::~VulkanImage() inline VulkanImage::~VulkanImage()
{ {
vmaDestroyImage(device->allocator, image, allocation); if (allocation)
vmaDestroyImage(device->allocator, image, allocation);
} }
inline void *VulkanImage::Map(size_t offset, size_t size) inline void *VulkanImage::Map(size_t offset, size_t size)

View file

@ -0,0 +1,30 @@
#pragma once
#include "vulkaninstance.h"
#if defined(VK_USE_PLATFORM_XLIB_KHR)
#include <X11/Xlib.h>
#endif
class VulkanSurface
{
public:
VulkanSurface(std::shared_ptr<VulkanInstance> instance, VkSurfaceKHR surface);
~VulkanSurface();
std::shared_ptr<VulkanInstance> Instance;
VkSurfaceKHR Surface = VK_NULL_HANDLE;
#ifdef VK_USE_PLATFORM_WIN32_KHR
VulkanSurface(std::shared_ptr<VulkanInstance> instance, HWND window);
HWND Window = 0;
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
VulkanSurface(std::shared_ptr<VulkanInstance> instance, Display* disp, Window wind);
Display* disp = nullptr;
Window wind;
#endif
};

View file

@ -0,0 +1,50 @@
#pragma once
#include "vulkandevice.h"
#include "vulkanobjects.h"
class VulkanSemaphore;
class VulkanFence;
class VulkanSwapChain
{
public:
VulkanSwapChain(VulkanDevice* device);
~VulkanSwapChain();
void Create(int width, int height, int imageCount, bool vsync, bool hdr, bool exclusivefullscreen);
bool Lost() const { return lost; }
int Width() const { return actualExtent.width; }
int Height() const { return actualExtent.height; }
VkSurfaceFormatKHR Format() const { return format; }
int ImageCount() const { return (int)images.size(); }
VulkanImage* GetImage(int index) { return images[index].get(); }
VulkanImageView* GetImageView(int index) { return views[index].get(); }
int AcquireImage(VulkanSemaphore* semaphore = nullptr, VulkanFence* fence = nullptr);
void QueuePresent(int imageIndex, VulkanSemaphore* semaphore = nullptr);
private:
void SelectFormat(bool hdr);
void SelectPresentMode(bool vsync, bool exclusivefullscreen);
bool CreateSwapchain(int width, int height, int imageCount, bool exclusivefullscreen, VkSwapchainKHR oldSwapChain = VK_NULL_HANDLE);
std::vector<VkSurfaceFormatKHR> GetSurfaceFormats();
std::vector<VkPresentModeKHR> GetPresentModes(bool exclusivefullscreen);
VulkanDevice* device = nullptr;
bool lost = true;
VkExtent2D actualExtent = {};
VkSwapchainKHR swapchain = VK_NULL_HANDLE;
VkSurfaceFormatKHR format = {};
VkPresentModeKHR presentMode;
std::vector<std::unique_ptr<VulkanImage>> images;
std::vector<std::unique_ptr<VulkanImageView>> views;
VulkanSwapChain(const VulkanSwapChain&) = delete;
VulkanSwapChain& operator=(const VulkanSwapChain&) = delete;
};

File diff suppressed because it is too large Load diff

View file

@ -263,7 +263,6 @@ enum TBuiltInVariable {
EbvObjectRayDirection, EbvObjectRayDirection,
EbvRayTmin, EbvRayTmin,
EbvRayTmax, EbvRayTmax,
EbvCullMask,
EbvHitT, EbvHitT,
EbvHitKind, EbvHitKind,
EbvObjectToWorld, EbvObjectToWorld,
@ -275,8 +274,6 @@ enum TBuiltInVariable {
// barycentrics // barycentrics
EbvBaryCoordNV, EbvBaryCoordNV,
EbvBaryCoordNoPerspNV, EbvBaryCoordNoPerspNV,
EbvBaryCoordEXT,
EbvBaryCoordNoPerspEXT,
// mesh shaders // mesh shaders
EbvTaskCountNV, EbvTaskCountNV,
EbvPrimitiveCountNV, EbvPrimitiveCountNV,
@ -481,10 +478,8 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvWorldToObject: return "WorldToObjectNV"; case EbvWorldToObject: return "WorldToObjectNV";
case EbvCurrentRayTimeNV: return "CurrentRayTimeNV"; case EbvCurrentRayTimeNV: return "CurrentRayTimeNV";
case EbvBaryCoordEXT: case EbvBaryCoordNV: return "BaryCoordNV";
case EbvBaryCoordNV: return "BaryCoordKHR"; case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
case EbvBaryCoordNoPerspEXT:
case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspKHR";
case EbvTaskCountNV: return "TaskCountNV"; case EbvTaskCountNV: return "TaskCountNV";
case EbvPrimitiveCountNV: return "PrimitiveCountNV"; case EbvPrimitiveCountNV: return "PrimitiveCountNV";

View file

@ -39,11 +39,6 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#ifdef _MSC_VER
#include <cfloat>
#else
#include <cmath>
#endif
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <list> #include <list>
@ -66,7 +61,7 @@ std::string to_string(const T& val) {
} }
#endif #endif
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || MINGW_HAS_SECURE_API #if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || defined MINGW_HAS_SECURE_API
#include <basetsd.h> #include <basetsd.h>
#ifndef snprintf #ifndef snprintf
#define snprintf sprintf_s #define snprintf sprintf_s
@ -219,7 +214,7 @@ template <class T> T Max(const T a, const T b) { return a > b ? a : b; }
// //
// Create a TString object from an integer. // Create a TString object from an integer.
// //
#if defined _MSC_VER || MINGW_HAS_SECURE_API #if defined _MSC_VER || defined MINGW_HAS_SECURE_API
inline const TString String(const int i, const int base = 10) inline const TString String(const int i, const int base = 10)
{ {
char text[16]; // 32 bit ints are at most 10 digits in base 10 char text[16]; // 32 bit ints are at most 10 digits in base 10
@ -308,34 +303,6 @@ template <class T> int IntLog2(T n)
return result; return result;
} }
inline bool IsInfinity(double x) {
#ifdef _MSC_VER
switch (_fpclass(x)) {
case _FPCLASS_NINF:
case _FPCLASS_PINF:
return true;
default:
return false;
}
#else
return std::isinf(x);
#endif
}
inline bool IsNan(double x) {
#ifdef _MSC_VER
switch (_fpclass(x)) {
case _FPCLASS_SNAN:
case _FPCLASS_QNAN:
return true;
default:
return false;
}
#else
return std::isnan(x);
#endif
}
} // end namespace glslang } // end namespace glslang
#endif // _COMMON_INCLUDED_ #endif // _COMMON_INCLUDED_

View file

@ -306,8 +306,6 @@ public:
TPoolAllocator& getAllocator() const { return allocator; } TPoolAllocator& getAllocator() const { return allocator; }
pool_allocator select_on_container_copy_construction() const { return pool_allocator{}; }
protected: protected:
pool_allocator& operator=(const pool_allocator&) { return *this; } pool_allocator& operator=(const pool_allocator&) { return *this; }
TPoolAllocator& allocator; TPoolAllocator& allocator;

View file

@ -65,7 +65,7 @@ struct TSpirvExecutionMode {
// spirv_execution_mode // spirv_execution_mode
TMap<int, TVector<const TIntermConstantUnion*>> modes; TMap<int, TVector<const TIntermConstantUnion*>> modes;
// spirv_execution_mode_id // spirv_execution_mode_id
TMap<int, TVector<const TIntermTyped*> > modeIds; TMap<int, TVector<const TIntermConstantUnion*> > modeIds;
}; };
// SPIR-V decorations // SPIR-V decorations
@ -75,7 +75,7 @@ struct TSpirvDecorate {
// spirv_decorate // spirv_decorate
TMap<int, TVector<const TIntermConstantUnion*> > decorates; TMap<int, TVector<const TIntermConstantUnion*> > decorates;
// spirv_decorate_id // spirv_decorate_id
TMap<int, TVector<const TIntermTyped*>> decorateIds; TMap<int, TVector<const TIntermConstantUnion*> > decorateIds;
// spirv_decorate_string // spirv_decorate_string
TMap<int, TVector<const TIntermConstantUnion*> > decorateStrings; TMap<int, TVector<const TIntermConstantUnion*> > decorateStrings;
}; };
@ -98,12 +98,20 @@ struct TSpirvInstruction {
struct TSpirvTypeParameter { struct TSpirvTypeParameter {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TSpirvTypeParameter(const TIntermConstantUnion* arg) { constant = arg; } TSpirvTypeParameter(const TIntermConstantUnion* arg) { isConstant = true; constant = arg; }
TSpirvTypeParameter(const TType* arg) { isConstant = false; type = arg; }
bool operator==(const TSpirvTypeParameter& rhs) const { return constant == rhs.constant; } bool operator==(const TSpirvTypeParameter& rhs) const
{
return isConstant == rhs.isConstant && ((isConstant && constant == rhs.constant) || (!isConstant && type == rhs.type));
}
bool operator!=(const TSpirvTypeParameter& rhs) const { return !operator==(rhs); } bool operator!=(const TSpirvTypeParameter& rhs) const { return !operator==(rhs); }
const TIntermConstantUnion* constant; bool isConstant;
union {
const TIntermConstantUnion* constant;
const TType* type;
};
}; };
typedef TVector<TSpirvTypeParameter> TSpirvTypeParameters; typedef TVector<TSpirvTypeParameter> TSpirvTypeParameters;

View file

@ -552,7 +552,6 @@ public:
perViewNV = false; perViewNV = false;
perTaskNV = false; perTaskNV = false;
#endif #endif
pervertexEXT = false;
} }
void clearMemory() void clearMemory()
@ -605,8 +604,7 @@ public:
bool isNoContraction() const { return false; } bool isNoContraction() const { return false; }
void setNoContraction() { } void setNoContraction() { }
bool isPervertexNV() const { return false; } bool isPervertexNV() const { return false; }
bool isPervertexEXT() const { return pervertexEXT; } void setNullInit() { }
void setNullInit() {}
bool isNullInit() const { return false; } bool isNullInit() const { return false; }
void setSpirvByReference() { } void setSpirvByReference() { }
bool isSpirvByReference() { return false; } bool isSpirvByReference() { return false; }
@ -617,7 +615,6 @@ public:
bool nopersp : 1; bool nopersp : 1;
bool explicitInterp : 1; bool explicitInterp : 1;
bool pervertexNV : 1; bool pervertexNV : 1;
bool pervertexEXT : 1;
bool perPrimitiveNV : 1; bool perPrimitiveNV : 1;
bool perViewNV : 1; bool perViewNV : 1;
bool perTaskNV : 1; bool perTaskNV : 1;
@ -666,13 +663,12 @@ public:
} }
bool isAuxiliary() const bool isAuxiliary() const
{ {
return centroid || patch || sample || pervertexNV || pervertexEXT; return centroid || patch || sample || pervertexNV;
} }
bool isPatch() const { return patch; } bool isPatch() const { return patch; }
bool isNoContraction() const { return noContraction; } bool isNoContraction() const { return noContraction; }
void setNoContraction() { noContraction = true; } void setNoContraction() { noContraction = true; }
bool isPervertexNV() const { return pervertexNV; } bool isPervertexNV() const { return pervertexNV; }
bool isPervertexEXT() const { return pervertexEXT; }
void setNullInit() { nullInit = true; } void setNullInit() { nullInit = true; }
bool isNullInit() const { return nullInit; } bool isNullInit() const { return nullInit; }
void setSpirvByReference() { spirvByReference = true; } void setSpirvByReference() { spirvByReference = true; }
@ -745,16 +741,6 @@ public:
} }
} }
bool isUniform() const
{
switch (storage) {
case EvqUniform:
return true;
default:
return false;
}
}
bool isIo() const bool isIo() const
{ {
switch (storage) { switch (storage) {
@ -860,7 +846,7 @@ public:
case EShLangTessEvaluation: case EShLangTessEvaluation:
return ! patch && isPipeInput(); return ! patch && isPipeInput();
case EShLangFragment: case EShLangFragment:
return (pervertexNV || pervertexEXT) && isPipeInput(); return pervertexNV && isPipeInput();
case EShLangMeshNV: case EShLangMeshNV:
return ! perTaskNV && isPipeOutput(); return ! perTaskNV && isPipeOutput();
@ -1869,12 +1855,10 @@ public:
bool isAtomic() const { return false; } bool isAtomic() const { return false; }
bool isCoopMat() const { return false; } bool isCoopMat() const { return false; }
bool isReference() const { return false; } bool isReference() const { return false; }
bool isSpirvType() const { return false; }
#else #else
bool isAtomic() const { return basicType == EbtAtomicUint; } bool isAtomic() const { return basicType == EbtAtomicUint; }
bool isCoopMat() const { return coopmat; } bool isCoopMat() const { return coopmat; }
bool isReference() const { return getBasicType() == EbtReference; } bool isReference() const { return getBasicType() == EbtReference; }
bool isSpirvType() const { return getBasicType() == EbtSpirvType; }
#endif #endif
// return true if this type contains any subtype which satisfies the given predicate. // return true if this type contains any subtype which satisfies the given predicate.
@ -2146,8 +2130,7 @@ public:
const char* getPrecisionQualifierString() const { return ""; } const char* getPrecisionQualifierString() const { return ""; }
TString getBasicTypeString() const { return ""; } TString getBasicTypeString() const { return ""; }
#else #else
TString getCompleteString(bool syntactic = false, bool getQualifiers = true, bool getPrecision = true, TString getCompleteString() const
bool getType = true, TString name = "", TString structName = "") const
{ {
TString typeString; TString typeString;
@ -2155,337 +2138,232 @@ public:
const auto appendUint = [&](unsigned int u) { typeString.append(std::to_string(u).c_str()); }; const auto appendUint = [&](unsigned int u) { typeString.append(std::to_string(u).c_str()); };
const auto appendInt = [&](int i) { typeString.append(std::to_string(i).c_str()); }; const auto appendInt = [&](int i) { typeString.append(std::to_string(i).c_str()); };
if (getQualifiers) { if (qualifier.hasSprivDecorate())
if (qualifier.hasSprivDecorate())
appendStr(qualifier.getSpirvDecorateQualifierString().c_str()); appendStr(qualifier.getSpirvDecorateQualifierString().c_str());
if (qualifier.hasLayout()) { if (qualifier.hasLayout()) {
// To reduce noise, skip this if the only layout is an xfb_buffer // To reduce noise, skip this if the only layout is an xfb_buffer
// with no triggering xfb_offset. // with no triggering xfb_offset.
TQualifier noXfbBuffer = qualifier; TQualifier noXfbBuffer = qualifier;
noXfbBuffer.layoutXfbBuffer = TQualifier::layoutXfbBufferEnd; noXfbBuffer.layoutXfbBuffer = TQualifier::layoutXfbBufferEnd;
if (noXfbBuffer.hasLayout()) { if (noXfbBuffer.hasLayout()) {
appendStr("layout("); appendStr("layout(");
if (qualifier.hasAnyLocation()) { if (qualifier.hasAnyLocation()) {
appendStr(" location="); appendStr(" location=");
appendUint(qualifier.layoutLocation); appendUint(qualifier.layoutLocation);
if (qualifier.hasComponent()) { if (qualifier.hasComponent()) {
appendStr(" component="); appendStr(" component=");
appendUint(qualifier.layoutComponent); appendUint(qualifier.layoutComponent);
} }
if (qualifier.hasIndex()) { if (qualifier.hasIndex()) {
appendStr(" index="); appendStr(" index=");
appendUint(qualifier.layoutIndex); appendUint(qualifier.layoutIndex);
}
}
if (qualifier.hasSet()) {
appendStr(" set=");
appendUint(qualifier.layoutSet);
}
if (qualifier.hasBinding()) {
appendStr(" binding=");
appendUint(qualifier.layoutBinding);
}
if (qualifier.hasStream()) {
appendStr(" stream=");
appendUint(qualifier.layoutStream);
}
if (qualifier.hasMatrix()) {
appendStr(" ");
appendStr(TQualifier::getLayoutMatrixString(qualifier.layoutMatrix));
}
if (qualifier.hasPacking()) {
appendStr(" ");
appendStr(TQualifier::getLayoutPackingString(qualifier.layoutPacking));
}
if (qualifier.hasOffset()) {
appendStr(" offset=");
appendInt(qualifier.layoutOffset);
}
if (qualifier.hasAlign()) {
appendStr(" align=");
appendInt(qualifier.layoutAlign);
}
if (qualifier.hasFormat()) {
appendStr(" ");
appendStr(TQualifier::getLayoutFormatString(qualifier.layoutFormat));
}
if (qualifier.hasXfbBuffer() && qualifier.hasXfbOffset()) {
appendStr(" xfb_buffer=");
appendUint(qualifier.layoutXfbBuffer);
}
if (qualifier.hasXfbOffset()) {
appendStr(" xfb_offset=");
appendUint(qualifier.layoutXfbOffset);
}
if (qualifier.hasXfbStride()) {
appendStr(" xfb_stride=");
appendUint(qualifier.layoutXfbStride);
}
if (qualifier.hasAttachment()) {
appendStr(" input_attachment_index=");
appendUint(qualifier.layoutAttachment);
}
if (qualifier.hasSpecConstantId()) {
appendStr(" constant_id=");
appendUint(qualifier.layoutSpecConstantId);
}
if (qualifier.layoutPushConstant)
appendStr(" push_constant");
if (qualifier.layoutBufferReference)
appendStr(" buffer_reference");
if (qualifier.hasBufferReferenceAlign()) {
appendStr(" buffer_reference_align=");
appendUint(1u << qualifier.layoutBufferReferenceAlign);
}
if (qualifier.layoutPassthrough)
appendStr(" passthrough");
if (qualifier.layoutViewportRelative)
appendStr(" layoutViewportRelative");
if (qualifier.layoutSecondaryViewportRelativeOffset != -2048) {
appendStr(" layoutSecondaryViewportRelativeOffset=");
appendInt(qualifier.layoutSecondaryViewportRelativeOffset);
}
if (qualifier.layoutShaderRecord)
appendStr(" shaderRecordNV");
appendStr(")");
}
}
if (qualifier.invariant)
appendStr(" invariant");
if (qualifier.noContraction)
appendStr(" noContraction");
if (qualifier.centroid)
appendStr(" centroid");
if (qualifier.smooth)
appendStr(" smooth");
if (qualifier.flat)
appendStr(" flat");
if (qualifier.nopersp)
appendStr(" noperspective");
if (qualifier.explicitInterp)
appendStr(" __explicitInterpAMD");
if (qualifier.pervertexNV)
appendStr(" pervertexNV");
if (qualifier.pervertexEXT)
appendStr(" pervertexEXT");
if (qualifier.perPrimitiveNV)
appendStr(" perprimitiveNV");
if (qualifier.perViewNV)
appendStr(" perviewNV");
if (qualifier.perTaskNV)
appendStr(" taskNV");
if (qualifier.patch)
appendStr(" patch");
if (qualifier.sample)
appendStr(" sample");
if (qualifier.coherent)
appendStr(" coherent");
if (qualifier.devicecoherent)
appendStr(" devicecoherent");
if (qualifier.queuefamilycoherent)
appendStr(" queuefamilycoherent");
if (qualifier.workgroupcoherent)
appendStr(" workgroupcoherent");
if (qualifier.subgroupcoherent)
appendStr(" subgroupcoherent");
if (qualifier.shadercallcoherent)
appendStr(" shadercallcoherent");
if (qualifier.nonprivate)
appendStr(" nonprivate");
if (qualifier.volatil)
appendStr(" volatile");
if (qualifier.restrict)
appendStr(" restrict");
if (qualifier.readonly)
appendStr(" readonly");
if (qualifier.writeonly)
appendStr(" writeonly");
if (qualifier.specConstant)
appendStr(" specialization-constant");
if (qualifier.nonUniform)
appendStr(" nonuniform");
if (qualifier.isNullInit())
appendStr(" null-init");
if (qualifier.isSpirvByReference())
appendStr(" spirv_by_reference");
if (qualifier.isSpirvLiteral())
appendStr(" spirv_literal");
appendStr(" ");
appendStr(getStorageQualifierString());
}
if (getType) {
if (syntactic) {
if (getPrecision && qualifier.precision != EpqNone) {
appendStr(" ");
appendStr(getPrecisionQualifierString());
}
if (isVector() || isMatrix()) {
appendStr(" ");
switch (basicType) {
case EbtDouble:
appendStr("d");
break;
case EbtInt:
appendStr("i");
break;
case EbtUint:
appendStr("u");
break;
case EbtBool:
appendStr("b");
break;
case EbtFloat:
default:
break;
}
if (isVector()) {
appendStr("vec");
appendInt(vectorSize);
} else {
appendStr("mat");
appendInt(matrixCols);
appendStr("x");
appendInt(matrixRows);
}
} else if (isStruct() && structure) {
appendStr(" ");
appendStr(structName.c_str());
appendStr("{");
bool hasHiddenMember = true;
for (size_t i = 0; i < structure->size(); ++i) {
if (!(*structure)[i].type->hiddenMember()) {
if (!hasHiddenMember)
appendStr(", ");
typeString.append((*structure)[i].type->getCompleteString(syntactic, getQualifiers, getPrecision, getType, (*structure)[i].type->getFieldName()));
hasHiddenMember = false;
}
}
appendStr("}");
} else {
appendStr(" ");
switch (basicType) {
case EbtDouble:
appendStr("double");
break;
case EbtInt:
appendStr("int");
break;
case EbtUint:
appendStr("uint");
break;
case EbtBool:
appendStr("bool");
break;
case EbtFloat:
appendStr("float");
break;
default:
appendStr("unexpected");
break;
}
}
if (name.length() > 0) {
appendStr(" ");
appendStr(name.c_str());
}
if (isArray()) {
for (int i = 0; i < (int)arraySizes->getNumDims(); ++i) {
int size = arraySizes->getDimSize(i);
if (size == UnsizedArraySize && i == 0 && arraySizes->isVariablyIndexed())
appendStr("[]");
else {
if (size == UnsizedArraySize) {
appendStr("[");
if (i == 0)
appendInt(arraySizes->getImplicitSize());
appendStr("]");
}
else {
appendStr("[");
appendInt(arraySizes->getDimSize(i));
appendStr("]");
}
}
}
}
}
else {
if (isArray()) {
for (int i = 0; i < (int)arraySizes->getNumDims(); ++i) {
int size = arraySizes->getDimSize(i);
if (size == UnsizedArraySize && i == 0 && arraySizes->isVariablyIndexed())
appendStr(" runtime-sized array of");
else {
if (size == UnsizedArraySize) {
appendStr(" unsized");
if (i == 0) {
appendStr(" ");
appendInt(arraySizes->getImplicitSize());
} }
}
else {
appendStr(" ");
appendInt(arraySizes->getDimSize(i));
}
appendStr("-element array of");
} }
} if (qualifier.hasSet()) {
appendStr(" set=");
appendUint(qualifier.layoutSet);
}
if (qualifier.hasBinding()) {
appendStr(" binding=");
appendUint(qualifier.layoutBinding);
}
if (qualifier.hasStream()) {
appendStr(" stream=");
appendUint(qualifier.layoutStream);
}
if (qualifier.hasMatrix()) {
appendStr(" ");
appendStr(TQualifier::getLayoutMatrixString(qualifier.layoutMatrix));
}
if (qualifier.hasPacking()) {
appendStr(" ");
appendStr(TQualifier::getLayoutPackingString(qualifier.layoutPacking));
}
if (qualifier.hasOffset()) {
appendStr(" offset=");
appendInt(qualifier.layoutOffset);
}
if (qualifier.hasAlign()) {
appendStr(" align=");
appendInt(qualifier.layoutAlign);
}
if (qualifier.hasFormat()) {
appendStr(" ");
appendStr(TQualifier::getLayoutFormatString(qualifier.layoutFormat));
}
if (qualifier.hasXfbBuffer() && qualifier.hasXfbOffset()) {
appendStr(" xfb_buffer=");
appendUint(qualifier.layoutXfbBuffer);
}
if (qualifier.hasXfbOffset()) {
appendStr(" xfb_offset=");
appendUint(qualifier.layoutXfbOffset);
}
if (qualifier.hasXfbStride()) {
appendStr(" xfb_stride=");
appendUint(qualifier.layoutXfbStride);
}
if (qualifier.hasAttachment()) {
appendStr(" input_attachment_index=");
appendUint(qualifier.layoutAttachment);
}
if (qualifier.hasSpecConstantId()) {
appendStr(" constant_id=");
appendUint(qualifier.layoutSpecConstantId);
}
if (qualifier.layoutPushConstant)
appendStr(" push_constant");
if (qualifier.layoutBufferReference)
appendStr(" buffer_reference");
if (qualifier.hasBufferReferenceAlign()) {
appendStr(" buffer_reference_align=");
appendUint(1u << qualifier.layoutBufferReferenceAlign);
}
if (qualifier.layoutPassthrough)
appendStr(" passthrough");
if (qualifier.layoutViewportRelative)
appendStr(" layoutViewportRelative");
if (qualifier.layoutSecondaryViewportRelativeOffset != -2048) {
appendStr(" layoutSecondaryViewportRelativeOffset=");
appendInt(qualifier.layoutSecondaryViewportRelativeOffset);
}
if (qualifier.layoutShaderRecord)
appendStr(" shaderRecordNV");
appendStr(")");
} }
if (isParameterized()) { }
appendStr("<");
for (int i = 0; i < (int)typeParameters->getNumDims(); ++i) { if (qualifier.invariant)
appendStr(" invariant");
if (qualifier.noContraction)
appendStr(" noContraction");
if (qualifier.centroid)
appendStr(" centroid");
if (qualifier.smooth)
appendStr(" smooth");
if (qualifier.flat)
appendStr(" flat");
if (qualifier.nopersp)
appendStr(" noperspective");
if (qualifier.explicitInterp)
appendStr(" __explicitInterpAMD");
if (qualifier.pervertexNV)
appendStr(" pervertexNV");
if (qualifier.perPrimitiveNV)
appendStr(" perprimitiveNV");
if (qualifier.perViewNV)
appendStr(" perviewNV");
if (qualifier.perTaskNV)
appendStr(" taskNV");
if (qualifier.patch)
appendStr(" patch");
if (qualifier.sample)
appendStr(" sample");
if (qualifier.coherent)
appendStr(" coherent");
if (qualifier.devicecoherent)
appendStr(" devicecoherent");
if (qualifier.queuefamilycoherent)
appendStr(" queuefamilycoherent");
if (qualifier.workgroupcoherent)
appendStr(" workgroupcoherent");
if (qualifier.subgroupcoherent)
appendStr(" subgroupcoherent");
if (qualifier.shadercallcoherent)
appendStr(" shadercallcoherent");
if (qualifier.nonprivate)
appendStr(" nonprivate");
if (qualifier.volatil)
appendStr(" volatile");
if (qualifier.restrict)
appendStr(" restrict");
if (qualifier.readonly)
appendStr(" readonly");
if (qualifier.writeonly)
appendStr(" writeonly");
if (qualifier.specConstant)
appendStr(" specialization-constant");
if (qualifier.nonUniform)
appendStr(" nonuniform");
if (qualifier.isNullInit())
appendStr(" null-init");
if (qualifier.isSpirvByReference())
appendStr(" spirv_by_reference");
if (qualifier.isSpirvLiteral())
appendStr(" spirv_literal");
appendStr(" ");
appendStr(getStorageQualifierString());
if (isArray()) {
for(int i = 0; i < (int)arraySizes->getNumDims(); ++i) {
int size = arraySizes->getDimSize(i);
if (size == UnsizedArraySize && i == 0 && arraySizes->isVariablyIndexed())
appendStr(" runtime-sized array of");
else {
if (size == UnsizedArraySize) {
appendStr(" unsized");
if (i == 0) {
appendStr(" ");
appendInt(arraySizes->getImplicitSize());
}
} else {
appendStr(" ");
appendInt(arraySizes->getDimSize(i));
}
appendStr("-element array of");
}
}
}
if (isParameterized()) {
appendStr("<");
for(int i = 0; i < (int)typeParameters->getNumDims(); ++i) {
appendInt(typeParameters->getDimSize(i)); appendInt(typeParameters->getDimSize(i));
if (i != (int)typeParameters->getNumDims() - 1) if (i != (int)typeParameters->getNumDims() - 1)
appendStr(", ");
}
appendStr(">");
}
if (getPrecision && qualifier.precision != EpqNone) {
appendStr(" ");
appendStr(getPrecisionQualifierString());
}
if (isMatrix()) {
appendStr(" ");
appendInt(matrixCols);
appendStr("X");
appendInt(matrixRows);
appendStr(" matrix of");
}
else if (isVector()) {
appendStr(" ");
appendInt(vectorSize);
appendStr("-component vector of");
}
appendStr(" ");
typeString.append(getBasicTypeString());
if (qualifier.builtIn != EbvNone) {
appendStr(" ");
appendStr(getBuiltInVariableString());
}
// Add struct/block members
if (isStruct() && structure) {
appendStr("{");
bool hasHiddenMember = true;
for (size_t i = 0; i < structure->size(); ++i) {
if (!(*structure)[i].type->hiddenMember()) {
if (!hasHiddenMember)
appendStr(", "); appendStr(", ");
typeString.append((*structure)[i].type->getCompleteString());
typeString.append(" ");
typeString.append((*structure)[i].type->getFieldName());
hasHiddenMember = false;
}
}
appendStr("}");
} }
} appendStr(">");
}
if (qualifier.precision != EpqNone) {
appendStr(" ");
appendStr(getPrecisionQualifierString());
}
if (isMatrix()) {
appendStr(" ");
appendInt(matrixCols);
appendStr("X");
appendInt(matrixRows);
appendStr(" matrix of");
} else if (isVector()) {
appendStr(" ");
appendInt(vectorSize);
appendStr("-component vector of");
}
appendStr(" ");
typeString.append(getBasicTypeString());
if (qualifier.builtIn != EbvNone) {
appendStr(" ");
appendStr(getBuiltInVariableString());
}
// Add struct/block members
if (isStruct() && structure) {
appendStr("{");
bool hasHiddenMember = true;
for (size_t i = 0; i < structure->size(); ++i) {
if (! (*structure)[i].type->hiddenMember()) {
if (!hasHiddenMember)
appendStr(", ");
typeString.append((*structure)[i].type->getCompleteString());
typeString.append(" ");
typeString.append((*structure)[i].type->getFieldName());
hasHiddenMember = false;
}
}
appendStr("}");
} }
return typeString; return typeString;
@ -2554,27 +2432,13 @@ public:
// type definitions, and member names to be considered the same type. // type definitions, and member names to be considered the same type.
// This rule applies recursively for nested or embedded types." // This rule applies recursively for nested or embedded types."
// //
// If type mismatch in structure, return member indices through lpidx and rpidx. bool sameStructType(const TType& right) const
// If matching members for either block are exhausted, return -1 for exhausted
// block and the index of the unmatched member. Otherwise return {-1,-1}.
//
bool sameStructType(const TType& right, int* lpidx = nullptr, int* rpidx = nullptr) const
{ {
// Initialize error to general type mismatch.
if (lpidx != nullptr) {
*lpidx = -1;
*rpidx = -1;
}
// Most commonly, they are both nullptr, or the same pointer to the same actual structure // Most commonly, they are both nullptr, or the same pointer to the same actual structure
// TODO: Why return true when neither types are structures?
if ((!isStruct() && !right.isStruct()) || if ((!isStruct() && !right.isStruct()) ||
(isStruct() && right.isStruct() && structure == right.structure)) (isStruct() && right.isStruct() && structure == right.structure))
return true; return true;
if (!isStruct() || !right.isStruct())
return false;
// Structure names have to match // Structure names have to match
if (*typeName != *right.typeName) if (*typeName != *right.typeName)
return false; return false;
@ -2584,30 +2448,17 @@ public:
bool isGLPerVertex = *typeName == "gl_PerVertex"; bool isGLPerVertex = *typeName == "gl_PerVertex";
// Both being nullptr was caught above, now they both have to be structures of the same number of elements // Both being nullptr was caught above, now they both have to be structures of the same number of elements
if (lpidx == nullptr && if (!isStruct() || !right.isStruct() ||
(structure->size() != right.structure->size() && !isGLPerVertex)) { (structure->size() != right.structure->size() && !isGLPerVertex))
return false; return false;
}
// Compare the names and types of all the members, which have to match // Compare the names and types of all the members, which have to match
for (size_t li = 0, ri = 0; li < structure->size() || ri < right.structure->size(); ++li, ++ri) { for (size_t li = 0, ri = 0; li < structure->size() || ri < right.structure->size(); ++li, ++ri) {
if (lpidx != nullptr) {
*lpidx = static_cast<int>(li);
*rpidx = static_cast<int>(ri);
}
if (li < structure->size() && ri < right.structure->size()) { if (li < structure->size() && ri < right.structure->size()) {
if ((*structure)[li].type->getFieldName() == (*right.structure)[ri].type->getFieldName()) { if ((*structure)[li].type->getFieldName() == (*right.structure)[ri].type->getFieldName()) {
if (*(*structure)[li].type != *(*right.structure)[ri].type) if (*(*structure)[li].type != *(*right.structure)[ri].type)
return false; return false;
} else { } else {
// Skip hidden members
if ((*structure)[li].type->hiddenMember()) {
ri--;
continue;
} else if ((*right.structure)[ri].type->hiddenMember()) {
li--;
continue;
}
// If one of the members is something that's inconsistently declared, skip over it // If one of the members is something that's inconsistently declared, skip over it
// for now. // for now.
if (isGLPerVertex) { if (isGLPerVertex) {
@ -2624,19 +2475,11 @@ public:
} }
// If we get here, then there should only be inconsistently declared members left // If we get here, then there should only be inconsistently declared members left
} else if (li < structure->size()) { } else if (li < structure->size()) {
if (!(*structure)[li].type->hiddenMember() && !isInconsistentGLPerVertexMember((*structure)[li].type->getFieldName())) { if (!isInconsistentGLPerVertexMember((*structure)[li].type->getFieldName()))
if (lpidx != nullptr) {
*rpidx = -1;
}
return false; return false;
}
} else { } else {
if (!(*right.structure)[ri].type->hiddenMember() && !isInconsistentGLPerVertexMember((*right.structure)[ri].type->getFieldName())) { if (!isInconsistentGLPerVertexMember((*right.structure)[ri].type->getFieldName()))
if (lpidx != nullptr) {
*lpidx = -1;
}
return false; return false;
}
} }
} }
@ -2660,15 +2503,10 @@ public:
return *referentType == *right.referentType; return *referentType == *right.referentType;
} }
// See if two types match, in all aspects except arrayness // See if two types match, in all aspects except arrayness
// If mismatch in structure members, return member indices in lpidx and rpidx. bool sameElementType(const TType& right) const
bool sameElementType(const TType& right, int* lpidx = nullptr, int* rpidx = nullptr) const
{ {
if (lpidx != nullptr) { return basicType == right.basicType && sameElementShape(right);
*lpidx = -1;
*rpidx = -1;
}
return basicType == right.basicType && sameElementShape(right, lpidx, rpidx);
} }
// See if two type's arrayness match // See if two type's arrayness match
@ -2702,20 +2540,15 @@ public:
#endif #endif
// See if two type's elements match in all ways except basic type // See if two type's elements match in all ways except basic type
// If mismatch in structure members, return member indices in lpidx and rpidx. bool sameElementShape(const TType& right) const
bool sameElementShape(const TType& right, int* lpidx = nullptr, int* rpidx = nullptr) const
{ {
if (lpidx != nullptr) { return sampler == right.sampler &&
*lpidx = -1;
*rpidx = -1;
}
return ((basicType != EbtSampler && right.basicType != EbtSampler) || sampler == right.sampler) &&
vectorSize == right.vectorSize && vectorSize == right.vectorSize &&
matrixCols == right.matrixCols && matrixCols == right.matrixCols &&
matrixRows == right.matrixRows && matrixRows == right.matrixRows &&
vector1 == right.vector1 && vector1 == right.vector1 &&
isCoopMat() == right.isCoopMat() && isCoopMat() == right.isCoopMat() &&
sameStructType(right, lpidx, rpidx) && sameStructType(right) &&
sameReferenceType(right); sameReferenceType(right);
} }

View file

@ -35,7 +35,7 @@
#define GLSLANG_BUILD_INFO #define GLSLANG_BUILD_INFO
#define GLSLANG_VERSION_MAJOR 11 #define GLSLANG_VERSION_MAJOR 11
#define GLSLANG_VERSION_MINOR 10 #define GLSLANG_VERSION_MINOR 6
#define GLSLANG_VERSION_PATCH 0 #define GLSLANG_VERSION_PATCH 0
#define GLSLANG_VERSION_FLAVOR "" #define GLSLANG_VERSION_FLAVOR ""

View file

@ -1155,7 +1155,7 @@ public:
virtual bool isIntegerDomain() const { return type.isIntegerDomain(); } virtual bool isIntegerDomain() const { return type.isIntegerDomain(); }
bool isAtomic() const { return type.isAtomic(); } bool isAtomic() const { return type.isAtomic(); }
bool isReference() const { return type.isReference(); } bool isReference() const { return type.isReference(); }
TString getCompleteString(bool enhanced = false) const { return type.getCompleteString(enhanced); } TString getCompleteString() const { return type.getCompleteString(); }
protected: protected:
TIntermTyped& operator=(const TIntermTyped&); TIntermTyped& operator=(const TIntermTyped&);
@ -1643,7 +1643,6 @@ public:
~TIntermAggregate() { delete pragmaTable; } ~TIntermAggregate() { delete pragmaTable; }
virtual TIntermAggregate* getAsAggregate() { return this; } virtual TIntermAggregate* getAsAggregate() { return this; }
virtual const TIntermAggregate* getAsAggregate() const { return this; } virtual const TIntermAggregate* getAsAggregate() const { return this; }
virtual void updatePrecision();
virtual void setOperator(TOperator o) { op = o; } virtual void setOperator(TOperator o) { op = o; }
virtual TIntermSequence& getSequence() { return sequence; } virtual TIntermSequence& getSequence() { return sequence; }
virtual const TIntermSequence& getSequence() const { return sequence; } virtual const TIntermSequence& getSequence() const { return sequence; }

View file

@ -50,6 +50,35 @@ namespace {
using namespace glslang; using namespace glslang;
typedef union {
double d;
int i[2];
} DoubleIntUnion;
// Some helper functions
bool isNan(double x)
{
DoubleIntUnion u;
// tough to find a platform independent library function, do it directly
u.d = x;
int bitPatternL = u.i[0];
int bitPatternH = u.i[1];
return (bitPatternH & 0x7ff80000) == 0x7ff80000 &&
((bitPatternH & 0xFFFFF) != 0 || bitPatternL != 0);
}
bool isInf(double x)
{
DoubleIntUnion u;
// tough to find a platform independent library function, do it directly
u.d = x;
int bitPatternL = u.i[0];
int bitPatternH = u.i[1];
return (bitPatternH & 0x7ff00000) == 0x7ff00000 &&
(bitPatternH & 0xFFFFF) == 0 && bitPatternL == 0;
}
const double pi = 3.1415926535897932384626433832795; const double pi = 3.1415926535897932384626433832795;
} // end anonymous namespace } // end anonymous namespace
@ -506,7 +535,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
case EbtFloat: newConstArray[i].setDConst(-unionArray[i].getDConst()); break; case EbtFloat: newConstArray[i].setDConst(-unionArray[i].getDConst()); break;
// Note: avoid UBSAN error regarding negating 0x80000000 // Note: avoid UBSAN error regarding negating 0x80000000
case EbtInt: newConstArray[i].setIConst( case EbtInt: newConstArray[i].setIConst(
static_cast<unsigned int>(unionArray[i].getIConst()) == 0x80000000 unionArray[i].getIConst() == 0x80000000
? -0x7FFFFFFF - 1 ? -0x7FFFFFFF - 1
: -unionArray[i].getIConst()); : -unionArray[i].getIConst());
break; break;
@ -638,12 +667,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
case EOpIsNan: case EOpIsNan:
{ {
newConstArray[i].setBConst(IsNan(unionArray[i].getDConst())); newConstArray[i].setBConst(isNan(unionArray[i].getDConst()));
break; break;
} }
case EOpIsInf: case EOpIsInf:
{ {
newConstArray[i].setBConst(IsInfinity(unionArray[i].getDConst())); newConstArray[i].setBConst(isInf(unionArray[i].getDConst()));
break; break;
} }

View file

@ -3,7 +3,7 @@
// Copyright (C) 2012-2016 LunarG, Inc. // Copyright (C) 2012-2016 LunarG, Inc.
// Copyright (C) 2015-2020 Google, Inc. // Copyright (C) 2015-2020 Google, Inc.
// Copyright (C) 2017 ARM Limited. // Copyright (C) 2017 ARM Limited.
// Modifications Copyright (C) 2020-2021 Advanced Micro Devices, Inc. All rights reserved. // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
// //
// All rights reserved. // All rights reserved.
// //
@ -316,7 +316,6 @@ const CustomFunction CustomFunctions[] = {
{ EOpTextureQuerySize, "textureSize", nullptr }, { EOpTextureQuerySize, "textureSize", nullptr },
{ EOpTextureQueryLod, "textureQueryLod", nullptr }, { EOpTextureQueryLod, "textureQueryLod", nullptr },
{ EOpTextureQueryLod, "textureQueryLOD", nullptr }, // extension GL_ARB_texture_query_lod
{ EOpTextureQueryLevels, "textureQueryLevels", nullptr }, { EOpTextureQueryLevels, "textureQueryLevels", nullptr },
{ EOpTextureQuerySamples, "textureSamples", nullptr }, { EOpTextureQuerySamples, "textureSamples", nullptr },
{ EOpTexture, "texture", nullptr }, { EOpTexture, "texture", nullptr },
@ -4160,6 +4159,106 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"u16vec4 unpack16(uint64_t);" "u16vec4 unpack16(uint64_t);"
"i32vec2 unpack32(int64_t);" "i32vec2 unpack32(int64_t);"
"u32vec2 unpack32(uint64_t);" "u32vec2 unpack32(uint64_t);"
"float64_t radians(float64_t);"
"f64vec2 radians(f64vec2);"
"f64vec3 radians(f64vec3);"
"f64vec4 radians(f64vec4);"
"float64_t degrees(float64_t);"
"f64vec2 degrees(f64vec2);"
"f64vec3 degrees(f64vec3);"
"f64vec4 degrees(f64vec4);"
"float64_t sin(float64_t);"
"f64vec2 sin(f64vec2);"
"f64vec3 sin(f64vec3);"
"f64vec4 sin(f64vec4);"
"float64_t cos(float64_t);"
"f64vec2 cos(f64vec2);"
"f64vec3 cos(f64vec3);"
"f64vec4 cos(f64vec4);"
"float64_t tan(float64_t);"
"f64vec2 tan(f64vec2);"
"f64vec3 tan(f64vec3);"
"f64vec4 tan(f64vec4);"
"float64_t asin(float64_t);"
"f64vec2 asin(f64vec2);"
"f64vec3 asin(f64vec3);"
"f64vec4 asin(f64vec4);"
"float64_t acos(float64_t);"
"f64vec2 acos(f64vec2);"
"f64vec3 acos(f64vec3);"
"f64vec4 acos(f64vec4);"
"float64_t atan(float64_t, float64_t);"
"f64vec2 atan(f64vec2, f64vec2);"
"f64vec3 atan(f64vec3, f64vec3);"
"f64vec4 atan(f64vec4, f64vec4);"
"float64_t atan(float64_t);"
"f64vec2 atan(f64vec2);"
"f64vec3 atan(f64vec3);"
"f64vec4 atan(f64vec4);"
"float64_t sinh(float64_t);"
"f64vec2 sinh(f64vec2);"
"f64vec3 sinh(f64vec3);"
"f64vec4 sinh(f64vec4);"
"float64_t cosh(float64_t);"
"f64vec2 cosh(f64vec2);"
"f64vec3 cosh(f64vec3);"
"f64vec4 cosh(f64vec4);"
"float64_t tanh(float64_t);"
"f64vec2 tanh(f64vec2);"
"f64vec3 tanh(f64vec3);"
"f64vec4 tanh(f64vec4);"
"float64_t asinh(float64_t);"
"f64vec2 asinh(f64vec2);"
"f64vec3 asinh(f64vec3);"
"f64vec4 asinh(f64vec4);"
"float64_t acosh(float64_t);"
"f64vec2 acosh(f64vec2);"
"f64vec3 acosh(f64vec3);"
"f64vec4 acosh(f64vec4);"
"float64_t atanh(float64_t);"
"f64vec2 atanh(f64vec2);"
"f64vec3 atanh(f64vec3);"
"f64vec4 atanh(f64vec4);"
"float64_t pow(float64_t, float64_t);"
"f64vec2 pow(f64vec2, f64vec2);"
"f64vec3 pow(f64vec3, f64vec3);"
"f64vec4 pow(f64vec4, f64vec4);"
"float64_t exp(float64_t);"
"f64vec2 exp(f64vec2);"
"f64vec3 exp(f64vec3);"
"f64vec4 exp(f64vec4);"
"float64_t log(float64_t);"
"f64vec2 log(f64vec2);"
"f64vec3 log(f64vec3);"
"f64vec4 log(f64vec4);"
"float64_t exp2(float64_t);"
"f64vec2 exp2(f64vec2);"
"f64vec3 exp2(f64vec3);"
"f64vec4 exp2(f64vec4);"
"float64_t log2(float64_t);"
"f64vec2 log2(f64vec2);"
"f64vec3 log2(f64vec3);"
"f64vec4 log2(f64vec4);"
"\n"); "\n");
} }
@ -4270,7 +4369,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
// //
//============================================================================ //============================================================================
if (profile != EEsProfile && (version >= 400 || version == 150)) { if (profile != EEsProfile && version >= 400) {
stageBuiltins[EShLangGeometry].append( stageBuiltins[EShLangGeometry].append(
"void EmitStreamVertex(int);" "void EmitStreamVertex(int);"
"void EndStreamPrimitive(int);" "void EndStreamPrimitive(int);"
@ -4554,7 +4653,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n"); "\n");
} }
// GL_ARB_shader_clock& GL_EXT_shader_realtime_clock // GL_ARB_shader_clock & GL_EXT_shader_realtime_clock
if (profile != EEsProfile && version >= 450) { if (profile != EEsProfile && version >= 450) {
commonBuiltins.append( commonBuiltins.append(
"uvec2 clock2x32ARB();" "uvec2 clock2x32ARB();"
@ -5075,13 +5174,9 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
); );
} }
if (version >= 430)
stageBuiltins[EShLangVertex].append(
"out int gl_ViewportMask[];" // GL_NV_viewport_array2
);
if (version >= 450) if (version >= 450)
stageBuiltins[EShLangVertex].append( stageBuiltins[EShLangVertex].append(
"out int gl_ViewportMask[];" // GL_NV_viewport_array2
"out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
"out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
"out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
@ -5217,13 +5312,9 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in int gl_InvocationID;" "in int gl_InvocationID;"
); );
if (version >= 430)
stageBuiltins[EShLangGeometry].append(
"out int gl_ViewportMask[];" // GL_NV_viewport_array2
);
if (version >= 450) if (version >= 450)
stageBuiltins[EShLangGeometry].append( stageBuiltins[EShLangGeometry].append(
"out int gl_ViewportMask[];" // GL_NV_viewport_array2
"out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
"out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
"out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
@ -5299,13 +5390,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
if (version >= 450) if (version >= 450)
stageBuiltins[EShLangTessControl].append( stageBuiltins[EShLangTessControl].append(
"float gl_CullDistance[];" "float gl_CullDistance[];"
);
if (version >= 430)
stageBuiltins[EShLangTessControl].append(
"int gl_ViewportMask[];" // GL_NV_viewport_array2 "int gl_ViewportMask[];" // GL_NV_viewport_array2
);
if (version >= 450)
stageBuiltins[EShLangTessControl].append(
"vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
"int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering "int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
"vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
@ -5408,13 +5493,9 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"out int gl_Layer;" "out int gl_Layer;"
"\n"); "\n");
if (version >= 430)
stageBuiltins[EShLangTessEvaluation].append(
"out int gl_ViewportMask[];" // GL_NV_viewport_array2
);
if (version >= 450) if (version >= 450)
stageBuiltins[EShLangTessEvaluation].append( stageBuiltins[EShLangTessEvaluation].append(
"out int gl_ViewportMask[];" // GL_NV_viewport_array2
"out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
"out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
"out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
@ -5571,8 +5652,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"flat in int gl_InvocationsPerPixelNV;" "flat in int gl_InvocationsPerPixelNV;"
"in vec3 gl_BaryCoordNV;" // GL_NV_fragment_shader_barycentric "in vec3 gl_BaryCoordNV;" // GL_NV_fragment_shader_barycentric
"in vec3 gl_BaryCoordNoPerspNV;" "in vec3 gl_BaryCoordNoPerspNV;"
"in vec3 gl_BaryCoordEXT;" // GL_EXT_fragment_shader_barycentric
"in vec3 gl_BaryCoordNoPerspEXT;"
); );
if (version >= 450) if (version >= 450)
@ -5637,9 +5716,7 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangFragment].append( stageBuiltins[EShLangFragment].append(
"in vec3 gl_BaryCoordNV;" "in vec3 gl_BaryCoordNV;"
"in vec3 gl_BaryCoordNoPerspNV;" "in vec3 gl_BaryCoordNoPerspNV;"
"in vec3 gl_BaryCoordEXT;" );
"in vec3 gl_BaryCoordNoPerspEXT;"
);
if (version >= 310) if (version >= 310)
stageBuiltins[EShLangFragment].append( stageBuiltins[EShLangFragment].append(
"flat in highp int gl_ShadingRateEXT;" // GL_EXT_fragment_shading_rate "flat in highp int gl_ShadingRateEXT;" // GL_EXT_fragment_shading_rate
@ -5861,7 +5938,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in uint gl_IncomingRayFlagsNV;" "in uint gl_IncomingRayFlagsNV;"
"in uint gl_IncomingRayFlagsEXT;" "in uint gl_IncomingRayFlagsEXT;"
"in float gl_CurrentRayTimeNV;" "in float gl_CurrentRayTimeNV;"
"in uint gl_CullMaskEXT;"
"\n"; "\n";
const char *hitDecls = const char *hitDecls =
"in uvec3 gl_LaunchIDNV;" "in uvec3 gl_LaunchIDNV;"
@ -5898,7 +5974,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in uint gl_IncomingRayFlagsNV;" "in uint gl_IncomingRayFlagsNV;"
"in uint gl_IncomingRayFlagsEXT;" "in uint gl_IncomingRayFlagsEXT;"
"in float gl_CurrentRayTimeNV;" "in float gl_CurrentRayTimeNV;"
"in uint gl_CullMaskEXT;"
"\n"; "\n";
const char *missDecls = const char *missDecls =
"in uvec3 gl_LaunchIDNV;" "in uvec3 gl_LaunchIDNV;"
@ -5918,7 +5993,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in uint gl_IncomingRayFlagsNV;" "in uint gl_IncomingRayFlagsNV;"
"in uint gl_IncomingRayFlagsEXT;" "in uint gl_IncomingRayFlagsEXT;"
"in float gl_CurrentRayTimeNV;" "in float gl_CurrentRayTimeNV;"
"in uint gl_CullMaskEXT;"
"\n"; "\n";
const char *callableDecls = const char *callableDecls =
@ -6255,44 +6329,38 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int
// //
// textureQueryLod(), fragment stage only // textureQueryLod(), fragment stage only
// Also enabled with extension GL_ARB_texture_query_lod // Also enabled with extension GL_ARB_texture_query_lod
// Extension GL_ARB_texture_query_lod says that textureQueryLOD() also exist at extension.
if (profile != EEsProfile && version >= 150 && sampler.isCombined() && sampler.dim != EsdRect && if (profile != EEsProfile && version >= 150 && sampler.isCombined() && sampler.dim != EsdRect &&
! sampler.isMultiSample() && ! sampler.isBuffer()) { ! sampler.isMultiSample() && ! sampler.isBuffer()) {
for (int f16TexAddr = 0; f16TexAddr < 2; ++f16TexAddr) {
const TString funcName[2] = {"vec2 textureQueryLod(", "vec2 textureQueryLOD("}; if (f16TexAddr && sampler.type != EbtFloat16)
continue;
for (int i = 0; i < 2; ++i){ stageBuiltins[EShLangFragment].append("vec2 textureQueryLod(");
for (int f16TexAddr = 0; f16TexAddr < 2; ++f16TexAddr) { stageBuiltins[EShLangFragment].append(typeName);
if (f16TexAddr && sampler.type != EbtFloat16)
continue;
stageBuiltins[EShLangFragment].append(funcName[i]);
stageBuiltins[EShLangFragment].append(typeName);
if (dimMap[sampler.dim] == 1)
if (f16TexAddr)
stageBuiltins[EShLangFragment].append(", float16_t");
else
stageBuiltins[EShLangFragment].append(", float");
else {
if (f16TexAddr)
stageBuiltins[EShLangFragment].append(", f16vec");
else
stageBuiltins[EShLangFragment].append(", vec");
stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]);
}
stageBuiltins[EShLangFragment].append(");\n");
}
stageBuiltins[EShLangCompute].append(funcName[i]);
stageBuiltins[EShLangCompute].append(typeName);
if (dimMap[sampler.dim] == 1) if (dimMap[sampler.dim] == 1)
stageBuiltins[EShLangCompute].append(", float"); if (f16TexAddr)
stageBuiltins[EShLangFragment].append(", float16_t");
else
stageBuiltins[EShLangFragment].append(", float");
else { else {
stageBuiltins[EShLangCompute].append(", vec"); if (f16TexAddr)
stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]); stageBuiltins[EShLangFragment].append(", f16vec");
else
stageBuiltins[EShLangFragment].append(", vec");
stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]);
} }
stageBuiltins[EShLangCompute].append(");\n"); stageBuiltins[EShLangFragment].append(");\n");
} }
stageBuiltins[EShLangCompute].append("vec2 textureQueryLod(");
stageBuiltins[EShLangCompute].append(typeName);
if (dimMap[sampler.dim] == 1)
stageBuiltins[EShLangCompute].append(", float");
else {
stageBuiltins[EShLangCompute].append(", vec");
stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]);
}
stageBuiltins[EShLangCompute].append(");\n");
} }
// //
@ -7633,11 +7701,6 @@ static void BuiltInVariable(const char* name, TBuiltInVariable builtIn, TSymbolT
symQualifier.builtIn = builtIn; symQualifier.builtIn = builtIn;
} }
static void RetargetVariable(const char* from, const char* to, TSymbolTable& symbolTable)
{
symbolTable.retargetSymbol(from, to);
}
// //
// For built-in variables inside a named block. // For built-in variables inside a named block.
// SpecialQualifier() won't ever go inside a block; their member's qualifier come // SpecialQualifier() won't ever go inside a block; their member's qualifier come
@ -7705,8 +7768,8 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
if (spvVersion.vulkan > 0 && spvVersion.vulkanRelaxed) { if (spvVersion.vulkan > 0 && spvVersion.vulkanRelaxed) {
// treat these built-ins as aliases of VertexIndex and InstanceIndex // treat these built-ins as aliases of VertexIndex and InstanceIndex
RetargetVariable("gl_InstanceID", "gl_InstanceIndex", symbolTable); BuiltInVariable("gl_VertexID", EbvVertexIndex, symbolTable);
RetargetVariable("gl_VertexID", "gl_VertexIndex", symbolTable); BuiltInVariable("gl_InstanceID", EbvInstanceIndex, symbolTable);
} }
if (profile != EEsProfile) { if (profile != EEsProfile) {
@ -8077,7 +8140,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
} }
if (profile != EEsProfile && version < 400) { if (profile != EEsProfile && version < 400) {
symbolTable.setFunctionExtensions("textureQueryLOD", 1, &E_GL_ARB_texture_query_lod); symbolTable.setFunctionExtensions("textureQueryLod", 1, &E_GL_ARB_texture_query_lod);
} }
if (profile != EEsProfile && version >= 460) { if (profile != EEsProfile && version >= 460) {
@ -8325,10 +8388,6 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setVariableExtensions("gl_BaryCoordNoPerspNV", 1, &E_GL_NV_fragment_shader_barycentric); symbolTable.setVariableExtensions("gl_BaryCoordNoPerspNV", 1, &E_GL_NV_fragment_shader_barycentric);
BuiltInVariable("gl_BaryCoordNV", EbvBaryCoordNV, symbolTable); BuiltInVariable("gl_BaryCoordNV", EbvBaryCoordNV, symbolTable);
BuiltInVariable("gl_BaryCoordNoPerspNV", EbvBaryCoordNoPerspNV, symbolTable); BuiltInVariable("gl_BaryCoordNoPerspNV", EbvBaryCoordNoPerspNV, symbolTable);
symbolTable.setVariableExtensions("gl_BaryCoordEXT", 1, &E_GL_EXT_fragment_shader_barycentric);
symbolTable.setVariableExtensions("gl_BaryCoordNoPerspEXT", 1, &E_GL_EXT_fragment_shader_barycentric);
BuiltInVariable("gl_BaryCoordEXT", EbvBaryCoordEXT, symbolTable);
BuiltInVariable("gl_BaryCoordNoPerspEXT", EbvBaryCoordNoPerspEXT, symbolTable);
} }
if ((profile != EEsProfile && version >= 450) || if ((profile != EEsProfile && version >= 450) ||
@ -8344,7 +8403,7 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setFunctionExtensions("clockARB", 1, &E_GL_ARB_shader_clock); symbolTable.setFunctionExtensions("clockARB", 1, &E_GL_ARB_shader_clock);
symbolTable.setFunctionExtensions("clock2x32ARB", 1, &E_GL_ARB_shader_clock); symbolTable.setFunctionExtensions("clock2x32ARB", 1, &E_GL_ARB_shader_clock);
symbolTable.setFunctionExtensions("clockRealtimeEXT", 1, &E_GL_EXT_shader_realtime_clock); symbolTable.setFunctionExtensions("clockRealtimeEXT", 1, &E_GL_EXT_shader_realtime_clock);
symbolTable.setFunctionExtensions("clockRealtime2x32EXT", 1, &E_GL_EXT_shader_realtime_clock); symbolTable.setFunctionExtensions("clockRealtime2x32EXT", 1, &E_GL_EXT_shader_realtime_clock);
if (profile == EEsProfile && version < 320) { if (profile == EEsProfile && version < 320) {
@ -8364,11 +8423,10 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
} }
if (profile != EEsProfile && version < 330 ) { if (profile != EEsProfile && version < 330 ) {
const char* bitsConvertExt[2] = {E_GL_ARB_shader_bit_encoding, E_GL_ARB_gpu_shader5}; symbolTable.setFunctionExtensions("floatBitsToInt", 1, &E_GL_ARB_shader_bit_encoding);
symbolTable.setFunctionExtensions("floatBitsToInt", 2, bitsConvertExt); symbolTable.setFunctionExtensions("floatBitsToUint", 1, &E_GL_ARB_shader_bit_encoding);
symbolTable.setFunctionExtensions("floatBitsToUint", 2, bitsConvertExt); symbolTable.setFunctionExtensions("intBitsToFloat", 1, &E_GL_ARB_shader_bit_encoding);
symbolTable.setFunctionExtensions("intBitsToFloat", 2, bitsConvertExt); symbolTable.setFunctionExtensions("uintBitsToFloat", 1, &E_GL_ARB_shader_bit_encoding);
symbolTable.setFunctionExtensions("uintBitsToFloat", 2, bitsConvertExt);
} }
if (profile != EEsProfile && version < 430 ) { if (profile != EEsProfile && version < 430 ) {
@ -8754,7 +8812,6 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setVariableExtensions("gl_RayTminEXT", 1, &E_GL_EXT_ray_tracing); symbolTable.setVariableExtensions("gl_RayTminEXT", 1, &E_GL_EXT_ray_tracing);
symbolTable.setVariableExtensions("gl_RayTmaxNV", 1, &E_GL_NV_ray_tracing); symbolTable.setVariableExtensions("gl_RayTmaxNV", 1, &E_GL_NV_ray_tracing);
symbolTable.setVariableExtensions("gl_RayTmaxEXT", 1, &E_GL_EXT_ray_tracing); symbolTable.setVariableExtensions("gl_RayTmaxEXT", 1, &E_GL_EXT_ray_tracing);
symbolTable.setVariableExtensions("gl_CullMaskEXT", 1, &E_GL_EXT_ray_cull_mask);
symbolTable.setVariableExtensions("gl_HitTNV", 1, &E_GL_NV_ray_tracing); symbolTable.setVariableExtensions("gl_HitTNV", 1, &E_GL_NV_ray_tracing);
symbolTable.setVariableExtensions("gl_HitTEXT", 1, &E_GL_EXT_ray_tracing); symbolTable.setVariableExtensions("gl_HitTEXT", 1, &E_GL_EXT_ray_tracing);
symbolTable.setVariableExtensions("gl_HitKindNV", 1, &E_GL_NV_ray_tracing); symbolTable.setVariableExtensions("gl_HitKindNV", 1, &E_GL_NV_ray_tracing);
@ -8804,7 +8861,6 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_RayTminEXT", EbvRayTmin, symbolTable); BuiltInVariable("gl_RayTminEXT", EbvRayTmin, symbolTable);
BuiltInVariable("gl_RayTmaxNV", EbvRayTmax, symbolTable); BuiltInVariable("gl_RayTmaxNV", EbvRayTmax, symbolTable);
BuiltInVariable("gl_RayTmaxEXT", EbvRayTmax, symbolTable); BuiltInVariable("gl_RayTmaxEXT", EbvRayTmax, symbolTable);
BuiltInVariable("gl_CullMaskEXT", EbvCullMask, symbolTable);
BuiltInVariable("gl_HitTNV", EbvHitT, symbolTable); BuiltInVariable("gl_HitTNV", EbvHitT, symbolTable);
BuiltInVariable("gl_HitTEXT", EbvHitT, symbolTable); BuiltInVariable("gl_HitTEXT", EbvHitT, symbolTable);
BuiltInVariable("gl_HitKindNV", EbvHitKind, symbolTable); BuiltInVariable("gl_HitKindNV", EbvHitKind, symbolTable);

View file

@ -416,24 +416,20 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child,
// TODO: but, did this bypass constant folding? // TODO: but, did this bypass constant folding?
// //
switch (op) { switch (op) {
case EOpConstructInt8: case EOpConstructInt8:
case EOpConstructUint8: case EOpConstructUint8:
case EOpConstructInt16: case EOpConstructInt16:
case EOpConstructUint16: case EOpConstructUint16:
case EOpConstructInt: case EOpConstructInt:
case EOpConstructUint: case EOpConstructUint:
case EOpConstructInt64: case EOpConstructInt64:
case EOpConstructUint64: case EOpConstructUint64:
case EOpConstructBool: case EOpConstructBool:
case EOpConstructFloat: case EOpConstructFloat:
case EOpConstructDouble: case EOpConstructDouble:
case EOpConstructFloat16: { case EOpConstructFloat16:
TIntermUnary* unary_node = child->getAsUnaryNode(); return child;
if (unary_node != nullptr) default: break; // some compilers want this
unary_node->updatePrecision();
return child;
}
default: break; // some compilers want this
} }
// //
@ -2766,7 +2762,7 @@ void TIntermBranch::updatePrecision(TPrecisionQualifier parentPrecision)
return; return;
if (exp->getBasicType() == EbtInt || exp->getBasicType() == EbtUint || if (exp->getBasicType() == EbtInt || exp->getBasicType() == EbtUint ||
exp->getBasicType() == EbtFloat) { exp->getBasicType() == EbtFloat || exp->getBasicType() == EbtFloat16) {
if (parentPrecision != EpqNone && exp->getQualifier().precision == EpqNone) { if (parentPrecision != EpqNone && exp->getQualifier().precision == EpqNone) {
exp->propagatePrecision(parentPrecision); exp->propagatePrecision(parentPrecision);
} }
@ -3284,7 +3280,7 @@ bool TIntermediate::promoteUnary(TIntermUnary& node)
void TIntermUnary::updatePrecision() void TIntermUnary::updatePrecision()
{ {
if (getBasicType() == EbtInt || getBasicType() == EbtUint || if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat) { getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
if (operand->getQualifier().precision > getQualifier().precision) if (operand->getQualifier().precision > getQualifier().precision)
getQualifier().precision = operand->getQualifier().precision; getQualifier().precision = operand->getQualifier().precision;
} }
@ -3780,34 +3776,12 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
return false; return false;
} }
// Propagate precision qualifiers *up* from children to parent, and then
// back *down* again to the children's subtrees.
void TIntermAggregate::updatePrecision()
{
if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat) {
TPrecisionQualifier maxPrecision = EpqNone;
TIntermSequence operands = getSequence();
for (unsigned int i = 0; i < operands.size(); ++i) {
TIntermTyped* typedNode = operands[i]->getAsTyped();
assert(typedNode);
maxPrecision = std::max(maxPrecision, typedNode->getQualifier().precision);
}
getQualifier().precision = maxPrecision;
for (unsigned int i = 0; i < operands.size(); ++i) {
TIntermTyped* typedNode = operands[i]->getAsTyped();
assert(typedNode);
typedNode->propagatePrecision(maxPrecision);
}
}
}
// Propagate precision qualifiers *up* from children to parent, and then // Propagate precision qualifiers *up* from children to parent, and then
// back *down* again to the children's subtrees. // back *down* again to the children's subtrees.
void TIntermBinary::updatePrecision() void TIntermBinary::updatePrecision()
{ {
if (getBasicType() == EbtInt || getBasicType() == EbtUint || if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat) { getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
if (op == EOpRightShift || op == EOpLeftShift) { if (op == EOpRightShift || op == EOpLeftShift) {
// For shifts get precision from left side only and thus no need to propagate // For shifts get precision from left side only and thus no need to propagate
getQualifier().precision = left->getQualifier().precision; getQualifier().precision = left->getQualifier().precision;
@ -3902,7 +3876,7 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
case EbtFloat16: PROMOTE(setDConst, double, Get); break; \ case EbtFloat16: PROMOTE(setDConst, double, Get); break; \
case EbtFloat: PROMOTE(setDConst, double, Get); break; \ case EbtFloat: PROMOTE(setDConst, double, Get); break; \
case EbtDouble: PROMOTE(setDConst, double, Get); break; \ case EbtDouble: PROMOTE(setDConst, double, Get); break; \
case EbtInt8: PROMOTE(setI8Const, signed char, Get); break; \ case EbtInt8: PROMOTE(setI8Const, char, Get); break; \
case EbtInt16: PROMOTE(setI16Const, short, Get); break; \ case EbtInt16: PROMOTE(setI16Const, short, Get); break; \
case EbtInt: PROMOTE(setIConst, int, Get); break; \ case EbtInt: PROMOTE(setIConst, int, Get); break; \
case EbtInt64: PROMOTE(setI64Const, long long, Get); break; \ case EbtInt64: PROMOTE(setI64Const, long long, Get); break; \

View file

@ -74,9 +74,6 @@ void C_DECL TParseContextBase::error(const TSourceLoc& loc, const char* szReason
{ {
if (messages & EShMsgOnlyPreprocessor) if (messages & EShMsgOnlyPreprocessor)
return; return;
// If enhanced msg readability, only print one error
if (messages & EShMsgEnhanced && numErrors > 0)
return;
va_list args; va_list args;
va_start(args, szExtraInfoFormat); va_start(args, szExtraInfoFormat);
outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args); outputMessage(loc, szReason, szToken, szExtraInfoFormat, EPrefixError, args);
@ -625,19 +622,6 @@ void TParseContextBase::growGlobalUniformBlock(const TSourceLoc& loc, TType& mem
globalUniformBlock->getWritableType().getQualifier().layoutBinding = globalUniformBinding; globalUniformBlock->getWritableType().getQualifier().layoutBinding = globalUniformBinding;
globalUniformBlock->getWritableType().getQualifier().layoutSet = globalUniformSet; globalUniformBlock->getWritableType().getQualifier().layoutSet = globalUniformSet;
// Check for declarations of this default uniform that already exist due to other compilation units.
TSymbol* symbol = symbolTable.find(memberName);
if (symbol) {
if (memberType != symbol->getType()) {
TString err;
err += "\"" + memberType.getCompleteString() + "\"";
err += " versus ";
err += "\"" + symbol->getType().getCompleteString() + "\"";
error(loc, "Types must match:", memberType.getFieldName().c_str(), err.c_str());
}
return;
}
// Add the requested member as a member to the global block. // Add the requested member as a member to the global block.
TType* type = new TType; TType* type = new TType;
type->shallowCopy(memberType); type->shallowCopy(memberType);

View file

@ -716,7 +716,7 @@ bool TParseContext::isIoResizeArray(const TType& type) const
(language == EShLangTessControl && type.getQualifier().storage == EvqVaryingOut && (language == EShLangTessControl && type.getQualifier().storage == EvqVaryingOut &&
! type.getQualifier().patch) || ! type.getQualifier().patch) ||
(language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn && (language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn &&
(type.getQualifier().pervertexNV || type.getQualifier().pervertexEXT)) || type.getQualifier().pervertexNV) ||
(language == EShLangMeshNV && type.getQualifier().storage == EvqVaryingOut && (language == EShLangMeshNV && type.getQualifier().storage == EvqVaryingOut &&
!type.getQualifier().perTaskNV)); !type.getQualifier().perTaskNV));
} }
@ -856,7 +856,7 @@ void TParseContext::checkIoArrayConsistency(const TSourceLoc& loc, int requiredS
error(loc, "inconsistent output number of vertices for array size of", feature, name.c_str()); error(loc, "inconsistent output number of vertices for array size of", feature, name.c_str());
else if (language == EShLangFragment) { else if (language == EShLangFragment) {
if (type.getOuterArraySize() > requiredSize) if (type.getOuterArraySize() > requiredSize)
error(loc, " cannot be greater than 3 for pervertexEXT", feature, name.c_str()); error(loc, " cannot be greater than 3 for pervertexNV", feature, name.c_str());
} }
else if (language == EShLangMeshNV) else if (language == EShLangMeshNV)
error(loc, "inconsistent output array size of", feature, name.c_str()); error(loc, "inconsistent output array size of", feature, name.c_str());
@ -902,10 +902,8 @@ TIntermTyped* TParseContext::handleBinaryMath(const TSourceLoc& loc, const char*
result = intermediate.addBinaryMath(op, left, right, loc); result = intermediate.addBinaryMath(op, left, right, loc);
} }
if (result == nullptr) { if (result == nullptr)
bool enhanced = intermediate.getEnhancedMsgs(); binaryOpError(loc, str, left->getCompleteString(), right->getCompleteString());
binaryOpError(loc, str, left->getCompleteString(enhanced), right->getCompleteString(enhanced));
}
return result; return result;
} }
@ -928,10 +926,8 @@ TIntermTyped* TParseContext::handleUnaryMath(const TSourceLoc& loc, const char*
if (result) if (result)
return result; return result;
else { else
bool enhanced = intermediate.getEnhancedMsgs(); unaryOpError(loc, str, childNode->getCompleteString());
unaryOpError(loc, str, childNode->getCompleteString(enhanced));
}
return childNode; return childNode;
} }
@ -957,8 +953,8 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
requireProfile(loc, ~EEsProfile, feature); requireProfile(loc, ~EEsProfile, feature);
profileRequires(loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, feature); profileRequires(loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, feature);
} else if (!base->getType().isCoopMat()) { } else if (!base->getType().isCoopMat()) {
bool enhanced = intermediate.getEnhancedMsgs(); error(loc, "does not operate on this type:", field.c_str(), base->getType().getCompleteString().c_str());
error(loc, "does not operate on this type:", field.c_str(), base->getType().getCompleteString(enhanced).c_str());
return base; return base;
} }
@ -1009,16 +1005,10 @@ TIntermTyped* TParseContext::handleDotDereference(const TSourceLoc& loc, TInterm
intermediate.addIoAccessed(field); intermediate.addIoAccessed(field);
} }
inheritMemoryQualifiers(base->getQualifier(), result->getWritableType().getQualifier()); inheritMemoryQualifiers(base->getQualifier(), result->getWritableType().getQualifier());
} else { } else
auto baseSymbol = base; error(loc, "no such field in structure", field.c_str(), "");
while (baseSymbol->getAsSymbolNode() == nullptr)
baseSymbol = baseSymbol->getAsBinaryNode()->getLeft();
TString structName;
structName.append("\'").append(baseSymbol->getAsSymbolNode()->getName().c_str()).append( "\'");
error(loc, "no such field in structure", field.c_str(), structName.c_str());
}
} else } else
error(loc, "does not apply to this type:", field.c_str(), base->getType().getCompleteString(intermediate.getEnhancedMsgs()).c_str()); error(loc, "does not apply to this type:", field.c_str(), base->getType().getCompleteString().c_str());
// Propagate noContraction up the dereference chain // Propagate noContraction up the dereference chain
if (base->getQualifier().isNoContraction()) if (base->getQualifier().isNoContraction())
@ -1324,14 +1314,14 @@ TIntermTyped* TParseContext::handleFunctionCall(const TSourceLoc& loc, TFunction
// //
result = addConstructor(loc, arguments, type); result = addConstructor(loc, arguments, type);
if (result == nullptr) if (result == nullptr)
error(loc, "cannot construct with these arguments", type.getCompleteString(intermediate.getEnhancedMsgs()).c_str(), ""); error(loc, "cannot construct with these arguments", type.getCompleteString().c_str(), "");
} }
} else { } else {
// //
// Find it in the symbol table. // Find it in the symbol table.
// //
const TFunction* fnCandidate; const TFunction* fnCandidate;
bool builtIn {false}; bool builtIn;
fnCandidate = findFunction(loc, *function, builtIn); fnCandidate = findFunction(loc, *function, builtIn);
if (fnCandidate) { if (fnCandidate) {
// This is a declared function that might map to // This is a declared function that might map to
@ -1504,7 +1494,7 @@ TIntermTyped* TParseContext::handleBuiltInFunctionCall(TSourceLoc loc, TIntermNo
else else
error(arguments->getLoc(), " wrong operand type", "Internal Error", error(arguments->getLoc(), " wrong operand type", "Internal Error",
"built in unary operator function. Type: %s", "built in unary operator function. Type: %s",
static_cast<TIntermTyped*>(arguments)->getCompleteString(intermediate.getEnhancedMsgs()).c_str()); static_cast<TIntermTyped*>(arguments)->getCompleteString().c_str());
} else if (result->getAsOperator()) } else if (result->getAsOperator())
builtInOpCheck(loc, function, *result->getAsOperator()); builtInOpCheck(loc, function, *result->getAsOperator());
@ -2327,7 +2317,7 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
error(loc, "argument must be compile-time constant", "payload number", "a"); error(loc, "argument must be compile-time constant", "payload number", "a");
else { else {
unsigned int location = (*argp)[10]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst(); unsigned int location = (*argp)[10]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(0, location) < 0) if (intermediate.checkLocationRT(0, location) < 0)
error(loc, "with layout(location =", "no rayPayloadEXT/rayPayloadInEXT declared", "%d)", location); error(loc, "with layout(location =", "no rayPayloadEXT/rayPayloadInEXT declared", "%d)", location);
} }
break; break;
@ -2340,7 +2330,7 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
error(loc, "argument must be compile-time constant", "callable data number", ""); error(loc, "argument must be compile-time constant", "callable data number", "");
else { else {
unsigned int location = (*argp)[1]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst(); unsigned int location = (*argp)[1]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(1, location) < 0) if (intermediate.checkLocationRT(1, location) < 0)
error(loc, "with layout(location =", "no callableDataEXT/callableDataInEXT declared", "%d)", location); error(loc, "with layout(location =", "no callableDataEXT/callableDataInEXT declared", "%d)", location);
} }
break; break;
@ -2505,8 +2495,6 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
case EOpEmitStreamVertex: case EOpEmitStreamVertex:
case EOpEndStreamPrimitive: case EOpEndStreamPrimitive:
if (version == 150)
requireExtensions(loc, 1, &E_GL_ARB_gpu_shader5, "if the verison is 150 , the EmitStreamVertex and EndStreamPrimitive only support at extension GL_ARB_gpu_shader5");
intermediate.setMultiStream(); intermediate.setMultiStream();
break; break;
@ -2609,24 +2597,23 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
// Check that if extended types are being used that the correct extensions are enabled. // Check that if extended types are being used that the correct extensions are enabled.
if (arg0 != nullptr) { if (arg0 != nullptr) {
const TType& type = arg0->getType(); const TType& type = arg0->getType();
bool enhanced = intermediate.getEnhancedMsgs();
switch (type.getBasicType()) { switch (type.getBasicType()) {
default: default:
break; break;
case EbtInt8: case EbtInt8:
case EbtUint8: case EbtUint8:
requireExtensions(loc, 1, &E_GL_EXT_shader_subgroup_extended_types_int8, type.getCompleteString(enhanced).c_str()); requireExtensions(loc, 1, &E_GL_EXT_shader_subgroup_extended_types_int8, type.getCompleteString().c_str());
break; break;
case EbtInt16: case EbtInt16:
case EbtUint16: case EbtUint16:
requireExtensions(loc, 1, &E_GL_EXT_shader_subgroup_extended_types_int16, type.getCompleteString(enhanced).c_str()); requireExtensions(loc, 1, &E_GL_EXT_shader_subgroup_extended_types_int16, type.getCompleteString().c_str());
break; break;
case EbtInt64: case EbtInt64:
case EbtUint64: case EbtUint64:
requireExtensions(loc, 1, &E_GL_EXT_shader_subgroup_extended_types_int64, type.getCompleteString(enhanced).c_str()); requireExtensions(loc, 1, &E_GL_EXT_shader_subgroup_extended_types_int64, type.getCompleteString().c_str());
break; break;
case EbtFloat16: case EbtFloat16:
requireExtensions(loc, 1, &E_GL_EXT_shader_subgroup_extended_types_float16, type.getCompleteString(enhanced).c_str()); requireExtensions(loc, 1, &E_GL_EXT_shader_subgroup_extended_types_float16, type.getCompleteString().c_str());
break; break;
} }
} }
@ -2799,10 +2786,7 @@ TFunction* TParseContext::handleConstructorCall(const TSourceLoc& loc, const TPu
TOperator op = intermediate.mapTypeToConstructorOp(type); TOperator op = intermediate.mapTypeToConstructorOp(type);
if (op == EOpNull) { if (op == EOpNull) {
if (intermediate.getEnhancedMsgs() && type.getBasicType() == EbtSampler) error(loc, "cannot construct this type", type.getBasicString(), "");
error(loc, "function not supported in this version; use texture() instead", "texture*D*", "");
else
error(loc, "cannot construct this type", type.getBasicString(), "");
op = EOpConstructFloat; op = EOpConstructFloat;
TType errorType(EbtFloat); TType errorType(EbtFloat);
type.shallowCopy(errorType); type.shallowCopy(errorType);
@ -3045,14 +3029,11 @@ void TParseContext::constantValueCheck(TIntermTyped* node, const char* token)
// //
// Both test, and if necessary spit out an error, to see if the node is really // Both test, and if necessary spit out an error, to see if the node is really
// a 32-bit integer or can implicitly convert to one. // an integer.
// //
void TParseContext::integerCheck(const TIntermTyped* node, const char* token) void TParseContext::integerCheck(const TIntermTyped* node, const char* token)
{ {
auto from_type = node->getBasicType(); if ((node->getBasicType() == EbtInt || node->getBasicType() == EbtUint) && node->isScalar())
if ((from_type == EbtInt || from_type == EbtUint ||
intermediate.canImplicitlyPromote(from_type, EbtInt, EOpNull) ||
intermediate.canImplicitlyPromote(from_type, EbtUint, EOpNull)) && node->isScalar())
return; return;
error(node->getLoc(), "scalar integer expression required", token, ""); error(node->getLoc(), "scalar integer expression required", token, "");
@ -3212,12 +3193,6 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
break; break;
} }
TString constructorString;
if (intermediate.getEnhancedMsgs())
constructorString.append(type.getCompleteString(true, false, false, true)).append(" constructor");
else
constructorString.append("constructor");
// See if it's a matrix // See if it's a matrix
bool constructingMatrix = false; bool constructingMatrix = false;
switch (op) { switch (op) {
@ -3275,7 +3250,7 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
if (function[arg].type->isArray()) { if (function[arg].type->isArray()) {
if (function[arg].type->isUnsizedArray()) { if (function[arg].type->isUnsizedArray()) {
// Can't construct from an unsized array. // Can't construct from an unsized array.
error(loc, "array argument must be sized", constructorString.c_str(), ""); error(loc, "array argument must be sized", "constructor", "");
return true; return true;
} }
arrayArg = true; arrayArg = true;
@ -3305,13 +3280,13 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
intArgument = true; intArgument = true;
if (type.isStruct()) { if (type.isStruct()) {
if (function[arg].type->contains16BitFloat()) { if (function[arg].type->contains16BitFloat()) {
requireFloat16Arithmetic(loc, constructorString.c_str(), "can't construct structure containing 16-bit type"); requireFloat16Arithmetic(loc, "constructor", "can't construct structure containing 16-bit type");
} }
if (function[arg].type->contains16BitInt()) { if (function[arg].type->contains16BitInt()) {
requireInt16Arithmetic(loc, constructorString.c_str(), "can't construct structure containing 16-bit type"); requireInt16Arithmetic(loc, "constructor", "can't construct structure containing 16-bit type");
} }
if (function[arg].type->contains8BitInt()) { if (function[arg].type->contains8BitInt()) {
requireInt8Arithmetic(loc, constructorString.c_str(), "can't construct structure containing 8-bit type"); requireInt8Arithmetic(loc, "constructor", "can't construct structure containing 8-bit type");
} }
} }
} }
@ -3325,9 +3300,9 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
case EOpConstructF16Vec3: case EOpConstructF16Vec3:
case EOpConstructF16Vec4: case EOpConstructF16Vec4:
if (type.isArray()) if (type.isArray())
requireFloat16Arithmetic(loc, constructorString.c_str(), "16-bit arrays not supported"); requireFloat16Arithmetic(loc, "constructor", "16-bit arrays not supported");
if (type.isVector() && function.getParamCount() != 1) if (type.isVector() && function.getParamCount() != 1)
requireFloat16Arithmetic(loc, constructorString.c_str(), "16-bit vectors only take vector types"); requireFloat16Arithmetic(loc, "constructor", "16-bit vectors only take vector types");
break; break;
case EOpConstructUint16: case EOpConstructUint16:
case EOpConstructU16Vec2: case EOpConstructU16Vec2:
@ -3338,9 +3313,9 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
case EOpConstructI16Vec3: case EOpConstructI16Vec3:
case EOpConstructI16Vec4: case EOpConstructI16Vec4:
if (type.isArray()) if (type.isArray())
requireInt16Arithmetic(loc, constructorString.c_str(), "16-bit arrays not supported"); requireInt16Arithmetic(loc, "constructor", "16-bit arrays not supported");
if (type.isVector() && function.getParamCount() != 1) if (type.isVector() && function.getParamCount() != 1)
requireInt16Arithmetic(loc, constructorString.c_str(), "16-bit vectors only take vector types"); requireInt16Arithmetic(loc, "constructor", "16-bit vectors only take vector types");
break; break;
case EOpConstructUint8: case EOpConstructUint8:
case EOpConstructU8Vec2: case EOpConstructU8Vec2:
@ -3351,9 +3326,9 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
case EOpConstructI8Vec3: case EOpConstructI8Vec3:
case EOpConstructI8Vec4: case EOpConstructI8Vec4:
if (type.isArray()) if (type.isArray())
requireInt8Arithmetic(loc, constructorString.c_str(), "8-bit arrays not supported"); requireInt8Arithmetic(loc, "constructor", "8-bit arrays not supported");
if (type.isVector() && function.getParamCount() != 1) if (type.isVector() && function.getParamCount() != 1)
requireInt8Arithmetic(loc, constructorString.c_str(), "8-bit vectors only take vector types"); requireInt8Arithmetic(loc, "constructor", "8-bit vectors only take vector types");
break; break;
default: default:
break; break;
@ -3435,7 +3410,7 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
if (type.isArray()) { if (type.isArray()) {
if (function.getParamCount() == 0) { if (function.getParamCount() == 0) {
error(loc, "array constructor must have at least one argument", constructorString.c_str(), ""); error(loc, "array constructor must have at least one argument", "constructor", "");
return true; return true;
} }
@ -3443,7 +3418,7 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
// auto adapt the constructor type to the number of arguments // auto adapt the constructor type to the number of arguments
type.changeOuterArraySize(function.getParamCount()); type.changeOuterArraySize(function.getParamCount());
} else if (type.getOuterArraySize() != function.getParamCount()) { } else if (type.getOuterArraySize() != function.getParamCount()) {
error(loc, "array constructor needs one argument per array element", constructorString.c_str(), ""); error(loc, "array constructor needs one argument per array element", "constructor", "");
return true; return true;
} }
@ -3456,7 +3431,7 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
// At least the dimensionalities have to match. // At least the dimensionalities have to match.
if (! function[0].type->isArray() || if (! function[0].type->isArray() ||
arraySizes.getNumDims() != function[0].type->getArraySizes()->getNumDims() + 1) { arraySizes.getNumDims() != function[0].type->getArraySizes()->getNumDims() + 1) {
error(loc, "array constructor argument not correct type to construct array element", constructorString.c_str(), ""); error(loc, "array constructor argument not correct type to construct array element", "constructor", "");
return true; return true;
} }
@ -3473,7 +3448,7 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
} }
if (arrayArg && op != EOpConstructStruct && ! type.isArrayOfArrays()) { if (arrayArg && op != EOpConstructStruct && ! type.isArrayOfArrays()) {
error(loc, "constructing non-array constituent from array argument", constructorString.c_str(), ""); error(loc, "constructing non-array constituent from array argument", "constructor", "");
return true; return true;
} }
@ -3483,51 +3458,51 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
// "If a matrix argument is given to a matrix constructor, // "If a matrix argument is given to a matrix constructor,
// it is a compile-time error to have any other arguments." // it is a compile-time error to have any other arguments."
if (function.getParamCount() != 1) if (function.getParamCount() != 1)
error(loc, "matrix constructed from matrix can only have one argument", constructorString.c_str(), ""); error(loc, "matrix constructed from matrix can only have one argument", "constructor", "");
return false; return false;
} }
if (overFull) { if (overFull) {
error(loc, "too many arguments", constructorString.c_str(), ""); error(loc, "too many arguments", "constructor", "");
return true; return true;
} }
if (op == EOpConstructStruct && ! type.isArray() && (int)type.getStruct()->size() != function.getParamCount()) { if (op == EOpConstructStruct && ! type.isArray() && (int)type.getStruct()->size() != function.getParamCount()) {
error(loc, "Number of constructor parameters does not match the number of structure fields", constructorString.c_str(), ""); error(loc, "Number of constructor parameters does not match the number of structure fields", "constructor", "");
return true; return true;
} }
if ((op != EOpConstructStruct && size != 1 && size < type.computeNumComponents()) || if ((op != EOpConstructStruct && size != 1 && size < type.computeNumComponents()) ||
(op == EOpConstructStruct && size < type.computeNumComponents())) { (op == EOpConstructStruct && size < type.computeNumComponents())) {
error(loc, "not enough data provided for construction", constructorString.c_str(), ""); error(loc, "not enough data provided for construction", "constructor", "");
return true; return true;
} }
if (type.isCoopMat() && function.getParamCount() != 1) { if (type.isCoopMat() && function.getParamCount() != 1) {
error(loc, "wrong number of arguments", constructorString.c_str(), ""); error(loc, "wrong number of arguments", "constructor", "");
return true; return true;
} }
if (type.isCoopMat() && if (type.isCoopMat() &&
!(function[0].type->isScalar() || function[0].type->isCoopMat())) { !(function[0].type->isScalar() || function[0].type->isCoopMat())) {
error(loc, "Cooperative matrix constructor argument must be scalar or cooperative matrix", constructorString.c_str(), ""); error(loc, "Cooperative matrix constructor argument must be scalar or cooperative matrix", "constructor", "");
return true; return true;
} }
TIntermTyped* typed = node->getAsTyped(); TIntermTyped* typed = node->getAsTyped();
if (typed == nullptr) { if (typed == nullptr) {
error(loc, "constructor argument does not have a type", constructorString.c_str(), ""); error(loc, "constructor argument does not have a type", "constructor", "");
return true; return true;
} }
if (op != EOpConstructStruct && op != EOpConstructNonuniform && typed->getBasicType() == EbtSampler) { if (op != EOpConstructStruct && op != EOpConstructNonuniform && typed->getBasicType() == EbtSampler) {
error(loc, "cannot convert a sampler", constructorString.c_str(), ""); error(loc, "cannot convert a sampler", "constructor", "");
return true; return true;
} }
if (op != EOpConstructStruct && typed->isAtomic()) { if (op != EOpConstructStruct && typed->isAtomic()) {
error(loc, "cannot convert an atomic_uint", constructorString.c_str(), ""); error(loc, "cannot convert an atomic_uint", "constructor", "");
return true; return true;
} }
if (typed->getBasicType() == EbtVoid) { if (typed->getBasicType() == EbtVoid) {
error(loc, "cannot convert a void", constructorString.c_str(), ""); error(loc, "cannot convert a void", "constructor", "");
return true; return true;
} }
@ -3806,7 +3781,7 @@ void TParseContext::globalQualifierTypeCheck(const TSourceLoc& loc, const TQuali
if (isTypeInt(publicType.basicType) || publicType.basicType == EbtDouble) if (isTypeInt(publicType.basicType) || publicType.basicType == EbtDouble)
profileRequires(loc, EEsProfile, 300, nullptr, "shader input/output"); profileRequires(loc, EEsProfile, 300, nullptr, "shader input/output");
if (!qualifier.flat && !qualifier.isExplicitInterpolation() && !qualifier.isPervertexNV() && !qualifier.isPervertexEXT()) { if (!qualifier.flat && !qualifier.isExplicitInterpolation() && !qualifier.isPervertexNV()) {
if (isTypeInt(publicType.basicType) || if (isTypeInt(publicType.basicType) ||
publicType.basicType == EbtDouble || publicType.basicType == EbtDouble ||
(publicType.userDef && ( publicType.userDef->containsBasicType(EbtInt) (publicType.userDef && ( publicType.userDef->containsBasicType(EbtInt)
@ -4611,7 +4586,7 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
if (ssoPre150 || if (ssoPre150 ||
(identifier == "gl_FragDepth" && ((nonEsRedecls && version >= 420) || esRedecls)) || (identifier == "gl_FragDepth" && ((nonEsRedecls && version >= 420) || esRedecls)) ||
(identifier == "gl_FragCoord" && ((nonEsRedecls && version >= 140) || esRedecls)) || (identifier == "gl_FragCoord" && ((nonEsRedecls && version >= 150) || esRedecls)) ||
identifier == "gl_ClipDistance" || identifier == "gl_ClipDistance" ||
identifier == "gl_CullDistance" || identifier == "gl_CullDistance" ||
identifier == "gl_ShadingRateEXT" || identifier == "gl_ShadingRateEXT" ||
@ -4680,7 +4655,7 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
symbolQualifier.storage != qualifier.storage) symbolQualifier.storage != qualifier.storage)
error(loc, "cannot change qualification of", "redeclaration", symbol->getName().c_str()); error(loc, "cannot change qualification of", "redeclaration", symbol->getName().c_str());
} else if (identifier == "gl_FragCoord") { } else if (identifier == "gl_FragCoord") {
if (!intermediate.getTexCoordRedeclared() && intermediate.inIoAccessed("gl_FragCoord")) if (intermediate.inIoAccessed("gl_FragCoord"))
error(loc, "cannot redeclare after use", "gl_FragCoord", ""); error(loc, "cannot redeclare after use", "gl_FragCoord", "");
if (qualifier.nopersp != symbolQualifier.nopersp || qualifier.flat != symbolQualifier.flat || if (qualifier.nopersp != symbolQualifier.nopersp || qualifier.flat != symbolQualifier.flat ||
qualifier.isMemory() || qualifier.isAuxiliary()) qualifier.isMemory() || qualifier.isAuxiliary())
@ -4690,9 +4665,6 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
if (! builtIn && (publicType.pixelCenterInteger != intermediate.getPixelCenterInteger() || if (! builtIn && (publicType.pixelCenterInteger != intermediate.getPixelCenterInteger() ||
publicType.originUpperLeft != intermediate.getOriginUpperLeft())) publicType.originUpperLeft != intermediate.getOriginUpperLeft()))
error(loc, "cannot redeclare with different qualification:", "redeclaration", symbol->getName().c_str()); error(loc, "cannot redeclare with different qualification:", "redeclaration", symbol->getName().c_str());
intermediate.setTexCoordRedeclared();
if (publicType.pixelCenterInteger) if (publicType.pixelCenterInteger)
intermediate.setPixelCenterInteger(); intermediate.setPixelCenterInteger();
if (publicType.originUpperLeft) if (publicType.originUpperLeft)
@ -5524,19 +5496,12 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
} }
if (language == EShLangFragment) { if (language == EShLangFragment) {
if (id == "origin_upper_left") { if (id == "origin_upper_left") {
requireProfile(loc, ECoreProfile | ECompatibilityProfile | ENoProfile, "origin_upper_left"); requireProfile(loc, ECoreProfile | ECompatibilityProfile, "origin_upper_left");
if (profile == ENoProfile) {
profileRequires(loc,ECoreProfile | ECompatibilityProfile, 140, E_GL_ARB_fragment_coord_conventions, "origin_upper_left");
}
publicType.shaderQualifiers.originUpperLeft = true; publicType.shaderQualifiers.originUpperLeft = true;
return; return;
} }
if (id == "pixel_center_integer") { if (id == "pixel_center_integer") {
requireProfile(loc, ECoreProfile | ECompatibilityProfile | ENoProfile, "pixel_center_integer"); requireProfile(loc, ECoreProfile | ECompatibilityProfile, "pixel_center_integer");
if (profile == ENoProfile) {
profileRequires(loc,ECoreProfile | ECompatibilityProfile, 140, E_GL_ARB_fragment_coord_conventions, "pixel_center_integer");
}
publicType.shaderQualifiers.pixelCenterInteger = true; publicType.shaderQualifiers.pixelCenterInteger = true;
return; return;
} }
@ -6069,8 +6034,6 @@ void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifie
dst.layoutShaderRecord = true; dst.layoutShaderRecord = true;
if (src.pervertexNV) if (src.pervertexNV)
dst.pervertexNV = true; dst.pervertexNV = true;
if (src.pervertexEXT)
dst.pervertexEXT = true;
#endif #endif
} }
} }
@ -6244,13 +6207,11 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
#ifndef GLSLANG_WEB #ifndef GLSLANG_WEB
if (qualifier.hasXfbOffset() && qualifier.hasXfbBuffer()) { if (qualifier.hasXfbOffset() && qualifier.hasXfbBuffer()) {
if (type.isUnsizedArray()) { int repeated = intermediate.addXfbBufferOffset(type);
if (repeated >= 0)
error(loc, "overlapping offsets at", "xfb_offset", "offset %d in buffer %d", repeated, qualifier.layoutXfbBuffer);
if (type.isUnsizedArray())
error(loc, "unsized array", "xfb_offset", "in buffer %d", qualifier.layoutXfbBuffer); error(loc, "unsized array", "xfb_offset", "in buffer %d", qualifier.layoutXfbBuffer);
} else {
int repeated = intermediate.addXfbBufferOffset(type);
if (repeated >= 0)
error(loc, "overlapping offsets at", "xfb_offset", "offset %d in buffer %d", repeated, qualifier.layoutXfbBuffer);
}
// "The offset must be a multiple of the size of the first component of the first // "The offset must be a multiple of the size of the first component of the first
// qualified variable or block member, or a compile-time error results. Further, if applied to an aggregate // qualified variable or block member, or a compile-time error results. Further, if applied to an aggregate
@ -6370,12 +6331,8 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 0, E_GL_EXT_shader_image_load_formatted, explanation); profileRequires(loc, ECoreProfile | ECompatibilityProfile, 0, E_GL_EXT_shader_image_load_formatted, explanation);
} }
if (qualifier.isPushConstant()) { if (qualifier.isPushConstant() && type.getBasicType() != EbtBlock)
if (type.getBasicType() != EbtBlock) error(loc, "can only be used with a block", "push_constant", "");
error(loc, "can only be used with a block", "push_constant", "");
if (type.isArray())
error(loc, "Push constants blocks can't be an array", "push_constant", "");
}
if (qualifier.hasBufferReference() && type.getBasicType() != EbtBlock) if (qualifier.hasBufferReference() && type.getBasicType() != EbtBlock)
error(loc, "can only be used with a block", "buffer_reference", ""); error(loc, "can only be used with a block", "buffer_reference", "");
@ -6536,8 +6493,6 @@ void TParseContext::layoutQualifierCheck(const TSourceLoc& loc, const TQualifier
error(loc, "can only be used with a uniform", "push_constant", ""); error(loc, "can only be used with a uniform", "push_constant", "");
if (qualifier.hasSet()) if (qualifier.hasSet())
error(loc, "cannot be used with push_constant", "set", ""); error(loc, "cannot be used with push_constant", "set", "");
if (qualifier.hasBinding())
error(loc, "cannot be used with push_constant", "binding", "");
} }
if (qualifier.hasBufferReference()) { if (qualifier.hasBufferReference()) {
if (qualifier.storage != EvqBuffer) if (qualifier.storage != EvqBuffer)
@ -6692,10 +6647,8 @@ const TFunction* TParseContext::findFunction(const TSourceLoc& loc, const TFunct
: findFunctionExact(loc, call, builtIn)); : findFunctionExact(loc, call, builtIn));
else if (version < 120) else if (version < 120)
function = findFunctionExact(loc, call, builtIn); function = findFunctionExact(loc, call, builtIn);
else if (version < 400) { else if (version < 400)
bool needfindFunction400 = extensionTurnedOn(E_GL_ARB_gpu_shader_fp64) || extensionTurnedOn(E_GL_ARB_gpu_shader5); function = extensionTurnedOn(E_GL_ARB_gpu_shader_fp64) ? findFunction400(loc, call, builtIn) : findFunction120(loc, call, builtIn);
function = needfindFunction400 ? findFunction400(loc, call, builtIn) : findFunction120(loc, call, builtIn);
}
else if (explicitTypesEnabled) else if (explicitTypesEnabled)
function = findFunctionExplicitTypes(loc, call, builtIn); function = findFunctionExplicitTypes(loc, call, builtIn);
else else
@ -7466,14 +7419,14 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
// Uniforms require a compile-time constant initializer // Uniforms require a compile-time constant initializer
if (qualifier == EvqUniform && ! initializer->getType().getQualifier().isFrontEndConstant()) { if (qualifier == EvqUniform && ! initializer->getType().getQualifier().isFrontEndConstant()) {
error(loc, "uniform initializers must be constant", "=", "'%s'", error(loc, "uniform initializers must be constant", "=", "'%s'",
variable->getType().getCompleteString(intermediate.getEnhancedMsgs()).c_str()); variable->getType().getCompleteString().c_str());
variable->getWritableType().getQualifier().makeTemporary(); variable->getWritableType().getQualifier().makeTemporary();
return nullptr; return nullptr;
} }
// Global consts require a constant initializer (specialization constant is okay) // Global consts require a constant initializer (specialization constant is okay)
if (qualifier == EvqConst && symbolTable.atGlobalLevel() && ! initializer->getType().getQualifier().isConstant()) { if (qualifier == EvqConst && symbolTable.atGlobalLevel() && ! initializer->getType().getQualifier().isConstant()) {
error(loc, "global const initializers must be constant", "=", "'%s'", error(loc, "global const initializers must be constant", "=", "'%s'",
variable->getType().getCompleteString(intermediate.getEnhancedMsgs()).c_str()); variable->getType().getCompleteString().c_str());
variable->getWritableType().getQualifier().makeTemporary(); variable->getWritableType().getQualifier().makeTemporary();
return nullptr; return nullptr;
} }
@ -7536,7 +7489,7 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
TIntermSymbol* intermSymbol = intermediate.addSymbol(*variable, loc); TIntermSymbol* intermSymbol = intermediate.addSymbol(*variable, loc);
TIntermTyped* initNode = intermediate.addAssign(EOpAssign, intermSymbol, initializer, loc); TIntermTyped* initNode = intermediate.addAssign(EOpAssign, intermSymbol, initializer, loc);
if (! initNode) if (! initNode)
assignError(loc, "=", intermSymbol->getCompleteString(intermediate.getEnhancedMsgs()), initializer->getCompleteString(intermediate.getEnhancedMsgs())); assignError(loc, "=", intermSymbol->getCompleteString(), initializer->getCompleteString());
return initNode; return initNode;
} }
@ -7607,7 +7560,7 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
} }
} else if (type.isMatrix()) { } else if (type.isMatrix()) {
if (type.getMatrixCols() != (int)initList->getSequence().size()) { if (type.getMatrixCols() != (int)initList->getSequence().size()) {
error(loc, "wrong number of matrix columns:", "initializer list", type.getCompleteString(intermediate.getEnhancedMsgs()).c_str()); error(loc, "wrong number of matrix columns:", "initializer list", type.getCompleteString().c_str());
return nullptr; return nullptr;
} }
TType vectorType(type, 0); // dereferenced type TType vectorType(type, 0); // dereferenced type
@ -7618,20 +7571,20 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
} }
} else if (type.isVector()) { } else if (type.isVector()) {
if (type.getVectorSize() != (int)initList->getSequence().size()) { if (type.getVectorSize() != (int)initList->getSequence().size()) {
error(loc, "wrong vector size (or rows in a matrix column):", "initializer list", type.getCompleteString(intermediate.getEnhancedMsgs()).c_str()); error(loc, "wrong vector size (or rows in a matrix column):", "initializer list", type.getCompleteString().c_str());
return nullptr; return nullptr;
} }
TBasicType destType = type.getBasicType(); TBasicType destType = type.getBasicType();
for (int i = 0; i < type.getVectorSize(); ++i) { for (int i = 0; i < type.getVectorSize(); ++i) {
TBasicType initType = initList->getSequence()[i]->getAsTyped()->getBasicType(); TBasicType initType = initList->getSequence()[i]->getAsTyped()->getBasicType();
if (destType != initType && !intermediate.canImplicitlyPromote(initType, destType)) { if (destType != initType && !intermediate.canImplicitlyPromote(initType, destType)) {
error(loc, "type mismatch in initializer list", "initializer list", type.getCompleteString(intermediate.getEnhancedMsgs()).c_str()); error(loc, "type mismatch in initializer list", "initializer list", type.getCompleteString().c_str());
return nullptr; return nullptr;
} }
} }
} else { } else {
error(loc, "unexpected initializer-list type:", "initializer list", type.getCompleteString(intermediate.getEnhancedMsgs()).c_str()); error(loc, "unexpected initializer-list type:", "initializer list", type.getCompleteString().c_str());
return nullptr; return nullptr;
} }
@ -7738,13 +7691,7 @@ TIntermTyped* TParseContext::addConstructor(const TSourceLoc& loc, TIntermNode*
return nullptr; return nullptr;
} }
TIntermTyped *ret_node = intermediate.setAggregateOperator(aggrNode, op, type, loc); return intermediate.setAggregateOperator(aggrNode, op, type, loc);
TIntermAggregate *agg_node = ret_node->getAsAggregate();
if (agg_node && (agg_node->isVector() || agg_node->isArray() || agg_node->isMatrix()))
agg_node->updatePrecision();
return ret_node;
} }
// Function for constructor implementation. Calls addUnaryMath with appropriate EOp value // Function for constructor implementation. Calls addUnaryMath with appropriate EOp value
@ -8139,9 +8086,8 @@ TIntermTyped* TParseContext::constructAggregate(TIntermNode* node, const TType&
{ {
TIntermTyped* converted = intermediate.addConversion(EOpConstructStruct, type, node->getAsTyped()); TIntermTyped* converted = intermediate.addConversion(EOpConstructStruct, type, node->getAsTyped());
if (! converted || converted->getType() != type) { if (! converted || converted->getType() != type) {
bool enhanced = intermediate.getEnhancedMsgs();
error(loc, "", "constructor", "cannot convert parameter %d from '%s' to '%s'", paramCount, error(loc, "", "constructor", "cannot convert parameter %d from '%s' to '%s'", paramCount,
node->getAsTyped()->getType().getCompleteString(enhanced).c_str(), type.getCompleteString(enhanced).c_str()); node->getAsTyped()->getType().getCompleteString().c_str(), type.getCompleteString().c_str());
return nullptr; return nullptr;
} }
@ -9291,14 +9237,11 @@ TIntermNode* TParseContext::addSwitch(const TSourceLoc& loc, TIntermTyped* expre
// "it is an error to have no statement between a label and the end of the switch statement." // "it is an error to have no statement between a label and the end of the switch statement."
// The specifications were updated to remove this (being ill-defined what a "statement" was), // The specifications were updated to remove this (being ill-defined what a "statement" was),
// so, this became a warning. However, 3.0 tests still check for the error. // so, this became a warning. However, 3.0 tests still check for the error.
if (isEsProfile() && (version <= 300 || version >= 320) && ! relaxedErrors()) if (isEsProfile() && version <= 300 && ! relaxedErrors())
error(loc, "last case/default label not followed by statements", "switch", "");
else if (!isEsProfile() && (version <= 430 || version >= 460))
error(loc, "last case/default label not followed by statements", "switch", ""); error(loc, "last case/default label not followed by statements", "switch", "");
else else
warn(loc, "last case/default label not followed by statements", "switch", ""); warn(loc, "last case/default label not followed by statements", "switch", "");
// emulate a break for error recovery // emulate a break for error recovery
lastStatements = intermediate.makeAggregate(intermediate.addBranch(EOpBreak, loc)); lastStatements = intermediate.makeAggregate(intermediate.addBranch(EOpBreak, loc));
lastStatements->setOperator(EOpSequence); lastStatements->setOperator(EOpSequence);

View file

@ -241,7 +241,7 @@ protected:
// override this to set the language-specific name // override this to set the language-specific name
virtual const char* getAtomicCounterBlockName() const { return ""; } virtual const char* getAtomicCounterBlockName() const { return ""; }
virtual void setAtomicCounterBlockDefaults(TType&) const {} virtual void setAtomicCounterBlockDefaults(TType&) const {}
virtual void setInvariant(const TSourceLoc&, const char*) {} virtual void setInvariant(const TSourceLoc& loc, const char* builtin) {}
virtual void finalizeAtomicCounterBlockLayout(TVariable&) {} virtual void finalizeAtomicCounterBlockLayout(TVariable&) {}
bool isAtomicCounterBlock(const TSymbol& symbol) { bool isAtomicCounterBlock(const TSymbol& symbol) {
const TVariable* var = symbol.getAsVariable(); const TVariable* var = symbol.getAsVariable();
@ -472,7 +472,7 @@ public:
// Determine loop control from attributes // Determine loop control from attributes
void handleLoopAttributes(const TAttributes& attributes, TIntermNode*); void handleLoopAttributes(const TAttributes& attributes, TIntermNode*);
// Function attributes // Function attributes
void handleFunctionAttributes(const TSourceLoc&, const TAttributes&); void handleFunctionAttributes(const TSourceLoc&, const TAttributes&, TFunction*);
// GL_EXT_spirv_intrinsics // GL_EXT_spirv_intrinsics
TSpirvRequirement* makeSpirvRequirement(const TSourceLoc& loc, const TString& name, TSpirvRequirement* makeSpirvRequirement(const TSourceLoc& loc, const TString& name,
@ -480,6 +480,7 @@ public:
TSpirvRequirement* mergeSpirvRequirements(const TSourceLoc& loc, TSpirvRequirement* spirvReq1, TSpirvRequirement* mergeSpirvRequirements(const TSourceLoc& loc, TSpirvRequirement* spirvReq1,
TSpirvRequirement* spirvReq2); TSpirvRequirement* spirvReq2);
TSpirvTypeParameters* makeSpirvTypeParameters(const TSourceLoc& loc, const TIntermConstantUnion* constant); TSpirvTypeParameters* makeSpirvTypeParameters(const TSourceLoc& loc, const TIntermConstantUnion* constant);
TSpirvTypeParameters* makeSpirvTypeParameters(const TPublicType& type);
TSpirvTypeParameters* mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1, TSpirvTypeParameters* mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1,
TSpirvTypeParameters* spirvTypeParams2); TSpirvTypeParameters* spirvTypeParams2);
TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, const TString& value); TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, const TString& value);

View file

@ -739,7 +739,6 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["f16subpassInputMS"] = F16SUBPASSINPUTMS; (*KeywordMap)["f16subpassInputMS"] = F16SUBPASSINPUTMS;
(*KeywordMap)["__explicitInterpAMD"] = EXPLICITINTERPAMD; (*KeywordMap)["__explicitInterpAMD"] = EXPLICITINTERPAMD;
(*KeywordMap)["pervertexNV"] = PERVERTEXNV; (*KeywordMap)["pervertexNV"] = PERVERTEXNV;
(*KeywordMap)["pervertexEXT"] = PERVERTEXEXT;
(*KeywordMap)["precise"] = PRECISE; (*KeywordMap)["precise"] = PRECISE;
(*KeywordMap)["rayPayloadNV"] = PAYLOADNV; (*KeywordMap)["rayPayloadNV"] = PAYLOADNV;
@ -1720,12 +1719,6 @@ int TScanContext::tokenizeIdentifier()
return keyword; return keyword;
return identifierOrType(); return identifierOrType();
case PERVERTEXEXT:
if ((!parseContext.isEsProfile() && parseContext.version >= 450) ||
parseContext.extensionTurnedOn(E_GL_EXT_fragment_shader_barycentric))
return keyword;
return identifierOrType();
case PRECISE: case PRECISE:
if ((parseContext.isEsProfile() && if ((parseContext.isEsProfile() &&
(parseContext.version >= 320 || parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5))) || (parseContext.version >= 320 || parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5))) ||

View file

@ -813,7 +813,6 @@ bool ProcessDeferred(
// set version/profile to defaultVersion/defaultProfile regardless of the #version // set version/profile to defaultVersion/defaultProfile regardless of the #version
// directive in the source code // directive in the source code
bool forceDefaultVersionAndProfile, bool forceDefaultVersionAndProfile,
int overrideVersion, // overrides version specified by #verison or default version
bool forwardCompatible, // give errors for use of deprecated features bool forwardCompatible, // give errors for use of deprecated features
EShMessages messages, // warnings/errors/AST; things to print out EShMessages messages, // warnings/errors/AST; things to print out
TIntermediate& intermediate, // returned tree, etc. TIntermediate& intermediate, // returned tree, etc.
@ -901,9 +900,6 @@ bool ProcessDeferred(
version = defaultVersion; version = defaultVersion;
profile = defaultProfile; profile = defaultProfile;
} }
if (source == EShSourceGlsl && overrideVersion != 0) {
version = overrideVersion;
}
bool goodVersion = DeduceVersionProfile(compiler->infoSink, stage, bool goodVersion = DeduceVersionProfile(compiler->infoSink, stage,
versionNotFirst, defaultVersion, source, version, profile, spvVersion); versionNotFirst, defaultVersion, source, version, profile, spvVersion);
@ -1279,7 +1275,6 @@ bool PreprocessDeferred(
int defaultVersion, // use 100 for ES environment, 110 for desktop int defaultVersion, // use 100 for ES environment, 110 for desktop
EProfile defaultProfile, EProfile defaultProfile,
bool forceDefaultVersionAndProfile, bool forceDefaultVersionAndProfile,
int overrideVersion, // use 0 if not overriding GLSL version
bool forwardCompatible, // give errors for use of deprecated features bool forwardCompatible, // give errors for use of deprecated features
EShMessages messages, // warnings/errors/AST; things to print out EShMessages messages, // warnings/errors/AST; things to print out
TShader::Includer& includer, TShader::Includer& includer,
@ -1290,7 +1285,7 @@ bool PreprocessDeferred(
DoPreprocessing parser(outputString); DoPreprocessing parser(outputString);
return ProcessDeferred(compiler, shaderStrings, numStrings, inputLengths, stringNames, return ProcessDeferred(compiler, shaderStrings, numStrings, inputLengths, stringNames,
preamble, optLevel, resources, defaultVersion, preamble, optLevel, resources, defaultVersion,
defaultProfile, forceDefaultVersionAndProfile, overrideVersion, defaultProfile, forceDefaultVersionAndProfile,
forwardCompatible, messages, intermediate, parser, forwardCompatible, messages, intermediate, parser,
false, includer, "", environment); false, includer, "", environment);
} }
@ -1319,7 +1314,6 @@ bool CompileDeferred(
int defaultVersion, // use 100 for ES environment, 110 for desktop int defaultVersion, // use 100 for ES environment, 110 for desktop
EProfile defaultProfile, EProfile defaultProfile,
bool forceDefaultVersionAndProfile, bool forceDefaultVersionAndProfile,
int overrideVersion, // use 0 if not overriding GLSL version
bool forwardCompatible, // give errors for use of deprecated features bool forwardCompatible, // give errors for use of deprecated features
EShMessages messages, // warnings/errors/AST; things to print out EShMessages messages, // warnings/errors/AST; things to print out
TIntermediate& intermediate,// returned tree, etc. TIntermediate& intermediate,// returned tree, etc.
@ -1330,7 +1324,7 @@ bool CompileDeferred(
DoFullParse parser; DoFullParse parser;
return ProcessDeferred(compiler, shaderStrings, numStrings, inputLengths, stringNames, return ProcessDeferred(compiler, shaderStrings, numStrings, inputLengths, stringNames,
preamble, optLevel, resources, defaultVersion, preamble, optLevel, resources, defaultVersion,
defaultProfile, forceDefaultVersionAndProfile, overrideVersion, defaultProfile, forceDefaultVersionAndProfile,
forwardCompatible, messages, intermediate, parser, forwardCompatible, messages, intermediate, parser,
true, includer, sourceEntryPointName, environment); true, includer, sourceEntryPointName, environment);
} }
@ -1349,6 +1343,7 @@ int ShInitialize()
glslang::GetGlobalLock(); glslang::GetGlobalLock();
++NumberOfClients; ++NumberOfClients;
glslang::ReleaseGlobalLock();
if (PerProcessGPA == nullptr) if (PerProcessGPA == nullptr)
PerProcessGPA = new TPoolAllocator(); PerProcessGPA = new TPoolAllocator();
@ -1358,7 +1353,6 @@ int ShInitialize()
glslang::HlslScanContext::fillInKeywordMap(); glslang::HlslScanContext::fillInKeywordMap();
#endif #endif
glslang::ReleaseGlobalLock();
return 1; return 1;
} }
@ -1421,10 +1415,9 @@ int ShFinalize()
--NumberOfClients; --NumberOfClients;
assert(NumberOfClients >= 0); assert(NumberOfClients >= 0);
bool finalize = NumberOfClients == 0; bool finalize = NumberOfClients == 0;
if (! finalize) { glslang::ReleaseGlobalLock();
glslang::ReleaseGlobalLock(); if (! finalize)
return 1; return 1;
}
for (int version = 0; version < VersionCount; ++version) { for (int version = 0; version < VersionCount; ++version) {
for (int spvVersion = 0; spvVersion < SpvVersionCount; ++spvVersion) { for (int spvVersion = 0; spvVersion < SpvVersionCount; ++spvVersion) {
@ -1462,7 +1455,6 @@ int ShFinalize()
glslang::HlslScanContext::deleteKeywordMap(); glslang::HlslScanContext::deleteKeywordMap();
#endif #endif
glslang::ReleaseGlobalLock();
return 1; return 1;
} }
@ -1504,7 +1496,7 @@ int ShCompile(
TIntermediate intermediate(compiler->getLanguage()); TIntermediate intermediate(compiler->getLanguage());
TShader::ForbidIncluder includer; TShader::ForbidIncluder includer;
bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, nullptr, bool success = CompileDeferred(compiler, shaderStrings, numStrings, inputLengths, nullptr,
"", optLevel, resources, defaultVersion, ENoProfile, false, 0, "", optLevel, resources, defaultVersion, ENoProfile, false,
forwardCompatible, messages, intermediate, includer); forwardCompatible, messages, intermediate, includer);
// //
@ -1765,7 +1757,7 @@ public:
}; };
TShader::TShader(EShLanguage s) TShader::TShader(EShLanguage s)
: stage(s), lengths(nullptr), stringNames(nullptr), preamble(""), overrideVersion(0) : stage(s), lengths(nullptr), stringNames(nullptr), preamble("")
{ {
pool = new TPoolAllocator; pool = new TPoolAllocator;
infoSink = new TInfoSink; infoSink = new TInfoSink;
@ -1834,14 +1826,7 @@ void TShader::setUniqueId(unsigned long long id)
intermediate->setUniqueId(id); intermediate->setUniqueId(id);
} }
void TShader::setOverrideVersion(int version)
{
overrideVersion = version;
}
void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); } void TShader::setInvertY(bool invert) { intermediate->setInvertY(invert); }
void TShader::setDxPositionW(bool invert) { intermediate->setDxPositionW(invert); }
void TShader::setEnhancedMsgs() { intermediate->setEnhancedMsgs(); }
void TShader::setNanMinMaxClamp(bool useNonNan) { intermediate->setNanMinMaxClamp(useNonNan); } void TShader::setNanMinMaxClamp(bool useNonNan) { intermediate->setNanMinMaxClamp(useNonNan); }
#ifndef GLSLANG_WEB #ifndef GLSLANG_WEB
@ -1921,7 +1906,7 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
return CompileDeferred(compiler, strings, numStrings, lengths, stringNames, return CompileDeferred(compiler, strings, numStrings, lengths, stringNames,
preamble, EShOptNone, builtInResources, defaultVersion, preamble, EShOptNone, builtInResources, defaultVersion,
defaultProfile, forceDefaultVersionAndProfile, overrideVersion, defaultProfile, forceDefaultVersionAndProfile,
forwardCompatible, messages, *intermediate, includer, sourceEntryPointName, forwardCompatible, messages, *intermediate, includer, sourceEntryPointName,
&environment); &environment);
} }
@ -1948,7 +1933,7 @@ bool TShader::preprocess(const TBuiltInResource* builtInResources,
return PreprocessDeferred(compiler, strings, numStrings, lengths, stringNames, preamble, return PreprocessDeferred(compiler, strings, numStrings, lengths, stringNames, preamble,
EShOptNone, builtInResources, defaultVersion, EShOptNone, builtInResources, defaultVersion,
defaultProfile, forceDefaultVersionAndProfile, overrideVersion, defaultProfile, forceDefaultVersionAndProfile,
forwardCompatible, message, includer, *intermediate, output_string, forwardCompatible, message, includer, *intermediate, output_string,
&environment); &environment);
} }
@ -2061,8 +2046,6 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
firstIntermediate->getVersion(), firstIntermediate->getVersion(),
firstIntermediate->getProfile()); firstIntermediate->getProfile());
intermediate[stage]->setLimits(firstIntermediate->getLimits()); intermediate[stage]->setLimits(firstIntermediate->getLimits());
if (firstIntermediate->getEnhancedMsgs())
intermediate[stage]->setEnhancedMsgs();
// The new TIntermediate must use the same origin as the original TIntermediates. // The new TIntermediate must use the same origin as the original TIntermediates.
// Otherwise linking will fail due to different coordinate systems. // Otherwise linking will fail due to different coordinate systems.

View file

@ -130,11 +130,11 @@ void TIntermediate::insertSpirvExecutionModeId(int executionMode, const TIntermA
spirvExecutionMode = new TSpirvExecutionMode; spirvExecutionMode = new TSpirvExecutionMode;
assert(args); assert(args);
TVector<const TIntermTyped*> extraOperands; TVector<const TIntermConstantUnion*> extraOperands;
for (auto arg : args->getSequence()) { for (auto arg : args->getSequence()) {
auto extraOperand = arg->getAsTyped(); auto extraOperand = arg->getAsConstantUnion();
assert(extraOperand != nullptr && extraOperand->getQualifier().isConstant()); assert(extraOperand != nullptr);
extraOperands.push_back(extraOperand); extraOperands.push_back(extraOperand);
} }
spirvExecutionMode->modeIds[executionMode] = extraOperands; spirvExecutionMode->modeIds[executionMode] = extraOperands;
@ -165,10 +165,10 @@ void TQualifier::setSpirvDecorateId(int decoration, const TIntermAggregate* args
spirvDecorate = new TSpirvDecorate; spirvDecorate = new TSpirvDecorate;
assert(args); assert(args);
TVector<const TIntermTyped*> extraOperands; TVector<const TIntermConstantUnion*> extraOperands;
for (auto arg : args->getSequence()) { for (auto arg : args->getSequence()) {
auto extraOperand = arg->getAsTyped(); auto extraOperand = arg->getAsConstantUnion();
assert(extraOperand != nullptr && extraOperand->getQualifier().isConstant()); assert(extraOperand != nullptr);
extraOperands.push_back(extraOperand); extraOperands.push_back(extraOperand);
} }
spirvDecorate->decorateIds[decoration] = extraOperands; spirvDecorate->decorateIds[decoration] = extraOperands;
@ -201,27 +201,25 @@ TString TQualifier::getSpirvDecorateQualifierString() const
const auto appendBool = [&](bool b) { qualifierString.append(std::to_string(b).c_str()); }; const auto appendBool = [&](bool b) { qualifierString.append(std::to_string(b).c_str()); };
const auto appendStr = [&](const char* s) { qualifierString.append(s); }; const auto appendStr = [&](const char* s) { qualifierString.append(s); };
const auto appendDecorate = [&](const TIntermTyped* constant) { const auto appendDecorate = [&](const TIntermConstantUnion* constant) {
auto& constArray = constant->getAsConstantUnion() != nullptr ? constant->getAsConstantUnion()->getConstArray()
: constant->getAsSymbolNode()->getConstArray();
if (constant->getBasicType() == EbtFloat) { if (constant->getBasicType() == EbtFloat) {
float value = static_cast<float>(constArray[0].getDConst()); float value = static_cast<float>(constant->getConstArray()[0].getDConst());
appendFloat(value); appendFloat(value);
} }
else if (constant->getBasicType() == EbtInt) { else if (constant->getBasicType() == EbtInt) {
int value = constArray[0].getIConst(); int value = constant->getConstArray()[0].getIConst();
appendInt(value); appendInt(value);
} }
else if (constant->getBasicType() == EbtUint) { else if (constant->getBasicType() == EbtUint) {
unsigned value = constArray[0].getUConst(); unsigned value = constant->getConstArray()[0].getUConst();
appendUint(value); appendUint(value);
} }
else if (constant->getBasicType() == EbtBool) { else if (constant->getBasicType() == EbtBool) {
bool value = constArray[0].getBConst(); bool value = constant->getConstArray()[0].getBConst();
appendBool(value); appendBool(value);
} }
else if (constant->getBasicType() == EbtString) { else if (constant->getBasicType() == EbtString) {
const TString* value = constArray[0].getSConst(); const TString* value = constant->getConstArray()[0].getSConst();
appendStr(value->c_str()); appendStr(value->c_str());
} }
else else
@ -292,6 +290,13 @@ TSpirvTypeParameters* TParseContext::makeSpirvTypeParameters(const TSourceLoc& l
return spirvTypeParams; return spirvTypeParams;
} }
TSpirvTypeParameters* TParseContext::makeSpirvTypeParameters(const TPublicType& type)
{
TSpirvTypeParameters* spirvTypeParams = new TSpirvTypeParameters;
spirvTypeParams->push_back(TSpirvTypeParameter(new TType(type)));
return spirvTypeParams;
}
TSpirvTypeParameters* TParseContext::mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1, TSpirvTypeParameters* spirvTypeParams2) TSpirvTypeParameters* TParseContext::mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1, TSpirvTypeParameters* spirvTypeParams2)
{ {
// Merge SPIR-V type parameters of the second one to the first one // Merge SPIR-V type parameters of the second one to the first one

View file

@ -279,14 +279,8 @@ TFunction::~TFunction()
// //
TSymbolTableLevel::~TSymbolTableLevel() TSymbolTableLevel::~TSymbolTableLevel()
{ {
for (tLevel::iterator it = level.begin(); it != level.end(); ++it) { for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
const TString& name = it->first; delete (*it).second;
auto retargetIter = std::find_if(retargetedSymbols.begin(), retargetedSymbols.end(),
[&name](const std::pair<TString, TString>& i) { return i.first == name; });
if (retargetIter == retargetedSymbols.end())
delete (*it).second;
}
delete [] defaultPrecision; delete [] defaultPrecision;
} }
@ -424,10 +418,6 @@ TSymbolTableLevel* TSymbolTableLevel::clone() const
TSymbolTableLevel *symTableLevel = new TSymbolTableLevel(); TSymbolTableLevel *symTableLevel = new TSymbolTableLevel();
symTableLevel->anonId = anonId; symTableLevel->anonId = anonId;
symTableLevel->thisLevel = thisLevel; symTableLevel->thisLevel = thisLevel;
symTableLevel->retargetedSymbols.clear();
for (auto &s : retargetedSymbols) {
symTableLevel->retargetedSymbols.push_back({s.first, s.second});
}
std::vector<bool> containerCopied(anonId, false); std::vector<bool> containerCopied(anonId, false);
tLevel::const_iterator iter; tLevel::const_iterator iter;
for (iter = level.begin(); iter != level.end(); ++iter) { for (iter = level.begin(); iter != level.end(); ++iter) {
@ -443,21 +433,8 @@ TSymbolTableLevel* TSymbolTableLevel::clone() const
symTableLevel->insert(*container, false); symTableLevel->insert(*container, false);
containerCopied[anon->getAnonId()] = true; containerCopied[anon->getAnonId()] = true;
} }
} else { } else
const TString& name = iter->first;
auto retargetIter = std::find_if(retargetedSymbols.begin(), retargetedSymbols.end(),
[&name](const std::pair<TString, TString>& i) { return i.first == name; });
if (retargetIter != retargetedSymbols.end())
continue;
symTableLevel->insert(*iter->second->clone(), false); symTableLevel->insert(*iter->second->clone(), false);
}
}
// Now point retargeted symbols to the newly created versions of them
for (auto &s : retargetedSymbols) {
TSymbol* sym = symTableLevel->find(s.second);
if (!sym)
continue;
symTableLevel->insert(s.first, sym);
} }
return symTableLevel; return symTableLevel;

View file

@ -84,7 +84,7 @@ typedef TVector<const char*> TExtensionList;
class TSymbol { class TSymbol {
public: public:
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
explicit TSymbol(const TString *n) : name(n), uniqueId(0), extensions(0), writable(true) { } explicit TSymbol(const TString *n) : name(n), extensions(0), writable(true) { }
virtual TSymbol* clone() const = 0; virtual TSymbol* clone() const = 0;
virtual ~TSymbol() { } // rely on all symbol owned memory coming from the pool virtual ~TSymbol() { } // rely on all symbol owned memory coming from the pool
@ -413,20 +413,13 @@ public:
TSymbolTableLevel() : defaultPrecision(0), anonId(0), thisLevel(false) { } TSymbolTableLevel() : defaultPrecision(0), anonId(0), thisLevel(false) { }
~TSymbolTableLevel(); ~TSymbolTableLevel();
bool insert(const TString& name, TSymbol* symbol) { bool insert(TSymbol& symbol, bool separateNameSpaces)
return level.insert(tLevelPair(name, symbol)).second;
}
bool insert(TSymbol& symbol, bool separateNameSpaces, const TString& forcedKeyName = TString())
{ {
// //
// returning true means symbol was added to the table with no semantic errors // returning true means symbol was added to the table with no semantic errors
// //
const TString& name = symbol.getName(); const TString& name = symbol.getName();
if (forcedKeyName.length()) { if (name == "") {
return level.insert(tLevelPair(forcedKeyName, &symbol)).second;
}
else if (name == "") {
symbol.getAsVariable()->setAnonId(anonId++); symbol.getAsVariable()->setAnonId(anonId++);
// An empty name means an anonymous container, exposing its members to the external scope. // An empty name means an anonymous container, exposing its members to the external scope.
// Give it a name and insert its members in the symbol table, pointing to the container. // Give it a name and insert its members in the symbol table, pointing to the container.
@ -478,16 +471,6 @@ public:
return true; return true;
} }
void retargetSymbol(const TString& from, const TString& to) {
tLevel::const_iterator fromIt = level.find(from);
tLevel::const_iterator toIt = level.find(to);
if (fromIt == level.end() || toIt == level.end())
return;
delete fromIt->second;
level[from] = toIt->second;
retargetedSymbols.push_back({from, to});
}
TSymbol* find(const TString& name) const TSymbol* find(const TString& name) const
{ {
tLevel::const_iterator it = level.find(name); tLevel::const_iterator it = level.find(name);
@ -600,8 +583,6 @@ protected:
tLevel level; // named mappings tLevel level; // named mappings
TPrecisionQualifier *defaultPrecision; TPrecisionQualifier *defaultPrecision;
// pair<FromName, ToName>
TVector<std::pair<TString, TString>> retargetedSymbols;
int anonId; int anonId;
bool thisLevel; // True if this level of the symbol table is a structure scope containing member function bool thisLevel; // True if this level of the symbol table is a structure scope containing member function
// that are supposed to see anonymous access to member variables. // that are supposed to see anonymous access to member variables.
@ -807,12 +788,6 @@ public:
return symbol; return symbol;
} }
void retargetSymbol(const TString& from, const TString& to) {
int level = currentLevel();
table[level]->retargetSymbol(from, to);
}
// Find of a symbol that returns how many layers deep of nested // Find of a symbol that returns how many layers deep of nested
// structures-with-member-functions ('this' scopes) deep the symbol was // structures-with-member-functions ('this' scopes) deep the symbol was
// found in. // found in.

View file

@ -225,9 +225,6 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_ARB_shading_language_packing] = EBhDisable; extensionBehavior[E_GL_ARB_shading_language_packing] = EBhDisable;
extensionBehavior[E_GL_ARB_texture_query_lod] = EBhDisable; extensionBehavior[E_GL_ARB_texture_query_lod] = EBhDisable;
extensionBehavior[E_GL_ARB_vertex_attrib_64bit] = EBhDisable; extensionBehavior[E_GL_ARB_vertex_attrib_64bit] = EBhDisable;
extensionBehavior[E_GL_ARB_draw_instanced] = EBhDisable;
extensionBehavior[E_GL_ARB_fragment_coord_conventions] = EBhDisable;
extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable; extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable;
extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable; extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable;
@ -259,8 +256,6 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_shader_8bit_storage] = EBhDisable; extensionBehavior[E_GL_EXT_shader_8bit_storage] = EBhDisable;
extensionBehavior[E_GL_EXT_subgroup_uniform_control_flow] = EBhDisable; extensionBehavior[E_GL_EXT_subgroup_uniform_control_flow] = EBhDisable;
extensionBehavior[E_GL_EXT_fragment_shader_barycentric] = EBhDisable;
// #line and #include // #line and #include
extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable; extensionBehavior[E_GL_GOOGLE_cpp_style_line_directive] = EBhDisable;
extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable; extensionBehavior[E_GL_GOOGLE_include_directive] = EBhDisable;
@ -336,7 +331,6 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_ray_tracing] = EBhDisable; extensionBehavior[E_GL_EXT_ray_tracing] = EBhDisable;
extensionBehavior[E_GL_EXT_ray_query] = EBhDisable; extensionBehavior[E_GL_EXT_ray_query] = EBhDisable;
extensionBehavior[E_GL_EXT_ray_flags_primitive_culling] = EBhDisable; extensionBehavior[E_GL_EXT_ray_flags_primitive_culling] = EBhDisable;
extensionBehavior[E_GL_EXT_ray_cull_mask] = EBhDisable;
extensionBehavior[E_GL_EXT_blend_func_extended] = EBhDisable; extensionBehavior[E_GL_EXT_blend_func_extended] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_implicit_conversions] = EBhDisable; extensionBehavior[E_GL_EXT_shader_implicit_conversions] = EBhDisable;
extensionBehavior[E_GL_EXT_fragment_shading_rate] = EBhDisable; extensionBehavior[E_GL_EXT_fragment_shading_rate] = EBhDisable;
@ -471,8 +465,6 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_ARB_shader_storage_buffer_object 1\n" "#define GL_ARB_shader_storage_buffer_object 1\n"
"#define GL_ARB_texture_query_lod 1\n" "#define GL_ARB_texture_query_lod 1\n"
"#define GL_ARB_vertex_attrib_64bit 1\n" "#define GL_ARB_vertex_attrib_64bit 1\n"
"#define GL_ARB_draw_instanced 1\n"
"#define GL_ARB_fragment_coord_conventions 1\n"
"#define GL_EXT_shader_non_constant_global_initializers 1\n" "#define GL_EXT_shader_non_constant_global_initializers 1\n"
"#define GL_EXT_shader_image_load_formatted 1\n" "#define GL_EXT_shader_image_load_formatted 1\n"
"#define GL_EXT_post_depth_coverage 1\n" "#define GL_EXT_post_depth_coverage 1\n"
@ -490,7 +482,6 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_debug_printf 1\n" "#define GL_EXT_debug_printf 1\n"
"#define GL_EXT_fragment_shading_rate 1\n" "#define GL_EXT_fragment_shading_rate 1\n"
"#define GL_EXT_shared_memory_block 1\n" "#define GL_EXT_shared_memory_block 1\n"
"#define GL_EXT_shader_integer_mix 1\n"
// GL_KHR_shader_subgroup // GL_KHR_shader_subgroup
"#define GL_KHR_shader_subgroup_basic 1\n" "#define GL_KHR_shader_subgroup_basic 1\n"
@ -508,7 +499,6 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_ray_tracing 1\n" "#define GL_EXT_ray_tracing 1\n"
"#define GL_EXT_ray_query 1\n" "#define GL_EXT_ray_query 1\n"
"#define GL_EXT_ray_flags_primitive_culling 1\n" "#define GL_EXT_ray_flags_primitive_culling 1\n"
"#define GL_EXT_ray_cull_mask 1\n"
"#define GL_EXT_spirv_intrinsics 1\n" "#define GL_EXT_spirv_intrinsics 1\n"
"#define GL_AMD_shader_ballot 1\n" "#define GL_AMD_shader_ballot 1\n"
@ -556,8 +546,6 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_shader_atomic_float 1\n" "#define GL_EXT_shader_atomic_float 1\n"
"#define GL_EXT_shader_atomic_float2 1\n" "#define GL_EXT_shader_atomic_float2 1\n"
"#define GL_EXT_fragment_shader_barycentric 1\n"
; ;
if (version >= 150) { if (version >= 150) {

View file

@ -161,8 +161,6 @@ const char* const E_GL_ARB_shader_storage_buffer_object = "GL_ARB_shader_storage
const char* const E_GL_ARB_shading_language_packing = "GL_ARB_shading_language_packing"; const char* const E_GL_ARB_shading_language_packing = "GL_ARB_shading_language_packing";
const char* const E_GL_ARB_texture_query_lod = "GL_ARB_texture_query_lod"; const char* const E_GL_ARB_texture_query_lod = "GL_ARB_texture_query_lod";
const char* const E_GL_ARB_vertex_attrib_64bit = "GL_ARB_vertex_attrib_64bit"; const char* const E_GL_ARB_vertex_attrib_64bit = "GL_ARB_vertex_attrib_64bit";
const char* const E_GL_ARB_draw_instanced = "GL_ARB_draw_instanced";
const char* const E_GL_ARB_fragment_coord_conventions = "GL_ARB_fragment_coord_conventions";
const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic"; const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic";
const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote"; const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote";
@ -201,7 +199,6 @@ const char* const E_GL_EXT_debug_printf = "GL_EXT_debug_prin
const char* const E_GL_EXT_ray_tracing = "GL_EXT_ray_tracing"; const char* const E_GL_EXT_ray_tracing = "GL_EXT_ray_tracing";
const char* const E_GL_EXT_ray_query = "GL_EXT_ray_query"; const char* const E_GL_EXT_ray_query = "GL_EXT_ray_query";
const char* const E_GL_EXT_ray_flags_primitive_culling = "GL_EXT_ray_flags_primitive_culling"; const char* const E_GL_EXT_ray_flags_primitive_culling = "GL_EXT_ray_flags_primitive_culling";
const char* const E_GL_EXT_ray_cull_mask = "GL_EXT_ray_cull_mask";
const char* const E_GL_EXT_blend_func_extended = "GL_EXT_blend_func_extended"; const char* const E_GL_EXT_blend_func_extended = "GL_EXT_blend_func_extended";
const char* const E_GL_EXT_shader_implicit_conversions = "GL_EXT_shader_implicit_conversions"; const char* const E_GL_EXT_shader_implicit_conversions = "GL_EXT_shader_implicit_conversions";
const char* const E_GL_EXT_fragment_shading_rate = "GL_EXT_fragment_shading_rate"; const char* const E_GL_EXT_fragment_shading_rate = "GL_EXT_fragment_shading_rate";
@ -210,7 +207,6 @@ const char* const E_GL_EXT_null_initializer = "GL_EXT_null_initi
const char* const E_GL_EXT_shared_memory_block = "GL_EXT_shared_memory_block"; const char* const E_GL_EXT_shared_memory_block = "GL_EXT_shared_memory_block";
const char* const E_GL_EXT_subgroup_uniform_control_flow = "GL_EXT_subgroup_uniform_control_flow"; const char* const E_GL_EXT_subgroup_uniform_control_flow = "GL_EXT_subgroup_uniform_control_flow";
const char* const E_GL_EXT_spirv_intrinsics = "GL_EXT_spirv_intrinsics"; const char* const E_GL_EXT_spirv_intrinsics = "GL_EXT_spirv_intrinsics";
const char* const E_GL_EXT_fragment_shader_barycentric = "GL_EXT_fragment_shader_barycentric";
// Arrays of extensions for the above viewportEXTs duplications // Arrays of extensions for the above viewportEXTs duplications

View file

@ -347,7 +347,7 @@ void TParseContext::handleLoopAttributes(const TAttributes& attributes, TIntermN
// //
// Function attributes // Function attributes
// //
void TParseContext::handleFunctionAttributes(const TSourceLoc& loc, const TAttributes& attributes) void TParseContext::handleFunctionAttributes(const TSourceLoc& loc, const TAttributes& attributes, TFunction* function)
{ {
for (auto it = attributes.begin(); it != attributes.end(); ++it) { for (auto it = attributes.begin(); it != attributes.end(); ++it) {
if (it->size() > 0) { if (it->size() > 0) {

View file

@ -315,7 +315,7 @@ GLSLANG_WEB_EXCLUDE_ON
%token <lex> PATCH SAMPLE NONUNIFORM %token <lex> PATCH SAMPLE NONUNIFORM
%token <lex> COHERENT VOLATILE RESTRICT READONLY WRITEONLY DEVICECOHERENT QUEUEFAMILYCOHERENT WORKGROUPCOHERENT %token <lex> COHERENT VOLATILE RESTRICT READONLY WRITEONLY DEVICECOHERENT QUEUEFAMILYCOHERENT WORKGROUPCOHERENT
%token <lex> SUBGROUPCOHERENT NONPRIVATE SHADERCALLCOHERENT %token <lex> SUBGROUPCOHERENT NONPRIVATE SHADERCALLCOHERENT
%token <lex> NOPERSPECTIVE EXPLICITINTERPAMD PERVERTEXEXT PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV %token <lex> NOPERSPECTIVE EXPLICITINTERPAMD PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV
%token <lex> PRECISE %token <lex> PRECISE
GLSLANG_WEB_EXCLUDE_OFF GLSLANG_WEB_EXCLUDE_OFF
@ -798,7 +798,7 @@ conditional_expression
parseContext.rValueErrorCheck($5.loc, ":", $6); parseContext.rValueErrorCheck($5.loc, ":", $6);
$$ = parseContext.intermediate.addSelection($1, $4, $6, $2.loc); $$ = parseContext.intermediate.addSelection($1, $4, $6, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, ":", $4->getCompleteString(parseContext.intermediate.getEnhancedMsgs()), $6->getCompleteString(parseContext.intermediate.getEnhancedMsgs())); parseContext.binaryOpError($2.loc, ":", $4->getCompleteString(), $6->getCompleteString());
$$ = $6; $$ = $6;
} }
} }
@ -815,7 +815,7 @@ assignment_expression
parseContext.rValueErrorCheck($2.loc, "assign", $3); parseContext.rValueErrorCheck($2.loc, "assign", $3);
$$ = parseContext.addAssign($2.loc, $2.op, $1, $3); $$ = parseContext.addAssign($2.loc, $2.op, $1, $3);
if ($$ == 0) { if ($$ == 0) {
parseContext.assignError($2.loc, "assign", $1->getCompleteString(parseContext.intermediate.getEnhancedMsgs()), $3->getCompleteString(parseContext.intermediate.getEnhancedMsgs())); parseContext.assignError($2.loc, "assign", $1->getCompleteString(), $3->getCompleteString());
$$ = $1; $$ = $1;
} }
} }
@ -877,7 +877,7 @@ expression
parseContext.samplerConstructorLocationCheck($2.loc, ",", $3); parseContext.samplerConstructorLocationCheck($2.loc, ",", $3);
$$ = parseContext.intermediate.addComma($1, $3, $2.loc); $$ = parseContext.intermediate.addComma($1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, ",", $1->getCompleteString(parseContext.intermediate.getEnhancedMsgs()), $3->getCompleteString(parseContext.intermediate.getEnhancedMsgs())); parseContext.binaryOpError($2.loc, ",", $1->getCompleteString(), $3->getCompleteString());
$$ = $3; $$ = $3;
} }
} }
@ -983,20 +983,20 @@ function_prototype
$$.function = $1; $$.function = $1;
$$.loc = $2.loc; $$.loc = $2.loc;
parseContext.requireExtensions($2.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute"); parseContext.requireExtensions($2.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
parseContext.handleFunctionAttributes($2.loc, *$3); parseContext.handleFunctionAttributes($2.loc, *$3, $$.function);
} }
| attribute function_declarator RIGHT_PAREN { | attribute function_declarator RIGHT_PAREN {
$$.function = $2; $$.function = $2;
$$.loc = $3.loc; $$.loc = $3.loc;
parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute"); parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
parseContext.handleFunctionAttributes($3.loc, *$1); parseContext.handleFunctionAttributes($3.loc, *$1, $$.function);
} }
| attribute function_declarator RIGHT_PAREN attribute { | attribute function_declarator RIGHT_PAREN attribute {
$$.function = $2; $$.function = $2;
$$.loc = $3.loc; $$.loc = $3.loc;
parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute"); parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
parseContext.handleFunctionAttributes($3.loc, *$1); parseContext.handleFunctionAttributes($3.loc, *$1, $$.function);
parseContext.handleFunctionAttributes($3.loc, *$4); parseContext.handleFunctionAttributes($3.loc, *$4, $$.function);
} }
; ;
@ -1290,14 +1290,6 @@ GLSLANG_WEB_EXCLUDE_ON
$$.init($1.loc); $$.init($1.loc);
$$.qualifier.pervertexNV = true; $$.qualifier.pervertexNV = true;
} }
| PERVERTEXEXT {
parseContext.globalCheck($1.loc, "pervertexEXT");
parseContext.profileRequires($1.loc, ECoreProfile, 0, E_GL_EXT_fragment_shader_barycentric, "fragment shader barycentric");
parseContext.profileRequires($1.loc, ECompatibilityProfile, 0, E_GL_EXT_fragment_shader_barycentric, "fragment shader barycentric");
parseContext.profileRequires($1.loc, EEsProfile, 0, E_GL_EXT_fragment_shader_barycentric, "fragment shader barycentric");
$$.init($1.loc);
$$.qualifier.pervertexEXT = true;
}
| PERPRIMITIVENV { | PERPRIMITIVENV {
// No need for profile version or extension check. Shader stage already checks both. // No need for profile version or extension check. Shader stage already checks both.
parseContext.globalCheck($1.loc, "perprimitiveNV"); parseContext.globalCheck($1.loc, "perprimitiveNV");
@ -3934,7 +3926,6 @@ iteration_statement_nonattributed
--parseContext.controlFlowNestingLevel; --parseContext.controlFlowNestingLevel;
} }
| DO { | DO {
parseContext.symbolTable.push();
++parseContext.loopNestingLevel; ++parseContext.loopNestingLevel;
++parseContext.statementNestingLevel; ++parseContext.statementNestingLevel;
++parseContext.controlFlowNestingLevel; ++parseContext.controlFlowNestingLevel;
@ -3946,7 +3937,6 @@ iteration_statement_nonattributed
parseContext.boolCheck($8.loc, $6); parseContext.boolCheck($8.loc, $6);
$$ = parseContext.intermediate.addLoop($3, $6, 0, false, $4.loc); $$ = parseContext.intermediate.addLoop($3, $6, 0, false, $4.loc);
parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
--parseContext.loopNestingLevel; --parseContext.loopNestingLevel;
--parseContext.statementNestingLevel; --parseContext.statementNestingLevel;
--parseContext.controlFlowNestingLevel; --parseContext.controlFlowNestingLevel;
@ -4375,6 +4365,9 @@ spirv_type_parameter
: constant_expression { : constant_expression {
$$ = parseContext.makeSpirvTypeParameters($1->getLoc(), $1->getAsConstantUnion()); $$ = parseContext.makeSpirvTypeParameters($1->getLoc(), $1->getAsConstantUnion());
} }
| type_specifier {
$$ = parseContext.makeSpirvTypeParameters($1);
}
spirv_instruction_qualifier spirv_instruction_qualifier
: SPIRV_INSTRUCTION LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN { : SPIRV_INSTRUCTION LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN {

View file

@ -315,7 +315,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
%token <lex> PATCH SAMPLE NONUNIFORM %token <lex> PATCH SAMPLE NONUNIFORM
%token <lex> COHERENT VOLATILE RESTRICT READONLY WRITEONLY DEVICECOHERENT QUEUEFAMILYCOHERENT WORKGROUPCOHERENT %token <lex> COHERENT VOLATILE RESTRICT READONLY WRITEONLY DEVICECOHERENT QUEUEFAMILYCOHERENT WORKGROUPCOHERENT
%token <lex> SUBGROUPCOHERENT NONPRIVATE SHADERCALLCOHERENT %token <lex> SUBGROUPCOHERENT NONPRIVATE SHADERCALLCOHERENT
%token <lex> NOPERSPECTIVE EXPLICITINTERPAMD PERVERTEXEXT PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV %token <lex> NOPERSPECTIVE EXPLICITINTERPAMD PERVERTEXNV PERPRIMITIVENV PERVIEWNV PERTASKNV
%token <lex> PRECISE %token <lex> PRECISE
@ -798,7 +798,7 @@ conditional_expression
parseContext.rValueErrorCheck($5.loc, ":", $6); parseContext.rValueErrorCheck($5.loc, ":", $6);
$$ = parseContext.intermediate.addSelection($1, $4, $6, $2.loc); $$ = parseContext.intermediate.addSelection($1, $4, $6, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, ":", $4->getCompleteString(parseContext.intermediate.getEnhancedMsgs()), $6->getCompleteString(parseContext.intermediate.getEnhancedMsgs())); parseContext.binaryOpError($2.loc, ":", $4->getCompleteString(), $6->getCompleteString());
$$ = $6; $$ = $6;
} }
} }
@ -815,7 +815,7 @@ assignment_expression
parseContext.rValueErrorCheck($2.loc, "assign", $3); parseContext.rValueErrorCheck($2.loc, "assign", $3);
$$ = parseContext.addAssign($2.loc, $2.op, $1, $3); $$ = parseContext.addAssign($2.loc, $2.op, $1, $3);
if ($$ == 0) { if ($$ == 0) {
parseContext.assignError($2.loc, "assign", $1->getCompleteString(parseContext.intermediate.getEnhancedMsgs()), $3->getCompleteString(parseContext.intermediate.getEnhancedMsgs())); parseContext.assignError($2.loc, "assign", $1->getCompleteString(), $3->getCompleteString());
$$ = $1; $$ = $1;
} }
} }
@ -877,7 +877,7 @@ expression
parseContext.samplerConstructorLocationCheck($2.loc, ",", $3); parseContext.samplerConstructorLocationCheck($2.loc, ",", $3);
$$ = parseContext.intermediate.addComma($1, $3, $2.loc); $$ = parseContext.intermediate.addComma($1, $3, $2.loc);
if ($$ == 0) { if ($$ == 0) {
parseContext.binaryOpError($2.loc, ",", $1->getCompleteString(parseContext.intermediate.getEnhancedMsgs()), $3->getCompleteString(parseContext.intermediate.getEnhancedMsgs())); parseContext.binaryOpError($2.loc, ",", $1->getCompleteString(), $3->getCompleteString());
$$ = $3; $$ = $3;
} }
} }
@ -983,20 +983,20 @@ function_prototype
$$.function = $1; $$.function = $1;
$$.loc = $2.loc; $$.loc = $2.loc;
parseContext.requireExtensions($2.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute"); parseContext.requireExtensions($2.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
parseContext.handleFunctionAttributes($2.loc, *$3); parseContext.handleFunctionAttributes($2.loc, *$3, $$.function);
} }
| attribute function_declarator RIGHT_PAREN { | attribute function_declarator RIGHT_PAREN {
$$.function = $2; $$.function = $2;
$$.loc = $3.loc; $$.loc = $3.loc;
parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute"); parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
parseContext.handleFunctionAttributes($3.loc, *$1); parseContext.handleFunctionAttributes($3.loc, *$1, $$.function);
} }
| attribute function_declarator RIGHT_PAREN attribute { | attribute function_declarator RIGHT_PAREN attribute {
$$.function = $2; $$.function = $2;
$$.loc = $3.loc; $$.loc = $3.loc;
parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute"); parseContext.requireExtensions($3.loc, 1, &E_GL_EXT_subgroup_uniform_control_flow, "attribute");
parseContext.handleFunctionAttributes($3.loc, *$1); parseContext.handleFunctionAttributes($3.loc, *$1, $$.function);
parseContext.handleFunctionAttributes($3.loc, *$4); parseContext.handleFunctionAttributes($3.loc, *$4, $$.function);
} }
; ;
@ -1290,14 +1290,6 @@ interpolation_qualifier
$$.init($1.loc); $$.init($1.loc);
$$.qualifier.pervertexNV = true; $$.qualifier.pervertexNV = true;
} }
| PERVERTEXEXT {
parseContext.globalCheck($1.loc, "pervertexEXT");
parseContext.profileRequires($1.loc, ECoreProfile, 0, E_GL_EXT_fragment_shader_barycentric, "fragment shader barycentric");
parseContext.profileRequires($1.loc, ECompatibilityProfile, 0, E_GL_EXT_fragment_shader_barycentric, "fragment shader barycentric");
parseContext.profileRequires($1.loc, EEsProfile, 0, E_GL_EXT_fragment_shader_barycentric, "fragment shader barycentric");
$$.init($1.loc);
$$.qualifier.pervertexEXT = true;
}
| PERPRIMITIVENV { | PERPRIMITIVENV {
// No need for profile version or extension check. Shader stage already checks both. // No need for profile version or extension check. Shader stage already checks both.
parseContext.globalCheck($1.loc, "perprimitiveNV"); parseContext.globalCheck($1.loc, "perprimitiveNV");
@ -3934,7 +3926,6 @@ iteration_statement_nonattributed
--parseContext.controlFlowNestingLevel; --parseContext.controlFlowNestingLevel;
} }
| DO { | DO {
parseContext.symbolTable.push();
++parseContext.loopNestingLevel; ++parseContext.loopNestingLevel;
++parseContext.statementNestingLevel; ++parseContext.statementNestingLevel;
++parseContext.controlFlowNestingLevel; ++parseContext.controlFlowNestingLevel;
@ -3946,7 +3937,6 @@ iteration_statement_nonattributed
parseContext.boolCheck($8.loc, $6); parseContext.boolCheck($8.loc, $6);
$$ = parseContext.intermediate.addLoop($3, $6, 0, false, $4.loc); $$ = parseContext.intermediate.addLoop($3, $6, 0, false, $4.loc);
parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
--parseContext.loopNestingLevel; --parseContext.loopNestingLevel;
--parseContext.statementNestingLevel; --parseContext.statementNestingLevel;
--parseContext.controlFlowNestingLevel; --parseContext.controlFlowNestingLevel;
@ -4375,6 +4365,9 @@ spirv_type_parameter
: constant_expression { : constant_expression {
$$ = parseContext.makeSpirvTypeParameters($1->getLoc(), $1->getAsConstantUnion()); $$ = parseContext.makeSpirvTypeParameters($1->getLoc(), $1->getAsConstantUnion());
} }
| type_specifier {
$$ = parseContext.makeSpirvTypeParameters($1);
}
spirv_instruction_qualifier spirv_instruction_qualifier
: SPIRV_INSTRUCTION LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN { : SPIRV_INSTRUCTION LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN {

View file

@ -501,12 +501,11 @@ extern int yydebug;
SHADERCALLCOHERENT = 702, /* SHADERCALLCOHERENT */ SHADERCALLCOHERENT = 702, /* SHADERCALLCOHERENT */
NOPERSPECTIVE = 703, /* NOPERSPECTIVE */ NOPERSPECTIVE = 703, /* NOPERSPECTIVE */
EXPLICITINTERPAMD = 704, /* EXPLICITINTERPAMD */ EXPLICITINTERPAMD = 704, /* EXPLICITINTERPAMD */
PERVERTEXEXT = 705, /* PERVERTEXEXT */ PERVERTEXNV = 705, /* PERVERTEXNV */
PERVERTEXNV = 706, /* PERVERTEXNV */ PERPRIMITIVENV = 706, /* PERPRIMITIVENV */
PERPRIMITIVENV = 707, /* PERPRIMITIVENV */ PERVIEWNV = 707, /* PERVIEWNV */
PERVIEWNV = 708, /* PERVIEWNV */ PERTASKNV = 708, /* PERTASKNV */
PERTASKNV = 709, /* PERTASKNV */ PRECISE = 709 /* PRECISE */
PRECISE = 710 /* PRECISE */
}; };
typedef enum yytokentype yytoken_kind_t; typedef enum yytokentype yytoken_kind_t;
#endif #endif
@ -554,7 +553,7 @@ union YYSTYPE
glslang::TArraySizes* typeParameters; glslang::TArraySizes* typeParameters;
} interm; } interm;
#line 558 "MachineIndependent/glslang_tab.cpp.h" #line 557 "MachineIndependent/glslang_tab.cpp.h"
}; };
typedef union YYSTYPE YYSTYPE; typedef union YYSTYPE YYSTYPE;

View file

@ -48,6 +48,37 @@
#endif #endif
#include <cstdint> #include <cstdint>
namespace {
bool IsInfinity(double x) {
#ifdef _MSC_VER
switch (_fpclass(x)) {
case _FPCLASS_NINF:
case _FPCLASS_PINF:
return true;
default:
return false;
}
#else
return std::isinf(x);
#endif
}
bool IsNan(double x) {
#ifdef _MSC_VER
switch (_fpclass(x)) {
case _FPCLASS_SNAN:
case _FPCLASS_QNAN:
return true;
default:
return false;
}
#else
return std::isnan(x);
#endif
}
}
namespace glslang { namespace glslang {

View file

@ -79,7 +79,7 @@ public:
target = &inputList; target = &inputList;
else if (base->getQualifier().storage == EvqVaryingOut) else if (base->getQualifier().storage == EvqVaryingOut)
target = &outputList; target = &outputList;
else if (base->getQualifier().isUniformOrBuffer() && !base->getQualifier().isPushConstant() && !base->getQualifier().isShaderRecord()) else if (base->getQualifier().isUniformOrBuffer() && !base->getQualifier().isPushConstant())
target = &uniformList; target = &uniformList;
// If a global is being visited, then we should also traverse it incase it's evaluation // If a global is being visited, then we should also traverse it incase it's evaluation
// ends up visiting inputs we want to tag as live // ends up visiting inputs we want to tag as live
@ -203,7 +203,11 @@ struct TResolverUniformAdaptor {
inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey) { inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey) {
TVarEntryInfo& ent = entKey.second; TVarEntryInfo& ent = entKey.second;
ent.clearNewAssignments(); ent.newLocation = -1;
ent.newComponent = -1;
ent.newBinding = -1;
ent.newSet = -1;
ent.newIndex = -1;
const bool isValid = resolver.validateBinding(stage, ent); const bool isValid = resolver.validateBinding(stage, ent);
if (isValid) { if (isValid) {
resolver.resolveSet(ent.stage, ent); resolver.resolveSet(ent.stage, ent);
@ -277,7 +281,11 @@ struct TResolverInOutAdaptor {
inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey) inline void operator()(std::pair<const TString, TVarEntryInfo>& entKey)
{ {
TVarEntryInfo& ent = entKey.second; TVarEntryInfo& ent = entKey.second;
ent.clearNewAssignments(); ent.newLocation = -1;
ent.newComponent = -1;
ent.newBinding = -1;
ent.newSet = -1;
ent.newIndex = -1;
const bool isValid = resolver.validateInOut(ent.stage, ent); const bool isValid = resolver.validateInOut(ent.stage, ent);
if (isValid) { if (isValid) {
resolver.resolveInOutLocation(stage, ent); resolver.resolveInOutLocation(stage, ent);
@ -506,24 +514,6 @@ struct TSymbolValidater
return; return;
} }
else { else {
// Deal with input/output pairs where one is a block member but the other is loose,
// e.g. with ARB_separate_shader_objects
if (type1.getBasicType() == EbtBlock &&
type1.isStruct() && !type2.isStruct()) {
// Iterate through block members tracking layout
glslang::TString name;
type1.getStruct()->begin()->type->appendMangledName(name);
if (name == mangleName2
&& type1.getQualifier().layoutLocation == type2.getQualifier().layoutLocation) return;
}
if (type2.getBasicType() == EbtBlock &&
type2.isStruct() && !type1.isStruct()) {
// Iterate through block members tracking layout
glslang::TString name;
type2.getStruct()->begin()->type->appendMangledName(name);
if (name == mangleName1
&& type1.getQualifier().layoutLocation == type2.getQualifier().layoutLocation) return;
}
TString err = "Invalid In/Out variable type : " + entKey.first; TString err = "Invalid In/Out variable type : " + entKey.first;
infoSink.info.message(EPrefixInternalError, err.c_str()); infoSink.info.message(EPrefixInternalError, err.c_str());
hadError = true; hadError = true;
@ -758,7 +748,7 @@ private:
}; };
TDefaultIoResolverBase::TDefaultIoResolverBase(const TIntermediate& intermediate) TDefaultIoResolverBase::TDefaultIoResolverBase(const TIntermediate& intermediate)
: referenceIntermediate(intermediate) : intermediate(intermediate)
, nextUniformLocation(intermediate.getUniformLocationBase()) , nextUniformLocation(intermediate.getUniformLocationBase())
, nextInputLocation(0) , nextInputLocation(0)
, nextOutputLocation(0) , nextOutputLocation(0)
@ -770,17 +760,17 @@ TDefaultIoResolverBase::TDefaultIoResolverBase(const TIntermediate& intermediate
int TDefaultIoResolverBase::getBaseBinding(EShLanguage stage, TResourceType res, unsigned int set) const { int TDefaultIoResolverBase::getBaseBinding(EShLanguage stage, TResourceType res, unsigned int set) const {
return stageIntermediates[stage] ? selectBaseBinding(stageIntermediates[stage]->getShiftBinding(res), stageIntermediates[stage]->getShiftBindingForSet(res, set)) return stageIntermediates[stage] ? selectBaseBinding(stageIntermediates[stage]->getShiftBinding(res), stageIntermediates[stage]->getShiftBindingForSet(res, set))
: selectBaseBinding(referenceIntermediate.getShiftBinding(res), referenceIntermediate.getShiftBindingForSet(res, set)); : selectBaseBinding(intermediate.getShiftBinding(res), intermediate.getShiftBindingForSet(res, set));
} }
const std::vector<std::string>& TDefaultIoResolverBase::getResourceSetBinding(EShLanguage stage) const { const std::vector<std::string>& TDefaultIoResolverBase::getResourceSetBinding(EShLanguage stage) const {
return stageIntermediates[stage] ? stageIntermediates[stage]->getResourceSetBinding() return stageIntermediates[stage] ? stageIntermediates[stage]->getResourceSetBinding()
: referenceIntermediate.getResourceSetBinding(); : intermediate.getResourceSetBinding();
} }
bool TDefaultIoResolverBase::doAutoBindingMapping() const { return referenceIntermediate.getAutoMapBindings(); } bool TDefaultIoResolverBase::doAutoBindingMapping() const { return intermediate.getAutoMapBindings(); }
bool TDefaultIoResolverBase::doAutoLocationMapping() const { return referenceIntermediate.getAutoMapLocations(); } bool TDefaultIoResolverBase::doAutoLocationMapping() const { return intermediate.getAutoMapLocations(); }
TDefaultIoResolverBase::TSlotSet::iterator TDefaultIoResolverBase::findSlot(int set, int slot) { TDefaultIoResolverBase::TSlotSet::iterator TDefaultIoResolverBase::findSlot(int set, int slot) {
return std::lower_bound(slots[set].begin(), slots[set].end(), slot); return std::lower_bound(slots[set].begin(), slots[set].end(), slot);
@ -837,7 +827,7 @@ int TDefaultIoResolverBase::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
} }
// no locations added if already present, a built-in variable, a block, or an opaque // no locations added if already present, a built-in variable, a block, or an opaque
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock || if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock ||
type.isAtomic() || type.isSpirvType() || (type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) { type.isAtomic() || (type.containsOpaque() && intermediate.getSpv().openGl == 0)) {
return ent.newLocation = -1; return ent.newLocation = -1;
} }
// no locations on blocks of built-in variables // no locations on blocks of built-in variables
@ -849,7 +839,7 @@ int TDefaultIoResolverBase::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
return ent.newLocation = -1; return ent.newLocation = -1;
} }
} }
int location = referenceIntermediate.getUniformLocationOverride(name); int location = intermediate.getUniformLocationOverride(name);
if (location != -1) { if (location != -1) {
return ent.newLocation = location; return ent.newLocation = location;
} }
@ -865,8 +855,8 @@ int TDefaultIoResolverBase::resolveInOutLocation(EShLanguage stage, TVarEntryInf
return ent.newLocation = -1; return ent.newLocation = -1;
} }
// no locations added if already present, a built-in variable, or a variable with SPIR-V decorate // no locations added if already present, or a built-in variable
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getQualifier().hasSprivDecorate()) { if (type.getQualifier().hasLocation() || type.isBuiltIn()) {
return ent.newLocation = -1; return ent.newLocation = -1;
} }
@ -952,8 +942,8 @@ int TDefaultGlslIoResolver::resolveInOutLocation(EShLanguage stage, TVarEntryInf
if (type.getQualifier().hasLocation()) { if (type.getQualifier().hasLocation()) {
return ent.newLocation = type.getQualifier().layoutLocation; return ent.newLocation = type.getQualifier().layoutLocation;
} }
// no locations added if already present, a built-in variable, or a variable with SPIR-V decorate // no locations added if already present, or a built-in variable
if (type.isBuiltIn() || type.getQualifier().hasSprivDecorate()) { if (type.isBuiltIn()) {
return ent.newLocation = -1; return ent.newLocation = -1;
} }
// no locations on blocks of built-in variables // no locations on blocks of built-in variables
@ -1034,8 +1024,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
} else { } else {
// no locations added if already present, a built-in variable, a block, or an opaque // no locations added if already present, a built-in variable, a block, or an opaque
if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock || if (type.getQualifier().hasLocation() || type.isBuiltIn() || type.getBasicType() == EbtBlock ||
type.isAtomic() || type.isSpirvType() || type.isAtomic() || (type.containsOpaque() && intermediate.getSpv().openGl == 0)) {
(type.containsOpaque() && referenceIntermediate.getSpv().openGl == 0)) {
return ent.newLocation = -1; return ent.newLocation = -1;
} }
// no locations on blocks of built-in variables // no locations on blocks of built-in variables
@ -1048,7 +1037,7 @@ int TDefaultGlslIoResolver::resolveUniformLocation(EShLanguage /*stage*/, TVarEn
} }
} }
} }
int location = referenceIntermediate.getUniformLocationOverride(name.c_str()); int location = intermediate.getUniformLocationOverride(name.c_str());
if (location != -1) { if (location != -1) {
return ent.newLocation = location; return ent.newLocation = location;
} }
@ -1097,7 +1086,7 @@ int TDefaultGlslIoResolver::resolveBinding(EShLanguage stage, TVarEntryInfo& ent
const TType& type = ent.symbol->getType(); const TType& type = ent.symbol->getType();
const TString& name = ent.symbol->getAccessName(); const TString& name = ent.symbol->getAccessName();
// On OpenGL arrays of opaque types take a separate binding for each element // On OpenGL arrays of opaque types take a separate binding for each element
int numBindings = referenceIntermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1; int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
TResourceType resource = getResourceType(type); TResourceType resource = getResourceType(type);
// don't need to handle uniform symbol, it will be handled in resolveUniformLocation // don't need to handle uniform symbol, it will be handled in resolveUniformLocation
if (resource == EResUbo && type.getBasicType() != EbtBlock) { if (resource == EResUbo && type.getBasicType() != EbtBlock) {
@ -1106,7 +1095,7 @@ int TDefaultGlslIoResolver::resolveBinding(EShLanguage stage, TVarEntryInfo& ent
// There is no 'set' qualifier in OpenGL shading language, each resource has its own // There is no 'set' qualifier in OpenGL shading language, each resource has its own
// binding name space, so remap the 'set' to resource type which make each resource // binding name space, so remap the 'set' to resource type which make each resource
// binding is valid from 0 to MAX_XXRESOURCE_BINDINGS // binding is valid from 0 to MAX_XXRESOURCE_BINDINGS
int set = referenceIntermediate.getSpv().openGl != 0 ? resource : ent.newSet; int set = intermediate.getSpv().openGl != 0 ? resource : ent.newSet;
int resourceKey = set; int resourceKey = set;
if (resource < EResCount) { if (resource < EResCount) {
if (type.getQualifier().hasBinding()) { if (type.getQualifier().hasBinding()) {
@ -1234,7 +1223,7 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink&
const TType& type = ent.symbol->getType(); const TType& type = ent.symbol->getType();
const TString& name = ent.symbol->getAccessName(); const TString& name = ent.symbol->getAccessName();
TResourceType resource = getResourceType(type); TResourceType resource = getResourceType(type);
int set = referenceIntermediate.getSpv().openGl != 0 ? resource : resolveSet(ent.stage, ent); int set = intermediate.getSpv().openGl != 0 ? resource : resolveSet(ent.stage, ent);
int resourceKey = set; int resourceKey = set;
if (type.getQualifier().hasBinding()) { if (type.getQualifier().hasBinding()) {
@ -1244,7 +1233,7 @@ void TDefaultGlslIoResolver::reserverResourceSlot(TVarEntryInfo& ent, TInfoSink&
if (iter == varSlotMap.end()) { if (iter == varSlotMap.end()) {
// Reserve the slots for the ubo, ssbo and opaques who has explicit binding // Reserve the slots for the ubo, ssbo and opaques who has explicit binding
int numBindings = referenceIntermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1; int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
varSlotMap[name] = binding; varSlotMap[name] = binding;
reserveSlot(resourceKey, binding, numBindings); reserveSlot(resourceKey, binding, numBindings);
} else { } else {
@ -1299,7 +1288,7 @@ struct TDefaultIoResolver : public TDefaultIoResolverBase {
const TType& type = ent.symbol->getType(); const TType& type = ent.symbol->getType();
const int set = getLayoutSet(type); const int set = getLayoutSet(type);
// On OpenGL arrays of opaque types take a seperate binding for each element // On OpenGL arrays of opaque types take a seperate binding for each element
int numBindings = referenceIntermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1; int numBindings = intermediate.getSpv().openGl != 0 && type.isSizedArray() ? type.getCumulativeArraySize() : 1;
TResourceType resource = getResourceType(type); TResourceType resource = getResourceType(type);
if (resource < EResCount) { if (resource < EResCount) {
if (type.getQualifier().hasBinding()) { if (type.getQualifier().hasBinding()) {
@ -1644,45 +1633,6 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) {
return TVarEntryInfo::TOrderByPriority()(p1.second, p2.second); return TVarEntryInfo::TOrderByPriority()(p1.second, p2.second);
}); });
resolver->endResolve(EShLangCount); resolver->endResolve(EShLangCount);
if (autoPushConstantBlockName.length()) {
bool upgraded = false;
for (size_t stage = 0; stage < EShLangCount; stage++) {
if (intermediates[stage] != nullptr) {
TVarLiveMap** pUniformVarMap = uniformResolve.uniformVarMap;
auto at = pUniformVarMap[stage]->find(autoPushConstantBlockName);
if (at == pUniformVarMap[stage]->end())
continue;
TQualifier& qualifier = at->second.symbol->getQualifier();
if (!qualifier.isUniform())
continue;
TType& t = at->second.symbol->getWritableType();
int size, stride;
TIntermediate::getBaseAlignment(t, size, stride, autoPushConstantBlockPacking,
qualifier.layoutMatrix == ElmRowMajor);
if (size <= int(autoPushConstantMaxSize)) {
qualifier.setBlockStorage(EbsPushConstant);
qualifier.layoutPacking = autoPushConstantBlockPacking;
// Push constants don't have set/binding etc. decorations, remove those.
qualifier.layoutSet = TQualifier::layoutSetEnd;
at->second.clearNewAssignments();
upgraded = true;
}
}
}
// If it's been upgraded to push_constant, then remove it from the uniformVector
// so it doesn't get a set/binding assigned to it.
if (upgraded) {
while (1) {
auto at = std::find_if(uniformVector.begin(), uniformVector.end(),
[this](const TVarLivePair& p) { return p.first == autoPushConstantBlockName; });
if (at != uniformVector.end())
uniformVector.erase(at);
else
break;
}
}
}
for (size_t stage = 0; stage < EShLangCount; stage++) { for (size_t stage = 0; stage < EShLangCount; stage++) {
if (intermediates[stage] != nullptr) { if (intermediates[stage] != nullptr) {
// traverse each stage, set new location to each input/output and unifom symbol, set new binding to // traverse each stage, set new location to each input/output and unifom symbol, set new binding to

View file

@ -61,15 +61,6 @@ struct TVarEntryInfo {
int newComponent; int newComponent;
int newIndex; int newIndex;
EShLanguage stage; EShLanguage stage;
void clearNewAssignments() {
newBinding = -1;
newSet = -1;
newLocation = -1;
newComponent = -1;
newIndex = -1;
}
struct TOrderById { struct TOrderById {
inline bool operator()(const TVarEntryInfo& l, const TVarEntryInfo& r) { return l.id < r.id; } inline bool operator()(const TVarEntryInfo& l, const TVarEntryInfo& r) { return l.id < r.id; }
}; };
@ -174,7 +165,7 @@ public:
protected: protected:
TDefaultIoResolverBase(TDefaultIoResolverBase&); TDefaultIoResolverBase(TDefaultIoResolverBase&);
TDefaultIoResolverBase& operator=(TDefaultIoResolverBase&); TDefaultIoResolverBase& operator=(TDefaultIoResolverBase&);
const TIntermediate& referenceIntermediate; const TIntermediate& intermediate;
int nextUniformLocation; int nextUniformLocation;
int nextInputLocation; int nextInputLocation;
int nextOutputLocation; int nextOutputLocation;
@ -300,7 +291,7 @@ public:
bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; } bool virtual doMap(TIoMapResolver*, TInfoSink&) { return true; }
}; };
// I/O mapper for GLSL // I/O mapper for OpenGL
class TGlslIoMapper : public TIoMapper { class TGlslIoMapper : public TIoMapper {
public: public:
TGlslIoMapper() { TGlslIoMapper() {
@ -310,8 +301,6 @@ public:
memset(intermediates, 0, sizeof(TIntermediate*) * (EShLangCount + 1)); memset(intermediates, 0, sizeof(TIntermediate*) * (EShLangCount + 1));
profile = ENoProfile; profile = ENoProfile;
version = 0; version = 0;
autoPushConstantMaxSize = 128;
autoPushConstantBlockPacking = ElpStd430;
} }
virtual ~TGlslIoMapper() { virtual ~TGlslIoMapper() {
for (size_t stage = 0; stage < EShLangCount; stage++) { for (size_t stage = 0; stage < EShLangCount; stage++) {
@ -331,13 +320,6 @@ public:
intermediates[stage] = nullptr; intermediates[stage] = nullptr;
} }
} }
// If set, the uniform block with the given name will be changed to be backed by
// push_constant if it's size is <= maxSize
void setAutoPushConstantBlock(const char* name, unsigned int maxSize, TLayoutPacking packing) {
autoPushConstantBlockName = name;
autoPushConstantMaxSize = maxSize;
autoPushConstantBlockPacking = packing;
}
// grow the reflection stage by stage // grow the reflection stage by stage
bool addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*) override; bool addStage(EShLanguage, TIntermediate&, TInfoSink&, TIoMapResolver*) override;
bool doMap(TIoMapResolver*, TInfoSink&) override; bool doMap(TIoMapResolver*, TInfoSink&) override;
@ -347,11 +329,6 @@ public:
bool hadError = false; bool hadError = false;
EProfile profile; EProfile profile;
int version; int version;
private:
TString autoPushConstantBlockName;
unsigned int autoPushConstantMaxSize;
TLayoutPacking autoPushConstantBlockPacking;
}; };
} // end namespace glslang } // end namespace glslang

View file

@ -55,28 +55,22 @@ namespace glslang {
// //
// Link-time error emitter. // Link-time error emitter.
// //
void TIntermediate::error(TInfoSink& infoSink, const char* message, EShLanguage unitStage) void TIntermediate::error(TInfoSink& infoSink, const char* message)
{ {
#ifndef GLSLANG_WEB #ifndef GLSLANG_WEB
infoSink.info.prefix(EPrefixError); infoSink.info.prefix(EPrefixError);
if (unitStage < EShLangCount) infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
infoSink.info << "Linking " << StageName(getStage()) << " and " << StageName(unitStage) << " stages: " << message << "\n";
else
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
#endif #endif
++numErrors; ++numErrors;
} }
// Link-time warning. // Link-time warning.
void TIntermediate::warn(TInfoSink& infoSink, const char* message, EShLanguage unitStage) void TIntermediate::warn(TInfoSink& infoSink, const char* message)
{ {
#ifndef GLSLANG_WEB #ifndef GLSLANG_WEB
infoSink.info.prefix(EPrefixWarning); infoSink.info.prefix(EPrefixWarning);
if (unitStage < EShLangCount) infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
infoSink.info << "Linking " << StageName(language) << " and " << StageName(unitStage) << " stages: " << message << "\n";
else
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
#endif #endif
} }
@ -318,7 +312,6 @@ void TIntermediate::mergeModes(TInfoSink& infoSink, TIntermediate& unit)
MERGE_TRUE(autoMapBindings); MERGE_TRUE(autoMapBindings);
MERGE_TRUE(autoMapLocations); MERGE_TRUE(autoMapLocations);
MERGE_TRUE(invertY); MERGE_TRUE(invertY);
MERGE_TRUE(dxPositionW);
MERGE_TRUE(flattenUniformArrays); MERGE_TRUE(flattenUniformArrays);
MERGE_TRUE(useUnknownFormat); MERGE_TRUE(useUnknownFormat);
MERGE_TRUE(hlslOffsets); MERGE_TRUE(hlslOffsets);
@ -586,6 +579,9 @@ void TIntermediate::mergeGlobalUniformBlocks(TInfoSink& infoSink, TIntermediate&
} }
void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* block, TIntermSymbol* unitBlock, TIntermediate* unit) { void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* block, TIntermSymbol* unitBlock, TIntermediate* unit) {
if (block->getType() == unitBlock->getType()) {
return;
}
if (block->getType().getTypeName() != unitBlock->getType().getTypeName() || if (block->getType().getTypeName() != unitBlock->getType().getTypeName() ||
block->getType().getBasicType() != unitBlock->getType().getBasicType() || block->getType().getBasicType() != unitBlock->getType().getBasicType() ||
@ -632,42 +628,44 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
} }
} }
TType unitType;
unitType.shallowCopy(unitBlock->getType());
// update symbol node in unit tree, // update symbol node in unit tree,
// and other nodes that may reference it // and other nodes that may reference it
class TMergeBlockTraverser : public TIntermTraverser { class TMergeBlockTraverser : public TIntermTraverser {
public: public:
TMergeBlockTraverser(const TIntermSymbol* newSym) TMergeBlockTraverser(const glslang::TType &type, const glslang::TType& unitType,
: newSymbol(newSym), unitType(nullptr), unit(nullptr), memberIndexUpdates(nullptr) glslang::TIntermediate& unit,
{ const std::map<unsigned int, unsigned int>& memberIdxUpdates) :
} newType(type), unitType(unitType), unit(unit), memberIndexUpdates(memberIdxUpdates)
TMergeBlockTraverser(const TIntermSymbol* newSym, const glslang::TType* unitType, glslang::TIntermediate* unit, { }
const std::map<unsigned int, unsigned int>* memberIdxUpdates) virtual ~TMergeBlockTraverser() { }
: TIntermTraverser(false, true), newSymbol(newSym), unitType(unitType), unit(unit), memberIndexUpdates(memberIdxUpdates)
{
}
virtual ~TMergeBlockTraverser() {}
const TIntermSymbol* newSymbol; const glslang::TType& newType; // type with modifications
const glslang::TType* unitType; // copy of original type const glslang::TType& unitType; // copy of original type
glslang::TIntermediate* unit; // intermediate that is being updated glslang::TIntermediate& unit; // intermediate that is being updated
const std::map<unsigned int, unsigned int>* memberIndexUpdates; const std::map<unsigned int, unsigned int>& memberIndexUpdates;
virtual void visitSymbol(TIntermSymbol* symbol) virtual void visitSymbol(TIntermSymbol* symbol)
{ {
if (newSymbol->getAccessName() == symbol->getAccessName() && glslang::TType& symType = symbol->getWritableType();
newSymbol->getQualifier().getBlockStorage() == symbol->getQualifier().getBlockStorage()) {
// Each symbol node may have a local copy of the block structure. if (symType == unitType) {
// Update those structures to match the new one post-merge // each symbol node has a local copy of the unitType
*(symbol->getWritableType().getWritableStruct()) = *(newSymbol->getType().getStruct()); // if merging involves changing properties that aren't shared objects
// they should be updated in all instances
// e.g. the struct list is a ptr to an object, so it can be updated
// once, outside the traverser
//*symType.getWritableStruct() = *newType.getStruct();
} }
} }
virtual bool visitBinary(TVisit, glslang::TIntermBinary* node) virtual bool visitBinary(TVisit, glslang::TIntermBinary* node)
{ {
if (!unit || !unitType || !memberIndexUpdates || memberIndexUpdates->empty()) if (node->getOp() == EOpIndexDirectStruct && node->getLeft()->getType() == unitType) {
return true;
if (node->getOp() == EOpIndexDirectStruct && node->getLeft()->getType() == *unitType) {
// this is a dereference to a member of the block since the // this is a dereference to a member of the block since the
// member list changed, need to update this to point to the // member list changed, need to update this to point to the
// right index // right index
@ -675,8 +673,8 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
glslang::TIntermConstantUnion* constNode = node->getRight()->getAsConstantUnion(); glslang::TIntermConstantUnion* constNode = node->getRight()->getAsConstantUnion();
unsigned int memberIdx = constNode->getConstArray()[0].getUConst(); unsigned int memberIdx = constNode->getConstArray()[0].getUConst();
unsigned int newIdx = memberIndexUpdates->at(memberIdx); unsigned int newIdx = memberIndexUpdates.at(memberIdx);
TIntermTyped* newConstNode = unit->addConstantUnion(newIdx, node->getRight()->getLoc()); TIntermTyped* newConstNode = unit.addConstantUnion(newIdx, node->getRight()->getLoc());
node->setRight(newConstNode); node->setRight(newConstNode);
delete constNode; delete constNode;
@ -685,20 +683,10 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
} }
return true; return true;
} }
}; } finalLinkTraverser(block->getType(), unitType, *unit, memberIndexUpdates);
// 'this' may have symbols that are using the old block structure, so traverse the tree to update those // update the tree to use the new type
// in 'visitSymbol' unit->getTreeRoot()->traverse(&finalLinkTraverser);
TMergeBlockTraverser finalLinkTraverser(block);
getTreeRoot()->traverse(&finalLinkTraverser);
// The 'unit' intermediate needs the block structures update, but also structure entry indices
// may have changed from the old block to the new one that it was merged into, so update those
// in 'visitBinary'
TType unitType;
unitType.shallowCopy(unitBlock->getType());
TMergeBlockTraverser unitFinalLinkTraverser(block, &unitType, unit, &memberIndexUpdates);
unit->getTreeRoot()->traverse(&unitFinalLinkTraverser);
// update the member list // update the member list
(*unitMemberList) = (*memberList); (*unitMemberList) = (*memberList);
@ -771,10 +759,7 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
auto checkName = [this, unitSymbol, &infoSink](const TString& name) { auto checkName = [this, unitSymbol, &infoSink](const TString& name) {
for (unsigned int i = 0; i < unitSymbol->getType().getStruct()->size(); ++i) { for (unsigned int i = 0; i < unitSymbol->getType().getStruct()->size(); ++i) {
if (name == (*unitSymbol->getType().getStruct())[i].type->getFieldName() if (name == (*unitSymbol->getType().getStruct())[i].type->getFieldName()) {
&& !((*unitSymbol->getType().getStruct())[i].type->getQualifier().hasLocation()
|| unitSymbol->getType().getQualifier().hasLocation())
) {
error(infoSink, "Anonymous member name used for global variable or other anonymous member: "); error(infoSink, "Anonymous member name used for global variable or other anonymous member: ");
infoSink.info << (*unitSymbol->getType().getStruct())[i].type->getCompleteString() << "\n"; infoSink.info << (*unitSymbol->getType().getStruct())[i].type->getCompleteString() << "\n";
} }
@ -830,10 +815,6 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE) #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
bool crossStage = getStage() != unitStage; bool crossStage = getStage() != unitStage;
bool writeTypeComparison = false; bool writeTypeComparison = false;
bool errorReported = false;
bool printQualifiers = false;
bool printPrecision = false;
bool printType = false;
// Types have to match // Types have to match
{ {
@ -865,48 +846,11 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
(symbol.getType().isUnsizedArray() || unitSymbol.getType().isUnsizedArray())); (symbol.getType().isUnsizedArray() || unitSymbol.getType().isUnsizedArray()));
} }
int lpidx = -1; if (!symbol.getType().sameElementType(unitSymbol.getType()) ||
int rpidx = -1; !symbol.getType().sameTypeParameters(unitSymbol.getType()) ||
if (!symbol.getType().sameElementType(unitSymbol.getType(), &lpidx, &rpidx)) { !arraysMatch ) {
if (lpidx >= 0 && rpidx >= 0) {
error(infoSink, "Member names and types must match:", unitStage);
infoSink.info << " Block: " << symbol.getType().getTypeName() << "\n";
infoSink.info << " " << StageName(getStage()) << " stage: \""
<< (*symbol.getType().getStruct())[lpidx].type->getCompleteString(true, false, false, true,
(*symbol.getType().getStruct())[lpidx].type->getFieldName()) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: \""
<< (*unitSymbol.getType().getStruct())[rpidx].type->getCompleteString(true, false, false, true,
(*unitSymbol.getType().getStruct())[rpidx].type->getFieldName()) << "\"\n";
errorReported = true;
} else if (lpidx >= 0 && rpidx == -1) {
TString errmsg = StageName(getStage());
errmsg.append(" block member has no corresponding member in ").append(StageName(unitStage)).append(" block:");
error(infoSink, errmsg.c_str(), unitStage);
infoSink.info << " " << StageName(getStage()) << " stage: Block: " << symbol.getType().getTypeName() << ", Member: "
<< (*symbol.getType().getStruct())[lpidx].type->getFieldName() << "\n";
infoSink.info << " " << StageName(unitStage) << " stage: Block: " << unitSymbol.getType().getTypeName() << ", Member: n/a \n";
errorReported = true;
} else if (lpidx == -1 && rpidx >= 0) {
TString errmsg = StageName(unitStage);
errmsg.append(" block member has no corresponding member in ").append(StageName(getStage())).append(" block:");
error(infoSink, errmsg.c_str(), unitStage);
infoSink.info << " " << StageName(unitStage) << " stage: Block: " << unitSymbol.getType().getTypeName() << ", Member: "
<< (*unitSymbol.getType().getStruct())[rpidx].type->getFieldName() << "\n";
infoSink.info << " " << StageName(getStage()) << " stage: Block: " << symbol.getType().getTypeName() << ", Member: n/a \n";
errorReported = true;
} else {
error(infoSink, "Types must match:", unitStage);
writeTypeComparison = true;
printType = true;
}
} else if (!arraysMatch) {
error(infoSink, "Array sizes must be compatible:", unitStage);
writeTypeComparison = true; writeTypeComparison = true;
printType = true; error(infoSink, "Types must match:");
} else if (!symbol.getType().sameTypeParameters(unitSymbol.getType())) {
error(infoSink, "Type parameters must match:", unitStage);
writeTypeComparison = true;
printType = true;
} }
} }
@ -914,51 +858,17 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
if (symbol.getType().getBasicType() == EbtBlock && unitSymbol.getType().getBasicType() == EbtBlock && if (symbol.getType().getBasicType() == EbtBlock && unitSymbol.getType().getBasicType() == EbtBlock &&
symbol.getType().getStruct() && unitSymbol.getType().getStruct() && symbol.getType().getStruct() && unitSymbol.getType().getStruct() &&
symbol.getType().sameStructType(unitSymbol.getType())) { symbol.getType().sameStructType(unitSymbol.getType())) {
unsigned int li = 0; for (unsigned int i = 0; i < symbol.getType().getStruct()->size(); ++i) {
unsigned int ri = 0; const TQualifier& qualifier = (*symbol.getType().getStruct())[i].type->getQualifier();
while (li < symbol.getType().getStruct()->size() && ri < unitSymbol.getType().getStruct()->size()) { const TQualifier& unitQualifier = (*unitSymbol.getType().getStruct())[i].type->getQualifier();
if ((*symbol.getType().getStruct())[li].type->hiddenMember()) { if (qualifier.layoutMatrix != unitQualifier.layoutMatrix ||
++li; qualifier.layoutOffset != unitQualifier.layoutOffset ||
continue; qualifier.layoutAlign != unitQualifier.layoutAlign ||
qualifier.layoutLocation != unitQualifier.layoutLocation ||
qualifier.layoutComponent != unitQualifier.layoutComponent) {
error(infoSink, "Interface block member layout qualifiers must match:");
writeTypeComparison = true;
} }
if ((*unitSymbol.getType().getStruct())[ri].type->hiddenMember()) {
++ri;
continue;
}
const TQualifier& qualifier = (*symbol.getType().getStruct())[li].type->getQualifier();
const TQualifier & unitQualifier = (*unitSymbol.getType().getStruct())[ri].type->getQualifier();
bool layoutQualifierError = false;
if (qualifier.layoutMatrix != unitQualifier.layoutMatrix) {
error(infoSink, "Interface block member layout matrix qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (qualifier.layoutOffset != unitQualifier.layoutOffset) {
error(infoSink, "Interface block member layout offset qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (qualifier.layoutAlign != unitQualifier.layoutAlign) {
error(infoSink, "Interface block member layout align qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (qualifier.layoutLocation != unitQualifier.layoutLocation) {
error(infoSink, "Interface block member layout location qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (qualifier.layoutComponent != unitQualifier.layoutComponent) {
error(infoSink, "Interface block member layout component qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (layoutQualifierError) {
infoSink.info << " " << StageName(getStage()) << " stage: Block: " << symbol.getType().getTypeName() << ", Member: "
<< (*symbol.getType().getStruct())[li].type->getFieldName() << " \""
<< (*symbol.getType().getStruct())[li].type->getCompleteString(true, true, false, false) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: Block: " << unitSymbol.getType().getTypeName() << ", Member: "
<< (*unitSymbol.getType().getStruct())[ri].type->getFieldName() << " \""
<< (*unitSymbol.getType().getStruct())[ri].type->getCompleteString(true, true, false, false) << "\"\n";
errorReported = true;
}
++li;
++ri;
} }
} }
@ -969,9 +879,8 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
// Qualifiers have to (almost) match // Qualifiers have to (almost) match
// Storage... // Storage...
if (!isInOut && symbol.getQualifier().storage != unitSymbol.getQualifier().storage) { if (!isInOut && symbol.getQualifier().storage != unitSymbol.getQualifier().storage) {
error(infoSink, "Storage qualifiers must match:", unitStage); error(infoSink, "Storage qualifiers must match:");
writeTypeComparison = true; writeTypeComparison = true;
printQualifiers = true;
} }
// Uniform and buffer blocks must either both have an instance name, or // Uniform and buffer blocks must either both have an instance name, or
@ -979,36 +888,33 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
if (symbol.getQualifier().isUniformOrBuffer() && if (symbol.getQualifier().isUniformOrBuffer() &&
(IsAnonymous(symbol.getName()) != IsAnonymous(unitSymbol.getName()))) { (IsAnonymous(symbol.getName()) != IsAnonymous(unitSymbol.getName()))) {
error(infoSink, "Matched Uniform or Storage blocks must all be anonymous," error(infoSink, "Matched Uniform or Storage blocks must all be anonymous,"
" or all be named:", unitStage); " or all be named:");
writeTypeComparison = true; writeTypeComparison = true;
} }
if (symbol.getQualifier().storage == unitSymbol.getQualifier().storage && if (symbol.getQualifier().storage == unitSymbol.getQualifier().storage &&
(IsAnonymous(symbol.getName()) != IsAnonymous(unitSymbol.getName()) || (IsAnonymous(symbol.getName()) != IsAnonymous(unitSymbol.getName()) ||
(!IsAnonymous(symbol.getName()) && symbol.getName() != unitSymbol.getName()))) { (!IsAnonymous(symbol.getName()) && symbol.getName() != unitSymbol.getName()))) {
warn(infoSink, "Matched shader interfaces are using different instance names.", unitStage); warn(infoSink, "Matched shader interfaces are using different instance names.");
writeTypeComparison = true; writeTypeComparison = true;
} }
// Precision... // Precision...
if (!isInOut && symbol.getQualifier().precision != unitSymbol.getQualifier().precision) { if (!isInOut && symbol.getQualifier().precision != unitSymbol.getQualifier().precision) {
error(infoSink, "Precision qualifiers must match:", unitStage); error(infoSink, "Precision qualifiers must match:");
writeTypeComparison = true; writeTypeComparison = true;
printPrecision = true;
} }
// Invariance... // Invariance...
if (! crossStage && symbol.getQualifier().invariant != unitSymbol.getQualifier().invariant) { if (! crossStage && symbol.getQualifier().invariant != unitSymbol.getQualifier().invariant) {
error(infoSink, "Presence of invariant qualifier must match:", unitStage); error(infoSink, "Presence of invariant qualifier must match:");
writeTypeComparison = true; writeTypeComparison = true;
printQualifiers = true;
} }
// Precise... // Precise...
if (! crossStage && symbol.getQualifier().isNoContraction() != unitSymbol.getQualifier().isNoContraction()) { if (! crossStage && symbol.getQualifier().isNoContraction() != unitSymbol.getQualifier().isNoContraction()) {
error(infoSink, "Presence of precise qualifier must match:", unitStage); error(infoSink, "Presence of precise qualifier must match:");
writeTypeComparison = true; writeTypeComparison = true;
printPrecision = true;
} }
// Auxiliary and interpolation... // Auxiliary and interpolation...
@ -1022,137 +928,57 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
symbol.getQualifier().isSample()!= unitSymbol.getQualifier().isSample() || symbol.getQualifier().isSample()!= unitSymbol.getQualifier().isSample() ||
symbol.getQualifier().isPatch() != unitSymbol.getQualifier().isPatch() || symbol.getQualifier().isPatch() != unitSymbol.getQualifier().isPatch() ||
symbol.getQualifier().isNonPerspective() != unitSymbol.getQualifier().isNonPerspective())) { symbol.getQualifier().isNonPerspective() != unitSymbol.getQualifier().isNonPerspective())) {
error(infoSink, "Interpolation and auxiliary storage qualifiers must match:", unitStage); error(infoSink, "Interpolation and auxiliary storage qualifiers must match:");
writeTypeComparison = true; writeTypeComparison = true;
printQualifiers = true;
} }
// Memory... // Memory...
bool memoryQualifierError = false; if (symbol.getQualifier().coherent != unitSymbol.getQualifier().coherent ||
if (symbol.getQualifier().coherent != unitSymbol.getQualifier().coherent) { symbol.getQualifier().devicecoherent != unitSymbol.getQualifier().devicecoherent ||
error(infoSink, "Memory coherent qualifier must match:", unitStage); symbol.getQualifier().queuefamilycoherent != unitSymbol.getQualifier().queuefamilycoherent ||
memoryQualifierError = true; symbol.getQualifier().workgroupcoherent != unitSymbol.getQualifier().workgroupcoherent ||
} symbol.getQualifier().subgroupcoherent != unitSymbol.getQualifier().subgroupcoherent ||
if (symbol.getQualifier().devicecoherent != unitSymbol.getQualifier().devicecoherent) { symbol.getQualifier().shadercallcoherent!= unitSymbol.getQualifier().shadercallcoherent ||
error(infoSink, "Memory devicecoherent qualifier must match:", unitStage); symbol.getQualifier().nonprivate != unitSymbol.getQualifier().nonprivate ||
memoryQualifierError = true; symbol.getQualifier().volatil != unitSymbol.getQualifier().volatil ||
} symbol.getQualifier().restrict != unitSymbol.getQualifier().restrict ||
if (symbol.getQualifier().queuefamilycoherent != unitSymbol.getQualifier().queuefamilycoherent) { symbol.getQualifier().readonly != unitSymbol.getQualifier().readonly ||
error(infoSink, "Memory queuefamilycoherent qualifier must match:", unitStage); symbol.getQualifier().writeonly != unitSymbol.getQualifier().writeonly) {
memoryQualifierError = true; error(infoSink, "Memory qualifiers must match:");
} writeTypeComparison = true;
if (symbol.getQualifier().workgroupcoherent != unitSymbol.getQualifier().workgroupcoherent) {
error(infoSink, "Memory workgroupcoherent qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().subgroupcoherent != unitSymbol.getQualifier().subgroupcoherent) {
error(infoSink, "Memory subgroupcoherent qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().shadercallcoherent != unitSymbol.getQualifier().shadercallcoherent) {
error(infoSink, "Memory shadercallcoherent qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().nonprivate != unitSymbol.getQualifier().nonprivate) {
error(infoSink, "Memory nonprivate qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().volatil != unitSymbol.getQualifier().volatil) {
error(infoSink, "Memory volatil qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().restrict != unitSymbol.getQualifier().restrict) {
error(infoSink, "Memory restrict qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().readonly != unitSymbol.getQualifier().readonly) {
error(infoSink, "Memory readonly qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (symbol.getQualifier().writeonly != unitSymbol.getQualifier().writeonly) {
error(infoSink, "Memory writeonly qualifier must match:", unitStage);
memoryQualifierError = true;
}
if (memoryQualifierError) {
writeTypeComparison = true;
printQualifiers = true;
} }
// Layouts... // Layouts...
// TODO: 4.4 enhanced layouts: Generalize to include offset/align: current spec // TODO: 4.4 enhanced layouts: Generalize to include offset/align: current spec
// requires separate user-supplied offset from actual computed offset, but // requires separate user-supplied offset from actual computed offset, but
// current implementation only has one offset. // current implementation only has one offset.
bool layoutQualifierError = false; if (symbol.getQualifier().layoutMatrix != unitSymbol.getQualifier().layoutMatrix ||
if (symbol.getQualifier().layoutMatrix != unitSymbol.getQualifier().layoutMatrix) { symbol.getQualifier().layoutPacking != unitSymbol.getQualifier().layoutPacking ||
error(infoSink, "Layout matrix qualifier must match:", unitStage); symbol.getQualifier().layoutLocation != unitSymbol.getQualifier().layoutLocation ||
layoutQualifierError = true; symbol.getQualifier().layoutComponent != unitSymbol.getQualifier().layoutComponent ||
} symbol.getQualifier().layoutIndex != unitSymbol.getQualifier().layoutIndex ||
if (symbol.getQualifier().layoutPacking != unitSymbol.getQualifier().layoutPacking) { symbol.getQualifier().layoutBinding != unitSymbol.getQualifier().layoutBinding ||
error(infoSink, "Layout packing qualifier must match:", unitStage); (symbol.getQualifier().hasBinding() && (symbol.getQualifier().layoutOffset != unitSymbol.getQualifier().layoutOffset))) {
layoutQualifierError = true; error(infoSink, "Layout qualification must match:");
}
if (symbol.getQualifier().hasLocation() && unitSymbol.getQualifier().hasLocation() && symbol.getQualifier().layoutLocation != unitSymbol.getQualifier().layoutLocation) {
error(infoSink, "Layout location qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().layoutComponent != unitSymbol.getQualifier().layoutComponent) {
error(infoSink, "Layout component qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().layoutIndex != unitSymbol.getQualifier().layoutIndex) {
error(infoSink, "Layout index qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().hasBinding() && unitSymbol.getQualifier().hasBinding() && symbol.getQualifier().layoutBinding != unitSymbol.getQualifier().layoutBinding) {
error(infoSink, "Layout binding qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (symbol.getQualifier().hasBinding() && (symbol.getQualifier().layoutOffset != unitSymbol.getQualifier().layoutOffset)) {
error(infoSink, "Layout offset qualifier must match:", unitStage);
layoutQualifierError = true;
}
if (layoutQualifierError) {
writeTypeComparison = true; writeTypeComparison = true;
printQualifiers = true;
} }
// Initializers have to match, if both are present, and if we don't already know the types don't match // Initializers have to match, if both are present, and if we don't already know the types don't match
if (! writeTypeComparison && ! errorReported) { if (! writeTypeComparison) {
if (! symbol.getConstArray().empty() && ! unitSymbol.getConstArray().empty()) { if (! symbol.getConstArray().empty() && ! unitSymbol.getConstArray().empty()) {
if (symbol.getConstArray() != unitSymbol.getConstArray()) { if (symbol.getConstArray() != unitSymbol.getConstArray()) {
error(infoSink, "Initializers must match:", unitStage); error(infoSink, "Initializers must match:");
infoSink.info << " " << symbol.getName() << "\n"; infoSink.info << " " << symbol.getName() << "\n";
} }
} }
} }
if (writeTypeComparison) { if (writeTypeComparison) {
if (symbol.getType().getBasicType() == EbtBlock && unitSymbol.getType().getBasicType() == EbtBlock && infoSink.info << " " << symbol.getName() << ": \"" << symbol.getType().getCompleteString() << "\" versus ";
symbol.getType().getStruct() && unitSymbol.getType().getStruct()) { if (symbol.getName() != unitSymbol.getName())
if (printType) { infoSink.info << unitSymbol.getName() << ": ";
infoSink.info << " " << StageName(getStage()) << " stage: \"" << symbol.getType().getCompleteString(true, printQualifiers, printPrecision,
printType, symbol.getName(), symbol.getType().getTypeName()) << "\"\n"; infoSink.info << "\"" << unitSymbol.getType().getCompleteString() << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: \"" << unitSymbol.getType().getCompleteString(true, printQualifiers, printPrecision,
printType, unitSymbol.getName(), unitSymbol.getType().getTypeName()) << "\"\n";
} else {
infoSink.info << " " << StageName(getStage()) << " stage: Block: " << symbol.getType().getTypeName() << " Instance: " << symbol.getName()
<< ": \"" << symbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: Block: " << unitSymbol.getType().getTypeName() << " Instance: " << unitSymbol.getName()
<< ": \"" << unitSymbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType) << "\"\n";
}
} else {
if (printType) {
infoSink.info << " " << StageName(getStage()) << " stage: \""
<< symbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType, symbol.getName()) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: \""
<< unitSymbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType, unitSymbol.getName()) << "\"\n";
} else {
infoSink.info << " " << StageName(getStage()) << " stage: " << symbol.getName() << " \""
<< symbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType) << "\"\n";
infoSink.info << " " << StageName(unitStage) << " stage: " << unitSymbol.getName() << " \""
<< unitSymbol.getType().getCompleteString(true, printQualifiers, printPrecision, printType) << "\"\n";
}
}
} }
#endif #endif
} }
@ -1960,7 +1786,7 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
return size; return size;
} }
int numComponents {0}; int numComponents;
if (type.isScalar()) if (type.isScalar())
numComponents = 1; numComponents = 1;
else if (type.isVector()) else if (type.isVector())
@ -2108,7 +1934,7 @@ int TIntermediate::getBaseAlignment(const TType& type, int& size, int& stride, T
} }
// rule 9 // rule 9
if (type.getBasicType() == EbtStruct || type.getBasicType() == EbtBlock) { if (type.getBasicType() == EbtStruct) {
const TTypeList& memberList = *type.getStruct(); const TTypeList& memberList = *type.getStruct();
size = 0; size = 0;
@ -2333,11 +2159,10 @@ int TIntermediate::computeBufferReferenceTypeSize(const TType& type)
bool TIntermediate::isIoResizeArray(const TType& type, EShLanguage language) { bool TIntermediate::isIoResizeArray(const TType& type, EShLanguage language) {
return type.isArray() && return type.isArray() &&
((language == EShLangGeometry && type.getQualifier().storage == EvqVaryingIn) || ((language == EShLangGeometry && type.getQualifier().storage == EvqVaryingIn) ||
(language == EShLangTessControl && (type.getQualifier().storage == EvqVaryingIn || type.getQualifier().storage == EvqVaryingOut) && (language == EShLangTessControl && type.getQualifier().storage == EvqVaryingOut &&
! type.getQualifier().patch) || ! type.getQualifier().patch) ||
(language == EShLangTessEvaluation && type.getQualifier().storage == EvqVaryingIn) ||
(language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn && (language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn &&
(type.getQualifier().pervertexNV || type.getQualifier().pervertexEXT)) || type.getQualifier().pervertexNV) ||
(language == EShLangMeshNV && type.getQualifier().storage == EvqVaryingOut && (language == EShLangMeshNV && type.getQualifier().storage == EvqVaryingOut &&
!type.getQualifier().perTaskNV)); !type.getQualifier().perTaskNV));
} }

View file

@ -290,8 +290,6 @@ public:
resources(TBuiltInResource{}), resources(TBuiltInResource{}),
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false), numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
invertY(false), invertY(false),
dxPositionW(false),
enhancedMsgs(false),
useStorageBuffer(false), useStorageBuffer(false),
invariantAll(false), invariantAll(false),
nanMinMaxClamp(false), nanMinMaxClamp(false),
@ -309,7 +307,7 @@ public:
useVulkanMemoryModel(false), useVulkanMemoryModel(false),
invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet), invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet),
inputPrimitive(ElgNone), outputPrimitive(ElgNone), inputPrimitive(ElgNone), outputPrimitive(ElgNone),
pixelCenterInteger(false), originUpperLeft(false),texCoordBuiltinRedeclared(false), pixelCenterInteger(false), originUpperLeft(false),
vertexSpacing(EvsNone), vertexOrder(EvoNone), interlockOrdering(EioNone), pointMode(false), earlyFragmentTests(false), vertexSpacing(EvsNone), vertexOrder(EvoNone), interlockOrdering(EioNone), pointMode(false), earlyFragmentTests(false),
postDepthCoverage(false), depthLayout(EldNone), postDepthCoverage(false), depthLayout(EldNone),
hlslFunctionality1(false), hlslFunctionality1(false),
@ -399,9 +397,6 @@ public:
case EShTargetSpv_1_5: case EShTargetSpv_1_5:
processes.addProcess("target-env spirv1.5"); processes.addProcess("target-env spirv1.5");
break; break;
case EShTargetSpv_1_6:
processes.addProcess("target-env spirv1.6");
break;
default: default:
processes.addProcess("target-env spirvUnknown"); processes.addProcess("target-env spirvUnknown");
break; break;
@ -420,9 +415,6 @@ public:
case EShTargetVulkan_1_2: case EShTargetVulkan_1_2:
processes.addProcess("target-env vulkan1.2"); processes.addProcess("target-env vulkan1.2");
break; break;
case EShTargetVulkan_1_3:
processes.addProcess("target-env vulkan1.3");
break;
default: default:
processes.addProcess("target-env vulkanUnknown"); processes.addProcess("target-env vulkanUnknown");
break; break;
@ -468,20 +460,6 @@ public:
} }
bool getInvertY() const { return invertY; } bool getInvertY() const { return invertY; }
void setDxPositionW(bool dxPosW)
{
dxPositionW = dxPosW;
if (dxPositionW)
processes.addProcess("dx-position-w");
}
bool getDxPositionW() const { return dxPositionW; }
void setEnhancedMsgs()
{
enhancedMsgs = true;
}
bool getEnhancedMsgs() const { return enhancedMsgs && source == EShSourceGlsl; }
#ifdef ENABLE_HLSL #ifdef ENABLE_HLSL
void setSource(EShSource s) { source = s; } void setSource(EShSource s) { source = s; }
EShSource getSource() const { return source; } EShSource getSource() const { return source; }
@ -834,8 +812,6 @@ public:
bool getOriginUpperLeft() const { return originUpperLeft; } bool getOriginUpperLeft() const { return originUpperLeft; }
void setPixelCenterInteger() { pixelCenterInteger = true; } void setPixelCenterInteger() { pixelCenterInteger = true; }
bool getPixelCenterInteger() const { return pixelCenterInteger; } bool getPixelCenterInteger() const { return pixelCenterInteger; }
void setTexCoordRedeclared() { texCoordBuiltinRedeclared = true; }
bool getTexCoordRedeclared() const { return texCoordBuiltinRedeclared; }
void addBlendEquation(TBlendEquationShift b) { blendEquations |= (1 << b); } void addBlendEquation(TBlendEquationShift b) { blendEquations |= (1 << b); }
unsigned int getBlendEquations() const { return blendEquations; } unsigned int getBlendEquations() const { return blendEquations; }
bool setXfbBufferStride(int buffer, unsigned stride) bool setXfbBufferStride(int buffer, unsigned stride)
@ -1040,8 +1016,8 @@ public:
protected: protected:
TIntermSymbol* addSymbol(long long Id, const TString&, const TType&, const TConstUnionArray&, TIntermTyped* subtree, const TSourceLoc&); TIntermSymbol* addSymbol(long long Id, const TString&, const TType&, const TConstUnionArray&, TIntermTyped* subtree, const TSourceLoc&);
void error(TInfoSink& infoSink, const char*, EShLanguage unitStage = EShLangCount); void error(TInfoSink& infoSink, const char*);
void warn(TInfoSink& infoSink, const char*, EShLanguage unitStage = EShLangCount); void warn(TInfoSink& infoSink, const char*);
void mergeCallGraphs(TInfoSink&, TIntermediate&); void mergeCallGraphs(TInfoSink&, TIntermediate&);
void mergeModes(TInfoSink&, TIntermediate&); void mergeModes(TInfoSink&, TIntermediate&);
void mergeTrees(TInfoSink&, TIntermediate&); void mergeTrees(TInfoSink&, TIntermediate&);
@ -1094,8 +1070,6 @@ protected:
int numPushConstants; int numPushConstants;
bool recursive; bool recursive;
bool invertY; bool invertY;
bool dxPositionW;
bool enhancedMsgs;
bool useStorageBuffer; bool useStorageBuffer;
bool invariantAll; bool invariantAll;
bool nanMinMaxClamp; // true if desiring min/max/clamp to favor non-NaN over NaN bool nanMinMaxClamp; // true if desiring min/max/clamp to favor non-NaN over NaN
@ -1124,7 +1098,6 @@ protected:
TLayoutGeometry outputPrimitive; TLayoutGeometry outputPrimitive;
bool pixelCenterInteger; bool pixelCenterInteger;
bool originUpperLeft; bool originUpperLeft;
bool texCoordBuiltinRedeclared;
TVertexSpacing vertexSpacing; TVertexSpacing vertexSpacing;
TVertexOrder vertexOrder; TVertexOrder vertexOrder;
TInterlockOrdering interlockOrdering; TInterlockOrdering interlockOrdering;
@ -1185,7 +1158,6 @@ protected:
// for callableData/callableDataIn // for callableData/callableDataIn
// set of names of statically read/written I/O that might need extra checking // set of names of statically read/written I/O that might need extra checking
std::set<TString> ioAccessed; std::set<TString> ioAccessed;
// source code of shader, useful as part of debug information // source code of shader, useful as part of debug information
std::string sourceFile; std::string sourceFile;
std::string sourceText; std::string sourceText;

Some files were not shown because too many files have changed in this diff Show more