Path: blob/21.2-virgl/src/gallium/auxiliary/tgsi/tgsi_iterate.c
4565 views
/**************************************************************************1*2* Copyright 2008 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#include "util/u_debug.h"28#include "tgsi_iterate.h"2930boolean31tgsi_iterate_shader(32const struct tgsi_token *tokens,33struct tgsi_iterate_context *ctx )34{35struct tgsi_parse_context parse;3637if (tgsi_parse_init( &parse, tokens ) != TGSI_PARSE_OK)38return FALSE;3940ctx->processor = parse.FullHeader.Processor;4142if (ctx->prolog)43if (!ctx->prolog( ctx ))44goto fail;4546while (!tgsi_parse_end_of_tokens( &parse )) {47tgsi_parse_token( &parse );4849switch (parse.FullToken.Token.Type) {50case TGSI_TOKEN_TYPE_INSTRUCTION:51if (ctx->iterate_instruction)52if (!ctx->iterate_instruction( ctx, &parse.FullToken.FullInstruction ))53goto fail;54break;5556case TGSI_TOKEN_TYPE_DECLARATION:57if (ctx->iterate_declaration)58if (!ctx->iterate_declaration( ctx, &parse.FullToken.FullDeclaration ))59goto fail;60break;6162case TGSI_TOKEN_TYPE_IMMEDIATE:63if (ctx->iterate_immediate)64if (!ctx->iterate_immediate( ctx, &parse.FullToken.FullImmediate ))65goto fail;66break;6768case TGSI_TOKEN_TYPE_PROPERTY:69if (ctx->iterate_property)70if (!ctx->iterate_property( ctx, &parse.FullToken.FullProperty ))71goto fail;72break;7374default:75assert( 0 );76}77}7879if (ctx->epilog)80if (!ctx->epilog( ctx ))81goto fail;8283tgsi_parse_free( &parse );84return TRUE;8586fail:87tgsi_parse_free( &parse );88return FALSE;89}909192