Path: blob/21.2-virgl/src/gallium/drivers/i915/i915_batchbuffer.h
4570 views
/**************************************************************************1*2* Copyright 2007 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef I915_BATCHBUFFER_H28#define I915_BATCHBUFFER_H2930#include "util/u_debug.h"31#include "i915_winsys.h"3233struct i915_context;3435static inline size_t36i915_winsys_batchbuffer_space(struct i915_winsys_batchbuffer *batch)37{38return batch->size - (batch->ptr - batch->map);39}4041static inline bool42i915_winsys_batchbuffer_check(struct i915_winsys_batchbuffer *batch,43size_t dwords)44{45return dwords * 4 <= i915_winsys_batchbuffer_space(batch);46}4748static inline void49i915_winsys_batchbuffer_dword_unchecked(struct i915_winsys_batchbuffer *batch,50unsigned dword)51{52*(unsigned *)batch->ptr = dword;53batch->ptr += 4;54}5556static inline void57i915_winsys_batchbuffer_float(struct i915_winsys_batchbuffer *batch, float f)58{59union {60float f;61unsigned int ui;62} uif;63uif.f = f;64assert(i915_winsys_batchbuffer_space(batch) >= 4);65i915_winsys_batchbuffer_dword_unchecked(batch, uif.ui);66}6768static inline void69i915_winsys_batchbuffer_dword(struct i915_winsys_batchbuffer *batch,70unsigned dword)71{72assert(i915_winsys_batchbuffer_space(batch) >= 4);73i915_winsys_batchbuffer_dword_unchecked(batch, dword);74}7576static inline void77i915_winsys_batchbuffer_write(struct i915_winsys_batchbuffer *batch, void *data,78size_t size)79{80assert(i915_winsys_batchbuffer_space(batch) >= size);8182memcpy(batch->ptr, data, size);83batch->ptr += size;84}8586static inline bool87i915_winsys_validate_buffers(struct i915_winsys_batchbuffer *batch,88struct i915_winsys_buffer **buffers,89int num_of_buffers)90{91return batch->iws->validate_buffers(batch, buffers, num_of_buffers);92}9394static inline int95i915_winsys_batchbuffer_reloc(struct i915_winsys_batchbuffer *batch,96struct i915_winsys_buffer *buffer,97enum i915_winsys_buffer_usage usage,98size_t offset, bool fenced)99{100return batch->iws->batchbuffer_reloc(batch, buffer, usage, offset, fenced);101}102103#endif104105106