Skip to content

Commit e8c4c1a

Browse files
committed
Cleanup some material system code
1 parent 6497f33 commit e8c4c1a

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

src/engine/renderer/Material.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

982982
void 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
}

src/engine/renderer/Material.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ struct Material {
9797
bool tcGenEnvironment;
9898
bool tcGen_Lightmap;
9999
bool hasDepthFade;
100-
bool alphaTest;
101100

102101
bool bspSurface;
103102
bool enableDeluxeMapping;

src/engine/renderer/tr_shader.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6019,10 +6019,7 @@ static shader_t *FinishShader()
60196019
ret->depthShader = nullptr;
60206020

60216021
if ( glConfig2.usingMaterialSystem && !tr.worldLoaded ) {
6022-
uint8_t maxStages = 0;
6023-
for ( shaderStage_t* pStage = ret->stages; pStage < ret->lastStage; pStage++ ) {
6024-
maxStages++;
6025-
}
6022+
uint8_t maxStages = ret->lastStage - ret->stages;
60266023

60276024
// Add 1 for potential fog stages
60286025
maxStages = PAD( maxStages + 1, 4 ); // Aligned to 4 components
@@ -6080,10 +6077,7 @@ static shader_t *FinishShader()
60806077
}
60816078

60826079
if ( glConfig2.usingMaterialSystem && !tr.worldLoaded ) {
6083-
uint8_t maxStages = 0;
6084-
for ( shaderStage_t* pStage = ret->stages; pStage < ret->lastStage; pStage++ ) {
6085-
maxStages++;
6086-
}
6080+
uint8_t maxStages = ret->lastStage - ret->stages;
60876081

60886082
// Add 1 for potential depth stages
60896083
// Add 1 for potential fog stages

0 commit comments

Comments
 (0)