Merge commit 'origin/master' into gallium-0.2
authorAlan Hourihane <alanh@tungstengraphics.com>
Fri, 28 Nov 2008 16:19:10 +0000 (16:19 +0000)
committerAlan Hourihane <alanh@tungstengraphics.com>
Fri, 28 Nov 2008 16:19:10 +0000 (16:19 +0000)
13 files changed:
configure.ac
progs/demos/fbo_firecube.c
src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc
src/glx/x11/glx_query.c
src/glx/x11/glxclient.h
src/glx/x11/glxcmds.c
src/glx/x11/glxext.c
src/glx/x11/single2.c
src/mesa/drivers/windows/gdi/wmesa.c
src/mesa/shader/prog_statevars.c
src/mesa/shader/slang/slang_codegen.c
src/mesa/shader/slang/slang_compile.c
src/mesa/shader/slang/slang_emit.c

index e48137f2abc4c43d3255f175600850f627207343..15f6068c8e0a8d013198d65f8ee15ca0531eaf66 100644 (file)
@@ -1033,6 +1033,7 @@ else
 fi
     echo "        DRI driver dir:  $DRI_DRIVER_INSTALL_DIR"
 fi
+echo "        Use XCB:         $enable_xcb"
 
 dnl Libraries
 echo ""
index ed87dd133cf63e68e1c7d39e6351c971aa88dee3..f5ee82a2f11598394d28789ebf80f04d6cf811a9 100644 (file)
@@ -154,6 +154,7 @@ static GLuint TexObj;
 static GLuint MyFB;
 static GLuint DepthRB;
 static GLboolean WireFrame = GL_FALSE;
+static GLboolean Anim = GL_TRUE;
 static GLint texType = 0;
 
 static GLint T0 = 0;
@@ -163,6 +164,11 @@ static GLint Win = 0;
 static GLfloat ViewRotX = 20.0, ViewRotY = 30.0, ViewRotZ = 0.0;
 static GLfloat CubeRot = 0.0;
 
+
+static void
+idle(void);
+
+
 static void
 CheckError(int line)
 {
@@ -561,7 +567,7 @@ drawfire(void)
    printstring(GLUT_BITMAP_HELVETICA_18, texNames[texType]);
    glColor3f(1.0, 0.0, 0.0);
    glRasterPos2i(10, 470);
-   printstring(GLUT_BITMAP_HELVETICA_10,
+   printstring(GLUT_BITMAP_HELVETICA_10, 
               "Fire V1.5 Written by David Bucciarelli (tech.hmw@plus.it)");
 
    if (help)
@@ -605,7 +611,10 @@ key(unsigned char key, int x, int y)
       cleanup();
       exit(0);
       break;
-
+   case ' ':
+      Anim = !Anim;
+      glutIdleFunc(Anim ? idle : NULL);
+      break;
    case 'a':
       v += 0.0005;
       break;
@@ -1013,7 +1022,7 @@ static void
 visible(int vis)
 {
    if (vis == GLUT_VISIBLE)
-      glutIdleFunc(idle);
+      glutIdleFunc(Anim ? idle : NULL);
    else
       glutIdleFunc(NULL);
 }
index 3dc16313fff51c16dbdb26ae630bfb45d9f46d37..ac7ff84fc4ae950fd428408d1738ba2e61d29b63 100644 (file)
@@ -103,23 +103,22 @@ bezierPatchMesh *bezierPatchMeshMake(int maptype, float umin, float umax, int us
   int dimension;
   int the_ustride;
   int the_vstride;
-  
-  bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
-  assert(ret);
 
-  ret->bpatch = NULL;
-  ret->bpatch_normal = NULL;
-  ret->bpatch_color  = NULL;
-  ret->bpatch_texcoord = NULL;
   if(maptype == GL_MAP2_VERTEX_3) dimension = 3;
   else if (maptype==GL_MAP2_VERTEX_4) dimension = 4;
   else {
     fprintf(stderr, "error in inMap2f, maptype=%i is wrong, maptype,map is invalid\n", maptype);
     return NULL;
   }
-  
+
+  bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
+  assert(ret);
+
+  ret->bpatch_normal = NULL;
+  ret->bpatch_color  = NULL;
+  ret->bpatch_texcoord = NULL;
   ret->bpatch = bezierPatchMake(umin, vmin, umax, vmax, uorder, vorder, dimension);
+
   /*copy the control points there*/
   the_ustride = vorder * dimension;
   the_vstride = dimension;
index 56f34951863c66018e5918f1c5539377b0381617..2789b841b1b7f41df6e4be698e606be8ec255857 100644 (file)
 
 #include "glxclient.h"
 
+#if defined(USE_XCB)
+# include <X11/Xlib-xcb.h>
+# include <xcb/xcb.h>
+# include <xcb/glx.h>
+#endif
+
+#ifdef USE_XCB
+
+/**
+ * Exchange a protocol request for glXQueryServerString.
+ */
+char *
+__glXQueryServerString(Display* dpy,
+                       int opcode,
+                       CARD32 screen,
+                       CARD32 name)
+{
+   xcb_connection_t *c = XGetXCBConnection(dpy);
+   xcb_glx_query_server_string_reply_t* reply =
+      xcb_glx_query_server_string_reply(c,
+                                        xcb_glx_query_server_string(c,
+                                                                    screen,
+                                                                    name),
+                                        NULL);
+
+   /* The spec doesn't mention this, but the Xorg server replies with
+    * a string already terminated with '\0'. */
+   uint32_t len = xcb_glx_query_server_string_string_length(reply);
+   char* buf = Xmalloc(len);
+   memcpy(buf, xcb_glx_query_server_string_string(reply), len);
+   free(reply);
+
+   return buf;
+}
+
+/**
+ * Exchange a protocol request for glGetString.
+ */
+char *
+__glXGetString(Display* dpy,
+               int opcode,
+               CARD32 contextTag,
+               CARD32 name)
+{
+   xcb_connection_t *c = XGetXCBConnection(dpy);
+   xcb_glx_get_string_reply_t* reply =
+      xcb_glx_get_string_reply(c,
+                               xcb_glx_get_string(c,
+                                                  contextTag,
+                                                  name),
+                               NULL);
+
+   /* The spec doesn't mention this, but the Xorg server replies with
+    * a string already terminated with '\0'. */
+   uint32_t len = xcb_glx_get_string_string_length(reply);
+   char* buf = Xmalloc(len);
+   memcpy(buf, xcb_glx_get_string_string(reply), len);
+   free(reply);
+
+   return buf;
+}
+
+#else
+
 /**
  * GLX protocol structure for the ficticious "GXLGenericGetString" request.
  * 
@@ -57,7 +121,7 @@ typedef struct GLXGenericGetString
  * Query the Server GLX string.
  * This routine will allocate the necessay space for the string.
  */
-char *
+static char *
 __glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
                          CARD32 for_whom, CARD32 name)
 {
@@ -101,3 +165,27 @@ __glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
 
    return buf;
 }
+
+char *
+__glXQueryServerString(Display* dpy,
+                       int opcode,
+                       CARD32 screen,
+                       CARD32 name)
+{
+   return __glXGetStringFromServer(dpy, opcode,
+                                   X_GLXQueryServerString,
+                                   screen, name);
+}
+
+char *
+__glXGetString(Display* dpy,
+               int opcode,
+               CARD32 contextTag,
+               CARD32 name)
+{
+   return __glXGetStringFromServer(dpy, opcode, X_GLsop_GetString,
+                                   contextTag, name);
+}
+
+#endif /* USE_XCB */
+
index 3b9076bdd722a40b154dd698ba3b925c3ae6ef62..467b0ebb7f9a7899bbb46ba32b7b31c88335878f 100644 (file)
@@ -741,8 +741,10 @@ extern void _XSend(Display*, const void*, long);
 extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
     int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags );
 
-extern char * __glXGetStringFromServer( Display * dpy, int opcode,
-    CARD32 glxCode, CARD32 for_whom, CARD32 name );
+extern char * __glXQueryServerString(Display* dpy, int opcode,
+                                     CARD32 screen, CARD32 name);
+extern char * __glXGetString(Display* dpy, int opcode,
+                             CARD32 screen, CARD32 name);
 
 extern char *__glXstrdup(const char *str);
 
index 391e0be05e7a3e0faacf69bb9f360bd4aebd3cc0..1d373ed29d81bea9ec76403b50107b76eeca9b90 100644 (file)
 #include "xf86dri.h"
 #endif
 
+#if defined(USE_XCB)
+#include <X11/Xlib-xcb.h>
+#include <xcb/xcb.h>
+#include <xcb/glx.h>
+#endif
+
 static const char __glXGLXClientVendorName[] = "SGI";
 static const char __glXGLXClientVersion[] = "1.4";
 
@@ -749,8 +755,10 @@ PUBLIC void glXCopyContext(Display *dpy, GLXContext source,
  */
 static Bool __glXIsDirect(Display *dpy, GLXContextID contextID)
 {
+#if !defined(USE_XCB)
     xGLXIsDirectReq *req;
     xGLXIsDirectReply reply;
+#endif
     CARD8 opcode;
 
     opcode = __glXSetupForCommand(dpy);
@@ -758,6 +766,18 @@ static Bool __glXIsDirect(Display *dpy, GLXContextID contextID)
        return GL_FALSE;
     }
 
+#ifdef USE_XCB
+   xcb_connection_t* c = XGetXCBConnection(dpy);
+   xcb_glx_is_direct_reply_t* reply =
+      xcb_glx_is_direct_reply(c,
+                              xcb_glx_is_direct(c, contextID),
+                              NULL);
+
+   const Bool is_direct = reply->is_direct ? True : False;
+   free(reply);
+
+   return is_direct;
+#else
     /* Send the glXIsDirect request */
     LockDisplay(dpy);
     GetReq(GLXIsDirect,req);
@@ -769,6 +789,7 @@ static Bool __glXIsDirect(Display *dpy, GLXContextID contextID)
     SyncHandle();
 
     return reply.isDirect;
+#endif /* USE_XCB */
 }
 
 /**
@@ -840,7 +861,6 @@ PUBLIC void glXDestroyGLXPixmap(Display *dpy, GLXPixmap glxpixmap)
 
 PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
 {
-    xGLXSwapBuffersReq *req;
     GLXContext gc;
     GLXContextTag tag;
     CARD8 opcode;
@@ -871,6 +891,13 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
        tag = 0;
     }
 
+#ifdef USE_XCB
+    xcb_connection_t* c = XGetXCBConnection(dpy);
+    xcb_glx_swap_buffers(c, tag, drawable);
+    xcb_flush(c);
+#else
+    xGLXSwapBuffersReq *req;
+
     /* Send the glXSwapBuffers request */
     LockDisplay(dpy);
     GetReq(GLXSwapBuffers,req);
@@ -881,6 +908,7 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
     UnlockDisplay(dpy);
     SyncHandle();
     XFlush(dpy);
+#endif /* USE_XCB */
 }
 
 
@@ -1314,9 +1342,8 @@ PUBLIC const char *glXQueryExtensionsString( Display *dpy, int screen )
 
     if (!psc->effectiveGLXexts) {
         if (!psc->serverGLXexts) {
-           psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
-                                                  X_GLXQueryServerString,
-                                                  screen, GLX_EXTENSIONS);
+           psc->serverGLXexts =
+              __glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS);
        }
 
        __glXCalculateUsableExtensions(psc,
@@ -1371,8 +1398,7 @@ PUBLIC const char *glXQueryServerString( Display *dpy, int screen, int name )
     }
 
     if ( *str == NULL ) {
-       *str = __glXGetStringFromServer(dpy, priv->majorOpcode,
-                                       X_GLXQueryServerString, screen, name);
+       *str = __glXQueryServerString(dpy, priv->majorOpcode, screen, name);
     }
     
     return *str;
@@ -1380,9 +1406,18 @@ PUBLIC const char *glXQueryServerString( Display *dpy, int screen, int name )
 
 void __glXClientInfo (  Display *dpy, int opcode  )
 {
-    xGLXClientInfoReq *req;
-    int size;
     char * ext_str = __glXGetClientGLExtensionString();
+    int size = strlen( ext_str ) + 1;
+
+#ifdef USE_XCB
+   xcb_connection_t *c = XGetXCBConnection(dpy);
+   xcb_glx_client_info(c,
+                       GLX_MAJOR_VERSION,
+                       GLX_MINOR_VERSION,
+                       size,
+                       (const uint8_t *)ext_str);
+#else
+    xGLXClientInfoReq *req;
 
     /* Send the glXClientInfo request */
     LockDisplay(dpy);
@@ -1392,14 +1427,14 @@ void __glXClientInfo (  Display *dpy, int opcode  )
     req->major = GLX_MAJOR_VERSION;
     req->minor = GLX_MINOR_VERSION;
 
-    size = strlen( ext_str ) + 1;
     req->length += (size + 3) >> 2;
     req->numbytes = size;
     Data(dpy, ext_str, size);
 
     UnlockDisplay(dpy);
     SyncHandle();
-    
+#endif /* USE_XCB */
+
     Xfree( ext_str );
 }
 
index b6bdbd52bb5b599d9f7a44d3f9f5647b6a983652..be6edf9b19317ebf70bc9d07780ce1c080c13136 100644 (file)
@@ -139,7 +139,8 @@ XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
 ** Free the per screen configs data as well as the array of
 ** __glXScreenConfigs.
 */
-     static void FreeScreenConfigs(__GLXdisplayPrivate * priv)
+static void
+FreeScreenConfigs(__GLXdisplayPrivate * priv)
 {
    __GLXscreenConfigs *psc;
    GLint i, screens;
@@ -221,6 +222,25 @@ __glXFreeDisplayPrivate(XExtData * extension)
 static Bool
 QueryVersion(Display * dpy, int opcode, int *major, int *minor)
 {
+#ifdef USE_XCB
+   xcb_connection_t *c = XGetXCBConnection(dpy);
+   xcb_glx_query_version_reply_t* reply =
+      xcb_glx_query_version_reply(c,
+                                  xcb_glx_query_version(c,
+                                                        GLX_MAJOR_VERSION,
+                                                        GLX_MINOR_VERSION),
+                                  NULL);
+
+   if(reply->major_version != GLX_MAJOR_VERSION)
+   {
+      free(reply);
+      return GL_FALSE;
+   }
+   *major = reply->major_version;
+   *minor = min(reply->minor_version, GLX_MINOR_VERSION);
+   free(reply);
+   return GL_TRUE;
+#else
    xGLXQueryVersionReq *req;
    xGLXQueryVersionReply reply;
 
@@ -245,6 +265,7 @@ QueryVersion(Display * dpy, int opcode, int *major, int *minor)
    *major = reply.majorVersion;
    *minor = min(reply.minorVersion, GLX_MINOR_VERSION);
    return GL_TRUE;
+#endif /* USE_XCB */
 }
 
 
@@ -529,9 +550,7 @@ getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
    __GLXscreenConfigs *psc;
 
    psc = priv->screenConfigs + screen;
-   psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
-                                                 X_GLXQueryServerString,
-                                                 screen, GLX_EXTENSIONS);
+   psc->serverGLXexts = __glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS);
 
    LockDisplay(dpy);
 
@@ -589,9 +608,7 @@ AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
    memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
    priv->screenConfigs = psc;
 
-   priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
-                                                     X_GLXQueryServerString,
-                                                     0, GLX_VERSION);
+   priv->serverGLXversion = __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION);
    if (priv->serverGLXversion == NULL) {
       FreeScreenConfigs(priv);
       return GL_FALSE;
index 83a250522206779e24a73bfe6aa1a2e77e0ad9ec..0b2d5113cc8eb605108e03d0e43dd329b47485d4 100644 (file)
@@ -679,9 +679,7 @@ __indirect_glGetString(GLenum name)
     */
 
    (void) __glXFlushRenderBuffer(gc, gc->pc);
-   s = (GLubyte *) __glXGetStringFromServer(dpy, gc->majorOpcode,
-                                            X_GLsop_GetString,
-                                            gc->currentContextTag, name);
+   s = (GLubyte *) __glXGetString(dpy, gc->majorOpcode, gc->currentContextTag, name);
    if (!s) {
       /* Throw data on the floor */
       __glXSetError(gc, GL_OUT_OF_MEMORY);
index 1ddea33e35c2f008cafc0628b6b3d05685b6fddf..80746950c714aa898dfecbdc2f8819e2d3a4a880 100644 (file)
@@ -56,11 +56,13 @@ wmesa_free_framebuffer(HDC hdc)
        prev = pwfb;
     }
     if (pwfb) {
+        struct gl_framebuffer *fb;
        if (pwfb == FirstFramebuffer)
            FirstFramebuffer = pwfb->next;
        else
            prev->next = pwfb->next;
-        _mesa_unreference_framebuffer(&pwfb->Base);
+        fb = &pwfb->Base;
+        _mesa_unreference_framebuffer(&fb); 
     }
 }
 
@@ -1503,6 +1505,9 @@ WMesaContext WMesaCreateContext(HDC hDC,
     ctx = &c->gl_ctx;
     _mesa_initialize_context(ctx, visual, NULL, &functions, (void *)c);
 
+    /* visual no longer needed - it was copied by _mesa_initialize_context() */
+    _mesa_destroy_visual(visual);
+
     _mesa_enable_sw_extensions(ctx);
     _mesa_enable_1_3_extensions(ctx);
     _mesa_enable_1_4_extensions(ctx);
index 34c47413506c95f24d07e610c6ed01341e59da7b..88fca198351f772dcd3bbb2826be8625444518e8 100644 (file)
@@ -631,6 +631,9 @@ append(char *dst, const char *src)
 }
 
 
+/**
+ * Convert token 'k' to a string, append it only 'dst' string.
+ */
 static void
 append_token(char *dst, gl_state_index k)
 {
@@ -763,11 +766,30 @@ append_token(char *dst, gl_state_index k)
    case STATE_LOCAL:
       append(dst, "local");
       break;
+   /* BEGIN internal state vars */
+   case STATE_INTERNAL:
+      append(dst, "(internal)");
+      break;
    case STATE_NORMAL_SCALE:
       append(dst, "normalScale");
       break;
-   case STATE_INTERNAL:
-      append(dst, "(internal)");
+   case STATE_TEXRECT_SCALE:
+      append(dst, "texrectScale");
+      break;
+   case STATE_FOG_PARAMS_OPTIMIZED:
+      append(dst, "fogParamsOptimized");
+      break;
+   case STATE_LIGHT_SPOT_DIR_NORMALIZED:
+      append(dst, "lightSpotDirNormalized");
+      break;
+   case STATE_LIGHT_POSITION:
+      append(dst, "lightPosition");
+      break;
+   case STATE_LIGHT_POSITION_NORMALIZED:
+      append(dst, "light.position.normalized");
+      break;
+   case STATE_LIGHT_HALF_VECTOR:
+      append(dst, "lightHalfVector");
       break;
    case STATE_PT_SCALE:
       append(dst, "PTscale");
@@ -818,16 +840,16 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
    char tmp[30];
 
    append(str, "state.");
-   append_token(str, (gl_state_index) state[0]);
+   append_token(str, state[0]);
 
    switch (state[0]) {
    case STATE_MATERIAL:
       append_face(str, state[1]);
-      append_token(str, (gl_state_index) state[2]);
+      append_token(str, state[2]);
       break;
    case STATE_LIGHT:
       append_index(str, state[1]); /* light number [i]. */
-      append_token(str, (gl_state_index) state[2]); /* coefficients */
+      append_token(str, state[2]); /* coefficients */
       break;
    case STATE_LIGHTMODEL_AMBIENT:
       append(str, "lightmodel.ambient");
@@ -843,11 +865,11 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
    case STATE_LIGHTPROD:
       append_index(str, state[1]); /* light number [i]. */
       append_face(str, state[2]);
-      append_token(str, (gl_state_index) state[3]);
+      append_token(str, state[3]);
       break;
    case STATE_TEXGEN:
       append_index(str, state[1]); /* tex unit [i] */
-      append_token(str, (gl_state_index) state[2]); /* plane coef */
+      append_token(str, state[2]); /* plane coef */
       break;
    case STATE_TEXENV_COLOR:
       append_index(str, state[1]); /* tex unit [i] */
@@ -869,11 +891,11 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
          /* state[2] = first row to fetch */
          /* state[3] = last row to fetch */
          /* state[4] = transpose, inverse or invtrans */
-         const gl_state_index mat = (gl_state_index) state[0];
+         const gl_state_index mat = state[0];
          const GLuint index = (GLuint) state[1];
          const GLuint firstRow = (GLuint) state[2];
          const GLuint lastRow = (GLuint) state[3];
-         const gl_state_index modifier = (gl_state_index) state[4];
+         const gl_state_index modifier = state[4];
          if (index ||
              mat == STATE_TEXTURE_MATRIX ||
              mat == STATE_PROGRAM_MATRIX)
@@ -901,10 +923,11 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
    case STATE_VERTEX_PROGRAM:
       /* state[1] = {STATE_ENV, STATE_LOCAL} */
       /* state[2] = parameter index          */
-      append_token(str, (gl_state_index) state[1]);
+      append_token(str, state[1]);
       append_index(str, state[2]);
       break;
    case STATE_INTERNAL:
+      append_token(str, state[1]);
       break;
    default:
       _mesa_problem(NULL, "Invalid state in _mesa_program_state_string");
index 8d2655ec517c52f2f88fff48973a1a4b9ed05fd4..8abb642a728bf82752780b2d292217d366b61faf 100644 (file)
@@ -2028,6 +2028,21 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
       return NULL;
    }
 
+   /* type checking to be sure function's return type matches 'dest' type */
+   if (dest) {
+      slang_typeinfo t0;
+
+      slang_typeinfo_construct(&t0);
+      _slang_typeof_operation(A, dest, &t0);
+
+      if (!slang_type_specifier_equal(&t0.spec, &fun->header.type.specifier)) {
+         slang_info_log_error(A->log,
+                              "Incompatible type returned by call to '%s'",
+                              name);
+         return NULL;
+      }
+   }
+
    n = _slang_gen_function_call(A, fun, oper, dest);
 
    if (n && !n->Store && !dest
index efae4e98fbefb456862dbd75b62f777ced440a4d..457a6b92c11c96798cd631f1896ce1cc5d790488 100644 (file)
@@ -1391,7 +1391,6 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O,
             RETURN0;
          break;
       case OP_METHOD:
-         printf("******* begin OP_METHOD\n");
          op->type = SLANG_OPER_METHOD;
          op->a_obj = parse_identifier(C);
          if (op->a_obj == SLANG_ATOM_NULL)
index f31e9b4e6c73916b998f5302c7decc087e74afdb..e3cb252a3d7f01de900ba55c31f9a3144317bfa3 100644 (file)
@@ -1324,7 +1324,8 @@ emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
        _slang_is_temp(emitInfo->vt, n->Children[1]->Store) &&
        (inst->DstReg.File == n->Children[1]->Store->File) &&
        (inst->DstReg.Index == n->Children[1]->Store->Index) &&
-       !n->Children[0]->Store->IsIndirect) {
+       !n->Children[0]->Store->IsIndirect &&
+       n->Children[0]->Store->Size <= 4) {
       /* Peephole optimization:
        * The Right-Hand-Side has its results in a temporary place.
        * Modify the RHS (and the prev instruction) to store its results