11#include "debug.h"
22#include "pipeline.h"
33#include "pipeline_internal.h"
4+ #include "platform.h"
45#include "shaders.h"
56#include "vkrt_internal.h"
67#include "vkrt_types.h"
910#include <stdint.h>
1011#include <vulkan/vulkan_core.h>
1112
13+ static void logRayTracingPipelineCreateResult (const char * label , uint64_t startTime , VkResult result ) {
14+ LOG_TRACE (
15+ "%s vkCreateRayTracingPipelinesKHR returned %d in %.3f ms (synchronous)" ,
16+ label ,
17+ (int )result ,
18+ (double )(getMicroseconds () - startTime ) / 1e3
19+ );
20+ }
21+
22+ static void logElapsedTraceMs (const char * label , uint64_t startTime ) {
23+ LOG_TRACE ("%s in %.3f ms" , label , (double )(getMicroseconds () - startTime ) / 1e3 );
24+ }
25+
26+ static void logMainRayTracingPipelineCreated (
27+ uint64_t startTime ,
28+ VkBool32 useSerShaders ,
29+ VkRayTracingInvocationReorderModeNV serReorderingHintMode ,
30+ uint32_t shaderStageCount ,
31+ uint32_t shaderGroupCount
32+ ) {
33+ LOG_TRACE (
34+ "Main RT pipeline created. Variant: %s, SER hint: %s, Shader Stages: %u, Shader Groups: %u, in %.3f ms" ,
35+ useSerShaders ? "SER" : "default" ,
36+ serReorderingHintMode == VK_RAY_TRACING_INVOCATION_REORDER_MODE_REORDER_EXT ? "reorder" : "none" ,
37+ shaderStageCount ,
38+ shaderGroupCount ,
39+ (double )(getMicroseconds () - startTime ) / 1e3
40+ );
41+ }
42+
43+ static void logSelectionRayTracingPipelineCreated (uint64_t startTime ) {
44+ LOG_TRACE ("Selection RT pipeline created in %.3f ms" , (double )(getMicroseconds () - startTime ) / 1e3 );
45+ }
46+
1247static VkResult createRayTracingPipelineTracked (
1348 VKRT * vkrt ,
1449 const char * label ,
@@ -27,12 +62,7 @@ static VkResult createRayTracingPipelineTracked(
2762 NULL ,
2863 outPipeline
2964 );
30- LOG_TRACE (
31- "%s vkCreateRayTracingPipelinesKHR returned %d in %.3f ms (synchronous)" ,
32- label ,
33- (int )result ,
34- (double )(getMicroseconds () - createStartTime ) / 1e3
35- );
65+ logRayTracingPipelineCreateResult (label , createStartTime , result );
3666 return result ;
3767}
3868
@@ -50,7 +80,7 @@ VKRT_Result createRayTracingPipeline(VKRT* vkrt) {
5080 if (createRayTracingShaderModules (vkrt , & shaderVariant , & modules ) != VKRT_SUCCESS ) {
5181 return VKRT_ERROR_SHADER_COMPILATION_FAILED ;
5282 }
53- LOG_TRACE ("Main RT shader modules created in %.3f ms " , ( double )( getMicroseconds () - shaderModuleStartTime ) / 1e3 );
83+ logElapsedTraceMs ("Main RT shader modules created" , shaderModuleStartTime );
5484
5585 VkPipelineShaderStageCreateInfo shaderStages [] = {
5686 makePipelineShaderStageInfo (VK_SHADER_STAGE_RAYGEN_BIT_KHR , modules .rayGen [VKRT_MAIN_RAYGEN_GROUP_RGB ]),
@@ -112,16 +142,15 @@ VKRT_Result createRayTracingPipeline(VKRT* vkrt) {
112142 vkrt -> core .rayTracingPipeline = VK_NULL_HANDLE ;
113143 return VKRT_ERROR_OPERATION_FAILED ;
114144 }
115- LOG_TRACE ("Main RT stack sizes queried in %.3f ms " , ( double )( getMicroseconds () - stackSizeStartTime ) / 1e3 );
145+ logElapsedTraceMs ("Main RT stack sizes queried" , stackSizeStartTime );
116146
117147 destroyRayTracingShaderModules (vkrt , & modules );
118- LOG_TRACE (
119- "Main RT pipeline created. Variant: %s, SER hint: %s, Shader Stages: %u, Shader Groups: %u, in %.3f ms" ,
120- useSerShaders ? "SER" : "default" ,
121- vkrt -> core .serReorderingHintMode == VK_RAY_TRACING_INVOCATION_REORDER_MODE_REORDER_EXT ? "reorder" : "none" ,
148+ logMainRayTracingPipelineCreated (
149+ startTime ,
150+ useSerShaders ,
151+ vkrt -> core .serReorderingHintMode ,
122152 (uint32_t )VKRT_ARRAY_COUNT (shaderStages ),
123- (uint32_t )VKRT_ARRAY_COUNT (shaderGroups ),
124- (double )(getMicroseconds () - startTime ) / 1e3
153+ (uint32_t )VKRT_ARRAY_COUNT (shaderGroups )
125154 );
126155 return VKRT_SUCCESS ;
127156}
@@ -144,10 +173,7 @@ VKRT_Result createSelectionRayTracingPipeline(VKRT* vkrt) {
144173 createShaderModule (vkrt , shaderSelectRahitData , shaderSelectRahitSize , & anyHitModule ) != VKRT_SUCCESS ) {
145174 goto cleanup ;
146175 }
147- LOG_TRACE (
148- "Selection RT shader modules created in %.3f ms" ,
149- (double )(getMicroseconds () - shaderModuleStartTime ) / 1e3
150- );
176+ logElapsedTraceMs ("Selection RT shader modules created" , shaderModuleStartTime );
151177
152178 VkPipelineShaderStageCreateInfo shaderStages [] = {
153179 makePipelineShaderStageInfo (VK_SHADER_STAGE_RAYGEN_BIT_KHR , rayGenModule ),
@@ -190,10 +216,10 @@ VKRT_Result createSelectionRayTracingPipeline(VKRT* vkrt) {
190216 vkrt -> core .selectionRayTracingPipeline = VK_NULL_HANDLE ;
191217 goto cleanup ;
192218 }
193- LOG_TRACE ("Selection RT stack size queried in %.3f ms " , ( double )( getMicroseconds () - stackSizeStartTime ) / 1e3 );
219+ logElapsedTraceMs ("Selection RT stack size queried" , stackSizeStartTime );
194220
195221 result = VKRT_SUCCESS ;
196- LOG_TRACE ( "Selection RT pipeline created in %.3f ms" , ( double )( getMicroseconds () - startTime ) / 1e3 );
222+ logSelectionRayTracingPipelineCreated ( startTime );
197223
198224cleanup :
199225 if (rayGenModule != VK_NULL_HANDLE ) vkDestroyShaderModule (vkrt -> core .device , rayGenModule , NULL );
0 commit comments