summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/i965/brw_winsys.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/i965/brw_winsys.h')
-rw-r--r--src/gallium/drivers/i965/brw_winsys.h243
1 files changed, 243 insertions, 0 deletions
diff --git a/src/gallium/drivers/i965/brw_winsys.h b/src/gallium/drivers/i965/brw_winsys.h
new file mode 100644
index 00000000000..2142db5a4db
--- /dev/null
+++ b/src/gallium/drivers/i965/brw_winsys.h
@@ -0,0 +1,243 @@
+/**************************************************************************
+ *
+ * Copyright © 2009 Jakob Bornecrantz
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef BRW_WINSYS_H
+#define BRW_WINSYS_H
+
+#include "pipe/p_compiler.h"
+
+struct brw_winsys;
+struct pipe_fence_handle;
+
+/* This currently just wraps dri_bo:
+ */
+struct brw_winsys_buffer {
+ struct brw_winsys_screen *sws;
+ void *bo;
+ unsigned offset;
+};
+
+enum brw_buffer_usage {
+ I915_GEM_DOMAIN_RENDER,
+ I915_GEM_DOMAIN_SAMPLER,
+ I915_GEM_DOMAIN_VERTEX,
+ I915_GEM_DOMAIN_INSTRUCTION,
+
+
+ /* XXX: migrate from domains to explicit usage cases, eg below:
+ */
+
+ /* use on textures */
+ BRW_USAGE_RENDER = 0x01,
+ BRW_USAGE_SAMPLER = 0x02,
+ BRW_USAGE_2D_TARGET = 0x04,
+ BRW_USAGE_2D_SOURCE = 0x08,
+ /* use on vertex */
+ BRW_USAGE_VERTEX = 0x10,
+};
+
+enum brw_buffer_type
+{
+ BRW_BUFFER_TYPE_TEXTURE,
+ BRW_BUFFER_TYPE_SCANOUT, /**< a texture used for scanning out from */
+ BRW_BUFFER_TYPE_VERTEX,
+};
+
+
+/* AKA winsys context:
+ */
+struct brw_batchbuffer {
+
+ struct brw_winsys *iws;
+ struct brw_winsys_buffer *buf;
+
+ /**
+ * Values exported to speed up the writing the batchbuffer,
+ * instead of having to go trough a accesor function for
+ * each dword written.
+ */
+ /*{@*/
+ uint8_t *map;
+ uint8_t *ptr;
+ size_t size;
+
+ size_t relocs;
+ size_t max_relocs;
+ /*@}*/
+};
+
+struct brw_winsys_screen {
+
+ /**
+ * Batchbuffer functions.
+ */
+ /*@{*/
+ /**
+ * Create a new batchbuffer.
+ */
+ struct brw_batchbuffer *(*batchbuffer_create)(struct brw_winsys_screen *iws);
+
+ /**
+ * Emit a relocation to a buffer.
+ * Target position in batchbuffer is the same as ptr.
+ */
+ int (*batchbuffer_reloc)(struct brw_batchbuffer *batch,
+ unsigned offset,
+ struct brw_winsys_buffer *reloc,
+ unsigned pre_add,
+ enum brw_buffer_usage usage);
+
+ /**
+ * Flush a bufferbatch.
+ */
+ void (*batchbuffer_flush)(struct brw_batchbuffer *batch,
+ struct pipe_fence_handle **fence);
+
+ /**
+ * Destroy a batchbuffer.
+ */
+ void (*batchbuffer_destroy)(struct brw_batchbuffer *batch);
+ /*@}*/
+
+
+ /**
+ * Buffer functions.
+ */
+ /*@{*/
+ /**
+ * Create a buffer.
+ */
+ struct brw_winsys_buffer *(*buffer_create)(struct brw_winsys *iws,
+ unsigned size,
+ unsigned alignment,
+ enum brw_buffer_type type);
+
+
+ /* Reference and unreference buffers:
+ */
+ void (*bo_reference)( struct brw_winsys_buffer *buffer );
+ void (*bo_unreference)( struct brw_winsys_buffer *buffer );
+ void (*bo_emit_reloc)( struct brw_winsys_buffer *buffer,
+ unsigned domain,
+ unsigned a,
+ unsigned b,
+ unsigned offset,
+ struct brw_winsys_buffer *b2);
+
+ /**
+ * Map a buffer.
+ */
+ void *(*buffer_map)(struct brw_winsys *iws,
+ struct brw_winsys_buffer *buffer,
+ boolean write);
+
+ /**
+ * Unmap a buffer.
+ */
+ void (*buffer_unmap)(struct brw_winsys *iws,
+ struct brw_winsys_buffer *buffer);
+
+ /**
+ * Write to a buffer.
+ *
+ * Arguments follows pipe_buffer_write.
+ */
+ int (*buffer_write)(struct brw_winsys *iws,
+ struct brw_winsys_buffer *dst,
+ size_t offset,
+ size_t size,
+ const void *data);
+
+ void (*buffer_destroy)(struct brw_winsys *iws,
+ struct brw_winsys_buffer *buffer);
+ /*@}*/
+
+
+ /**
+ * Fence functions.
+ */
+ /*@{*/
+ /**
+ * Reference fence and set ptr to fence.
+ */
+ void (*fence_reference)(struct brw_winsys *iws,
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *fence);
+
+ /**
+ * Check if a fence has finished.
+ */
+ int (*fence_signalled)(struct brw_winsys *iws,
+ struct pipe_fence_handle *fence);
+
+ /**
+ * Wait on a fence to finish.
+ */
+ int (*fence_finish)(struct brw_winsys *iws,
+ struct pipe_fence_handle *fence);
+ /*@}*/
+
+
+ /**
+ * Destroy the winsys.
+ */
+ void (*destroy)(struct brw_winsys *iws);
+};
+
+
+/**
+ * Create i915 pipe_screen.
+ */
+struct pipe_screen *i915_create_screen(struct brw_winsys *iws, unsigned pci_id);
+
+/**
+ * Create a i915 pipe_context.
+ */
+struct pipe_context *i915_create_context(struct pipe_screen *screen);
+
+/**
+ * Get the brw_winsys buffer backing the texture.
+ *
+ * TODO UGLY
+ */
+struct pipe_texture;
+boolean i915_get_texture_buffer_brw(struct pipe_texture *texture,
+ struct brw_winsys_buffer **buffer,
+ unsigned *stride);
+
+/**
+ * Wrap a brw_winsys buffer with a texture blanket.
+ *
+ * TODO UGLY
+ */
+struct pipe_texture * i915_texture_blanket_brw(struct pipe_screen *screen,
+ struct pipe_texture *tmplt,
+ unsigned pitch,
+ struct brw_winsys_buffer *buffer);
+
+
+
+
+#endif