Skip to content

Commit 83374de

Browse files
committed
shader: don't use GENERIC profile to compile Cg shaders
Instead, make an educated guess of what the GSG we are going to be compiling this shader for wants to use as profile.
1 parent 9382e09 commit 83374de

File tree

7 files changed

+32
-13
lines changed

7 files changed

+32
-13
lines changed

panda/src/display/config_display.cxx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -478,15 +478,6 @@ ConfigVariableBool sync_video
478478
"cheesy estimate of scene complexity. Some drivers may ignore "
479479
"this request."));
480480

481-
ConfigVariableBool basic_shaders_only
482-
("basic-shaders-only", false,
483-
PRC_DESC("Set this to true if you aren't interested in shader model three "
484-
"and beyond. Setting this flag will cause panda to disable "
485-
"bleeding-edge shader functionality which tends to be unreliable "
486-
"or broken. At some point, when functionality that is currently "
487-
"flaky becomes reliable, we may expand the definition of what "
488-
"constitutes 'basic' shaders."));
489-
490481
/**
491482
* Initializes the library. This must be called at least once before any of
492483
* the functions or classes in this library can be used. Normally it will be

panda/src/display/config_display.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ extern EXPCL_PANDA_DISPLAY ConfigVariableDouble pixel_zoom;
108108

109109
extern EXPCL_PANDA_DISPLAY ConfigVariableColor background_color;
110110
extern EXPCL_PANDA_DISPLAY ConfigVariableBool sync_video;
111-
extern EXPCL_PANDA_DISPLAY ConfigVariableBool basic_shaders_only;
112111

113112
extern EXPCL_PANDA_DISPLAY void init_libdisplay();
114113

panda/src/glstuff/glGraphicsStateGuardian_src.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,8 @@ reset() {
16841684
}
16851685
}
16861686

1687+
Shader::set_default_caps(_shader_caps);
1688+
16871689
} else if (_supports_glsl) {
16881690
// No, but we do support GLSL...
16891691
_shader_caps._active_vprofile = (int)CG_PROFILE_GLSLV;

panda/src/gobj/config_gobj.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,15 @@ ConfigVariableBool stereo_lens_old_convergence
511511
"old, incorrect behavior, this may be set to 'true' to switch "
512512
"back to the old calculation."));
513513

514+
ConfigVariableBool basic_shaders_only
515+
("basic-shaders-only", false,
516+
PRC_DESC("Set this to true if you aren't interested in shader model three "
517+
"and beyond. Setting this flag will cause panda to disable "
518+
"bleeding-edge shader functionality which tends to be unreliable "
519+
"or broken. At some point, when functionality that is currently "
520+
"flaky becomes reliable, we may expand the definition of what "
521+
"constitutes 'basic' shaders."));
522+
514523
ConfigVariableString cg_glsl_version
515524
("cg-glsl-version", "",
516525
PRC_DESC("If this is set, it forces the Cg compiler to generate GLSL "

panda/src/gobj/config_gobj.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ extern EXPCL_PANDA_GOBJ ConfigVariableDouble async_load_delay;
8787
extern EXPCL_PANDA_GOBJ ConfigVariableInt lens_geom_segments;
8888
extern EXPCL_PANDA_GOBJ ConfigVariableBool stereo_lens_old_convergence;
8989

90+
extern EXPCL_PANDA_GOBJ ConfigVariableBool basic_shaders_only;
9091
extern EXPCL_PANDA_GOBJ ConfigVariableString cg_glsl_version;
9192
extern EXPCL_PANDA_GOBJ ConfigVariableBool glsl_preprocess;
9293
extern EXPCL_PANDA_GOBJ ConfigVariableInt glsl_include_recursion_limit;

panda/src/gobj/shader.cxx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,15 @@ get_compiled(unsigned int &format, string &binary) const {
15891589
return !binary.empty();
15901590
}
15911591

1592+
/**
1593+
* Called by the graphics back-end to specify the caps with which we will
1594+
* likely want to be compiling our shaders.
1595+
*/
1596+
void Shader::
1597+
set_default_caps(const ShaderCaps &caps) {
1598+
_default_caps = caps;
1599+
}
1600+
15921601
#ifdef HAVE_CG
15931602
/**
15941603
*
@@ -2364,9 +2373,15 @@ Shader(ShaderLanguage lang) :
23642373
_cg_fprofile = CG_PROFILE_UNKNOWN;
23652374
_cg_gprofile = CG_PROFILE_UNKNOWN;
23662375
if (_default_caps._ultimate_vprofile == 0 || _default_caps._ultimate_vprofile == CG_PROFILE_UNKNOWN) {
2367-
_default_caps._active_vprofile = CG_PROFILE_GENERIC;
2368-
_default_caps._active_fprofile = CG_PROFILE_GENERIC;
2369-
_default_caps._active_gprofile = CG_PROFILE_GENERIC;
2376+
if (basic_shaders_only) {
2377+
_default_caps._active_vprofile = CG_PROFILE_ARBVP1;
2378+
_default_caps._active_fprofile = CG_PROFILE_ARBFP1;
2379+
_default_caps._active_gprofile = CG_PROFILE_UNKNOWN;
2380+
} else {
2381+
_default_caps._active_vprofile = CG_PROFILE_UNKNOWN;
2382+
_default_caps._active_fprofile = CG_PROFILE_UNKNOWN;
2383+
_default_caps._active_gprofile = CG_PROFILE_UNKNOWN;
2384+
}
23702385
_default_caps._ultimate_vprofile = cgGetProfile("glslv");
23712386
_default_caps._ultimate_fprofile = cgGetProfile("glslf");
23722387
_default_caps._ultimate_gprofile = cgGetProfile("glslg");

panda/src/gobj/shader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ class EXPCL_PANDA_GOBJ Shader : public TypedWritableReferenceCount {
527527
void set_compiled(unsigned int format, const char *data, size_t length);
528528
bool get_compiled(unsigned int &format, std::string &binary) const;
529529

530+
static void set_default_caps(const ShaderCaps &caps);
531+
530532
private:
531533
#ifdef HAVE_CG
532534
ShaderArgClass cg_parameter_class(CGparameter p);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy