Skip to content

Commit f762722

Browse files
Merge pull request #851 from Devsh-Graphics-Programming/spirv_intrinsics
Added OpIAddCarry and OpISubBorrow intrinsics
2 parents ac82f19 + 2e6bffa commit f762722

File tree

5 files changed

+83
-4
lines changed

5 files changed

+83
-4
lines changed

include/nbl/builtin/hlsl/spirv_intrinsics/core.hlsl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_CORE_INCLUDED_
55
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_CORE_INCLUDED_
66

7-
87
#ifdef __HLSL_VERSION // TODO: AnastZIuk fix public search paths so we don't choke
98
#include "spirv/unified1/spirv.hpp"
109

1110
#include <nbl/builtin/hlsl/vector_utils/vector_traits.hlsl>
12-
#include "nbl/builtin/hlsl/type_traits.hlsl"
11+
#include <nbl/builtin/hlsl/type_traits.hlsl>
1312
#include <nbl/builtin/hlsl/concepts.hlsl>
13+
#include <nbl/builtin/hlsl/spirv_intrinsics/output_structs.hlsl>
1414

1515
namespace nbl
1616
{
@@ -327,6 +327,14 @@ template<typename BooleanVector>
327327
[[vk::ext_instruction(spv::OpAny)]]
328328
enable_if_t<is_vector_v<BooleanVector>&& is_same_v<typename vector_traits<BooleanVector>::scalar_type, bool>, BooleanVector> any(BooleanVector vec);
329329

330+
template<typename T NBL_FUNC_REQUIRES(concepts::UnsignedIntegral<T>)
331+
[[vk::ext_instruction(spv::OpIAddCarry)]]
332+
AddCarryOutput<T> AddCarry(T operand1, T operand2);
333+
334+
template<typename T NBL_FUNC_REQUIRES(concepts::UnsignedIntegral<T>)
335+
[[vk::ext_instruction(spv::OpISubBorrow)]]
336+
SubBorrowOutput<T> SubBorrow(T operand1, T operand2);
337+
330338
}
331339

332340
#endif
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_FRAGMENT_SHADER_BARYCENTRIC_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_FRAGMENT_SHADER_BARYCENTRIC_INCLUDED_
6+
7+
#include "spirv/unified1/spirv.hpp"
8+
9+
namespace nbl
10+
{
11+
namespace hlsl
12+
{
13+
namespace spirv
14+
{
15+
16+
[[vk::ext_capability(/*spv::CapabilityFragmentBarycentricKHR*/5284)]]
17+
[[vk::ext_extension("SPV_KHR_fragment_shader_barycentric")]]
18+
[[vk::ext_builtin_input(/*spv::BuiltInBaryCoordKHR*/5286)]]
19+
static const float32_t3 BaryCoordKHR;
20+
21+
[[vk::ext_capability(/*spv::CapabilityFragmentBarycentricKHR*/5284)]]
22+
[[vk::ext_extension("SPV_KHR_fragment_shader_barycentric")]]
23+
[[vk::ext_builtin_input(/*spv::BuiltInBaryCoordKHR*/5287)]]
24+
static const float32_t3 BaryCoordNoPerspKHR;
25+
26+
}
27+
}
28+
}
29+
30+
#endif
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
6+
7+
#include <nbl/builtin/hlsl/concepts/core.hlsl>
8+
9+
namespace nbl
10+
{
11+
namespace hlsl
12+
{
13+
14+
template<typename T NBL_STRUCT_CONSTRAINABLE>
15+
struct AddCarryOutput;
16+
template<typename T NBL_STRUCT_CONSTRAINABLE>
17+
struct SubBorrowOutput;
18+
19+
20+
template<typename T> NBL_PARTIAL_REQ_TOP(concepts::UnsignedIntegral<T>)
21+
struct AddCarryOutput<T NBL_PARTIAL_REQ_BOT(concepts::UnsignedIntegral<T>) >
22+
{
23+
T result;
24+
T carry;
25+
};
26+
27+
template<typename T> NBL_PARTIAL_REQ_TOP(concepts::UnsignedIntegral<T>)
28+
struct SubBorrowOutput<T NBL_PARTIAL_REQ_BOT(concepts::UnsignedIntegral<T>) >
29+
{
30+
T result;
31+
T borrow;
32+
};
33+
}
34+
}
35+
36+
#endif

include/nbl/builtin/hlsl/tgmath/output_structs.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4-
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
5-
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
4+
#ifndef _NBL_BUILTIN_HLSL_TGMATH_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_TGMATH_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
66

77
#include <nbl/builtin/hlsl/concepts/core.hlsl>
88
#include <nbl/builtin/hlsl/concepts/vector.hlsl>

src/nbl/builtin/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,15 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/matrix_utils/matrix_traits.hl
230230
#spirv intrinsics
231231
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/core.hlsl")
232232
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/fragment_shader_pixel_interlock.hlsl")
233+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/fragment_shader_barycentric.hlsl")
233234
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/raytracing.hlsl")
234235
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_arithmetic.hlsl")
235236
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_ballot.hlsl")
236237
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_basic.hlsl")
237238
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_shuffle.hlsl")
238239
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_vote.hlsl")
239240
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/glsl.std.450.hlsl")
241+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/output_structs.hlsl")
240242
#C++ compatibility
241243
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat.hlsl")
242244
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/basic.h")
@@ -359,5 +361,8 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/concepts/accessors/fft.hlsl")
359361
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/tgmath.hlsl")
360362
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/tgmath/impl.hlsl")
361363
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/tgmath/output_structs.hlsl")
364+
#blur
365+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/prefix_sum_blur/blur.hlsl")
366+
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/prefix_sum_blur/box_sampler.hlsl")
362367

363368
ADD_CUSTOM_BUILTIN_RESOURCES(nblBuiltinResourceData NBL_RESOURCES_TO_EMBED "${NBL_ROOT_PATH}/include" "nbl/builtin" "nbl::builtin" "${NBL_ROOT_PATH_BINARY}/include" "${NBL_ROOT_PATH_BINARY}/src" "STATIC" "INTERNAL")

0 commit comments

Comments
 (0)