<div dir="ltr">On 18 August 2013 10:30, Mark Mueller <span dir="ltr"><<a href="mailto:markkmueller@gmail.com" target="_blank">markkmueller@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">When the time comes, are there any concerns with using a 64 bit type, like portability? 64 bits for flags would be useful for something that I'm looking into and I'm curious how much pain that could cause.</div>
</blockquote><div><br></div><div>We already use 64-bit bitfields in several places in Mesa--search src/mesa/main/mtypes.h for GLbitfield64 for some examples.</div><div><br></div><div>We also have the macros BITFIELD64_BIT(), BITFIELD64_MASK(), and BITFIELD64_RANGE() to make sure that the appropriate types are used for intermediate computations. For example:</div>
<div><br></div><div>my_bitfield |= 1 << 33;</div><div><br></div><div>Is unsafe because 1 and 33 are 32-bit immediate values, so 1 << 33 is computed using 32-bit math. Whereas:</div><div><br></div><div>my_bitfield |= BITFIELD64_BIT(33);</div>
<div><br></div><div>does the right thing.</div><div><br></div><div>As far as portability goes, it's not really a big issue in the i965 back-end since i965 graphics only exists on die with x86 :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Sun, Aug 18, 2013 at 10:58 AM, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div>On 08/18/2013 09:34 AM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
We are getting close to the maximum number of BRW_NEW_* bits that can<br>
be stored in brw->state.dirty.brw without overflowing 32 bits, and<br>
geometry shaders are going to add more. Add a STATIC_ASSERT so that<br>
we will be alerted when we need to switch to 64 bits.<br>
</blockquote>
<br></div>
Good call.<br>
<br>
Reviewed-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><div><div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
src/mesa/drivers/dri/i965/brw_<u></u>context.c | 5 +++++<br>
src/mesa/drivers/dri/i965/brw_<u></u>context.h | 1 +<br>
2 files changed, 6 insertions(+)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_context.c b/src/mesa/drivers/dri/i965/<u></u>brw_context.c<br>
index 11d438b..44a35d1 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_context.c<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_context.c<br>
@@ -448,6 +448,11 @@ brwCreateContext(int api,<br>
brw->state.dirty.mesa = ~0;<br>
brw->state.dirty.brw = ~0;<br>
<br>
+ /* Make sure that brw->state.dirty.brw has enough bits to hold all possible<br>
+ * dirty flags.<br>
+ */<br>
+ STATIC_ASSERT(BRW_NUM_STATE_<u></u>BITS <= 8 * sizeof(brw->state.dirty.brw));<br>
+<br>
brw->emit_state_always = 0;<br>
<br>
brw->batch.need_workaround_<u></u>flush = true;<br>
diff --git a/src/mesa/drivers/dri/i965/<u></u>brw_context.h b/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
index 74e38f1..dbad507 100644<br>
--- a/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/<u></u>brw_context.h<br>
@@ -155,6 +155,7 @@ enum brw_state_id {<br>
BRW_STATE_UNIFORM_BUFFER,<br>
BRW_STATE_META_IN_PROGRESS,<br>
BRW_STATE_INTERPOLATION_MAP,<br>
+ BRW_NUM_STATE_BITS<br>
};<br>
<br>
#define BRW_NEW_URB_FENCE (1 << BRW_STATE_URB_FENCE)<br>
<br>
</blockquote>
<br></div></div></div></div><div><div>
______________________________<u></u>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div>
</blockquote></div><br></div></div>