diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.h b/src/gallium/auxiliary/cso_cache/cso_cache.h index 052245f..90d9e9d 100644 --- a/src/gallium/auxiliary/cso_cache/cso_cache.h +++ b/src/gallium/auxiliary/cso_cache/cso_cache.h @@ -73,7 +73,6 @@ #ifndef CSO_CACHE_H #define CSO_CACHE_H -#include "pipe/p_context.h" #include "pipe/p_state.h" /* cso_hash.h is necessary for cso_hash_iter, as MSVC requires structures diff --git a/src/gallium/auxiliary/util/u_box.h b/src/gallium/auxiliary/util/u_box.h deleted file mode 100644 index 2fa6017..0000000 --- a/src/gallium/auxiliary/util/u_box.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef UTIL_BOX_INLINES_H -#define UTIL_BOX_INLINES_H - -#include "pipe/p_state.h" - -static inline -void u_box_1d( unsigned x, - unsigned w, - struct pipe_box *box ) -{ - box->x = x; - box->y = 0; - box->z = 0; - box->width = w; - box->height = 1; - box->depth = 1; -} - -static inline -void u_box_2d( unsigned x, - unsigned y, - unsigned w, - unsigned h, - struct pipe_box *box ) -{ - box->x = x; - box->y = y; - box->z = 0; - box->width = w; - box->height = h; - box->depth = 1; -} - -static inline -void u_box_origin_2d( unsigned w, - unsigned h, - struct pipe_box *box ) -{ - box->x = 0; - box->y = 0; - box->z = 0; - box->width = w; - box->height = h; - box->depth = 1; -} - -static inline -void u_box_2d_zslice( unsigned x, - unsigned y, - unsigned z, - unsigned w, - unsigned h, - struct pipe_box *box ) -{ - box->x = x; - box->y = y; - box->z = z; - box->width = w; - box->height = h; - box->depth = 1; -} - -static inline -void u_box_3d( unsigned x, - unsigned y, - unsigned z, - unsigned w, - unsigned h, - unsigned d, - struct pipe_box *box ) -{ - box->x = x; - box->y = y; - box->z = z; - box->width = w; - box->height = h; - box->depth = d; -} - -#endif diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c index 16d4cbf..b7adfda 100644 --- a/src/gallium/auxiliary/util/u_format.c +++ b/src/gallium/auxiliary/util/u_format.c @@ -36,7 +36,6 @@ #include "u_memory.h" #include "u_format.h" #include "u_format_s3tc.h" -#include "u_surface.h" #include "pipe/p_defines.h" diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 5a27e28..8ee3319 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -28,16 +28,13 @@ #ifndef U_INLINES_H #define U_INLINES_H -#include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_shader_tokens.h" #include "pipe/p_state.h" -#include "pipe/p_screen.h" #include "util/u_debug.h" #include "util/u_debug_describe.h" #include "util/u_debug_refcnt.h" #include "util/u_atomic.h" -#include "util/u_box.h" #include "util/u_math.h" @@ -103,111 +100,6 @@ pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference) (debug_reference_descriptor)debug_describe_reference); } -static inline void -pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf) -{ - struct pipe_surface *old_surf = *ptr; - - if (pipe_reference_described(&(*ptr)->reference, &surf->reference, - (debug_reference_descriptor)debug_describe_surface)) - old_surf->context->surface_destroy(old_surf->context, old_surf); - *ptr = surf; -} - -/** - * Similar to pipe_surface_reference() but always set the pointer to NULL - * and pass in an explicit context. The explicit context avoids the problem - * of using a deleted context's surface_destroy() method when freeing a surface - * that's shared by multiple contexts. - */ -static inline void -pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr) -{ - if (pipe_reference_described(&(*ptr)->reference, NULL, - (debug_reference_descriptor)debug_describe_surface)) - pipe->surface_destroy(pipe, *ptr); - *ptr = NULL; -} - - -static inline void -pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex) -{ - struct pipe_resource *old_tex = *ptr; - - if (pipe_reference_described(&(*ptr)->reference, &tex->reference, - (debug_reference_descriptor)debug_describe_resource)) - old_tex->screen->resource_destroy(old_tex->screen, old_tex); - *ptr = tex; -} - -static inline void -pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_view *view) -{ - struct pipe_sampler_view *old_view = *ptr; - - if (pipe_reference_described(&(*ptr)->reference, &view->reference, - (debug_reference_descriptor)debug_describe_sampler_view)) - old_view->context->sampler_view_destroy(old_view->context, old_view); - *ptr = view; -} - -/** - * Similar to pipe_sampler_view_reference() but always set the pointer to - * NULL and pass in an explicit context. Passing an explicit context is a - * work-around for fixing a dangling context pointer problem when textures - * are shared by multiple contexts. XXX fix this someday. - */ -static inline void -pipe_sampler_view_release(struct pipe_context *ctx, - struct pipe_sampler_view **ptr) -{ - struct pipe_sampler_view *old_view = *ptr; - if (*ptr && (*ptr)->context != ctx) { - debug_printf_once(("context mis-match in pipe_sampler_view_release()\n")); - } - if (pipe_reference_described(&(*ptr)->reference, NULL, - (debug_reference_descriptor)debug_describe_sampler_view)) { - ctx->sampler_view_destroy(ctx, old_view); - } - *ptr = NULL; -} - - -static inline void -pipe_so_target_reference(struct pipe_stream_output_target **ptr, - struct pipe_stream_output_target *target) -{ - struct pipe_stream_output_target *old = *ptr; - - if (pipe_reference_described(&(*ptr)->reference, &target->reference, - (debug_reference_descriptor)debug_describe_so_target)) - old->context->stream_output_target_destroy(old->context, old); - *ptr = target; -} - -static inline void -pipe_surface_reset(struct pipe_context *ctx, struct pipe_surface* ps, - struct pipe_resource *pt, unsigned level, unsigned layer) -{ - pipe_resource_reference(&ps->texture, pt); - ps->format = pt->format; - ps->width = u_minify(pt->width0, level); - ps->height = u_minify(pt->height0, level); - ps->u.tex.level = level; - ps->u.tex.first_layer = ps->u.tex.last_layer = layer; - ps->context = ctx; -} - -static inline void -pipe_surface_init(struct pipe_context *ctx, struct pipe_surface* ps, - struct pipe_resource *pt, unsigned level, unsigned layer) -{ - ps->texture = 0; - pipe_reference_init(&ps->reference, 1); - pipe_surface_reset(ctx, ps, pt, level, layer); -} - /* Return true if the surfaces are equal. */ static inline boolean pipe_surface_equal(struct pipe_surface *s1, struct pipe_surface *s2) @@ -223,281 +115,6 @@ pipe_surface_equal(struct pipe_surface *s1, struct pipe_surface *s2) s1->u.tex.last_layer == s2->u.tex.last_layer)); } -/* - * Convenience wrappers for screen buffer functions. - */ - - -/** - * Create a new resource. - * \param bind bitmask of PIPE_BIND_x flags - * \param usage bitmask of PIPE_USAGE_x flags - */ -static inline struct pipe_resource * -pipe_buffer_create( struct pipe_screen *screen, - unsigned bind, - unsigned usage, - unsigned size ) -{ - struct pipe_resource buffer; - memset(&buffer, 0, sizeof buffer); - buffer.target = PIPE_BUFFER; - buffer.format = PIPE_FORMAT_R8_UNORM; /* want TYPELESS or similar */ - buffer.bind = bind; - buffer.usage = usage; - buffer.flags = 0; - buffer.width0 = size; - buffer.height0 = 1; - buffer.depth0 = 1; - buffer.array_size = 1; - return screen->resource_create(screen, &buffer); -} - - -/** - * Map a range of a resource. - * \param offset start of region, in bytes - * \param length size of region, in bytes - * \param access bitmask of PIPE_TRANSFER_x flags - * \param transfer returns a transfer object - */ -static inline void * -pipe_buffer_map_range(struct pipe_context *pipe, - struct pipe_resource *buffer, - unsigned offset, - unsigned length, - unsigned access, - struct pipe_transfer **transfer) -{ - struct pipe_box box; - void *map; - - assert(offset < buffer->width0); - assert(offset + length <= buffer->width0); - assert(length); - - u_box_1d(offset, length, &box); - - map = pipe->transfer_map(pipe, buffer, 0, access, &box, transfer); - if (map == NULL) { - return NULL; - } - - return map; -} - - -/** - * Map whole resource. - * \param access bitmask of PIPE_TRANSFER_x flags - * \param transfer returns a transfer object - */ -static inline void * -pipe_buffer_map(struct pipe_context *pipe, - struct pipe_resource *buffer, - unsigned access, - struct pipe_transfer **transfer) -{ - return pipe_buffer_map_range(pipe, buffer, 0, buffer->width0, access, transfer); -} - - -static inline void -pipe_buffer_unmap(struct pipe_context *pipe, - struct pipe_transfer *transfer) -{ - pipe->transfer_unmap(pipe, transfer); -} - -static inline void -pipe_buffer_flush_mapped_range(struct pipe_context *pipe, - struct pipe_transfer *transfer, - unsigned offset, - unsigned length) -{ - struct pipe_box box; - int transfer_offset; - - assert(length); - assert(transfer->box.x <= (int) offset); - assert((int) (offset + length) <= transfer->box.x + transfer->box.width); - - /* Match old screen->buffer_flush_mapped_range() behaviour, where - * offset parameter is relative to the start of the buffer, not the - * mapped range. - */ - transfer_offset = offset - transfer->box.x; - - u_box_1d(transfer_offset, length, &box); - - pipe->transfer_flush_region(pipe, transfer, &box); -} - -static inline void -pipe_buffer_write(struct pipe_context *pipe, - struct pipe_resource *buf, - unsigned offset, - unsigned size, - const void *data) -{ - struct pipe_box box; - unsigned access = PIPE_TRANSFER_WRITE; - - if (offset == 0 && size == buf->width0) { - access |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE; - } else { - access |= PIPE_TRANSFER_DISCARD_RANGE; - } - - u_box_1d(offset, size, &box); - - pipe->transfer_inline_write( pipe, - buf, - 0, - access, - &box, - data, - size, - 0); -} - -/** - * Special case for writing non-overlapping ranges. - * - * We can avoid GPU/CPU synchronization when writing range that has never - * been written before. - */ -static inline void -pipe_buffer_write_nooverlap(struct pipe_context *pipe, - struct pipe_resource *buf, - unsigned offset, unsigned size, - const void *data) -{ - struct pipe_box box; - - u_box_1d(offset, size, &box); - - pipe->transfer_inline_write(pipe, - buf, - 0, - (PIPE_TRANSFER_WRITE | - PIPE_TRANSFER_UNSYNCHRONIZED), - &box, - data, - 0, 0); -} - - -/** - * Create a new resource and immediately put data into it - * \param bind bitmask of PIPE_BIND_x flags - * \param usage bitmask of PIPE_USAGE_x flags - */ -static inline struct pipe_resource * -pipe_buffer_create_with_data(struct pipe_context *pipe, - unsigned bind, - unsigned usage, - unsigned size, - const void *ptr) -{ - struct pipe_resource *res = pipe_buffer_create(pipe->screen, - bind, usage, size); - pipe_buffer_write_nooverlap(pipe, res, 0, size, ptr); - return res; -} - -static inline void -pipe_buffer_read(struct pipe_context *pipe, - struct pipe_resource *buf, - unsigned offset, - unsigned size, - void *data) -{ - struct pipe_transfer *src_transfer; - ubyte *map; - - map = (ubyte *) pipe_buffer_map_range(pipe, - buf, - offset, size, - PIPE_TRANSFER_READ, - &src_transfer); - if (!map) - return; - - memcpy(data, map, size); - pipe_buffer_unmap(pipe, src_transfer); -} - - -/** - * Map a resource for reading/writing. - * \param access bitmask of PIPE_TRANSFER_x flags - */ -static inline void * -pipe_transfer_map(struct pipe_context *context, - struct pipe_resource *resource, - unsigned level, unsigned layer, - unsigned access, - unsigned x, unsigned y, - unsigned w, unsigned h, - struct pipe_transfer **transfer) -{ - struct pipe_box box; - u_box_2d_zslice(x, y, layer, w, h, &box); - return context->transfer_map(context, - resource, - level, - access, - &box, transfer); -} - - -/** - * Map a 3D (texture) resource for reading/writing. - * \param access bitmask of PIPE_TRANSFER_x flags - */ -static inline void * -pipe_transfer_map_3d(struct pipe_context *context, - struct pipe_resource *resource, - unsigned level, - unsigned access, - unsigned x, unsigned y, unsigned z, - unsigned w, unsigned h, unsigned d, - struct pipe_transfer **transfer) -{ - struct pipe_box box; - u_box_3d(x, y, z, w, h, d, &box); - return context->transfer_map(context, - resource, - level, - access, - &box, transfer); -} - -static inline void -pipe_transfer_unmap( struct pipe_context *context, - struct pipe_transfer *transfer ) -{ - context->transfer_unmap( context, transfer ); -} - -static inline void -pipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_resource *buf) -{ - if (buf) { - struct pipe_constant_buffer cb; - cb.buffer = buf; - cb.buffer_offset = 0; - cb.buffer_size = buf->width0; - cb.user_buffer = NULL; - pipe->set_constant_buffer(pipe, shader, index, &cb); - } else { - pipe->set_constant_buffer(pipe, shader, index, NULL); - } -} - - /** * Get the polygon offset enable/disable flag for the given polygon fill mode. * \param fill_mode one of PIPE_POLYGON_MODE_POINT/LINE/FILL @@ -602,24 +219,6 @@ util_pipe_tex_to_tgsi_tex(enum pipe_texture_target pipe_tex_target, } -static inline void -util_copy_constant_buffer(struct pipe_constant_buffer *dst, - const struct pipe_constant_buffer *src) -{ - if (src) { - pipe_resource_reference(&dst->buffer, src->buffer); - dst->buffer_offset = src->buffer_offset; - dst->buffer_size = src->buffer_size; - dst->user_buffer = src->user_buffer; - } - else { - pipe_resource_reference(&dst->buffer, NULL); - dst->buffer_offset = 0; - dst->buffer_size = 0; - dst->user_buffer = NULL; - } -} - static inline unsigned util_max_layer(const struct pipe_resource *r, unsigned level) { diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h deleted file mode 100644 index 93e2d50..0000000 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 VMware, Inc. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * @file - * Functions to produce packed colors/Z from floats. - */ - - -#ifndef U_PACK_COLOR_H -#define U_PACK_COLOR_H - - -#include "pipe/p_compiler.h" -#include "pipe/p_format.h" -#include "util/u_debug.h" -#include "util/u_format.h" -#include "util/u_math.h" - - -/** - * Helper union for packing pixel values. - * Will often contain values in formats which are too complex to be described - * in simple terms, hence might just effectively contain a number of bytes. - * Must be big enough to hold data for all formats (currently 256 bits). - */ -union util_color { - ubyte ub; - ushort us; - uint ui[4]; - ushort h[4]; /* half float */ - float f[4]; - double d[4]; -}; - -/** - * Pack 4 ubytes into a 4-byte word - */ -static inline unsigned -pack_ub4(ubyte b0, ubyte b1, ubyte b2, ubyte b3) -{ - return ((((unsigned int)b0) << 0) | - (((unsigned int)b1) << 8) | - (((unsigned int)b2) << 16) | - (((unsigned int)b3) << 24)); -} - - -/** - * Pack/convert 4 floats into one 4-byte word. - */ -static inline unsigned -pack_ui32_float4(float a, float b, float c, float d) -{ - return pack_ub4( float_to_ubyte(a), - float_to_ubyte(b), - float_to_ubyte(c), - float_to_ubyte(d) ); -} - - - -#endif /* U_PACK_COLOR_H */ diff --git a/src/gallium/auxiliary/util/u_rect.h b/src/gallium/auxiliary/util/u_rect.h deleted file mode 100644 index b26f671..0000000 --- a/src/gallium/auxiliary/util/u_rect.h +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 VMware, Inc. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 U_RECT_H -#define U_RECT_H - -#include "pipe/p_compiler.h" -#include "util/u_math.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct u_rect { - int x0, x1; - int y0, y1; -}; - -/* Do two rectangles intersect? - */ -static inline boolean -u_rect_test_intersection(const struct u_rect *a, - const struct u_rect *b) -{ - return (!(a->x1 < b->x0 || - b->x1 < a->x0 || - a->y1 < b->y0 || - b->y1 < a->y0)); -} - -/* Find the intersection of two rectangles known to intersect. - */ -static inline void -u_rect_find_intersection(const struct u_rect *a, - struct u_rect *b) -{ - /* Caller should verify intersection exists before calling. - */ - if (b->x0 < a->x0) b->x0 = a->x0; - if (b->x1 > a->x1) b->x1 = a->x1; - if (b->y0 < a->y0) b->y0 = a->y0; - if (b->y1 > a->y1) b->y1 = a->y1; -} - - -static inline int -u_rect_area(const struct u_rect *r) -{ - return (r->x1 - r->x0) * (r->y1 - r->y0); -} - -static inline void -u_rect_possible_intersection(const struct u_rect *a, - struct u_rect *b) -{ - if (u_rect_test_intersection(a,b)) { - u_rect_find_intersection(a,b); - } - else { - b->x0 = b->x1 = b->y0 = b->y1 = 0; - } -} - -/* Set @d to a rectangle that covers both @a and @b. - */ -static inline void -u_rect_union(struct u_rect *d, const struct u_rect *a, const struct u_rect *b) -{ - d->x0 = MIN2(a->x0, b->x0); - d->y0 = MIN2(a->y0, b->y0); - d->x1 = MAX2(a->x1, b->x1); - d->y1 = MAX2(a->y1, b->y1); -} - -#ifdef __cplusplus -} -#endif - -#endif /* U_RECT_H */ diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c deleted file mode 100644 index 3836c4c..0000000 --- a/src/gallium/auxiliary/util/u_surface.c +++ /dev/null @@ -1,462 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * @file - * Surface utility functions. - * - * @author Brian Paul - */ - - -#include "pipe/p_defines.h" -#include "pipe/p_screen.h" -#include "pipe/p_state.h" - -#include "util/u_format.h" -#include "util/u_inlines.h" -#include "util/u_rect.h" -#include "util/u_surface.h" -#include "util/u_pack_color.h" - - -/** - * Initialize a pipe_surface object. 'view' is considered to have - * uninitialized contents. - */ -void -u_surface_default_template(struct pipe_surface *surf, - const struct pipe_resource *texture) -{ - memset(surf, 0, sizeof(*surf)); - - surf->format = texture->format; -} - - -/** - * Copy 2D rect from one place to another. - * Position and sizes are in pixels. - * src_stride may be negative to do vertical flip of pixels from source. - */ -void -util_copy_rect(ubyte * dst, - enum pipe_format format, - unsigned dst_stride, - unsigned dst_x, - unsigned dst_y, - unsigned width, - unsigned height, - const ubyte * src, - int src_stride, - unsigned src_x, - unsigned src_y) -{ - unsigned i; - int src_stride_pos = src_stride < 0 ? -src_stride : src_stride; - int blocksize = util_format_get_blocksize(format); - int blockwidth = util_format_get_blockwidth(format); - int blockheight = util_format_get_blockheight(format); - - assert(blocksize > 0); - assert(blockwidth > 0); - assert(blockheight > 0); - - dst_x /= blockwidth; - dst_y /= blockheight; - width = (width + blockwidth - 1)/blockwidth; - height = (height + blockheight - 1)/blockheight; - src_x /= blockwidth; - src_y /= blockheight; - - dst += dst_x * blocksize; - src += src_x * blocksize; - dst += dst_y * dst_stride; - src += src_y * src_stride_pos; - width *= blocksize; - - if (width == dst_stride && (int)width == src_stride) - memcpy(dst, src, height * width); - else { - for (i = 0; i < height; i++) { - memcpy(dst, src, width); - dst += dst_stride; - src += src_stride; - } - } -} - - -/** - * Copy 3D box from one place to another. - * Position and sizes are in pixels. - */ -void -util_copy_box(ubyte * dst, - enum pipe_format format, - unsigned dst_stride, unsigned dst_slice_stride, - unsigned dst_x, unsigned dst_y, unsigned dst_z, - unsigned width, unsigned height, unsigned depth, - const ubyte * src, - int src_stride, unsigned src_slice_stride, - unsigned src_x, unsigned src_y, unsigned src_z) -{ - unsigned z; - dst += dst_z * dst_slice_stride; - src += src_z * src_slice_stride; - for (z = 0; z < depth; ++z) { - util_copy_rect(dst, - format, - dst_stride, - dst_x, dst_y, - width, height, - src, - src_stride, - src_x, src_y); - - dst += dst_slice_stride; - src += src_slice_stride; - } -} - - -void -util_fill_rect(ubyte * dst, - enum pipe_format format, - unsigned dst_stride, - unsigned dst_x, - unsigned dst_y, - unsigned width, - unsigned height, - union util_color *uc) -{ - const struct util_format_description *desc = util_format_description(format); - unsigned i, j; - unsigned width_size; - int blocksize = desc->block.bits / 8; - int blockwidth = desc->block.width; - int blockheight = desc->block.height; - - assert(blocksize > 0); - assert(blockwidth > 0); - assert(blockheight > 0); - - dst_x /= blockwidth; - dst_y /= blockheight; - width = (width + blockwidth - 1)/blockwidth; - height = (height + blockheight - 1)/blockheight; - - dst += dst_x * blocksize; - dst += dst_y * dst_stride; - width_size = width * blocksize; - - switch (blocksize) { - case 1: - if(dst_stride == width_size) - memset(dst, uc->ub, height * width_size); - else { - for (i = 0; i < height; i++) { - memset(dst, uc->ub, width_size); - dst += dst_stride; - } - } - break; - case 2: - for (i = 0; i < height; i++) { - uint16_t *row = (uint16_t *)dst; - for (j = 0; j < width; j++) - *row++ = uc->us; - dst += dst_stride; - } - break; - case 4: - for (i = 0; i < height; i++) { - uint32_t *row = (uint32_t *)dst; - for (j = 0; j < width; j++) - *row++ = uc->ui[0]; - dst += dst_stride; - } - break; - default: - for (i = 0; i < height; i++) { - ubyte *row = dst; - for (j = 0; j < width; j++) { - memcpy(row, uc, blocksize); - row += blocksize; - } - dst += dst_stride; - } - break; - } -} - - -void -util_fill_box(ubyte * dst, - enum pipe_format format, - unsigned stride, - unsigned layer_stride, - unsigned x, - unsigned y, - unsigned z, - unsigned width, - unsigned height, - unsigned depth, - union util_color *uc) -{ - unsigned layer; - dst += z * layer_stride; - for (layer = z; layer < depth; layer++) { - util_fill_rect(dst, format, - stride, - x, y, width, height, uc); - dst += layer_stride; - } -} - - -/** - * Fallback function for pipe->resource_copy_region(). - * Note: (X,Y)=(0,0) is always the upper-left corner. - */ -void -util_resource_copy_region(struct pipe_context *pipe, - struct pipe_resource *dst, - unsigned dst_level, - unsigned dst_x, unsigned dst_y, unsigned dst_z, - struct pipe_resource *src, - unsigned src_level, - const struct pipe_box *src_box) -{ - struct pipe_transfer *src_trans, *dst_trans; - uint8_t *dst_map; - const uint8_t *src_map; - ASSERTED enum pipe_format src_format; - enum pipe_format dst_format; - struct pipe_box dst_box; - - assert(src && dst); - if (!src || !dst) - return; - - assert((src->target == PIPE_BUFFER && dst->target == PIPE_BUFFER) || - (src->target != PIPE_BUFFER && dst->target != PIPE_BUFFER)); - - src_format = src->format; - dst_format = dst->format; - - assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format)); - assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format)); - assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format)); - - src_map = pipe->transfer_map(pipe, - src, - src_level, - PIPE_TRANSFER_READ, - src_box, &src_trans); - assert(src_map); - if (!src_map) { - goto no_src_map; - } - - dst_box.x = dst_x; - dst_box.y = dst_y; - dst_box.z = dst_z; - dst_box.width = src_box->width; - dst_box.height = src_box->height; - dst_box.depth = src_box->depth; - - dst_map = pipe->transfer_map(pipe, - dst, - dst_level, - PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, - &dst_box, &dst_trans); - assert(dst_map); - if (!dst_map) { - goto no_dst_map; - } - - if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) { - assert(src_box->height == 1); - assert(src_box->depth == 1); - memcpy(dst_map, src_map, src_box->width); - } else { - util_copy_box(dst_map, - dst_format, - dst_trans->stride, dst_trans->layer_stride, - 0, 0, 0, - src_box->width, src_box->height, src_box->depth, - src_map, - src_trans->stride, src_trans->layer_stride, - 0, 0, 0); - } - - pipe->transfer_unmap(pipe, dst_trans); -no_dst_map: - pipe->transfer_unmap(pipe, src_trans); -no_src_map: - ; -} - - - -#define UBYTE_TO_USHORT(B) ((B) | ((B) << 8)) - - -/* Return if the box is totally inside the resource. - */ -static boolean -is_box_inside_resource(const struct pipe_resource *res, - const struct pipe_box *box, - unsigned level) -{ - unsigned width = 1, height = 1, depth = 1; - - switch (res->target) { - case PIPE_BUFFER: - width = res->width0; - height = 1; - depth = 1; - break; - case PIPE_TEXTURE_1D: - width = u_minify(res->width0, level); - height = 1; - depth = 1; - break; - case PIPE_TEXTURE_2D: - case PIPE_TEXTURE_RECT: - width = u_minify(res->width0, level); - height = u_minify(res->height0, level); - depth = 1; - break; - case PIPE_TEXTURE_3D: - width = u_minify(res->width0, level); - height = u_minify(res->height0, level); - depth = u_minify(res->depth0, level); - break; - case PIPE_TEXTURE_CUBE: - width = u_minify(res->width0, level); - height = u_minify(res->height0, level); - depth = 6; - break; - case PIPE_TEXTURE_1D_ARRAY: - width = u_minify(res->width0, level); - height = 1; - depth = res->array_size; - break; - case PIPE_TEXTURE_2D_ARRAY: - width = u_minify(res->width0, level); - height = u_minify(res->height0, level); - depth = res->array_size; - break; - case PIPE_TEXTURE_CUBE_ARRAY: - width = u_minify(res->width0, level); - height = u_minify(res->height0, level); - depth = res->array_size; - assert(res->array_size % 6 == 0); - break; - case PIPE_MAX_TEXTURE_TYPES:; - } - - return box->x >= 0 && - box->x + box->width <= (int) width && - box->y >= 0 && - box->y + box->height <= (int) height && - box->z >= 0 && - box->z + box->depth <= (int) depth; -} - -static unsigned -get_sample_count(const struct pipe_resource *res) -{ - return res->nr_samples ? res->nr_samples : 1; -} - -/** - * Try to do a blit using resource_copy_region. The function calls - * resource_copy_region if the blit description is compatible with it. - * - * It returns TRUE if the blit was done using resource_copy_region. - * - * It returns FALSE otherwise and the caller must fall back to a more generic - * codepath for the blit operation. (e.g. by using u_blitter) - */ -boolean -util_try_blit_via_copy_region(struct pipe_context *ctx, - const struct pipe_blit_info *blit) -{ - unsigned mask = util_format_get_mask(blit->dst.format); - - /* No format conversions. */ - if (blit->src.resource->format != blit->src.format || - blit->dst.resource->format != blit->dst.format || - !util_is_format_compatible( - util_format_description(blit->src.resource->format), - util_format_description(blit->dst.resource->format))) { - return FALSE; - } - - /* No masks, no filtering, no scissor. */ - if ((blit->mask & mask) != mask || - blit->filter != PIPE_TEX_FILTER_NEAREST || - blit->scissor_enable) { - return FALSE; - } - - /* No flipping. */ - if (blit->src.box.width < 0 || - blit->src.box.height < 0 || - blit->src.box.depth < 0) { - return FALSE; - } - - /* No scaling. */ - if (blit->src.box.width != blit->dst.box.width || - blit->src.box.height != blit->dst.box.height || - blit->src.box.depth != blit->dst.box.depth) { - return FALSE; - } - - /* No out-of-bounds access. */ - if (!is_box_inside_resource(blit->src.resource, &blit->src.box, - blit->src.level) || - !is_box_inside_resource(blit->dst.resource, &blit->dst.box, - blit->dst.level)) { - return FALSE; - } - - /* Sample counts must match. */ - if (get_sample_count(blit->src.resource) != - get_sample_count(blit->dst.resource)) { - return FALSE; - } - - ctx->resource_copy_region(ctx, blit->dst.resource, blit->dst.level, - blit->dst.box.x, blit->dst.box.y, blit->dst.box.z, - blit->src.resource, blit->src.level, - &blit->src.box); - return TRUE; -} diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h deleted file mode 100644 index bfd8f40..0000000 --- a/src/gallium/auxiliary/util/u_surface.h +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 U_SURFACE_H -#define U_SURFACE_H - - -#include "pipe/p_compiler.h" -#include "pipe/p_state.h" - -#include "util/u_pack_color.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -extern void -u_surface_default_template(struct pipe_surface *view, - const struct pipe_resource *texture); - -extern void -util_copy_rect(ubyte * dst, enum pipe_format format, - unsigned dst_stride, unsigned dst_x, unsigned dst_y, - unsigned width, unsigned height, const ubyte * src, - int src_stride, unsigned src_x, unsigned src_y); - -extern void -util_copy_box(ubyte * dst, - enum pipe_format format, - unsigned dst_stride, unsigned dst_slice_stride, - unsigned dst_x, unsigned dst_y, unsigned dst_z, - unsigned width, unsigned height, unsigned depth, - const ubyte * src, - int src_stride, unsigned src_slice_stride, - unsigned src_x, unsigned src_y, unsigned src_z); - -extern void -util_fill_rect(ubyte * dst, enum pipe_format format, - unsigned dst_stride, unsigned dst_x, unsigned dst_y, - unsigned width, unsigned height, union util_color *uc); - -extern void -util_fill_box(ubyte * dst, enum pipe_format format, - unsigned stride, unsigned layer_stride, - unsigned x, unsigned y, unsigned z, - unsigned width, unsigned height, unsigned depth, - union util_color *uc); - - -extern void -util_resource_copy_region(struct pipe_context *pipe, - struct pipe_resource *dst, - unsigned dst_level, - unsigned dst_x, unsigned dst_y, unsigned dst_z, - struct pipe_resource *src, - unsigned src_level, - const struct pipe_box *src_box); - -extern void -util_clear_render_target(struct pipe_context *pipe, - struct pipe_surface *dst, - const union pipe_color_union *color, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height); - -extern void -util_clear_depth_stencil(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned clear_flags, - double depth, - unsigned stencil, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height); - -extern boolean -util_try_blit_via_copy_region(struct pipe_context *ctx, - const struct pipe_blit_info *blit); - - -#ifdef __cplusplus -} -#endif - - -#endif /* U_SURFACE_H */ diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h deleted file mode 100644 index 0702729..0000000 --- a/src/gallium/include/pipe/p_context.h +++ /dev/null @@ -1,546 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 VMware, Inc. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 PIPE_CONTEXT_H -#define PIPE_CONTEXT_H - -#include "p_compiler.h" -#include "p_format.h" -#include "p_video_enums.h" -#include "p_defines.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -struct pipe_blend_color; -struct pipe_blend_state; -struct pipe_blit_info; -struct pipe_box; -struct pipe_clip_state; -struct pipe_constant_buffer; -struct pipe_depth_stencil_alpha_state; -struct pipe_draw_info; -struct pipe_fence_handle; -struct pipe_framebuffer_state; -struct pipe_index_buffer; -struct pipe_query; -struct pipe_poly_stipple; -struct pipe_rasterizer_state; -struct pipe_resolve_info; -struct pipe_resource; -struct pipe_sampler_state; -struct pipe_sampler_view; -struct pipe_scissor_state; -struct pipe_shader_state; -struct pipe_stencil_ref; -struct pipe_stream_output_target; -struct pipe_surface; -struct pipe_transfer; -struct pipe_vertex_buffer; -struct pipe_vertex_element; -struct pipe_video_buffer; -struct pipe_video_codec; -struct pipe_viewport_state; -struct pipe_compute_state; -union pipe_color_union; -union pipe_query_result; - -/** - * Gallium rendering context. Basically: - * - state setting functions - * - VBO drawing functions - * - surface functions - */ -struct pipe_context { - struct pipe_screen *screen; - - void *priv; /**< context private data (for DRI for example) */ - void *draw; /**< private, for draw module (temporary?) */ - - void (*destroy)( struct pipe_context * ); - - /** - * VBO drawing - */ - /*@{*/ - void (*draw_vbo)( struct pipe_context *pipe, - const struct pipe_draw_info *info ); - /*@}*/ - - /** - * Predicate subsequent rendering on occlusion query result - * \param query the query predicate, or NULL if no predicate - * \param condition whether to skip on FALSE or TRUE query results - * \param mode one of PIPE_RENDER_COND_x - */ - void (*render_condition)( struct pipe_context *pipe, - struct pipe_query *query, - boolean condition, - uint mode ); - - /** - * Query objects - */ - /*@{*/ - struct pipe_query *(*create_query)( struct pipe_context *pipe, - unsigned query_type ); - - void (*destroy_query)(struct pipe_context *pipe, - struct pipe_query *q); - - void (*begin_query)(struct pipe_context *pipe, struct pipe_query *q); - void (*end_query)(struct pipe_context *pipe, struct pipe_query *q); - - /** - * Get results of a query. - * \param wait if true, this query will block until the result is ready - * \return TRUE if results are ready, FALSE otherwise - */ - boolean (*get_query_result)(struct pipe_context *pipe, - struct pipe_query *q, - boolean wait, - union pipe_query_result *result); - /*@}*/ - - /** - * State functions (create/bind/destroy state objects) - */ - /*@{*/ - void * (*create_blend_state)(struct pipe_context *, - const struct pipe_blend_state *); - void (*bind_blend_state)(struct pipe_context *, void *); - void (*delete_blend_state)(struct pipe_context *, void *); - - void * (*create_sampler_state)(struct pipe_context *, - const struct pipe_sampler_state *); - void (*bind_sampler_states)(struct pipe_context *, - unsigned shader, unsigned start_slot, - unsigned num_samplers, void **samplers); - void (*delete_sampler_state)(struct pipe_context *, void *); - - void * (*create_rasterizer_state)(struct pipe_context *, - const struct pipe_rasterizer_state *); - void (*bind_rasterizer_state)(struct pipe_context *, void *); - void (*delete_rasterizer_state)(struct pipe_context *, void *); - - void * (*create_depth_stencil_alpha_state)(struct pipe_context *, - const struct pipe_depth_stencil_alpha_state *); - void (*bind_depth_stencil_alpha_state)(struct pipe_context *, void *); - void (*delete_depth_stencil_alpha_state)(struct pipe_context *, void *); - - void * (*create_fs_state)(struct pipe_context *, - const struct pipe_shader_state *); - void (*bind_fs_state)(struct pipe_context *, void *); - void (*delete_fs_state)(struct pipe_context *, void *); - - void * (*create_vs_state)(struct pipe_context *, - const struct pipe_shader_state *); - void (*bind_vs_state)(struct pipe_context *, void *); - void (*delete_vs_state)(struct pipe_context *, void *); - - void * (*create_gs_state)(struct pipe_context *, - const struct pipe_shader_state *); - void (*bind_gs_state)(struct pipe_context *, void *); - void (*delete_gs_state)(struct pipe_context *, void *); - - void * (*create_vertex_elements_state)(struct pipe_context *, - unsigned num_elements, - const struct pipe_vertex_element *); - void (*bind_vertex_elements_state)(struct pipe_context *, void *); - void (*delete_vertex_elements_state)(struct pipe_context *, void *); - - /*@}*/ - - /** - * Parameter-like state (or properties) - */ - /*@{*/ - void (*set_blend_color)( struct pipe_context *, - const struct pipe_blend_color * ); - - void (*set_stencil_ref)( struct pipe_context *, - const struct pipe_stencil_ref * ); - - void (*set_sample_mask)( struct pipe_context *, - unsigned sample_mask ); - - void (*set_clip_state)( struct pipe_context *, - const struct pipe_clip_state * ); - - void (*set_constant_buffer)( struct pipe_context *, - uint shader, uint index, - struct pipe_constant_buffer *buf ); - - void (*set_framebuffer_state)( struct pipe_context *, - const struct pipe_framebuffer_state * ); - - void (*set_polygon_stipple)( struct pipe_context *, - const struct pipe_poly_stipple * ); - - void (*set_scissor_states)( struct pipe_context *, - unsigned start_slot, - unsigned num_scissors, - const struct pipe_scissor_state * ); - - void (*set_viewport_states)( struct pipe_context *, - unsigned start_slot, - unsigned num_viewports, - const struct pipe_viewport_state *); - - void (*set_sampler_views)(struct pipe_context *, unsigned shader, - unsigned start_slot, unsigned num_views, - struct pipe_sampler_view **); - - /** - * Bind an array of shader resources that will be used by the - * graphics pipeline. Any resources that were previously bound to - * the specified range will be unbound after this call. - * - * \param start first resource to bind. - * \param count number of consecutive resources to bind. - * \param resources array of pointers to the resources to bind, it - * should contain at least \a count elements - * unless it's NULL, in which case no new - * resources will be bound. - */ - void (*set_shader_resources)(struct pipe_context *, - unsigned start, unsigned count, - struct pipe_surface **resources); - - void (*set_vertex_buffers)( struct pipe_context *, - unsigned start_slot, - unsigned num_buffers, - const struct pipe_vertex_buffer * ); - - void (*set_index_buffer)( struct pipe_context *pipe, - const struct pipe_index_buffer * ); - - /*@}*/ - - /** - * Stream output functions. - */ - /*@{*/ - - struct pipe_stream_output_target *(*create_stream_output_target)( - struct pipe_context *, - struct pipe_resource *, - unsigned buffer_offset, - unsigned buffer_size); - - void (*stream_output_target_destroy)(struct pipe_context *, - struct pipe_stream_output_target *); - - void (*set_stream_output_targets)(struct pipe_context *, - unsigned num_targets, - struct pipe_stream_output_target **targets, - unsigned append_bitmask); - - /*@}*/ - - - /** - * Resource functions for blit-like functionality - * - * If a driver supports multisampling, blit must implement color resolve. - */ - /*@{*/ - - /** - * Copy a block of pixels from one resource to another. - * The resource must be of the same format. - * Resources with nr_samples > 1 are not allowed. - */ - void (*resource_copy_region)(struct pipe_context *pipe, - struct pipe_resource *dst, - unsigned dst_level, - unsigned dstx, unsigned dsty, unsigned dstz, - struct pipe_resource *src, - unsigned src_level, - const struct pipe_box *src_box); - - /* Optimal hardware path for blitting pixels. - * Scaling, format conversion, up- and downsampling (resolve) are allowed. - */ - void (*blit)(struct pipe_context *pipe, - const struct pipe_blit_info *info); - - /*@}*/ - - /** - * Clear the specified set of currently bound buffers to specified values. - * The entire buffers are cleared (no scissor, no colormask, etc). - * - * \param buffers bitfield of PIPE_CLEAR_* values. - * \param color pointer to a union of fiu array for each of r, g, b, a. - * \param depth depth clear value in [0,1]. - * \param stencil stencil clear value - */ - void (*clear)(struct pipe_context *pipe, - unsigned buffers, - const union pipe_color_union *color, - double depth, - unsigned stencil); - - /** - * Clear a color rendertarget surface. - * \param color pointer to an union of fiu array for each of r, g, b, a. - */ - void (*clear_render_target)(struct pipe_context *pipe, - struct pipe_surface *dst, - const union pipe_color_union *color, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height); - - /** - * Clear a depth-stencil surface. - * \param clear_flags bitfield of PIPE_CLEAR_DEPTH/STENCIL values. - * \param depth depth clear value in [0,1]. - * \param stencil stencil clear value - */ - void (*clear_depth_stencil)(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned clear_flags, - double depth, - unsigned stencil, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height); - - /** Flush draw commands - * - * \param flags bitfield of enum pipe_flush_flags values. - */ - void (*flush)(struct pipe_context *pipe, - struct pipe_fence_handle **fence, - unsigned flags); - - /** - * Create a view on a texture to be used by a shader stage. - */ - struct pipe_sampler_view * (*create_sampler_view)(struct pipe_context *ctx, - struct pipe_resource *texture, - const struct pipe_sampler_view *templat); - - void (*sampler_view_destroy)(struct pipe_context *ctx, - struct pipe_sampler_view *view); - - - /** - * Get a surface which is a "view" into a resource, used by - * render target / depth stencil stages. - */ - struct pipe_surface *(*create_surface)(struct pipe_context *ctx, - struct pipe_resource *resource, - const struct pipe_surface *templat); - - void (*surface_destroy)(struct pipe_context *ctx, - struct pipe_surface *); - - /** - * Map a resource. - * - * Transfers are (by default) context-private and allow uploads to be - * interleaved with rendering. - * - * out_transfer will contain the transfer object that must be passed - * to all the other transfer functions. It also contains useful - * information (like texture strides). - */ - void *(*transfer_map)(struct pipe_context *, - struct pipe_resource *resource, - unsigned level, - unsigned usage, /* a combination of PIPE_TRANSFER_x */ - const struct pipe_box *, - struct pipe_transfer **out_transfer); - - /* If transfer was created with WRITE|FLUSH_EXPLICIT, only the - * regions specified with this call are guaranteed to be written to - * the resource. - */ - void (*transfer_flush_region)( struct pipe_context *, - struct pipe_transfer *transfer, - const struct pipe_box *); - - void (*transfer_unmap)(struct pipe_context *, - struct pipe_transfer *transfer); - - /* One-shot transfer operation with data supplied in a user - * pointer. XXX: strides?? - */ - void (*transfer_inline_write)( struct pipe_context *, - struct pipe_resource *, - unsigned level, - unsigned usage, /* a combination of PIPE_TRANSFER_x */ - const struct pipe_box *, - const void *data, - unsigned stride, - unsigned layer_stride); - - /** - * Flush any pending framebuffer writes and invalidate texture caches. - */ - void (*texture_barrier)(struct pipe_context *); - - /** - * Flush caches according to flags. - */ - void (*memory_barrier)(struct pipe_context *, unsigned flags); - - /** - * Creates a video codec for a specific video format/profile - */ - struct pipe_video_codec *(*create_video_codec)( struct pipe_context *context, - const struct pipe_video_codec *templat ); - - /** - * Creates a video buffer as decoding target - */ - struct pipe_video_buffer *(*create_video_buffer)( struct pipe_context *context, - const struct pipe_video_buffer *templat ); - - /** - * Compute kernel execution - */ - /*@{*/ - /** - * Define the compute program and parameters to be used by - * pipe_context::launch_grid. - */ - void *(*create_compute_state)(struct pipe_context *context, - const struct pipe_compute_state *); - void (*bind_compute_state)(struct pipe_context *, void *); - void (*delete_compute_state)(struct pipe_context *, void *); - - /** - * Bind an array of shader resources that will be used by the - * compute program. Any resources that were previously bound to - * the specified range will be unbound after this call. - * - * \param start first resource to bind. - * \param count number of consecutive resources to bind. - * \param resources array of pointers to the resources to bind, it - * should contain at least \a count elements - * unless it's NULL, in which case no new - * resources will be bound. - */ - void (*set_compute_resources)(struct pipe_context *, - unsigned start, unsigned count, - struct pipe_surface **resources); - - /** - * Bind an array of buffers to be mapped into the address space of - * the GLOBAL resource. Any buffers that were previously bound - * between [first, first + count - 1] are unbound after this call. - * - * \param first first buffer to map. - * \param count number of consecutive buffers to map. - * \param resources array of pointers to the buffers to map, it - * should contain at least \a count elements - * unless it's NULL, in which case no new - * resources will be bound. - * \param handles array of pointers to the memory locations that - * will be updated with the address each buffer - * will be mapped to. The base memory address of - * each of the buffers will be added to the value - * pointed to by its corresponding handle to form - * the final address argument. It should contain - * at least \a count elements, unless \a - * resources is NULL in which case \a handles - * should be NULL as well. - * - * Note that the driver isn't required to make any guarantees about - * the contents of the \a handles array being valid anytime except - * during the subsequent calls to pipe_context::launch_grid. This - * means that the only sensible location handles[i] may point to is - * somewhere within the INPUT buffer itself. This is so to - * accommodate implementations that lack virtual memory but - * nevertheless migrate buffers on the fly, leading to resource - * base addresses that change on each kernel invocation or are - * unknown to the pipe driver. - */ - void (*set_global_binding)(struct pipe_context *context, - unsigned first, unsigned count, - struct pipe_resource **resources, - uint32_t **handles); - - /** - * Launch the compute kernel starting from instruction \a pc of the - * currently bound compute program. - * - * \a grid_layout and \a block_layout are arrays of size \a - * PIPE_COMPUTE_CAP_GRID_DIMENSION that determine the layout of the - * grid (in block units) and working block (in thread units) to be - * used, respectively. - * - * \a pc For drivers that use PIPE_SHADER_IR_LLVM as their prefered IR, - * this value will be the index of the kernel in the opencl.kernels - * metadata list. - * - * \a input will be used to initialize the INPUT resource, and it - * should point to a buffer of at least - * pipe_compute_state::req_input_mem bytes. - */ - void (*launch_grid)(struct pipe_context *context, - const uint *block_layout, const uint *grid_layout, - uint32_t pc, const void *input); - /*@}*/ - - /** - * Get sample position for an individual sample point. - * - * \param sample_count - total number of samples - * \param sample_index - sample to get the position values for - * \param out_value - return value of 2 floats for x and y position for - * requested sample. - */ - void (*get_sample_position)(struct pipe_context *context, - unsigned sample_count, - unsigned sample_index, - float *out_value); - - /** - * Flush the resource cache, so that the resource can be used - * by an external client. Possible usage: - * - flushing a resource before presenting it on the screen - * - flushing a resource if some other process or device wants to use it - * This shouldn't be used to flush caches if the resource is only managed - * by a single pipe_screen and is not shared with another process. - * (i.e. you shouldn't use it to flush caches explicitly if you want to e.g. - * use the resource for texturing) - */ - void (*flush_resource)(struct pipe_context *ctx, - struct pipe_resource *resource); -}; - - -#ifdef __cplusplus -} -#endif - -#endif /* PIPE_CONTEXT_H */ diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h deleted file mode 100644 index cf958d2..0000000 --- a/src/gallium/include/pipe/p_screen.h +++ /dev/null @@ -1,230 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 VMware, Inc. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * @file - * - * Screen, Adapter or GPU - * - * These are driver functions/facilities that are context independent. - */ - - -#ifndef P_SCREEN_H -#define P_SCREEN_H - - -#include "pipe/p_compiler.h" -#include "pipe/p_format.h" -#include "pipe/p_defines.h" -#include "pipe/p_video_enums.h" - - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** Opaque types */ -struct winsys_handle; -struct pipe_fence_handle; -struct pipe_resource; -struct pipe_surface; -struct pipe_transfer; -struct pipe_box; - - -/** - * Gallium screen/adapter context. Basically everything - * hardware-specific that doesn't actually require a rendering - * context. - */ -struct pipe_screen { - void (*destroy)( struct pipe_screen * ); - - const char *(*get_name)( struct pipe_screen * ); - - const char *(*get_vendor)( struct pipe_screen * ); - - /** - * Query an integer-valued capability/parameter/limit - * \param param one of PIPE_CAP_x - */ - int (*get_param)( struct pipe_screen *, enum pipe_cap param ); - - /** - * Query a float-valued capability/parameter/limit - * \param param one of PIPE_CAP_x - */ - float (*get_paramf)( struct pipe_screen *, enum pipe_capf param ); - - /** - * Query a per-shader-stage integer-valued capability/parameter/limit - * \param param one of PIPE_CAP_x - */ - int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param ); - - /** - * Query an integer-valued capability/parameter/limit for a codec/profile - * \param param one of PIPE_VIDEO_CAP_x - */ - int (*get_video_param)( struct pipe_screen *, - enum pipe_video_profile profile, - enum pipe_video_entrypoint entrypoint, - enum pipe_video_cap param ); - - /** - * Query a compute-specific capability/parameter/limit. - * \param param one of PIPE_COMPUTE_CAP_x - * \param ret pointer to a preallocated buffer that will be - * initialized to the parameter value, or NULL. - * \return size in bytes of the parameter value that would be - * returned. - */ - int (*get_compute_param)(struct pipe_screen *, - enum pipe_compute_cap param, - void *ret); - - /** - * Query a timestamp in nanoseconds. The returned value should match - * PIPE_QUERY_TIMESTAMP. This function returns immediately and doesn't - * wait for rendering to complete (which cannot be achieved with queries). - */ - uint64_t (*get_timestamp)(struct pipe_screen *); - - struct pipe_context * (*context_create)( struct pipe_screen *, - void *priv ); - - /** - * Check if the given pipe_format is supported as a texture or - * drawing surface. - * \param bindings bitmask of PIPE_BIND_* - */ - boolean (*is_format_supported)( struct pipe_screen *, - enum pipe_format format, - enum pipe_texture_target target, - unsigned sample_count, - unsigned bindings ); - - /** - * Check if the given pipe_format is supported as output for this codec/profile. - * \param profile profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN - */ - boolean (*is_video_format_supported)( struct pipe_screen *, - enum pipe_format format, - enum pipe_video_profile profile, - enum pipe_video_entrypoint entrypoint ); - - /** - * Check if we can actually create the given resource (test the dimension, - * overall size, etc). Used to implement proxy textures. - * \return TRUE if size is OK, FALSE if too large. - */ - boolean (*can_create_resource)(struct pipe_screen *screen, - const struct pipe_resource *templat); - - /** - * Create a new texture object, using the given template info. - */ - struct pipe_resource * (*resource_create)(struct pipe_screen *, - const struct pipe_resource *templat); - - /** - * Create a texture from a winsys_handle. The handle is often created in - * another process by first creating a pipe texture and then calling - * resource_get_handle. - */ - struct pipe_resource * (*resource_from_handle)(struct pipe_screen *, - const struct pipe_resource *templat, - struct winsys_handle *handle); - - /** - * Get a winsys_handle from a texture. Some platforms/winsys requires - * that the texture is created with a special usage flag like - * DISPLAYTARGET or PRIMARY. - */ - boolean (*resource_get_handle)(struct pipe_screen *, - struct pipe_resource *tex, - struct winsys_handle *handle); - - - void (*resource_destroy)(struct pipe_screen *, - struct pipe_resource *pt); - - - /** - * Do any special operations to ensure frontbuffer contents are - * displayed, eg copy fake frontbuffer. - * \param winsys_drawable_handle an opaque handle that the calling context - * gets out-of-band - * \param subbox an optional sub region to flush - */ - void (*flush_frontbuffer)( struct pipe_screen *screen, - struct pipe_resource *resource, - unsigned level, unsigned layer, - void *winsys_drawable_handle, - struct pipe_box *subbox ); - - /** Set ptr = fence, with reference counting */ - void (*fence_reference)( struct pipe_screen *screen, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence ); - - /** - * Checks whether the fence has been signalled. - */ - boolean (*fence_signalled)( struct pipe_screen *screen, - struct pipe_fence_handle *fence ); - - /** - * Wait for the fence to finish. - * \param timeout in nanoseconds (may be PIPE_TIMEOUT_INFINITE). - */ - boolean (*fence_finish)( struct pipe_screen *screen, - struct pipe_fence_handle *fence, - uint64_t timeout ); - - /** - * Returns a driver-specific query. - * - * If \p info is NULL, the number of available queries is returned. - * Otherwise, the driver query at the specified \p index is returned - * in \p info. The function returns non-zero on success. - */ - int (*get_driver_query_info)(struct pipe_screen *screen, - unsigned index, - struct pipe_driver_query_info *info); - -}; - - -#ifdef __cplusplus -} -#endif - -#endif /* P_SCREEN_H */ diff --git a/src/gallium/include/pipe/p_video_enums.h b/src/gallium/include/pipe/p_video_enums.h deleted file mode 100644 index 10205ac..0000000 --- a/src/gallium/include/pipe/p_video_enums.h +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 Younes Manton. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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 PIPE_VIDEO_ENUMS_H -#define PIPE_VIDEO_ENUMS_H - -enum pipe_video_format -{ - PIPE_VIDEO_FORMAT_UNKNOWN = 0, - PIPE_VIDEO_FORMAT_MPEG12, /**< MPEG1, MPEG2 */ - PIPE_VIDEO_FORMAT_MPEG4, /**< DIVX, XVID */ - PIPE_VIDEO_FORMAT_VC1, /**< WMV */ - PIPE_VIDEO_FORMAT_MPEG4_AVC /**< H.264 */ -}; - -enum pipe_video_profile -{ - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_PROFILE_MPEG1, - PIPE_VIDEO_PROFILE_MPEG2_SIMPLE, - PIPE_VIDEO_PROFILE_MPEG2_MAIN, - PIPE_VIDEO_PROFILE_MPEG4_SIMPLE, - PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE, - PIPE_VIDEO_PROFILE_VC1_SIMPLE, - PIPE_VIDEO_PROFILE_VC1_MAIN, - PIPE_VIDEO_PROFILE_VC1_ADVANCED, - PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE, - PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN, - PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH -}; - -/* Video caps, can be different for each codec/profile */ -enum pipe_video_cap -{ - PIPE_VIDEO_CAP_SUPPORTED = 0, - PIPE_VIDEO_CAP_NPOT_TEXTURES = 1, - PIPE_VIDEO_CAP_MAX_WIDTH = 2, - PIPE_VIDEO_CAP_MAX_HEIGHT = 3, - PIPE_VIDEO_CAP_PREFERED_FORMAT = 4, - PIPE_VIDEO_CAP_PREFERS_INTERLACED = 5, - PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE = 6, - PIPE_VIDEO_CAP_SUPPORTS_INTERLACED = 7, - PIPE_VIDEO_CAP_MAX_LEVEL = 8 -}; - -enum pipe_video_entrypoint -{ - PIPE_VIDEO_ENTRYPOINT_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_ENTRYPOINT_IDCT, - PIPE_VIDEO_ENTRYPOINT_MC, - PIPE_VIDEO_ENTRYPOINT_ENCODE -}; - -#endif /* PIPE_VIDEO_ENUMS_H */ diff --git a/src/gallium/meson.build b/src/gallium/meson.build index 23441ed..64e9cb4 100644 --- a/src/gallium/meson.build +++ b/src/gallium/meson.build @@ -23,15 +23,10 @@ sources_libgallium = [ 'include/pipe/p_defines.h', - 'include/pipe/p_context.h', 'include/pipe/p_state.h', 'include/pipe/p_format.h', 'include/pipe/p_shader_tokens.h', - 'include/pipe/p_screen.h', - 'include/pipe/p_video_enums.h', 'auxiliary/util/u_format.h', - 'auxiliary/util/u_rect.h', - 'auxiliary/util/u_surface.h', 'auxiliary/util/u_format.c', 'auxiliary/util/u_inlines.h', 'auxiliary/util/u_texture.c', @@ -41,12 +36,9 @@ sources_libgallium = [ 'auxiliary/util/u_dual_blend.h', 'auxiliary/util/u_texture.h', 'auxiliary/util/u_hash_table.h', - 'auxiliary/util/u_box.h', - 'auxiliary/util/u_pack_color.h', 'auxiliary/util/u_double_list.h', 'auxiliary/util/u_debug_refcnt.h', 'auxiliary/util/u_format_s3tc.h', - 'auxiliary/util/u_surface.c', 'auxiliary/util/u_half.h', 'auxiliary/util/u_prim.h', 'auxiliary/util/u_debug_describe.c', diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 5f73b6a..303d353 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -30,9 +30,7 @@ #include #include "pipe/p_shader_tokens.h" -#include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "pipe/p_screen.h" #include "pipe/p_state.h" #include "util/u_inlines.h" #include "util/u_memory.h"