diff options
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 8 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.h | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 26 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 4 |
4 files changed, 24 insertions, 18 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 25990e8fc6e..b90e67ac838 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -761,7 +761,7 @@ void GPU_pass_bind(GPUPass *pass, double time, int mipmap) /* now bind the textures */ for (input=inputs->first; input; input=input->next) { if (input->ima) - input->tex = GPU_texture_from_blender(input->ima, input->iuser, input->imagencd, time, mipmap); + input->tex = GPU_texture_from_blender(input->ima, input->iuser, input->image_isdata, time, mipmap); if (input->tex && input->bindtex) { GPU_texture_bind(input->tex, input->texid); @@ -917,7 +917,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) input->ima = link->ptr1; input->iuser = link->ptr2; - input->imagencd = link->imagencd; + input->image_isdata = link->image_isdata; input->textarget = GL_TEXTURE_2D; input->textype = GPU_TEX2D; MEM_freeN(link); @@ -1110,14 +1110,14 @@ GPUNodeLink *GPU_dynamic_uniform(float *num, int dynamictype, void *data) return link; } -GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, int ncd) +GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, int isdata) { GPUNodeLink *link = GPU_node_link_create(0); link->image= 1; link->ptr1= ima; link->ptr2= iuser; - link->imagencd= ncd; + link->image_isdata= isdata; return link; } diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h index 42e87532e26..f61f34908c5 100644 --- a/source/blender/gpu/intern/gpu_codegen.h +++ b/source/blender/gpu/intern/gpu_codegen.h @@ -91,7 +91,7 @@ struct GPUNodeLink { const char *attribname; int image; - int imagencd; + int image_isdata; int texture; int texturesize; @@ -138,7 +138,7 @@ typedef struct GPUInput { struct Image *ima; /* image */ struct ImageUser *iuser;/* image user */ - int imagencd; /* image does not contain color data */ + int image_isdata; /* image does not contain color data */ float *dynamicvec; /* vector data in case it is dynamic */ int dynamictype; /* origin of the dynamic uniform (GPUDynamicType) */ void *dynamicdata; /* data source of the dynamic uniform */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index fd8dd562c02..b40e19e1c9e 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -422,7 +422,7 @@ static void gpu_verify_reflection(Image *ima) } } -int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int mipmap, int ncd) +int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int mipmap, int is_data) { ImBuf *ibuf = NULL; unsigned int *bind = NULL; @@ -492,7 +492,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int } /* TODO unneeded when float images are correctly treated as linear always */ - if (!ncd) + if (!is_data) do_color_management = TRUE; if (ibuf->rect==NULL) @@ -611,12 +611,21 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int rect= tilerect; } } + #ifdef WITH_DDS if (ibuf->ftype & DDS) GPU_create_gl_tex_compressed(bind, rect, rectw, recth, mipmap, ima, ibuf); else #endif GPU_create_gl_tex(bind, rect, frect, rectw, recth, mipmap, use_high_bit_depth, ima); + + /* mark as non-color data texture */ + if(*bind) { + if (is_data) + ima->tpageflag |= IMA_GLBIND_IS_DATA; + else + ima->tpageflag &= ~IMA_GLBIND_IS_DATA; + } /* clean up */ if (tilerect) @@ -908,7 +917,8 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) /* if color correction is needed, we must update the part that needs updating. */ if (ibuf->rect_float) { float *buffer = MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf"); - IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h); + int is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA); + IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h, is_data); glBindTexture(GL_TEXTURE_2D, ima->bindcode); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, @@ -934,12 +944,8 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); glPixelStorei(GL_UNPACK_SKIP_ROWS, y); - if (ibuf->rect_float) - glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, - GL_FLOAT, ibuf->rect_float); - else - glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, - GL_UNSIGNED_BYTE, ibuf->rect); + glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, + GL_UNSIGNED_BYTE, ibuf->rect); glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); @@ -1135,7 +1141,7 @@ void GPU_free_image(Image *ima) ima->repbind= NULL; } - ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; + ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE|IMA_GLBIND_IS_DATA); } void GPU_free_images(void) diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 798868a5efe..21d5482e9cc 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -528,7 +528,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, float * return tex; } -GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int ncd, double time, int mipmap) +GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int isdata, double time, int mipmap) { GPUTexture *tex; GLint w, h, border, lastbindcode, bindcode; @@ -536,7 +536,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int ncd, doub glGetIntegerv(GL_TEXTURE_BINDING_2D, &lastbindcode); GPU_update_image_time(ima, time); - bindcode = GPU_verify_image(ima, iuser, 0, 0, mipmap, ncd); + bindcode = GPU_verify_image(ima, iuser, 0, 0, mipmap, isdata); if (ima->gputexture) { ima->gputexture->bindcode = bindcode; |