mesa: drop unneeded assert
[mesa.git] / src / mesa / main / uniform_query.cpp
index b9b9ff23ffa59657e9ab828fb5f2320ded12aa38..3108d348d6fa90f88137c97cae6ef1419a331504 100644 (file)
@@ -35,7 +35,6 @@
 #include "compiler/glsl/ir_uniform.h"
 #include "compiler/glsl/glsl_parser_extras.h"
 #include "compiler/glsl/program.h"
-#include "program/hash_table.h"
 #include "util/bitscan.h"
 
 
@@ -180,10 +179,10 @@ validate_uniform_parameters(struct gl_context *ctx,
 
    /* Check that the given location is in bounds of uniform remap table.
     * Unlinked programs will have NumUniformRemapTable == 0, so we can take
-    * the shProg->LinkStatus check out of the main path.
+    * the shProg->data->LinkStatus check out of the main path.
     */
    if (unlikely(location >= (GLint) shProg->NumUniformRemapTable)) {
-      if (!shProg->LinkStatus)
+      if (!shProg->data->LinkStatus)
          _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
                      caller);
       else
@@ -194,7 +193,7 @@ validate_uniform_parameters(struct gl_context *ctx,
    }
 
    if (location == -1) {
-      if (!shProg->LinkStatus)
+      if (!shProg->data->LinkStatus)
          _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
                      caller);
 
@@ -382,9 +381,12 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
               case GLSL_TYPE_BOOL:
                  dst[didx].f = src[sidx].i ? 1.0f : 0.0f;
                  break;
-              case GLSL_TYPE_DOUBLE:
-                 dst[didx].f = *(double *)&src[sidx].f;
+               case GLSL_TYPE_DOUBLE: {
+                  double tmp;
+                  memcpy(&tmp, &src[sidx].f, sizeof(tmp));
+                  dst[didx].f = tmp;
                  break;
+               }
               default:
                  assert(!"Should not get here.");
                  break;
@@ -392,20 +394,28 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
               break;
            case GLSL_TYPE_DOUBLE:
               switch (uni->type->base_type) {
-              case GLSL_TYPE_UINT:
-                 *(double *)&dst[didx].f = (double) src[sidx].u;
+               case GLSL_TYPE_UINT: {
+                  double tmp = src[sidx].u;
+                  memcpy(&dst[didx].f, &tmp, sizeof(tmp));
                  break;
+               }
               case GLSL_TYPE_INT:
               case GLSL_TYPE_SAMPLER:
-              case GLSL_TYPE_IMAGE:
-                 *(double *)&dst[didx].f = (double) src[sidx].i;
+               case GLSL_TYPE_IMAGE: {
+                  double tmp = src[sidx].i;
+                  memcpy(&dst[didx].f, &tmp, sizeof(tmp));
                  break;
-              case GLSL_TYPE_BOOL:
-                 *(double *)&dst[didx].f = src[sidx].i ? 1.0f : 0.0f;
+               }
+               case GLSL_TYPE_BOOL: {
+                  double tmp = src[sidx].i ? 1.0 : 0.0;
+                  memcpy(&dst[didx].f, &tmp, sizeof(tmp));
                  break;
-              case GLSL_TYPE_FLOAT:
-                 *(double *)&dst[didx].f = (double) src[sidx].f;
+               }
+               case GLSL_TYPE_FLOAT: {
+                  double tmp = src[sidx].f;
+                  memcpy(&dst[didx].f, &tmp, sizeof(tmp));
                  break;
+               }
               default:
                  assert(!"Should not get here.");
                  break;
@@ -437,9 +447,12 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
               case GLSL_TYPE_BOOL:
                  dst[didx].i = src[sidx].i ? 1 : 0;
                  break;
-              case GLSL_TYPE_DOUBLE:
-                 dst[didx].i = IROUNDD(*(double *)&src[sidx].f);
+               case GLSL_TYPE_DOUBLE: {
+                  double tmp;
+                  memcpy(&tmp, &src[sidx].f, sizeof(tmp));
+                  dst[didx].i = IROUNDD(tmp);
                  break;
+               }
               default:
                  assert(!"Should not get here.");
                  break;
@@ -486,9 +499,12 @@ log_uniform(const void *values, enum glsl_base_type basicType,
       case GLSL_TYPE_FLOAT:
         printf("%g ", v[i].f);
         break;
-      case GLSL_TYPE_DOUBLE:
-         printf("%g ", *(double* )&v[i * 2].f);
+      case GLSL_TYPE_DOUBLE: {
+         double tmp;
+         memcpy(&tmp, &v[i * 2].f, sizeof(tmp));
+         printf("%g ", tmp);
          break;
+      }
       default:
         assert(!"Should not get here.");
         break;
@@ -1052,7 +1068,7 @@ _mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg,
                                 char *errMsg, size_t errMsgLength)
 {
    /* Shader does not have samplers. */
-   if (shProg->NumUniformStorage == 0)
+   if (shProg->data->NumUniformStorage == 0)
       return true;
 
    if (!shProg->SamplersValidated) {