14a49301eSmrg/**************************************************************************
24a49301eSmrg *
3af69d88dSmrg * Copyright 2008 VMware, Inc.
44a49301eSmrg * All Rights Reserved.
54a49301eSmrg *
64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a
74a49301eSmrg * copy of this software and associated documentation files (the
84a49301eSmrg * "Software"), to deal in the Software without restriction, including
94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish,
104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to
114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to
124a49301eSmrg * the following conditions:
134a49301eSmrg *
144a49301eSmrg * The above copyright notice and this permission notice (including the
154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions
164a49301eSmrg * of the Software.
174a49301eSmrg *
184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
254a49301eSmrg *
264a49301eSmrg **************************************************************************/
274a49301eSmrg
284a49301eSmrg/**
294a49301eSmrg * @file
304a49301eSmrg * Buffer validation.
314a49301eSmrg *
32af69d88dSmrg * @author Jose Fonseca <jfonseca@vmware.com>
334a49301eSmrg */
344a49301eSmrg
354a49301eSmrg#ifndef PB_VALIDATE_H_
364a49301eSmrg#define PB_VALIDATE_H_
374a49301eSmrg
384a49301eSmrg
394a49301eSmrg#include "pipe/p_compiler.h"
404a49301eSmrg#include "pipe/p_defines.h"
414a49301eSmrg
424a49301eSmrg#ifdef __cplusplus
434a49301eSmrgextern "C" {
444a49301eSmrg#endif
454a49301eSmrg
464a49301eSmrg
474a49301eSmrgstruct pb_buffer;
484a49301eSmrgstruct pipe_fence_handle;
497ec681f3Smrgstruct hash_table;
504a49301eSmrg
514a49301eSmrg
524a49301eSmrg/**
534a49301eSmrg * Buffer validation list.
544a49301eSmrg *
554a49301eSmrg * It holds a list of buffers to be validated and fenced when flushing.
564a49301eSmrg */
574a49301eSmrgstruct pb_validate;
584a49301eSmrg
594a49301eSmrg
604a49301eSmrgenum pipe_error
614a49301eSmrgpb_validate_add_buffer(struct pb_validate *vl,
624a49301eSmrg                       struct pb_buffer *buf,
637ec681f3Smrg                       enum pb_usage_flags flags,
647ec681f3Smrg                       struct hash_table *ht,
657ec681f3Smrg                       boolean *already_present);
664a49301eSmrg
674a49301eSmrgenum pipe_error
684a49301eSmrgpb_validate_foreach(struct pb_validate *vl,
694a49301eSmrg                    enum pipe_error (*callback)(struct pb_buffer *buf, void *data),
704a49301eSmrg                    void *data);
714a49301eSmrg
724a49301eSmrg/**
734a49301eSmrg * Validate all buffers for hardware access.
744a49301eSmrg *
754a49301eSmrg * Should be called right before issuing commands to the hardware.
764a49301eSmrg */
774a49301eSmrgenum pipe_error
784a49301eSmrgpb_validate_validate(struct pb_validate *vl);
794a49301eSmrg
804a49301eSmrg/**
814a49301eSmrg * Fence all buffers and clear the list.
824a49301eSmrg *
834a49301eSmrg * Should be called right after issuing commands to the hardware.
844a49301eSmrg */
854a49301eSmrgvoid
864a49301eSmrgpb_validate_fence(struct pb_validate *vl,
874a49301eSmrg                  struct pipe_fence_handle *fence);
884a49301eSmrg
894a49301eSmrgstruct pb_validate *
904a49301eSmrgpb_validate_create(void);
914a49301eSmrg
924a49301eSmrgvoid
934a49301eSmrgpb_validate_destroy(struct pb_validate *vl);
944a49301eSmrg
954a49301eSmrg
964a49301eSmrg#ifdef __cplusplus
974a49301eSmrg}
984a49301eSmrg#endif
994a49301eSmrg
1004a49301eSmrg#endif /*PB_VALIDATE_H_*/
101