Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ The included licenses apply to the following files:
Place release notes for the upcoming release below this line and remove this
line upon naming the release. Refer to previous for appropriate section names.

#### Other Changes

- Built-in HLSL headers are now embedded in the dxcompiler library so that users do not need to copy headers around with the toolchain.
- vector_utils.h and enable_if.h are renamed to vector_utils and enable_if respectively in alignment with TC57 decision on standard header files to exclude file extensions (See: https://github.com/hlsl-tc57/tc57/blob/main/docs/DesignConsiderations.md#minor-details).

### Version 1.10.2605

#### Experimental Shader Model 6.10

- Removed experimental Cooperative Vector, this has been replaced by LinAlg matrix.
Expand Down
62 changes: 13 additions & 49 deletions tools/clang/lib/Headers/hlsl/dx/linalg.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// Header for HLSL Linear Algebra Matrix APIs.
//===----------------------------------------------------------------------===//
//
// Part of the DirectXShaderCompiler, 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
//
//===----------------------------------------------------------------------===//
// DirectX Shader Model 6.10 Linear Algebra objects and APIs.
//===----------------------------------------------------------------------===//

#include <enable_if>
#include <type_traits>

#if ((__SHADER_TARGET_MAJOR > 6) || \
(__SHADER_TARGET_MAJOR == 6 && __SHADER_TARGET_MINOR >= 10)) && \
Expand All @@ -7,56 +19,8 @@
#pragma dxc diagnostic push
#pragma dxc diagnostic ignored "-Whlsl-groupshared-202x"

namespace hlsl {

#define SIZE_TYPE int

template <typename T> struct is_arithmetic {
static const bool value = false;
};

#define __ARITHMETIC_TYPE(type) \
template <> struct is_arithmetic<type> { \
static const bool value = true; \
};

#if __HLSL_ENABLE_16_BIT
__ARITHMETIC_TYPE(uint16_t)
__ARITHMETIC_TYPE(int16_t)
#endif
__ARITHMETIC_TYPE(uint)
__ARITHMETIC_TYPE(int)
__ARITHMETIC_TYPE(uint64_t)
__ARITHMETIC_TYPE(int64_t)
__ARITHMETIC_TYPE(half)
__ARITHMETIC_TYPE(float)
__ARITHMETIC_TYPE(double)

template <typename T> struct is_signed {
static const bool value = true;
};

#define __UNSIGNED_TYPE(type) \
template <> struct is_signed<type> { \
static const bool value = false; \
};

#if __HLSL_ENABLE_16_BIT
__UNSIGNED_TYPE(uint16_t)
#endif
__UNSIGNED_TYPE(uint)
__UNSIGNED_TYPE(uint64_t)

#undef __UNSIGNED_TYPE

template <bool B, typename T> struct enable_if {};

template <typename T> struct enable_if<true, T> {
using type = T;
};

} // namespace hlsl

namespace dxil {

// This enum must _exactly_ match the DXIL constants.
Expand Down
29 changes: 29 additions & 0 deletions tools/clang/lib/Headers/hlsl/enable_if
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// Part of the DirectXShaderCompiler, 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
//
//===----------------------------------------------------------------------===//
// SFINAE construct for enable_if to enable and disable declarations.
//===----------------------------------------------------------------------===//

#ifndef __HLSL_ENABLE_IF
#define __HLSL_ENABLE_IF

#if __HLSL_VERSION >= 2021

namespace hlsl {

template <bool B, typename T> struct enable_if {};

template <typename T> struct enable_if<true, T> {
using type = T;
};

} // namespace hlsl

#endif // __HLSL_VERSION >= 2021

#endif // __HLSL_ENABLE_IF
17 changes: 0 additions & 17 deletions tools/clang/lib/Headers/hlsl/enable_if.h

This file was deleted.

60 changes: 60 additions & 0 deletions tools/clang/lib/Headers/hlsl/type_traits
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//===----------------------------------------------------------------------===//
//
// Part of the DirectXShaderCompiler, 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
//
//===----------------------------------------------------------------------===//
// Template trait constructs for driving template specialization.
//===----------------------------------------------------------------------===//

#ifndef __HLSL_TYPE_TRAITS
#define __HLSL_TYPE_TRAITS

#if __HLSL_VERSION >= 2021

namespace hlsl {

template <typename T> struct is_arithmetic {
static const bool value = false;
};

#define __ARITHMETIC_TYPE(type) \
template <> struct is_arithmetic<type> { \
static const bool value = true; \
};

#if __HLSL_ENABLE_16_BIT
__ARITHMETIC_TYPE(uint16_t)
__ARITHMETIC_TYPE(int16_t)
#endif
__ARITHMETIC_TYPE(uint)
__ARITHMETIC_TYPE(int)
__ARITHMETIC_TYPE(uint64_t)
__ARITHMETIC_TYPE(int64_t)
__ARITHMETIC_TYPE(half)
__ARITHMETIC_TYPE(float)
__ARITHMETIC_TYPE(double)

template <typename T> struct is_signed {
static const bool value = true;
};

#define __UNSIGNED_TYPE(type) \
template <> struct is_signed<type> { \
static const bool value = false; \
};

#if __HLSL_ENABLE_16_BIT
__UNSIGNED_TYPE(uint16_t)
#endif
__UNSIGNED_TYPE(uint)
__UNSIGNED_TYPE(uint64_t)

#undef __UNSIGNED_TYPE

} // namespace hlsl

#endif // __HLSL_VERSION >= 2021
#endif // __HLSL_TYPE_TRAITS
42 changes: 42 additions & 0 deletions tools/clang/lib/Headers/hlsl/vector_utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// Part of the DirectXShaderCompiler, 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
//
//===----------------------------------------------------------------------===//
// Header for vector template utility functions for operating on vector
// templates.
//===----------------------------------------------------------------------===//

#ifndef __HLSL_VECTOR_UTILS
#define __HLSL_VECTOR_UTILS

#if __HLSL_VERSION >= 2021

#include <enable_if>

namespace hlsl {

template <int Off, int OSz, typename T, int ISz>
typename hlsl::enable_if<Off + OSz <= ISz, vector<T, OSz> >::type
slice(vector<T, ISz> In) {
vector<T, OSz> Result = (vector<T, OSz>)0;

[unroll]
for (int I = 0; I < OSz; ++I)
Result[I] = In[I + Off];

return Result;
}

template <int OSz, typename T, int ISz>
vector<T, OSz> slice(vector<T, ISz> In) {
return slice<0, OSz, T, ISz>(In);
}

} // namespace hlsl

#endif // __HLSL_VERSION >= 2021
#endif // __HLSL_VECTOR_UTILS
32 changes: 0 additions & 32 deletions tools/clang/lib/Headers/hlsl/vector_utils.h

This file was deleted.

5 changes: 3 additions & 2 deletions tools/clang/lib/Lex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ set(generate_embedded_headers_script
"${LLVM_MAIN_SRC_DIR}/utils/generate_hlsl_embedded_headers.py")

set(hlsl_embedded_inputs
enable_if.h
vector_utils.h
enable_if
type_traits
vector_utils
dx/linalg.h
)

Expand Down
25 changes: 25 additions & 0 deletions tools/clang/test/CodeGenDXIL/templates/vector_slice_6_0.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: %dxc -T ps_6_0 -E main %s | FileCheck %s

#include <vector_utils>

RWByteAddressBuffer buf;

float4 main(uint4 id: IN0) : SV_Target
{
vector<float, 4> fVec = buf.Load<vector<float, 4> >(0);

float2 lhs = hlsl::slice<1, 2>(fVec);
float2 rhs = hlsl::slice<2>(fVec);

// CHECK: [[Val:%.*]] = call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32
// CHECK: [[V0:%.*]] = extractvalue %dx.types.ResRet.f32 [[Val]], 0
// CHECK: [[V1:%.*]] = extractvalue %dx.types.ResRet.f32 [[Val]], 1
// CHECK: [[V2:%.*]] = extractvalue %dx.types.ResRet.f32 [[Val]], 2
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float [[V1]])
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float [[V2]])
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float [[V0]])
// CHECK: call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float [[V1]])

float4 res = {lhs, rhs};
return res;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// RUN: %dxc -T ps_6_0 -E main -M %s | FileCheck %s
// RUN: %dxc -T ps_6_0 -E main -verify %s

// Verify that the bundled HLSL header tools/clang/lib/Headers/hlsl/enable_if.h
// Verify that the bundled HLSL header tools/clang/lib/Headers/hlsl/enable_if
// is found via the angled-#include "embedded headers" path even when no -I
// search path points at the hlsl/ directory.

// expected-no-diagnostics

#include <enable_if.h>
#include <enable_if>

float4 main() : SV_Target { return 0; }

// CHECK: <built-in:hlsl>/enable_if.h
// CHECK: <built-in:hlsl>/enable_if

Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

// expected-no-diagnostics

#include <enable_if.h>
#include <enable_if>

#ifndef HLSL_OVERLAY_ENABLE_IF
#error "Expected the on-disk overlay enable_if.h to take precedence over the embedded copy."
#error "Expected the on-disk overlay enable_if to take precedence over the embedded copy."
#endif

float4 main() : SV_Target { return 0; }

// The dependency dump must list the on-disk overlay path and must not
// reference the virtual built-in:hlsl filename used for embedded headers.
// CHECK-NOT: <built-in:hlsl>
// CHECK: Inputs{{[/\\]}}enable_if.h
// CHECK: Inputs{{[/\\]}}enable_if
6 changes: 3 additions & 3 deletions tools/clang/test/SemaHLSL/hlsl/vectors/slice-errors.hlsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %dxc -T ps_6_9 -E main -verify %s

#include <vector_utils.h>
#include <vector_utils>

RWByteAddressBuffer buf;

Expand All @@ -15,8 +15,8 @@ float4 main(uint4 id: IN0) : SV_Target
// expected-error@+1 {{no matching function for call to 'slice'}}
float4 rhs = hlsl::slice<2, 4>(fVec);

// expected-note@vector_utils.h:13 {{candidate template ignored: disabled by 'enable_if' [with Off = 2, OSz = 4, T = float, ISz = 4]}}
// expected-note@vector_utils.h:26 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'T'}}
// expected-note@vector_utils:23 {{candidate template ignored: disabled by 'enable_if' [with Off = 2, OSz = 4, T = float, ISz = 4]}}
// expected-note@vector_utils:35 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'T'}}

return lhs + rhs;
}
Expand Down
2 changes: 1 addition & 1 deletion tools/clang/test/SemaHLSL/hlsl/vectors/slice.hlsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// REQUIRES: dxil-1-9
// RUN: %dxc -T ps_6_9 -E main %s | FileCheck %s

#include <vector_utils.h>
#include <vector_utils>

RWByteAddressBuffer buf;

Expand Down
Loading