Skip to content

Commit e4c98e8

Browse files
committed
Remove final DirectX Shader Model concepts. OpenGL GLSL version supported by the driver can be directly queried, rather than a layer of abstraction through SM2, SM3 and SM4. Allows Use_GLSL to be removed following refactoring.
1 parent 5d593f0 commit e4c98e8

File tree

10 files changed

+23
-39
lines changed

10 files changed

+23
-39
lines changed

code/graphics/2d.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ void poly_list::allocate(int _verts)
17401740
tsb = (tsb_t*)vm_malloc(sizeof(tsb_t) * _verts);
17411741
}
17421742

1743-
if ( Use_GLSL >= 3 ) {
1743+
if ( GLSL_version >= 130 ) {
17441744
submodels = (int*)vm_malloc(sizeof(int) * _verts);
17451745
}
17461746

@@ -1922,7 +1922,7 @@ void poly_list::make_index_buffer(SCP_vector<int> &vertex_list)
19221922
buffer_list_internal.tsb[z] = tsb[j];
19231923
}
19241924

1925-
if ( Use_GLSL >= 3 ) {
1925+
if ( GLSL_version >= 130 ) {
19261926
buffer_list_internal.submodels[z] = submodels[j];
19271927
}
19281928

@@ -1952,7 +1952,7 @@ poly_list& poly_list::operator = (poly_list &other_list)
19521952
memcpy(tsb, other_list.tsb, sizeof(tsb_t) * other_list.n_verts);
19531953
}
19541954

1955-
if ( Use_GLSL >= 3 ) {
1955+
if ( GLSL_version >= 130 ) {
19561956
memcpy(submodels, other_list.submodels, sizeof(int) * other_list.n_verts);
19571957
}
19581958

@@ -2147,7 +2147,7 @@ uint gr_determine_model_shader_flags(
21472147
) {
21482148
uint shader_flags = 0;
21492149

2150-
if ( Use_GLSL >= 2 ) {
2150+
if ( GLSL_version >= 120 ) {
21512151
shader_flags |= SDR_FLAG_MODEL_CLIP;
21522152
}
21532153

code/graphics/grbatch.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,12 @@ int batch_add_bitmap(int texture, int tmap_flags, vertex *pnt, int orient, float
728728
return 1;
729729
}
730730

731-
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || Use_GLSL <= 2 ) ) {
731+
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || GLSL_version <= 120 ) ) {
732732
// don't render this as a soft particle if we don't support soft particles
733733
tmap_flags &= ~(TMAP_FLAG_SOFT_QUAD);
734734
}
735735

736-
if ( Use_GLSL > 2 && Cmdline_softparticles && !Cmdline_no_geo_sdr_effects && Is_Extension_Enabled(OGL_EXT_GEOMETRY_SHADER4) && (tmap_flags & TMAP_FLAG_VERTEX_GEN) ) {
736+
if ( GLSL_version > 120 && Cmdline_softparticles && !Cmdline_no_geo_sdr_effects && Is_Extension_Enabled(OGL_EXT_GEOMETRY_SHADER4) && (tmap_flags & TMAP_FLAG_VERTEX_GEN) ) {
737737
geometry_batch_add_bitmap(texture, tmap_flags, pnt, orient, rad, alpha, depth);
738738
return 0;
739739
} else if ( tmap_flags & TMAP_FLAG_VERTEX_GEN ) {
@@ -797,7 +797,7 @@ int batch_add_bitmap_rotated(int texture, int tmap_flags, vertex *pnt, float ang
797797
return 1;
798798
}
799799

800-
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || Use_GLSL <= 2 ) ) {
800+
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || GLSL_version <= 120 ) ) {
801801
// don't render this as a soft particle if we don't support soft particles
802802
tmap_flags &= ~(TMAP_FLAG_SOFT_QUAD);
803803
}
@@ -1179,7 +1179,7 @@ int distortion_add_bitmap_rotated(int texture, int tmap_flags, vertex *pnt, floa
11791179
return 1;
11801180
}
11811181

1182-
if ( Use_GLSL < 2 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
1182+
if ( GLSL_version < 120 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
11831183
// don't render distortions if we can't support them.
11841184
return 0;
11851185
}
@@ -1214,7 +1214,7 @@ int distortion_add_beam(int texture, int tmap_flags, vec3d *start, vec3d *end, f
12141214
return 1;
12151215
}
12161216

1217-
if ( Use_GLSL < 2 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
1217+
if ( GLSL_version < 120 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) {
12181218
// don't render distortions if we can't support them.
12191219
return 0;
12201220
}

code/graphics/gropengl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ static ushort *GL_original_gamma_ramp = NULL;
7575

7676
int Use_VBOs = 0;
7777
int Use_PBOs = 0;
78-
int Use_GLSL = 0;
7978

8079
static int GL_dump_frames = 0;
8180
static ubyte *GL_dump_buffer = NULL;

code/graphics/gropengl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,5 @@ extern int GLSL_version;
668668

669669
extern int Use_VBOs;
670670
extern int Use_PBOs;
671-
extern int Use_GLSL;
672671

673672
#endif

code/graphics/gropengldraw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,7 +3067,7 @@ void opengl_clear_deferred_buffers()
30673067

30683068
void gr_opengl_deferred_lighting_begin()
30693069
{
3070-
if (Use_GLSL < 2 || Cmdline_no_deferred_lighting)
3070+
if (GLSL_version < 120 || Cmdline_no_deferred_lighting)
30713071
return;
30723072

30733073
Deferred_lighting = true;
@@ -3093,7 +3093,7 @@ extern float static_tube_factor;
30933093

30943094
void gr_opengl_deferred_lighting_finish()
30953095
{
3096-
if ( Use_GLSL < 2 || Cmdline_no_deferred_lighting ) {
3096+
if ( GLSL_version < 120 || Cmdline_no_deferred_lighting ) {
30973097
return;
30983098
}
30993099

code/graphics/gropenglextension.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -446,21 +446,8 @@ void opengl_extensions_init()
446446

447447
GLSL_version = ver;
448448

449-
// SM 4.0 compatible or better
450-
if (ver >= 330) {
451-
Use_GLSL = 4;
452-
}
453-
// SM 3.0 compatible
454-
else if ( ver >= 130 ) {
455-
Use_GLSL = 3;
456-
}
457-
// SM 2.0 compatible
458-
else if (ver >= 120) {
459-
Use_GLSL = 2;
460-
}
461-
// we require GLSL 1.20 or higher
462-
else if (ver < 110) {
463-
Use_GLSL = 0;
449+
// we require a minimum GLSL version
450+
if (!is_minimum_GLSL_version()) {
464451
mprintf((" OpenGL Shading Language version %s is not sufficient to use GLSL mode in FSO. Defaulting to fixed-function renderer.\n", glGetString(GL_SHADING_LANGUAGE_VERSION) ));
465452
}
466453
}
@@ -474,7 +461,7 @@ void opengl_extensions_init()
474461
Cmdline_no_deferred_lighting = 1;
475462
}
476463

477-
if ( Use_GLSL < 2 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) || !Is_Extension_Enabled(OGL_ARB_FLOATING_POINT_TEXTURES) ) {
464+
if ( GLSL_version < 120 || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) || !Is_Extension_Enabled(OGL_ARB_FLOATING_POINT_TEXTURES) ) {
478465
mprintf((" No hardware support for deferred lighting. Deferred lighting will be disabled. \n"));
479466
Cmdline_no_deferred_lighting = 1;
480467
Cmdline_no_batching = true;

code/graphics/gropenglshader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,10 @@ static char *opengl_load_shader(shader_type type_id, char *filename, int flags)
309309
sflags += "#version 120\n";
310310
#endif
311311

312-
if (Use_GLSL >= 4) {
312+
if (GLSL_version >= 330) {
313313
sflags += "#define GLSL_VERSION 330\n";
314314
}
315-
else if (Use_GLSL == 3) {
315+
else if (GLSL_version == 130) {
316316
sflags += "#define GLSL_VERSION 130\n";
317317
}
318318
else {

code/graphics/gropengltnl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ int gr_opengl_create_stream_buffer_object()
226226

227227
int opengl_create_texture_buffer_object()
228228
{
229-
if ( Use_GLSL < 3 || !Is_Extension_Enabled(OGL_ARB_TEXTURE_BUFFER) || !Is_Extension_Enabled(OGL_ARB_FLOATING_POINT_TEXTURES) ) {
229+
if ( GLSL_version < 130 || !Is_Extension_Enabled(OGL_ARB_TEXTURE_BUFFER) || !Is_Extension_Enabled(OGL_ARB_FLOATING_POINT_TEXTURES) ) {
230230
return -1;
231231
}
232232

@@ -406,7 +406,7 @@ bool gr_opengl_config_buffer(const int buffer_id, vertex_buffer *vb, bool update
406406
}
407407

408408
if (vb->flags & VB_FLAG_MODEL_ID) {
409-
Assert( Use_GLSL >= 3 );
409+
Assert( GLSL_version >= 130 );
410410

411411
Verify( update_ibuffer_only || vb->model_list->submodels != NULL );
412412
vb->stride += (1 * sizeof(GLfloat));

code/model/modelinterp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4360,7 +4360,7 @@ void interp_configure_vertex_buffers(polymodel *pm, int mn)
43604360
polygon_list[i].n_verts = vert_count;
43614361

43624362
// set submodel ID
4363-
if ( Use_GLSL >= 3 ) {
4363+
if ( GLSL_version >= 130 ) {
43644364
for ( j = 0; j < polygon_list[i].n_verts; ++j ) {
43654365
polygon_list[i].submodels[j] = mn;
43664366
}
@@ -4416,7 +4416,7 @@ void interp_configure_vertex_buffers(polymodel *pm, int mn)
44164416
memcpy( (model_list->tsb) + model_list->n_verts, polygon_list[i].tsb, sizeof(tsb_t) * polygon_list[i].n_verts );
44174417
}
44184418

4419-
if ( Use_GLSL >= 3 ) {
4419+
if ( GLSL_version >= 130 ) {
44204420
memcpy( (model_list->submodels) + model_list->n_verts, polygon_list[i].submodels, sizeof(int) * polygon_list[i].n_verts );
44214421
}
44224422

@@ -4436,7 +4436,7 @@ void interp_configure_vertex_buffers(polymodel *pm, int mn)
44364436
}
44374437

44384438
if ( model_list->submodels != NULL ) {
4439-
Assert( Use_GLSL >= 3 );
4439+
Assert( GLSL_version >= 130 );
44404440
vertex_flags |= VB_FLAG_MODEL_ID;
44414441
}
44424442

code/model/modelread.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ SCP_vector<bsp_collision_tree> Bsp_collision_tree_list;
5858

5959
static int model_initted = 0;
6060
extern int Cmdline_nohtl;
61-
extern int Use_GLSL;
6261

6362
#ifndef NDEBUG
6463
CFILE *ss_fp = NULL; // file pointer used to dump subsystem information
@@ -754,7 +753,7 @@ void create_vertex_buffer(polymodel *pm)
754753

755754
bool use_batched_rendering = true;
756755

757-
if ( Use_GLSL >= 3 && !Cmdline_no_batching ) {
756+
if ( GLSL_version >= 130 && !Cmdline_no_batching ) {
758757
uint stride = 0;
759758

760759
// figure out if the vertex stride of this entire model matches. if not, turn off batched rendering for this model
@@ -2407,7 +2406,7 @@ void model_load_texture(polymodel *pm, int i, char *file)
24072406
gr_maybe_create_shader(SDR_TYPE_MODEL, shader_flags | SDR_FLAG_MODEL_LIGHT);
24082407
gr_maybe_create_shader(SDR_TYPE_MODEL, shader_flags | SDR_FLAG_MODEL_LIGHT | SDR_FLAG_MODEL_FOG);
24092408

2410-
if( !Cmdline_no_batching && Use_GLSL >= 3 ) {
2409+
if( !Cmdline_no_batching && GLSL_version >= 130 ) {
24112410
shader_flags &= ~SDR_FLAG_MODEL_DEFERRED;
24122411
shader_flags |= SDR_FLAG_MODEL_TRANSFORM;
24132412

0 commit comments

Comments
 (0)