summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2016-12-11 08:53:23 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2016-12-11 08:53:23 +0000
commit58cad0a2ccb28b1f82763d80861c6085def38b30 (patch)
tree8f199bc844429c0ca70acb457cd48a354b6ff177 /lib/mesa/src/gallium/auxiliary/util
parent21ab4c9f31674b113c24177398ed39f29b7cd8e6 (diff)
Merge Mesa 13.0.2
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/util')
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_clear.h63
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_format_r11g11b10f.h232
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_format_rgb9e5.h165
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_slab.c171
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_slab.h96
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_staging.c132
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_staging.h63
7 files changed, 0 insertions, 922 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_clear.h b/lib/mesa/src/gallium/auxiliary/util/u_clear.h
deleted file mode 100644
index 864d1302b..000000000
--- a/lib/mesa/src/gallium/auxiliary/util/u_clear.h
+++ /dev/null
@@ -1,63 +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.
- *
- **************************************************************************/
-
-/* Authors:
- * Michel Dänzer
- */
-
-
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-
-
-/**
- * Clear the given buffers to the specified values.
- * No masking, no scissor (clear entire buffer).
- */
-static inline void
-util_clear(struct pipe_context *pipe,
- struct pipe_framebuffer_state *framebuffer, unsigned buffers,
- const union pipe_color_union *color, double depth, unsigned stencil)
-{
- unsigned i;
-
- for (i = 0; i < framebuffer->nr_cbufs; i++) {
- if (buffers & (PIPE_CLEAR_COLOR0 << i)) {
- struct pipe_surface *ps = framebuffer->cbufs[i];
-
- if (ps) {
- pipe->clear_render_target(pipe, ps, color, 0, 0, ps->width, ps->height);
- }
- }
- }
-
- if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
- struct pipe_surface *ps = framebuffer->zsbuf;
- pipe->clear_depth_stencil(pipe, ps, buffers & PIPE_CLEAR_DEPTHSTENCIL,
- depth, stencil,
- 0, 0, ps->width, ps->height);
- }
-}
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_format_r11g11b10f.h b/lib/mesa/src/gallium/auxiliary/util/u_format_r11g11b10f.h
deleted file mode 100644
index 218822b16..000000000
--- a/lib/mesa/src/gallium/auxiliary/util/u_format_r11g11b10f.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) 2011 Marek Olšák <maraeo@gmail.com>
- *
- * 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.
- */
-
-/* Based on code from The OpenGL Programming Guide / 7th Edition, Appendix J.
- * Available here: http://www.opengl-redbook.com/appendices/
- * The algorithm in the book contains a bug though, which is fixed in the code
- * below.
- */
-
-#define UF11(e, m) ((e << 6) | (m))
-#define UF11_EXPONENT_BIAS 15
-#define UF11_EXPONENT_BITS 0x1F
-#define UF11_EXPONENT_SHIFT 6
-#define UF11_MANTISSA_BITS 0x3F
-#define UF11_MANTISSA_SHIFT (23 - UF11_EXPONENT_SHIFT)
-#define UF11_MAX_EXPONENT (UF11_EXPONENT_BITS << UF11_EXPONENT_SHIFT)
-
-#define UF10(e, m) ((e << 5) | (m))
-#define UF10_EXPONENT_BIAS 15
-#define UF10_EXPONENT_BITS 0x1F
-#define UF10_EXPONENT_SHIFT 5
-#define UF10_MANTISSA_BITS 0x1F
-#define UF10_MANTISSA_SHIFT (23 - UF10_EXPONENT_SHIFT)
-#define UF10_MAX_EXPONENT (UF10_EXPONENT_BITS << UF10_EXPONENT_SHIFT)
-
-#define F32_INFINITY 0x7f800000
-
-static inline unsigned f32_to_uf11(float val)
-{
- union {
- float f;
- uint32_t ui;
- } f32 = {val};
-
- uint16_t uf11 = 0;
-
- /* Decode little-endian 32-bit floating-point value */
- int sign = (f32.ui >> 16) & 0x8000;
- /* Map exponent to the range [-127,128] */
- int exponent = ((f32.ui >> 23) & 0xff) - 127;
- int mantissa = f32.ui & 0x007fffff;
-
- if (exponent == 128) { /* Infinity or NaN */
- /* From the GL_EXT_packed_float spec:
- *
- * "Additionally: negative infinity is converted to zero; positive
- * infinity is converted to positive infinity; and both positive and
- * negative NaN are converted to positive NaN."
- */
- uf11 = UF11_MAX_EXPONENT;
- if (mantissa) {
- uf11 |= 1; /* NaN */
- } else {
- if (sign)
- uf11 = 0; /* 0.0 */
- }
- } else if (sign) {
- return 0;
- } else if (val > 65024.0f) {
- /* From the GL_EXT_packed_float spec:
- *
- * "Likewise, finite positive values greater than 65024 (the maximum
- * finite representable unsigned 11-bit floating-point value) are
- * converted to 65024."
- */
- uf11 = UF11(30, 63);
- }
- else if (exponent > -15) { /* Representable value */
- exponent += UF11_EXPONENT_BIAS;
- mantissa >>= UF11_MANTISSA_SHIFT;
- uf11 = exponent << UF11_EXPONENT_SHIFT | mantissa;
- }
-
- return uf11;
-}
-
-static inline float uf11_to_f32(uint16_t val)
-{
- union {
- float f;
- uint32_t ui;
- } f32;
-
- int exponent = (val & 0x07c0) >> UF11_EXPONENT_SHIFT;
- int mantissa = (val & 0x003f);
-
- f32.f = 0.0;
-
- if (exponent == 0) {
- if (mantissa != 0) {
- const float scale = 1.0 / (1 << 20);
- f32.f = scale * mantissa;
- }
- }
- else if (exponent == 31) {
- f32.ui = F32_INFINITY | mantissa;
- }
- else {
- float scale, decimal;
- exponent -= 15;
- if (exponent < 0) {
- scale = 1.0f / (1 << -exponent);
- }
- else {
- scale = (float) (1 << exponent);
- }
- decimal = 1.0f + (float) mantissa / 64;
- f32.f = scale * decimal;
- }
-
- return f32.f;
-}
-
-static inline unsigned f32_to_uf10(float val)
-{
- union {
- float f;
- uint32_t ui;
- } f32 = {val};
-
- uint16_t uf10 = 0;
-
- /* Decode little-endian 32-bit floating-point value */
- int sign = (f32.ui >> 16) & 0x8000;
- /* Map exponent to the range [-127,128] */
- int exponent = ((f32.ui >> 23) & 0xff) - 127;
- int mantissa = f32.ui & 0x007fffff;
-
- if (exponent == 128) {
- /* From the GL_EXT_packed_float spec:
- *
- * "Additionally: negative infinity is converted to zero; positive
- * infinity is converted to positive infinity; and both positive and
- * negative NaN are converted to positive NaN."
- */
- uf10 = UF10_MAX_EXPONENT;
- if (mantissa) {
- uf10 |= 1; /* NaN */
- } else {
- if (sign)
- uf10 = 0; /* 0.0 */
- }
- } else if (sign) {
- return 0;
- } else if (val > 64512.0f) {
- /* From the GL_EXT_packed_float spec:
- *
- * "Likewise, finite positive values greater than 64512 (the maximum
- * finite representable unsigned 10-bit floating-point value) are
- * converted to 64512."
- */
- uf10 = UF10(30, 31);
- }
- else if (exponent > -15) { /* Representable value */
- exponent += UF10_EXPONENT_BIAS;
- mantissa >>= UF10_MANTISSA_SHIFT;
- uf10 = exponent << UF10_EXPONENT_SHIFT | mantissa;
- }
-
- return uf10;
-}
-
-static inline float uf10_to_f32(uint16_t val)
-{
- union {
- float f;
- uint32_t ui;
- } f32;
-
- int exponent = (val & 0x03e0) >> UF10_EXPONENT_SHIFT;
- int mantissa = (val & 0x001f);
-
- f32.f = 0.0;
-
- if (exponent == 0) {
- if (mantissa != 0) {
- const float scale = 1.0 / (1 << 20);
- f32.f = scale * mantissa;
- }
- }
- else if (exponent == 31) {
- f32.ui = F32_INFINITY | mantissa;
- }
- else {
- float scale, decimal;
- exponent -= 15;
- if (exponent < 0) {
- scale = 1.0f / (1 << -exponent);
- }
- else {
- scale = (float) (1 << exponent);
- }
- decimal = 1.0f + (float) mantissa / 32;
- f32.f = scale * decimal;
- }
-
- return f32.f;
-}
-
-static inline unsigned float3_to_r11g11b10f(const float rgb[3])
-{
- return ( f32_to_uf11(rgb[0]) & 0x7ff) |
- ((f32_to_uf11(rgb[1]) & 0x7ff) << 11) |
- ((f32_to_uf10(rgb[2]) & 0x3ff) << 22);
-}
-
-static inline void r11g11b10f_to_float3(unsigned rgb, float retval[3])
-{
- retval[0] = uf11_to_f32( rgb & 0x7ff);
- retval[1] = uf11_to_f32((rgb >> 11) & 0x7ff);
- retval[2] = uf10_to_f32((rgb >> 22) & 0x3ff);
-}
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_format_rgb9e5.h b/lib/mesa/src/gallium/auxiliary/util/u_format_rgb9e5.h
deleted file mode 100644
index 59fc291e9..000000000
--- a/lib/mesa/src/gallium/auxiliary/util/u_format_rgb9e5.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2011 Marek Olšák <maraeo@gmail.com>
- *
- * 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.
- */
-
-/* Copied from EXT_texture_shared_exponent and edited. */
-
-#ifndef RGB9E5_H
-#define RGB9E5_H
-
-#include <assert.h>
-
-#include "c99_math.h"
-
-#define RGB9E5_EXPONENT_BITS 5
-#define RGB9E5_MANTISSA_BITS 9
-#define RGB9E5_EXP_BIAS 15
-#define RGB9E5_MAX_VALID_BIASED_EXP 31
-
-#define MAX_RGB9E5_EXP (RGB9E5_MAX_VALID_BIASED_EXP - RGB9E5_EXP_BIAS)
-#define RGB9E5_MANTISSA_VALUES (1<<RGB9E5_MANTISSA_BITS)
-#define MAX_RGB9E5_MANTISSA (RGB9E5_MANTISSA_VALUES-1)
-#define MAX_RGB9E5 (((float)MAX_RGB9E5_MANTISSA)/RGB9E5_MANTISSA_VALUES * (1<<MAX_RGB9E5_EXP))
-#define EPSILON_RGB9E5 ((1.0/RGB9E5_MANTISSA_VALUES) / (1<<RGB9E5_EXP_BIAS))
-
-typedef union {
- unsigned int raw;
- float value;
- struct {
-#if defined(MESA_BIG_ENDIAN) || defined(PIPE_ARCH_BIG_ENDIAN)
- unsigned int negative:1;
- unsigned int biasedexponent:8;
- unsigned int mantissa:23;
-#else
- unsigned int mantissa:23;
- unsigned int biasedexponent:8;
- unsigned int negative:1;
-#endif
- } field;
-} float754;
-
-typedef union {
- unsigned int raw;
- struct {
-#if defined(MESA_BIG_ENDIAN) || defined(PIPE_ARCH_BIG_ENDIAN)
- unsigned int biasedexponent:RGB9E5_EXPONENT_BITS;
- unsigned int b:RGB9E5_MANTISSA_BITS;
- unsigned int g:RGB9E5_MANTISSA_BITS;
- unsigned int r:RGB9E5_MANTISSA_BITS;
-#else
- unsigned int r:RGB9E5_MANTISSA_BITS;
- unsigned int g:RGB9E5_MANTISSA_BITS;
- unsigned int b:RGB9E5_MANTISSA_BITS;
- unsigned int biasedexponent:RGB9E5_EXPONENT_BITS;
-#endif
- } field;
-} rgb9e5;
-
-static inline float rgb9e5_ClampRange(float x)
-{
- if (x > 0.0f) {
- if (x >= MAX_RGB9E5) {
- return MAX_RGB9E5;
- } else {
- return x;
- }
- } else {
- /* NaN gets here too since comparisons with NaN always fail! */
- return 0.0;
- }
-}
-
-/* Ok, FloorLog2 is not correct for the denorm and zero values, but we
- are going to do a max of this value with the minimum rgb9e5 exponent
- that will hide these problem cases. */
-static inline int rgb9e5_FloorLog2(float x)
-{
- float754 f;
-
- f.value = x;
- return (f.field.biasedexponent - 127);
-}
-
-static inline unsigned float3_to_rgb9e5(const float rgb[3])
-{
- rgb9e5 retval;
- float maxrgb;
- int rm, gm, bm;
- float rc, gc, bc;
- int exp_shared, maxm;
- double denom;
-
- rc = rgb9e5_ClampRange(rgb[0]);
- gc = rgb9e5_ClampRange(rgb[1]);
- bc = rgb9e5_ClampRange(rgb[2]);
-
- maxrgb = MAX3(rc, gc, bc);
- exp_shared = MAX2(-RGB9E5_EXP_BIAS-1, rgb9e5_FloorLog2(maxrgb)) + 1 + RGB9E5_EXP_BIAS;
- assert(exp_shared <= RGB9E5_MAX_VALID_BIASED_EXP);
- assert(exp_shared >= 0);
- /* This exp2 function could be replaced by a table. */
- denom = exp2(exp_shared - RGB9E5_EXP_BIAS - RGB9E5_MANTISSA_BITS);
-
- maxm = (int) floor(maxrgb / denom + 0.5);
- if (maxm == MAX_RGB9E5_MANTISSA+1) {
- denom *= 2;
- exp_shared += 1;
- assert(exp_shared <= RGB9E5_MAX_VALID_BIASED_EXP);
- } else {
- assert(maxm <= MAX_RGB9E5_MANTISSA);
- }
-
- rm = (int) floor(rc / denom + 0.5);
- gm = (int) floor(gc / denom + 0.5);
- bm = (int) floor(bc / denom + 0.5);
-
- assert(rm <= MAX_RGB9E5_MANTISSA);
- assert(gm <= MAX_RGB9E5_MANTISSA);
- assert(bm <= MAX_RGB9E5_MANTISSA);
- assert(rm >= 0);
- assert(gm >= 0);
- assert(bm >= 0);
-
- retval.field.r = rm;
- retval.field.g = gm;
- retval.field.b = bm;
- retval.field.biasedexponent = exp_shared;
-
- return retval.raw;
-}
-
-static inline void rgb9e5_to_float3(unsigned rgb, float retval[3])
-{
- rgb9e5 v;
- int exponent;
- float scale;
-
- v.raw = rgb;
- exponent = v.field.biasedexponent - RGB9E5_EXP_BIAS - RGB9E5_MANTISSA_BITS;
- scale = exp2f(exponent);
-
- retval[0] = v.field.r * scale;
- retval[1] = v.field.g * scale;
- retval[2] = v.field.b * scale;
-}
-
-#endif
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_slab.c b/lib/mesa/src/gallium/auxiliary/util/u_slab.c
deleted file mode 100644
index 7e7d43bd8..000000000
--- a/lib/mesa/src/gallium/auxiliary/util/u_slab.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright 2010 Marek Olšák <maraeo@gmail.com>
- *
- * 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
- * on 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
- * THE AUTHOR(S) AND/OR THEIR 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. */
-
-#include "util/u_slab.h"
-
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "util/simple_list.h"
-
-#include <stdio.h>
-
-#define UTIL_SLAB_MAGIC 0xcafe4321
-
-/* The block is either allocated memory or free space. */
-struct util_slab_block {
- /* The header. */
- /* The first next free block. */
- struct util_slab_block *next_free;
-
- intptr_t magic;
-
- /* Memory after the last member is dedicated to the block itself.
- * The allocated size is always larger than this structure. */
-};
-
-static struct util_slab_block *
-util_slab_get_block(struct util_slab_mempool *pool,
- struct util_slab_page *page, unsigned index)
-{
- return (struct util_slab_block*)
- ((uint8_t*)page + sizeof(struct util_slab_page) +
- (pool->block_size * index));
-}
-
-static void util_slab_add_new_page(struct util_slab_mempool *pool)
-{
- struct util_slab_page *page;
- struct util_slab_block *block;
- unsigned i;
-
- page = MALLOC(pool->page_size);
- insert_at_tail(&pool->list, page);
-
- /* Mark all blocks as free. */
- for (i = 0; i < pool->num_blocks-1; i++) {
- block = util_slab_get_block(pool, page, i);
- block->next_free = util_slab_get_block(pool, page, i+1);
- block->magic = UTIL_SLAB_MAGIC;
- }
-
- block = util_slab_get_block(pool, page, pool->num_blocks-1);
- block->next_free = pool->first_free;
- block->magic = UTIL_SLAB_MAGIC;
- pool->first_free = util_slab_get_block(pool, page, 0);
- pool->num_pages++;
-
-#if 0
- fprintf(stderr, "New page! Num of pages: %i\n", pool->num_pages);
-#endif
-}
-
-static void *util_slab_alloc_st(struct util_slab_mempool *pool)
-{
- struct util_slab_block *block;
-
- if (!pool->first_free)
- util_slab_add_new_page(pool);
-
- block = pool->first_free;
- assert(block->magic == UTIL_SLAB_MAGIC);
- pool->first_free = block->next_free;
-
- return (uint8_t*)block + sizeof(struct util_slab_block);
-}
-
-static void util_slab_free_st(struct util_slab_mempool *pool, void *ptr)
-{
- struct util_slab_block *block =
- (struct util_slab_block*)
- ((uint8_t*)ptr - sizeof(struct util_slab_block));
-
- assert(block->magic == UTIL_SLAB_MAGIC);
- block->next_free = pool->first_free;
- pool->first_free = block;
-}
-
-static void *util_slab_alloc_mt(struct util_slab_mempool *pool)
-{
- void *mem;
-
- pipe_mutex_lock(pool->mutex);
- mem = util_slab_alloc_st(pool);
- pipe_mutex_unlock(pool->mutex);
- return mem;
-}
-
-static void util_slab_free_mt(struct util_slab_mempool *pool, void *ptr)
-{
- pipe_mutex_lock(pool->mutex);
- util_slab_free_st(pool, ptr);
- pipe_mutex_unlock(pool->mutex);
-}
-
-void util_slab_set_thread_safety(struct util_slab_mempool *pool,
- enum util_slab_threading threading)
-{
- pool->threading = threading;
-
- if (threading) {
- pool->alloc = util_slab_alloc_mt;
- pool->free = util_slab_free_mt;
- } else {
- pool->alloc = util_slab_alloc_st;
- pool->free = util_slab_free_st;
- }
-}
-
-void util_slab_create(struct util_slab_mempool *pool,
- unsigned item_size,
- unsigned num_blocks,
- enum util_slab_threading threading)
-{
- item_size = align(item_size, sizeof(intptr_t));
-
- pool->num_pages = 0;
- pool->num_blocks = num_blocks;
- pool->block_size = sizeof(struct util_slab_block) + item_size;
- pool->block_size = align(pool->block_size, sizeof(intptr_t));
- pool->page_size = sizeof(struct util_slab_page) +
- num_blocks * pool->block_size;
- pool->first_free = NULL;
-
- make_empty_list(&pool->list);
-
- pipe_mutex_init(pool->mutex);
-
- util_slab_set_thread_safety(pool, threading);
-}
-
-void util_slab_destroy(struct util_slab_mempool *pool)
-{
- struct util_slab_page *page, *temp;
-
- if (pool->list.next) {
- foreach_s(page, temp, &pool->list) {
- remove_from_list(page);
- FREE(page);
- }
- }
-
- pipe_mutex_destroy(pool->mutex);
-}
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_slab.h b/lib/mesa/src/gallium/auxiliary/util/u_slab.h
deleted file mode 100644
index 0df039bcd..000000000
--- a/lib/mesa/src/gallium/auxiliary/util/u_slab.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2010 Marek Olšák <maraeo@gmail.com>
- *
- * 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
- * on 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
- * THE AUTHOR(S) AND/OR THEIR 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
- * Simple slab allocator for equally sized memory allocations.
- * util_slab_alloc and util_slab_free have time complexity in O(1).
- *
- * Good for allocations which have very low lifetime and are allocated
- * and freed very often. Use a profiler first to know if it's worth using it!
- *
- * Candidates: transfer_map
- *
- * @author Marek Olšák
- */
-
-#ifndef U_SLAB_H
-#define U_SLAB_H
-
-#include "os/os_thread.h"
-
-enum util_slab_threading {
- UTIL_SLAB_SINGLETHREADED = FALSE,
- UTIL_SLAB_MULTITHREADED = TRUE
-};
-
-/* The page is an array of blocks (allocations). */
-struct util_slab_page {
- /* The header (linked-list pointers). */
- struct util_slab_page *prev, *next;
-
- /* Memory after the last member is dedicated to the page itself.
- * The allocated size is always larger than this structure. */
-};
-
-struct util_slab_mempool {
- /* Public members. */
- void *(*alloc)(struct util_slab_mempool *pool);
- void (*free)(struct util_slab_mempool *pool, void *ptr);
-
- /* Private members. */
- struct util_slab_block *first_free;
-
- struct util_slab_page list;
-
- unsigned block_size;
- unsigned page_size;
- unsigned num_blocks;
- unsigned num_pages;
- enum util_slab_threading threading;
-
- pipe_mutex mutex;
-};
-
-void util_slab_create(struct util_slab_mempool *pool,
- unsigned item_size,
- unsigned num_blocks,
- enum util_slab_threading threading);
-
-void util_slab_destroy(struct util_slab_mempool *pool);
-
-void util_slab_set_thread_safety(struct util_slab_mempool *pool,
- enum util_slab_threading threading);
-
-static inline void *
-util_slab_alloc(struct util_slab_mempool *pool)
-{
- return pool->alloc(pool);
-}
-
-static inline void
-util_slab_free(struct util_slab_mempool *pool, void *ptr)
-{
- pool->free(pool, ptr);
-}
-
-#endif
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_staging.c b/lib/mesa/src/gallium/auxiliary/util/u_staging.c
deleted file mode 100644
index b569c8f99..000000000
--- a/lib/mesa/src/gallium/auxiliary/util/u_staging.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Luca Barbieri
- *
- * 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 COPYRIGHT OWNER(S) 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.
- *
- **************************************************************************/
-
-#include "util/u_staging.h"
-#include "pipe/p_context.h"
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-
-static void
-util_staging_resource_template(struct pipe_resource *pt, unsigned width, unsigned height, unsigned depth, struct pipe_resource *template)
-{
- memset(template, 0, sizeof(struct pipe_resource));
- if(pt->target != PIPE_BUFFER && depth <= 1)
- template->target = PIPE_TEXTURE_RECT;
- else
- template->target = pt->target;
- template->format = pt->format;
- template->width0 = width;
- template->height0 = height;
- template->depth0 = depth;
- template->array_size = 1;
- template->last_level = 0;
- template->nr_samples = pt->nr_samples;
- template->bind = 0;
- template->usage = PIPE_USAGE_STAGING;
- template->flags = 0;
-}
-
-struct util_staging_transfer *
-util_staging_transfer_init(struct pipe_context *pipe,
- struct pipe_resource *pt,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- boolean direct, struct util_staging_transfer *tx)
-{
- struct pipe_screen *pscreen = pipe->screen;
-
- struct pipe_resource staging_resource_template;
-
- pipe_resource_reference(&tx->base.resource, pt);
- tx->base.level = level;
- tx->base.usage = usage;
- tx->base.box = *box;
-
- if (direct)
- {
- tx->staging_resource = pt;
- return tx;
- }
-
- util_staging_resource_template(pt, box->width, box->height, box->depth, &staging_resource_template);
- tx->staging_resource = pscreen->resource_create(pscreen, &staging_resource_template);
- if (!tx->staging_resource)
- {
- pipe_resource_reference(&tx->base.resource, NULL);
- FREE(tx);
- return NULL;
- }
-
- if (usage & PIPE_TRANSFER_READ)
- {
- /* XXX this looks wrong dst is always the same but looping over src z? */
- int zi;
- struct pipe_box sbox;
- sbox.x = box->x;
- sbox.y = box->y;
- sbox.z = box->z;
- sbox.width = box->width;
- sbox.height = box->height;
- sbox.depth = 1;
- for(zi = 0; zi < box->depth; ++zi) {
- sbox.z = sbox.z + zi;
- pipe->resource_copy_region(pipe, tx->staging_resource, 0, 0, 0, 0,
- tx->base.resource, level, &sbox);
- }
- }
-
- return tx;
-}
-
-void
-util_staging_transfer_destroy(struct pipe_context *pipe, struct pipe_transfer *ptx)
-{
- struct util_staging_transfer *tx = (struct util_staging_transfer *)ptx;
-
- if (tx->staging_resource != tx->base.resource)
- {
- if(tx->base.usage & PIPE_TRANSFER_WRITE) {
- /* XXX this looks wrong src is always the same but looping over dst z? */
- int zi;
- struct pipe_box sbox;
- sbox.x = 0;
- sbox.y = 0;
- sbox.z = 0;
- sbox.width = tx->base.box.width;
- sbox.height = tx->base.box.height;
- sbox.depth = 1;
- for(zi = 0; zi < tx->base.box.depth; ++zi)
- pipe->resource_copy_region(pipe, tx->base.resource, tx->base.level, tx->base.box.x, tx->base.box.y, tx->base.box.z + zi,
- tx->staging_resource, 0, &sbox);
- }
-
- pipe_resource_reference(&tx->staging_resource, NULL);
- }
-
- pipe_resource_reference(&ptx->resource, NULL);
- FREE(ptx);
-}
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_staging.h b/lib/mesa/src/gallium/auxiliary/util/u_staging.h
deleted file mode 100644
index ddbb33443..000000000
--- a/lib/mesa/src/gallium/auxiliary/util/u_staging.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Luca Barbieri
- *
- * 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 COPYRIGHT OWNER(S) 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.
- *
- **************************************************************************/
-
-/* Direct3D 10/11 has no concept of transfers. Applications instead
- * create resources with a STAGING or DYNAMIC usage, copy between them
- * and the real resource and use Map to map the STAGING/DYNAMIC resource.
- *
- * This util module allows to implement Gallium drivers as a Direct3D
- * driver would be implemented: transfers allocate a resource with
- * PIPE_USAGE_STAGING, and copy the data between it and the real resource
- * with resource_copy_region.
- */
-
-#ifndef U_STAGING_H
-#define U_STAGING_H
-
-#include "pipe/p_state.h"
-
-struct util_staging_transfer {
- struct pipe_transfer base;
-
- /* if direct, same as base.resource, otherwise the temporary staging resource */
- struct pipe_resource *staging_resource;
-};
-
-/* user must be stride, slice_stride and offset */
-/* pt->usage == PIPE_USAGE_DYNAMIC || pt->usage == PIPE_USAGE_STAGING should be a good value to pass for direct */
-/* staging resource is currently created with PIPE_USAGE_STAGING */
-struct util_staging_transfer *
-util_staging_transfer_init(struct pipe_context *pipe,
- struct pipe_resource *pt,
- unsigned level,
- unsigned usage,
- const struct pipe_box *box,
- boolean direct, struct util_staging_transfer *tx);
-
-void
-util_staging_transfer_destroy(struct pipe_context *pipe, struct pipe_transfer *ptx);
-
-#endif