2007-10-29 16:20:45 +00:00
|
|
|
/**************************************************************************
|
2022-03-18 05:14:55 +00:00
|
|
|
*
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* Copyright 2008 VMware, Inc.
|
2007-10-29 16:20:45 +00:00
|
|
|
* All Rights Reserved.
|
2022-03-18 05:14:55 +00:00
|
|
|
*
|
2007-08-13 16:24:24 +01:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
2007-10-29 16:20:45 +00:00
|
|
|
* 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:
|
2022-03-18 05:14:55 +00:00
|
|
|
*
|
2007-10-29 16:20:45 +00:00
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
|
|
* of the Software.
|
2022-03-18 05:14:55 +00:00
|
|
|
*
|
2007-08-13 16:24:24 +01:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
2007-10-29 16:20:45 +00:00
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
2007-10-29 16:20:45 +00:00
|
|
|
* 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.
|
2022-03-18 05:14:55 +00:00
|
|
|
*
|
2007-10-29 16:20:45 +00:00
|
|
|
**************************************************************************/
|
2007-08-13 16:24:24 +01:00
|
|
|
|
|
|
|
|
2010-02-03 12:13:06 +00:00
|
|
|
/*
|
2008-08-25 00:48:55 +01:00
|
|
|
* Memory functions
|
|
|
|
*/
|
2008-07-26 01:17:10 +01:00
|
|
|
|
|
|
|
|
2008-08-25 00:48:55 +01:00
|
|
|
#ifndef U_MEMORY_H
|
|
|
|
#define U_MEMORY_H
|
2008-07-26 01:17:10 +01:00
|
|
|
|
2009-02-18 12:05:26 +00:00
|
|
|
#include "util/u_debug.h"
|
2018-11-09 18:40:15 +00:00
|
|
|
#include "util/os_memory.h"
|
2008-07-26 01:17:10 +01:00
|
|
|
|
2007-12-11 15:58:39 +00:00
|
|
|
|
2008-08-31 09:40:08 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-02-03 12:13:06 +00:00
|
|
|
#define MALLOC(_size) os_malloc(_size)
|
2007-10-29 16:20:45 +00:00
|
|
|
|
2010-02-03 12:13:06 +00:00
|
|
|
#define CALLOC(_count, _size) os_calloc(_count, _size)
|
2007-10-29 16:20:45 +00:00
|
|
|
|
2010-02-03 12:13:06 +00:00
|
|
|
#define FREE(_ptr ) os_free(_ptr)
|
2007-10-29 16:20:45 +00:00
|
|
|
|
2010-02-03 12:13:06 +00:00
|
|
|
#define REALLOC(_ptr, _old_size, _size) os_realloc(_ptr, _old_size, _size)
|
2007-10-29 16:20:45 +00:00
|
|
|
|
2008-01-25 10:33:58 +00:00
|
|
|
#define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T))
|
|
|
|
|
2007-10-29 16:20:45 +00:00
|
|
|
#define CALLOC_STRUCT(T) (struct T *) CALLOC(1, sizeof(struct T))
|
|
|
|
|
CELL: use variant-length fragment ops programs
This is a set of changes that optimizes the memory use of fragment
operation programs (by using and transmitting only as much memory as is
needed for the fragment ops programs, instead of maximal sizes), as well
as eliminate the dependency on hard-coded maximal program sizes. State
that is not dependent on fragment facing (i.e. that isn't using
two-sided stenciling) will only save and transmit a single
fragment operation program, instead of two identical programs.
- Added the ability to emit a LNOP (No Operation (Load)) instruction.
This is used to pad the generated fragment operations programs to
a multiple of 8 bytes, which is necessary for proper operation of
the dual instruction pipeline, and also required for proper SPU-side
decoding.
- Added the ability to allocate and manage a variant-length
struct cell_command_fragment_ops. This structure now puts the
generated function field at the end, where it can be as large
as necessary.
- On the PPU side, we now combine the generated front-facing and
back-facing code into a single variant-length buffer (and only use one
if the two sets of code are identical) for transmission to the SPU.
- On the SPU side, we pull the correct sizes out of the buffer,
allocate a new code buffer if the one we have isn't large enough,
and save the code to that buffer. The buffer is deallocated when
the SPU exits.
- Commented out the emit_fetch() static function, which was not being used.
2008-11-21 18:42:14 +00:00
|
|
|
#define CALLOC_VARIANT_LENGTH_STRUCT(T,more_size) ((struct T *) CALLOC(1, sizeof(struct T) + more_size))
|
|
|
|
|
2007-12-11 15:58:39 +00:00
|
|
|
|
2010-02-03 12:13:06 +00:00
|
|
|
#define align_malloc(_size, _alignment) os_malloc_aligned(_size, _alignment)
|
|
|
|
#define align_free(_ptr) os_free_aligned(_ptr)
|
2018-09-13 00:26:38 +01:00
|
|
|
#define align_realloc(_ptr, _oldsize, _newsize, _alignment) os_realloc_aligned(_ptr, _oldsize, _newsize, _alignment)
|
2007-12-11 15:58:39 +00:00
|
|
|
|
2016-10-21 16:25:08 +01:00
|
|
|
static inline void *
|
|
|
|
align_calloc(size_t size, unsigned long alignment)
|
|
|
|
{
|
|
|
|
void *ptr = align_malloc(size, alignment);
|
|
|
|
if (ptr)
|
|
|
|
memset(ptr, 0, size);
|
|
|
|
return ptr;
|
|
|
|
}
|
2007-12-11 15:58:39 +00:00
|
|
|
|
2008-02-06 16:28:20 +00:00
|
|
|
/**
|
2008-02-07 09:26:08 +00:00
|
|
|
* Duplicate a block of memory.
|
2008-02-06 16:28:20 +00:00
|
|
|
*/
|
2015-07-21 00:58:43 +01:00
|
|
|
static inline void *
|
2020-03-26 03:44:59 +00:00
|
|
|
mem_dup(const void *src, size_t size)
|
2008-02-06 16:28:20 +00:00
|
|
|
{
|
2008-02-07 09:26:08 +00:00
|
|
|
void *dup = MALLOC(size);
|
2008-02-06 16:28:20 +00:00
|
|
|
if (dup)
|
|
|
|
memcpy(dup, src, size);
|
|
|
|
return dup;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-25 00:48:55 +01:00
|
|
|
/**
|
|
|
|
* Offset of a field in a struct, in bytes.
|
2007-08-13 16:24:24 +01:00
|
|
|
*/
|
2010-03-17 19:50:33 +00:00
|
|
|
#define Offset(TYPE, MEMBER) ((uintptr_t)&(((TYPE *)NULL)->MEMBER))
|
2008-04-21 12:38:14 +01:00
|
|
|
|
|
|
|
|
2021-06-27 22:55:29 +01:00
|
|
|
/* Allocate a structure aligned to a cache line. (used to make atomic ops faster) */
|
|
|
|
#define MALLOC_STRUCT_CL(T) (struct T *)align_malloc(sizeof(struct T), CACHE_LINE_SIZE)
|
|
|
|
#define CALLOC_STRUCT_CL(T) (struct T *)align_calloc(sizeof(struct T), CACHE_LINE_SIZE)
|
|
|
|
#define FREE_CL(ptr) align_free(ptr)
|
2008-02-25 11:05:41 +00:00
|
|
|
|
2008-08-31 09:40:08 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-08-25 00:48:55 +01:00
|
|
|
#endif /* U_MEMORY_H */
|