<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 28, 2014 at 2:17 PM, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 05/27/2014 08:28 PM, Matt Turner wrote:<br>
> On Tue, May 27, 2014 at 7:49 PM, Ian Romanick <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>> wrote:<br>
>> From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
>><br>
>> No change in the peak ir_variable memory usage in a trimmed apitrace of<br>
>> dota2 on 64-bit.<br>
>><br>
>> No change in the peak ir_variable memory usage in a trimmed apitrace of<br>
>> dota2 on 32-bit.<br>
>><br>
>> Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
>> ---<br>
>> src/glsl/ir.h | 5 +++--<br>
>> 1 file changed, 3 insertions(+), 2 deletions(-)<br>
>><br>
>> diff --git a/src/glsl/ir.h b/src/glsl/ir.h<br>
>> index 7faee74..bc02f6e 100644<br>
>> --- a/src/glsl/ir.h<br>
>> +++ b/src/glsl/ir.h<br>
>> @@ -92,12 +92,13 @@ enum ir_node_type {<br>
>> */<br>
>> class ir_instruction : public exec_node {<br>
>> private:<br>
>> - enum ir_node_type ir_type;<br>
>> + uint8_t ir_type;<br>
>><br>
>> public:<br>
>> inline enum ir_node_type get_ir_type() const<br>
>> {<br>
>> - return this->ir_type;<br>
>> + STATIC_ASSERT(ir_type_max < 256);<br>
>> + return (enum ir_node_type) this->ir_type;<br>
>> }<br>
>><br>
>> /**<br>
>> --<br>
>> 1.8.1.4<br>
><br>
> Instead of doing this, you can mark the enum type with the PACKED<br>
> attribute. I did this in a similar change in i965 already. See<br>
> <a href="http://lists.freedesktop.org/archives/mesa-dev/2014-February/054643.html" target="_blank">http://lists.freedesktop.org/archives/mesa-dev/2014-February/054643.html</a><br>
><br>
> This way we still get enum type checking and warnings out of switch<br>
> statements and such.<br>
<br>
Hmm... that would mean that patch 10 wouldn't strictly be necessary.<br>
The disadvantage is that the next patch would need (right?) some changes<br>
for MSVC, especially on 32-bit. I think it would need to be<br>
<br>
#if sizeof(ir_node_type) < sizeof(void *)<br></blockquote><div><br></div><div>I don't think the preprocessor can evaluate sizeof().</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
# define PADDING_BYTES (sizeof(void *) - sizeof(ir_node_type))<br>
#else<br>
# define PADDING_BYTES sizeof(void *)<br>
# if (__GNUC__ >= 3)<br>
# error "GCC did us wrong."<br>
# endif<br>
#endif<br>
<br>
uint8_t padding[PADDING_BYTES];<br>
<br>
Seems a little sketchy, but might still be better... hmm...<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>