glsl: Fix MSVC build.
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 28 May 2013 12:56:18 +0000 (13:56 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 28 May 2013 12:56:18 +0000 (13:56 +0100)
It appears that `sizeof(Class::member)` is either non-standard or
merely unsupported in MSVC.

So use `sizeof(instance->member)` instead, which is guaranteed to work
everywhere.

Also promote the assert to a static assert.

Trivial.

src/glsl/link_uniforms.cpp

index 04218be7ac96911bbd65830c7816890f0a03a6cd..ad636681f8e1e21b87c7fabc7116db3eaf539f65 100644 (file)
@@ -653,7 +653,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
        *     types cannot have initializers."
        */
       memset(prog->_LinkedShaders[i]->SamplerUnits, 0,
-             sizeof(gl_shader::SamplerUnits));
+             sizeof(prog->_LinkedShaders[i]->SamplerUnits));
 
       link_update_uniform_buffer_variables(prog->_LinkedShaders[i]);
 
@@ -724,9 +724,9 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
       prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used;
       prog->_LinkedShaders[i]->shadow_samplers = parcel.shader_shadow_samplers;
 
-      assert(sizeof(gl_shader::SamplerTargets) == sizeof(parcel.targets));
+      STATIC_ASSERT(sizeof(prog->_LinkedShaders[i]->SamplerTargets) == sizeof(parcel.targets));
       memcpy(prog->_LinkedShaders[i]->SamplerTargets, parcel.targets,
-             sizeof(gl_shader::SamplerTargets));
+             sizeof(prog->_LinkedShaders[i]->SamplerTargets));
    }
 
 #ifndef NDEBUG