Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-10-22 13:58:11 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-10-22 14:00:40 +0300
commit2d084d4ec430ec8b280a52286eeeca770f2221bc (patch)
tree2436fda8529effee889b423fabb065826a791307 /source/blender/gpu/intern/gpu_texture.c
parent0e70feab22fd0871d61a03b43c591fb300990de7 (diff)
GPU: Fix Issue with recursive downsample and Intel HDXXX
This is caused by a driver bug that prevent us from rendering to (or even binding) a texture mip level that is below GL_TEXTURE_MAX_LEVEL of the target texture. This is fine in most drivers (and legal AFAIK) but not on thoses Intels HDXXX + Windows. As a fix we just put GL_TEXTURE_MAX_LEVEL lower (which is illegal because it is undefined behaviour), but in practice it works ok and does not trigger any warnings or errors. This commit fixes most of the problems encountered on these GPUs (T56668).
Diffstat (limited to 'source/blender/gpu/intern/gpu_texture.c')
-rw-r--r--source/blender/gpu/intern/gpu_texture.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 6a8e686afb3..c3a1148a360 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -916,12 +916,13 @@ GPUTexture *GPU_texture_create_cube(
const int channels = gpu_get_component_count(tex_format);
if (fpixels) {
- fpixels_px = fpixels + 0 * w * w * channels;
- fpixels_nx = fpixels + 1 * w * w * channels;
- fpixels_py = fpixels + 2 * w * w * channels;
- fpixels_ny = fpixels + 3 * w * w * channels;
- fpixels_pz = fpixels + 4 * w * w * channels;
- fpixels_nz = fpixels + 5 * w * w * channels;
+ int face_ofs = w * w * channels;
+ fpixels_px = fpixels + 0 * face_ofs;
+ fpixels_nx = fpixels + 1 * face_ofs;
+ fpixels_py = fpixels + 2 * face_ofs;
+ fpixels_ny = fpixels + 3 * face_ofs;
+ fpixels_pz = fpixels + 4 * face_ofs;
+ fpixels_nz = fpixels + 5 * face_ofs;
}
else {
fpixels_px = fpixels_py = fpixels_pz = fpixels_nx = fpixels_ny = fpixels_nz = NULL;
@@ -1099,6 +1100,7 @@ void *GPU_texture_read(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplv
samples_count *= size[0];
samples_count *= max_ii(1, size[1]);
samples_count *= max_ii(1, size[2]);
+ samples_count *= (GPU_texture_cube(tex)) ? 6 : 1;
switch (gpu_data_format) {
case GPU_DATA_FLOAT:
@@ -1123,7 +1125,16 @@ void *GPU_texture_read(GPUTexture *tex, GPUDataFormat gpu_data_format, int miplv
glBindTexture(tex->target, tex->bindcode);
- glGetTexImage(tex->target, miplvl, data_format, data_type, buf);
+ if (GPU_texture_cube(tex)) {
+ int cube_face_size = buf_size / 6;
+ for (int i = 0; i < 6; ++i) {
+ glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, miplvl, data_format, data_type,
+ ((char *)buf) + cube_face_size * i);
+ }
+ }
+ else {
+ glGetTexImage(tex->target, miplvl, data_format, data_type, buf);
+ }
glBindTexture(tex->target, 0);