From f720e2497e50e6fdc986e2029b0f85b8e5a93798 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 23 Sep 2021 17:20:21 -0700 Subject: [PATCH] mesa: remove unused files The removed files have no user. Signed-off-by: Chia-I Wu Reviewed-by: Yiwei Zhang Reviewed-by: Ryan Neph Acked-by: Gert Wollny v2: u_bitmask.* is unused as well --- src/gallium/auxiliary/os/os_mman.h | 87 - src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h | 218 --- src/gallium/auxiliary/tgsi/tgsi_transform.c | 250 --- src/gallium/auxiliary/tgsi/tgsi_transform.h | 96 - src/gallium/auxiliary/tgsi/tgsi_ureg.c | 1736 ------------------ src/gallium/auxiliary/tgsi/tgsi_ureg.h | 1206 ------------ src/gallium/auxiliary/util/rgtc.c | 61 - src/gallium/auxiliary/util/rgtc.h | 39 - src/gallium/auxiliary/util/u_bitmask.c | 328 ---- src/gallium/auxiliary/util/u_bitmask.h | 117 -- src/gallium/meson.build | 9 - 11 files changed, 4147 deletions(-) delete mode 100644 src/gallium/auxiliary/os/os_mman.h delete mode 100644 src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h delete mode 100644 src/gallium/auxiliary/tgsi/tgsi_transform.c delete mode 100644 src/gallium/auxiliary/tgsi/tgsi_transform.h delete mode 100644 src/gallium/auxiliary/tgsi/tgsi_ureg.c delete mode 100644 src/gallium/auxiliary/tgsi/tgsi_ureg.h delete mode 100644 src/gallium/auxiliary/util/rgtc.c delete mode 100644 src/gallium/auxiliary/util/rgtc.h delete mode 100644 src/gallium/auxiliary/util/u_bitmask.c delete mode 100644 src/gallium/auxiliary/util/u_bitmask.h diff --git a/src/gallium/auxiliary/os/os_mman.h b/src/gallium/auxiliary/os/os_mman.h deleted file mode 100644 index a735309..0000000 --- a/src/gallium/auxiliary/os/os_mman.h +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************** - * - * Copyright 2011 LunarG, 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 - * OS independent memory mapping (with large file support). - * - * @author Chia-I Wu - */ - -#ifndef _OS_MMAN_H_ -#define _OS_MMAN_H_ - - -#include "pipe/p_config.h" -#include "pipe/p_compiler.h" - -#if defined(PIPE_OS_UNIX) -# ifndef _FILE_OFFSET_BITS -# error _FILE_OFFSET_BITS must be defined to 64 -# endif -# include -#else -# error Unsupported OS -#endif - -#if defined(PIPE_OS_ANDROID) -# include /* for EINVAL */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -#if defined(PIPE_OS_ANDROID) - -extern void *__mmap2(void *, size_t, int, int, int, size_t); - -static inline void *os_mmap(void *addr, size_t length, int prot, int flags, int fd, loff_t offset) -{ - /* offset must be aligned to 4096 (not necessarily the page size) */ - if (unlikely(offset & 4095)) { - errno = EINVAL; - return MAP_FAILED; - } - - return __mmap2(addr, length, prot, flags, fd, (size_t) (offset >> 12)); -} - -#else -/* assume large file support exists */ -# define os_mmap(addr, length, prot, flags, fd, offset) mmap(addr, length, prot, flags, fd, offset) -#endif - -#define os_munmap(addr, length) munmap(addr, length) - - -#ifdef __cplusplus -} -#endif - -#endif /* _OS_MMAN_H_ */ diff --git a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h deleted file mode 100644 index 92aab15..0000000 --- a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h +++ /dev/null @@ -1,218 +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 OP12_TEX -#define OP12_TEX(a) OP12(a) -#endif - -#ifndef OP14_TEX -#define OP14_TEX(a) OP14(a) -#endif - -#ifndef OP12_SAMPLE -#define OP12_SAMPLE(a) OP12(a) -#endif - -#ifndef OP13_SAMPLE -#define OP13_SAMPLE(a) OP13(a) -#endif - -#ifndef OP14_SAMPLE -#define OP14_SAMPLE(a) OP14(a) -#endif - -#ifndef OP15_SAMPLE -#define OP15_SAMPLE(a) OP15(a) -#endif - -#ifndef OP00_LBL -#define OP00_LBL(a) OP00(a) -#endif - -#ifndef OP01_LBL -#define OP01_LBL(a) OP01(a) -#endif - -OP11(ARL) -OP11(MOV) -OP11(LIT) -OP11(RCP) -OP11(RSQ) -OP11(EXP) -OP11(LOG) -OP12(MUL) -OP12(ADD) -OP12(DP3) -OP12(DP4) -OP12(DST) -OP12(MIN) -OP12(MAX) -OP12(SLT) -OP12(SGE) -OP13(MAD) -OP12(SUB) -OP13(LRP) -OP11(SQRT) -OP11(FRC) -OP11(FLR) -OP11(ROUND) -OP11(EX2) -OP11(LG2) -OP12(POW) -OP12(XPD) -OP11(ABS) -OP12(DPH) -OP11(COS) -OP11(DDX) -OP11(DDY) -OP00(KILL) -OP11(PK2H) -OP11(PK2US) -OP11(PK4B) -OP11(PK4UB) -OP12(SEQ) -OP12(SGT) -OP11(SIN) -OP12(SLE) -OP12(SNE) -OP12_TEX(TEX) -OP14_TEX(TXD) -OP12_TEX(TXP) -OP11(UP2H) -OP11(UP2US) -OP11(UP4B) -OP11(UP4UB) -OP11(ARR) -OP00_LBL(CAL) -OP00(RET) -OP11(SSG) -OP13(CMP) -OP11(SCS) -OP12_TEX(TXB) -OP12(DIV) -OP12(DP2) -OP12_TEX(TXL) -OP00(BRK) -OP01_LBL(IF) -OP01_LBL(UIF) -OP00_LBL(ELSE) -OP00(ENDIF) -OP11(CEIL) -OP11(I2F) -OP11(NOT) -OP11(TRUNC) -OP12(SHL) -OP12(AND) -OP12(OR) -OP12(MOD) -OP12(XOR) -OP12_TEX(TXF) -OP12_TEX(TXQ) -OP00(CONT) -OP01(EMIT) -OP01(ENDPRIM) -OP00_LBL(BGNLOOP) -OP00(BGNSUB) -OP00_LBL(ENDLOOP) -OP00(ENDSUB) -OP00(NOP) -OP01(KILL_IF) -OP00(END) -OP11(F2I) -OP12(FSEQ) -OP12(FSGE) -OP12(FSLT) -OP12(FSNE) -OP12(IDIV) -OP12(IMAX) -OP12(IMIN) -OP11(INEG) -OP12(ISGE) -OP12(ISHR) -OP12(ISLT) -OP11(F2U) -OP11(U2F) -OP12(UADD) -OP12(UDIV) -OP13(UMAD) -OP12(UMAX) -OP12(UMIN) -OP12(UMOD) -OP12(UMUL) -OP12(USEQ) -OP12(USGE) -OP12(USHR) -OP12(USLT) -OP12(USNE) -OP01(SWITCH) -OP01(CASE) -OP00(DEFAULT) -OP00(ENDSWITCH) - -OP13_SAMPLE(SAMPLE) -OP12_SAMPLE(SAMPLE_I) -OP13_SAMPLE(SAMPLE_I_MS) -OP14_SAMPLE(SAMPLE_B) -OP14_SAMPLE(SAMPLE_C) -OP14_SAMPLE(SAMPLE_C_LZ) -OP15_SAMPLE(SAMPLE_D) -OP14_SAMPLE(SAMPLE_L) -OP13_SAMPLE(GATHER4) -OP12(SVIEWINFO) -OP13(SAMPLE_POS) -OP12(SAMPLE_INFO) -OP11(UARL) - -OP13(UCMP) - -OP12(IMUL_HI) -OP12(UMUL_HI) - -#undef OP00 -#undef OP01 -#undef OP10 -#undef OP11 -#undef OP12 -#undef OP13 - -#ifdef OP14 -#undef OP14 -#endif - -#ifdef OP15 -#undef OP15 -#endif - -#undef OP00_LBL -#undef OP01_LBL - -#undef OP12_TEX -#undef OP14_TEX - -#undef OP12_SAMPLE -#undef OP13_SAMPLE -#undef OP14_SAMPLE -#undef OP15_SAMPLE diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.c b/src/gallium/auxiliary/tgsi/tgsi_transform.c deleted file mode 100644 index b16d296..0000000 --- a/src/gallium/auxiliary/tgsi/tgsi_transform.c +++ /dev/null @@ -1,250 +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. - * - **************************************************************************/ - -/** - * TGSI program transformation utility. - * - * Authors: Brian Paul - */ - -#include "util/u_debug.h" - -#include "tgsi_transform.h" - - - -static void -emit_instruction(struct tgsi_transform_context *ctx, - const struct tgsi_full_instruction *inst) -{ - uint ti = ctx->ti; - - ti += tgsi_build_full_instruction(inst, - ctx->tokens_out + ti, - ctx->header, - ctx->max_tokens_out - ti); - ctx->ti = ti; -} - - -static void -emit_declaration(struct tgsi_transform_context *ctx, - const struct tgsi_full_declaration *decl) -{ - uint ti = ctx->ti; - - ti += tgsi_build_full_declaration(decl, - ctx->tokens_out + ti, - ctx->header, - ctx->max_tokens_out - ti); - ctx->ti = ti; -} - - -static void -emit_immediate(struct tgsi_transform_context *ctx, - const struct tgsi_full_immediate *imm) -{ - uint ti = ctx->ti; - - ti += tgsi_build_full_immediate(imm, - ctx->tokens_out + ti, - ctx->header, - ctx->max_tokens_out - ti); - ctx->ti = ti; -} - - -static void -emit_property(struct tgsi_transform_context *ctx, - const struct tgsi_full_property *prop) -{ - uint ti = ctx->ti; - - ti += tgsi_build_full_property(prop, - ctx->tokens_out + ti, - ctx->header, - ctx->max_tokens_out - ti); - ctx->ti = ti; -} - - -/** - * Apply user-defined transformations to the input shader to produce - * the output shader. - * For example, a register search-and-replace operation could be applied - * by defining a transform_instruction() callback that examined and changed - * the instruction src/dest regs. - * - * \return number of tokens emitted - */ -int -tgsi_transform_shader(const struct tgsi_token *tokens_in, - struct tgsi_token *tokens_out, - uint max_tokens_out, - struct tgsi_transform_context *ctx) -{ - uint procType; - - /* input shader */ - struct tgsi_parse_context parse; - - /* output shader */ - struct tgsi_processor *processor; - - - /** - ** callback context init - **/ - ctx->emit_instruction = emit_instruction; - ctx->emit_declaration = emit_declaration; - ctx->emit_immediate = emit_immediate; - ctx->emit_property = emit_property; - ctx->tokens_out = tokens_out; - ctx->max_tokens_out = max_tokens_out; - - - /** - ** Setup to begin parsing input shader - **/ - if (tgsi_parse_init( &parse, tokens_in ) != TGSI_PARSE_OK) { - debug_printf("tgsi_parse_init() failed in tgsi_transform_shader()!\n"); - return -1; - } - procType = parse.FullHeader.Processor.Processor; - assert(procType == TGSI_PROCESSOR_FRAGMENT || - procType == TGSI_PROCESSOR_VERTEX || - procType == TGSI_PROCESSOR_GEOMETRY); - - - /** - ** Setup output shader - **/ - ctx->header = (struct tgsi_header *)tokens_out; - *ctx->header = tgsi_build_header(); - - processor = (struct tgsi_processor *) (tokens_out + 1); - *processor = tgsi_build_processor( procType, ctx->header ); - - ctx->ti = 2; - - - /** - ** Loop over incoming program tokens/instructions - */ - while( !tgsi_parse_end_of_tokens( &parse ) ) { - - tgsi_parse_token( &parse ); - - switch( parse.FullToken.Token.Type ) { - case TGSI_TOKEN_TYPE_INSTRUCTION: - { - struct tgsi_full_instruction *fullinst - = &parse.FullToken.FullInstruction; - - if (ctx->transform_instruction) - ctx->transform_instruction(ctx, fullinst); - else - ctx->emit_instruction(ctx, fullinst); - } - break; - - case TGSI_TOKEN_TYPE_DECLARATION: - { - struct tgsi_full_declaration *fulldecl - = &parse.FullToken.FullDeclaration; - - if (ctx->transform_declaration) - ctx->transform_declaration(ctx, fulldecl); - else - ctx->emit_declaration(ctx, fulldecl); - } - break; - - case TGSI_TOKEN_TYPE_IMMEDIATE: - { - struct tgsi_full_immediate *fullimm - = &parse.FullToken.FullImmediate; - - if (ctx->transform_immediate) - ctx->transform_immediate(ctx, fullimm); - else - ctx->emit_immediate(ctx, fullimm); - } - break; - case TGSI_TOKEN_TYPE_PROPERTY: - { - struct tgsi_full_property *fullprop - = &parse.FullToken.FullProperty; - - if (ctx->transform_property) - ctx->transform_property(ctx, fullprop); - else - ctx->emit_property(ctx, fullprop); - } - break; - - default: - assert( 0 ); - } - } - - if (ctx->epilog) { - ctx->epilog(ctx); - } - - tgsi_parse_free (&parse); - - return ctx->ti; -} - - -#include "tgsi_text.h" - -extern int tgsi_transform_foo( struct tgsi_token *tokens_out, - uint max_tokens_out ); - -/* This function exists only so that tgsi_text_translate() doesn't get - * magic-ed out of the libtgsi.a archive by the build system. Don't - * remove unless you know this has been fixed - check on mingw/scons - * builds as well. - */ -int -tgsi_transform_foo( struct tgsi_token *tokens_out, - uint max_tokens_out ) -{ - const char *text = - "FRAG\n" - "DCL IN[0], COLOR, CONSTANT\n" - "DCL OUT[0], COLOR\n" - " 0: MOV OUT[0], IN[0]\n" - " 1: END"; - - return tgsi_text_translate( text, - tokens_out, - max_tokens_out ); -} diff --git a/src/gallium/auxiliary/tgsi/tgsi_transform.h b/src/gallium/auxiliary/tgsi/tgsi_transform.h deleted file mode 100644 index 8b96664..0000000 --- a/src/gallium/auxiliary/tgsi/tgsi_transform.h +++ /dev/null @@ -1,96 +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 TGSI_TRANSFORM_H -#define TGSI_TRANSFORM_H - - -#include "pipe/p_shader_tokens.h" -#include "tgsi/tgsi_parse.h" -#include "tgsi/tgsi_build.h" - - - -/** - * Subclass this to add caller-specific data - */ -struct tgsi_transform_context -{ -/**** PUBLIC ***/ - - /** - * User-defined callbacks invoked per instruction. - */ - void (*transform_instruction)(struct tgsi_transform_context *ctx, - struct tgsi_full_instruction *inst); - - void (*transform_declaration)(struct tgsi_transform_context *ctx, - struct tgsi_full_declaration *decl); - - void (*transform_immediate)(struct tgsi_transform_context *ctx, - struct tgsi_full_immediate *imm); - void (*transform_property)(struct tgsi_transform_context *ctx, - struct tgsi_full_property *prop); - - /** - * Called at end of input program to allow caller to append extra - * instructions. Return number of tokens emitted. - */ - void (*epilog)(struct tgsi_transform_context *ctx); - - -/*** PRIVATE ***/ - - /** - * These are setup by tgsi_transform_shader() and cannot be overridden. - * Meant to be called from in the above user callback functions. - */ - void (*emit_instruction)(struct tgsi_transform_context *ctx, - const struct tgsi_full_instruction *inst); - void (*emit_declaration)(struct tgsi_transform_context *ctx, - const struct tgsi_full_declaration *decl); - void (*emit_immediate)(struct tgsi_transform_context *ctx, - const struct tgsi_full_immediate *imm); - void (*emit_property)(struct tgsi_transform_context *ctx, - const struct tgsi_full_property *prop); - - struct tgsi_header *header; - uint max_tokens_out; - struct tgsi_token *tokens_out; - uint ti; -}; - - - -extern int -tgsi_transform_shader(const struct tgsi_token *tokens_in, - struct tgsi_token *tokens_out, - uint max_tokens_out, - struct tgsi_transform_context *ctx); - - -#endif /* TGSI_TRANSFORM_H */ diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c deleted file mode 100644 index ded78c2..0000000 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ /dev/null @@ -1,1736 +0,0 @@ -/************************************************************************** - * - * Copyright 2009-2010 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, INC 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 "pipe/p_context.h" -#include "pipe/p_state.h" -#include "tgsi/tgsi_ureg.h" -#include "tgsi/tgsi_build.h" -#include "tgsi/tgsi_info.h" -#include "tgsi/tgsi_dump.h" -#include "tgsi/tgsi_sanity.h" -#include "util/u_debug.h" -#include "util/u_memory.h" -#include "util/u_math.h" -#include "util/u_bitmask.h" - -union tgsi_any_token { - struct tgsi_header header; - struct tgsi_processor processor; - struct tgsi_token token; - struct tgsi_property prop; - struct tgsi_property_data prop_data; - struct tgsi_declaration decl; - struct tgsi_declaration_range decl_range; - struct tgsi_declaration_dimension decl_dim; - struct tgsi_declaration_interp decl_interp; - struct tgsi_declaration_semantic decl_semantic; - struct tgsi_declaration_sampler_view decl_sampler_view; - struct tgsi_declaration_array array; - struct tgsi_immediate imm; - union tgsi_immediate_data imm_data; - struct tgsi_instruction insn; - struct tgsi_instruction_label insn_label; - struct tgsi_instruction_texture insn_texture; - struct tgsi_texture_offset insn_texture_offset; - struct tgsi_src_register src; - struct tgsi_ind_register ind; - struct tgsi_dimension dim; - struct tgsi_dst_register dst; - unsigned value; -}; - - -struct ureg_tokens { - union tgsi_any_token *tokens; - unsigned size; - unsigned order; - unsigned count; -}; - -#define UREG_MAX_INPUT PIPE_MAX_ATTRIBS -#define UREG_MAX_SYSTEM_VALUE PIPE_MAX_ATTRIBS -#define UREG_MAX_OUTPUT PIPE_MAX_SHADER_OUTPUTS -#define UREG_MAX_CONSTANT_RANGE 32 -#define UREG_MAX_HW_ATOMIC_RANGE 32 -#define UREG_MAX_IMMEDIATE 4096 -#define UREG_MAX_ADDR 3 -#define UREG_MAX_PRED 1 -#define UREG_MAX_ARRAY_TEMPS 256 - -struct const_decl { - struct { - unsigned first; - unsigned last; - } constant_range[UREG_MAX_CONSTANT_RANGE]; - unsigned nr_constant_ranges; -}; - -struct hw_atomic_decl { - struct { - unsigned first; - unsigned last; - unsigned array_id; - } hw_atomic_range[UREG_MAX_HW_ATOMIC_RANGE]; - unsigned nr_hw_atomic_ranges; -}; - -#define DOMAIN_DECL 0 -#define DOMAIN_INSN 1 - -struct ureg_program -{ - unsigned processor; - struct pipe_context *pipe; - - struct { - unsigned semantic_name; - unsigned semantic_index; - unsigned interp; - unsigned char cylindrical_wrap; - unsigned interp_location; - } fs_input[UREG_MAX_INPUT]; - unsigned nr_fs_inputs; - - unsigned vs_inputs[UREG_MAX_INPUT/32]; - - struct { - unsigned index; - unsigned semantic_name; - unsigned semantic_index; - } gs_input[UREG_MAX_INPUT]; - unsigned nr_gs_inputs; - - struct { - unsigned index; - unsigned semantic_name; - unsigned semantic_index; - } system_value[UREG_MAX_SYSTEM_VALUE]; - unsigned nr_system_values; - - struct { - unsigned semantic_name; - unsigned semantic_index; - unsigned usage_mask; /* = TGSI_WRITEMASK_* */ - } output[UREG_MAX_OUTPUT]; - unsigned nr_outputs; - - struct { - union { - float f[4]; - unsigned u[4]; - int i[4]; - } value; - unsigned nr; - unsigned type; - } immediate[UREG_MAX_IMMEDIATE]; - unsigned nr_immediates; - - struct ureg_src sampler[PIPE_MAX_SAMPLERS]; - unsigned nr_samplers; - - struct { - unsigned index; - unsigned target; - unsigned return_type_x; - unsigned return_type_y; - unsigned return_type_z; - unsigned return_type_w; - } sampler_view[PIPE_MAX_SHADER_SAMPLER_VIEWS]; - unsigned nr_sampler_views; - - struct util_bitmask *free_temps; - struct util_bitmask *local_temps; - struct util_bitmask *decl_temps; - unsigned nr_temps; - - unsigned array_temps[UREG_MAX_ARRAY_TEMPS]; - unsigned nr_array_temps; - - struct const_decl const_decls; - struct const_decl const_decls2D[PIPE_MAX_CONSTANT_BUFFERS]; - - struct hw_atomic_decl hw_atomic_decls[PIPE_MAX_HW_ATOMIC_BUFFERS]; - - unsigned properties[TGSI_PROPERTY_COUNT]; - - unsigned nr_addrs; - unsigned nr_preds; - unsigned nr_instructions; - - struct ureg_tokens domain[2]; -}; - -static union tgsi_any_token error_tokens[32]; - -static void tokens_error( struct ureg_tokens *tokens ) -{ - if (tokens->tokens && tokens->tokens != error_tokens) - FREE(tokens->tokens); - - tokens->tokens = error_tokens; - tokens->size = ARRAY_SIZE(error_tokens); - tokens->count = 0; -} - - -static void tokens_expand( struct ureg_tokens *tokens, - unsigned count ) -{ - unsigned old_size = tokens->size * sizeof(unsigned); - - if (tokens->tokens == error_tokens) { - return; - } - - while (tokens->count + count > tokens->size) { - tokens->size = (1 << ++tokens->order); - } - - tokens->tokens = REALLOC(tokens->tokens, - old_size, - tokens->size * sizeof(unsigned)); - if (tokens->tokens == NULL) { - tokens_error(tokens); - } -} - -static void set_bad( struct ureg_program *ureg ) -{ - tokens_error(&ureg->domain[0]); -} - - - -static union tgsi_any_token *get_tokens( struct ureg_program *ureg, - unsigned domain, - unsigned count ) -{ - struct ureg_tokens *tokens = &ureg->domain[domain]; - union tgsi_any_token *result; - - if (tokens->count + count > tokens->size) - tokens_expand(tokens, count); - - result = &tokens->tokens[tokens->count]; - tokens->count += count; - return result; -} - - -static union tgsi_any_token *retrieve_token( struct ureg_program *ureg, - unsigned domain, - unsigned nr ) -{ - if (ureg->domain[domain].tokens == error_tokens) - return &error_tokens[0]; - - return &ureg->domain[domain].tokens[nr]; -} - - - -static inline struct ureg_dst -ureg_dst_register( unsigned file, - unsigned index ) -{ - struct ureg_dst dst; - - dst.File = file; - dst.WriteMask = TGSI_WRITEMASK_XYZW; - dst.Indirect = 0; - dst.IndirectFile = TGSI_FILE_NULL; - dst.IndirectIndex = 0; - dst.IndirectSwizzle = 0; - dst.Saturate = 0; - dst.PredNegate = 0; - dst.PredSwizzleX = TGSI_SWIZZLE_X; - dst.PredSwizzleY = TGSI_SWIZZLE_Y; - dst.PredSwizzleZ = TGSI_SWIZZLE_Z; - dst.PredSwizzleW = TGSI_SWIZZLE_W; - dst.Index = index; - dst.ArrayID = 0; - - return dst; -} - - -void -ureg_property(struct ureg_program *ureg, unsigned name, unsigned value) -{ - assert(name < ARRAY_SIZE(ureg->properties)); - ureg->properties[name] = value; -} - -struct ureg_src -ureg_DECL_fs_input_cyl_centroid(struct ureg_program *ureg, - unsigned semantic_name, - unsigned semantic_index, - unsigned interp_mode, - unsigned cylindrical_wrap, - unsigned interp_location) -{ - unsigned i; - - for (i = 0; i < ureg->nr_fs_inputs; i++) { - if (ureg->fs_input[i].semantic_name == semantic_name && - ureg->fs_input[i].semantic_index == semantic_index) { - goto out; - } - } - - if (ureg->nr_fs_inputs < UREG_MAX_INPUT) { - ureg->fs_input[i].semantic_name = semantic_name; - ureg->fs_input[i].semantic_index = semantic_index; - ureg->fs_input[i].interp = interp_mode; - ureg->fs_input[i].cylindrical_wrap = cylindrical_wrap; - ureg->fs_input[i].interp_location = interp_location; - ureg->nr_fs_inputs++; - } else { - set_bad(ureg); - } - -out: - return ureg_src_register(TGSI_FILE_INPUT, i); -} - - -struct ureg_src -ureg_DECL_vs_input( struct ureg_program *ureg, - unsigned index ) -{ - assert(ureg->processor == TGSI_PROCESSOR_VERTEX); - - ureg->vs_inputs[index/32] |= 1 << (index % 32); - return ureg_src_register( TGSI_FILE_INPUT, index ); -} - - -struct ureg_src -ureg_DECL_gs_input(struct ureg_program *ureg, - unsigned index, - unsigned semantic_name, - unsigned semantic_index) -{ - if (ureg->nr_gs_inputs < UREG_MAX_INPUT) { - ureg->gs_input[ureg->nr_gs_inputs].index = index; - ureg->gs_input[ureg->nr_gs_inputs].semantic_name = semantic_name; - ureg->gs_input[ureg->nr_gs_inputs].semantic_index = semantic_index; - ureg->nr_gs_inputs++; - } else { - set_bad(ureg); - } - - /* XXX: Add suport for true 2D input registers. */ - return ureg_src_register(TGSI_FILE_INPUT, index); -} - - -struct ureg_src -ureg_DECL_system_value(struct ureg_program *ureg, - unsigned index, - unsigned semantic_name, - unsigned semantic_index) -{ - if (ureg->nr_system_values < UREG_MAX_SYSTEM_VALUE) { - ureg->system_value[ureg->nr_system_values].index = index; - ureg->system_value[ureg->nr_system_values].semantic_name = semantic_name; - ureg->system_value[ureg->nr_system_values].semantic_index = semantic_index; - ureg->nr_system_values++; - } else { - set_bad(ureg); - } - - return ureg_src_register(TGSI_FILE_SYSTEM_VALUE, index); -} - - -struct ureg_dst -ureg_DECL_output_masked( struct ureg_program *ureg, - unsigned name, - unsigned index, - unsigned usage_mask ) -{ - unsigned i; - - assert(usage_mask != 0); - - for (i = 0; i < ureg->nr_outputs; i++) { - if (ureg->output[i].semantic_name == name && - ureg->output[i].semantic_index == index) { - ureg->output[i].usage_mask |= usage_mask; - goto out; - } - } - - if (ureg->nr_outputs < UREG_MAX_OUTPUT) { - ureg->output[i].semantic_name = name; - ureg->output[i].semantic_index = index; - ureg->output[i].usage_mask = usage_mask; - ureg->nr_outputs++; - } - else { - set_bad( ureg ); - } - -out: - return ureg_dst_register( TGSI_FILE_OUTPUT, i ); -} - - -struct ureg_dst -ureg_DECL_output( struct ureg_program *ureg, - unsigned name, - unsigned index ) -{ - return ureg_DECL_output_masked(ureg, name, index, TGSI_WRITEMASK_XYZW); -} - - -/* Returns a new constant register. Keep track of which have been - * referred to so that we can emit decls later. - * - * Constant operands declared with this function must be addressed - * with a two-dimensional index. - * - * There is nothing in this code to bind this constant to any tracked - * value or manage any constant_buffer contents -- that's the - * resposibility of the calling code. - */ -void -ureg_DECL_constant2D(struct ureg_program *ureg, - unsigned first, - unsigned last, - unsigned index2D) -{ - struct const_decl *decl = &ureg->const_decls2D[index2D]; - - assert(index2D < PIPE_MAX_CONSTANT_BUFFERS); - - if (decl->nr_constant_ranges < UREG_MAX_CONSTANT_RANGE) { - uint i = decl->nr_constant_ranges++; - - decl->constant_range[i].first = first; - decl->constant_range[i].last = last; - } -} - - -/* A one-dimensional, depricated version of ureg_DECL_constant2D(). - * - * Constant operands declared with this function must be addressed - * with a one-dimensional index. - */ -struct ureg_src -ureg_DECL_constant(struct ureg_program *ureg, - unsigned index) -{ - struct const_decl *decl = &ureg->const_decls; - unsigned minconst = index, maxconst = index; - unsigned i; - - /* Inside existing range? - */ - for (i = 0; i < decl->nr_constant_ranges; i++) { - if (decl->constant_range[i].first <= index && - decl->constant_range[i].last >= index) { - goto out; - } - } - - /* Extend existing range? - */ - for (i = 0; i < decl->nr_constant_ranges; i++) { - if (decl->constant_range[i].last == index - 1) { - decl->constant_range[i].last = index; - goto out; - } - - if (decl->constant_range[i].first == index + 1) { - decl->constant_range[i].first = index; - goto out; - } - - minconst = MIN2(minconst, decl->constant_range[i].first); - maxconst = MAX2(maxconst, decl->constant_range[i].last); - } - - /* Create new range? - */ - if (decl->nr_constant_ranges < UREG_MAX_CONSTANT_RANGE) { - i = decl->nr_constant_ranges++; - decl->constant_range[i].first = index; - decl->constant_range[i].last = index; - goto out; - } - - /* Collapse all ranges down to one: - */ - i = 0; - decl->constant_range[0].first = minconst; - decl->constant_range[0].last = maxconst; - decl->nr_constant_ranges = 1; - -out: - assert(i < decl->nr_constant_ranges); - assert(decl->constant_range[i].first <= index); - assert(decl->constant_range[i].last >= index); - return ureg_src_register(TGSI_FILE_CONSTANT, index); -} - - -/* Returns a new hw atomic register. Keep track of which have been - * referred to so that we can emit decls later. - */ -void -ureg_DECL_hw_atomic(struct ureg_program *ureg, - unsigned first, - unsigned last, - unsigned buffer_id, - unsigned array_id) -{ - struct hw_atomic_decl *decl = &ureg->hw_atomic_decls[buffer_id]; - - if (decl->nr_hw_atomic_ranges < UREG_MAX_HW_ATOMIC_RANGE) { - uint i = decl->nr_hw_atomic_ranges++; - - decl->hw_atomic_range[i].first = first; - decl->hw_atomic_range[i].last = last; - decl->hw_atomic_range[i].array_id = array_id; - } else { - set_bad(ureg); - } -} - -static struct ureg_dst alloc_temporary( struct ureg_program *ureg, - boolean local ) -{ - unsigned i; - - /* Look for a released temporary. - */ - for (i = util_bitmask_get_first_index(ureg->free_temps); - i != UTIL_BITMASK_INVALID_INDEX; - i = util_bitmask_get_next_index(ureg->free_temps, i + 1)) { - if (util_bitmask_get(ureg->local_temps, i) == local) - break; - } - - /* Or allocate a new one. - */ - if (i == UTIL_BITMASK_INVALID_INDEX) { - i = ureg->nr_temps++; - - if (local) - util_bitmask_set(ureg->local_temps, i); - - /* Start a new declaration when the local flag changes */ - if (!i || util_bitmask_get(ureg->local_temps, i - 1) != local) - util_bitmask_set(ureg->decl_temps, i); - } - - util_bitmask_clear(ureg->free_temps, i); - - return ureg_dst_register( TGSI_FILE_TEMPORARY, i ); -} - -struct ureg_dst ureg_DECL_temporary( struct ureg_program *ureg ) -{ - return alloc_temporary(ureg, FALSE); -} - -struct ureg_dst ureg_DECL_local_temporary( struct ureg_program *ureg ) -{ - return alloc_temporary(ureg, TRUE); -} - -struct ureg_dst ureg_DECL_array_temporary( struct ureg_program *ureg, - unsigned size, - boolean local ) -{ - unsigned i = ureg->nr_temps; - struct ureg_dst dst = ureg_dst_register( TGSI_FILE_TEMPORARY, i ); - - if (local) - util_bitmask_set(ureg->local_temps, i); - - /* Always start a new declaration at the start */ - util_bitmask_set(ureg->decl_temps, i); - - ureg->nr_temps += size; - - /* and also at the end of the array */ - util_bitmask_set(ureg->decl_temps, ureg->nr_temps); - - if (ureg->nr_array_temps < UREG_MAX_ARRAY_TEMPS) { - ureg->array_temps[ureg->nr_array_temps++] = i; - dst.ArrayID = ureg->nr_array_temps; - } - - return dst; -} - -void ureg_release_temporary( struct ureg_program *ureg, - struct ureg_dst tmp ) -{ - if(tmp.File == TGSI_FILE_TEMPORARY) - util_bitmask_set(ureg->free_temps, tmp.Index); -} - - -/* Allocate a new address register. - */ -struct ureg_dst ureg_DECL_address( struct ureg_program *ureg ) -{ - if (ureg->nr_addrs < UREG_MAX_ADDR) - return ureg_dst_register( TGSI_FILE_ADDRESS, ureg->nr_addrs++ ); - - assert( 0 ); - return ureg_dst_register( TGSI_FILE_ADDRESS, 0 ); -} - -/* Allocate a new predicate register. - */ -struct ureg_dst -ureg_DECL_predicate(struct ureg_program *ureg) -{ - if (ureg->nr_preds < UREG_MAX_PRED) { - return ureg_dst_register(TGSI_FILE_PREDICATE, ureg->nr_preds++); - } - - assert(0); - return ureg_dst_register(TGSI_FILE_PREDICATE, 0); -} - -/* Allocate a new sampler. - */ -struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg, - int nr ) -{ - unsigned i; - - for (i = 0; i < ureg->nr_samplers; i++) - if (ureg->sampler[i].Index == nr) - return ureg->sampler[i]; - - if (i < PIPE_MAX_SAMPLERS) { - ureg->sampler[i] = ureg_src_register( TGSI_FILE_SAMPLER, nr ); - ureg->nr_samplers++; - return ureg->sampler[i]; - } - - assert( 0 ); - return ureg->sampler[0]; -} - -/* - * Allocate a new shader sampler view. - */ -struct ureg_src -ureg_DECL_sampler_view(struct ureg_program *ureg, - unsigned index, - unsigned target, - unsigned return_type_x, - unsigned return_type_y, - unsigned return_type_z, - unsigned return_type_w) -{ - struct ureg_src reg = ureg_src_register(TGSI_FILE_SAMPLER_VIEW, index); - uint i; - - for (i = 0; i < ureg->nr_sampler_views; i++) { - if (ureg->sampler_view[i].index == index) { - return reg; - } - } - - if (i < PIPE_MAX_SHADER_SAMPLER_VIEWS) { - ureg->sampler_view[i].index = index; - ureg->sampler_view[i].target = target; - ureg->sampler_view[i].return_type_x = return_type_x; - ureg->sampler_view[i].return_type_y = return_type_y; - ureg->sampler_view[i].return_type_z = return_type_z; - ureg->sampler_view[i].return_type_w = return_type_w; - ureg->nr_sampler_views++; - return reg; - } - - assert(0); - return reg; -} - -static int -match_or_expand_immediate( const unsigned *v, - unsigned nr, - unsigned *v2, - unsigned *pnr2, - unsigned *swizzle ) -{ - unsigned nr2 = *pnr2; - unsigned i, j; - - *swizzle = 0; - - for (i = 0; i < nr; i++) { - boolean found = FALSE; - - for (j = 0; j < nr2 && !found; j++) { - if (v[i] == v2[j]) { - *swizzle |= j << (i * 2); - found = TRUE; - } - } - - if (!found) { - if (nr2 >= 4) { - return FALSE; - } - - v2[nr2] = v[i]; - *swizzle |= nr2 << (i * 2); - nr2++; - } - } - - /* Actually expand immediate only when fully succeeded. - */ - *pnr2 = nr2; - return TRUE; -} - - -static struct ureg_src -decl_immediate( struct ureg_program *ureg, - const unsigned *v, - unsigned nr, - unsigned type ) -{ - unsigned i, j; - unsigned swizzle = 0; - - /* Could do a first pass where we examine all existing immediates - * without expanding. - */ - - for (i = 0; i < ureg->nr_immediates; i++) { - if (ureg->immediate[i].type != type) { - continue; - } - if (match_or_expand_immediate(v, - nr, - ureg->immediate[i].value.u, - &ureg->immediate[i].nr, - &swizzle)) { - goto out; - } - } - - if (ureg->nr_immediates < UREG_MAX_IMMEDIATE) { - i = ureg->nr_immediates++; - ureg->immediate[i].type = type; - if (match_or_expand_immediate(v, - nr, - ureg->immediate[i].value.u, - &ureg->immediate[i].nr, - &swizzle)) { - goto out; - } - } - - set_bad(ureg); - -out: - /* Make sure that all referenced elements are from this immediate. - * Has the effect of making size-one immediates into scalars. - */ - for (j = nr; j < 4; j++) { - swizzle |= (swizzle & 0x3) << (j * 2); - } - - return ureg_swizzle(ureg_src_register(TGSI_FILE_IMMEDIATE, i), - (swizzle >> 0) & 0x3, - (swizzle >> 2) & 0x3, - (swizzle >> 4) & 0x3, - (swizzle >> 6) & 0x3); -} - - -struct ureg_src -ureg_DECL_immediate( struct ureg_program *ureg, - const float *v, - unsigned nr ) -{ - union { - float f[4]; - unsigned u[4]; - } fu; - unsigned int i; - - for (i = 0; i < nr; i++) { - fu.f[i] = v[i]; - } - - return decl_immediate(ureg, fu.u, nr, TGSI_IMM_FLOAT32); -} - - -struct ureg_src -ureg_DECL_immediate_uint( struct ureg_program *ureg, - const unsigned *v, - unsigned nr ) -{ - return decl_immediate(ureg, v, nr, TGSI_IMM_UINT32); -} - - -struct ureg_src -ureg_DECL_immediate_block_uint( struct ureg_program *ureg, - const unsigned *v, - unsigned nr ) -{ - uint index; - uint i; - - if (ureg->nr_immediates + (nr + 3) / 4 > UREG_MAX_IMMEDIATE) { - set_bad(ureg); - return ureg_src_register(TGSI_FILE_IMMEDIATE, 0); - } - - index = ureg->nr_immediates; - ureg->nr_immediates += (nr + 3) / 4; - - for (i = index; i < ureg->nr_immediates; i++) { - ureg->immediate[i].type = TGSI_IMM_UINT32; - ureg->immediate[i].nr = nr > 4 ? 4 : nr; - memcpy(ureg->immediate[i].value.u, - &v[(i - index) * 4], - ureg->immediate[i].nr * sizeof(uint)); - nr -= 4; - } - - return ureg_src_register(TGSI_FILE_IMMEDIATE, index); -} - - -struct ureg_src -ureg_DECL_immediate_int( struct ureg_program *ureg, - const int *v, - unsigned nr ) -{ - return decl_immediate(ureg, (const unsigned *)v, nr, TGSI_IMM_INT32); -} - - -void -ureg_emit_src( struct ureg_program *ureg, - struct ureg_src src ) -{ - unsigned size = 1 + (src.Indirect ? 1 : 0) + - (src.Dimension ? (src.DimIndirect ? 2 : 1) : 0); - - union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size ); - unsigned n = 0; - - assert(src.File != TGSI_FILE_NULL); - assert(src.File < TGSI_FILE_COUNT); - - out[n].value = 0; - out[n].src.File = src.File; - out[n].src.SwizzleX = src.SwizzleX; - out[n].src.SwizzleY = src.SwizzleY; - out[n].src.SwizzleZ = src.SwizzleZ; - out[n].src.SwizzleW = src.SwizzleW; - out[n].src.Index = src.Index; - out[n].src.Negate = src.Negate; - out[0].src.Absolute = src.Absolute; - n++; - - if (src.Indirect) { - out[0].src.Indirect = 1; - out[n].value = 0; - out[n].ind.File = src.IndirectFile; - out[n].ind.Swizzle = src.IndirectSwizzle; - out[n].ind.Index = src.IndirectIndex; - out[n].ind.ArrayID = src.ArrayID; - n++; - } - - if (src.Dimension) { - out[0].src.Dimension = 1; - out[n].dim.Dimension = 0; - out[n].dim.Padding = 0; - if (src.DimIndirect) { - out[n].dim.Indirect = 1; - out[n].dim.Index = src.DimensionIndex; - n++; - out[n].value = 0; - out[n].ind.File = src.DimIndFile; - out[n].ind.Swizzle = src.DimIndSwizzle; - out[n].ind.Index = src.DimIndIndex; - out[n].ind.ArrayID = src.ArrayID; - } else { - out[n].dim.Indirect = 0; - out[n].dim.Index = src.DimensionIndex; - } - n++; - } - - assert(n == size); -} - - -void -ureg_emit_dst( struct ureg_program *ureg, - struct ureg_dst dst ) -{ - unsigned size = (1 + - (dst.Indirect ? 1 : 0)); - - union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size ); - unsigned n = 0; - - assert(dst.File != TGSI_FILE_NULL); - assert(dst.File != TGSI_FILE_CONSTANT); - assert(dst.File != TGSI_FILE_INPUT); - assert(dst.File != TGSI_FILE_SAMPLER); - assert(dst.File != TGSI_FILE_SAMPLER_VIEW); - assert(dst.File != TGSI_FILE_IMMEDIATE); - assert(dst.File < TGSI_FILE_COUNT); - - out[n].value = 0; - out[n].dst.File = dst.File; - out[n].dst.WriteMask = dst.WriteMask; - out[n].dst.Indirect = dst.Indirect; - out[n].dst.Index = dst.Index; - n++; - - if (dst.Indirect) { - out[n].value = 0; - out[n].ind.File = dst.IndirectFile; - out[n].ind.Swizzle = dst.IndirectSwizzle; - out[n].ind.Index = dst.IndirectIndex; - out[n].ind.ArrayID = dst.ArrayID; - n++; - } - - assert(n == size); -} - - -static void validate( unsigned opcode, - unsigned nr_dst, - unsigned nr_src ) -{ -#ifdef DEBUG - const struct tgsi_opcode_info *info = tgsi_get_opcode_info( opcode ); - assert(info); - if(info) { - assert(nr_dst == info->num_dst); - assert(nr_src == info->num_src); - } -#else - (void)opcode; - (void)nr_dst; - (void)nr_src; -#endif -} - -struct ureg_emit_insn_result -ureg_emit_insn(struct ureg_program *ureg, - unsigned opcode, - boolean saturate, - unsigned precise, - unsigned num_dst, - unsigned num_src ) -{ - union tgsi_any_token *out; - uint count = 1; - struct ureg_emit_insn_result result; - - validate( opcode, num_dst, num_src ); - - out = get_tokens( ureg, DOMAIN_INSN, count ); - out[0].insn = tgsi_default_instruction(); - out[0].insn.Opcode = opcode; - out[0].insn.Saturate = saturate; - out[0].insn.Precise = precise; - out[0].insn.NumDstRegs = num_dst; - out[0].insn.NumSrcRegs = num_src; - - result.insn_token = ureg->domain[DOMAIN_INSN].count - count; - result.extended_token = result.insn_token; - - ureg->nr_instructions++; - - return result; -} - - -void -ureg_emit_label(struct ureg_program *ureg, - unsigned extended_token, - unsigned *label_token ) -{ - union tgsi_any_token *out, *insn; - - if(!label_token) - return; - - out = get_tokens( ureg, DOMAIN_INSN, 1 ); - out[0].value = 0; - - insn = retrieve_token( ureg, DOMAIN_INSN, extended_token ); - insn->insn.Label = 1; - - *label_token = ureg->domain[DOMAIN_INSN].count - 1; -} - -/* Will return a number which can be used in a label to point to the - * next instruction to be emitted. - */ -unsigned -ureg_get_instruction_number( struct ureg_program *ureg ) -{ - return ureg->nr_instructions; -} - -/* Patch a given label (expressed as a token number) to point to a - * given instruction (expressed as an instruction number). - */ -void -ureg_fixup_label(struct ureg_program *ureg, - unsigned label_token, - unsigned instruction_number ) -{ - union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_INSN, label_token ); - - out->insn_label.Label = instruction_number; -} - - -void -ureg_emit_texture(struct ureg_program *ureg, - unsigned extended_token, - unsigned target, unsigned num_offsets) -{ - union tgsi_any_token *out, *insn; - - out = get_tokens( ureg, DOMAIN_INSN, 1 ); - insn = retrieve_token( ureg, DOMAIN_INSN, extended_token ); - - insn->insn.Texture = 1; - - out[0].value = 0; - out[0].insn_texture.Texture = target; - out[0].insn_texture.NumOffsets = num_offsets; -} - -void -ureg_emit_texture_offset(struct ureg_program *ureg, - const struct tgsi_texture_offset *offset) -{ - union tgsi_any_token *out; - - out = get_tokens( ureg, DOMAIN_INSN, 1); - - out[0].value = 0; - out[0].insn_texture_offset = *offset; - -} - - -void -ureg_fixup_insn_size(struct ureg_program *ureg, - unsigned insn ) -{ - union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_INSN, insn ); - - assert(out->insn.Type == TGSI_TOKEN_TYPE_INSTRUCTION); - out->insn.NrTokens = ureg->domain[DOMAIN_INSN].count - insn - 1; -} - - -void -ureg_insn(struct ureg_program *ureg, - unsigned opcode, - const struct ureg_dst *dst, - unsigned nr_dst, - const struct ureg_src *src, - unsigned nr_src, - unsigned precise ) -{ - struct ureg_emit_insn_result insn; - unsigned i; - boolean saturate; - - if (nr_dst && ureg_dst_is_empty(dst[0])) { - return; - } - - saturate = nr_dst ? dst[0].Saturate : FALSE; - - insn = ureg_emit_insn(ureg, - opcode, - saturate, - precise, - nr_dst, - nr_src); - - for (i = 0; i < nr_dst; i++) - ureg_emit_dst( ureg, dst[i] ); - - for (i = 0; i < nr_src; i++) - ureg_emit_src( ureg, src[i] ); - - ureg_fixup_insn_size( ureg, insn.insn_token ); -} - -void -ureg_tex_insn(struct ureg_program *ureg, - unsigned opcode, - const struct ureg_dst *dst, - unsigned nr_dst, - unsigned target, - const struct tgsi_texture_offset *texoffsets, - unsigned nr_offset, - const struct ureg_src *src, - unsigned nr_src ) -{ - struct ureg_emit_insn_result insn; - unsigned i; - boolean saturate; - - if (nr_dst && ureg_dst_is_empty(dst[0])) { - return; - } - - saturate = nr_dst ? dst[0].Saturate : FALSE; - - insn = ureg_emit_insn(ureg, - opcode, - saturate, - 0, - nr_dst, - nr_src); - - ureg_emit_texture( ureg, insn.extended_token, target, nr_offset ); - - for (i = 0; i < nr_offset; i++) - ureg_emit_texture_offset( ureg, &texoffsets[i]); - - for (i = 0; i < nr_dst; i++) - ureg_emit_dst( ureg, dst[i] ); - - for (i = 0; i < nr_src; i++) - ureg_emit_src( ureg, src[i] ); - - ureg_fixup_insn_size( ureg, insn.insn_token ); -} - - -void -ureg_label_insn(struct ureg_program *ureg, - unsigned opcode, - const struct ureg_src *src, - unsigned nr_src, - unsigned *label_token ) -{ - struct ureg_emit_insn_result insn; - unsigned i; - - insn = ureg_emit_insn(ureg, - opcode, - FALSE, - 0, - 0, - nr_src); - - ureg_emit_label( ureg, insn.extended_token, label_token ); - - for (i = 0; i < nr_src; i++) - ureg_emit_src( ureg, src[i] ); - - ureg_fixup_insn_size( ureg, insn.insn_token ); -} - - -static void -emit_decl_semantic(struct ureg_program *ureg, - unsigned file, - unsigned index, - unsigned semantic_name, - unsigned semantic_index, - unsigned usage_mask) -{ - union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3); - - out[0].value = 0; - out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; - out[0].decl.NrTokens = 3; - out[0].decl.File = file; - out[0].decl.UsageMask = usage_mask; - out[0].decl.Semantic = 1; - - out[1].value = 0; - out[1].decl_range.First = index; - out[1].decl_range.Last = index; - - out[2].value = 0; - out[2].decl_semantic.Name = semantic_name; - out[2].decl_semantic.Index = semantic_index; -} - - -static void -emit_decl_fs(struct ureg_program *ureg, - unsigned file, - unsigned index, - unsigned semantic_name, - unsigned semantic_index, - unsigned interpolate, - unsigned cylindrical_wrap, - unsigned interpolate_location) -{ - union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 4); - - out[0].value = 0; - out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; - out[0].decl.NrTokens = 4; - out[0].decl.File = file; - out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; /* FIXME! */ - out[0].decl.Interpolate = 1; - out[0].decl.Semantic = 1; - - out[1].value = 0; - out[1].decl_range.First = index; - out[1].decl_range.Last = index; - - out[2].value = 0; - out[2].decl_interp.Interpolate = interpolate; - out[2].decl_interp.CylindricalWrap = cylindrical_wrap; - out[2].decl_interp.Location = interpolate_location; - - out[3].value = 0; - out[3].decl_semantic.Name = semantic_name; - out[3].decl_semantic.Index = semantic_index; -} - -static void -emit_decl_temps( struct ureg_program *ureg, - unsigned first, unsigned last, - boolean local, - unsigned arrayid ) -{ - union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, - arrayid ? 3 : 2 ); - - out[0].value = 0; - out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; - out[0].decl.NrTokens = 2; - out[0].decl.File = TGSI_FILE_TEMPORARY; - out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; - out[0].decl.Local = local; - - out[1].value = 0; - out[1].decl_range.First = first; - out[1].decl_range.Last = last; - - if (arrayid) { - out[0].decl.Array = 1; - out[2].value = 0; - out[2].array.ArrayID = arrayid; - } -} - -static void emit_decl_range( struct ureg_program *ureg, - unsigned file, - unsigned first, - unsigned count ) -{ - union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 ); - - out[0].value = 0; - out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; - out[0].decl.NrTokens = 2; - out[0].decl.File = file; - out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; - out[0].decl.Semantic = 0; - - out[1].value = 0; - out[1].decl_range.First = first; - out[1].decl_range.Last = first + count - 1; -} - -static void -emit_decl_range2D(struct ureg_program *ureg, - unsigned file, - unsigned first, - unsigned last, - unsigned index2D) -{ - union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3); - - out[0].value = 0; - out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; - out[0].decl.NrTokens = 3; - out[0].decl.File = file; - out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; - out[0].decl.Dimension = 1; - - out[1].value = 0; - out[1].decl_range.First = first; - out[1].decl_range.Last = last; - - out[2].value = 0; - out[2].decl_dim.Index2D = index2D; -} - -static void -emit_decl_sampler_view(struct ureg_program *ureg, - unsigned index, - unsigned target, - unsigned return_type_x, - unsigned return_type_y, - unsigned return_type_z, - unsigned return_type_w ) -{ - union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3); - - out[0].value = 0; - out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; - out[0].decl.NrTokens = 3; - out[0].decl.File = TGSI_FILE_SAMPLER_VIEW; - out[0].decl.UsageMask = 0xf; - - out[1].value = 0; - out[1].decl_range.First = index; - out[1].decl_range.Last = index; - - out[2].value = 0; - out[2].decl_sampler_view.Resource = target; - out[2].decl_sampler_view.ReturnTypeX = return_type_x; - out[2].decl_sampler_view.ReturnTypeY = return_type_y; - out[2].decl_sampler_view.ReturnTypeZ = return_type_z; - out[2].decl_sampler_view.ReturnTypeW = return_type_w; -} - -static void -emit_immediate( struct ureg_program *ureg, - const unsigned *v, - unsigned type ) -{ - union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 5 ); - - out[0].value = 0; - out[0].imm.Type = TGSI_TOKEN_TYPE_IMMEDIATE; - out[0].imm.NrTokens = 5; - out[0].imm.DataType = type; - out[0].imm.Padding = 0; - - out[1].imm_data.Uint = v[0]; - out[2].imm_data.Uint = v[1]; - out[3].imm_data.Uint = v[2]; - out[4].imm_data.Uint = v[3]; -} - -static void -emit_property(struct ureg_program *ureg, - unsigned name, - unsigned data) -{ - union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 2); - - out[0].value = 0; - out[0].prop.Type = TGSI_TOKEN_TYPE_PROPERTY; - out[0].prop.NrTokens = 2; - out[0].prop.PropertyName = name; - - out[1].prop_data.Data = data; -} - -static void -emit_decl_atomic_2d(struct ureg_program *ureg, - unsigned first, - unsigned last, - unsigned index2D, - unsigned array_id) -{ - union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, array_id ? 4 : 3); - - out[0].value = 0; - out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; - out[0].decl.NrTokens = 3; - out[0].decl.File = TGSI_FILE_HW_ATOMIC; - out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; - out[0].decl.Dimension = 1; - out[0].decl.Array = array_id != 0; - - out[1].value = 0; - out[1].decl_range.First = first; - out[1].decl_range.Last = last; - - out[2].value = 0; - out[2].decl_dim.Index2D = index2D; - - if (array_id) { - out[3].value = 0; - out[3].array.ArrayID = array_id; - } -} - -static void emit_decls( struct ureg_program *ureg ) -{ - unsigned i; - - for (i = 0; i < ARRAY_SIZE(ureg->properties); i++) - if (ureg->properties[i] != ~0u) - emit_property(ureg, i, ureg->properties[i]); - - if (ureg->processor == TGSI_PROCESSOR_VERTEX) { - for (i = 0; i < UREG_MAX_INPUT; i++) { - if (ureg->vs_inputs[i/32] & (1 << (i%32))) { - emit_decl_range( ureg, TGSI_FILE_INPUT, i, 1 ); - } - } - } else if (ureg->processor == TGSI_PROCESSOR_FRAGMENT) { - for (i = 0; i < ureg->nr_fs_inputs; i++) { - emit_decl_fs(ureg, - TGSI_FILE_INPUT, - i, - ureg->fs_input[i].semantic_name, - ureg->fs_input[i].semantic_index, - ureg->fs_input[i].interp, - ureg->fs_input[i].cylindrical_wrap, - ureg->fs_input[i].interp_location); - } - } else { - for (i = 0; i < ureg->nr_gs_inputs; i++) { - emit_decl_semantic(ureg, - TGSI_FILE_INPUT, - ureg->gs_input[i].index, - ureg->gs_input[i].semantic_name, - ureg->gs_input[i].semantic_index, - TGSI_WRITEMASK_XYZW); - } - } - - for (i = 0; i < ureg->nr_system_values; i++) { - emit_decl_semantic(ureg, - TGSI_FILE_SYSTEM_VALUE, - ureg->system_value[i].index, - ureg->system_value[i].semantic_name, - ureg->system_value[i].semantic_index, - TGSI_WRITEMASK_XYZW); - } - - for (i = 0; i < ureg->nr_outputs; i++) { - emit_decl_semantic(ureg, - TGSI_FILE_OUTPUT, - i, - ureg->output[i].semantic_name, - ureg->output[i].semantic_index, - ureg->output[i].usage_mask); - } - - for (i = 0; i < ureg->nr_samplers; i++) { - emit_decl_range( ureg, - TGSI_FILE_SAMPLER, - ureg->sampler[i].Index, 1 ); - } - - for (i = 0; i < ureg->nr_sampler_views; i++) { - emit_decl_sampler_view(ureg, - ureg->sampler_view[i].index, - ureg->sampler_view[i].target, - ureg->sampler_view[i].return_type_x, - ureg->sampler_view[i].return_type_y, - ureg->sampler_view[i].return_type_z, - ureg->sampler_view[i].return_type_w); - } - - if (ureg->const_decls.nr_constant_ranges) { - for (i = 0; i < ureg->const_decls.nr_constant_ranges; i++) { - emit_decl_range(ureg, - TGSI_FILE_CONSTANT, - ureg->const_decls.constant_range[i].first, - ureg->const_decls.constant_range[i].last - ureg->const_decls.constant_range[i].first + 1); - } - } - - for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { - struct const_decl *decl = &ureg->const_decls2D[i]; - - if (decl->nr_constant_ranges) { - uint j; - - for (j = 0; j < decl->nr_constant_ranges; j++) { - emit_decl_range2D(ureg, - TGSI_FILE_CONSTANT, - decl->constant_range[j].first, - decl->constant_range[j].last, - i); - } - } - } - - for (i = 0; i < PIPE_MAX_HW_ATOMIC_BUFFERS; i++) { - struct hw_atomic_decl *decl = &ureg->hw_atomic_decls[i]; - - if (decl->nr_hw_atomic_ranges) { - uint j; - - for (j = 0; j < decl->nr_hw_atomic_ranges; j++) { - emit_decl_atomic_2d(ureg, - decl->hw_atomic_range[j].first, - decl->hw_atomic_range[j].last, - i, - decl->hw_atomic_range[j].array_id); - } - } - } - - if (ureg->nr_temps) { - unsigned array = 0; - for (i = 0; i < ureg->nr_temps;) { - boolean local = util_bitmask_get(ureg->local_temps, i); - unsigned first = i; - i = util_bitmask_get_next_index(ureg->decl_temps, i + 1); - if (i == UTIL_BITMASK_INVALID_INDEX) - i = ureg->nr_temps; - - if (array < ureg->nr_array_temps && ureg->array_temps[array] == first) - emit_decl_temps( ureg, first, i - 1, local, ++array ); - else - emit_decl_temps( ureg, first, i - 1, local, 0 ); - } - } - - if (ureg->nr_addrs) { - emit_decl_range( ureg, - TGSI_FILE_ADDRESS, - 0, ureg->nr_addrs ); - } - - if (ureg->nr_preds) { - emit_decl_range(ureg, - TGSI_FILE_PREDICATE, - 0, - ureg->nr_preds); - } - - for (i = 0; i < ureg->nr_immediates; i++) { - emit_immediate( ureg, - ureg->immediate[i].value.u, - ureg->immediate[i].type ); - } -} - -/* Append the instruction tokens onto the declarations to build a - * contiguous stream suitable to send to the driver. - */ -static void copy_instructions( struct ureg_program *ureg ) -{ - unsigned nr_tokens = ureg->domain[DOMAIN_INSN].count; - union tgsi_any_token *out = get_tokens( ureg, - DOMAIN_DECL, - nr_tokens ); - - memcpy(out, - ureg->domain[DOMAIN_INSN].tokens, - nr_tokens * sizeof out[0] ); -} - -static void -fixup_header_size(struct ureg_program *ureg) -{ - union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_DECL, 0 ); - - out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 2; -} - - -static void -emit_header( struct ureg_program *ureg ) -{ - union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 ); - - out[0].header.HeaderSize = 2; - out[0].header.BodySize = 0; - - out[1].processor.Processor = ureg->processor; - out[1].processor.Padding = 0; -} - - -const struct tgsi_token *ureg_finalize( struct ureg_program *ureg ) -{ - const struct tgsi_token *tokens; - - emit_header( ureg ); - emit_decls( ureg ); - copy_instructions( ureg ); - fixup_header_size( ureg ); - - if (ureg->domain[0].tokens == error_tokens || - ureg->domain[1].tokens == error_tokens) { - debug_printf("%s: error in generated shader\n", __FUNCTION__); - assert(0); - return NULL; - } - - tokens = &ureg->domain[DOMAIN_DECL].tokens[0].token; - - if (0) { - debug_printf("%s: emitted shader %d tokens:\n", __FUNCTION__, - ureg->domain[DOMAIN_DECL].count); - tgsi_dump( tokens, 0 ); - } - -#if DEBUG - if (tokens && !tgsi_sanity_check(tokens)) { - debug_printf("tgsi_ureg.c, sanity check failed on generated tokens:\n"); - tgsi_dump(tokens, 0); - assert(0); - } -#endif - - - return tokens; -} - - -void *ureg_create_shader( struct ureg_program *ureg, - struct pipe_context *pipe, - const struct pipe_stream_output_info *so ) -{ - struct pipe_shader_state state; - - state.tokens = ureg_finalize(ureg); - if(!state.tokens) - return NULL; - - if (so) - state.stream_output = *so; - else - memset(&state.stream_output, 0, sizeof(state.stream_output)); - - if (ureg->processor == TGSI_PROCESSOR_VERTEX) - return pipe->create_vs_state( pipe, &state ); - else - return pipe->create_fs_state( pipe, &state ); -} - - -const struct tgsi_token *ureg_get_tokens( struct ureg_program *ureg, - unsigned *nr_tokens ) -{ - const struct tgsi_token *tokens; - - ureg_finalize(ureg); - - tokens = &ureg->domain[DOMAIN_DECL].tokens[0].token; - - if (nr_tokens) - *nr_tokens = ureg->domain[DOMAIN_DECL].size; - - ureg->domain[DOMAIN_DECL].tokens = 0; - ureg->domain[DOMAIN_DECL].size = 0; - ureg->domain[DOMAIN_DECL].order = 0; - ureg->domain[DOMAIN_DECL].count = 0; - - return tokens; -} - - -void ureg_free_tokens( const struct tgsi_token *tokens ) -{ - FREE((struct tgsi_token *)tokens); -} - - -struct ureg_program *ureg_create( unsigned processor ) -{ - unsigned i; - struct ureg_program *ureg = CALLOC_STRUCT( ureg_program ); - if (ureg == NULL) - goto no_ureg; - - ureg->processor = processor; - - for (i = 0; i < ARRAY_SIZE(ureg->properties); i++) - ureg->properties[i] = ~0; - - ureg->free_temps = util_bitmask_create(); - if (ureg->free_temps == NULL) - goto no_free_temps; - - ureg->local_temps = util_bitmask_create(); - if (ureg->local_temps == NULL) - goto no_local_temps; - - ureg->decl_temps = util_bitmask_create(); - if (ureg->decl_temps == NULL) - goto no_decl_temps; - - return ureg; - -no_decl_temps: - util_bitmask_destroy(ureg->local_temps); -no_local_temps: - util_bitmask_destroy(ureg->free_temps); -no_free_temps: - FREE(ureg); -no_ureg: - return NULL; -} - - -unsigned -ureg_get_nr_outputs( const struct ureg_program *ureg ) -{ - if (!ureg) - return 0; - return ureg->nr_outputs; -} - - -void ureg_destroy( struct ureg_program *ureg ) -{ - unsigned i; - - for (i = 0; i < ARRAY_SIZE(ureg->domain); i++) { - if (ureg->domain[i].tokens && - ureg->domain[i].tokens != error_tokens) - FREE(ureg->domain[i].tokens); - } - - util_bitmask_destroy(ureg->free_temps); - util_bitmask_destroy(ureg->local_temps); - util_bitmask_destroy(ureg->decl_temps); - - FREE(ureg); -} diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h deleted file mode 100644 index a68af19..0000000 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ /dev/null @@ -1,1206 +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, INC 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 TGSI_UREG_H -#define TGSI_UREG_H - -#include "pipe/p_compiler.h" -#include "pipe/p_shader_tokens.h" -#include "util/u_debug.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct ureg_program; -struct pipe_stream_output_info; - -/* Almost a tgsi_src_register, but we need to pull in the Absolute - * flag from the _ext token. Indirect flag always implies ADDR[0]. - */ -struct ureg_src -{ - unsigned File : 4; /* TGSI_FILE_ */ - unsigned SwizzleX : 2; /* TGSI_SWIZZLE_ */ - unsigned SwizzleY : 2; /* TGSI_SWIZZLE_ */ - unsigned SwizzleZ : 2; /* TGSI_SWIZZLE_ */ - unsigned SwizzleW : 2; /* TGSI_SWIZZLE_ */ - unsigned Indirect : 1; /* BOOL */ - unsigned DimIndirect : 1; /* BOOL */ - unsigned Dimension : 1; /* BOOL */ - unsigned Absolute : 1; /* BOOL */ - unsigned Negate : 1; /* BOOL */ - unsigned IndirectFile : 4; /* TGSI_FILE_ */ - unsigned IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */ - unsigned DimIndFile : 4; /* TGSI_FILE_ */ - unsigned DimIndSwizzle : 2; /* TGSI_SWIZZLE_ */ - int Index : 16; /* SINT */ - int IndirectIndex : 16; /* SINT */ - int DimensionIndex : 16; /* SINT */ - int DimIndIndex : 16; /* SINT */ - unsigned ArrayID : 10; /* UINT */ -}; - -/* Very similar to a tgsi_dst_register, removing unsupported fields - * and adding a Saturate flag. It's easier to push saturate into the - * destination register than to try and create a _SAT variant of each - * instruction function. - */ -struct ureg_dst -{ - unsigned File : 4; /* TGSI_FILE_ */ - unsigned WriteMask : 4; /* TGSI_WRITEMASK_ */ - unsigned Indirect : 1; /* BOOL */ - unsigned Saturate : 1; /* BOOL */ - unsigned Predicate : 1; - unsigned PredNegate : 1; /* BOOL */ - unsigned PredSwizzleX : 2; /* TGSI_SWIZZLE_ */ - unsigned PredSwizzleY : 2; /* TGSI_SWIZZLE_ */ - unsigned PredSwizzleZ : 2; /* TGSI_SWIZZLE_ */ - unsigned PredSwizzleW : 2; /* TGSI_SWIZZLE_ */ - int Index : 16; /* SINT */ - int IndirectIndex : 16; /* SINT */ - unsigned IndirectFile : 4; /* TGSI_FILE_ */ - int IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */ - unsigned ArrayID : 10; /* UINT */ -}; - -struct pipe_context; - -struct ureg_program * -ureg_create( unsigned processor ); - -const struct tgsi_token * -ureg_finalize( struct ureg_program * ); - -/* Create and return a shader: - */ -void * -ureg_create_shader( struct ureg_program *, - struct pipe_context *pipe, - const struct pipe_stream_output_info *so ); - - -/* Alternately, return the built token stream and hand ownership of - * that memory to the caller: - */ -const struct tgsi_token * -ureg_get_tokens( struct ureg_program *ureg, - unsigned *nr_tokens ); - -/* - * Returns the number of currently declared outputs. - */ -unsigned -ureg_get_nr_outputs( const struct ureg_program *ureg ); - - -/* Free the tokens created by ureg_get_tokens() */ -void ureg_free_tokens( const struct tgsi_token *tokens ); - - -void -ureg_destroy( struct ureg_program * ); - - -/*********************************************************************** - * Convenience routine: - */ -static inline void * -ureg_create_shader_with_so_and_destroy( struct ureg_program *p, - struct pipe_context *pipe, - const struct pipe_stream_output_info *so ) -{ - void *result = ureg_create_shader( p, pipe, so ); - ureg_destroy( p ); - return result; -} - -static inline void * -ureg_create_shader_and_destroy( struct ureg_program *p, - struct pipe_context *pipe ) -{ - return ureg_create_shader_with_so_and_destroy(p, pipe, NULL); -} - - -/*********************************************************************** - * Build shader properties: - */ - -void -ureg_property(struct ureg_program *ureg, unsigned name, unsigned value); - - -/*********************************************************************** - * Build shader declarations: - */ - -struct ureg_src -ureg_DECL_fs_input_cyl_centroid(struct ureg_program *, - unsigned semantic_name, - unsigned semantic_index, - unsigned interp_mode, - unsigned cylindrical_wrap, - unsigned interp_location); - -static inline struct ureg_src -ureg_DECL_fs_input_cyl(struct ureg_program *ureg, - unsigned semantic_name, - unsigned semantic_index, - unsigned interp_mode, - unsigned cylindrical_wrap) -{ - return ureg_DECL_fs_input_cyl_centroid(ureg, - semantic_name, - semantic_index, - interp_mode, - cylindrical_wrap, - 0); -} - -static inline struct ureg_src -ureg_DECL_fs_input(struct ureg_program *ureg, - unsigned semantic_name, - unsigned semantic_index, - unsigned interp_mode) -{ - return ureg_DECL_fs_input_cyl_centroid(ureg, - semantic_name, - semantic_index, - interp_mode, - 0, 0); -} - -struct ureg_src -ureg_DECL_vs_input( struct ureg_program *, - unsigned index ); - -struct ureg_src -ureg_DECL_gs_input(struct ureg_program *, - unsigned index, - unsigned semantic_name, - unsigned semantic_index); - -struct ureg_src -ureg_DECL_system_value(struct ureg_program *, - unsigned index, - unsigned semantic_name, - unsigned semantic_index); - -struct ureg_dst -ureg_DECL_output_masked( struct ureg_program *, - unsigned semantic_name, - unsigned semantic_index, - unsigned usage_mask ); - -struct ureg_dst -ureg_DECL_output( struct ureg_program *, - unsigned semantic_name, - unsigned semantic_index ); - -struct ureg_src -ureg_DECL_immediate( struct ureg_program *, - const float *v, - unsigned nr ); - -struct ureg_src -ureg_DECL_immediate_uint( struct ureg_program *, - const unsigned *v, - unsigned nr ); - -struct ureg_src -ureg_DECL_immediate_block_uint( struct ureg_program *, - const unsigned *v, - unsigned nr ); - -struct ureg_src -ureg_DECL_immediate_int( struct ureg_program *, - const int *v, - unsigned nr ); - -void -ureg_DECL_constant2D(struct ureg_program *ureg, - unsigned first, - unsigned last, - unsigned index2D); - -struct ureg_src -ureg_DECL_constant( struct ureg_program *, - unsigned index ); - -void -ureg_DECL_hw_atomic(struct ureg_program *ureg, - unsigned first, - unsigned last, - unsigned buffer_id, - unsigned array_id); - -struct ureg_dst -ureg_DECL_temporary( struct ureg_program * ); - -/** - * Emit a temporary with the LOCAL declaration flag set. For use when - * the register value is not required to be preserved across - * subroutine boundaries. - */ -struct ureg_dst -ureg_DECL_local_temporary( struct ureg_program * ); - -/** - * Declare "size" continuous temporary registers. - */ -struct ureg_dst -ureg_DECL_array_temporary( struct ureg_program *, - unsigned size, - boolean local ); - -void -ureg_release_temporary( struct ureg_program *ureg, - struct ureg_dst tmp ); - -struct ureg_dst -ureg_DECL_address( struct ureg_program * ); - -struct ureg_dst -ureg_DECL_predicate(struct ureg_program *); - -/* Supply an index to the sampler declaration as this is the hook to - * the external pipe_sampler state. Users of this function probably - * don't want just any sampler, but a specific one which they've set - * up state for in the context. - */ -struct ureg_src -ureg_DECL_sampler(struct ureg_program *, - int index ); - -struct ureg_src -ureg_DECL_sampler_view(struct ureg_program *, - unsigned index, - unsigned target, - unsigned return_type_x, - unsigned return_type_y, - unsigned return_type_z, - unsigned return_type_w ); - - -static inline struct ureg_src -ureg_imm4f( struct ureg_program *ureg, - float a, float b, - float c, float d) -{ - float v[4]; - v[0] = a; - v[1] = b; - v[2] = c; - v[3] = d; - return ureg_DECL_immediate( ureg, v, 4 ); -} - -static inline struct ureg_src -ureg_imm3f( struct ureg_program *ureg, - float a, float b, - float c) -{ - float v[3]; - v[0] = a; - v[1] = b; - v[2] = c; - return ureg_DECL_immediate( ureg, v, 3 ); -} - -static inline struct ureg_src -ureg_imm2f( struct ureg_program *ureg, - float a, float b) -{ - float v[2]; - v[0] = a; - v[1] = b; - return ureg_DECL_immediate( ureg, v, 2 ); -} - -static inline struct ureg_src -ureg_imm1f( struct ureg_program *ureg, - float a) -{ - float v[1]; - v[0] = a; - return ureg_DECL_immediate( ureg, v, 1 ); -} - -static inline struct ureg_src -ureg_imm4u( struct ureg_program *ureg, - unsigned a, unsigned b, - unsigned c, unsigned d) -{ - unsigned v[4]; - v[0] = a; - v[1] = b; - v[2] = c; - v[3] = d; - return ureg_DECL_immediate_uint( ureg, v, 4 ); -} - -static inline struct ureg_src -ureg_imm3u( struct ureg_program *ureg, - unsigned a, unsigned b, - unsigned c) -{ - unsigned v[3]; - v[0] = a; - v[1] = b; - v[2] = c; - return ureg_DECL_immediate_uint( ureg, v, 3 ); -} - -static inline struct ureg_src -ureg_imm2u( struct ureg_program *ureg, - unsigned a, unsigned b) -{ - unsigned v[2]; - v[0] = a; - v[1] = b; - return ureg_DECL_immediate_uint( ureg, v, 2 ); -} - -static inline struct ureg_src -ureg_imm1u( struct ureg_program *ureg, - unsigned a) -{ - return ureg_DECL_immediate_uint( ureg, &a, 1 ); -} - -static inline struct ureg_src -ureg_imm4i( struct ureg_program *ureg, - int a, int b, - int c, int d) -{ - int v[4]; - v[0] = a; - v[1] = b; - v[2] = c; - v[3] = d; - return ureg_DECL_immediate_int( ureg, v, 4 ); -} - -static inline struct ureg_src -ureg_imm3i( struct ureg_program *ureg, - int a, int b, - int c) -{ - int v[3]; - v[0] = a; - v[1] = b; - v[2] = c; - return ureg_DECL_immediate_int( ureg, v, 3 ); -} - -static inline struct ureg_src -ureg_imm2i( struct ureg_program *ureg, - int a, int b) -{ - int v[2]; - v[0] = a; - v[1] = b; - return ureg_DECL_immediate_int( ureg, v, 2 ); -} - -static inline struct ureg_src -ureg_imm1i( struct ureg_program *ureg, - int a) -{ - return ureg_DECL_immediate_int( ureg, &a, 1 ); -} - -/* Where the destination register has a valid file, but an empty - * writemask. - */ -static inline boolean -ureg_dst_is_empty( struct ureg_dst dst ) -{ - return dst.File != TGSI_FILE_NULL && - dst.WriteMask == 0; -} - -/*********************************************************************** - * Functions for patching up labels - */ - - -/* Will return a number which can be used in a label to point to the - * next instruction to be emitted. - */ -unsigned -ureg_get_instruction_number( struct ureg_program *ureg ); - - -/* Patch a given label (expressed as a token number) to point to a - * given instruction (expressed as an instruction number). - * - * Labels are obtained from instruction emitters, eg ureg_CAL(). - * Instruction numbers are obtained from ureg_get_instruction_number(), - * above. - */ -void -ureg_fixup_label(struct ureg_program *ureg, - unsigned label_token, - unsigned instruction_number ); - - -/* Generic instruction emitter. Use if you need to pass the opcode as - * a parameter, rather than using the emit_OP() variants below. - */ -void -ureg_insn(struct ureg_program *ureg, - unsigned opcode, - const struct ureg_dst *dst, - unsigned nr_dst, - const struct ureg_src *src, - unsigned nr_src, - unsigned precise ); - - -void -ureg_tex_insn(struct ureg_program *ureg, - unsigned opcode, - const struct ureg_dst *dst, - unsigned nr_dst, - unsigned target, - const struct tgsi_texture_offset *texoffsets, - unsigned nr_offset, - const struct ureg_src *src, - unsigned nr_src ); - - -void -ureg_label_insn(struct ureg_program *ureg, - unsigned opcode, - const struct ureg_src *src, - unsigned nr_src, - unsigned *label); - - -/*********************************************************************** - * Internal instruction helpers, don't call these directly: - */ - -struct ureg_emit_insn_result { - unsigned insn_token; /*< Used to fixup insn size. */ - unsigned extended_token; /*< Used to set the Extended bit, usually the same as insn_token. */ -}; - -struct ureg_emit_insn_result -ureg_emit_insn(struct ureg_program *ureg, - unsigned opcode, - boolean saturate, - unsigned precise, - unsigned num_dst, - unsigned num_src ); - -void -ureg_emit_label(struct ureg_program *ureg, - unsigned insn_token, - unsigned *label_token ); - -void -ureg_emit_texture(struct ureg_program *ureg, - unsigned insn_token, - unsigned target, unsigned num_offsets); - -void -ureg_emit_texture_offset(struct ureg_program *ureg, - const struct tgsi_texture_offset *offset); - -void -ureg_emit_dst( struct ureg_program *ureg, - struct ureg_dst dst ); - -void -ureg_emit_src( struct ureg_program *ureg, - struct ureg_src src ); - -void -ureg_fixup_insn_size(struct ureg_program *ureg, - unsigned insn ); - - -#define OP00( op ) \ -static inline void ureg_##op( struct ureg_program *ureg ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - FALSE, \ - 0, \ - 0, \ - 0); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP01( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_src src ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - FALSE, \ - 0, \ - 0, \ - 1); \ - ureg_emit_src( ureg, src ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP00_LBL( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - unsigned *label_token ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - FALSE, \ - 0, \ - 0, \ - 0); \ - ureg_emit_label( ureg, insn.extended_token, label_token ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP01_LBL( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_src src, \ - unsigned *label_token ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - FALSE, \ - 0, \ - 0, \ - 1); \ - ureg_emit_label( ureg, insn.extended_token, label_token ); \ - ureg_emit_src( ureg, src ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP10( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 0); \ - ureg_emit_dst( ureg, dst ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - - -#define OP11( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - struct ureg_src src ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 1); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP12( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - struct ureg_src src0, \ - struct ureg_src src1 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 2); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP12_TEX( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - unsigned target, \ - struct ureg_src src0, \ - struct ureg_src src1 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 2); \ - ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP12_SAMPLE( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - struct ureg_src src0, \ - struct ureg_src src1 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - unsigned target = TGSI_TEXTURE_UNKNOWN; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 2); \ - ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP13( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - struct ureg_src src0, \ - struct ureg_src src1, \ - struct ureg_src src2 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 3); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_emit_src( ureg, src2 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP13_SAMPLE( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - struct ureg_src src0, \ - struct ureg_src src1, \ - struct ureg_src src2 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - unsigned target = TGSI_TEXTURE_UNKNOWN; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 3); \ - ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_emit_src( ureg, src2 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP14_TEX( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - unsigned target, \ - struct ureg_src src0, \ - struct ureg_src src1, \ - struct ureg_src src2, \ - struct ureg_src src3 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 4); \ - ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_emit_src( ureg, src2 ); \ - ureg_emit_src( ureg, src3 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP14_SAMPLE( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - struct ureg_src src0, \ - struct ureg_src src1, \ - struct ureg_src src2, \ - struct ureg_src src3 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - unsigned target = TGSI_TEXTURE_UNKNOWN; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 4); \ - ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_emit_src( ureg, src2 ); \ - ureg_emit_src( ureg, src3 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - - -#define OP14( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - struct ureg_src src0, \ - struct ureg_src src1, \ - struct ureg_src src2, \ - struct ureg_src src3 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 4); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_emit_src( ureg, src2 ); \ - ureg_emit_src( ureg, src3 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - - -#define OP15( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - struct ureg_src src0, \ - struct ureg_src src1, \ - struct ureg_src src2, \ - struct ureg_src src3, \ - struct ureg_src src4 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 5); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_emit_src( ureg, src2 ); \ - ureg_emit_src( ureg, src3 ); \ - ureg_emit_src( ureg, src4 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -#define OP15_SAMPLE( op ) \ -static inline void ureg_##op( struct ureg_program *ureg, \ - struct ureg_dst dst, \ - struct ureg_src src0, \ - struct ureg_src src1, \ - struct ureg_src src2, \ - struct ureg_src src3, \ - struct ureg_src src4 ) \ -{ \ - unsigned opcode = TGSI_OPCODE_##op; \ - unsigned target = TGSI_TEXTURE_UNKNOWN; \ - struct ureg_emit_insn_result insn; \ - if (ureg_dst_is_empty(dst)) \ - return; \ - insn = ureg_emit_insn(ureg, \ - opcode, \ - dst.Saturate, \ - 0, \ - 1, \ - 5); \ - ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \ - ureg_emit_dst( ureg, dst ); \ - ureg_emit_src( ureg, src0 ); \ - ureg_emit_src( ureg, src1 ); \ - ureg_emit_src( ureg, src2 ); \ - ureg_emit_src( ureg, src3 ); \ - ureg_emit_src( ureg, src4 ); \ - ureg_fixup_insn_size( ureg, insn.insn_token ); \ -} - -/* Use a template include to generate a correctly-typed ureg_OP() - * function for each TGSI opcode: - */ -#include "tgsi_opcode_tmp.h" - - -/*********************************************************************** - * Inline helpers for manipulating register structs: - */ -static inline struct ureg_src -ureg_negate( struct ureg_src reg ) -{ - assert(reg.File != TGSI_FILE_NULL); - reg.Negate ^= 1; - return reg; -} - -static inline struct ureg_src -ureg_abs( struct ureg_src reg ) -{ - assert(reg.File != TGSI_FILE_NULL); - reg.Absolute = 1; - reg.Negate = 0; - return reg; -} - -static inline struct ureg_src -ureg_swizzle( struct ureg_src reg, - int x, int y, int z, int w ) -{ - unsigned swz = ( (reg.SwizzleX << 0) | - (reg.SwizzleY << 2) | - (reg.SwizzleZ << 4) | - (reg.SwizzleW << 6)); - - assert(reg.File != TGSI_FILE_NULL); - assert(x < 4); - assert(y < 4); - assert(z < 4); - assert(w < 4); - - reg.SwizzleX = (swz >> (x*2)) & 0x3; - reg.SwizzleY = (swz >> (y*2)) & 0x3; - reg.SwizzleZ = (swz >> (z*2)) & 0x3; - reg.SwizzleW = (swz >> (w*2)) & 0x3; - return reg; -} - -static inline struct ureg_src -ureg_scalar( struct ureg_src reg, int x ) -{ - return ureg_swizzle(reg, x, x, x, x); -} - -static inline struct ureg_dst -ureg_writemask( struct ureg_dst reg, - unsigned writemask ) -{ - assert(reg.File != TGSI_FILE_NULL); - reg.WriteMask &= writemask; - return reg; -} - -static inline struct ureg_dst -ureg_saturate( struct ureg_dst reg ) -{ - assert(reg.File != TGSI_FILE_NULL); - reg.Saturate = 1; - return reg; -} - -static inline struct ureg_dst -ureg_predicate(struct ureg_dst reg, - boolean negate, - unsigned swizzle_x, - unsigned swizzle_y, - unsigned swizzle_z, - unsigned swizzle_w) -{ - assert(reg.File != TGSI_FILE_NULL); - reg.Predicate = 1; - reg.PredNegate = negate; - reg.PredSwizzleX = swizzle_x; - reg.PredSwizzleY = swizzle_y; - reg.PredSwizzleZ = swizzle_z; - reg.PredSwizzleW = swizzle_w; - return reg; -} - -static inline struct ureg_dst -ureg_dst_indirect( struct ureg_dst reg, struct ureg_src addr ) -{ - assert(reg.File != TGSI_FILE_NULL); - assert(addr.File == TGSI_FILE_ADDRESS || addr.File == TGSI_FILE_TEMPORARY); - reg.Indirect = 1; - reg.IndirectFile = addr.File; - reg.IndirectIndex = addr.Index; - reg.IndirectSwizzle = addr.SwizzleX; - return reg; -} - -static inline struct ureg_src -ureg_src_indirect( struct ureg_src reg, struct ureg_src addr ) -{ - assert(reg.File != TGSI_FILE_NULL); - assert(addr.File == TGSI_FILE_ADDRESS || addr.File == TGSI_FILE_TEMPORARY); - reg.Indirect = 1; - reg.IndirectFile = addr.File; - reg.IndirectIndex = addr.Index; - reg.IndirectSwizzle = addr.SwizzleX; - return reg; -} - -static inline struct ureg_src -ureg_src_dimension( struct ureg_src reg, int index ) -{ - assert(reg.File != TGSI_FILE_NULL); - reg.Dimension = 1; - reg.DimIndirect = 0; - reg.DimensionIndex = index; - return reg; -} - - -static inline struct ureg_src -ureg_src_dimension_indirect( struct ureg_src reg, struct ureg_src addr, - int index ) -{ - assert(reg.File != TGSI_FILE_NULL); - reg.Dimension = 1; - reg.DimIndirect = 1; - reg.DimensionIndex = index; - reg.DimIndFile = addr.File; - reg.DimIndIndex = addr.Index; - reg.DimIndSwizzle = addr.SwizzleX; - return reg; -} - -static inline struct ureg_dst -ureg_dst_array_offset( struct ureg_dst reg, int offset ) -{ - assert(reg.File == TGSI_FILE_TEMPORARY); - reg.Index += offset; - return reg; -} - -static inline struct ureg_dst -ureg_dst( struct ureg_src src ) -{ - struct ureg_dst dst; - - assert(!src.Indirect || - (src.IndirectFile == TGSI_FILE_ADDRESS || - src.IndirectFile == TGSI_FILE_TEMPORARY)); - - dst.File = src.File; - dst.WriteMask = TGSI_WRITEMASK_XYZW; - dst.IndirectFile = src.IndirectFile; - dst.Indirect = src.Indirect; - dst.IndirectIndex = src.IndirectIndex; - dst.IndirectSwizzle = src.IndirectSwizzle; - dst.Saturate = 0; - dst.Index = src.Index; - dst.ArrayID = src.ArrayID; - - return dst; -} - -static inline struct ureg_src -ureg_src_register(unsigned file, - unsigned index) -{ - struct ureg_src src; - - src.File = file; - src.SwizzleX = TGSI_SWIZZLE_X; - src.SwizzleY = TGSI_SWIZZLE_Y; - src.SwizzleZ = TGSI_SWIZZLE_Z; - src.SwizzleW = TGSI_SWIZZLE_W; - src.Indirect = 0; - src.IndirectFile = TGSI_FILE_NULL; - src.IndirectIndex = 0; - src.IndirectSwizzle = 0; - src.Absolute = 0; - src.Index = index; - src.Negate = 0; - src.Dimension = 0; - src.DimensionIndex = 0; - src.DimIndirect = 0; - src.DimIndFile = TGSI_FILE_NULL; - src.DimIndIndex = 0; - src.DimIndSwizzle = 0; - src.ArrayID = 0; - - return src; -} - -static inline struct ureg_src -ureg_src( struct ureg_dst dst ) -{ - struct ureg_src src; - - src.File = dst.File; - src.SwizzleX = TGSI_SWIZZLE_X; - src.SwizzleY = TGSI_SWIZZLE_Y; - src.SwizzleZ = TGSI_SWIZZLE_Z; - src.SwizzleW = TGSI_SWIZZLE_W; - src.Indirect = dst.Indirect; - src.IndirectFile = dst.IndirectFile; - src.IndirectIndex = dst.IndirectIndex; - src.IndirectSwizzle = dst.IndirectSwizzle; - src.Absolute = 0; - src.Index = dst.Index; - src.Negate = 0; - src.Dimension = 0; - src.DimensionIndex = 0; - src.DimIndirect = 0; - src.DimIndFile = TGSI_FILE_NULL; - src.DimIndIndex = 0; - src.DimIndSwizzle = 0; - src.ArrayID = dst.ArrayID; - - return src; -} - - - -static inline struct ureg_dst -ureg_dst_undef( void ) -{ - struct ureg_dst dst; - - dst.File = TGSI_FILE_NULL; - dst.WriteMask = 0; - dst.Indirect = 0; - dst.IndirectFile = TGSI_FILE_NULL; - dst.IndirectIndex = 0; - dst.IndirectSwizzle = 0; - dst.Saturate = 0; - dst.Index = 0; - dst.ArrayID = 0; - - return dst; -} - -static inline struct ureg_src -ureg_src_undef( void ) -{ - struct ureg_src src; - - src.File = TGSI_FILE_NULL; - src.SwizzleX = 0; - src.SwizzleY = 0; - src.SwizzleZ = 0; - src.SwizzleW = 0; - src.Indirect = 0; - src.IndirectFile = TGSI_FILE_NULL; - src.IndirectIndex = 0; - src.IndirectSwizzle = 0; - src.Absolute = 0; - src.Index = 0; - src.Negate = 0; - src.Dimension = 0; - src.DimensionIndex = 0; - src.DimIndirect = 0; - src.DimIndFile = TGSI_FILE_NULL; - src.DimIndIndex = 0; - src.DimIndSwizzle = 0; - src.ArrayID = 0; - - return src; -} - -static inline boolean -ureg_src_is_undef( struct ureg_src src ) -{ - return src.File == TGSI_FILE_NULL; -} - -static inline boolean -ureg_dst_is_undef( struct ureg_dst dst ) -{ - return dst.File == TGSI_FILE_NULL; -} - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/gallium/auxiliary/util/rgtc.c b/src/gallium/auxiliary/util/rgtc.c deleted file mode 100644 index 6886ac0..0000000 --- a/src/gallium/auxiliary/util/rgtc.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2011 Red Hat Inc. - * - * block compression parts are: - * Copyright (C) 2004 Roland Scheidegger 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, 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. - * - * Author: - * Dave Airlie - */ - -#include -#include "macros.h" - -#include "rgtc.h" - -#define RGTC_DEBUG 0 - -#define TAG(x) util_format_unsigned_##x - -#define TYPE unsigned char -#define T_MIN 0 -#define T_MAX 0xff - -#include "texcompress_rgtc_tmp.h" - -#undef TAG -#undef TYPE -#undef T_MIN -#undef T_MAX - -#define TAG(x) util_format_signed_##x -#define TYPE signed char -#define T_MIN (signed char)-128 -#define T_MAX (signed char)127 - -#include "texcompress_rgtc_tmp.h" - -#undef TAG -#undef TYPE -#undef T_MIN -#undef T_MAX - diff --git a/src/gallium/auxiliary/util/rgtc.h b/src/gallium/auxiliary/util/rgtc.h deleted file mode 100644 index 6bba9f2..0000000 --- a/src/gallium/auxiliary/util/rgtc.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright © 2014 Red Hat - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - */ - -#ifndef _RGTC_H -#define _RGTC_H - -void util_format_unsigned_fetch_texel_rgtc(unsigned srcRowStride, const unsigned char *pixdata, - unsigned i, unsigned j, unsigned char *value, unsigned comps); - -void util_format_signed_fetch_texel_rgtc(unsigned srcRowStride, const signed char *pixdata, - unsigned i, unsigned j, signed char *value, unsigned comps); - -void util_format_unsigned_encode_rgtc_ubyte(unsigned char *blkaddr, unsigned char srccolors[4][4], - int numxpixels, int numypixels); - -void util_format_signed_encode_rgtc_ubyte(signed char *blkaddr, signed char srccolors[4][4], - int numxpixels, int numypixels); -#endif /* _RGTC_H */ diff --git a/src/gallium/auxiliary/util/u_bitmask.c b/src/gallium/auxiliary/util/u_bitmask.c deleted file mode 100644 index b19be29..0000000 --- a/src/gallium/auxiliary/util/u_bitmask.c +++ /dev/null @@ -1,328 +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 - * Generic bitmask implementation. - * - * @author Jose Fonseca - */ - - -#include "pipe/p_compiler.h" -#include "util/u_debug.h" - -#include "util/u_memory.h" -#include "util/u_bitmask.h" - - -typedef uint32_t util_bitmask_word; - - -#define UTIL_BITMASK_INITIAL_WORDS 16 -#define UTIL_BITMASK_BITS_PER_BYTE 8 -#define UTIL_BITMASK_BITS_PER_WORD (sizeof(util_bitmask_word) * UTIL_BITMASK_BITS_PER_BYTE) - - -struct util_bitmask -{ - util_bitmask_word *words; - - /** Number of bits we can currently hold */ - unsigned size; - - /** Number of consecutive bits set at the start of the bitmask */ - unsigned filled; -}; - - -struct util_bitmask * -util_bitmask_create(void) -{ - struct util_bitmask *bm; - - bm = MALLOC_STRUCT(util_bitmask); - if(!bm) - return NULL; - - bm->words = (util_bitmask_word *)CALLOC(UTIL_BITMASK_INITIAL_WORDS, sizeof(util_bitmask_word)); - if(!bm->words) { - FREE(bm); - return NULL; - } - - bm->size = UTIL_BITMASK_INITIAL_WORDS * UTIL_BITMASK_BITS_PER_WORD; - bm->filled = 0; - - return bm; -} - - -/** - * Resize the bitmask if necessary - */ -static inline boolean -util_bitmask_resize(struct util_bitmask *bm, - unsigned minimum_index) -{ - unsigned minimum_size = minimum_index + 1; - unsigned new_size; - util_bitmask_word *new_words; - - /* Check integer overflow */ - if(!minimum_size) - return FALSE; - - if(bm->size >= minimum_size) - return TRUE; - - assert(bm->size % UTIL_BITMASK_BITS_PER_WORD == 0); - new_size = bm->size; - while(new_size < minimum_size) { - new_size *= 2; - /* Check integer overflow */ - if(new_size < bm->size) - return FALSE; - } - assert(new_size); - assert(new_size % UTIL_BITMASK_BITS_PER_WORD == 0); - - new_words = (util_bitmask_word *)REALLOC((void *)bm->words, - bm->size / UTIL_BITMASK_BITS_PER_BYTE, - new_size / UTIL_BITMASK_BITS_PER_BYTE); - if(!new_words) - return FALSE; - - memset(new_words + bm->size/UTIL_BITMASK_BITS_PER_WORD, - 0, - (new_size - bm->size)/UTIL_BITMASK_BITS_PER_BYTE); - - bm->size = new_size; - bm->words = new_words; - - return TRUE; -} - - -/** - * Lazily update the filled. - */ -static inline void -util_bitmask_filled_set(struct util_bitmask *bm, - unsigned index) -{ - assert(bm->filled <= bm->size); - assert(index < bm->size); - - if(index == bm->filled) { - ++bm->filled; - assert(bm->filled <= bm->size); - } -} - -static inline void -util_bitmask_filled_unset(struct util_bitmask *bm, - unsigned index) -{ - assert(bm->filled <= bm->size); - assert(index < bm->size); - - if(index < bm->filled) - bm->filled = index; -} - - -unsigned -util_bitmask_add(struct util_bitmask *bm) -{ - unsigned word; - unsigned bit; - util_bitmask_word mask; - - assert(bm); - - /* linear search for an empty index */ - word = bm->filled / UTIL_BITMASK_BITS_PER_WORD; - bit = bm->filled % UTIL_BITMASK_BITS_PER_WORD; - mask = 1 << bit; - while(word < bm->size / UTIL_BITMASK_BITS_PER_WORD) { - while(bit < UTIL_BITMASK_BITS_PER_WORD) { - if(!(bm->words[word] & mask)) - goto found; - ++bm->filled; - ++bit; - mask <<= 1; - } - ++word; - bit = 0; - mask = 1; - } -found: - - /* grow the bitmask if necessary */ - if(!util_bitmask_resize(bm, bm->filled)) - return UTIL_BITMASK_INVALID_INDEX; - - assert(!(bm->words[word] & mask)); - bm->words[word] |= mask; - - return bm->filled++; -} - - -unsigned -util_bitmask_set(struct util_bitmask *bm, - unsigned index) -{ - unsigned word; - unsigned bit; - util_bitmask_word mask; - - assert(bm); - - /* grow the bitmask if necessary */ - if(!util_bitmask_resize(bm, index)) - return UTIL_BITMASK_INVALID_INDEX; - - word = index / UTIL_BITMASK_BITS_PER_WORD; - bit = index % UTIL_BITMASK_BITS_PER_WORD; - mask = 1 << bit; - - bm->words[word] |= mask; - - util_bitmask_filled_set(bm, index); - - return index; -} - - -void -util_bitmask_clear(struct util_bitmask *bm, - unsigned index) -{ - unsigned word; - unsigned bit; - util_bitmask_word mask; - - assert(bm); - - if(index >= bm->size) - return; - - word = index / UTIL_BITMASK_BITS_PER_WORD; - bit = index % UTIL_BITMASK_BITS_PER_WORD; - mask = 1 << bit; - - bm->words[word] &= ~mask; - - util_bitmask_filled_unset(bm, index); -} - - -boolean -util_bitmask_get(struct util_bitmask *bm, - unsigned index) -{ - unsigned word = index / UTIL_BITMASK_BITS_PER_WORD; - unsigned bit = index % UTIL_BITMASK_BITS_PER_WORD; - util_bitmask_word mask = 1 << bit; - - assert(bm); - - if(index < bm->filled) { - assert(bm->words[word] & mask); - return TRUE; - } - - if(index >= bm->size) - return FALSE; - - if(bm->words[word] & mask) { - util_bitmask_filled_set(bm, index); - return TRUE; - } - else - return FALSE; -} - - -unsigned -util_bitmask_get_next_index(struct util_bitmask *bm, - unsigned index) -{ - unsigned word = index / UTIL_BITMASK_BITS_PER_WORD; - unsigned bit = index % UTIL_BITMASK_BITS_PER_WORD; - util_bitmask_word mask = 1 << bit; - - if(index < bm->filled) { - assert(bm->words[word] & mask); - return index; - } - - if(index >= bm->size) { - return UTIL_BITMASK_INVALID_INDEX; - } - - /* Do a linear search */ - while(word < bm->size / UTIL_BITMASK_BITS_PER_WORD) { - while(bit < UTIL_BITMASK_BITS_PER_WORD) { - if(bm->words[word] & mask) { - if(index == bm->filled) { - ++bm->filled; - assert(bm->filled <= bm->size); - } - return index; - } - ++index; - ++bit; - mask <<= 1; - } - ++word; - bit = 0; - mask = 1; - } - - return UTIL_BITMASK_INVALID_INDEX; -} - - -unsigned -util_bitmask_get_first_index(struct util_bitmask *bm) -{ - return util_bitmask_get_next_index(bm, 0); -} - - -void -util_bitmask_destroy(struct util_bitmask *bm) -{ - assert(bm); - - FREE(bm->words); - FREE(bm); -} - diff --git a/src/gallium/auxiliary/util/u_bitmask.h b/src/gallium/auxiliary/util/u_bitmask.h deleted file mode 100644 index 98b85dd..0000000 --- a/src/gallium/auxiliary/util/u_bitmask.h +++ /dev/null @@ -1,117 +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 - * Generic bitmask. - * - * @author Jose Fonseca - */ - -#ifndef U_HANDLE_BITMASK_H_ -#define U_HANDLE_BITMASK_H_ - - -#include "pipe/p_compiler.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -#define UTIL_BITMASK_INVALID_INDEX (~0U) - - -/** - * Abstract data type to represent arbitrary set of bits. - */ -struct util_bitmask; - - -struct util_bitmask * -util_bitmask_create(void); - - -/** - * Search a cleared bit and set it. - * - * It searches for the first cleared bit. - * - * Returns the bit index on success, or UTIL_BITMASK_INVALID_INDEX on out of - * memory growing the bitmask. - */ -unsigned -util_bitmask_add(struct util_bitmask *bm); - -/** - * Set a bit. - * - * Returns the input index on success, or UTIL_BITMASK_INVALID_INDEX on out of - * memory growing the bitmask. - */ -unsigned -util_bitmask_set(struct util_bitmask *bm, - unsigned index); - -void -util_bitmask_clear(struct util_bitmask *bm, - unsigned index); - -boolean -util_bitmask_get(struct util_bitmask *bm, - unsigned index); - - -void -util_bitmask_destroy(struct util_bitmask *bm); - - -/** - * Search for the first set bit. - * - * Returns UTIL_BITMASK_INVALID_INDEX if a set bit cannot be found. - */ -unsigned -util_bitmask_get_first_index(struct util_bitmask *bm); - - -/** - * Search for the first set bit, starting from the giving index. - * - * Returns UTIL_BITMASK_INVALID_INDEX if a set bit cannot be found. - */ -unsigned -util_bitmask_get_next_index(struct util_bitmask *bm, - unsigned index); - - -#ifdef __cplusplus -} -#endif - -#endif /* U_HANDLE_BITMASK_H_ */ diff --git a/src/gallium/meson.build b/src/gallium/meson.build index a5b7588..23441ed 100644 --- a/src/gallium/meson.build +++ b/src/gallium/meson.build @@ -32,7 +32,6 @@ sources_libgallium = [ 'auxiliary/util/u_format.h', 'auxiliary/util/u_rect.h', 'auxiliary/util/u_surface.h', - 'auxiliary/util/rgtc.h', 'auxiliary/util/u_format.c', 'auxiliary/util/u_inlines.h', 'auxiliary/util/u_texture.c', @@ -46,8 +45,6 @@ sources_libgallium = [ 'auxiliary/util/u_pack_color.h', 'auxiliary/util/u_double_list.h', 'auxiliary/util/u_debug_refcnt.h', - 'auxiliary/util/u_bitmask.c', - 'auxiliary/util/u_bitmask.h', 'auxiliary/util/u_format_s3tc.h', 'auxiliary/util/u_surface.c', 'auxiliary/util/u_half.h', @@ -58,9 +55,7 @@ sources_libgallium = [ 'auxiliary/cso_cache/cso_cache.h', 'auxiliary/cso_cache/cso_cache.c', 'auxiliary/cso_cache/cso_hash.c', - 'auxiliary/tgsi/tgsi_opcode_tmp.h', 'auxiliary/tgsi/tgsi_dump.c', - 'auxiliary/tgsi/tgsi_ureg.c', 'auxiliary/tgsi/tgsi_build.c', 'auxiliary/tgsi/tgsi_build.h', 'auxiliary/tgsi/tgsi_util.h', @@ -70,9 +65,7 @@ sources_libgallium = [ 'auxiliary/tgsi/tgsi_parse.h', 'auxiliary/tgsi/tgsi_text.h', 'auxiliary/tgsi/tgsi_strings.h', - 'auxiliary/tgsi/tgsi_ureg.h', 'auxiliary/tgsi/tgsi_parse.c', - 'auxiliary/tgsi/tgsi_transform.h', 'auxiliary/tgsi/tgsi_info.h', 'auxiliary/tgsi/tgsi_text.c', 'auxiliary/tgsi/tgsi_strings.c', @@ -82,8 +75,6 @@ sources_libgallium = [ 'auxiliary/tgsi/tgsi_dump.h', 'auxiliary/tgsi/tgsi_util.c', 'auxiliary/tgsi/tgsi_sanity.h', - 'auxiliary/tgsi/tgsi_transform.c', - 'auxiliary/os/os_mman.h', ] inc_gallium = include_directories('include', 'auxiliary', 'auxiliary/util')