Skip to content

Commit

Permalink
Cleanup nuke non-UBO and non-integer texture paths
Browse files Browse the repository at this point in the history
  • Loading branch information
VReaperV committed Oct 11, 2024
1 parent 7d793e9 commit f7e67a1
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 111 deletions.
2 changes: 1 addition & 1 deletion src/engine/renderer/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void UpdateSurfaceDataLightMapping( uint32_t* materials, Material& material, dra

// bind u_LightTiles
if ( r_realtimeLightingRenderer.Get() == Util::ordinal( realtimeLightingRenderer_t::TILED ) ) {
gl_lightMappingShaderMaterial->SetUniform_LightTilesIntBindless(
gl_lightMappingShaderMaterial->SetUniform_LightTilesBindless(
GL_BindToTMU( BIND_LIGHTTILES, tr.lighttileRenderImage )
);
}
Expand Down
8 changes: 2 additions & 6 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2289,8 +2289,6 @@ GLShader_lightMapping::GLShader_lightMapping( GLShaderManager *manager ) :
u_LightGrid1( this ),
u_LightGrid2( this ),
u_LightTiles( this ),
u_LightTilesInt( this ),
u_LightsTexture( this ),
u_TextureMatrix( this ),
u_SpecularExponent( this ),
u_ColorModulate( this ),
Expand Down Expand Up @@ -2338,7 +2336,6 @@ void GLShader_lightMapping::SetShaderProgramUniforms( shaderProgram_t *shaderPro
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_EnvironmentMap0" ), BIND_ENVIRONMENTMAP0 );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_EnvironmentMap1" ), BIND_ENVIRONMENTMAP1 );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightTiles" ), BIND_LIGHTTILES );
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightTilesInt" ), BIND_LIGHTTILES );
if( !glConfig2.uniformBufferObjectAvailable ) {
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), BIND_LIGHTS );
}
Expand All @@ -2358,7 +2355,7 @@ GLShader_lightMappingMaterial::GLShader_lightMappingMaterial( GLShaderManager* m
u_EnvironmentMap1( this ),
u_LightGrid1( this ),
u_LightGrid2( this ),
u_LightTilesInt( this ),
u_LightTiles( this ),
u_TextureMatrix( this ),
u_SpecularExponent( this ),
u_ColorModulate( this ),
Expand Down Expand Up @@ -3021,7 +3018,7 @@ GLShader_liquidMaterial::GLShader_liquidMaterial( GLShaderManager* manager ) :
u_NormalScale( this ),
u_FogDensity( this ),
u_FogColor( this ),
u_LightTilesInt( this ),
u_LightTiles( this ),
u_SpecularExponent( this ),
u_LightGridOrigin( this ),
u_LightGridScale( this ),
Expand Down Expand Up @@ -3098,7 +3095,6 @@ GLShader_lighttile::GLShader_lighttile( GLShaderManager *manager ) :
GLShader( "lighttile", ATTR_POSITION | ATTR_TEXCOORD, manager ),
u_DepthMap( this ),
u_Lights( this ),
u_LightsTexture( this ),
u_numLights( this ),
u_lightLayer( this ),
u_ModelMatrix( this ),
Expand Down
39 changes: 2 additions & 37 deletions src/engine/renderer/gl_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2425,22 +2425,6 @@ class u_CloudMap :
}
};

class u_LightsTexture :
GLUniformSampler2D {
public:
u_LightsTexture( GLShader* shader ) :
GLUniformSampler2D( shader, "u_LightsTexture" ) {
}

void SetUniform_LightsTextureBindless( GLuint64 bindlessHandle ) {
this->SetValueBindless( bindlessHandle );
}

GLint GetUniformLocation_LightsTexture() {
return this->GetLocation();
}
};

class u_LightTiles :
GLUniformSampler3D {
public:
Expand All @@ -2457,22 +2441,6 @@ class u_LightTiles :
}
};

class u_LightTilesInt :
GLUniformUSampler3D {
public:
u_LightTilesInt( GLShader* shader ) :
GLUniformUSampler3D( shader, "u_LightTilesInt" ) {
}

void SetUniform_LightTilesIntBindless( GLuint64 bindlessHandle ) {
this->SetValueBindless( bindlessHandle );
}

GLint GetUniformLocation_LightTilesInt() {
return this->GetLocation();
}
};

class u_LightGrid1 :
GLUniformSampler3D {
public:
Expand Down Expand Up @@ -4023,8 +3991,6 @@ class GLShader_lightMapping :
public u_LightGrid1,
public u_LightGrid2,
public u_LightTiles,
public u_LightTilesInt,
public u_LightsTexture,
public u_TextureMatrix,
public u_SpecularExponent,
public u_ColorModulate,
Expand Down Expand Up @@ -4074,7 +4040,7 @@ class GLShader_lightMappingMaterial :
public u_EnvironmentMap1,
public u_LightGrid1,
public u_LightGrid2,
public u_LightTilesInt,
public u_LightTiles,
public u_TextureMatrix,
public u_SpecularExponent,
public u_ColorModulate,
Expand Down Expand Up @@ -4629,7 +4595,7 @@ class GLShader_liquidMaterial :
public u_NormalScale,
public u_FogDensity,
public u_FogColor,
public u_LightTilesInt,
public u_LightTiles,
public u_SpecularExponent,
public u_LightGridOrigin,
public u_LightGridScale,
Expand Down Expand Up @@ -4689,7 +4655,6 @@ class GLShader_lighttile :
public GLShader,
public u_DepthMap,
public u_Lights,
public u_LightsTexture,
public u_numLights,
public u_lightLayer,
public u_ModelMatrix,
Expand Down
12 changes: 6 additions & 6 deletions src/engine/renderer/glsl_source/computeLight_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ const int lightsPerLayer = 16;

#define idxs_t uvec4

uniform usampler3D u_LightTilesInt;
uniform usampler3D u_LightTiles;

const uint numLayers = MAX_REF_LIGHTS / 256;
const vec3 tileScale = vec3( r_tileStep, 1.0 / numLayers );

idxs_t fetchIdxs( in vec3 coords, in usampler3D u_LightTilesInt ) {
return texture3D( u_LightTilesInt, coords );
idxs_t fetchIdxs( in vec3 coords, in usampler3D u_LightTiles ) {
return texture3D( u_LightTiles, coords );
}

// 8 bits per light ID
Expand All @@ -227,11 +227,11 @@ uint nextIdx( in uint count, in idxs_t idxs ) {

#if defined(USE_REFLECTIVE_SPECULAR)
void computeDynamicLights( vec3 P, vec3 normal, vec3 viewDir, vec4 diffuse, vec4 material,
inout vec4 color, in usampler3D u_LightTilesInt,
inout vec4 color, in usampler3D u_LightTiles,
in samplerCube u_EnvironmentMap0, in samplerCube u_EnvironmentMap1 )
#else // !USE_REFLECTIVE_SPECULAR
void computeDynamicLights( vec3 P, vec3 normal, vec3 viewDir, vec4 diffuse, vec4 material,
inout vec4 color, in usampler3D u_LightTilesInt )
inout vec4 color, in usampler3D u_LightTiles )
#endif // !USE_REFLECTIVE_SPECULAR
{
vec2 tile = floor( gl_FragCoord.xy * ( 1.0 / float( TILE_SIZE ) ) ) + 0.5;
Expand All @@ -241,7 +241,7 @@ void computeDynamicLights( vec3 P, vec3 normal, vec3 viewDir, vec4 diffuse, vec4

uint lightCount = 0;
for( uint layer = 0; layer < numLayers; layer++ ) {
idxs_t idxs = fetchIdxs( tileScale * vec3( tile, float( layer ) + 0.5 ), u_LightTilesInt );
idxs_t idxs = fetchIdxs( tileScale * vec3( tile, float( layer ) + 0.5 ), u_LightTiles );

uint lightOffset = layer * globalLightsPerLayer;
uint layerLightCount = lightOffset < u_numLights ? min( min( u_numLights - lightOffset, globalLightsPerLayer ), lightsPerLayer ) : 0;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/renderer/glsl_source/lightMapping_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ void main()
// Blend dynamic lights.
#if defined(r_realtimeLighting) && r_realtimeLightingRenderer == 1
#if defined(USE_REFLECTIVE_SPECULAR)
computeDynamicLights(var_Position, normal, viewDir, diffuse, material, color, u_LightTilesInt,
computeDynamicLights(var_Position, normal, viewDir, diffuse, material, color, u_LightTiles,
u_EnvironmentMap0, u_EnvironmentMap1);
#else // !USE_REFLECTIVE_SPECULAR
computeDynamicLights(var_Position, normal, viewDir, diffuse, material, color, u_LightTilesInt);
computeDynamicLights(var_Position, normal, viewDir, diffuse, material, color, u_LightTiles);
#endif // !USE_REFLECTIVE_SPECULAR
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/glsl_source/material_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
samplerCube u_EnvironmentMap0 = samplerCube( u_EnvironmentMap0_initial );
samplerCube u_EnvironmentMap1 = samplerCube( u_EnvironmentMap1_initial );
#endif // !USE_REFLECTIVE_SPECULAR
usampler3D u_LightTilesInt = usampler3D( u_LightTilesInt_initial );
usampler3D u_LightTiles = usampler3D( u_LightTiles_initial );
#endif // !COMPUTELIGHT_GLSL

#if defined(FOGQUAKE3_GLSL)
Expand Down
14 changes: 1 addition & 13 deletions src/engine/renderer/tr_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2905,13 +2905,7 @@ void RB_RenderPostDepthLightTile()
gl_lighttileShader->SetUniform_numLights( backEnd.refdef.numLights );
gl_lighttileShader->SetUniform_zFar( projToViewParams );

if( glConfig2.uniformBufferObjectAvailable ) {
gl_lighttileShader->SetUniformBlock_Lights( tr.dlightUBO );
} else {
gl_lighttileShader->SetUniform_LightsTextureBindless(
GL_BindToTMU( 1, tr.dlightImage )
);
}
gl_lighttileShader->SetUniformBlock_Lights( tr.dlightUBO );

gl_lighttileShader->SetUniform_DepthMapBindless(
GL_BindToTMU( 1, tr.depthtile2RenderImage )
Expand Down Expand Up @@ -5370,12 +5364,6 @@ const RenderCommand *SetupLightsCommand::ExecuteSelf( ) const
}

glUnmapBuffer( bufferTarget );
if( !glConfig2.uniformBufferObjectAvailable ) {
gl_lighttileShader->SetUniform_LightsTextureBindless(
GL_BindToTMU( 1, tr.dlightImage )
);
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, tr.dlightImage->width, tr.dlightImage->height, GL_RGBA, GL_FLOAT, nullptr );
}
glBindBuffer( bufferTarget, 0 );
}

Expand Down
22 changes: 1 addition & 21 deletions src/engine/renderer/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2482,21 +2482,6 @@ static void R_CreateDepthRenderImage()
return;
}

if( !glConfig2.uniformBufferObjectAvailable )
{
int w = 64;
int h = 3 * MAX_REF_LIGHTS / w;

imageParams_t imageParams = {};
imageParams.filterType = filterType_t::FT_NEAREST;
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;

imageParams.bits = IF_NOPICMIP;
imageParams.bits |= r_highPrecisionRendering.Get() ? IF_RGBA32F : IF_RGBA16F;

tr.dlightImage = R_CreateImage("_dlightImage", nullptr, w, h, 4, imageParams );
}

if ( r_realtimeLightingRenderer.Get() != Util::ordinal( realtimeLightingRenderer_t::TILED ) )
{
/* Do not create lightTile images when the tiled renderer is not used.
Expand Down Expand Up @@ -2536,12 +2521,7 @@ static void R_CreateDepthRenderImage()

tr.depthtile2RenderImage = R_CreateImage( "_depthtile2Render", nullptr, w, h, 1, imageParams );

imageParams.bits = IF_NOPICMIP;

if ( glConfig2.textureIntegerAvailable && r_highPrecisionRendering.Get() )
{
imageParams.bits |= IF_RGBA32UI;
}
imageParams.bits = IF_NOPICMIP | IF_RGBA32UI;

tr.lighttileRenderImage = R_Create3DImage( "_lighttileRender", nullptr, w, h, 4, imageParams );
}
Expand Down
1 change: 0 additions & 1 deletion src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2650,7 +2650,6 @@ enum class realtimeLightingRenderer_t { LEGACY, TILED };
FBO_t *fbos[ MAX_FBOS ];

GLuint dlightUBO;
image_t *dlightImage; // if the UBO is not available

std::vector<VBO_t *> vbos;
std::vector<IBO_t *> ibos;
Expand Down
19 changes: 2 additions & 17 deletions src/engine/renderer/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ static void EnableAvailableFeatures()
{
if ( r_realtimeLightingRenderer.Get() == Util::ordinal( realtimeLightingRenderer_t::TILED ) )
{
if ( !glConfig2.textureFloatAvailable )
{
Log::Warn( "Tiled dynamic light renderer disabled because GL_ARB_texture_float is not available.");
glConfig2.realtimeLighting = false;
}

if ( !glConfig2.uniformBufferObjectAvailable ) {
Log::Warn( "Tiled dynamic light renderer disabled because GL_ARB_uniform_buffer_object is not available." );
glConfig2.realtimeLighting = false;
Expand Down Expand Up @@ -1075,19 +1069,10 @@ void Render_lightMapping( shaderStage_t *pStage )
if ( backEnd.refdef.numShaderLights > 0 )
{
gl_lightMappingShader->SetUniform_numLights( backEnd.refdef.numLights );

if( glConfig2.uniformBufferObjectAvailable )
{
gl_lightMappingShader->SetUniformBlock_Lights( tr.dlightUBO );
} else
{
gl_lightMappingShader->SetUniform_LightsTextureBindless(
GL_BindToTMU( BIND_LIGHTS, tr.dlightImage )
);
}
gl_lightMappingShader->SetUniformBlock_Lights( tr.dlightUBO );

// bind u_LightTiles
gl_lightMappingShader->SetUniform_LightTilesIntBindless(
gl_lightMappingShader->SetUniform_LightTilesBindless(
GL_BindToTMU( BIND_LIGHTTILES, tr.lighttileRenderImage )
);
}
Expand Down
7 changes: 1 addition & 6 deletions src/engine/renderer/tr_vbo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,11 +980,6 @@ static void R_InitLightUBO()
glBindBuffer( GL_UNIFORM_BUFFER, tr.dlightUBO );
glBufferData( GL_UNIFORM_BUFFER, MAX_REF_LIGHTS * sizeof( shaderLight_t ), nullptr, GL_DYNAMIC_DRAW );
glBindBuffer( GL_UNIFORM_BUFFER, 0 );
} else {
glGenBuffers( 1, &tr.dlightUBO );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, tr.dlightUBO );
glBufferData( GL_PIXEL_UNPACK_BUFFER, MAX_REF_LIGHTS * sizeof( shaderLight_t ), nullptr, GL_DYNAMIC_DRAW );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 );
}
}

Expand Down Expand Up @@ -1118,7 +1113,7 @@ void R_ShutdownVBOs()
Com_Free_Aligned( tess.vertsBuffer );
Com_Free_Aligned( tess.indexesBuffer );

if( glConfig2.uniformBufferObjectAvailable ) {
if( glConfig2.realtimeLighting ) {
glDeleteBuffers( 1, &tr.dlightUBO );
tr.dlightUBO = 0;
}
Expand Down

0 comments on commit f7e67a1

Please sign in to comment.