gl33: remove avoid_sampler_uniform_updates workaround and make it the default
This commit is contained in:
parent
b61185ff06
commit
7c82cbba9b
4 changed files with 15 additions and 45 deletions
|
@ -975,14 +975,12 @@ uint gl33_bind_texture(Texture *texture, GLuint lock_target, int preferred_unit)
|
|||
(unit->pending != NULL || unit->locked_for_target != lock_target)
|
||||
) {
|
||||
// someone else already took this unit for rendering
|
||||
unit = NULL;
|
||||
log_fatal("BUG: can't bind %s to unit %i: unit already locked for rendering!",
|
||||
texture->debug_label, preferred_unit);
|
||||
}
|
||||
}
|
||||
|
||||
if(unit == NULL) {
|
||||
assert(!glext.issues.avoid_sampler_uniform_updates);
|
||||
unit = gl33_get_free_texunit();
|
||||
}
|
||||
assume(unit != NULL);
|
||||
|
||||
if(unit->locked_for_target) {
|
||||
gl33_relocate_texuint(unit);
|
||||
|
@ -996,7 +994,7 @@ uint gl33_bind_texture(Texture *texture, GLuint lock_target, int preferred_unit)
|
|||
|
||||
assert(!lock_target || lock_target == texture->bind_target);
|
||||
|
||||
if(glext.issues.avoid_sampler_uniform_updates && preferred_unit >= 0) {
|
||||
if(preferred_unit >= 0) {
|
||||
assert(preferred_unit < R.texunits.limit);
|
||||
TextureUnit *u = &R.texunits.array[preferred_unit];
|
||||
|
||||
|
|
|
@ -223,6 +223,8 @@ static void *gl33_sync_uniform(const char *key, void *value, void *arg) {
|
|||
GLuint preferred_unit = CASTPTR_ASSUME_ALIGNED(uniform->cache.pending, int)[i];
|
||||
GLuint unit = gl33_bind_texture(tex, get_texture_target(tex, utype), preferred_unit);
|
||||
|
||||
assert(unit == preferred_unit);
|
||||
|
||||
if(unit != preferred_unit) {
|
||||
gl33_update_uniform(uniform, i, 1, &unit);
|
||||
}
|
||||
|
@ -375,19 +377,17 @@ static bool cache_uniforms(ShaderProgram *prog) {
|
|||
if(UNIFORM_TYPE_IS_SAMPLER(uni.type)) {
|
||||
list_push(&sampler_uniforms, new_uni);
|
||||
|
||||
if(glext.issues.avoid_sampler_uniform_updates) {
|
||||
// Bind each sampler to a different texturing unit.
|
||||
// This way we can change textures by binding them to the right texturing units, and never update the shader's samplers again.
|
||||
// Bind each sampler to a different texturing unit.
|
||||
// This way we can change textures by binding them to the right texturing units, and never update the shader's samplers again.
|
||||
|
||||
int payload[new_uni->array_size];
|
||||
assert(sizeof(payload) == new_uni->array_size * new_uni->elem_size);
|
||||
int payload[new_uni->array_size];
|
||||
assert(sizeof(payload) == new_uni->array_size * new_uni->elem_size);
|
||||
|
||||
for(int j = 0; j < ARRAY_SIZE(payload); ++j) {
|
||||
payload[j] = sampler_binding++;
|
||||
}
|
||||
|
||||
gl33_update_uniform(new_uni, 0, new_uni->array_size, payload);
|
||||
for(int j = 0; j < ARRAY_SIZE(payload); ++j) {
|
||||
payload[j] = sampler_binding++;
|
||||
}
|
||||
|
||||
gl33_update_uniform(new_uni, 0, new_uni->array_size, payload);
|
||||
}
|
||||
|
||||
if(magic_index != UMAGIC_INVALID) {
|
||||
|
|
|
@ -766,7 +766,6 @@ static void detect_broken_intel_driver(void) {
|
|||
|
||||
static bool glcommon_check_workaround(const char *name, const char *envvar, const char *(*detect)(void)) {
|
||||
int env_setting = env_get_int(envvar, -1);
|
||||
glext.issues.avoid_sampler_uniform_updates = false;
|
||||
|
||||
if(env_setting > 0) {
|
||||
log_warn("Enabled workaround `%s` (forced by environment)", name);
|
||||
|
@ -800,26 +799,6 @@ EM_JS(bool, webgl_is_mac, (void), {
|
|||
})
|
||||
#endif
|
||||
|
||||
static const char *detect_slow_sampler_update(void) {
|
||||
#if defined(__MACOSX__) || defined(__EMSCRIPTEN__)
|
||||
const char *gl_vendor = get_unmasked_property(GL_VENDOR, true);
|
||||
const char *gl_renderer = get_unmasked_property(GL_RENDERER, true);
|
||||
|
||||
if(
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
webgl_is_mac() &&
|
||||
#endif
|
||||
strstr(gl_renderer, "Radeon") && ( // This looks like an AMD Radeon card...
|
||||
(strstr(gl_vendor, "ATI") || strstr(gl_vendor, "AMD")) || // ...and AMD's official driver...
|
||||
(strstr(gl_vendor, "Google") && strstr(gl_renderer, "OpenGL")) // ...or ANGLE, backed by OpenGL.
|
||||
)
|
||||
) {
|
||||
return "buggy AMD driver on macOS; see https://github.com/taisei-project/taisei/issues/182";
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *detect_broken_norm16(void) {
|
||||
const char *gl_vendor = get_unmasked_property(GL_VENDOR, true);
|
||||
const char *gl_renderer = get_unmasked_property(GL_RENDERER, true);
|
||||
|
@ -832,12 +811,6 @@ static const char *detect_broken_norm16(void) {
|
|||
}
|
||||
|
||||
static void glcommon_check_issues(void) {
|
||||
glext.issues.avoid_sampler_uniform_updates = glcommon_check_workaround(
|
||||
"avoid sampler uniform updates",
|
||||
"TAISEI_GL_WORKAROUND_AVOID_SAMPLER_UNIFORM_UPDATES",
|
||||
detect_slow_sampler_update
|
||||
);
|
||||
|
||||
glext.issues.disable_norm16 = glcommon_check_workaround(
|
||||
"disable normalized 16bpc pixel formats",
|
||||
"TAISEI_GL_WORKAROUND_DISABLE_NORM16",
|
||||
|
|
|
@ -156,8 +156,7 @@ struct glext_s {
|
|||
} version;
|
||||
|
||||
struct {
|
||||
uchar avoid_sampler_uniform_updates : 1;
|
||||
uchar disable_norm16 : 1;
|
||||
bool disable_norm16 : 1;
|
||||
} issues;
|
||||
|
||||
ext_flag_t clear_texture;
|
||||
|
|
Loading…
Reference in a new issue