Explorar o código

Update DXC and add windows arm64 DLLs

Panagiotis Christopoulos Charitos hai 7 meses
pai
achega
e02d4cdf55

+ 1 - 1
AnKi/Config.h.cmake

@@ -109,7 +109,7 @@
 #		define ANKI_CPU_ARCH_ARM 0
 #	endif
 #elif ANKI_COMPILER_MSVC
-#	if defined(_M_ARM)
+#	if defined(_M_ARM) || defined(_M_ARM64)
 #		define ANKI_CPU_ARCH_X86 0
 #		define ANKI_CPU_ARCH_ARM 1
 #	elif defined(_M_X64) || defined(_M_IX86)

+ 15 - 7
AnKi/ShaderCompiler/Dxc.cpp

@@ -14,17 +14,17 @@
 #if ANKI_OS_WINDOWS
 #	include <windows.h>
 #	include <wrl/client.h>
-#	include <ThirdParty/Dxc/d3d12shader.h>
+#	include <ThirdParty/Dxc/Include/d3d12shader.h>
 #	define CComPtr Microsoft::WRL::ComPtr
 #else
 #	pragma GCC diagnostic push
 #	pragma GCC diagnostic ignored "-Wimplicit-int-conversion"
 #	pragma GCC diagnostic ignored "-Wambiguous-reversed-operator"
 #	define __EMULATE_UUID
-#	include <ThirdParty/Dxc/WinAdapter.h>
+#	include <ThirdParty/Dxc/Include/WinAdapter.h>
 #	pragma GCC diagnostic pop
 #endif
-#include <ThirdParty/Dxc/dxcapi.h>
+#include <ThirdParty/Dxc/Include/dxcapi.h>
 
 namespace anki {
 
@@ -56,16 +56,24 @@ static Error lazyDxcInit(ShaderCompilerString& errorMessage)
 	{
 		// Init DXC
 #if ANKI_OS_WINDOWS
-		g_dxilLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/dxil.dll");
+#	if ANKI_CPU_ARCH_X86
+		g_dxilLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/Lib/WinX64/dxil.dll");
+#	else
+		g_dxilLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/Lib/WinArm64/dxil.dll");
+#	endif
 		if(g_dxilLib == 0)
 		{
 			errorMessage = "dxil.dll missing or wrong architecture";
 			return Error::kFunctionFailed;
 		}
 
-		g_dxcLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/dxcompiler.dll");
+#	if ANKI_CPU_ARCH_X86
+		g_dxcLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/Lib/WinX64/dxcompiler.dll");
+#	else
+		g_dxcLib = LoadLibraryA(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/Lib/WinArm64/dxcompiler.dll");
+#	endif
 #else
-		g_dxcLib = dlopen(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/libdxcompiler.so", RTLD_LAZY);
+		g_dxcLib = dlopen(ANKI_SOURCE_DIRECTORY "/ThirdParty/Dxc/Lib/LinuxX64/libdxcompiler.so", RTLD_LAZY);
 #endif
 		if(g_dxcLib == 0)
 		{
@@ -482,7 +490,7 @@ Error doReflectionDxil(ConstWeakArray<U8> dxil, ShaderType type, ShaderReflectio
 			ANKI_DXC_CHECK(dxRefl->GetInputParameterDesc(i, &in));
 
 			VertexAttributeSemantic a = VertexAttributeSemantic::kCount;
-#	define ANKI_ATTRIB_NAME(x, idx) CString(in.SemanticName) == #    x&& in.SemanticIndex == idx
+#	define ANKI_ATTRIB_NAME(x, idx) CString(in.SemanticName) == #x&& in.SemanticIndex == idx
 			if(ANKI_ATTRIB_NAME(POSITION, 0))
 			{
 				a = VertexAttributeSemantic::kPosition;

+ 155 - 0
ThirdParty/Dxc/Include/Support/ErrorCodes.h

@@ -0,0 +1,155 @@
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// ErrorCodes.h                                                              //
+// Copyright (C) Microsoft Corporation. All rights reserved.                 //
+// This file is distributed under the University of Illinois Open Source     //
+// License. See LICENSE.TXT for details.                                     //
+//                                                                           //
+// Provides error code values for the DirectX compiler and tools.            //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+// Redeclare some macros to not depend on winerror.h
+#define DXC_SEVERITY_ERROR 1
+#define DXC_MAKE_HRESULT(sev, fac, code)                                       \
+  ((HRESULT)(((unsigned long)(sev) << 31) | ((unsigned long)(fac) << 16) |     \
+             ((unsigned long)(code))))
+
+#define HRESULT_IS_WIN32ERR(hr)                                                \
+  ((HRESULT)(hr & 0xFFFF0000) ==                                               \
+   MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, 0))
+#define HRESULT_AS_WIN32ERR(hr) (HRESULT_CODE(hr))
+
+// Error codes from C libraries (0n150) - 0x8096xxxx
+#define FACILITY_ERRNO (0x96)
+#define HRESULT_FROM_ERRNO(x)                                                  \
+  MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_ERRNO, (x))
+
+// Error codes from DXC libraries (0n170) - 0x8013xxxx
+#define FACILITY_DXC (0xAA)
+
+// 0x00000000 - The operation succeeded.
+#define DXC_S_OK 0 // _HRESULT_TYPEDEF_(0x00000000L)
+
+// 0x80AA0001 - The operation failed because overlapping semantics were found.
+#define DXC_E_OVERLAPPING_SEMANTICS                                            \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0001))
+
+// 0x80AA0002 - The operation failed because multiple depth semantics were
+// found.
+#define DXC_E_MULTIPLE_DEPTH_SEMANTICS                                         \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0002))
+
+// 0x80AA0003 - Input file is too large.
+#define DXC_E_INPUT_FILE_TOO_LARGE                                             \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0003))
+
+// 0x80AA0004 - Error parsing DXBC container.
+#define DXC_E_INCORRECT_DXBC                                                   \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0004))
+
+// 0x80AA0005 - Error parsing DXBC bytecode.
+#define DXC_E_ERROR_PARSING_DXBC_BYTECODE                                      \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0005))
+
+// 0x80AA0006 - Data is too large.
+#define DXC_E_DATA_TOO_LARGE                                                   \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0006))
+
+// 0x80AA0007 - Incompatible converter options.
+#define DXC_E_INCOMPATIBLE_CONVERTER_OPTIONS                                   \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0007))
+
+// 0x80AA0008 - Irreducible control flow graph.
+#define DXC_E_IRREDUCIBLE_CFG                                                  \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0008))
+
+// 0x80AA0009 - IR verification error.
+#define DXC_E_IR_VERIFICATION_FAILED                                           \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0009))
+
+// 0x80AA000A - Scope-nested control flow recovery failed.
+#define DXC_E_SCOPE_NESTED_FAILED                                              \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000A))
+
+// 0x80AA000B - Operation is not supported.
+#define DXC_E_NOT_SUPPORTED                                                    \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000B))
+
+// 0x80AA000C - Unable to encode string.
+#define DXC_E_STRING_ENCODING_FAILED                                           \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000C))
+
+// 0x80AA000D - DXIL container is invalid.
+#define DXC_E_CONTAINER_INVALID                                                \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000D))
+
+// 0x80AA000E - DXIL container is missing the DXIL part.
+#define DXC_E_CONTAINER_MISSING_DXIL                                           \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000E))
+
+// 0x80AA000F - Unable to parse DxilModule metadata.
+#define DXC_E_INCORRECT_DXIL_METADATA                                          \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x000F))
+
+// 0x80AA0010 - Error parsing DDI signature.
+#define DXC_E_INCORRECT_DDI_SIGNATURE                                          \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0010))
+
+// 0x80AA0011 - Duplicate part exists in dxil container.
+#define DXC_E_DUPLICATE_PART                                                   \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0011))
+
+// 0x80AA0012 - Error finding part in dxil container.
+#define DXC_E_MISSING_PART                                                     \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0012))
+
+// 0x80AA0013 - Malformed DXIL Container.
+#define DXC_E_MALFORMED_CONTAINER                                              \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0013))
+
+// 0x80AA0014 - Incorrect Root Signature for shader.
+#define DXC_E_INCORRECT_ROOT_SIGNATURE                                         \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0014))
+
+// 0X80AA0015 - DXIL container is missing DebugInfo part.
+#define DXC_E_CONTAINER_MISSING_DEBUG                                          \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0015))
+
+// 0X80AA0016 - Unexpected failure in macro expansion.
+#define DXC_E_MACRO_EXPANSION_FAILURE                                          \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0016))
+
+// 0X80AA0017 - DXIL optimization pass failed.
+#define DXC_E_OPTIMIZATION_FAILED                                              \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0017))
+
+// 0X80AA0018 - General internal error.
+#define DXC_E_GENERAL_INTERNAL_ERROR                                           \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0018))
+
+// 0X80AA0019 - Abort compilation error.
+#define DXC_E_ABORT_COMPILATION_ERROR                                          \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x0019))
+
+// 0X80AA001A - Error in extension mechanism.
+#define DXC_E_EXTENSION_ERROR                                                  \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001A))
+
+// 0X80AA001B - LLVM Fatal Error
+#define DXC_E_LLVM_FATAL_ERROR                                                 \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001B))
+
+// 0X80AA001C - LLVM Unreachable code
+#define DXC_E_LLVM_UNREACHABLE                                                 \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001C))
+
+// 0X80AA001D - LLVM Cast Failure
+#define DXC_E_LLVM_CAST_ERROR                                                  \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001D))
+
+// 0X80AA001E - External validator (DXIL.dll) required, and missing.
+#define DXC_E_VALIDATOR_MISSING                                                \
+  DXC_MAKE_HRESULT(DXC_SEVERITY_ERROR, FACILITY_DXC, (0x001E))

+ 0 - 0
ThirdParty/Dxc/WinAdapter.h → ThirdParty/Dxc/Include/WinAdapter.h


+ 0 - 0
ThirdParty/Dxc/d3d12shader.h → ThirdParty/Dxc/Include/d3d12shader.h


+ 0 - 0
ThirdParty/Dxc/dxcapi.h → ThirdParty/Dxc/Include/dxcapi.h


+ 0 - 0
ThirdParty/Dxc/dxcerrors.h → ThirdParty/Dxc/Include/dxcerrors.h


+ 0 - 0
ThirdParty/Dxc/dxcisense.h → ThirdParty/Dxc/Include/dxcisense.h


+ 222 - 0
ThirdParty/Dxc/Include/hlsl/LICENSE.txt

@@ -0,0 +1,222 @@
+==============================================================================
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+    TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+    1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+    2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+    3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+    4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+    5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+    6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+    7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+    8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+    9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+    END OF TERMS AND CONDITIONS
+
+    APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+    Copyright [yyyy] [name of copyright owner]
+
+    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.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.

+ 7 - 0
ThirdParty/Dxc/Include/hlsl/README.txt

@@ -0,0 +1,7 @@
+HLSL Standard Header Library
+============================
+
+The contents of this directory and subdirectories are the HLSL Standard Header
+library. These headers are open source software. You may freely distribute all
+or parts of these headers under the terms of the license agreement found in
+LICENSE.txt.

+ 275 - 0
ThirdParty/Dxc/Include/hlsl/vk/khr/cooperative_matrix.h

@@ -0,0 +1,275 @@
+// Copyright (c) 2024 Google LLC
+//
+// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+#ifndef _HLSL_VK_KHR_COOPERATIVE_MATRIX_H_
+#define _HLSL_VK_KHR_COOPERATIVE_MATRIX_H_
+
+#if __SPIRV_MAJOR_VERSION__ == 1 && __SPIRV_MINOR_VERSION__ < 6
+#error "CooperativeMatrix requires a minimum of SPIR-V 1.6"
+#endif
+
+#include "vk/spirv.h"
+
+namespace vk {
+namespace khr {
+
+// The base cooperative matrix class. The template arguments correspond to the
+// operands in the OpTypeCooperativeMatrixKHR instruction.
+template <typename ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+class CooperativeMatrix {
+  template <class NewComponentType>
+  CooperativeMatrix<NewComponentType, scope, rows, columns, use> cast();
+
+  // Apply OpSNegate or OFNegate, depending on ComponentType, in a element by
+  // element manner.
+  CooperativeMatrix negate();
+
+  // Apply OpIAdd or OFAdd, depending on ComponentType, in a element by element
+  // manner.
+  CooperativeMatrix operator+(CooperativeMatrix other);
+
+  // Apply OpISub or OFSub, depending on ComponentType, in a element by element
+  // manner.
+  CooperativeMatrix operator-(CooperativeMatrix other);
+
+  // Apply OpIMul or OFMul, depending on ComponentType, in a element by element
+  // manner.
+  CooperativeMatrix operator*(CooperativeMatrix other);
+
+  // Apply OpSDiv, OpUDiv or OFDiv, depending on ComponentType, in a element by
+  // element manner.
+  CooperativeMatrix operator/(CooperativeMatrix other);
+
+  // Apply OpMatrixTimesScalar in a element by element manner.
+  CooperativeMatrix operator*(ComponentType scalar);
+
+  // Store the cooperative matrix using OpCooperativeMatrixStoreKHR to
+  // data using the given memory layout, stride, and memory access operands.
+  // `NonPrivatePointer` and `MakePointerAvailable` with the workgroup scope
+  // will be added to the memory access operands to make the memory coherent.
+  //
+  // This function uses a SPIR-V pointer because HLSL does not allow groupshared
+  // memory object to be passed by reference. The pointer is a hack to get
+  // around that.
+  //
+  // The layout and stride will be passed to the SPIR-V instruction as is. The
+  // precise meaning can be found in the specification for
+  // SPV_KHR_cooperative_matrix.
+  template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+            class Type>
+  void Store(WorkgroupSpirvPointer<Type> data, uint32_t stride);
+
+  // Same as above, but uses MemoryAccessMaskNone for the memory access
+  // operands.
+  template <CooperativeMatrixLayout layout, class Type>
+  void Store(WorkgroupSpirvPointer<Type> data, uint32_t stride) {
+    Store<MemoryAccessMaskNone, layout>(data, stride);
+  }
+
+  // Store the cooperative matrix using OpCooperativeMatrixStoreKHR to
+  // data[index] using the given memory layout, stride, and memory access
+  // operands. The layout and stride will be passed to the SPIR-V instruction as
+  // is. The precise meaning can be found in the specification for
+  // SPV_KHR_cooperative_matrix.
+  template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+            class Type>
+  void Store(RWStructuredBuffer<Type> data, uint32_t index, uint32_t stride);
+
+  // Same as above, but uses MemoryAccessMaskNone for the memory access
+  // operands.
+  template <CooperativeMatrixLayout layout, class Type>
+  void Store(RWStructuredBuffer<Type> data, uint32_t index, uint32_t stride) {
+    Store<MemoryAccessMaskNone, layout>(data, index, stride);
+  }
+
+  // Store the cooperative matrix using OpCooperativeMatrixStoreKHR to
+  // data[index] using the given memory layout, stride, and memory access
+  // operands. `NonPrivatePointer` and `MakePointerAvailable` with the
+  // QueueFamily scope will be added to the memory access operands to make the
+  // memory coherent.
+  //
+  // The layout and stride will be passed to the SPIR-V instruction as is. The
+  // precise meaning can be found in the specification for
+  // SPV_KHR_cooperative_matrix.
+  template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+            class Type>
+  void CoherentStore(globallycoherent RWStructuredBuffer<Type> data,
+                     uint32_t index, uint32_t stride);
+
+  // Same as above, but uses MemoryAccessMaskNone for the memory access operands
+  // template argument.
+  template <CooperativeMatrixLayout layout, class Type>
+  void CoherentStore(globallycoherent RWStructuredBuffer<Type> data,
+                     uint32_t index, uint32_t stride) {
+    CoherentStore<MemoryAccessMaskNone, layout>(data, index, stride);
+  }
+
+  // Loads a cooperative matrix using OpCooperativeMatrixLoadKHR from
+  // data using the given memory layout, stride, and memory access operands.
+  // `NonPrivatePointer` and `MakePointerVisible` with the workgroup scope
+  // will be added to the memory access operands to make the memory coherent.
+  //
+  // This function uses a SPIR-V pointer because HLSL does not allow groupshared
+  // memory object to be passed by reference. The pointer is a hack to get
+  // around that.
+  //
+  // The layout and stride will be passed to the SPIR-V instruction as is. The
+  // precise meaning can be found in the specification for
+  // SPV_KHR_cooperative_matrix.
+  template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+            class Type>
+  static CooperativeMatrix Load(WorkgroupSpirvPointer<Type> data,
+                                uint32_t stride);
+
+  // Same as above, but uses MemoryAccessMaskNone for the memory access
+  // operands.
+  template <CooperativeMatrixLayout layout, class Type>
+  static CooperativeMatrix Load(WorkgroupSpirvPointer<Type> data,
+                                uint32_t stride) {
+    return Load<MemoryAccessMaskNone, layout>(data, stride);
+  }
+
+  // Loads a cooperative matrix using OpCooperativeMatrixLoadKHR from
+  // data[index] using the given memory layout, stride, and memory access
+  // operands.
+  //
+  // The layout and stride will be passed to the SPIR-V instruction as is. The
+  // precise meaning can be found in the specification for
+  // SPV_KHR_cooperative_matrix.
+  template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+            class Type>
+  static CooperativeMatrix Load(RWStructuredBuffer<Type> data, uint32_t index,
+                                uint32_t stride);
+
+  // Same as above, but uses MemoryAccessMaskNone for the memory access
+  // operands.
+  template <CooperativeMatrixLayout layout, class Type>
+  static CooperativeMatrix Load(RWStructuredBuffer<Type> data, uint32_t index,
+                                uint32_t stride) {
+    return Load<MemoryAccessMaskNone, layout>(data, index, stride);
+  }
+
+  // Loads a cooperative matrix using OpCooperativeMatrixLoadKHR from
+  // data[index] using the given memory layout, stride, and memory access
+  // operands. `NonPrivatePointer` and `MakePointerVisible` with the QueueFamily
+  // scope will be added to the memory access operands to make the memory
+  // coherent.
+  //
+  //
+  // The layout and stride will be passed to the SPIR-V instruction as is. The
+  // precise meaning can be found in the specification for
+  // SPV_KHR_cooperative_matrix.
+  template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+            class Type>
+  static CooperativeMatrix
+  CoherentLoad(globallycoherent RWStructuredBuffer<Type> data, uint32_t index,
+               uint32_t stride);
+
+  // Same as above, but uses MemoryAccessMaskNone for the memory access operands
+  // template argument.
+  template <CooperativeMatrixLayout layout, class Type>
+  static CooperativeMatrix
+  CoherentLoad(globallycoherent RWStructuredBuffer<Type> data, uint32_t index,
+               uint32_t stride) {
+    return CoherentLoad<MemoryAccessMaskNone, layout>(data, index, stride);
+  }
+
+  // Loads a cooperative matrix using OpCooperativeMatrixLoadKHR from
+  // data[index] using the given memory layout, stride, and memory access
+  // operands. No memory access bits are added to the operands. Since the memory
+  // is readonly, there should be no need.
+  //
+  // The layout and stride will be passed to the SPIR-V instruction as is. The
+  // precise meaning can be found in the specification for
+  // SPV_KHR_cooperative_matrix.
+  template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+            class Type>
+  static CooperativeMatrix Load(StructuredBuffer<Type> data, uint32_t index,
+                                uint32_t stride);
+
+  // Same as above, but uses MemoryAccessMaskNone for the memory access
+  // operands.
+  template <CooperativeMatrixLayout layout, class Type>
+  static CooperativeMatrix Load(StructuredBuffer<Type> data, uint32_t index,
+                                uint32_t stride) {
+    return Load<MemoryAccessMaskNone, layout>(data, index, stride);
+  }
+
+  // Constructs a cooperative matrix with all values initialized to v. Note that
+  // all threads in scope must have the same value for v.
+  static CooperativeMatrix Splat(ComponentType v);
+
+  // Returns the result of OpCooperativeMatrixLengthKHR on the current type.
+  static uint32_t GetLength();
+
+  // Functions to access the elements of the cooperative matrix. The index must
+  // be less than GetLength().
+  void Set(ComponentType value, uint32_t index);
+  ComponentType Get(uint32_t index);
+
+  static const bool hasSignedIntegerComponentType =
+      (ComponentType(0) - ComponentType(1) < ComponentType(0));
+
+  // clang-format off
+  using SpirvMatrixType = vk::SpirvOpaqueType<
+      /* OpTypeCooperativeMatrixKHR */ 4456, ComponentType,
+      vk::integral_constant<uint, scope>, vk::integral_constant<uint, rows>,
+      vk::integral_constant<uint, columns>, vk::integral_constant<uint, use> >;
+
+  [[vk::ext_extension("SPV_KHR_cooperative_matrix")]]
+  [[vk::ext_capability(/* CooperativeMatrixKHRCapability */ 6022)]]
+  [[vk::ext_capability(/* VulkanMemoryModel */ 5345)]]
+  SpirvMatrixType _matrix;
+  // clang-format on
+};
+
+// Cooperative matrix that can be used in the "a" position of a multiply add
+// instruction (r = (a * b) + c).
+template <typename ComponentType, Scope scope, uint rows, uint columns>
+using CooperativeMatrixA =
+    CooperativeMatrix<ComponentType, scope, rows, columns,
+                      CooperativeMatrixUseMatrixAKHR>;
+
+// Cooperative matrix that can be used in the "b" position of a multiply add
+// instruction (r = (a * b) + c).
+template <typename ComponentType, Scope scope, uint rows, uint columns>
+using CooperativeMatrixB =
+    CooperativeMatrix<ComponentType, scope, rows, columns,
+                      CooperativeMatrixUseMatrixBKHR>;
+
+// Cooperative matrix that can be used in the "r" and "c" position of a multiply
+// add instruction (r = (a * b) + c).
+template <typename ComponentType, Scope scope, uint rows, uint columns>
+using CooperativeMatrixAccumulator =
+    CooperativeMatrix<ComponentType, scope, rows, columns,
+                      CooperativeMatrixUseMatrixAccumulatorKHR>;
+
+// Returns the result of OpCooperativeMatrixMulAddKHR when applied to a, b, and
+// c. The cooperative matrix operands are inferred, with the
+// SaturatingAccumulationKHR bit not set.
+template <typename ComponentType, Scope scope, uint rows, uint columns, uint K>
+CooperativeMatrixAccumulator<ComponentType, scope, rows, columns>
+cooperativeMatrixMultiplyAdd(
+    CooperativeMatrixA<ComponentType, scope, rows, K> a,
+    CooperativeMatrixB<ComponentType, scope, K, columns> b,
+    CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> c);
+
+// Returns the result of OpCooperativeMatrixMulAddKHR when applied to a, b, and
+// c. The cooperative matrix operands are inferred, with the
+// SaturatingAccumulationKHR bit set.
+template <typename ComponentType, Scope scope, uint rows, uint columns, uint K>
+CooperativeMatrixAccumulator<ComponentType, scope, rows, columns>
+cooperativeMatrixSaturatingMultiplyAdd(
+    CooperativeMatrixA<ComponentType, scope, rows, K> a,
+    CooperativeMatrixB<ComponentType, scope, K, columns> b,
+    CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> c);
+
+} // namespace khr
+} // namespace vk
+
+#include "cooperative_matrix.impl"
+#endif // _HLSL_VK_KHR_COOPERATIVE_MATRIX_H_

+ 377 - 0
ThirdParty/Dxc/Include/hlsl/vk/khr/cooperative_matrix.impl

@@ -0,0 +1,377 @@
+// Copyright (c) 2024 Google LLC
+//
+// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+#include "vk/opcode_selector.h"
+
+template <typename ResultType, typename ComponentType>
+[[vk::ext_instruction(/* OpMatrixTimesScalar */ 143)]] ResultType
+__builtin_spv_MatrixTimesScalar(ResultType a, ComponentType b);
+
+template <typename ComponentType, vk::Scope scope, uint rows, uint columns,
+          vk::CooperativeMatrixUse use>
+[[vk::ext_instruction(/* OpCompositeExtract */ 81)]] ComponentType
+__builtin_spv_ExtractFromCooperativeMatrix(
+    typename vk::khr::CooperativeMatrix<ComponentType, scope, rows, columns,
+                                        use>::SpirvMatrixType matrix,
+    uint32_t index);
+
+template <typename CoopMatrixType, typename ComponentType>
+[[vk::ext_instruction(/* OpCompositeConstruct */ 80)]] CoopMatrixType
+__builtin_spv_ConstructCooperativeMatrix(ComponentType value);
+
+template <class ResultPointerType, class BaseType>
+[[vk::ext_instruction(/* OpAccessChain */ 65)]] ResultPointerType
+__builtin_spv_AccessChain([[vk::ext_reference]] BaseType base, uint32_t index);
+
+template <class ObjectType, class PointerType>
+[[vk::ext_instruction(/* OpLoad */ 61)]] ObjectType
+__builtin_spv_LoadPointer(PointerType base);
+
+template <class PointerType, class ObjectType>
+[[vk::ext_instruction(/* OpLoad */ 62)]] void
+__builtin_spv_StorePointer(PointerType base, ObjectType object);
+
+template <typename ComponentType, vk::Scope scope, uint rows, uint columns,
+          vk::CooperativeMatrixUse use>
+[[vk::ext_instruction(/* OpCompositeInsert */ 82)]]
+typename vk::khr::CooperativeMatrix<ComponentType, scope, rows, columns,
+                                    use>::SpirvMatrixType
+__builtin_spv_InsertIntoCooperativeMatrix(
+    ComponentType value,
+    typename vk::khr::CooperativeMatrix<ComponentType, scope, rows, columns,
+                                        use>::SpirvMatrixType matrix,
+    uint32_t index);
+
+// Define the load and store instructions
+template <typename ResultType, typename PointerType>
+[[vk::ext_instruction(/* OpCooperativeMatrixLoadKHR */ 4457)]] ResultType
+__builtin_spv_CooperativeMatrixLoadKHR(
+    [[vk::ext_reference]] PointerType pointer,
+    vk::CooperativeMatrixLayout memory_layout, uint stride,
+    [[vk::ext_literal]] uint32_t memory_operand);
+
+template <typename ResultType, typename PointerType>
+[[vk::ext_instruction(/* OpCooperativeMatrixLoadKHR */ 4457)]] ResultType
+__builtin_spv_CooperativeMatrixLoadKHR(
+    [[vk::ext_reference]] PointerType pointer,
+    vk::CooperativeMatrixLayout memory_layout, uint stride,
+    [[vk::ext_literal]] uint32_t memory_operand, vk::Scope scope);
+
+template <typename ResultType, typename PointerType>
+[[vk::ext_instruction(/* OpCooperativeMatrixLoadKHR */ 4457)]] ResultType
+__builtin_spv_CooperativeMatrixWorkgroupLoadKHR(
+    vk::WorkgroupSpirvPointer<PointerType> pointer,
+    vk::CooperativeMatrixLayout memory_layout, uint stride,
+    [[vk::ext_literal]] uint32_t memory_operand, vk::Scope scope);
+
+template <typename ObjectType, typename PointerType>
+[[vk::ext_instruction(/* OpCooperativeMatrixStoreKHR */ 4458)]] void
+__builtin_spv_CooperativeMatrixStoreKHR(
+    [[vk::ext_reference]] PointerType pointer, ObjectType object,
+    vk::CooperativeMatrixLayout memory_layout, uint stride,
+    [[vk::ext_literal]] uint32_t memory_operand, vk::Scope scope);
+
+template <typename ObjectType, typename PointerType>
+[[vk::ext_instruction(/* OpCooperativeMatrixStoreKHR */ 4458)]] void
+__builtin_spv_CooperativeMatrixStoreKHR(
+    [[vk::ext_reference]] PointerType pointer, ObjectType object,
+    vk::CooperativeMatrixLayout memory_layout, uint stride,
+    [[vk::ext_literal]] uint32_t memory_operand);
+
+template <typename ObjectType, typename PointerType>
+[[vk::ext_instruction(/* OpCooperativeMatrixStoreKHR */ 4458)]] void
+__builtin_spv_CooperativeMatrixWorkgroupStoreKHR(
+    vk::WorkgroupSpirvPointer<PointerType> pointer, ObjectType object,
+    vk::CooperativeMatrixLayout memory_layout, uint stride,
+    [[vk::ext_literal]] uint32_t memory_operand, vk::Scope scope);
+
+// We cannot define `OpCooperativeMatrixLengthKHR` using ext_instruction because
+// one of the operands is a type id. This builtin will have specific code in the
+// compiler to expand it.
+template <class MatrixType> uint __builtin_spv_CooperativeMatrixLengthKHR();
+
+// Arithmetic Instructions
+template <typename ResultType, typename MatrixTypeA, typename MatrixTypeB,
+          typename MatrixTypeC>
+[[vk::ext_instruction(/* OpCooperativeMatrixMulAddKHR */ 4459)]] ResultType
+__builtin_spv_CooperativeMatrixMulAddKHR(MatrixTypeA a, MatrixTypeB b,
+                                         MatrixTypeC c,
+                                         [[vk::ext_literal]] int operands);
+namespace vk {
+namespace khr {
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+template <class NewComponentType>
+CooperativeMatrix<NewComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::cast() {
+  using ResultType =
+      CooperativeMatrix<NewComponentType, scope, rows, columns, use>;
+  ResultType result;
+  result._matrix = util::ConversionSelector<ComponentType, NewComponentType>::
+      template Convert<typename ResultType::SpirvMatrixType>(_matrix);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::negate() {
+  CooperativeMatrix result;
+  result._matrix = util::ArithmeticSelector<ComponentType>::Negate(_matrix);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator+(
+    CooperativeMatrix other) {
+  CooperativeMatrix result;
+  result._matrix =
+      util::ArithmeticSelector<ComponentType>::Add(_matrix, other._matrix);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator-(
+    CooperativeMatrix other) {
+  CooperativeMatrix result;
+  result._matrix =
+      util::ArithmeticSelector<ComponentType>::Sub(_matrix, other._matrix);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator*(
+    CooperativeMatrix other) {
+  CooperativeMatrix result;
+  result._matrix =
+      util::ArithmeticSelector<ComponentType>::Mul(_matrix, other._matrix);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator/(
+    CooperativeMatrix other) {
+  CooperativeMatrix result;
+  result._matrix =
+      util::ArithmeticSelector<ComponentType>::Div(_matrix, other._matrix);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::operator*(
+    ComponentType scalar) {
+  CooperativeMatrix result;
+  result._matrix = __builtin_spv_MatrixTimesScalar(_matrix, scalar);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+          class Type>
+void CooperativeMatrix<ComponentType, scope, rows, columns, use>::Store(
+    WorkgroupSpirvPointer<Type> data, uint32_t stride) {
+  __builtin_spv_CooperativeMatrixWorkgroupStoreKHR(
+      data, _matrix, layout, stride,
+      memoryAccessOperands | MemoryAccessNonPrivatePointerMask |
+          MemoryAccessMakePointerAvailableMask,
+      ScopeWorkgroup);
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+          class Type>
+void CooperativeMatrix<ComponentType, scope, rows, columns, use>::Store(
+    RWStructuredBuffer<Type> data, uint32_t index, uint32_t stride) {
+  __builtin_spv_CooperativeMatrixStoreKHR(data[index], _matrix, layout, stride,
+                                          memoryAccessOperands);
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+          class Type>
+void CooperativeMatrix<ComponentType, scope, rows, columns, use>::CoherentStore(
+    globallycoherent RWStructuredBuffer<Type> data, uint32_t index,
+    uint32_t stride) {
+  __builtin_spv_CooperativeMatrixStoreKHR(
+      data[index], _matrix, layout, stride,
+      memoryAccessOperands | MemoryAccessNonPrivatePointerMask |
+          MemoryAccessMakePointerAvailableMask,
+      ScopeQueueFamily);
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+          class Type>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::Load(
+    vk::WorkgroupSpirvPointer<Type> buffer, uint32_t stride) {
+  CooperativeMatrix result;
+  result._matrix =
+      __builtin_spv_CooperativeMatrixWorkgroupLoadKHR<SpirvMatrixType>(
+          buffer, layout, stride,
+          memoryAccessOperands | MemoryAccessNonPrivatePointerMask |
+              MemoryAccessMakePointerVisibleMask,
+          ScopeWorkgroup);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+          class Type>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::Load(
+    RWStructuredBuffer<Type> buffer, uint32_t index, uint32_t stride) {
+  CooperativeMatrix result;
+  result._matrix = __builtin_spv_CooperativeMatrixLoadKHR<SpirvMatrixType>(
+      buffer[index], layout, stride, memoryAccessOperands);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+          class Type>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::CoherentLoad(
+    RWStructuredBuffer<Type> buffer, uint32_t index, uint32_t stride) {
+  CooperativeMatrix result;
+  result._matrix = __builtin_spv_CooperativeMatrixLoadKHR<SpirvMatrixType>(
+      buffer[index], layout, stride,
+      memoryAccessOperands | MemoryAccessNonPrivatePointerMask |
+          MemoryAccessMakePointerVisibleMask,
+      ScopeQueueFamily);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+template <uint32_t memoryAccessOperands, CooperativeMatrixLayout layout,
+          class Type>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::Load(
+    StructuredBuffer<Type> buffer, uint32_t index, uint32_t stride) {
+  CooperativeMatrix result;
+  result._matrix = __builtin_spv_CooperativeMatrixLoadKHR<SpirvMatrixType>(
+      buffer[index], layout, stride, MemoryAccessMaskNone);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>
+CooperativeMatrix<ComponentType, scope, rows, columns, use>::Splat(
+    ComponentType v) {
+  CooperativeMatrix result;
+  result._matrix = __builtin_spv_ConstructCooperativeMatrix<SpirvMatrixType>(v);
+  return result;
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+uint CooperativeMatrix<ComponentType, scope, rows, columns, use>::GetLength() {
+  return __builtin_spv_CooperativeMatrixLengthKHR<SpirvMatrixType>();
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+ComponentType CooperativeMatrix<ComponentType, scope, rows, columns, use>::Get(
+    uint32_t index) {
+  // clang-format off
+  using ComponentPtr = vk::SpirvOpaqueType<
+      /* OpTypePointer */ 32,
+      /* function storage class */ vk::Literal<vk::integral_constant<uint, 7> >,
+      ComponentType>;
+  // clang-format on
+  ComponentPtr ptr = __builtin_spv_AccessChain<ComponentPtr>(_matrix, index);
+  return __builtin_spv_LoadPointer<ComponentType>(ptr);
+}
+
+template <class ComponentType, Scope scope, uint rows, uint columns,
+          CooperativeMatrixUse use>
+void CooperativeMatrix<ComponentType, scope, rows, columns, use>::Set(
+    ComponentType value, uint32_t index) {
+  // clang-format off
+  using ComponentPtr = vk::SpirvOpaqueType<
+      /* OpTypePointer */ 32,
+      /* function storage class */ vk::Literal<vk::integral_constant<uint, 7> >,
+      ComponentType>;
+  // clang-format on
+  ComponentPtr ptr = __builtin_spv_AccessChain<ComponentPtr>(_matrix, index);
+  return __builtin_spv_StorePointer(ptr, value);
+}
+
+template <typename ComponentType, Scope scope, uint rows, uint columns, uint K>
+CooperativeMatrixAccumulator<ComponentType, scope, rows, columns>
+cooperativeMatrixMultiplyAdd(
+    CooperativeMatrixA<ComponentType, scope, rows, K> a,
+    CooperativeMatrixB<ComponentType, scope, K, columns> b,
+    CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> c) {
+
+  const vk::CooperativeMatrixOperandsMask allSignedComponents =
+      vk::CooperativeMatrixOperandsMatrixASignedComponentsKHRMask |
+      vk::CooperativeMatrixOperandsMatrixBSignedComponentsKHRMask |
+      vk::CooperativeMatrixOperandsMatrixCSignedComponentsKHRMask |
+      vk::CooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask;
+
+  const vk::CooperativeMatrixOperandsMask operands =
+      (vk::CooperativeMatrixOperandsMask)(
+          a.hasSignedIntegerComponentType
+              ? allSignedComponents
+              : vk::CooperativeMatrixOperandsMaskNone);
+
+  CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> result;
+  result._matrix = __builtin_spv_CooperativeMatrixMulAddKHR<
+      typename CooperativeMatrixAccumulator<ComponentType, scope, rows,
+                                            columns>::SpirvMatrixType>(
+      a._matrix, b._matrix, c._matrix, operands);
+  return result;
+}
+
+template <typename ComponentType, Scope scope, uint rows, uint columns, uint K>
+CooperativeMatrixAccumulator<ComponentType, scope, rows, columns>
+cooperativeMatrixSaturatingMultiplyAdd(
+    CooperativeMatrixA<ComponentType, scope, rows, K> a,
+    CooperativeMatrixB<ComponentType, scope, K, columns> b,
+    CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> c) {
+
+  const vk::CooperativeMatrixOperandsMask allSignedComponents =
+      vk::CooperativeMatrixOperandsMatrixASignedComponentsKHRMask |
+      vk::CooperativeMatrixOperandsMatrixBSignedComponentsKHRMask |
+      vk::CooperativeMatrixOperandsMatrixCSignedComponentsKHRMask |
+      vk::CooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask |
+      vk::CooperativeMatrixOperandsSaturatingAccumulationKHRMask;
+
+  const vk::CooperativeMatrixOperandsMask operands =
+      (vk::CooperativeMatrixOperandsMask)(
+          a.hasSignedIntegerComponentType
+              ? allSignedComponents
+              : vk::CooperativeMatrixOperandsSaturatingAccumulationKHRMask);
+  CooperativeMatrixAccumulator<ComponentType, scope, rows, columns> result;
+  result._matrix = __builtin_spv_CooperativeMatrixMulAddKHR<
+      typename CooperativeMatrixAccumulator<ComponentType, scope, rows,
+                                            columns>::SpirvMatrixType>(
+      a._matrix, b._matrix, c._matrix, operands);
+  return result;
+}
+
+} // namespace khr
+} // namespace vk

+ 227 - 0
ThirdParty/Dxc/Include/hlsl/vk/opcode_selector.h

@@ -0,0 +1,227 @@
+// Copyright (c) 2024 Google LLC
+//
+// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+#ifndef _HLSL_VK_KHR_OPCODE_SELECTOR_H_
+#define _HLSL_VK_KHR_OPCODE_SELECTOR_H_
+
+#define DECLARE_UNARY_OP(name, opcode)                                         \
+  template <typename ResultType>                                               \
+  [[vk::ext_instruction(opcode)]] ResultType __builtin_spv_##name(             \
+      ResultType a)
+
+DECLARE_UNARY_OP(CopyObject, 83);
+DECLARE_UNARY_OP(SNegate, 126);
+DECLARE_UNARY_OP(FNegate, 127);
+
+#define DECLARE_CONVERSION_OP(name, opcode)                                    \
+  template <typename ResultType, typename OperandType>                         \
+  [[vk::ext_instruction(opcode)]] ResultType __builtin_spv_##name(             \
+      OperandType a)
+
+DECLARE_CONVERSION_OP(ConvertFtoU, 109);
+DECLARE_CONVERSION_OP(ConvertFtoS, 110);
+DECLARE_CONVERSION_OP(ConvertSToF, 111);
+DECLARE_CONVERSION_OP(ConvertUToF, 112);
+DECLARE_CONVERSION_OP(UConvert, 113);
+DECLARE_CONVERSION_OP(SConvert, 114);
+DECLARE_CONVERSION_OP(FConvert, 115);
+DECLARE_CONVERSION_OP(Bitcast, 124);
+
+#undef DECLARY_UNARY_OP
+
+#define DECLARE_BINOP(name, opcode)                                            \
+  template <typename ResultType>                                               \
+  [[vk::ext_instruction(opcode)]] ResultType __builtin_spv_##name(             \
+      ResultType a, ResultType b)
+
+DECLARE_BINOP(IAdd, 128);
+DECLARE_BINOP(FAdd, 129);
+DECLARE_BINOP(ISub, 130);
+DECLARE_BINOP(FSub, 131);
+DECLARE_BINOP(IMul, 132);
+DECLARE_BINOP(FMul, 133);
+DECLARE_BINOP(UDiv, 134);
+DECLARE_BINOP(SDiv, 135);
+DECLARE_BINOP(FDiv, 136);
+
+#undef DECLARE_BINOP
+namespace vk {
+namespace util {
+
+template <class ComponentType> class ArithmeticSelector;
+
+#define ARITHMETIC_SELECTOR(BaseType, OpNegate, OpAdd, OpSub, OpMul, OpDiv,    \
+                            SIGNED_INTEGER_TYPE)                               \
+  template <> class ArithmeticSelector<BaseType> {                             \
+    template <class T> static T Negate(T a) { return OpNegate(a); }            \
+    template <class T> static T Add(T a, T b) { return OpAdd(a, b); }          \
+    template <class T> static T Sub(T a, T b) { return OpSub(a, b); }          \
+    template <class T> static T Mul(T a, T b) { return OpMul(a, b); }          \
+    template <class T> static T Div(T a, T b) { return OpDiv(a, b); }          \
+  };
+
+ARITHMETIC_SELECTOR(half, __builtin_spv_FNegate, __builtin_spv_FAdd,
+                    __builtin_spv_FSub, __builtin_spv_FMul, __builtin_spv_FDiv,
+                    false);
+ARITHMETIC_SELECTOR(float, __builtin_spv_FNegate, __builtin_spv_FAdd,
+                    __builtin_spv_FSub, __builtin_spv_FMul, __builtin_spv_FDiv,
+                    false);
+ARITHMETIC_SELECTOR(double, __builtin_spv_FNegate, __builtin_spv_FAdd,
+                    __builtin_spv_FSub, __builtin_spv_FMul, __builtin_spv_FDiv,
+                    false);
+
+#if __HLSL_ENABLE_16_BIT
+ARITHMETIC_SELECTOR(int16_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
+                    __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_SDiv,
+                    true);
+ARITHMETIC_SELECTOR(uint16_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
+                    __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_UDiv,
+                    false);
+#endif // __HLSL_ENABLE_16_BIT
+
+ARITHMETIC_SELECTOR(int32_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
+                    __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_SDiv,
+                    true);
+ARITHMETIC_SELECTOR(int64_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
+                    __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_SDiv,
+                    true);
+ARITHMETIC_SELECTOR(uint32_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
+                    __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_UDiv,
+                    false);
+ARITHMETIC_SELECTOR(uint64_t, __builtin_spv_SNegate, __builtin_spv_IAdd,
+                    __builtin_spv_ISub, __builtin_spv_IMul, __builtin_spv_UDiv,
+                    false);
+
+// The conversion selector is will be used to convert one type to another
+// using the SPIR-V conversion instructions. See
+// https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_conversion_instructions.
+// SourceType and TargetType must be integer or floating point scalar type.
+
+// ConversionSelector::Convert converts an object of type S to an object of type
+// T. S must be SourceType, a vector of SourceType, or a cooperative matrix of
+// SourceType. T must be TargetType, a vector of TargetType, or a cooperative
+// matrix of TargetType. T must have the same number of components as S. T is a
+// cooperative matrix if and only if S is a cooperative matrix.
+template <class SourceType, class TargetType> class ConversionSelector;
+
+#define CONVERSION_SELECTOR(SourceType, TargetType, OpConvert)                 \
+  template <> class ConversionSelector<SourceType, TargetType> {               \
+    template <class T, class S> static T Convert(S a) {                        \
+      return OpConvert<T>(a);                                                  \
+    }                                                                          \
+  };
+
+#if __HLSL_ENABLE_16_BIT
+CONVERSION_SELECTOR(uint16_t, uint16_t, __builtin_spv_CopyObject);
+CONVERSION_SELECTOR(uint16_t, int16_t, __builtin_spv_Bitcast);
+CONVERSION_SELECTOR(uint16_t, uint32_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(uint16_t, int32_t, __builtin_spv_SConvert);
+CONVERSION_SELECTOR(uint16_t, uint64_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(uint16_t, int64_t, __builtin_spv_SConvert);
+CONVERSION_SELECTOR(uint16_t, half, __builtin_spv_ConvertUToF);
+CONVERSION_SELECTOR(uint16_t, float, __builtin_spv_ConvertUToF);
+CONVERSION_SELECTOR(uint16_t, double, __builtin_spv_ConvertUToF);
+
+CONVERSION_SELECTOR(int16_t, uint16_t, __builtin_spv_Bitcast);
+CONVERSION_SELECTOR(int16_t, int16_t, __builtin_spv_CopyObject);
+CONVERSION_SELECTOR(int16_t, uint32_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(int16_t, int32_t, __builtin_spv_SConvert);
+CONVERSION_SELECTOR(int16_t, uint64_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(int16_t, int64_t, __builtin_spv_SConvert);
+CONVERSION_SELECTOR(int16_t, half, __builtin_spv_ConvertSToF);
+CONVERSION_SELECTOR(int16_t, float, __builtin_spv_ConvertSToF);
+CONVERSION_SELECTOR(int16_t, double, __builtin_spv_ConvertSToF);
+
+CONVERSION_SELECTOR(uint32_t, uint16_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(uint32_t, int16_t, __builtin_spv_SConvert);
+
+CONVERSION_SELECTOR(int32_t, uint16_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(int32_t, int16_t, __builtin_spv_SConvert);
+
+CONVERSION_SELECTOR(uint64_t, uint16_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(uint64_t, int16_t, __builtin_spv_SConvert);
+
+CONVERSION_SELECTOR(int64_t, uint16_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(int64_t, int16_t, __builtin_spv_SConvert);
+
+CONVERSION_SELECTOR(half, uint16_t, __builtin_spv_ConvertFtoU);
+CONVERSION_SELECTOR(half, int16_t, __builtin_spv_ConvertFtoS);
+
+CONVERSION_SELECTOR(float, uint16_t, __builtin_spv_ConvertFtoU);
+CONVERSION_SELECTOR(float, int16_t, __builtin_spv_ConvertFtoS);
+
+CONVERSION_SELECTOR(double, uint16_t, __builtin_spv_ConvertFtoU);
+CONVERSION_SELECTOR(double, int16_t, __builtin_spv_ConvertFtoS);
+#endif
+
+CONVERSION_SELECTOR(uint32_t, uint32_t, __builtin_spv_CopyObject);
+CONVERSION_SELECTOR(uint32_t, int32_t, __builtin_spv_Bitcast);
+CONVERSION_SELECTOR(uint32_t, uint64_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(uint32_t, int64_t, __builtin_spv_SConvert);
+CONVERSION_SELECTOR(uint32_t, half, __builtin_spv_ConvertUToF);
+CONVERSION_SELECTOR(uint32_t, float, __builtin_spv_ConvertUToF);
+CONVERSION_SELECTOR(uint32_t, double, __builtin_spv_ConvertUToF);
+
+CONVERSION_SELECTOR(int32_t, uint32_t, __builtin_spv_Bitcast);
+CONVERSION_SELECTOR(int32_t, int32_t, __builtin_spv_CopyObject);
+CONVERSION_SELECTOR(int32_t, uint64_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(int32_t, int64_t, __builtin_spv_SConvert);
+CONVERSION_SELECTOR(int32_t, half, __builtin_spv_ConvertSToF);
+CONVERSION_SELECTOR(int32_t, float, __builtin_spv_ConvertSToF);
+CONVERSION_SELECTOR(int32_t, double, __builtin_spv_ConvertSToF);
+
+CONVERSION_SELECTOR(uint64_t, uint32_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(uint64_t, int32_t, __builtin_spv_SConvert);
+CONVERSION_SELECTOR(uint64_t, uint64_t, __builtin_spv_Bitcast);
+CONVERSION_SELECTOR(uint64_t, int64_t, __builtin_spv_CopyObject);
+CONVERSION_SELECTOR(uint64_t, half, __builtin_spv_ConvertUToF);
+CONVERSION_SELECTOR(uint64_t, float, __builtin_spv_ConvertUToF);
+CONVERSION_SELECTOR(uint64_t, double, __builtin_spv_ConvertUToF);
+
+CONVERSION_SELECTOR(int64_t, uint32_t, __builtin_spv_UConvert);
+CONVERSION_SELECTOR(int64_t, int32_t, __builtin_spv_SConvert);
+CONVERSION_SELECTOR(int64_t, uint64_t, __builtin_spv_Bitcast);
+CONVERSION_SELECTOR(int64_t, int64_t, __builtin_spv_CopyObject);
+CONVERSION_SELECTOR(int64_t, half, __builtin_spv_ConvertSToF);
+CONVERSION_SELECTOR(int64_t, float, __builtin_spv_ConvertSToF);
+CONVERSION_SELECTOR(int64_t, double, __builtin_spv_ConvertSToF);
+
+CONVERSION_SELECTOR(half, uint32_t, __builtin_spv_ConvertFtoU);
+CONVERSION_SELECTOR(half, int32_t, __builtin_spv_ConvertFtoS);
+CONVERSION_SELECTOR(half, uint64_t, __builtin_spv_ConvertFtoU);
+CONVERSION_SELECTOR(half, int64_t, __builtin_spv_ConvertFtoS);
+CONVERSION_SELECTOR(half, half, __builtin_spv_CopyObject);
+#if __HLSL_ENABLE_16_BIT
+CONVERSION_SELECTOR(half, float, __builtin_spv_FConvert);
+#else
+CONVERSION_SELECTOR(half, float, __builtin_spv_CopyObject);
+#endif
+
+CONVERSION_SELECTOR(half, double, __builtin_spv_FConvert);
+
+CONVERSION_SELECTOR(float, uint32_t, __builtin_spv_ConvertFtoU);
+CONVERSION_SELECTOR(float, int32_t, __builtin_spv_ConvertFtoS);
+CONVERSION_SELECTOR(float, uint64_t, __builtin_spv_ConvertFtoU);
+CONVERSION_SELECTOR(float, int64_t, __builtin_spv_ConvertFtoS);
+#if __HLSL_ENABLE_16_BIT
+CONVERSION_SELECTOR(float, half, __builtin_spv_FConvert);
+#else
+CONVERSION_SELECTOR(float, half, __builtin_spv_CopyObject);
+#endif
+CONVERSION_SELECTOR(float, float, __builtin_spv_CopyObject);
+CONVERSION_SELECTOR(float, double, __builtin_spv_FConvert);
+
+CONVERSION_SELECTOR(double, uint32_t, __builtin_spv_ConvertFtoU);
+CONVERSION_SELECTOR(double, int32_t, __builtin_spv_ConvertFtoS);
+CONVERSION_SELECTOR(double, uint64_t, __builtin_spv_ConvertFtoU);
+CONVERSION_SELECTOR(double, int64_t, __builtin_spv_ConvertFtoS);
+CONVERSION_SELECTOR(double, half, __builtin_spv_FConvert);
+CONVERSION_SELECTOR(double, float, __builtin_spv_FConvert);
+CONVERSION_SELECTOR(double, double, __builtin_spv_CopyObject);
+}; // namespace util
+} // namespace vk
+
+#endif // _HLSL_VK_KHR_OPCODE_SELECTOR_H_

+ 85 - 0
ThirdParty/Dxc/Include/hlsl/vk/spirv.h

@@ -0,0 +1,85 @@
+// Copyright (c) 2024 Google LLC
+//
+// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+#ifndef _HLSL_VK_SPIRV_H_
+#define _HLSL_VK_SPIRV_H_
+
+namespace vk {
+
+enum CooperativeMatrixUse {
+  CooperativeMatrixUseMatrixAKHR = 0,
+  CooperativeMatrixUseMatrixBKHR = 1,
+  CooperativeMatrixUseMatrixAccumulatorKHR = 2,
+  CooperativeMatrixUseMax = 0x7fffffff,
+};
+
+enum CooperativeMatrixLayout {
+  CooperativeMatrixLayoutRowMajorKHR = 0,
+  CooperativeMatrixLayoutColumnMajorKHR = 1,
+  CooperativeMatrixLayoutRowBlockedInterleavedARM = 4202,
+  CooperativeMatrixLayoutColumnBlockedInterleavedARM = 4203,
+  CooperativeMatrixLayoutMax = 0x7fffffff,
+};
+
+enum CooperativeMatrixOperandsMask {
+  CooperativeMatrixOperandsMaskNone = 0,
+  CooperativeMatrixOperandsMatrixASignedComponentsKHRMask = 0x00000001,
+  CooperativeMatrixOperandsMatrixBSignedComponentsKHRMask = 0x00000002,
+  CooperativeMatrixOperandsMatrixCSignedComponentsKHRMask = 0x00000004,
+  CooperativeMatrixOperandsMatrixResultSignedComponentsKHRMask = 0x00000008,
+  CooperativeMatrixOperandsSaturatingAccumulationKHRMask = 0x00000010,
+};
+
+enum MemoryAccessMask {
+  MemoryAccessMaskNone = 0,
+  MemoryAccessVolatileMask = 0x00000001,
+  MemoryAccessAlignedMask = 0x00000002,
+  MemoryAccessNontemporalMask = 0x00000004,
+  MemoryAccessMakePointerAvailableMask = 0x00000008,
+  MemoryAccessMakePointerAvailableKHRMask = 0x00000008,
+  MemoryAccessMakePointerVisibleMask = 0x00000010,
+  MemoryAccessMakePointerVisibleKHRMask = 0x00000010,
+  MemoryAccessNonPrivatePointerMask = 0x00000020,
+  MemoryAccessNonPrivatePointerKHRMask = 0x00000020,
+  MemoryAccessAliasScopeINTELMaskMask = 0x00010000,
+  MemoryAccessNoAliasINTELMaskMask = 0x00020000,
+};
+
+enum Scope {
+  ScopeCrossDevice = 0,
+  ScopeDevice = 1,
+  ScopeWorkgroup = 2,
+  ScopeSubgroup = 3,
+  ScopeInvocation = 4,
+  ScopeQueueFamily = 5,
+  ScopeQueueFamilyKHR = 5,
+  ScopeShaderCallKHR = 6,
+  ScopeMax = 0x7fffffff,
+};
+
+enum StorageClass {
+  StorageClassWorkgroup = 4,
+};
+
+// An opaque type to represent a Spir-V pointer to the workgroup storage class.
+// clang-format off
+template <typename PointeeType>
+using WorkgroupSpirvPointer = const vk::SpirvOpaqueType<
+    /* OpTypePointer */ 32,
+    vk::Literal<vk::integral_constant<uint, StorageClassWorkgroup> >,
+    PointeeType>;
+// clang-format on
+
+// Returns an opaque Spir-V pointer to v. The memory object v's storage class
+// modifier must be groupshared. If the incorrect storage class is used, then
+// there will be a validation error, and it will not show the correct
+template <typename T>
+[[vk::ext_instruction(/* OpCopyObject */ 83)]] WorkgroupSpirvPointer<T>
+GetGroupSharedAddress([[vk::ext_reference]] T v);
+
+} // namespace vk
+
+#endif // _HLSL_VK_SPIRV_H_

+ 0 - 0
ThirdParty/Dxc/libdxcompiler.so → ThirdParty/Dxc/Lib/LinuxX64/libdxcompiler.so


+ 0 - 0
ThirdParty/Dxc/libdxil.so → ThirdParty/Dxc/Lib/LinuxX64/libdxil.so


BIN=BIN
ThirdParty/Dxc/Lib/WinArm64/dxcompiler.dll


BIN=BIN
ThirdParty/Dxc/Lib/WinArm64/dxil.dll


+ 0 - 0
ThirdParty/Dxc/dxcompiler.dll → ThirdParty/Dxc/Lib/WinX64/dxcompiler.dll


+ 0 - 0
ThirdParty/Dxc/dxil.dll → ThirdParty/Dxc/Lib/WinX64/dxil.dll


+ 174 - 0
ThirdParty/Dxc/ReleaseNotes.md

@@ -0,0 +1,174 @@
+# DirectX Shader Compiler Redistributable Package
+
+This package contains a copy of the DirectX Shader Compiler redistributable and its associated development headers.
+
+For help getting started, please see:
+
+<https://github.com/microsoft/DirectXShaderCompiler/wiki>
+
+## Licenses
+
+The included licenses apply to the following files:
+
+| License file | Applies to |
+|---|---|
+|LICENSE-MIT.txt    |d3d12shader.h|
+|LICENSE-LLVM.txt   |all other files|
+
+## Changelog
+
+### Version 1.8.2502
+
+This cumulative release contains numerous bug fixes and stability improvements.
+
+Here are some highlights:
+
+- The incomplete WaveMatrix implementation has been removed. [#6807](https://github.com/microsoft/DirectXShaderCompiler/pull/6807)
+- DXIL Validator Hash is open sourced. [#6846](https://github.com/microsoft/DirectXShaderCompiler/pull/6846)
+- DXIL container validation for PSV0 part allows any content ordering inside string and semantic index tables. [#6859](https://github.com/microsoft/DirectXShaderCompiler/pull/6859)
+- The and() and or() intrinsics will now accept non-integer parameters by casting them to bools. [#7060](https://github.com/microsoft/DirectXShaderCompiler/pull/7060)
+- Released executables will now expect the filenames associated with the released pdbs. Instead of expecting `dxc_full.pdb`, `dxc.exe` will now expect `dxc.pdb`.
+
+### Version 1.8.2407
+
+This cumulative release contains numerous bug fixes and stability improvments.
+
+Here are some highlights:
+
+- dxc generates invalid alignment on groupshared matrix load/store instructions in [#6416](https://github.com/microsoft/DirectXShaderCompiler/issues/6416)
+- [Optimization] DXC is missing common factor optimization in some cases in [#6593](https://github.com/microsoft/DirectXShaderCompiler/issues/6593)
+- [SPIR-V] Implement WaveMutliPrefix* in [#6600](https://github.com/microsoft/DirectXShaderCompiler/issues/6600)
+- [SPIR-V] Implement SampleCmpLevel for SM6.7 in [#6613](https://github.com/microsoft/DirectXShaderCompiler/issues/6613)
+- Avoid adding types to default namespace in [#6646](https://github.com/microsoft/DirectXShaderCompiler/issues/6646)
+- Release notes once found in `README.md` can now be found in `ReleaseNotes.md`
+- Fixed several bugs in the loop restructurizer. Shader developers who are using -opt-disable structurize-loop-exits-for-unroll to disable the loop restructurizer should consider removing that workaround.
+
+### Version 1.8.2405
+
+DX Compiler Release for May 2024
+
+This release includes two major new elements:
+
+- The introduction of the first component of HLSL 202x
+- The inclusion of clang-built Windows binaries
+
+See [the official blog post](https://devblogs.microsoft.com/directx/dxc-1-8-2405-available) for a more detailed description of this release.
+
+HLSL 202x is a placeholder designation for what will ultimately be a new language version that further aligns HLSL with modern language features. It is intended to serve as a bridge to help transition to the expected behavior of the modernized compiler.
+
+To experiment with 202x, use the `-HV 202x` flag. We recommend enabling these warnings as well to catch potential changes in behavior: `-Wconversion -Wdouble-promotion -Whlsl-legacy-literal`.
+
+The first feature available in 202x updates HLSL's treatment of literals to better conform with C/C++. In previous versions, un-suffixed literal types targeted the highest possible precision. This feature revises that to mostly conform with C/C++ behavior. See the above blog post for details.
+
+Clang-built Windows binaries are included in addition to the MSVC-built binaries that have always been shipped before. The clang-built compiler is expected to improve HLSL compile times in many cases. We are eager for feedback about this build positive or negative, related to compile times or correctness.
+
+### Version 1.8.2403.2
+
+DX Compiler Release for March 2024 - Patch 2
+
+- Fix regression: [#6426](https://github.com/microsoft/DirectXShaderCompiler/issues/6426) Regression, SIGSEGV instead of diagnostics when encountering bool operator==(const T&, const T&).
+
+### Version 1.8.2403.1
+
+DX Compiler Release for March 2024 - Patch 1
+
+- Fix regression: [#6419](https://github.com/microsoft/DirectXShaderCompiler/issues/6419) crash when using literal arguments with `fmod`.
+
+### Version 1.8.2403
+
+DX Compiler release for March 2024
+
+- Shader Model 6.8 is fully supported
+  - Work Graphs allow node shaders with user-defined input and output payloads
+  - New Barrier builtin functions with specific memory types and semantics
+  - Expanded Comparison sampler intrinsics: SampleCmpBias, SampleCmpGrad, and CalculateLevelOfDetail
+  - StartVertexLocation and StartInstanceLocation semantics
+  - WaveSizeRange entry point attribute allows specifying a range of supported wave sizes
+- Improved compile-time validation and runtime validation information
+- Various stability improvements including numerous address sanitation fixes
+- Several Diagnostic improvements
+  - Many diagnostics are generated earlier and with more detailed information
+  - Library profile diagnostic improvements
+  - No longer infer library shader type when not specified
+  - More helpful diagnostics for numthreads and other entry point attributes
+  - Validation errors more accurately determine usage by the entry point
+- Improve debug info generation
+- Further improvements to Linux build quality
+- File paths arguments for `IDxcIncludeHandler::LoadSource` will now be normalized to use OS specific slashes
+  (`\` for windows, `/` for *nix) and no longer have double slashes except for UNC paths (`\\my\unc\path`).”
+
+### Version 1.7.2308
+
+DX Compiler release for August 2023
+
+- HLSL 2021 is now enabled by default
+- Various HLSL 2021 fixes have been made to
+  - Operator overloading fixes
+  - Templates fixes
+  - Select() with samplers
+  - Bitfields show in reflections
+  - Bitfields can be used on enums
+  - Allow function template default params
+- Issues with loading and using Linux binaries have been resolved
+- Support #pragma region/endregion
+- Various stability and diagnostic improvements
+- Dxcapi.h inline documentation is improved
+- Linking of libraries created by different compilers is disallowed to prevent interface Issues
+- Inout parameter correctness improved
+
+The package includes dxc.exe, dxcompiler.dll, corresponding lib and headers, and dxil.dll for x64 and arm64 platforms on Windows.
+The package also includes Linux version of the compiler with corresponding executable, libdxcompiler.so, corresponding headers, and libdxil.so for x64 platforms.
+
+The new DirectX 12 Agility SDK (Microsoft.Direct3D.D3D12 nuget package) and a hardware driver with appropriate support
+are required to run shader model 6.7 shaders. Please see <https://aka.ms/directx12agility> for details.
+
+The SPIR-V backend of the compiler has been enabled in this release.
+
+### Version 1.7.2212
+
+DX Compiler release for December 2022.
+
+- Includes full support of HLSL 2021 for SPIRV generation as well as many HLSL 2021 fixes and enhancements:
+  - HLSL 2021's `and`, `or` and `select` intrinsics are now exposed in all language modes. This was done to ease porting code bases to HLSL2021, but may cause name conflicts in existing code.
+  - Improved template utility with user-defined types
+  - Many additional bug fixes
+- Linux binaries are now included.
+ This includes the compiler executable, the dynamic library, and the dxil signing library.
+- New flags for inspecting compile times:
+  - `-ftime-report` flag prints a high level summary of compile time broken down by major phase or pass in the compiler. The DXC
+command line will print the output to stdout.
+  - `-ftime-trace` flag prints a Chrome trace json file. The output can be routed to a specific file by providing a filename to
+the argument using the format `-ftime-trace=<filename>`. Chrome trace files can be opened in Chrome by loading the built-in tracing tool
+at chrome://tracing. The trace file captures hierarchial timing data with additional context enabling a much more in-depth profiling
+experience.
+  - Both new options are supported via the DXC API using the `DXC_OUT_TIME_REPORT` and `DXC_OUT_TIME_TRACE` output kinds respectively.
+- IDxcPdbUtils2 enables reading new PDB container part
+- `-P` flag will now behave as it does with cl using the file specified by `-Fi` or a default
+- Unbound multidimensional resource arrays are allowed
+- Diagnostic improvements
+- Reflection support on non-Windows platforms; minor updates adding RequiredFeatureFlags to library function reflection and thread group size for AS and MS.
+
+The package includes dxc.exe, dxcompiler.dll, corresponding lib and headers, and dxil.dll for x64 and arm64 platforms on Windows.
+For the first time the package also includes Linux version of the compiler with corresponding executable, libdxcompiler.so, corresponding headers, and libdxil.so for x64 platforms.
+
+The new DirectX 12 Agility SDK (Microsoft.Direct3D.D3D12 nuget package) and a hardware driver with appropriate support
+are required to run shader model 6.7 shaders. Please see <https://aka.ms/directx12agility> for details.
+
+The SPIR-V backend of the compiler has been enabled in this release. Please note that Microsoft does not perform testing/verification of the SPIR-V backend.
+
+### Version 1.7.2207
+
+DX Compiler release for July 2022. Contains shader model 6.7 and many bug fixes and improvements, such as:
+
+- Features: Shader Model 6.7 includes support for Raw Gather, Programmable Offsets, QuadAny/QuadAll, WaveOpsIncludeHelperLanes, and more!
+- Platforms: ARM64 support
+- HLSL 2021 : Enable “using” keyword
+- Optimizations: Loop unrolling and dead code elimination improvements
+- Developer tools: Improved disassembly output
+
+The package includes dxc.exe, dxcompiler.dll, corresponding lib and headers, and dxil.dll for x64 and, for the first time, arm64 platforms!
+
+The new DirectX 12 Agility SDK (Microsoft.Direct3D.D3D12 nuget package) and a hardware driver with appropriate support
+are required to run shader model 6.7 shaders. Please see <https://aka.ms/directx12agility> for details.
+
+The SPIR-V backend of the compiler has been enabled in this release. Please note that Microsoft does not perform testing/verification of the SPIR-V backend.

BIN=BIN
ThirdParty/Dxc/dxc


BIN=BIN
ThirdParty/Dxc/dxc.exe


+ 0 - 7
ThirdParty/Dxc/dxc.sh

@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
-
-export LD_LIBRARY_PATH=$SCRIPT_DIR:$LD_LIBRARY_PATH
-
-$SCRIPT_DIR/dxc.bin "$@"

BIN=BIN
ThirdParty/Dxc/dxv


BIN=BIN
ThirdParty/Dxc/dxv.exe