diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-17 16:58:33 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-18 04:43:52 +0300 |
commit | 2d9eee15c58ba1d3e2bd05a17ca09d74421c47ea (patch) | |
tree | 5178eda0d4dfef2081cad696d37052f3a797a39b /source/blender/gpu | |
parent | 0ef57d3fc079795f77ab7f13bca842ab172af08f (diff) |
Cleanup: GPU: Set default GL_UNPACK_ALIGNMENT to 1
Ogl default is 4 but for almost all cases, blender use tightly
packed format. This avoid confusion and state change for the
common case.
The only case that __might__ need alignement is DDS loader
(untested) so leaving this as it is.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 5 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_state.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_texture.c | 12 |
3 files changed, 7 insertions, 12 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 7e6d47636f6..9fdb98cfbf6 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1195,6 +1195,9 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf, bool use_srgb) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); + /* Reset to opengl Defaults. (Untested, might not be needed) */ + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16; for (i = 0; i < ibuf->dds_data.nummipmaps && (width || height); i++) { if (width == 0) { @@ -1213,6 +1216,8 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf, bool use_srgb) width >>= 1; height >>= 1; } + /* Restore Blender default. */ + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); /* set number of mipmap levels we have, needed in case they don't go down to 1x1 */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, i - 1); diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c index 636a5e2c31d..b52504eb492 100644 --- a/source/blender/gpu/intern/gpu_state.c +++ b/source/blender/gpu/intern/gpu_state.c @@ -412,6 +412,8 @@ void GPU_state_init(void) glCullFace(GL_BACK); glDisable(GL_CULL_FACE); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + /* Is default but better be explicit. */ glEnable(GL_MULTISAMPLE); diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index c4d7eccf9f9..4c847236f09 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -1465,16 +1465,8 @@ void GPU_texture_update_sub(GPUTexture *tex, BLI_assert((int)tex->format > -1); BLI_assert(tex->components > -1); - const uint bytesize = gpu_get_bytesize(tex->format); GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag); GLenum data_type = gpu_get_gl_datatype(gpu_data_format); - GLint alignment; - - /* The default pack size for textures is 4, which won't work for byte based textures */ - if (bytesize == 1) { - glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - } glBindTexture(tex->target, tex->bindcode); switch (tex->target) { @@ -1505,10 +1497,6 @@ void GPU_texture_update_sub(GPUTexture *tex, BLI_assert(!"tex->target mode not supported"); } - if (bytesize == 1) { - glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); - } - glBindTexture(tex->target, 0); } |