[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51628] trunk/blender/source/blender: Fix issue after commit 50282: float texture painting non-color data textures did
Brecht Van Lommel
brechtvanlommel at pandora.be
Thu Oct 25 17:25:29 CEST 2012
Revision: 51628
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51628
Author: blendix
Date: 2012-10-25 15:25:28 +0000 (Thu, 25 Oct 2012)
Log Message:
-----------
Fix issue after commit 50282: float texture painting non-color data textures did
not do correct partial updates, now it remembers if the opengl texture is a
non-color data texture or not and takes that into account for the update.
Also includes some renaming ncd => is_data for consistency with color space
terminology used elsewhere.
Modified Paths:
--------------
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/gpu/GPU_draw.h
trunk/blender/source/blender/gpu/GPU_extensions.h
trunk/blender/source/blender/gpu/GPU_material.h
trunk/blender/source/blender/gpu/intern/gpu_codegen.c
trunk/blender/source/blender/gpu/intern/gpu_codegen.h
trunk/blender/source/blender/gpu/intern/gpu_draw.c
trunk/blender/source/blender/gpu/intern/gpu_extensions.c
trunk/blender/source/blender/imbuf/IMB_imbuf.h
trunk/blender/source/blender/imbuf/intern/divers.c
trunk/blender/source/blender/makesdna/DNA_image_types.h
trunk/blender/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
trunk/blender/source/blender/nodes/shader/nodes/node_shader_tex_image.c
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2012-10-25 15:25:28 UTC (rev 51628)
@@ -1293,6 +1293,7 @@
if (NULL == newimaadr(fd, ibuf)) { /* so was restored */
BLI_remlink(&ima->ibufs, ibuf);
ima->bindcode = 0;
+ ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
ima->gputexture = NULL;
}
}
@@ -3025,6 +3026,7 @@
/* if not restored, we keep the binded opengl index */
if (ima->ibufs.first == NULL) {
ima->bindcode = 0;
+ ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
ima->gputexture = NULL;
}
Modified: trunk/blender/source/blender/gpu/GPU_draw.h
===================================================================
--- trunk/blender/source/blender/gpu/GPU_draw.h 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/gpu/GPU_draw.h 2012-10-25 15:25:28 UTC (rev 51628)
@@ -124,7 +124,7 @@
void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h);
void GPU_update_images_framechange(void);
int GPU_update_image_time(struct Image *ima, double time);
-int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int compare, int mipmap, int ncd);
+int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int compare, int mipmap, int isdata);
void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float *frect, int rectw, int recth, int mipmap, int use_hight_bit_depth, struct Image *ima);
void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, struct Image *ima, struct ImBuf *ibuf);
int GPU_upload_dxt_texture(struct ImBuf *ibuf);
Modified: trunk/blender/source/blender/gpu/GPU_extensions.h
===================================================================
--- trunk/blender/source/blender/gpu/GPU_extensions.h 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/gpu/GPU_extensions.h 2012-10-25 15:25:28 UTC (rev 51628)
@@ -111,7 +111,7 @@
GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256]);
GPUTexture *GPU_texture_create_vsm_shadow_map(int size, char err_out[256]);
GPUTexture *GPU_texture_from_blender(struct Image *ima,
- struct ImageUser *iuser, int ncd, double time, int mipmap);
+ struct ImageUser *iuser, int isdata, double time, int mipmap);
void GPU_texture_free(GPUTexture *tex);
void GPU_texture_ref(GPUTexture *tex);
Modified: trunk/blender/source/blender/gpu/GPU_material.h
===================================================================
--- trunk/blender/source/blender/gpu/GPU_material.h 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/gpu/GPU_material.h 2012-10-25 15:25:28 UTC (rev 51628)
@@ -107,7 +107,7 @@
GPUNodeLink *GPU_attribute(int type, const char *name);
GPUNodeLink *GPU_uniform(float *num);
GPUNodeLink *GPU_dynamic_uniform(float *num, int dynamictype, void *data);
-GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, int ncd);
+GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, int isdata);
GPUNodeLink *GPU_texture(int size, float *pixels);
GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex, int dynamictype, void *data);
GPUNodeLink *GPU_socket(GPUNodeStack *sock);
Modified: trunk/blender/source/blender/gpu/intern/gpu_codegen.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_codegen.c 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/gpu/intern/gpu_codegen.c 2012-10-25 15:25:28 UTC (rev 51628)
@@ -761,7 +761,7 @@
/* 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 @@
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 @@
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;
}
Modified: trunk/blender/source/blender/gpu/intern/gpu_codegen.h
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_codegen.h 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/gpu/intern/gpu_codegen.h 2012-10-25 15:25:28 UTC (rev 51628)
@@ -91,7 +91,7 @@
const char *attribname;
int image;
- int imagencd;
+ int image_isdata;
int texture;
int texturesize;
@@ -138,7 +138,7 @@
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 */
Modified: trunk/blender/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_draw.c 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/gpu/intern/gpu_draw.c 2012-10-25 15:25:28 UTC (rev 51628)
@@ -422,7 +422,7 @@
}
}
-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 @@
}
/* 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 @@
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 @@
/* 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 @@
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 @@
ima->repbind= NULL;
}
- ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
+ ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE|IMA_GLBIND_IS_DATA);
}
void GPU_free_images(void)
Modified: trunk/blender/source/blender/gpu/intern/gpu_extensions.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_extensions.c 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/gpu/intern/gpu_extensions.c 2012-10-25 15:25:28 UTC (rev 51628)
@@ -528,7 +528,7 @@
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 @@
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;
Modified: trunk/blender/source/blender/imbuf/IMB_imbuf.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf.h 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf.h 2012-10-25 15:25:28 UTC (rev 51628)
@@ -371,7 +371,7 @@
void IMB_rect_from_float(struct ImBuf *ibuf);
/* Create char buffer for part of the image, color corrected if necessary,
* Changed part will be stored in buffer. This is expected to be used for texture painting updates */
-void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h);
+void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h, int is_data);
void IMB_float_from_rect(struct ImBuf *ibuf);
void IMB_float_from_rect_simple(struct ImBuf *ibuf); /* no profile conversion */
/* note, check that the conversion exists, only some are supported */
Modified: trunk/blender/source/blender/imbuf/intern/divers.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/divers.c 2012-10-25 15:11:02 UTC (rev 51627)
+++ trunk/blender/source/blender/imbuf/intern/divers.c 2012-10-25 15:25:28 UTC (rev 51628)
@@ -561,7 +561,7 @@
}
/* converts from linear float to sRGB byte for part of the texture, buffer will hold the changed part */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list