From e31dd19000e1f880274cea7ac6efbb8a28a9ebde Mon Sep 17 00:00:00 2001 From: Sultim Tsyrendashiev Date: Fri, 29 Sep 2023 11:11:07 +0100 Subject: [PATCH] Rename swapchain primitive info Restore line drawing --- Include/RTGL1/RTGL1.h | 28 ++++++++++++++++++---------- Source/DrawFrameInfo.h | 6 +++--- Source/RasterizedDataCollector.cpp | 8 ++++++++ Source/VulkanDevice.cpp | 4 ++-- 4 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Include/RTGL1/RTGL1.h b/Include/RTGL1/RTGL1.h index 0240ae3c..347caacf 100644 --- a/Include/RTGL1/RTGL1.h +++ b/Include/RTGL1/RTGL1.h @@ -159,7 +159,7 @@ typedef enum RgStructureType RG_STRUCTURE_TYPE_MESH_PRIMITIVE_TEXTURE_LAYERS_EXT = 5, RG_STRUCTURE_TYPE_MESH_PRIMITIVE_PBR_EXT = 6, RG_STRUCTURE_TYPE_MESH_PRIMITIVE_ATTACHED_LIGHT_EXT = 7, - RG_STRUCTURE_TYPE_MESH_PRIMITIVE_FORCE_RASTERIZED_EXT = 8, + RG_STRUCTURE_TYPE_MESH_PRIMITIVE_SWAPCHAINED_EXT = 8, RG_STRUCTURE_TYPE_LIGHT_INFO = 9, RG_STRUCTURE_TYPE_LIGHT_DIRECTIONAL_EXT = 10, RG_STRUCTURE_TYPE_LIGHT_SPHERICAL_EXT = 11, @@ -436,16 +436,24 @@ typedef struct RgMeshPrimitiveAttachedLightEXT RgBool32 evenOnDynamic; } RgMeshPrimitiveAttachedLightEXT; -// Can be linked after RgMeshPrimitiveInfo. -typedef struct RgMeshPrimitiveForceRasterizedEXT +typedef enum RgMeshPrimitiveSwapchainedFlagBits { - RgStructureType sType; - void* pNext; - const RgViewport* pViewport; - const float* pView; - const float* pProjection; - const float* pViewProjection; -} RgMeshPrimitiveForceRasterizedEXT; + RG_MESH_PRIMITIVE_SWAPCHAINED_DRAW_AS_LINES = 1, +} RgMeshPrimitiveSwapchainedFlagBits; +typedef uint32_t RgMeshPrimitiveSwapchainedFlags; + +// To draw directly into a swapchain image, at full resolution. +// Can be linked after RgMeshPrimitiveInfo. +typedef struct RgMeshPrimitiveSwapchainedEXT +{ + RgStructureType sType; + void* pNext; + RgMeshPrimitiveSwapchainedFlags flags; + const RgViewport* pViewport; + const float* pView; + const float* pProjection; + const float* pViewProjection; +} RgMeshPrimitiveSwapchainedEXT; // Primitive is an indexed or non-indexed geometry with a material. typedef struct RgMeshPrimitiveInfo diff --git a/Source/DrawFrameInfo.h b/Source/DrawFrameInfo.h index a18e7b5c..5c0ed7ef 100644 --- a/Source/DrawFrameInfo.h +++ b/Source/DrawFrameInfo.h @@ -76,7 +76,7 @@ namespace detail template<> constexpr auto TypeToStructureType< RgMeshPrimitiveTextureLayersEXT > = RG_STRUCTURE_TYPE_MESH_PRIMITIVE_TEXTURE_LAYERS_EXT ; template<> constexpr auto TypeToStructureType< RgMeshPrimitivePBREXT > = RG_STRUCTURE_TYPE_MESH_PRIMITIVE_PBR_EXT ; template<> constexpr auto TypeToStructureType< RgMeshPrimitiveAttachedLightEXT > = RG_STRUCTURE_TYPE_MESH_PRIMITIVE_ATTACHED_LIGHT_EXT ; - template<> constexpr auto TypeToStructureType< RgMeshPrimitiveForceRasterizedEXT > = RG_STRUCTURE_TYPE_MESH_PRIMITIVE_FORCE_RASTERIZED_EXT ; + template<> constexpr auto TypeToStructureType< RgMeshPrimitiveSwapchainedEXT > = RG_STRUCTURE_TYPE_MESH_PRIMITIVE_SWAPCHAINED_EXT ; template<> constexpr auto TypeToStructureType< RgLensFlareInfo > = RG_STRUCTURE_TYPE_LENS_FLARE_INFO ; template<> constexpr auto TypeToStructureType< RgLightInfo > = RG_STRUCTURE_TYPE_LIGHT_INFO ; template<> constexpr auto TypeToStructureType< RgLightAdditionalEXT > = RG_STRUCTURE_TYPE_LIGHT_ADDITIONAL_EXT ; @@ -118,7 +118,7 @@ namespace detail static_assert( CheckMembers< RgMeshPrimitiveTextureLayersEXT >() ); static_assert( CheckMembers< RgMeshPrimitivePBREXT >() ); static_assert( CheckMembers< RgMeshPrimitiveAttachedLightEXT >() ); - static_assert( CheckMembers< RgMeshPrimitiveForceRasterizedEXT >() ); + static_assert( CheckMembers< RgMeshPrimitiveSwapchainedEXT >() ); static_assert( CheckMembers< RgLensFlareInfo >() ); static_assert( CheckMembers< RgLightInfo >() ); static_assert( CheckMembers< RgLightAdditionalEXT >() ); @@ -145,7 +145,7 @@ namespace detail template<> struct LinkRootHelper< RgMeshPrimitiveTextureLayersEXT >{ using Root = RgMeshPrimitiveInfo; }; template<> struct LinkRootHelper< RgMeshPrimitivePBREXT >{ using Root = RgMeshPrimitiveInfo; }; template<> struct LinkRootHelper< RgMeshPrimitiveAttachedLightEXT >{ using Root = RgMeshPrimitiveInfo; }; - template<> struct LinkRootHelper< RgMeshPrimitiveForceRasterizedEXT >{ using Root = RgMeshPrimitiveInfo; }; + template<> struct LinkRootHelper< RgMeshPrimitiveSwapchainedEXT >{ using Root = RgMeshPrimitiveInfo; }; template<> struct LinkRootHelper< RgOriginalTextureDetailsEXT >{ using Root = RgOriginalTextureInfo; }; template<> struct LinkRootHelper< RgLightAdditionalEXT >{ using Root = RgLightInfo; }; template<> struct LinkRootHelper< RgLightDirectionalEXT >{ using Root = RgLightInfo; }; diff --git a/Source/RasterizedDataCollector.cpp b/Source/RasterizedDataCollector.cpp index e30b70d7..2be93ca1 100644 --- a/Source/RasterizedDataCollector.cpp +++ b/Source/RasterizedDataCollector.cpp @@ -137,6 +137,14 @@ namespace } } + if( auto sw = pnext::find< RgMeshPrimitiveSwapchainedEXT >( &info ) ) + { + if( sw->flags & RG_MESH_PRIMITIVE_SWAPCHAINED_DRAW_AS_LINES ) + { + r = r | PipelineStateFlagBits::DRAW_AS_LINES; + } + } + return r; } diff --git a/Source/VulkanDevice.cpp b/Source/VulkanDevice.cpp index d58ae5aa..253e149f 100644 --- a/Source/VulkanDevice.cpp +++ b/Source/VulkanDevice.cpp @@ -1084,7 +1084,7 @@ void RTGL1::VulkanDevice::UploadMeshPrimitive( const RgMeshInfo* pMesh, auto uploadPrimitive_Core = [ this, &logDebugStat ]( const RgMeshInfo& mesh, const RgMeshPrimitiveInfo& prim ) { - assert( !pnext::find< RgMeshPrimitiveForceRasterizedEXT >( &prim ) ); + assert( !pnext::find< RgMeshPrimitiveSwapchainedEXT >( &prim ) ); if( IsRasterized( mesh, prim ) ) { @@ -1243,7 +1243,7 @@ void RTGL1::VulkanDevice::UploadMeshPrimitive( const RgMeshInfo* pMesh, } } - if( auto raster = pnext::find< RgMeshPrimitiveForceRasterizedEXT >( &prim ) ) + if( auto raster = pnext::find< RgMeshPrimitiveSwapchainedEXT >( &prim ) ) { float vp[ 16 ]; if( raster->pViewProjection )