summaryrefslogtreecommitdiff
path: root/drivers/gles2
diff options
context:
space:
mode:
authorlawnjelly <lawnjelly@gmail.com>2019-09-20 09:45:51 +0100
committerlawnjelly <lawnjelly@gmail.com>2019-09-22 15:38:20 +0100
commitf5365aa0e12fe0ba2acb60a3fcb99126e0428b93 (patch)
tree689e8ff3c92d425a817b27960bea240f1509dca7 /drivers/gles2
parent2add51d0823fe2ef7cb439a6f3fae17e8dd4717f (diff)
Fix GLES2 skinning where VERTEX_TEXTURE not supported
Although the backup USE_SKELETON_SOFTWARE skinning path is currently used when float texture is not supported, the default skinning path still fails when float texture is supported but GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS is 0, i.e. the device cannot read from texture during vertex shader. This PR adds the logic to activate the SKELETON_SOFTWARE path if either of these cases occur, preventing crashes on devices which have this combination of features.
Diffstat (limited to 'drivers/gles2')
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp6
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp11
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.h2
3 files changed, 13 insertions, 6 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index cc414c26af..96878c86b4 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -1432,11 +1432,11 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste
}
}
- bool clear_skeleton_buffer = !storage->config.float_texture_supported;
+ bool clear_skeleton_buffer = storage->config.use_skeleton_software;
if (p_skeleton) {
- if (storage->config.float_texture_supported) {
+ if (!storage->config.use_skeleton_software) {
//use float texture workflow
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1);
glBindTexture(GL_TEXTURE_2D, p_skeleton->tex_id);
@@ -2452,7 +2452,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
if (skeleton) {
state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON, true);
- state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, !storage->config.float_texture_supported);
+ state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, storage->config.use_skeleton_software);
} else {
state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON, false);
state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, false);
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index 5c02d8096d..0379aee561 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -2432,7 +2432,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
// from surface->data.
// if USE_SKELETON_SOFTWARE is active
- if (!config.float_texture_supported) {
+ if (config.use_skeleton_software) {
// if this geometry is used specifically for skinning
if (p_format & (VS::ARRAY_FORMAT_BONES | VS::ARRAY_FORMAT_WEIGHTS))
surface->data = array;
@@ -3514,7 +3514,7 @@ void RasterizerStorageGLES2::skeleton_allocate(RID p_skeleton, int p_bones, bool
skeleton->size = p_bones;
skeleton->use_2d = p_2d_skeleton;
- if (config.float_texture_supported) {
+ if (!config.use_skeleton_software) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, skeleton->tex_id);
@@ -3699,7 +3699,7 @@ void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const PoolVector<
void RasterizerStorageGLES2::update_dirty_skeletons() {
- if (!config.float_texture_supported)
+ if (config.use_skeleton_software)
return;
glActiveTexture(GL_TEXTURE0);
@@ -5751,9 +5751,14 @@ void RasterizerStorageGLES2::initialize() {
frame.current_rt = NULL;
frame.clear_request = false;
+ glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &config.max_vertex_texture_image_units);
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &config.max_texture_image_units);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &config.max_texture_size);
+ // the use skeleton software path should be used if either float texture is not supported,
+ // OR max_vertex_texture_image_units is zero
+ config.use_skeleton_software = (config.float_texture_supported == false) || (config.max_vertex_texture_image_units == 0);
+
shaders.copy.init();
shaders.cubemap_filter.init();
bool ggx_hq = GLOBAL_GET("rendering/quality/reflections/high_quality_ggx");
diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h
index d139697b86..e6cdcac59f 100644
--- a/drivers/gles2/rasterizer_storage_gles2.h
+++ b/drivers/gles2/rasterizer_storage_gles2.h
@@ -60,7 +60,9 @@ public:
bool shrink_textures_x2;
bool use_fast_texture_filter;
+ bool use_skeleton_software;
+ int max_vertex_texture_image_units;
int max_texture_image_units;
int max_texture_size;