Skip to content
Merged
12 changes: 10 additions & 2 deletions include/nbl/builtin/hlsl/spirv_intrinsics/core.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_CORE_INCLUDED_
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_CORE_INCLUDED_


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

#include <nbl/builtin/hlsl/vector_utils/vector_traits.hlsl>
#include "nbl/builtin/hlsl/type_traits.hlsl"
#include <nbl/builtin/hlsl/type_traits.hlsl>
#include <nbl/builtin/hlsl/concepts.hlsl>
#include <nbl/builtin/hlsl/spirv_intrinsics/output_structs.hlsl>

namespace nbl
{
Expand Down Expand Up @@ -300,6 +300,14 @@ template<typename BooleanVector>
[[vk::ext_instruction(spv::OpAny)]]
enable_if_t<is_vector_v<BooleanVector>&& is_same_v<typename vector_traits<BooleanVector>::scalar_type, bool>, BooleanVector> any(BooleanVector vec);

template<typename T NBL_FUNC_REQUIRES(concepts::UnsignedIntegral<T>)
[[vk::ext_instruction(spv::OpIAddCarry)]]
AddCarryOutput<T> AddCarry(T operand1, T operand2);

template<typename T NBL_FUNC_REQUIRES(concepts::UnsignedIntegral<T>)
[[vk::ext_instruction(spv::OpISubBorrow)]]
SubBorrowOutput<T> SubBorrow(T operand1, T operand2);

}

#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_FRAGMENT_SHADER_BARYCENTRIC_INCLUDED_
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_FRAGMENT_SHADER_BARYCENTRIC_INCLUDED_

#include "spirv/unified1/spirv.hpp"

namespace nbl
{
namespace hlsl
{
namespace spirv
{

[[vk::ext_capability(/*spv::CapabilityFragmentBarycentricKHR*/5284)]]
[[vk::ext_extension("SPV_KHR_fragment_shader_barycentric")]]
[[vk::ext_builtin_input(/*spv::BuiltInBaryCoordKHR*/5286)]]
static const float32_t3 BaryCoordKHR;

[[vk::ext_capability(/*spv::CapabilityFragmentBarycentricKHR*/5284)]]
[[vk::ext_extension("SPV_KHR_fragment_shader_barycentric")]]
[[vk::ext_builtin_input(/*spv::BuiltInBaryCoordKHR*/5287)]]
static const float32_t3 BaryCoordNoPerspKHR;

}
}
}

#endif
36 changes: 36 additions & 0 deletions include/nbl/builtin/hlsl/spirv_intrinsics/output_structs.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_

#include <nbl/builtin/hlsl/concepts/core.hlsl>

namespace nbl
{
namespace hlsl
{

template<typename T NBL_STRUCT_CONSTRAINABLE>
struct AddCarryOutput;
template<typename T NBL_STRUCT_CONSTRAINABLE>
struct SubBorrowOutput;


template<typename T> NBL_PARTIAL_REQ_TOP(concepts::UnsignedIntegral<T>)
struct AddCarryOutput<T NBL_PARTIAL_REQ_BOT(concepts::UnsignedIntegral<T>) >
{
T result;
T carry;
};

template<typename T> NBL_PARTIAL_REQ_TOP(concepts::UnsignedIntegral<T>)
struct SubBorrowOutput<T NBL_PARTIAL_REQ_BOT(concepts::UnsignedIntegral<T>) >
{
T result;
T borrow;
};
}
}

#endif
4 changes: 2 additions & 2 deletions include/nbl/builtin/hlsl/tgmath/output_structs.hlsl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
#define _NBL_BUILTIN_HLSL_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
#ifndef _NBL_BUILTIN_HLSL_TGMATH_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_
#define _NBL_BUILTIN_HLSL_TGMATH_SPIRV_INTRINSICS_OUTPUT_STRUCTS_INCLUDED_

#include <nbl/builtin/hlsl/concepts/core.hlsl>
#include <nbl/builtin/hlsl/concepts/vector.hlsl>
Expand Down
5 changes: 5 additions & 0 deletions src/nbl/builtin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/matrix_utils/matrix_traits.hl
#spirv intrinsics
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/core.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/fragment_shader_pixel_interlock.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/fragment_shader_barycentric.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/raytracing.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_arithmetic.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_ballot.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_basic.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_shuffle.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/subgroup_vote.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/glsl.std.450.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/spirv_intrinsics/output_structs.hlsl")
#C++ compatibility
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/cpp_compat/basic.h")
Expand Down Expand Up @@ -359,5 +361,8 @@ LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/concepts/accessors/fft.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/tgmath.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/tgmath/impl.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/tgmath/output_structs.hlsl")
#blur
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/prefix_sum_blur/blur.hlsl")
LIST_BUILTIN_RESOURCE(NBL_RESOURCES_TO_EMBED "hlsl/prefix_sum_blur/box_sampler.hlsl")

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")