Skip to content

Commit

Permalink
Finalize passthrough, standardize ext naming
Browse files Browse the repository at this point in the history
  • Loading branch information
1runeberg committed Nov 9, 2024
1 parent d15057b commit 716979c
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 73 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ file(GLOB_RECURSE XRVK_SHADERS
)

# Compile shaders
if(BUILD_SHADERS)
if(NOT ANDROID AND BUILD_SHADERS)
set(SHADER_OUTPUT_FILES)
foreach(SHADER ${XRVK_SHADERS})
# Get the filename with extension
Expand All @@ -160,7 +160,7 @@ if(BUILD_SHADERS)
endforeach()

# Create a custom target that depends on all shader output files
add_custom_target(CompileShaders ALL DEPENDS ${SHADER_OUTPUT_FILES})
add_custom_target(_compile_shaders ALL DEPENDS ${SHADER_OUTPUT_FILES})
endif()

# Set openxr
Expand Down Expand Up @@ -381,6 +381,6 @@ add_custom_command(TARGET ${XRLIB} POST_BUILD
# Compile shaders only if we're not in an android build
if(NOT ANDROID AND BUILD_SHADERS)
add_custom_command(TARGET ${XRLIB} POST_BUILD
COMMAND ${CMAKE_COMMAND} --build . --target CompileShaders
COMMAND ${CMAKE_COMMAND} --build . --target _compile_shaders
)
endif()
2 changes: 1 addition & 1 deletion include/xrlib/ext/EXT/hand_tracking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace xrlib::EXT
{
class CHandTracking : public ExtBase
class CHandTracking : public CExtBase
{
public:
CHandTracking( XrInstance xrInstance );
Expand Down
4 changes: 2 additions & 2 deletions include/xrlib/ext/FB/display_refresh_rate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

namespace xrlib::FB
{
class DisplayRefreshRate : public ExtBase
class CDisplayRefreshRate : public CExtBase
{
public:

DisplayRefreshRate( XrInstance xrInstance );
CDisplayRefreshRate( XrInstance xrInstance );

/// <summary>
/// Retrieve all supported display refresh rates from the openxr runtime that is valid for the running session and hardware
Expand Down
45 changes: 27 additions & 18 deletions include/xrlib/ext/FB/passthrough.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,30 @@

namespace xrlib::FB
{
class Passthrough : public xrlib::ExtBase_Passthrough
class CPassthrough : public xrlib::ExtBase_Passthrough
{
public:
struct PassthroughLayer
struct SPassthroughLayer
{
XrPassthroughLayerFB layer = XR_NULL_HANDLE;
XrCompositionLayerPassthroughFB composition { XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB };
XrPassthroughStyleFB style { XR_TYPE_PASSTHROUGH_STYLE_FB };
};

Passthrough( XrInstance xrInstance );
~Passthrough();
CPassthrough( XrInstance xrInstance );
~CPassthrough();

// Passthrough base functions
XrResult Init( XrSession session, CInstance *pInstance, void *pOtherInfo ) override;
// CPassthrough base functions
XrResult Init( XrSession session, CInstance *pInstance, void *pOtherInfo = nullptr ) override;

bool BSystemSupportsPassthrough();
bool BSystemSupportsColorPassthrough();

XrResult AddLayer( XrSession session, ELayerType eLayerType, XrCompositionLayerFlags flags,
XrResult AddLayer(
XrSession session,
ELayerType eLayerType,
XrCompositionLayerFlags flags,
XrFlags64 layerFlags = 0,
float fOpacity = 1.0f, XrSpace xrSpace = XR_NULL_HANDLE, void *pOtherInfo = nullptr ) override;
XrResult RemoveLayer( uint32_t unIndex ) override;

Expand All @@ -54,22 +61,22 @@ namespace xrlib::FB
XrResult PauseLayer( int index = -1 ) override;
XrResult ResumeLayer( int index = -1 ) override;

void GetCompositionLayers( std::vector< XrCompositionLayerBaseHeader * > &outCompositionLayers ) override;
void GetCompositionLayers( std::vector< XrCompositionLayerBaseHeader * > &outCompositionLayers, bool bReset = true ) override;

// FB Passthrough additional capabilities
std::vector< PassthroughLayer > *GetPassthroughLayers() { return &m_vecPassthroughLayers; }
// FB CPassthrough additional capabilities
std::vector< SPassthroughLayer > *GetPassthroughLayers() { return &m_vecPassthroughLayers; }

XrResult SetPassThroughOpacity( PassthroughLayer &refLayer, float fOpacity );
XrResult SetPassThroughEdgeColor( PassthroughLayer &refLayer, XrColor4f xrEdgeColor );
XrResult SetPassThroughParams( PassthroughLayer &refLayer, float fOpacity, XrColor4f xrEdgeColor );
XrResult SetPassThroughOpacity( SPassthroughLayer &refLayer, float fOpacity );
XrResult SetPassThroughEdgeColor( SPassthroughLayer &refLayer, XrColor4f xrEdgeColor );
XrResult SetPassThroughParams( SPassthroughLayer &refLayer, float fOpacity, XrColor4f xrEdgeColor );

XrResult SetStyleToMono( int index, float fOpacity = 1.0f );
XrResult SetStyleToColorMap( int index, bool bRed, bool bGreen, bool bBlue, float fAlpha = 1.0f, float fOpacity = 1.0f );
XrResult SetBCS( int index, float fOpacity = 1.0f, float fBrightness = 0.0f, float fContrast = 1.0f, float fSaturation = 1.0f );

// FB Triangle mesh
void SetTriangleMesh( TriangleMesh *pTriangleMesh );
TriangleMesh *GetTriangleMesh() { return m_pTriangleMesh; }
void SetTriangleMesh( CTriangleMesh *pTriangleMesh );
CTriangleMesh *GetTriangleMesh() { return m_pTriangleMesh; }
bool IsTriangleMeshSupported() { return m_pTriangleMesh && flagSupportedLayerTypes.IsSet( (int) ELayerType::MESH_PROJECTION ); }
bool CreateTriangleMesh( CInstance *pInstance );

Expand Down Expand Up @@ -110,14 +117,16 @@ namespace xrlib::FB


private:
// Passthrough layers
std::vector< PassthroughLayer > m_vecPassthroughLayers;
CInstance *m_pInstance = nullptr;

// CPassthrough layers
std::vector< SPassthroughLayer > m_vecPassthroughLayers;

// The main passthrough object which represents the passthrough feature
XrPassthroughFB m_fbPassthrough = XR_NULL_HANDLE;

// Triangle mesh extension for mesh projections of the passthrough layer
TriangleMesh *m_pTriangleMesh = nullptr;
CTriangleMesh *m_pTriangleMesh = nullptr;

// Geometry instances for mesh projections
std::vector< XrGeometryInstanceFB > m_vecGeometryInstances;
Expand Down
6 changes: 3 additions & 3 deletions include/xrlib/ext/FB/triangle_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

namespace xrlib::FB
{
class TriangleMesh : public ExtBase
class CTriangleMesh : public CExtBase
{
public:
TriangleMesh( XrInstance xrInstance );
~TriangleMesh();
CTriangleMesh( XrInstance xrInstance );
~CTriangleMesh();

std::vector< XrTriangleMeshFB > *GetMeshes() { return &m_vecMeshes; }

Expand Down
2 changes: 1 addition & 1 deletion include/xrlib/ext/KHR/visibility_mask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace xrlib::KHR
{
class CVisibilityMask : public ExtBase
class CVisibilityMask : public CExtBase
{
public:

Expand Down
6 changes: 3 additions & 3 deletions include/xrlib/ext/ext_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@

namespace xrlib
{
class ExtBase
class CExtBase
{
public:
ExtBase( XrInstance xrInstance, std::string sName ) :
CExtBase( XrInstance xrInstance, std::string sName ) :
m_xrInstance( xrInstance ),
m_sName( sName )
{
assert( xrInstance != XR_NULL_HANDLE );
assert( !sName.empty() );
}

~ExtBase() {};
~CExtBase() {};

std::string GetName() { return m_sName; }

Expand Down
10 changes: 5 additions & 5 deletions include/xrlib/ext/ext_base_passthrough.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace xrlib
{
struct Instance;
class ExtBase_Passthrough : public xrlib::ExtBase
class ExtBase_Passthrough : public xrlib::CExtBase
{
public:
enum class ELayerType
Expand All @@ -47,22 +47,22 @@ namespace xrlib

Flag8 flagSupportedLayerTypes { 0 };

ExtBase_Passthrough( XrInstance xrInstance, std::string sName ) : ExtBase ( xrInstance, sName ) {};
ExtBase_Passthrough( XrInstance xrInstance, std::string sName ) : CExtBase ( xrInstance, sName ) {};
~ExtBase_Passthrough() {};
bool IsActive() { return m_bIsActive; }

virtual XrResult Init( XrSession xrSession, CInstance *pInstance, void *pOtherInfo ) = 0;
virtual XrResult Init( XrSession xrSession, CInstance *pInstance, void *pOtherInfo = nullptr ) = 0;
virtual XrResult Start() = 0;
virtual XrResult Stop() = 0;
virtual XrResult PauseLayer( int index = -1 ) = 0;
virtual XrResult ResumeLayer( int index = -1 ) = 0;

virtual XrResult AddLayer( XrSession xrSession, ELayerType eLayerType, XrCompositionLayerFlags flags,
virtual XrResult AddLayer( XrSession xrSession, ELayerType eLayerType, XrCompositionLayerFlags flags, XrFlags64 layerFlags = 0,
float fOpacity = 1.0f, XrSpace xrSpace = XR_NULL_HANDLE, void* pOtherInfo = nullptr ) = 0;

virtual XrResult RemoveLayer( uint32_t unIndex ) = 0;

virtual void GetCompositionLayers( std::vector< XrCompositionLayerBaseHeader * > &outCompositionLayers ) = 0;
virtual void GetCompositionLayers( std::vector< XrCompositionLayerBaseHeader * > &outCompositionLayers, bool bReset = true ) = 0;

protected:
bool m_bIsActive = false;
Expand Down
4 changes: 4 additions & 0 deletions include/xrvk/render.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ namespace xrlib
XrFrameState frameState { XR_TYPE_FRAME_STATE };
XrViewState sharedEyeState { XR_TYPE_VIEW_STATE };
XrCompositionLayerProjection projectionLayer { XR_TYPE_COMPOSITION_LAYER_PROJECTION };
XrCompositionLayerFlags compositionLayerFlags = 0;
XrEnvironmentBlendMode environmentBlendMode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;

XrVector3f eyeScale = { 1.0f, 1.0f, 1.0f };
XrPosef hmdPose;
Expand All @@ -189,6 +191,8 @@ namespace xrlib
XrCompositionLayerProjectionView { XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW } };

std::vector< XrCompositionLayerBaseHeader * > frameLayers;
std::vector< XrCompositionLayerBaseHeader * > preAppFrameLayers;
std::vector< XrCompositionLayerBaseHeader * > postAppFrameLayers;

std::vector< CDeviceBuffer * > vecStagingBuffers;

Expand Down
2 changes: 1 addition & 1 deletion src/ext/EXT/hand_tracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace xrlib::EXT
}

CHandTracking::CHandTracking( XrInstance xrInstance ) :
ExtBase( xrInstance, XR_EXT_HAND_TRACKING_EXTENSION_NAME)
CExtBase( xrInstance, XR_EXT_HAND_TRACKING_EXTENSION_NAME)
{
// Initialize function pointers
XrResult result = INIT_PFN( xrInstance, xrLocateHandJointsEXT );
Expand Down
10 changes: 5 additions & 5 deletions src/ext/FB/display_refresh_rate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

namespace xrlib::FB
{
DisplayRefreshRate::DisplayRefreshRate( XrInstance xrInstance ) :
ExtBase( xrInstance, XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME )
CDisplayRefreshRate::CDisplayRefreshRate( XrInstance xrInstance ) :
CExtBase( xrInstance, XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME )
{
// Initialize all function pointers available for this extension
INIT_PFN( xrInstance, xrEnumerateDisplayRefreshRatesFB );
INIT_PFN( xrInstance, xrGetDisplayRefreshRateFB );
INIT_PFN( xrInstance, xrRequestDisplayRefreshRateFB );
}

XrResult DisplayRefreshRate::GetSupportedRefreshRates( XrSession xrSession, std::vector< float > &outSupportedRefreshRates )
XrResult CDisplayRefreshRate::GetSupportedRefreshRates( XrSession xrSession, std::vector< float > &outSupportedRefreshRates )
{
// Get the refresh rate count capacity
uint32_t unRefreshRateCount = 0;
Expand All @@ -54,7 +54,7 @@ namespace xrlib::FB
return xrResult;
}

float DisplayRefreshRate::GetCurrentRefreshRate( XrSession xrSession )
float CDisplayRefreshRate::GetCurrentRefreshRate( XrSession xrSession )
{
float outRefreshRate = 0.0f;
XrResult xrResult = xrGetDisplayRefreshRateFB( xrSession, &outRefreshRate );
Expand All @@ -68,7 +68,7 @@ namespace xrlib::FB
return outRefreshRate;
}

XrResult DisplayRefreshRate::RequestRefreshRate( XrSession xrSession, float fRequestedRefreshRate )
XrResult CDisplayRefreshRate::RequestRefreshRate( XrSession xrSession, float fRequestedRefreshRate )
{

XrResult xrResult = xrRequestDisplayRefreshRateFB( xrSession, fRequestedRefreshRate );
Expand Down
Loading

0 comments on commit 716979c

Please sign in to comment.