@@ -517,19 +517,6 @@ pl_renderer_initialize(plRendererSettings tSettings)
517517 gptData -> ptStagingUnCachedBuddyAllocator = gptGpuAllocators -> get_staging_uncached_buddy_allocator (gptData -> ptDevice );
518518 gptData -> ptStagingCachedAllocator = gptGpuAllocators -> get_staging_cached_allocator (gptData -> ptDevice );
519519
520- // create staging buffers
521- // const plBufferDesc tStagingBufferDesc = {
522- // .tUsage = PL_BUFFER_USAGE_STAGING,
523- // .szByteSize = 268435456,
524- // .pcDebugName = "Renderer Staging Buffer"
525- // };
526- // for(uint32_t i = 0; i < gptGfx->get_frames_in_flight(); i++)
527- // {
528- // gptData->atStagingBufferHandle[i].tStagingBufferHandle = pl__renderer_create_staging_buffer(&tStagingBufferDesc, "staging", i);
529- // gptData->atStagingBufferHandle[i].szOffset = 0;
530- // gptData->atStagingBufferHandle[i].szSize = tStagingBufferDesc.szByteSize;
531- // }
532-
533520 // create dummy textures
534521 const plTextureDesc tDummyTextureDesc = {
535522 .tDimensions = {2 , 2 , 1 },
@@ -984,16 +971,17 @@ pl_renderer_create_scene(plSceneInit tInit)
984971 // create global bindgroup
985972 ptScene -> uTextureIndexCount = 0 ;
986973
987-
988974 for (uint32_t i = 0 ; i < gptGfx -> get_frames_in_flight (); i ++ )
989975 {
976+ // create global bindgroup
990977 const plBindGroupDesc tGlobalBindGroupDesc = {
991978 .ptPool = gptData -> ptBindGroupPool ,
992979 .tLayout = gptData -> tGlobalSceneBindGroupLayout ,
993980 .pcDebugName = "global bind group"
994981 };
995982 ptScene -> atGlobalBindGroup [i ] = gptGfx -> create_bind_group (gptData -> ptDevice , & tGlobalBindGroupDesc );
996983
984+ // partially update global bindgroup (just samplers)
997985 plBindGroupUpdateSamplerData tGlobalSamplerData [] = {
998986 {
999987 .tSampler = gptData -> tDefaultSampler ,
@@ -1006,16 +994,15 @@ pl_renderer_create_scene(plSceneInit tInit)
1006994 };
1007995
1008996 plBindGroupUpdateData tGlobalBindGroupData = {
1009- .uSamplerCount = 2 ,
997+ .uSamplerCount = 2 ,
1010998 .atSamplerBindings = tGlobalSamplerData ,
1011999 };
1012-
10131000 gptGfx -> update_bind_group (gptData -> ptDevice , ptScene -> atGlobalBindGroup [i ], & tGlobalBindGroupData );
10141001 }
10151002
1003+ // pre-create some global buffers, later we should defer this
10161004 const plBufferDesc atLightShadowDataBufferDesc = {
10171005 .tUsage = PL_BUFFER_USAGE_STORAGE | PL_BUFFER_USAGE_STAGING ,
1018- // .szByteSize = 134217728,
10191006 .szByteSize = PL_MAX_LIGHTS * sizeof (plGPULightShadowData ),
10201007 .pcDebugName = "shadow data buffer"
10211008 };
@@ -1034,14 +1021,12 @@ pl_renderer_create_scene(plSceneInit tInit)
10341021
10351022 for (uint32_t i = 0 ; i < gptGfx -> get_frames_in_flight (); i ++ )
10361023 {
1037-
10381024 ptScene -> atLightShadowDataBuffer [i ] = pl__renderer_create_staging_buffer (& atLightShadowDataBufferDesc , "shadow buffer" , i );
1039- ptScene -> atShadowCameraBuffers [i ] = pl__renderer_create_staging_buffer (& atCameraBuffersDesc , "shadow camera buffer" , i );
1040-
1041- ptScene -> atGPUProbeDataBuffers [i ] = pl__renderer_create_staging_buffer (& atProbeDataBufferDesc , "probe buffer" , i );
1042-
1025+ ptScene -> atShadowCameraBuffers [i ] = pl__renderer_create_staging_buffer (& atCameraBuffersDesc , "shadow camera buffer" , i );
1026+ ptScene -> atGPUProbeDataBuffers [i ] = pl__renderer_create_staging_buffer (& atProbeDataBufferDesc , "probe buffer" , i );
10431027 }
10441028
1029+ // pre-create working buffers for environment filtering, later we should defer this
10451030 for (uint32_t i = 0 ; i < 7 ; i ++ )
10461031 {
10471032 const size_t uMaxFaceSize = ((size_t )1024 * (size_t )1024 ) * 4 * sizeof (float );
@@ -1054,6 +1039,7 @@ pl_renderer_create_scene(plSceneInit tInit)
10541039 ptScene -> atFilterWorkingBuffers [i ] = pl__renderer_create_local_buffer (& tInputBufferDesc , "filter buffer" , i , NULL , 0 );
10551040 }
10561041
1042+ // create probe material & mesh
10571043 plMaterialComponent * ptMaterial = NULL ;
10581044 plEntity tMaterial = pl_renderer_create_material (ptScene -> ptComponentLibrary , "environment probe material" , & ptMaterial );
10591045 ptMaterial -> tBlendMode = PL_BLEND_MODE_OPAQUE ;
@@ -1067,8 +1053,8 @@ pl_renderer_create_scene(plSceneInit tInit)
10671053 ptScene -> tProbeMesh = gptMesh -> create_sphere_mesh (ptScene -> ptComponentLibrary , "environment probe mesh" , 0.25f , 32 , 32 , & ptMesh );
10681054 ptMesh -> tMaterial = tMaterial ;
10691055
1056+ // create shadow atlas
10701057 ptScene -> uShadowAtlasResolution = 1024 * 8 ;
1071-
10721058 const plTextureDesc tShadowDepthTextureDesc = {
10731059 .tDimensions = {(float )ptScene -> uShadowAtlasResolution , (float )ptScene -> uShadowAtlasResolution , 1 },
10741060 .tFormat = PL_FORMAT_D16_UNORM ,
@@ -1078,7 +1064,9 @@ pl_renderer_create_scene(plSceneInit tInit)
10781064 .tUsage = PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT | PL_TEXTURE_USAGE_SAMPLED ,
10791065 .pcDebugName = "shadow map"
10801066 };
1067+ ptScene -> tShadowTexture = pl__renderer_create_local_texture (& tShadowDepthTextureDesc , "shadow map" , 0 , PL_TEXTURE_USAGE_SAMPLED );
10811068
1069+ // create shadow map render passes
10821070 const plRenderPassDesc tDepthRenderPassDesc = {
10831071 .tLayout = gptData -> tDepthRenderPassLayout ,
10841072 .tDepthTarget = {
@@ -1108,16 +1096,15 @@ pl_renderer_create_scene(plSceneInit tInit)
11081096 };
11091097
11101098 plRenderPassAttachments atShadowAttachmentSets [PL_MAX_FRAMES_IN_FLIGHT ] = {0 };
1111- ptScene -> tShadowTexture = pl__renderer_create_local_texture (& tShadowDepthTextureDesc , "shadow map" , 0 , PL_TEXTURE_USAGE_SAMPLED );
11121099 ptScene -> atShadowTextureBindlessIndices = pl__renderer_get_bindless_texture_index (ptScene , ptScene -> tShadowTexture );
11131100 for (uint32_t i = 0 ; i < gptGfx -> get_frames_in_flight (); i ++ )
11141101 {
11151102 atShadowAttachmentSets [i ].atViewAttachments [0 ] = ptScene -> tShadowTexture ;
11161103 }
1117-
11181104 ptScene -> tShadowRenderPass = gptGfx -> create_render_pass (gptData -> ptDevice , & tDepthRenderPassDesc , atShadowAttachmentSets );
11191105 ptScene -> tFirstShadowRenderPass = gptGfx -> create_render_pass (gptData -> ptDevice , & tFirstDepthRenderPassDesc , atShadowAttachmentSets );
11201106
1107+ // create tonemap shader
11211108 const plShaderDesc tTonemapShaderDesc = {
11221109 .tPixelShader = gptShader -> load_glsl ("tonemap.frag" , "main" , NULL , NULL ),
11231110 .tVertexShader = gptShader -> load_glsl ("full_quad.vert" , "main" , NULL , NULL ),
@@ -2158,56 +2145,6 @@ pl_renderer_outline_entities(plScene* ptScene, uint32_t uCount, plEntity* atEnti
21582145 {
21592146 plEntity tEntity = ptScene -> sbtOutlinedEntities [i ];
21602147
2161- plObjectComponent * ptObject = gptECS -> get_component (ptScene -> ptComponentLibrary , gptData -> tObjectComponentType , tEntity );
2162- plMeshComponent * ptMesh = gptECS -> get_component (ptScene -> ptComponentLibrary , tMeshComponentType , ptObject -> tMesh );
2163- plMaterialComponent * ptMaterial = gptECS -> get_component (ptScene -> ptComponentLibrary , gptData -> tMaterialComponentType , ptMesh -> tMaterial );
2164-
2165- int iDataStride = 0 ;
2166- int iFlagCopy0 = (int )ptMesh -> ulVertexStreamMask ;
2167- while (iFlagCopy0 )
2168- {
2169- iDataStride += iFlagCopy0 & 1 ;
2170- iFlagCopy0 >>= 1 ;
2171- }
2172-
2173- int iTextureMappingFlags = 0 ;
2174- for (uint32_t j = 0 ; j < PL_TEXTURE_SLOT_COUNT ; j ++ )
2175- {
2176- if ((ptMaterial -> atTextureMaps [j ].acName [0 ] != 0 ))
2177- iTextureMappingFlags |= 1 << j ;
2178- }
2179-
2180- int iObjectRenderingFlags = iSceneWideRenderingFlags ;
2181-
2182- if (ptMaterial -> tFlags & PL_MATERIAL_FLAG_CAST_RECEIVE_SHADOW )
2183- {
2184- iObjectRenderingFlags |= PL_RENDERING_FLAG_SHADOWS ;
2185- }
2186-
2187- // choose shader variant
2188- int aiConstantData0 [5 ] = {
2189- (int )ptMesh -> ulVertexStreamMask ,
2190- iDataStride ,
2191- iTextureMappingFlags ,
2192- PL_INFO_MATERIAL_METALLICROUGHNESS ,
2193- iObjectRenderingFlags
2194- };
2195-
2196- // use stencil buffer
2197- const plGraphicsState tOutlineVariantTemp = {
2198- .ulDepthWriteEnabled = 0 ,
2199- .ulDepthMode = PL_COMPARE_MODE_ALWAYS ,
2200- .ulCullMode = PL_CULL_MODE_CULL_FRONT ,
2201- .ulWireframe = 0 ,
2202- .ulStencilTestEnabled = 1 ,
2203- .ulStencilMode = PL_COMPARE_MODE_LESS ,
2204- .ulStencilRef = 128 ,
2205- .ulStencilMask = 0xff ,
2206- .ulStencilOpFail = PL_STENCIL_OP_KEEP ,
2207- .ulStencilOpDepthFail = PL_STENCIL_OP_KEEP ,
2208- .ulStencilOpPass = PL_STENCIL_OP_KEEP
2209- };
2210-
22112148 uint64_t ulIndex = 0 ;
22122149 if (pl_hm_has_key_ex (& ptScene -> tDrawableHashmap , tEntity .uData , & ulIndex ))
22132150 {
@@ -2232,8 +2169,6 @@ pl_renderer_outline_entities(plScene* ptScene, uint32_t uCount, plEntity* atEnti
22322169 }
22332170 }
22342171 }
2235-
2236- // gptGfx->queue_shader_for_deletion(ptDevice, ptScene->sbtOutlinedEntities[i].tShader);
22372172 }
22382173 pl_sb_reset (ptScene -> sbtOutlinedEntities );
22392174 pl_sb_reset (ptScene -> sbtOutlineDrawablesOldShaders );
@@ -2300,21 +2235,6 @@ pl_renderer_outline_entities(plScene* ptScene, uint32_t uCount, plEntity* atEnti
23002235 tVariantTemp .ulStencilOpDepthFail = PL_STENCIL_OP_REPLACE ;
23012236 tVariantTemp .ulStencilOpPass = PL_STENCIL_OP_REPLACE ;
23022237
2303- // use stencil buffer
2304- const plGraphicsState tOutlineVariantTemp = {
2305- .ulDepthWriteEnabled = 0 ,
2306- .ulDepthMode = PL_COMPARE_MODE_ALWAYS ,
2307- .ulCullMode = PL_CULL_MODE_CULL_FRONT ,
2308- .ulWireframe = 0 ,
2309- .ulStencilTestEnabled = 1 ,
2310- .ulStencilMode = PL_COMPARE_MODE_LESS ,
2311- .ulStencilRef = 128 ,
2312- .ulStencilMask = 0xff ,
2313- .ulStencilOpFail = PL_STENCIL_OP_KEEP ,
2314- .ulStencilOpDepthFail = PL_STENCIL_OP_KEEP ,
2315- .ulStencilOpPass = PL_STENCIL_OP_KEEP
2316- };
2317-
23182238 pl_sb_push (ptScene -> sbtOutlinedEntities , ptDrawable -> tEntity );
23192239 pl_sb_push (ptScene -> sbtOutlineDrawablesOldShaders , ptDrawable -> tShader );
23202240 pl_sb_push (ptScene -> sbtOutlineDrawablesOldEnvShaders , ptDrawable -> tEnvShader );
@@ -2956,7 +2876,6 @@ pl_renderer_prepare_scene(plScene* ptScene)
29562876 plBuffer * ptShadowDataBuffer = gptGfx -> get_buffer (ptDevice , ptScene -> atLightShadowDataBuffer [uFrameIdx ]);
29572877 memcpy (ptShadowDataBuffer -> tMemoryAllocation .pHostMapped , ptScene -> sbtLightShadowData , sizeof (plGPULightShadowData ) * pl_sb_size (ptScene -> sbtLightShadowData ));
29582878
2959-
29602879 const uint32_t uProbeCount = pl_sb_size (ptScene -> sbtProbeData );
29612880 for (uint32_t uProbeIndex = 0 ; uProbeIndex < uProbeCount ; uProbeIndex ++ )
29622881 {
@@ -3672,26 +3591,6 @@ pl_renderer_render_view(plView* ptView, plCamera* ptCamera, plCamera* ptCullCame
36723591 gptGfx -> submit_command_buffer (ptSceneCmdBuffer , & tSceneSubmitInfo );
36733592 gptGfx -> return_command_buffer (ptSceneCmdBuffer );
36743593
3675-
3676- plCommandBuffer * ptPickingDecodeCmdBuffer = gptGfx -> request_command_buffer (ptCmdPool );
3677-
3678- const plBeginCommandInfo tPickingDecodeBeginInfo = {
3679- .uWaitSemaphoreCount = 1 ,
3680- .atWaitSempahores = {gptData -> aptSemaphores [uFrameIdx ]},
3681- .auWaitSemaphoreValues = {gptData -> aulNextTimelineValue [uFrameIdx ]},
3682- };
3683- gptGfx -> begin_command_recording (ptPickingDecodeCmdBuffer , & tPickingDecodeBeginInfo );
3684-
3685- gptGfx -> end_command_recording (ptPickingDecodeCmdBuffer );
3686-
3687- const plSubmitInfo tPickingDecodeSubmitInfo = {
3688- .uSignalSemaphoreCount = 1 ,
3689- .atSignalSempahores = {gptData -> aptSemaphores [uFrameIdx ]},
3690- .auSignalSemaphoreValues = {++ gptData -> aulNextTimelineValue [uFrameIdx ]}
3691- };
3692- gptGfx -> submit_command_buffer (ptPickingDecodeCmdBuffer , & tPickingDecodeSubmitInfo );
3693- gptGfx -> return_command_buffer (ptPickingDecodeCmdBuffer );
3694-
36953594 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~uv map pass for JFA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36963595
36973596 const plBeginCommandInfo tUVBeginInfo = {
0 commit comments