summaryrefslogtreecommitdiff
path: root/drivers/gles3/rasterizer_storage_gles3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles3/rasterizer_storage_gles3.cpp')
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp57
1 files changed, 48 insertions, 9 deletions
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 3255726c1f..0fc095a868 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -876,11 +876,34 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, VS::CubeMapSi
}
}
+ Image::Format img_format;
+
+ //convert special case RGB10_A2 to RGBA8 because it's not a supported image format
+ if (texture->gl_internal_format_cache == GL_RGB10_A2) {
+
+ img_format = Image::FORMAT_RGBA8;
+
+ uint32_t *ptr = (uint32_t *)wb.ptr();
+ uint32_t num_pixels = data_size / 4;
+
+ for (int ofs = 0; ofs < num_pixels; ofs++) {
+ uint32_t px = ptr[ofs];
+ uint32_t a = px >> 30 & 0xFF;
+
+ ptr[ofs] = (px >> 2 & 0xFF) |
+ (px >> 12 & 0xFF) << 8 |
+ (px >> 22 & 0xFF) << 16 |
+ (a | a << 2 | a << 4 | a << 6) << 24;
+ }
+ } else {
+ img_format = texture->format;
+ }
+
wb = PoolVector<uint8_t>::Write();
data.resize(data_size);
- Image *img = memnew(Image(texture->alloc_width, texture->alloc_height, texture->mipmaps > 1 ? true : false, texture->format, data));
+ Image *img = memnew(Image(texture->alloc_width, texture->alloc_height, texture->mipmaps > 1 ? true : false, img_format, data));
return Ref<Image>(img);
#else
@@ -2184,10 +2207,15 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
Transform2D v = value;
GLfloat *gui = (GLfloat *)data;
+ //in std140 members of mat2 are treated as vec4s
gui[0] = v.elements[0][0];
gui[1] = v.elements[0][1];
- gui[2] = v.elements[1][0];
- gui[3] = v.elements[1][1];
+ gui[2] = 0;
+ gui[3] = 0;
+ gui[4] = v.elements[1][0];
+ gui[5] = v.elements[1][1];
+ gui[6] = 0;
+ gui[7] = 0;
} break;
case ShaderLanguage::TYPE_MAT3: {
@@ -2362,9 +2390,15 @@ _FORCE_INLINE_ static void _fill_std140_ubo_value(ShaderLanguage::DataType type,
case ShaderLanguage::TYPE_MAT2: {
GLfloat *gui = (GLfloat *)data;
- for (int i = 0; i < 2; i++) {
- gui[i] = value[i].real;
- }
+ //in std140 members of mat2 are treated as vec4s
+ gui[0] = value[0].real;
+ gui[1] = value[1].real;
+ gui[2] = 0;
+ gui[3] = 0;
+ gui[4] = value[2].real;
+ gui[5] = value[3].real;
+ gui[6] = 0;
+ gui[7] = 0;
} break;
case ShaderLanguage::TYPE_MAT3: {
@@ -2418,11 +2452,14 @@ _FORCE_INLINE_ static void _fill_std140_ubo_empty(ShaderLanguage::DataType type,
case ShaderLanguage::TYPE_BVEC4:
case ShaderLanguage::TYPE_IVEC4:
case ShaderLanguage::TYPE_UVEC4:
- case ShaderLanguage::TYPE_VEC4:
- case ShaderLanguage::TYPE_MAT2: {
+ case ShaderLanguage::TYPE_VEC4: {
zeromem(data, 16);
} break;
+ case ShaderLanguage::TYPE_MAT2: {
+
+ zeromem(data, 32);
+ } break;
case ShaderLanguage::TYPE_MAT3: {
zeromem(data, 48);
@@ -5332,7 +5369,7 @@ void RasterizerStorageGLES3::particles_set_emitting(RID p_particles, bool p_emit
Particles *particles = particles_owner.getornull(p_particles);
ERR_FAIL_COND(!particles);
if (p_emitting != particles->emitting) {
- // Restart is overriden by set_emitting
+ // Restart is overridden by set_emitting
particles->restart_request = false;
}
particles->emitting = p_emitting;
@@ -5680,6 +5717,7 @@ void RasterizerStorageGLES3::_particles_process(Particles *p_particles, float p_
SWAP(p_particles->particle_buffers[0], p_particles->particle_buffers[1]);
SWAP(p_particles->particle_vaos[0], p_particles->particle_vaos[1]);
+ glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
glBindVertexArray(0);
/* //debug particles :D
glBindBuffer(GL_ARRAY_BUFFER, p_particles->particle_buffers[0]);
@@ -6950,6 +6988,7 @@ bool RasterizerStorageGLES3::free(RID p_rid) {
memdelete(cls);
} else if (particles_owner.owns(p_rid)) {
Particles *particles = particles_owner.get(p_rid);
+ particles->instance_remove_deps();
particles_owner.free(p_rid);
memdelete(particles);
} else {