@@ -185,8 +185,8 @@ static void ComputeDynamics( shaderStage_t* pStage ) {
185185 pStage->dynamic = pStage->dynamic || pStage->rgbExp .numOps || pStage->redExp .numOps || pStage->greenExp .numOps || pStage->blueExp .numOps ;
186186 pStage->dynamic = pStage->dynamic || pStage->deformMagnitudeExp .numOps ;
187187 pStage->dynamic = pStage->dynamic || pStage->depthScaleExp .numOps || pStage->etaExp .numOps || pStage->etaDeltaExp .numOps
188- || pStage->fogDensityExp .numOps || pStage->fresnelBiasExp .numOps || pStage->fresnelPowerExp .numOps
189- || pStage->fresnelScaleExp .numOps || pStage->normalIntensityExp .numOps || pStage->refractionIndexExp .numOps ;
188+ || pStage->fogDensityExp .numOps || pStage->fresnelBiasExp .numOps || pStage->fresnelPowerExp .numOps
189+ || pStage->fresnelScaleExp .numOps || pStage->normalIntensityExp .numOps || pStage->refractionIndexExp .numOps ;
190190
191191 pStage->dynamic = pStage->dynamic || pStage->colorDynamic || pStage->texMatricesDynamic || pStage->texturesDynamic ;
192192}
@@ -818,7 +818,7 @@ void MaterialSystem::GenerateWorldCommandBuffer() {
818818 surfaceDescriptorsCount = totalDrawSurfs;
819819 descriptorSize = BOUNDING_SPHERE_SIZE + maxStages;
820820 glBufferData ( GL_SHADER_STORAGE_BUFFER, surfaceDescriptorsCount * descriptorSize * sizeof ( uint32_t ),
821- nullptr , GL_STATIC_DRAW );
821+ nullptr , GL_STATIC_DRAW );
822822 uint32_t * surfaceDescriptors = surfaceDescriptorsSSBO.MapBufferRange ( surfaceDescriptorsCount * descriptorSize );
823823
824824 surfaceCommandsCount = totalBatchCount * SURFACE_COMMANDS_PER_BATCH;
@@ -865,8 +865,8 @@ void MaterialSystem::GenerateWorldCommandBuffer() {
865865 atomicCommandCountersBuffer.BufferStorage ( GL_ATOMIC_COUNTER_BUFFER,
866866 MAX_COMMAND_COUNTERS * MAX_VIEWS, MAX_FRAMES, nullptr );
867867 atomicCommandCountersBuffer.MapAll ( GL_ATOMIC_COUNTER_BUFFER );
868- uint32_t * atomicCommandCounters = (uint32_t *) atomicCommandCountersBuffer.GetData ();
869- memset ( atomicCommandCounters, 0 , MAX_COMMAND_COUNTERS * MAX_VIEWFRAMES * sizeof (uint32_t ) );
868+ uint32_t * atomicCommandCounters = ( uint32_t * ) atomicCommandCountersBuffer.GetData ();
869+ memset ( atomicCommandCounters, 0 , MAX_COMMAND_COUNTERS * MAX_VIEWFRAMES * sizeof ( uint32_t ) );
870870
871871 /* For use in debugging compute shaders
872872 Intended for use with Nsight Graphics to format the output */
@@ -980,22 +980,18 @@ void MaterialSystem::GenerateWorldCommandBuffer() {
980980}
981981
982982void MaterialSystem::GenerateDepthImages ( const int width, const int height, imageParams_t imageParms ) {
983- int size = std::max ( width, height );
984983 imageParms.bits ^= ( IF_NOPICMIP | IF_PACKED_DEPTH24_STENCIL8 );
985984 imageParms.bits |= IF_ONECOMP32F;
986985
987- depthImageLevels = 0 ;
988- while ( size > 0 ) {
989- depthImageLevels++;
990- size >>= 1 ; // mipmaps round down
991- }
986+ depthImageLevels = log2f ( std::max ( width, height ) ) + 1 ;
992987
993988 depthImage = R_CreateImage ( " _depthImage" , nullptr , width, height, depthImageLevels, imageParms );
994989 GL_Bind ( depthImage );
990+
995991 int mipmapWidth = width;
996992 int mipmapHeight = height;
997- for ( int j = 0 ; j < depthImageLevels; j ++ ) {
998- glTexImage2D ( GL_TEXTURE_2D, j , GL_R32F, mipmapWidth, mipmapHeight, 0 , GL_RED, GL_FLOAT, nullptr );
993+ for ( int i = 0 ; i < depthImageLevels; i ++ ) {
994+ glTexImage2D ( GL_TEXTURE_2D, i , GL_R32F, mipmapWidth, mipmapHeight, 0 , GL_RED, GL_FLOAT, nullptr );
999995 mipmapWidth = mipmapWidth > 1 ? mipmapWidth >> 1 : 1 ;
1000996 mipmapHeight = mipmapHeight > 1 ? mipmapHeight >> 1 : 1 ;
1001997 }
0 commit comments