gallium: refactor/replace p_util.h with util/u_memory.h and util/u_math.h

Also, rename p_tile.[ch] to u_tile.[ch]
This commit is contained in:
Brian Paul 2008-08-24 17:48:55 -06:00
parent ec7415642d
commit 4f25420bdd
200 changed files with 2244 additions and 477 deletions

View File

@ -35,8 +35,8 @@ not available in Windows Kernel Mode. Use the appropriate p_*.h include.
* Use MALLOC, CALLOC, FREE instead of the malloc, calloc, free functions.
* Use align_pointer() function defined in p_util.h for aligning pointers in a
portable way.
* Use align_pointer() function defined in u_memory.h for aligning pointers
in a portable way.
== Debugging ==

View File

@ -28,9 +28,10 @@
/* Authors: Zack Rusin <zack@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "pipe/p_debug.h"
#include "util/u_memory.h"
#include "cso_cache.h"
#include "cso_hash.h"

View File

@ -36,7 +36,7 @@
*/
#include "pipe/p_state.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "tgsi/tgsi_parse.h"

View File

@ -31,7 +31,7 @@
*/
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "cso_hash.h"

View File

@ -31,7 +31,8 @@
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "draw_context.h"
#include "draw_vbuf.h"
#include "draw_vs.h"

View File

@ -30,7 +30,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "draw/draw_private.h"
#include "draw/draw_pipe.h"

View File

@ -32,11 +32,12 @@
*/
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "tgsi/tgsi_transform.h"
#include "tgsi/tgsi_dump.h"

View File

@ -38,7 +38,6 @@
*/
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@ -47,6 +46,9 @@
#include "tgsi/tgsi_transform.h"
#include "tgsi/tgsi_dump.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "draw_context.h"
#include "draw_vs.h"
#include "draw_pipe.h"

View File

@ -32,7 +32,9 @@
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "pipe/p_shader_tokens.h"
#include "draw_vs.h"

View File

@ -33,7 +33,7 @@
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "draw_pipe.h"

View File

@ -28,7 +28,9 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw_vs.h"
#include "draw_pipe.h"

View File

@ -32,7 +32,8 @@
* \author Brian Paul
*/
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "draw_pipe.h"

View File

@ -34,12 +34,14 @@
*/
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "tgsi/tgsi_transform.h"
#include "tgsi/tgsi_dump.h"

View File

@ -36,10 +36,12 @@
*/
#include "pipe/p_util.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "draw_pipe.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "draw/draw_pipe.h"
/** Subclass of draw_stage */

View File

@ -28,7 +28,8 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "draw_vs.h"

View File

@ -33,7 +33,7 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "draw_private.h"
#include "draw_pipe.h"

View File

@ -30,7 +30,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "draw/draw_private.h"
#include "draw/draw_pipe.h"

View File

@ -28,7 +28,7 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "draw_private.h"
#include "draw_pipe.h"

View File

@ -35,7 +35,8 @@
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "draw_vbuf.h"
#include "draw_private.h"

View File

@ -28,9 +28,10 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "draw_private.h"
#include "draw_pipe.h"

View File

@ -28,7 +28,8 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "draw_vs.h"

View File

@ -30,7 +30,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_pt.h"

View File

@ -25,7 +25,7 @@
*
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"

View File

@ -25,7 +25,7 @@
*
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"

View File

@ -30,7 +30,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"

View File

@ -31,7 +31,8 @@
*/
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"

View File

@ -25,7 +25,8 @@
*
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
#include "draw/draw_vertex.h"

View File

@ -25,7 +25,7 @@
*
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_context.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"

View File

@ -30,7 +30,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_pt.h"

View File

@ -25,7 +25,9 @@
*
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_pt.h"

View File

@ -30,7 +30,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_pt.h"

View File

@ -37,8 +37,6 @@
#define DRAW_VBUF_H_
#include "pipe/p_util.h"
struct draw_context;
struct vertex_info;

View File

@ -31,11 +31,15 @@
* Brian Paul
*/
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
#include "draw_context.h"
#include "draw_vs.h"
#include "translate/translate.h"
#include "translate/translate_cache.h"

View File

@ -29,9 +29,9 @@
*/
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi/tgsi_exec.h"

View File

@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"

View File

@ -29,8 +29,9 @@
#include "pipe/p_config.h"
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi/tgsi_exec.h"

View File

@ -31,7 +31,8 @@
* Brian Paul
*/
#include "pipe/p_util.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"

View File

@ -32,7 +32,6 @@
* Brian Paul
*/
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"
#include "draw_context.h"

View File

@ -31,13 +31,14 @@
* Brian Paul
*/
#include "util/u_math.h"
#include "util/u_memory.h"
#include "pipe/p_config.h"
#include "draw_vs.h"
#if defined(PIPE_ARCH_X86)
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "draw_private.h"

View File

@ -30,7 +30,8 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vbuf.h"

View File

@ -41,11 +41,12 @@
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/p_util.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_dump.h"
#include "util/u_memory.h"
#include <llvm/Module.h>
#include <llvm/CallingConv.h>
#include <llvm/Constants.h>

View File

@ -35,7 +35,7 @@
#include "storage.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include <llvm/CallingConv.h>
#include <llvm/Constants.h>

View File

@ -29,7 +29,7 @@
#include "storagesoa.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include <llvm/CallingConv.h>
#include <llvm/Constants.h>

View File

@ -45,7 +45,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_winsys.h"
#include "pipe/p_thread.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "pb_buffer.h"

View File

@ -35,7 +35,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"

View File

@ -35,7 +35,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"

View File

@ -38,7 +38,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_winsys.h"
#include "pipe/p_thread.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_time.h"

View File

@ -37,7 +37,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_winsys.h"
#include "pipe/p_thread.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_time.h"

View File

@ -35,7 +35,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_buffer_fenced.h"

View File

@ -36,7 +36,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_mm.h"
#include "pb_buffer.h"

View File

@ -39,7 +39,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "pb_buffer.h"

View File

@ -39,7 +39,7 @@
#include "pipe/p_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_time.h"

View File

@ -35,7 +35,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_debug.h"
#include "pb_buffer.h"

View File

@ -35,7 +35,7 @@
#include "pipe/p_winsys.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pb_buffer.h"

View File

@ -33,7 +33,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "rtasm_execmem.h"

View File

@ -30,7 +30,7 @@
*/
#include "pipe/p_compiler.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "rtasm_ppc_spe.h"
#ifdef GALLIUM_CELL

View File

@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
#include "sct.h"

View File

@ -26,7 +26,6 @@
**************************************************************************/
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_build.h"
#include "tgsi_parse.h"

View File

@ -28,6 +28,10 @@
#ifndef TGSI_BUILD_H
#define TGSI_BUILD_H
struct tgsi_token;
#if defined __cplusplus
extern "C" {
#endif

View File

@ -26,7 +26,6 @@
**************************************************************************/
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "util/u_string.h"
#include "tgsi_dump_c.h"
#include "tgsi_build.h"

View File

@ -52,11 +52,11 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
#include "tgsi_exec.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#define FAST_MATH 1

View File

@ -26,10 +26,10 @@
**************************************************************************/
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_parse.h"
#include "tgsi_build.h"
#include "util/u_memory.h"
void
tgsi_full_token_init(

View File

@ -33,11 +33,11 @@
*/
#include "tgsi_scan.h"
#include "tgsi/tgsi_parse.h"
#include "util/u_math.h"
#include "tgsi/tgsi_build.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_scan.h"
#include "pipe/p_util.h"

View File

@ -25,7 +25,7 @@
*
**************************************************************************/
#include "pipe/p_util.h"
#include "pipe/p_debug.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_math.h"
#include "tgsi/tgsi_parse.h"

View File

@ -31,6 +31,7 @@
* Authors: Brian Paul
*/
#include "pipe/p_debug.h"
#include "tgsi_transform.h"

View File

@ -29,7 +29,6 @@
#define TGSI_TRANSFORM_H
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_build.h"

View File

@ -26,7 +26,6 @@
**************************************************************************/
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi_parse.h"
#include "tgsi_build.h"

View File

@ -31,7 +31,6 @@
*/
#include "pipe/p_config.h"
#include "pipe/p_util.h"
#include "pipe/p_state.h"
#include "translate.h"

View File

@ -25,7 +25,7 @@
*
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_state.h"
#include "translate.h"
#include "translate_cache.h"

View File

@ -30,7 +30,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_state.h"
#include "translate.h"

View File

@ -28,7 +28,7 @@
#include "pipe/p_config.h"
#include "pipe/p_compiler.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
#include "translate.h"

View File

@ -5,7 +5,6 @@ LIBNAME = util
C_SOURCES = \
p_debug.c \
p_tile.c \
u_blit.c \
u_draw_quad.c \
u_gen_mipmap.c \
@ -16,6 +15,7 @@ C_SOURCES = \
u_rect.c \
u_simple_shaders.c \
u_snprintf.c \
u_tile.c \
u_time.c
include ../../Makefile.template

View File

@ -6,7 +6,6 @@ util = env.ConvenienceLibrary(
'p_debug.c',
'p_debug_mem.c',
'p_debug_prof.c',
'p_tile.c',
'u_blit.c',
'u_draw_quad.c',
'u_gen_mipmap.c',
@ -17,6 +16,7 @@ util = env.ConvenienceLibrary(
'u_rect.c',
'u_simple_shaders.c',
'u_snprintf.c',
'u_tile.c',
'u_time.c',
])

View File

@ -51,7 +51,6 @@
#endif
#include "pipe/p_compiler.h"
#include "pipe/p_util.h"
#include "pipe/p_debug.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"

View File

@ -37,12 +37,13 @@
#include "pipe/p_debug.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_draw_quad.h"
#include "util/u_blit.h"
#include "util/u_draw_quad.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
#include "cso_cache/cso_context.h"

View File

@ -37,10 +37,10 @@
#include "pipe/p_debug.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_memory.h"
#include "util/u_draw_quad.h"
#include "util/u_gen_mipmap.h"
#include "util/u_simple_shaders.h"

View File

@ -35,9 +35,9 @@
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "u_handle_table.h"
#include "util/u_memory.h"
#include "util/u_handle_table.h"
#define HANDLE_TABLE_INITIAL_SIZE 16

View File

@ -40,10 +40,11 @@
#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
#include "pipe/p_util.h"
#include "cso_cache/cso_hash.h"
#include "u_hash_table.h"
#include "util/u_memory.h"
#include "util/u_hash_table.h"
struct hash_table

View File

@ -40,8 +40,6 @@
#include "pipe/p_compiler.h"
#include "pipe/p_util.h"
#include "util/u_math.h"
#ifdef __cplusplus
@ -49,6 +47,132 @@ extern "C" {
#endif
#if defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
__inline double ceil(double val)
{
double ceil_val;
if((val - (long) val) == 0) {
ceil_val = val;
}
else {
if(val > 0) {
ceil_val = (long) val + 1;
}
else {
ceil_val = (long) val;
}
}
return ceil_val;
}
#ifndef PIPE_SUBSYSTEM_WINDOWS_CE
__inline double floor(double val)
{
double floor_val;
if((val - (long) val) == 0) {
floor_val = val;
}
else {
if(val > 0) {
floor_val = (long) val;
}
else {
floor_val = (long) val - 1;
}
}
return floor_val;
}
#endif
#pragma function(pow)
__inline double __cdecl pow(double val, double exponent)
{
/* XXX */
assert(0);
return 0;
}
#pragma function(log)
__inline double __cdecl log(double val)
{
/* XXX */
assert(0);
return 0;
}
#pragma function(atan2)
__inline double __cdecl atan2(double val)
{
/* XXX */
assert(0);
return 0;
}
#else
#include <math.h>
#include <stdarg.h>
#endif
#if defined(_MSC_VER)
#if _MSC_VER < 1400 && !defined(__cplusplus) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
static INLINE float cosf( float f )
{
return (float) cos( (double) f );
}
static INLINE float sinf( float f )
{
return (float) sin( (double) f );
}
static INLINE float ceilf( float f )
{
return (float) ceil( (double) f );
}
static INLINE float floorf( float f )
{
return (float) floor( (double) f );
}
static INLINE float powf( float f, float g )
{
return (float) pow( (double) f, (double) g );
}
static INLINE float sqrtf( float f )
{
return (float) sqrt( (double) f );
}
static INLINE float fabsf( float f )
{
return (float) fabs( (double) f );
}
static INLINE float logf( float f )
{
return (float) log( (double) f );
}
#else
/* Work-around an extra semi-colon in VS 2005 logf definition */
#ifdef logf
#undef logf
#define logf(x) ((float)log((double)(x)))
#endif /* logf */
#endif
#endif /* _MSC_VER */
#define POW2_TABLE_SIZE 256
#define POW2_TABLE_SCALE ((float) (POW2_TABLE_SIZE-1))
extern float pow2_table[POW2_TABLE_SIZE];
@ -59,6 +183,11 @@ extern void
util_init_math(void);
union fi {
float f;
int i;
unsigned ui;
};
/**
@ -195,6 +324,113 @@ util_iround(float f)
#if defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
/**
* Find first bit set in word. Least significant bit is 1.
* Return 0 if no bits set.
*/
static INLINE
unsigned ffs( unsigned u )
{
unsigned i;
if( u == 0 ) {
return 0;
}
__asm bsf eax, [u]
__asm inc eax
__asm mov [i], eax
return i;
}
#endif
/**
* Return float bits.
*/
static INLINE unsigned
fui( float f )
{
union fi fi;
fi.f = f;
return fi.ui;
}
static INLINE float
ubyte_to_float(ubyte ub)
{
return (float) ub * (1.0f / 255.0f);
}
/**
* Convert float in [0,1] to ubyte in [0,255] with clamping.
*/
static INLINE ubyte
float_to_ubyte(float f)
{
const int ieee_0996 = 0x3f7f0000; /* 0.996 or so */
union fi tmp;
tmp.f = f;
if (tmp.i < 0) {
return (ubyte) 0;
}
else if (tmp.i >= ieee_0996) {
return (ubyte) 255;
}
else {
tmp.f = tmp.f * (255.0f/256.0f) + 32768.0f;
return (ubyte) tmp.i;
}
}
#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
static INLINE int
align(int value, int alignment)
{
return (value + alignment - 1) & ~(alignment - 1);
}
#ifndef COPY_4V
#define COPY_4V( DST, SRC ) \
do { \
(DST)[0] = (SRC)[0]; \
(DST)[1] = (SRC)[1]; \
(DST)[2] = (SRC)[2]; \
(DST)[3] = (SRC)[3]; \
} while (0)
#endif
#ifndef COPY_4FV
#define COPY_4FV( DST, SRC ) COPY_4V(DST, SRC)
#endif
#ifndef ASSIGN_4V
#define ASSIGN_4V( DST, V0, V1, V2, V3 ) \
do { \
(DST)[0] = (V0); \
(DST)[1] = (V1); \
(DST)[2] = (V2); \
(DST)[3] = (V3); \
} while (0)
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,6 +1,6 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@ -25,78 +25,18 @@
*
**************************************************************************/
#ifndef P_UTIL_H
#define P_UTIL_H
#include "p_config.h"
#include "p_compiler.h"
#include "p_debug.h"
#include "p_pointer.h"
/**
* Memory functions
*/
#if defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
__inline double ceil(double val)
{
double ceil_val;
if((val - (long) val) == 0) {
ceil_val = val;
} else {
if(val > 0) {
ceil_val = (long) val + 1;
} else {
ceil_val = (long) val;
}
}
#ifndef U_MEMORY_H
#define U_MEMORY_H
return ceil_val;
}
#ifndef PIPE_SUBSYSTEM_WINDOWS_CE
__inline double floor(double val)
{
double floor_val;
#include "util/u_pointer.h"
if((val - (long) val) == 0) {
floor_val = val;
} else {
if(val > 0) {
floor_val = (long) val;
} else {
floor_val = (long) val - 1;
}
}
return floor_val;
}
#endif
#pragma function(pow)
__inline double __cdecl pow(double val, double exponent)
{
/* XXX */
assert(0);
return 0;
}
#pragma function(log)
__inline double __cdecl log(double val)
{
/* XXX */
assert(0);
return 0;
}
#pragma function(atan2)
__inline double __cdecl atan2(double val)
{
/* XXX */
assert(0);
return 0;
}
#else
#include <math.h>
#include <stdarg.h>
#endif
/* Define ENOMEM for WINCE */
#if (_WIN32_WCE < 600)
@ -105,9 +45,6 @@ __inline double __cdecl atan2(double val)
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG)
@ -254,7 +191,6 @@ align_free(void *ptr)
}
/**
* Duplicate a block of memory.
*/
@ -268,193 +204,19 @@ mem_dup(const void *src, uint size)
}
#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
/**
* Number of elements in an array.
*/
#ifndef Elements
#define Elements(x) (sizeof(x)/sizeof((x)[0]))
#endif
#define Offset(TYPE, MEMBER) ((unsigned)&(((TYPE *)NULL)->MEMBER))
/**
* Return a pointer aligned to next multiple of 16 bytes.
* Offset of a field in a struct, in bytes.
*/
static INLINE void *
align16( void *unaligned )
{
return align_pointer( unaligned, 16 );
}
static INLINE int align(int value, int alignment)
{
return (value + alignment - 1) & ~(alignment - 1);
}
#define Offset(TYPE, MEMBER) ((unsigned)&(((TYPE *)NULL)->MEMBER))
#if defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
static INLINE unsigned ffs( unsigned u )
{
unsigned i;
if( u == 0 ) {
return 0;
}
__asm bsf eax, [u]
__asm inc eax
__asm mov [i], eax
return i;
}
#endif
union fi {
float f;
int i;
unsigned ui;
};
#define UBYTE_TO_FLOAT( ub ) ((float)(ub) / 255.0F)
#define IEEE_0996 0x3f7f0000 /* 0.996 or so */
/* This function/macro is sensitive to precision. Test very carefully
* if you change it!
*/
#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \
do { \
union fi __tmp; \
__tmp.f = (F); \
if (__tmp.i < 0) \
UB = (ubyte) 0; \
else if (__tmp.i >= IEEE_0996) \
UB = (ubyte) 255; \
else { \
__tmp.f = __tmp.f * (255.0f/256.0f) + 32768.0f; \
UB = (ubyte) __tmp.i; \
} \
} while (0)
static INLINE unsigned pack_ub4( unsigned char b0,
unsigned char b1,
unsigned char b2,
unsigned char b3 )
{
return ((((unsigned int)b0) << 0) |
(((unsigned int)b1) << 8) |
(((unsigned int)b2) << 16) |
(((unsigned int)b3) << 24));
}
static INLINE unsigned fui( float f )
{
union fi fi;
fi.f = f;
return fi.ui;
}
static INLINE unsigned char float_to_ubyte( float f )
{
unsigned char ub;
UNCLAMPED_FLOAT_TO_UBYTE(ub, f);
return ub;
}
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) );
}
#define COPY_4V( DST, SRC ) \
do { \
(DST)[0] = (SRC)[0]; \
(DST)[1] = (SRC)[1]; \
(DST)[2] = (SRC)[2]; \
(DST)[3] = (SRC)[3]; \
} while (0)
#define COPY_4FV( DST, SRC ) COPY_4V(DST, SRC)
#define ASSIGN_4V( DST, V0, V1, V2, V3 ) \
do { \
(DST)[0] = (V0); \
(DST)[1] = (V1); \
(DST)[2] = (V2); \
(DST)[3] = (V3); \
} while (0)
#if defined(_MSC_VER)
#if _MSC_VER < 1400 && !defined(__cplusplus) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
static INLINE float cosf( float f )
{
return (float) cos( (double) f );
}
static INLINE float sinf( float f )
{
return (float) sin( (double) f );
}
static INLINE float ceilf( float f )
{
return (float) ceil( (double) f );
}
static INLINE float floorf( float f )
{
return (float) floor( (double) f );
}
static INLINE float powf( float f, float g )
{
return (float) pow( (double) f, (double) g );
}
static INLINE float sqrtf( float f )
{
return (float) sqrt( (double) f );
}
static INLINE float fabsf( float f )
{
return (float) fabs( (double) f );
}
static INLINE float logf( float f )
{
return (float) log( (double) f );
}
#else
/* Work-around an extra semi-colon in VS 2005 logf definition */
#ifdef logf
#undef logf
#define logf(x) ((float)log((double)(x)))
#endif /* logf */
#endif
#endif /* _MSC_VER */
#ifdef __cplusplus
}
#endif
#endif
#endif /* U_MEMORY_H */

View File

@ -24,9 +24,9 @@
#include "pipe/p_compiler.h"
#include "pipe/p_util.h"
#include "pipe/p_debug.h"
#include "util/u_memory.h"
#include "util/u_mm.h"

View File

@ -37,6 +37,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
#include "util/u_math.h"
/**
@ -150,10 +151,10 @@ util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
if (pf_size_x(format) <= 8) {
/* format uses 8-bit components or less */
UNCLAMPED_FLOAT_TO_UBYTE(r, rgba[0]);
UNCLAMPED_FLOAT_TO_UBYTE(g, rgba[1]);
UNCLAMPED_FLOAT_TO_UBYTE(b, rgba[2]);
UNCLAMPED_FLOAT_TO_UBYTE(a, rgba[3]);
r = float_to_ubyte(rgba[0]);
g = float_to_ubyte(rgba[1]);
b = float_to_ubyte(rgba[2]);
a = float_to_ubyte(rgba[3]);
}
switch (format) {
@ -286,4 +287,31 @@ util_pack_z(enum pipe_format format, double z)
}
/**
* 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 */

View File

@ -0,0 +1,107 @@
/**************************************************************************
*
* Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* 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 TUNGSTEN GRAPHICS 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_POINTER_H
#define U_POINTER_H
#include "pipe/p_compiler.h"
#ifdef __cplusplus
extern "C" {
#endif
static INLINE intptr_t
pointer_to_intptr( const void *p )
{
union {
const void *p;
intptr_t i;
} pi;
pi.p = p;
return pi.i;
}
static INLINE void *
intptr_to_pointer( intptr_t i )
{
union {
void *p;
intptr_t i;
} pi;
pi.i = i;
return pi.p;
}
static INLINE uintptr_t
pointer_to_uintptr( const void *ptr )
{
union {
const void *p;
uintptr_t u;
} pu;
pu.p = ptr;
return pu.u;
}
static INLINE void *
uintptr_to_pointer( uintptr_t u )
{
union {
void *p;
uintptr_t u;
} pu;
pu.u = u;
return pu.p;
}
/**
* Return a pointer aligned to next multiple of N bytes.
*/
static INLINE void *
align_pointer( const void *unaligned, uintptr_t alignment )
{
uintptr_t aligned = (pointer_to_uintptr( unaligned ) + alignment - 1) & ~(alignment - 1);
return uintptr_to_pointer( aligned );
}
/**
* Return a pointer aligned to next multiple of 16 bytes.
*/
static INLINE void *
align16( void *unaligned )
{
return align_pointer( unaligned, 16 );
}
#ifdef __cplusplus
}
#endif
#endif /* U_POINTER_H */

View File

@ -31,7 +31,6 @@
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "pipe/p_format.h"
#include "util/u_rect.h"

View File

@ -37,10 +37,10 @@
#include "pipe/p_debug.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
#include "pipe/p_shader_tokens.h"
#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
#include "tgsi/tgsi_build.h"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,101 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* 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 TUNGSTEN GRAPHICS 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 P_TILE_H
#define P_TILE_H
#include "pipe/p_compiler.h"
struct pipe_surface;
/**
* Clip tile against surface dims.
* \return TRUE if tile is totally clipped, FALSE otherwise
*/
static INLINE boolean
pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_surface *ps)
{
if (x >= ps->width)
return TRUE;
if (y >= ps->height)
return TRUE;
if (x + *w > ps->width)
*w = ps->width - x;
if (y + *h > ps->height)
*h = ps->height - y;
return FALSE;
}
#ifdef __cplusplus
extern "C" {
#endif
void
pipe_get_tile_raw(struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
void *p, int dst_stride);
void
pipe_put_tile_raw(struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
const void *p, int src_stride);
void
pipe_get_tile_rgba(struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
float *p);
void
pipe_put_tile_rgba(struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
const float *p);
void
pipe_get_tile_z(struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
uint *z);
void
pipe_put_tile_z(struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
const uint *z);
void
pipe_tile_raw_to_rgba(enum pipe_format format,
void *src,
uint w, uint h,
float *dst, unsigned dst_stride);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -34,7 +34,6 @@
#define CELL_COMMON_H
#include "pipe/p_compiler.h"
#include "pipe/p_util.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"

View File

@ -34,7 +34,7 @@
#include <assert.h>
#include <stdint.h>
#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "cell/common.h"
#include "cell_clear.h"
#include "cell_context.h"

View File

@ -35,7 +35,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_format.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "pipe/p_screen.h"

View File

@ -30,7 +30,7 @@
* Brian Paul
*/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
#include "cell_context.h"

View File

@ -33,7 +33,7 @@
#include "cell_context.h"
#include "cell_render.h"
#include "cell_spu.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "draw/draw_private.h"

View File

@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"

View File

@ -25,7 +25,7 @@
*
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "draw/draw_vertex.h"

View File

@ -25,7 +25,7 @@
*
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "cell_context.h"
#include "cell_state.h"
#include "cell_state_emit.h"

View File

@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "draw/draw_context.h"

View File

@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "util/p_tile.h"

View File

@ -33,7 +33,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "cell_context.h"

View File

@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_util.h"
#include "util/u_memory.h"
#include "cell_winsys.h"

View File

@ -63,7 +63,6 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"

Some files were not shown because too many files have changed in this diff Show More