Skip to content
Merged
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
2 changes: 1 addition & 1 deletion DX12AgilitySDK.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -- Agility SDK Configuration ---

set(DX12_AGILITY_SDK_PATH "${CMAKE_SOURCE_DIR}/vendor/DX12AgilitySDK")
set(DX12_AGILITY_SDK_PATH "${CMAKE_CURRENT_SOURCE_DIR}/vendor/DX12AgilitySDK")

set(DX12_AGILITY_SDK_INCLUDE_PATH "${DX12_AGILITY_SDK_PATH}/build/native/include")
set(DX12_AGILITY_SDK_BIN_PATH "${DX12_AGILITY_SDK_PATH}/build/native/bin/x64")
15 changes: 13 additions & 2 deletions PyroRHI/Api/AccelerationStructure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ namespace PyroshockStudios {
static constexpr inline AccelerationStructureGeometryFlags NO_DUPLICATE_ANY_HIT_INVOCATION = { 0x00000002 };
};

using AccelerationStructureGeometryInstanceFlags = u32;
struct AccelerationStructureGeometryInstanceFlagBits {
static constexpr inline AccelerationStructureGeometryInstanceFlags NONE = { 0x00 };
static constexpr inline AccelerationStructureGeometryInstanceFlags TRIANGLE_FACING_CULL_DISABLE = { 0x01 };
static constexpr inline AccelerationStructureGeometryInstanceFlags TRIANGLE_FLIP_FACING = { 0x02 };
static constexpr inline AccelerationStructureGeometryInstanceFlags FORCE_OPAQUE = { 0x04 };
static constexpr inline AccelerationStructureGeometryInstanceFlags FORCE_NO_OPAQUE = { 0x08 };
static constexpr inline AccelerationStructureGeometryInstanceFlags FORCE_OPACITY_MICROMAP_STATE = { 0x10 };
static constexpr inline AccelerationStructureGeometryInstanceFlags DISABLE_OPACITY_MICROMAPS = { 0x20 };
};

struct BlasTriangleGeometryInfo {
Format vertexFormat = Format::Undefined; ///< Required, vertex format. How the BLAS should interpret the vertices.
IndexType indexType = IndexType::None; ///< Optional index format, if type is NONE, indexBuffer is expected to be PYRO_NULL_BUFFER
Expand Down Expand Up @@ -125,7 +136,7 @@ namespace PyroshockStudios {
u32 instanceCustomIndex : 24;
u32 mask : 8;
u32 instanceShaderBindingTableRecordOffset : 24;
u32 flags : 8;
AccelerationStructureGeometryInstanceFlags flags : 8;
BlasAddress blasAddress = PYRO_NULL_BLAS_ADDRESS;
};

Expand All @@ -134,7 +145,7 @@ namespace PyroshockStudios {
struct TlasInstanceInfo {
Buffer data = {};
u32 count = {};
//bool bDataArrayOfPointers = {};
// bool bDataArrayOfPointers = {};
AccelerationStructureGeometryFlags flags = AccelerationStructureGeometryFlagBits::OPAQUE; ///< Attribute for opaque/transparent instance
};

Expand Down
45 changes: 39 additions & 6 deletions PyroRHI/Api/ICommandBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ namespace PyroshockStudios {
/**
* @brief Parameters describing a buffer memory barrier.
*
* Used to synchronize access to buffer resources between pipeline stages or queues.
* Used to synchronize access to buffer resources between pipeline stages or layouts.
*/
struct BufferMemoryBarrierInfo {
/// @brief Buffer handle to apply the barrier to.
Expand Down Expand Up @@ -314,7 +314,7 @@ namespace PyroshockStudios {
/**
* @brief Parameters describing an image memory barrier.
*
* Used to synchronize access to image resources between pipeline stages, layouts, or queues.
* Used to synchronize access to image resources between pipeline stages or layouts.
*/
struct ImageMemoryBarrierInfo {
/// @brief Image handle to apply the barrier to.
Expand All @@ -340,6 +340,26 @@ namespace PyroshockStudios {
PYRO_NODISCARD eastl::string ToString(usize indentation = 0) const;
};

/**
* @brief Parameters describing an acceleration structure barrier.
*
* Used to synchronize access to BLAS/TLAS resources between pipeline stages, layouts, or queues.
*/
struct AccelerationStructureBarrierInfo {
/// @brief BLAS/TLAS handle to apply the barrier to.
eastl::variant<BlasId, TlasId> accelerationStructure = PYRO_NULL_BLAS;

/// @brief Source access flags (before the barrier).
Access srcAccess = AccessConsts::NONE;

/// @brief Destination access flags (after the barrier).
Access dstAccess = AccessConsts::NONE;

PYRO_NODISCARD bool operator==(const AccelerationStructureBarrierInfo&) const = default;
PYRO_NODISCARD bool operator!=(const AccelerationStructureBarrierInfo&) const = default;
PYRO_NODISCARD eastl::string ToString(usize indentation = 0) const;
};

/**
* @brief Parameters for invalidating timestamp queries on the command buffer.
*/
Expand Down Expand Up @@ -389,7 +409,7 @@ namespace PyroshockStudios {
/**
* @brief Name for the label, useful for profiling or debugging.
*/
eastl::string_view name = {};
eastl::string name = {};

PYRO_NODISCARD bool operator==(const CommandLabelInfo&) const = default;
PYRO_NODISCARD bool operator!=(const CommandLabelInfo&) const = default;
Expand Down Expand Up @@ -750,15 +770,22 @@ namespace PyroshockStudios {
// ---------------------------------------------------------------------

/**
* @brief Inserts a barrier for synchronizing buffer memory accesses. *MUST* be called outside of a renderpass
* @brief Inserts a barrier for synchronizing buffer memory accesses. *MUST* be called outside of a renderpass.
*/
virtual void BufferBarrier(const BufferMemoryBarrierInfo& info) = 0;

/**
* @brief Inserts a barrier for synchronizing image memory accesses. *MUST* be called outside of a renderpass
* @brief Inserts a barrier for synchronizing image memory accesses. *MUST* be called outside of a renderpass.
*/
virtual void ImageBarrier(const ImageMemoryBarrierInfo& info) = 0;

/**
* @brief - REQUIRES ACCELERATION STRUCTURE SUPPORT -
* Inserts a barrier for synchronizing acceleration structure accesses. Use this for synchronising builds/updates.
* *MUST* be called outside of a renderpass.
*/
virtual void AccelerationStructureBarrier(const AccelerationStructureBarrierInfo& info) = 0;

// ---------------------------------------------------------------------
// Synchronization
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -943,7 +970,13 @@ namespace PyroshockStudios {
// ---------------------------------------------------------------------
// Ray tracing and Acceleration structures
// ---------------------------------------------------------------------


/**
* @brief - REQUIRES ACCELERATION STRUCTURE SUPPORT -
* Builds/updates a list of BLAS/TLAS. *MUST* be called outside of a renderpass.
* NOTE: It is **INVALID** to build a TLAS in the same call that relies on a BLAS build. For a TLAS build to successfully complete,
* its BLAS must have been built in a previous BuildAccelerationStructures() call, and a AccelerationStructureBarrier().
*/
virtual void BuildAccelerationStructures(const BuildAccelerationStructuresInfo& info) = 0;


Expand Down
18 changes: 11 additions & 7 deletions PyroRHI/Api/IDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ namespace PyroshockStudios {
* If `bDefer` is true, the object will be scheduled to be destroyed after all queue submits have completed, and `CollectGarbage()` is required to be called.
*/
virtual void DestroyTimestampQueryPool(ITimestampQueryPool*& queryPool, bool bDefer = false) = 0;

/**
* @brief - REQUIRES ACCELERATION STRUCTURE SUPPORT -
* @brief Destroys the BLAS.
Expand Down Expand Up @@ -840,17 +840,21 @@ namespace PyroshockStudios {
*/
PYRO_NODISCARD virtual DeviceStatusInfo Status() const = 0;


// ---------------------------------------------------------------------
// Device configuration
// ---------------------------------------------------------------------

/**
* @brief Sets the shader model version that the device will be expecting from now on.
* FORMAT: 0xMAJORMINOR
* e.g. for DirectX ShaderModel 5.1 -> 0x51
* e.g. for Vulkan SPIR-V 1.3 -> 0x13
*/
* @brief Gets the current shader model version that has been configured.
*/
PYRO_NODISCARD virtual u32 GetActiveShaderModel() const = 0;
/**
* @brief Sets the shader model version that the device will be expecting from now on.
* FORMAT: 0xMAJORMINOR
* e.g. for DirectX ShaderModel 5.1 -> 0x51
* e.g. for Vulkan SPIR-V 1.3 -> 0x13
*/
virtual void SetShaderModel(u32 shaderModel) = 0;
};
} // namespace RHI
Expand Down
16 changes: 16 additions & 0 deletions PyroRHI/Api/ToString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,22 @@ namespace PyroshockStudios {
return s;
}

inline eastl::string AccelerationStructureBarrierInfo::ToString(usize indentation) const {
eastl::string s;
s += "AccelerationStructureBarrierInfo {\n";
if (eastl::holds_alternative<BlasId>(accelerationStructure)) {
s += Indent(indentation + 2) + "BLAS: " + ToHexH64(eastl::get<BlasId>(accelerationStructure)) + "\n";
} else if (eastl::holds_alternative<TlasId>(accelerationStructure)) {
s += Indent(indentation + 2) + "TLAS: " + ToHexH64(eastl::get<TlasId>(accelerationStructure)) + "\n";
} else {
s += Indent(indentation + 2) + "!BAD VARIANT!\n";
}
s += Indent(indentation + 2) + "srcAccess: " + srcAccess.ToString() + "\n";
s += Indent(indentation + 2) + "dstAccess: " + dstAccess.ToString() + "\n";
s += Indent(indentation) + "}";
return s;
}

inline eastl::string InvalidateTimestampQueryInfo::ToString(usize indentation) const {
eastl::string s;
s += "InvalidateTimestampQueryInfo {\n";
Expand Down
29 changes: 16 additions & 13 deletions PyroRHI/Context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
#pragma once
#include <PyroCommon/Core.hpp>
#include <PyroCommon/LoggerInterface.hpp>
#include <PyroRHI/Core.hpp>
#include <PyroRHI/Api/Forward.hpp>
#include <PyroRHI/Core.hpp>
#include <PyroRHI/Shader/Forward.hpp>
#include <PyroRHI/Shader/ShaderModelFeature.hpp>

namespace PyroshockStudios {
inline namespace RHI {
Expand All @@ -38,14 +39,15 @@ namespace PyroshockStudios {
RightHanded_OriginBottomLeft
};
struct RHIProperties {
bool bHeadlessEnvironment = false;
bool bBufferDeviceAddress = false;
bool bDrawIndirectCount = false;
bool bUint8IndexBuffer = false;
bool bTesselationShader = false;
bool bGeometryShader = false;
bool bBCnTextureCompression = false;
RHIViewportConvention viewportConvention = RHIViewportConvention::None;
bool bHeadlessEnvironment = false; ///< No windowing system is required for full api usage.
bool bBufferDeviceAddress = false; ///< Supports using 64 bit device addresses in shaders.
bool bDrawIndirectCount = false; ///< Can use a count buffer alongside indirect drawing.
bool bUint8IndexBuffer = false; ///< Supports 8 bit index buffers
bool bTesselationShader = false; ///< Supports Hull and Domain shaders
bool bGeometryShader = false; ///< Supports Geometry shaders
bool bBCnTextureCompression = false; ///< Supports BC1-7 compression
bool bEnhancedUndefinedLayoutTransitions = false; ///< Supports transitioning a resource from Undefined if the prior layout is not Undefined.
RHIViewportConvention viewportConvention = RHIViewportConvention::None; ///< States the convention of the viewport to keep display consistent across APIs.
};

class RHIContext : ILoggerAware, DeleteCopy, DeleteMove {
Expand All @@ -55,8 +57,9 @@ namespace PyroshockStudios {

virtual IDevice* CreateDevice() = 0;

virtual const RHIProperties& Properties() = 0;
virtual IShaderFeatureSet* ShaderFeatureSet() = 0;
virtual const RHIProperties& Properties() const = 0;
virtual const IShaderFeatureSet* ShaderFeatureSet() const = 0;
virtual u32 GetMinimumShaderModelFeatureTier(ShaderModelFeatureFlags shaderModelFeatures) const = 0;
};
}
}
} // namespace RHI
} // namespace PyroshockStudios
75 changes: 75 additions & 0 deletions PyroRHI/Shader/ShaderModelFeature.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#pragma once
#include <PyroCommon/Types.hpp>
namespace PyroshockStudios {
inline namespace RHI {
struct ShaderModelFeatureFlagProperties {
using Data = u64;
};
using ShaderModelFeatureFlags = Flags<ShaderModelFeatureFlagProperties>;
struct ShaderModelFeatureBits {
// --- Baseline Features (SM 5.1 / SPIR-V 1.3+) ---

/** * @brief Wave Intrinsics (e.g., WaveGetLaneIndex, WaveActiveSum).
* - HLSL: Shader Model 6.0+
* - SPIR-V: 1.3+ (Core in Vulkan 1.1) with GroupNonUniform capabilities.
*/
static constexpr inline ShaderModelFeatureFlags SUBGROUP_OPERATIONS = { 0x0000000001 };

/**
* @brief 64-bit integer types (uint64_t, int64_t).
* - HLSL: Shader Model 6.0+
* - SPIR-V: Requires 'Int64' capability.
*/
static constexpr inline ShaderModelFeatureFlags SHADER_INT64 = { 0x0000000002 };

/**
* @brief 16-bit float types (half, float16_t).
* - HLSL: Shader Model 6.0+ (and 6.2+ for more ops)
* - SPIR-V: Requires 'Float16' capability.
*/
static constexpr inline ShaderModelFeatureFlags SHADER_FLOAT16 = { 0x0000000004 };

/**
* @brief Conservative Rasterization.
* - HLSL: Shader Model 6.0+ (Tied to API capability)
* - SPIR-V: Requires 'SPV_EXT_conservative_rasterization' extension.
*/
static constexpr inline ShaderModelFeatureFlags CONSERVATIVE_RASTERIZATION = { 0x0000000008 };

/**
* @brief Ray Tracing (Gen Shaders, Hit Shaders, etc.).
* - HLSL: Shader Model 6.3+ (DXR)
* - SPIR-V: 1.4+ (Requires 'SPV_KHR_ray_tracing' or similar extension)
*/
static constexpr inline ShaderModelFeatureFlags RAY_TRACING = { 0x0000000010 };

/**
* @brief Inline Ray Tracing (TraceRaysInline).
* - HLSL: Shader Model 6.5+
* - SPIR-V: 1.4+ (Requires 'SPV_KHR_ray_query' or similar extension)
*/
static constexpr inline ShaderModelFeatureFlags RAY_QUERY = { 0x0000000020 };

/**
* @brief Variable Rate Shading (VRS).
* - HLSL: Shader Model 6.4+
* - SPIR-V: 1.5+ (Requires 'SPV_KHR_fragment_shading_rate' extension)
*/
static constexpr inline ShaderModelFeatureFlags VARIABLE_RATE_SHADING = { 0x0000000040 };

/**
* @brief Mesh and Task Shaders.
* - HLSL: Shader Model 6.5+
* - SPIR-V: 1.5+ (Requires 'SPV_EXT_mesh_shader' extension)
*/
static constexpr inline ShaderModelFeatureFlags MESH_SHADER = { 0x0000000080 };

/**
* @brief Atomic operations on 64-bit integers.
* - HLSL: Shader Model 6.6+
* - SPIR-V: Requires 'AtomicInt64' capability.
*/
static constexpr inline ShaderModelFeatureFlags SHADER_INT64_ATOMICS = { 0x0000000100 };
};
} // namespace RHI
} // namespace PyroshockStudios
Loading
Loading