@@ -574,9 +574,8 @@ void MaterialSystem::GenerateWorldCommandBuffer() {
574574
575575 texDataBufferType = glConfig2.maxUniformBlockSize >= MIN_MATERIAL_UBO_SIZE ? GL_UNIFORM_BUFFER : GL_SHADER_STORAGE_BUFFER;
576576
577- texDataBuffer.BindBuffer ( texDataBufferType );
578- texDataBuffer.BufferStorage ( texDataBufferType, ( texData.size () + dynamicTexData.size () ) * TEX_BUNDLE_SIZE, 1 , nullptr );
579- texDataBuffer.MapAll ( texDataBufferType );
577+ texDataBuffer.BufferStorage ( ( texData.size () + dynamicTexData.size () ) * TEX_BUNDLE_SIZE, 1 , nullptr );
578+ texDataBuffer.MapAll ();
580579 TexBundle* textureBundles = ( TexBundle* ) texDataBuffer.GetData ();
581580 memset ( textureBundles, 0 , ( texData.size () + dynamicTexData.size () ) * TEX_BUNDLE_SIZE * sizeof ( uint32_t ) );
582581
@@ -589,11 +588,9 @@ void MaterialSystem::GenerateWorldCommandBuffer() {
589588 dynamicTexDataOffset = texData.size () * TEX_BUNDLE_SIZE;
590589 dynamicTexDataSize = dynamicTexData.size () * TEX_BUNDLE_SIZE;
591590
592- texDataBuffer.FlushAll ( texDataBufferType );
591+ texDataBuffer.FlushAll ();
593592 texDataBuffer.UnmapBuffer ();
594- texDataBuffer.UnBindBuffer ( texDataBufferType );
595593
596- lightMapDataUBO.BindBuffer ();
597594 lightMapDataUBO.BufferStorage ( MAX_LIGHTMAPS * LIGHTMAP_SIZE, 1 , nullptr );
598595 lightMapDataUBO.MapAll ();
599596 uint64_t * lightmapData = ( uint64_t * ) lightMapDataUBO.GetData ();
@@ -633,7 +630,6 @@ void MaterialSystem::GenerateWorldCommandBuffer() {
633630
634631 lightMapDataUBO.FlushAll ();
635632 lightMapDataUBO.UnmapBuffer ();
636- lightMapDataUBO.UnBindBuffer ();
637633
638634 surfaceCommandsCount = totalBatchCount * SURFACE_COMMANDS_PER_BATCH;
639635
@@ -643,13 +639,11 @@ void MaterialSystem::GenerateWorldCommandBuffer() {
643639 SurfaceCommand* surfaceCommands = ( SurfaceCommand* ) surfaceCommandsSSBO.GetData ();
644640 memset ( surfaceCommands, 0 , surfaceCommandsCount * sizeof ( SurfaceCommand ) * MAX_VIEWFRAMES );
645641
646- culledCommandsBuffer.BindBuffer ( GL_SHADER_STORAGE_BUFFER );
647- culledCommandsBuffer.BufferStorage ( GL_SHADER_STORAGE_BUFFER,
648- surfaceCommandsCount * INDIRECT_COMMAND_SIZE * MAX_VIEWFRAMES, 1 , nullptr );
649- culledCommandsBuffer.MapAll ( GL_SHADER_STORAGE_BUFFER );
642+ culledCommandsBuffer.BufferStorage ( surfaceCommandsCount * INDIRECT_COMMAND_SIZE * MAX_VIEWFRAMES, 1 , nullptr );
643+ culledCommandsBuffer.MapAll ();
650644 GLIndirectBuffer::GLIndirectCommand* culledCommands = ( GLIndirectBuffer::GLIndirectCommand* ) culledCommandsBuffer.GetData ();
651645 memset ( culledCommands, 0 , surfaceCommandsCount * sizeof ( GLIndirectBuffer::GLIndirectCommand ) * MAX_VIEWFRAMES );
652- culledCommandsBuffer.FlushAll ( GL_SHADER_STORAGE_BUFFER );
646+ culledCommandsBuffer.FlushAll ();
653647
654648 surfaceBatchesUBO.BindBuffer ();
655649 glBufferData ( GL_UNIFORM_BUFFER, MAX_SURFACE_COMMAND_BATCHES * sizeof ( SurfaceCommandBatch ), nullptr , GL_STATIC_DRAW );
@@ -675,10 +669,8 @@ void MaterialSystem::GenerateWorldCommandBuffer() {
675669 }
676670 }
677671
678- atomicCommandCountersBuffer.BindBuffer ( GL_ATOMIC_COUNTER_BUFFER );
679- atomicCommandCountersBuffer.BufferStorage ( GL_ATOMIC_COUNTER_BUFFER,
680- MAX_COMMAND_COUNTERS * MAX_VIEWS, MAX_FRAMES, nullptr );
681- atomicCommandCountersBuffer.MapAll ( GL_ATOMIC_COUNTER_BUFFER );
672+ atomicCommandCountersBuffer.BufferStorage ( MAX_COMMAND_COUNTERS * MAX_VIEWS, MAX_FRAMES, nullptr );
673+ atomicCommandCountersBuffer.MapAll ();
682674 uint32_t * atomicCommandCounters = ( uint32_t * ) atomicCommandCountersBuffer.GetData ();
683675 memset ( atomicCommandCounters, 0 , MAX_COMMAND_COUNTERS * MAX_VIEWFRAMES * sizeof ( uint32_t ) );
684676
@@ -786,19 +778,14 @@ void MaterialSystem::GenerateWorldCommandBuffer() {
786778 memcpy ( surfaceCommands + surfaceCommandsCount * i, surfaceCommands, surfaceCommandsCount * sizeof ( SurfaceCommand ) );
787779 }
788780
789- surfaceDescriptorsSSBO.BindBuffer ();
790781 surfaceDescriptorsSSBO.UnmapBuffer ();
791782
792- surfaceCommandsSSBO.BindBuffer ();
793783 surfaceCommandsSSBO.UnmapBuffer ();
794784
795- culledCommandsBuffer.BindBuffer ( GL_SHADER_STORAGE_BUFFER );
796785 culledCommandsBuffer.UnmapBuffer ();
797786
798- atomicCommandCountersBuffer.BindBuffer ( GL_ATOMIC_COUNTER_BUFFER);
799787 atomicCommandCountersBuffer.UnmapBuffer ();
800788
801- surfaceBatchesUBO.BindBuffer ();
802789 surfaceBatchesUBO.UnmapBuffer ();
803790
804791 GL_CheckErrors ();
@@ -1619,7 +1606,7 @@ void MaterialSystem::UpdateDynamicSurfaces() {
16191606 texDataBuffer.BindBuffer ( texDataBufferType );
16201607 GL_CheckErrors ();
16211608 TexBundle* textureBundles =
1622- ( TexBundle* ) texDataBuffer.MapBufferRange ( texDataBufferType, dynamicTexDataOffset, dynamicTexDataSize );
1609+ ( TexBundle* ) texDataBuffer.MapBufferRange ( dynamicTexDataOffset, dynamicTexDataSize );
16231610 GL_CheckErrors ();
16241611
16251612 GenerateTexturesBuffer ( dynamicTexData, textureBundles );
0 commit comments