void 
intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, unsigned int x)
{
    assert(intel_batchbuffer_space(batch) >= 4);
    *(unsigned int *)batch->ptr = x;
    batch->ptr += 4;
}
void 
intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
                                   unsigned int size)
{
    assert(size < batch->size - 8);

    if (intel_batchbuffer_space(batch) < size) {
        intel_batchbuffer_flush(batch);
    }
}
void
intel_batchbuffer_align(struct intel_batchbuffer *batch, unsigned int alignedment)
{
    int used = batch->ptr - batch->map;
    int pad_size;

    assert((alignedment & 3) == 0);
    pad_size = ALIGN(used, alignedment) - used;
    assert((pad_size & 3) == 0);
    assert(intel_batchbuffer_space(batch) >= pad_size);

    while (pad_size >= 4) {
        intel_batchbuffer_emit_dword(batch, 0);
        pad_size -= 4;
    }
}
Beispiel #4
0
GLuint *
intelExtendInlinePrimitive(struct intel_context *intel, GLuint dwords)
{
   GLuint sz = dwords * sizeof(GLuint);
   GLuint *ptr;

   assert(intel->prim.flush == intel_flush_inline_primitive);

   if (intel_batchbuffer_space(intel->batch) < sz)
      intelWrapInlinePrimitive(intel);

/*    _mesa_printf("."); */

   intel->vtbl.assert_not_dirty(intel);

   ptr = (GLuint *) intel->batch->ptr;
   intel->batch->ptr += sz;

   return ptr;
}
Beispiel #5
0
/* Emit a primitive referencing vertices in a vertex buffer.
 */
void
intelStartInlinePrimitive(struct intel_context *intel,
                          GLuint prim, GLuint batch_flags)
{
   BATCH_LOCALS;

   intel->vtbl.emit_state(intel);

   /* Need to make sure at the very least that we don't wrap
    * batchbuffers in BEGIN_BATCH below, otherwise the primitive will
    * be emitted to a batchbuffer missing the required full-state
    * preamble.
    */
   if (intel_batchbuffer_space(intel->batch) < 100) {
      intel_batchbuffer_flush(intel->batch);
      intel->vtbl.emit_state(intel);
   }

/*    _mesa_printf("%s *", __progname); */

   intel_wait_flips(intel, batch_flags);

   /* Emit a slot which will be filled with the inline primitive
    * command later.
    */
   BEGIN_BATCH(2, batch_flags);
   OUT_BATCH(0);

   intel->prim.start_ptr = intel->batch->ptr;
   intel->prim.primitive = prim;
   intel->prim.flush = intel_flush_inline_primitive;

   OUT_BATCH(0);
   ADVANCE_BATCH();

/*    _mesa_printf(">"); */
}
int
intel_batchbuffer_check_free_space(struct intel_batchbuffer *batch, int size)
{
    return intel_batchbuffer_space(batch) >= size;
}